Administrator 2 年之前
父節點
當前提交
2ccc471197
共有 3 個文件被更改,包括 61 次插入2 次删除
  1. 3 0
      pages/index/index.js
  2. 52 1
      pages/me/me.js
  3. 6 1
      pages/me/me.wxml

+ 3 - 0
pages/index/index.js

@@ -228,6 +228,9 @@ Page({
         console.log("ffff", res)
       }
     })
+  },
+  onTabItemTap(item){
+    console.log("$$$$$$$",item)
   }
 
 

+ 52 - 1
pages/me/me.js

@@ -1,12 +1,63 @@
 import http from '../../base/httputil'
+const app = getApp()
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-
+    isShowAccoutDialog : false
+  },
+  init_userInfo() {
+    let that = this
+    if (app.globalToken == null) {
+      http.showLoading()
+      wx.getUserProfile({
+        desc: 'desc',
+        success: (res) => {
+          this.getSysUserInfo(res.userInfo)
+        },
+        fail: res => {
+          console.log(res)
+        },
+      })
+    }
+  },
+  getSysUserInfo(info) {
+    let that = this
+    wx.login({
+      success(res) {
+        var code = res.code
+        var data = {
+          wxCode: code,
+          wxNickName: info.nickName,
+          wxAvatarUrl: info.avatarUrl
+        }
+        http.send_post("/auth/applogin", data, that.loginSuccess)
+      },
+      fail(res) {
+        console.log("ffff", res)
+      }
+    })
   },
+  loginSuccess(res) {
+    console.log("rrrr",res)
+    if (res.data.code != 200) {
+      wx.showToast({
+        title: res.data.msg,
+        icon: "none"
+      })
+    } else {
+      app.globalToken = res.data.data.access_token
+      console.log("我的令牌:",app.globalToken )
+      //登录成功,获取首页数据
+      http.hideLoading()
+      this.setData({
+        isShowAccoutDialog : true
+      })
+    }
+  },
+
   /**
    * 生命周期函数--监听页面加载
    */

+ 6 - 1
pages/me/me.wxml

@@ -3,5 +3,10 @@
   <open-data type="userAvatarUrl"></open-data>
   <open-data type="userNickName" lang="zh_CN"></open-data>
 
-  <button>绑定账号</button>
+  <button bindtap="init_userInfo">绑定账号</button>
+
+  <view wx:if="{{isShowAccoutDialog}}">
+    账号<input/>
+    密码<input/>
+  </view>
 </view>