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
38 lines
941 B
// app.js |
|
const http = require('./api/http.js') |
|
App({ |
|
onLaunch() { |
|
// 登录 |
|
}, |
|
login(){ |
|
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) |
|
}) |
|
} |
|
}) |
|
}, |
|
fail: res=>{ |
|
console.log('取消授权') |
|
} |
|
}) |
|
}) |
|
}, |
|
globalData: { |
|
$http: http.$http |
|
} |
|
}) |