Browse Source

联系客服

zhaoxiaohai 3 years ago
parent
commit
9143f97d64

+ 20 - 3
custom-tab-bar/index.js

@@ -2,8 +2,7 @@ Component({
     /**
      * 组件的属性列表
      */
-    properties: {
-    },
+    properties: {},
 
     /**
      * 组件的初始数据
@@ -35,7 +34,9 @@ Component({
                 text: '我的',
                 url: '/pages/tabbar-pages/user/index'
             }
-        ]
+        ],
+        show: false,
+        phoneNumber: "17757394388"
     },
 
     /**
@@ -44,6 +45,9 @@ Component({
     methods: {
         /* tabbar */
         onChange(event) {
+            if (event.target.dataset.index == 1) return this.setData({
+                show: true
+            })
             this.setData({
                 active: event.target.dataset.index
             });
@@ -57,5 +61,18 @@ Component({
                 active: this.data.tabbarList.findIndex(item => item.url === `/${page.route}`)
             });
         },
+        /* 呼叫电话 */
+        CallOut() {
+            wx.makePhoneCall({
+                phoneNumber: this.data.phoneNumber
+            }).catch((e) => {
+                console.log(123)
+            })
+        },
+        onClose() {
+            this.setData({
+                show: false
+            })
+        },
     }
 })

+ 2 - 1
custom-tab-bar/index.json

@@ -2,6 +2,7 @@
     "component": true,
     "usingComponents": {
         "van-tabbar": "@vant/weapp/tabbar/index",
-        "van-tabbar-item": "@vant/weapp/tabbar-item/index"
+        "van-tabbar-item": "@vant/weapp/tabbar-item/index",
+        "van-dialog": "@vant/weapp/dialog/index"
     }
 }

+ 5 - 1
custom-tab-bar/index.wxml

@@ -1,3 +1,7 @@
 <van-tabbar active="{{ active }}" placeholder>
     <van-tabbar-item bindtap="onChange" data-index="{{index}}" wx:for="{{tabbarList}}" wx:key="index" icon="{{item.icon}}">{{item.text}}</van-tabbar-item>
-</van-tabbar>
+</van-tabbar>
+
+<van-dialog use-slot title="在线客服" show="{{ show }}" confirmButtonText='呼叫' show-cancel-button bind:close="onClose" bind:confirm="CallOut" confirm-button-color="#4BBECF">
+    <view style="text-align: center; height: 150rpx; line-height: 150rpx;">请联系:{{phoneNumber}}</view>
+</van-dialog>

+ 2 - 17
pages/tabbar-pages/customer-service-staff/index.js

@@ -4,25 +4,13 @@ Page({
      * 页面的初始数据
      */
     data: {
-        show: true,
-        phoneNumber: "17757394388"
     },
 
     /**
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {},
-    onClose() {
-        this.setData({
-            show: !this.data.show
-        })
-    },
-    /* 呼叫电话 */
-    CallOut() {
-        wx.makePhoneCall({
-            phoneNumber: this.data.phoneNumber
-        })
-    },
+
     /**
      * 生命周期函数--监听页面初次渲染完成
      */
@@ -34,10 +22,7 @@ Page({
      * 生命周期函数--监听页面显示
      */
     onShow: function () {
-        this.getTabBar().init();
-        this.setData({
-            show: true
-        })
+
     },
 
     /**

+ 1 - 9
pages/tabbar-pages/customer-service-staff/index.wxml

@@ -1,10 +1,2 @@
 <!-- 自定义头部 -->
-<My_navBar></My_navBar>
-
-<view style="position: absolute; top: 48%; width: 100vw; padding: 0 150rpx; box-sizing: border-box;">
-    <van-button plain type="primary" size="large" color='#4BBECF' bindtap="onClose">联系客服</van-button>
-</view>
-
-<van-dialog use-slot title="在线客服" show="{{ show }}" confirmButtonText='呼叫' show-cancel-button bind:close="onClose" bind:confirm="CallOut" confirm-button-color="#4BBECF">
-    <view style="text-align: center; height: 150rpx; line-height: 150rpx;">请联系:{{phoneNumber}}</view>
-</van-dialog>
+<My_navBar></My_navBar>

+ 0 - 5
utils/Http.js

@@ -27,12 +27,7 @@ class HTTP {
                 wx.hideLoading()
             },
             fial: (err) => {
-                console.log(123)
                 reject(err);
-                wx.showToast({
-                    title: '请求失败,请稍后再试',
-                    icon: 'none'
-                })
                 wx.hideLoading();
             }
         })