登录完善,会议活动筛选分页,扫码签到完善,分标委列表,详情

This commit is contained in:
姚亚男
2021-10-15 18:35:39 +08:00
parent 6ef45b33f7
commit 280db0a273
46 changed files with 785 additions and 474 deletions
+29 -44
View File
@@ -1,6 +1,7 @@
// pages/mine/mine.js
import UserApi from '../../assets/js/http/userApi'
import { encrypt } from '../../assets/js/jsencrypt/rsa'
import { wxBind } from '../../assets/js/common'
var countdown = 60; // 倒计时秒数
Page({
data: {
@@ -79,25 +80,29 @@ Page({
},
// 微信登录
wxLogin(){
let params = {
openId: this.data.openid,
rsaPublicKey: this.data.rsaPublicKey
}
UserApi.wxLogin(params).then(res=>{
if(res.success) {// 已经用手机号登录过,此时用微信快捷登录时,把微信的个人信息存进缓存(微信信息在缓存的userInfoTemp)
wx.getStorage({
key: 'userInfoTemp',
success(result){
console.log(result)
}
})
}else{ // 首次登录不能直接用微信快捷登录
wx.showToast({
title: '暂未授权手机号',
duration: 2000,
icon: "none",
})
wxBind((res)=>{
let params = {
openId: res.data.openid,
rsaPublicKey: this.data.rsaPublicKey
}
UserApi.wxLogin(params).then(res=>{
if(res.success) {// 已经用手机号登录过,此时用微信快捷登录时,把微信的个人信息存进缓存(微信信息在缓存的userInfoTemp)
wx.setStorageSync('userInfo', res.result.userInfo)
wx.setStorage({
key: 'X-Access-Token',
data: res.result.token
})
wx.switchTab({
url: '../home/home',
})
}else{ // 首次登录不能直接用微信快捷登录
wx.showToast({
title: '暂未授权手机号',
duration: 2000,
icon: "none",
})
}
})
})
},
// 登录
@@ -163,33 +168,13 @@ Page({
},
// 绑定微信
wxBind(){
const that = this
// 获取openid进行手机号和微信的绑定
wx.login({
success (res) {
if (res.code) {
//发起网络请求
wx.request({
url: 'https://api.weixin.qq.com/sns/jscode2session',
data: {
appid: 'wx24914e866df035fb',
secret: '0d2830f26f57722716249f2b2236f409',
js_code: res.code,
grant_type: 'authorization_code'
},
success (res) { // 成功拿到openId
// 微信和该账号绑定
let params = {
openId: res.openId,
rsaPublicKey: that.data.rsaPublicKey
}
UserApi.wxBind(params).then(res=>{})
}
})
} else {
console.log('授权失败!' + res.errMsg)
}
wxBind((res)=>{
let params = {
openId: res.data.openid,
rsaPublicKey: that.data.rsaPublicKey
}
// 需要判断是否绑定过微信,再进行绑定请求
UserApi.wxBind(params).then(res=>{})
})
},