Просмотр исходного кода

提交代码~

release/210823_需求对对碰
王饶冀 4 лет назад
Родитель
Сommit
7ea1f3f026
2 измененных файлов: 18 добавлений и 25 удалений
  1. 11
    11
      app.js
  2. 7
    14
      pages/login/login.js

+ 11
- 11
app.js Просмотреть файл

// app.js // app.js
App({ App({
onLaunch() { onLaunch() {
// 获取本地用户信息
const userInfo = wx.getStorageSync('userInfo') || null;
if(userInfo){
this.globalData.userInfo = userInfo;
console.log(`从本地拿到的userInfo`)
}

// 版本更新 // 版本更新
const updateManager = wx.getUpdateManager() const updateManager = wx.getUpdateManager()


success: (result) => { success: (result) => {
console.log("微信LOGIN result") console.log("微信LOGIN result")
if (!!result.data && result.data.openid) { if (!!result.data && result.data.openid) {
// this.globalData.openid = result.data.openid;
this.globalData.openid = result.data.openid;
this.globalData.appid = result.data.appid; this.globalData.appid = result.data.appid;
this.globalData.sessionKey = result.data.sessionKey; this.globalData.sessionKey = result.data.sessionKey;
// 获取本地用户信息
const userInfo = wx.getStorageSync('userInfo') || null;
console.log(userInfo,'userInfo')
if(userInfo){
this.globalData.userInfo = userInfo;
}
} }
}
}
}) })
} else { } else {
wx.showToast({ wx.showToast({
}, },
globalData: { globalData: {
userInfo: null, userInfo: null,
openid: "oBkT7vu1Q8l-xsbux_i1FNmRWuJ4",
// openid:"",
// openid: "oBkT7vu1Q8l-xsbux_i1FNmRWuJ4",
openid: "",
appid: "", appid: "",
sessionKey: "", sessionKey: "",
suiteCode: "", suiteCode: "",

+ 7
- 14
pages/login/login.js Просмотреть файл

}, },
// 保存用户信息 // 保存用户信息
appletLogin(iv, encryptedData) { appletLogin(iv, encryptedData) {
wx.showLoading({
title: '登录中...',
mask: true
})
let { nickName, gender, country, city, province, avatarUrl } = this.data.userInfo; let { nickName, gender, country, city, province, avatarUrl } = this.data.userInfo;
$request.get('/com/appletLogin.action', { $request.get('/com/appletLogin.action', {
// openid: app.globalData.openid, // openid: app.globalData.openid,
province, province,
city city
}).then(res => { }).then(res => {
// console.log(res,'保存用户信息返回的Res')
console.log(res,'保存用户信息返回的Res')
this.getUserSession() this.getUserSession()
}).catch(error => { }).catch(error => {
console.log(error, 'error appletLogin') console.log(error, 'error appletLogin')
// 保存个人信息后拿到新数据 // 保存个人信息后拿到新数据
getUserSession() { getUserSession() {
let that = this let that = this
wx.showLoading({
title: '加载中',
mask: true
})
$request.post('/script/getSession.action', {}).then(res => { $request.post('/script/getSession.action', {}).then(res => {
console.log(res, 'getUserSession---res')
wx.hideLoading() wx.hideLoading()
app.globalData.customerId = res.data.customer.customerId
// wx.navigateTo({
// url: "/pages/mine/mine", //跳转页面的路径,可带参数 ?隔开,不同参数用 & 分隔;相对路径,不需要.wxml后缀
// success: function () {}, //成功后的回调;
// fail: function () {}, //失败后的回调;
// complete: function () {} //结束后的回调(成功,失败都会执行)
// })

app.globalData.customerId = res.data.customer.customerId;
wx.navigateBack()
}).catch(error => { }).catch(error => {
console.log(error, "获取error") console.log(error, "获取error")
}) })

Загрузка…
Отмена
Сохранить