You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
941 B

3 years ago
// app.js
const http = require('./api/http.js')
3 years ago
App({
onLaunch() {
// 登录
},
login(){
3 years ago
return new Promise((resolve,reject)=>{
wx.getUserProfile({
lang: 'zh_CN',
desc: '需要获取您的信息用来展示',
success: res => {
wx.showLoading({ title: '登录中' })
wx.login({
success: result => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
let data = {
code: result.code,
iv: res.iv,
encryptedData:res.encryptedData
}
http.$http('post','wxapp/auth',data).then((result)=>{
console.log('数据已返回')
resolve(result)
})
}
3 years ago
})
},
fail: res=>{
console.log('取消授权')
3 years ago
}
})
})
},
globalData: {
$http: http.$http
3 years ago
}
})