锦水居民端小程序
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.

124 lines
3.3 KiB

var api = require("../../utils/api.js")
6 years ago
Page({
data: {
gridId: "",
gridName: "",
6 years ago
gridNameArr: [],
formid: "",
resToken: "",
resGridName: "",
inviteUserId: "",
module: ""
6 years ago
},
onLoad: function (options) {
// 上级页面传递过来的gid
console.log(options.gid)
if (options.gid) {
this.setData({
gridId: options.gid,
inviteUserId: options.inviteUserId
})
}
if (options.module) {
this.setData({
module: options.module
})
}
6 years ago
this.getToken(options.gid)
this.getGridName(options.gid)
},
getToken: function () {
6 years ago
let that = this
wx.login({
success (res) {
6 years ago
if (res.code) {
console.log("微信CODE: " + res.code)
6 years ago
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)
6 years ago
// 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("/")
6 years ago
})
})
},
bindGetUserInfo: function () {
// 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'
// })
// })
// }
// })
// }
// })
6 years ago
// } else {
// console.log('拒绝授权')
// wx.redirectTo({
// url: '/pages/index/index'
// })
// // wx.showModal({
// // title: '提示',
// // content: '您点击了拒绝授权,将无法进入小程序,请授权之后再进入!',
// // showCancel: false,
// // confirmText: '返回授权',
// // success: function (res) {
// // if (res.confirm) {
// // console.log('用户点击了“返回授权”')
// // }
// // }
// // })
// }
if (this.data.module != '') {
wx.reLaunch({
url: `/pages/indexNew/indexNew?scene=${this.data.module}`
})
} else {
wx.reLaunch({
url: "/pages/indexNew/indexNew"
})
}
6 years ago
}
})