Browse Source

个人中心

zhaoxiaohai 3 years ago
parent
commit
b545a4dffa
3 changed files with 81 additions and 53 deletions
  1. 74 47
      pages/tabbar/mine/index.js
  2. 2 3
      pages/tabbar/mine/index.wxml
  3. 5 3
      pages/tabbar/mine/userMsg/index.js

+ 74 - 47
pages/tabbar/mine/index.js

@@ -5,23 +5,9 @@ Page({
      * 页面的初始数据
      */
     data: {
+        wusercenter: false, //个人中心权限
         userMsg: {},
-        pathList: [{
-            name: "团队管理",
-            icon: "icon-a-wodetuanduiguanli",
-            color: "var(--assist)",
-            path: "/pages/teams/index"
-        }, {
-            name: "修改登录密码",
-            icon: "icon-a-wodeguanyuyingyong",
-            color: "var(--warning)",
-            path: "/pages/tabbar/mine/changePassword/index"
-        }, {
-            name: "绑定微信",
-            icon: "icon-a-wodebangdingweixin",
-            color: "var(--success)",
-            path: "#"
-        }]
+        pathList: [], //功能权限
     },
 
     /**
@@ -29,6 +15,45 @@ Page({
      */
     onLoad(options) {
         this.queryUserMsg();
+        let auth = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['通用'], ['个人中心'])[0].apps;
+        let wusercenter = false; //个人中心
+        let pathList = [];
+        auth.forEach(v => {
+            if (v.name == 'wusercenter') {
+                wusercenter = true;
+            } else {
+                switch (v.name) {
+                    case "teamManagement":
+                        pathList.push({
+                            name: "团队管理",
+                            icon: "icon-a-wodetuanduiguanli",
+                            color: "var(--assist)",
+                            path: `/${v.path}`,
+                            meta: v.meta
+                        })
+                        break;
+                    case "changePassword":
+                        pathList.push({
+                            name: "修改登录密码",
+                            icon: "icon-a-wodeguanyuyingyong",
+                            color: "var(--warning)",
+                            path: `/${v.path}`
+                        })
+                        break;
+                    case "wechatAgreement":
+                        pathList.push({
+                            name: "绑定微信",
+                            icon: "icon-a-wodebangdingweixin",
+                            color: "var(--success)"
+                        })
+                        break;
+                }
+            }
+        });
+        this.setData({
+            wusercenter,
+            pathList
+        })
     },
     /* 查询用户信息 */
     queryUserMsg() {
@@ -114,46 +139,48 @@ Page({
             phonenumber,
             attinfos
         } = this.data.userMsg;
+        /* &auth=${JSON.stringify(this.data.wusercenter.meta.auth)} */
         wx.navigateTo({
             url: `./userMsg/index?attinfos=${JSON.stringify(attinfos)}&name=${name}&phonenumber=${phonenumber}`
         })
     },
     listClick(e) {
         const {
-            name
+            item
         } = e.currentTarget.dataset;
         const that = this;
-        if (name == '绑定微信') {
-            wx.showModal({
-                title: "提示",
-                content: "是否使用当前微信绑定此账号?",
-                success: res => {
-                    if (res.confirm) {
-                        wx.login({
-                            success(res) {
-                                if (res.code) _Http.basic({
-                                    "classname": "common.usercenter.usercenter",
-                                    "method": "WechatBinding",
-                                    "content": {
-                                        "wechat_code": res.code
-                                    }
-                                }).then(res => {
-                                    if (res.code == 0) return wx.showToast({
-                                        title: res.msg,
-                                        icon: "none"
-                                    });
-                                    wx.showToast({
-                                        title: '绑定成功',
-                                    })
-                                    that.setData({
-                                        "userMsg.iswechatbinding": true
-                                    })
+        if (item.name == '绑定微信') return wx.showModal({
+            title: "提示",
+            content: "是否使用当前微信绑定此账号?",
+            success: res => {
+                if (res.confirm) {
+                    wx.login({
+                        success(res) {
+                            if (res.code) _Http.basic({
+                                "classname": "common.usercenter.usercenter",
+                                "method": "WechatBinding",
+                                "content": {
+                                    "wechat_code": res.code
+                                }
+                            }).then(res => {
+                                if (res.code == 0) return wx.showToast({
+                                    title: res.msg,
+                                    icon: "none"
+                                });
+                                wx.showToast({
+                                    title: '绑定成功',
                                 })
-                            }
-                        })
-                    }
+                                that.setData({
+                                    "userMsg.iswechatbinding": true
+                                })
+                            })
+                        }
+                    })
                 }
-            })
-        }
+            }
+        });
+        wx.navigateTo({
+            url: item.meta ? `${item.path}?auth=${JSON.stringify(item.meta)}` : item.path
+        })
     }
 })

+ 2 - 3
pages/tabbar/mine/index.wxml

@@ -1,5 +1,5 @@
 <view class="user-box">
-    <My_card custom-class='user-con' hover bindtap="changeUserMsg">
+    <My_card wx:if="{{wusercenter}}" custom-class='user-con' hover bindtap="changeUserMsg">
         <van-image image-class="v-img" round width="128rpx" height="128rpx" src="{{userMsg.attinfos[0].url||'/static/image/user.png'}}" />
         <view class="user-msg">
             <view class="user-name">
@@ -23,7 +23,7 @@
     </My_card>
 </view>
 <My_card custom-class='operating' hover>
-    <navigator class="item" url="{{item.path}}" wx:for="{{pathList}}" data-name="{{item.name}}" bindtap="listClick">
+    <navigator class="item" url="#" wx:for="{{pathList}}" data-item="{{item}}" bindtap="listClick">
         <view class="con">
             <view class="label">
                 <text class="iconfont {{item.icon}}" style="color: {{item.color}};" />
@@ -38,7 +38,6 @@
         </view>
     </navigator>
 </My_card>
-<!-- iswechatbinding -->
 <view style="width: 100vw;text-align: center;margin-top: 200rpx;">
     <van-button custom-class='out-login' color="#CCC" bindtap="outLogin" plain>退出登录</van-button>
 </view>

+ 5 - 3
pages/tabbar/mine/userMsg/index.js

@@ -2,7 +2,6 @@ let time = null;
 const _Http = getApp().globalData.http;
 const MD5 = require('../../../../utils/md5');
 Page({
-
     /**
      * 页面的初始数据
      */
@@ -39,7 +38,10 @@ Page({
      * 生命周期函数--监听页面加载
      */
     onLoad(options) {
-        const that = this;
+        /*         console.log(options)
+                let auth = options.auth ? JSON.parse(options.auth) : {};
+                    auth
+                */
         this.setData({
             attinfos: JSON.parse(options.attinfos),
             "fromList1[0].value": options.name,
@@ -53,7 +55,7 @@ Page({
                 })
             },
             "copyPhonenumber": options.phonenumber
-        })
+        });
     },
     /* from1监听 */
     form1CompletedOrNot({