wkw hace 3 semanas
padre
commit
1d3194e48e

+ 12 - 0
custom-tab-bar/index.js

@@ -25,6 +25,15 @@ Component({
       }
     ],
     showShare: false,
+    showAgreementModal:false,
+    programConfig: {}
+  },
+  lifetimes: {
+    attached() {
+      this.setData({
+        programConfig: app.globalData.programConfig
+      });
+    }
   },
   methods: {
     switchTab(e) {
@@ -38,6 +47,9 @@ Component({
     openShare() {
       this.setData({ showShare: true })
     },
+    openShowAgreementModal(){
+      this.setData({ showAgreementModal: true })
+    },
     // 分享逻辑
     onShareAppMessage() {
       return {

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

@@ -1,6 +1,7 @@
 {
   "component": true,
   "usingComponents": {
-    "van-popup": "@vant/weapp/popup/index"
+    "van-popup": "@vant/weapp/popup/index",
+    "van-dialog": "@vant/weapp/dialog/index"
   }
 }

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

@@ -15,10 +15,6 @@
 >
   <view class="share-container">
     <view class="share-options">
-      <!-- <view class="share-item" bindtap="shareToWechat">
-        <image class="share-icon" src="/static/tabbar/weixin.png" mode="aspectFit" />
-        <text class="share-text">微信好友</text>
-      </view> -->
       <button class="share-item" open-type="share">
         <image class="share-icon" src="/static/tabbar/weixin.png" mode="aspectFit" />
         <text class="share-text">微信好友</text>
@@ -33,4 +29,19 @@
       <image class="share-cancel-img" src="/static/tabbar/cancel.png" mode="aspectFit"/>
     </view>
   </view>
-</van-popup>
+</van-popup>
+
+<!-- 客服弹窗 -->
+<van-dialog
+  confirm-button-class="confirm-btn"
+  use-slot
+  title="联系客服"
+  show="{{showAgreementModal}}"
+  show-cancel-button="{{false}}"
+>
+  <view class="dialog-box">
+    <image class="box-code" src="{{programConfig.customer_qrcode}}" mode="aspectFill"></image>
+    <view class="box-text" bindtap="onPhone" wx:if="{{programConfig.customer_phone}}">客服电话:{{programConfig.customer_phone}}</view>
+    <view class="box-text" wx:if="{{programConfig.customer_email}}">客服邮箱:{{programConfig.customer_email}}</view>
+  </view>
+</van-dialog>

+ 23 - 0
custom-tab-bar/index.wxss

@@ -72,3 +72,26 @@
 .share-item::after {
   border: none !important;
 }
+/* 客服弹框样式 */
+.dialog-box{
+  padding: 32rpx;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
+.box-code{
+  width: 264rpx;
+  height: 264rpx;
+  border-radius: 20rpx;
+}
+.box-text{
+  font-weight: 400;
+  font-size: 24rpx;
+  color: #8D8D8D;
+  line-height: 34rpx;
+  margin-top: 32rpx;
+}
+.confirm-btn{
+  width: 100% !important;
+  color: #FDA233 !important;
+}

+ 7 - 3
pages/mine/mine.js

@@ -15,8 +15,7 @@ Page({
     ],
     userInfo: {},
     programConfig:{},
-    baseUrl:BASE_URL,
-    showAgreementModal:false
+    baseUrl:BASE_URL
   },
   goPage(e){
     const index = e.currentTarget.dataset.index;
@@ -30,7 +29,12 @@ Page({
     if (pageMap[index]) {
       wx.navigateTo({ url: pageMap[index] });
     } else if (index === 5) {
-      this.setData({ showAgreementModal: true });
+      const tabbar = this.getTabBar && this.getTabBar();
+      if (tabbar && tabbar.openShowAgreementModal) {
+        tabbar.openShowAgreementModal()
+      } else {
+        console.log("没找到 tabbar 组件")
+      }
     }
   },
   onLoad(options) {

+ 1 - 2
pages/mine/mine.json

@@ -1,8 +1,7 @@
 {
   "usingComponents": {
     "van-image": "@vant/weapp/image/index",
-    "van-cell": "@vant/weapp/cell/index",
-    "van-dialog": "@vant/weapp/dialog/index"
+    "van-cell": "@vant/weapp/cell/index"
   },
   "navigationStyle": "custom"
 }

+ 0 - 14
pages/mine/mine.wxml

@@ -26,18 +26,4 @@
       </view>
     </view>
   </view>
-  <!-- 客服弹窗 -->
-  <van-dialog
-    confirm-button-class="confirm-btn"
-    use-slot
-    title="联系客服"
-    show="{{showAgreementModal}}"
-    show-cancel-button="{{false}}"
-  >
-    <view class="dialog-box">
-      <image class="box-code" src="{{programConfig.customer_qrcode}}" mode="aspectFill"></image>
-      <view class="box-text" bindtap="onPhone" wx:if="{{programConfig.customer_phone}}">客服电话:{{programConfig.customer_phone}}</view>
-      <view class="box-text" wx:if="{{programConfig.customer_email}}">客服邮箱:{{programConfig.customer_email}}</view>
-    </view>
-  </van-dialog>
 </view>

+ 3 - 26
pages/mine/mine.wxss

@@ -94,32 +94,6 @@ page {
 .logo-item{
   margin-bottom: 170rpx;
 }
-/* 客服弹框样式 */
-.van-dialog__header{
-  font-weight: bold !important;
-}
-.dialog-box{
-  padding: 32rpx;
-  display: flex;
-  flex-direction: column;
-  align-items: center;
-}
-.box-code{
-  width: 264rpx;
-  height: 264rpx;
-  border-radius: 20rpx;
-}
-.box-text{
-  font-weight: 400;
-  font-size: 24rpx;
-  color: #8D8D8D;
-  line-height: 34rpx;
-  margin-top: 32rpx;
-}
-.confirm-btn{
-  width: 100% !important;
-  color: #FDA233 !important;
-}
 .avatar-wrapper{
   background: none;
   border: none;
@@ -133,3 +107,6 @@ page {
 button::after {
   border: none;
 }
+.van-dialog__header{
+  font-weight: bold !important;
+}