12345678910111213141516171819202122232425262728293031323334353637 |
- // app.js
- App({
- onLaunch() {
- // 展示本地存储能力
- const logs = wx.getStorageSync('logs') || []
- logs.unshift(Date.now())
- wx.setStorageSync('logs', logs)
- // 登录
- wx.login({
- success: res => {
- // 发送 res.code 到后台换取 openId, sessionKey, unionId
- console.log(res)
- wx.request( {
- url: this.globalData.url + "/v1/user/open.id/set",
- header: {
- "Content-Type": "application/json"
- },
- method: "POST",
- data: { code: res.code },
- complete: function( res ) {
- if (res.data.code == 200){
- wx.setStorageSync('openId', res.data.data.openid)
- }
-
- }
- })
- }
- })
- },
- globalData: {
- userInfo: null,
- //url:"http://127.0.0.1:8081"
- //url:"http://www.tao1024.com:8081"
- url:"https://www.shisanmiao.com"
- }
- })
|