Administrator 2 tahun lalu
induk
melakukan
64e554fbaa
2 mengubah file dengan 68 tambahan dan 11 penghapusan
  1. 52 4
      pages/me/me.js
  2. 16 7
      pages/me/me.wxml

+ 52 - 4
pages/me/me.js

@@ -1,13 +1,26 @@
 import http from '../../base/httputil'
 const app = getApp()
+
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-    isShowAccoutDialog : false
+    isShowAccoutDialog : false,
+    isBindSuccess : false,
+    userInfo:null,
+    userName :null,
+    password: null,
+    openid: null
+  },
+  inputUserName(e){
+    this.userName = e.detail.value
+  },
+  inputPassword(e){
+    this.password = e.detail.value
   },
+
   init_userInfo() {
     let that = this
     if (app.globalToken == null) {
@@ -16,6 +29,9 @@ Page({
         desc: 'desc',
         success: (res) => {
           this.getSysUserInfo(res.userInfo)
+          that.setData({
+            userInfo : res.userInfo
+          })
         },
         fail: res => {
           console.log(res)
@@ -33,6 +49,7 @@ Page({
           wxNickName: info.nickName,
           wxAvatarUrl: info.avatarUrl
         }
+        
         http.send_post("/auth/applogin", data, that.loginSuccess)
       },
       fail(res) {
@@ -41,24 +58,55 @@ Page({
     })
   },
   loginSuccess(res) {
-    console.log("rrrr",res)
+    
+    let that = this
     if (res.data.code != 200) {
+      that.openid = res.data.data
       wx.showToast({
         title: res.data.msg,
         icon: "none"
       })
-      this.setData({
+      http.hideLoading()
+      that.setData({
         isShowAccoutDialog : true
       })
+      
     } else {
       app.globalToken = res.data.data.access_token
       console.log("我的令牌:",app.globalToken )
       //登录成功,获取首页数据
       http.hideLoading()
-    
+      this.setData({
+        isBindSuccess : true
+      })
     }
   },
 
+  modalCancel(){
+    this.setData({
+      isShowAccoutDialog : false
+    })
+  },
+  modalSubmit(){
+    let obj = new Object()
+    obj.openid = this.openid
+    obj.userName = this.userName
+    obj.password = this.password
+    http.send_post("/system/minapp/AppLoginController/bindWxUser",obj,this.modalSubmitSuccess)
+  },
+  modalSubmitSuccess(res){
+    wx.showToast({
+      title: res.data.msg,
+      icon: "none"
+    })
+    if (res.data.code == 200) {
+      this.setData({
+        isShowAccoutDialog : false,
+        isBindSuccess : true
+      })
+    }
+
+  },
   /**
    * 生命周期函数--监听页面加载
    */

+ 16 - 7
pages/me/me.wxml

@@ -1,12 +1,21 @@
 <view class="container_c">
 
-  <open-data type="userAvatarUrl" class="wd_img"></open-data>
-  <open-data type="userNickName" lang="zh_CN" class="wd_txt"></open-data>
 
-  <button bindtap="init_userInfo" class="wd_btn">绑定账号</button>
+  <image src="{{userInfo.avatarUrl}}" class="wd_img"></image>
 
-  <modal wx:if="{{isShowAccoutDialog}}">
-    <view class="vi_inp">账号<input/></view>
-    <view class="vi_inp">密码<input password type="text"/></view>
+  <div type="userNickName" lang="zh_CN" class="wd_txt">
+    {{userInfo.nickName}}
+  </div>
+
+
+  <button wx:if="{{!isBindSuccess}}" bindtap="init_userInfo" class="wd_btn">绑定账号</button>
+  <label wx:if="{{isBindSuccess}}">账号绑定成功</label>
+
+
+
+
+  <modal wx:if="{{isShowAccoutDialog}}" bindcancel="modalCancel" bindconfirm="modalSubmit">
+    <view class="vi_inp">账号<input bindinput="inputUserName" /></view>
+    <view class="vi_inp">密码<input bindinput="inputPassword" password type="text" /></view>
   </modal>
-</view>
+</view>