feiyu02
2022-08-11 a82b8c09ca795a4b6273b03a79ba488f6cce5eb0
微信一键登录

1.完成一键登录部分功能;
已修改2个文件
66 ■■■■■ 文件已修改
pages/module_user/userlogin/userlogin.js 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
project.config.json 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/module_user/userlogin/userlogin.js
@@ -34,7 +34,71 @@
  },
  loginWx() {
    var that = this
    wx.getUserProfile({
      lang: 'zh_CN',
      desc: '用于显示,提示用户当前已登录',
      success(res) {
        //获取缓存的用户账户密码
    wx.getStorage({
      key: 'accessToken',
      success(res) {
        app.globalData.accessToken = res.data
        that.setData({
          userName: res.data.userName,
          password: res.data.password
        })
        userservice.login(that.data.userName, that.data.password, {
          success (data) {
            if (data.success) {
              app.globalData.accessToken = {
                userName: that.data.userName,
                password: that.data.password,
                userId: data.userId,
                suserId: data.suserId,
              }
              wx.setStorage({
                key: 'accessToken',
                data: app.globalData.accessToken,
              })
              that.getUserInfo()
            } else {
              wx.showToast({
                title: '账户或密码错误',
                duration: 1000,
                icon: 'none',
              })
            }
          },
          complete () {
            that.setData({
              loading: false
            })
          }
        })
      },
    })
      }
    })
  },
  getUserInfo() {
    var that = this
    userservice.getUserInfo(app.globalData.accessToken.userId, {
      success(data) {
        app.globalData.userInfo = data
        wx.setStorage({
          key: 'userInfo',
          data: data,
          success: (result) => {
            wx.switchTab({
              url: '/pages/home/home',
            })
          }
        })
      }
    })
  },
  gotoLogin() {
project.config.json
@@ -22,7 +22,7 @@
    "checkSiteMap": true,
    "uploadWithSourceMap": true,
    "compileHotReLoad": false,
    "useMultiFrameRuntime": true,
    "useMultiFrameRuntime": false,
    "useApiHook": true,
    "babelSetting": {
      "ignore": [],