var api = require('../../utils/api.js') var global = require('../../utils/config.js') const app = getApp() Page({ data: { gridId: '', gridName: '', gridNameArr: [], formid: '', resToken: '', resGridName: '', inviteUserId: '' }, onLoad: function (options) { // 上级页面传递过来的gid console.log(options.gid) if (options.gid) { this.setData({ gridId: options.gid, inviteUserId: options.inviteUserId }) } this.getToken(options.gid) this.getGridName(options.gid) }, getToken: function (gid) { let that = this wx.login({ success(res) { if (res.code) { console.log('微信CODE: ' + res.code) let wxCode = res.code const para = { inviteUserId: that.data.inviteUserId, gridId: that.data.gridId, wxCode: res.code } api.getTokenV2(para).then(function (res) { // global.Token = res.data.token wx.removeStorageSync('token') wx.setStorageSync('token', res.data.token) // that.setData({ // resToken: res.data.token, // resGridName: res.data.grid // }) }) } } }) }, getGridName: function (gid) { let that = this api.getCompleteName(gid).then(function (res) { console.log(res.data) wx.setStorage({ key: "gridName", data: res.data }) that.setData({ gridName: res.data, gridNameArr: res.data.split('/') }) }) }, bindGetUserInfo: function (e) { // if (e.detail.userInfo) { // // let wxHeadImg = e.detail.userInfo.avatarUrl // // let wxNickName = e.detail.userInfo.nickName // console.log(e) // let that = this // wx.login({ // success: function (response) { // let code = response.code; // wx.getUserInfo({ // success: function (res) { // console.log(res.encryptedData) // console.log(res.iv) // let encryptedData = res.encryptedData // let iv = res.iv // api.updateWxInfo(code, encryptedData, iv).then(function (res) { // // 跳转到首页 // console.log('跳转到首页') // wx.setStorageSync('isFirst', 'noFirst') // wx.reLaunch({ // url: '/pages/index/index' // }) // }) // } // }) // } // }) // } else { // console.log('拒绝授权') // wx.redirectTo({ // url: '/pages/index/index' // }) // // wx.showModal({ // // title: '提示', // // content: '您点击了拒绝授权,将无法进入小程序,请授权之后再进入!', // // showCancel: false, // // confirmText: '返回授权', // // success: function (res) { // // if (res.confirm) { // // console.log('用户点击了“返回授权”') // // } // // } // // }) // } wx.reLaunch({ url: '/pages/indexNew/indexNew' }) } })