【bug】 bug修改 微信扫描二维码签到登录后跳转的问题

This commit is contained in:
fengachen
2022-01-07 14:56:47 +08:00
parent 877622c36b
commit 878f8b52ec
9 changed files with 240 additions and 103 deletions
+24
View File
@@ -54,4 +54,28 @@ export function isLogin(callback) {
})
}
})
}
/**
* @description 微信扫描二维码的签到 检验是否登录
* @param successCallback 确定登录后的回调
* @param meetingId 失败后 需要将meetingId 存入缓存 为了下次登录后跳转 签到页面 接口获取信息用
*/
export function isLoginSignIn(successCallback,meetingId) {
wx.getStorage({
key: 'X-Access-Token',
success(res) {
successCallback()
},
fail() {
// 设置是否是签到的登录
wx.setStorage({
key:"isSignLogin",
data:meetingId
})
wx.navigateTo({
url: '../login/login',
})
}
})
}
+17 -5
View File
@@ -52,25 +52,37 @@ Page({
})
return
}
// 邮编
if (formData.postalCode === '') {
// 银行账号
if (formData.bankAccount === '') {
wx.showToast({
title: '请输入邮编',
title: '请输入银行账号',
icon: 'none',
duration: 800
})
return
}
if(this.data.flag){
// 开户行
if (formData.openingBank === '') {
wx.showToast({
title: '信息输入有误',
title: '请输入开户行',
icon: 'none',
duration: 800
})
return
}
// if(this.data.flag){
// wx.showToast({
// title: '信息输入有误',
// icon: 'none',
// duration: 800
// })
// return
// }
const that = this
let pages = getCurrentPages()
let prevPage = pages[pages.length - 3];
+5 -4
View File
@@ -40,21 +40,22 @@
</view>
<view class="wx-form-item">
<view class="wx-form-label validate">邮编</view>
<view class="wx-form-label">邮政编码</view>
<view class="wx-form-value">
<input name="postalCode" placeholder="请输入邮编" maxlength="6" type="number" bindblur="validatePostCode" data-message='请输入邮编' data-errmsg='请输入正确的邮编' />
<!-- bindblur="validatePostCode" data-message='请输入邮编' data-errmsg='请输入正确的邮编'-->
<input name="postalCode" placeholder="请输入邮政编码:" maxlength="6" type="number" />
</view>
</view>
<view class="wx-form-item">
<view class="wx-form-label">银行账号:</view>
<view class="wx-form-label validate">银行账号:</view>
<view class="wx-form-value">
<input name="bankAccount" placeholder="请输入银行账号" maxlength="50" type="number" />
</view>
</view>
<view class="wx-form-item">
<view class="wx-form-label">开户行:</view>
<view class="wx-form-label validate">开户行:</view>
<view class="wx-form-value">
<input name="openingBank" placeholder="请输入开户行" maxlength="50" />
</view>
+81 -42
View File
@@ -1,8 +1,14 @@
// pages/mine/mine.js
import UserApi from '../../assets/js/http/userApi'
import { encrypt } from '../../assets/js/jsencrypt/rsa'
import { wxBind } from '../../assets/js/common'
import {appletName} from "../../assets/js/project.config"
import {
encrypt
} from '../../assets/js/jsencrypt/rsa'
import {
wxBind
} from '../../assets/js/common'
import {
appletName
} from "../../assets/js/project.config"
var countdown = 60; // 倒计时秒数
Page({
data: {
@@ -12,7 +18,7 @@ Page({
openId: '',
count: 60,
userInfoTemp: '',
appletName:appletName,
appletName: appletName,
rsaPublicKey: '',
showGetCaptcha: true,
authorize: false // 默认没有微信授权
@@ -63,7 +69,7 @@ Page({
}
},
// 倒计时
countDown(){
countDown() {
if (countdown === 0) {
this.setData({
showGetCaptcha: true
@@ -85,12 +91,12 @@ Page({
// 倒计时 end
},
// 手机号密码登录页
phonePassword(){
phonePassword() {
wx.navigateTo({
url: '../phonePassword/phonePassword',
})
},
goBack(){
goBack() {
wx.navigateBack()
},
@@ -101,24 +107,24 @@ Page({
})
},
// 微信登录
wxLogin(){
wxLogin() {
const that = this
wx.getStorage({
key: 'authorize',
success(result){
success(result) {
// 做过查看微信用户信息
if(result.data){ // 做过用户信息获取
if (result.data) { // 做过用户信息获取
wx.showToast({
title: '登录中...',
icon: 'loading'
})
wxBind((res)=>{
wxBind((res) => {
let params = {
openId: encrypt(that.data.rsaPublicKey,res.result.openid),
openId: encrypt(that.data.rsaPublicKey, res.result.openid),
rsaPublicKey: that.data.rsaPublicKey
}
UserApi.wxLogin(params).then(res=>{
if(res.success) {// 已经用手机号登录过,此时用微信快捷登录时,把微信的个人信息存进缓存(微信信息在缓存的userInfoTemp)
UserApi.wxLogin(params).then(res => {
if (res.success) { // 已经用手机号登录过,此时用微信快捷登录时,把微信的个人信息存进缓存(微信信息在缓存的userInfoTemp)
wx.setStorageSync('userInfo', res.result.userInfo)
wx.setStorage({
key: 'X-Access-Token',
@@ -129,10 +135,26 @@ Page({
key: 'avatarUrl',
data: result.avatarUrl
})
wx.switchTab({
url: '../home/home',
// 判断是否是微信扫描二维码签到 的登录 如果是 需要跳转到签到页面
wx.getStorage({
key: 'isSignLogin',
success(res) {
console.log(res.data)
if (res.data) {
wx.navigateTo({
url: `../scanSign/scanSign?isLoginSignIn=${res.data}`,
})
}
},
fail() {
console.log('fail');
// 跳转首页
wx.switchTab({
url: '../home/home',
})
}
})
}else{ // 首次登录不能直接用微信快捷登录
} else { // 首次登录不能直接用微信快捷登录
wx.showToast({
title: '暂无授权手机号',
icon: 'none'
@@ -140,18 +162,18 @@ Page({
}
})
})
}else{
} else {
that.getUserInfo()
}
},
fail(err){
fail(err) {
// 没有做过查看微信用户信息
that.getUserInfo()
}
})
},
// 获取用户信息,微信登录
getUserInfo(){
getUserInfo() {
const that = this
wx.showModal({
title: '温馨提示',
@@ -160,7 +182,7 @@ Page({
if (res.confirm) {
wx.getUserProfile({
desc: '获取你的昵称、头像、地区及性别',
success(result){
success(result) {
let userInfoTemp = JSON.parse(result.rawData)
wx.setStorage({
key: 'userInfoTemp',
@@ -173,14 +195,14 @@ Page({
title: '登录中...',
icon: 'loading'
})
wxBind((res)=>{
wxBind((res) => {
let params = {
openId: encrypt(that.data.rsaPublicKey,res.result.openid),
openId: encrypt(that.data.rsaPublicKey, res.result.openid),
rsaPublicKey: that.data.rsaPublicKey
}
console.log(params.openId,'params.openiD');
UserApi.wxLogin(params).then(res=>{
if(res.success) {// 已经用手机号登录过,此时用微信快捷登录时,把微信的个人信息存进缓存(微信信息在缓存的userInfoTemp)
console.log(params.openId, 'params.openiD');
UserApi.wxLogin(params).then(res => {
if (res.success) { // 已经用手机号登录过,此时用微信快捷登录时,把微信的个人信息存进缓存(微信信息在缓存的userInfoTemp)
wx.setStorageSync('userInfo', res.result.userInfo)
wx.setStorage({
key: 'X-Access-Token',
@@ -191,7 +213,7 @@ Page({
})
wx.setStorageSync('authorize', true) // 设置有过微信授权
wx.setStorageSync('avatarUrl', that.data.userInfoTemp.avatarUrl)
}else{ // 首次登录不能直接用微信快捷登录
} else { // 首次登录不能直接用微信快捷登录
wx.showToast({
title: '暂无授权手机号',
icon: 'none'
@@ -200,7 +222,7 @@ Page({
})
})
},
fail(err){
fail(err) {
wx.setStorageSync('authorize', false)
}
})
@@ -223,7 +245,7 @@ Page({
}
if (e.detail.value.phone && e.detail.value.captcha) {
let params = {
username: encrypt(this.data.rsaPublicKey,e.detail.value.phone), // 手机号加密
username: encrypt(this.data.rsaPublicKey, e.detail.value.phone), // 手机号加密
captcha: e.detail.value.captcha,
rsaPublicKey: this.data.rsaPublicKey
}
@@ -231,7 +253,7 @@ Page({
UserApi.codeLogin(params).then(res => {
if (res.success) {
// 第一次登录系统,需要设置密码
if(res.message === "updatePassword") {
if (res.message === "updatePassword") {
// 存临时token
wx.setStorage({
key: 'token-temp',
@@ -242,7 +264,7 @@ Page({
wx.navigateTo({
url: `../setPassword/setPassword?userInfo=${userInfo}`,
})
}else{
} else {
// 存token和userInfo
wx.setStorage({
key: 'X-Access-Token',
@@ -254,10 +276,27 @@ Page({
})
// 绑定微信
this.wxBindPhone()
// 跳转首页
wx.switchTab({
url: '../home/home',
// 判断是否是微信扫描二维码签到 的登录 如果是 需要跳转到签到页面
wx.getStorage({
key: 'isSignLogin',
success(res) {
console.log(res.data)
if (res.data) {
wx.navigateTo({
url: `../scanSign/scanSign?isLoginSignIn=${res.data}`,
})
}
},
fail() {
console.log('fail');
// 跳转首页
wx.switchTab({
url: '../home/home',
})
}
})
}
} else {
wx.showToast({
@@ -277,21 +316,21 @@ Page({
}
},
// 忘记密码
updateInfo(){
updateInfo() {
wx.navigateTo({
url: '../forgetPassword/forgetPassword',
})
},
// 绑定微信
wxBindPhone(){
wxBindPhone() {
const that = this
wxBind((res)=>{
wxBind((res) => {
let params = {
openId: encrypt(that.data.rsaPublicKey,res.result.openid),
openId: encrypt(that.data.rsaPublicKey, res.result.openid),
rsaPublicKey: that.data.rsaPublicKey
}
// 需要判断是否绑定过微信,再进行绑定请求
UserApi.wxBind(params).then(res=>{})
UserApi.wxBind(params).then(res => {})
})
},
// onLoad(){
@@ -312,7 +351,7 @@ Page({
const that = this
wx.getStorage({
key: 'userInfoTemp',
success(res){
success(res) {
that.setData({
userInfoTemp: res.data
})
@@ -327,7 +366,7 @@ Page({
key: 'rsaPublicKey',
data: res.result
})
}else{
} else {
wx.showToast({
title: res.message,
icon: 'none',
@@ -342,4 +381,4 @@ Page({
})
})
}
})
})
+1 -1
View File
@@ -34,7 +34,7 @@
<view class="list-item" wx:for="{{meetingList}}" bindtap="meetingDetail" data-meetinginfo="{{item}}" wx:key="item">
<view class="title">
<text>{{item.meetingName}}</text>
<text>{{item.startTime}}</text>
<text style="min-width:100px">{{item.startTime}}</text>
</view>
<view class="content-text">
<image mode="aspectFill" src="../../assets/images/personnel.png"></image>
@@ -529,9 +529,9 @@
<text>签到时间</text>
<text>{{singInPersonInfo.checkInTime}}</text>
</view>
<view style='width:100%;height:120px'>
<view style='width:100%;height:120px;display:flex;padding-right:30rpx;box-sizing:border-box'>
<text>签到信息</text>
<image style='margin-right:30px' class="back-img" src="{{signImgSrc}}"></image>
<image class="back-img" src="{{signImgSrc}}"></image>
</view>
</view>
<!-- 签到信息end -->
+56 -35
View File
@@ -1,7 +1,11 @@
// pages/meeting/meeting.js
import UserApi from '../../assets/js/http/userApi'
import { encrypt } from '../../assets/js/jsencrypt/rsa'
import { wxBind } from '../../assets/js/common'
import {
encrypt
} from '../../assets/js/jsencrypt/rsa'
import {
wxBind
} from '../../assets/js/common'
Page({
@@ -21,18 +25,20 @@ Page({
rsaPublicKey: '', // 公钥
flag: false
},
showPassword(){
showPassword() {
this.setData({
show: !this.data.show
})
},
goBack(){
goBack() {
wx.navigateBack()
},
// 改变验证码
handleChangeCheckCode() {
this.data.currdatetime = new Date().getTime()
UserApi.sendImage({time: this.data.currdatetime}).then(res=>{
UserApi.sendImage({
time: this.data.currdatetime
}).then(res => {
if (res.success) {
this.setData({
"form.randCodeImage": res.result,
@@ -49,7 +55,7 @@ Page({
})
})
},
clearrepeatval(){
clearrepeatval() {
this.data.vals = []
this.setData({
password: ''
@@ -61,22 +67,22 @@ Page({
const vals = this.data.vals
// 获取当前输入的值
const currentval = e.detail.value.replace(/\s+/g, "")
if(currentval){ // 如果值存在追加到vals中
if (currentval) { // 如果值存在追加到vals中
vals.push(currentval)
}
if(vals.length == 1 ){
const v = vals[vals.length-1].length
if(v > 1){ // 如果第一个的长度就大于1 说明是粘贴过来的
if (vals.length == 1) {
const v = vals[vals.length - 1].length
if (v > 1) { // 如果第一个的长度就大于1 说明是粘贴过来的
this.clearrepeatval()
}
}
if(vals.length > 1){
if (vals.length > 1) {
// 如果值数组大于1 就获取最后一个值长度和倒数第二个值长度
// 比较值长度差如果大于1 则粘贴的
const lastv = vals[vals.length-1].length // 获取最后一个值的长度
const secondv = vals[vals.length-2].length // 获取倒数第二个值得长度
const lastv = vals[vals.length - 1].length // 获取最后一个值的长度
const secondv = vals[vals.length - 2].length // 获取倒数第二个值得长度
const dis = lastv - secondv
if(dis>1){
if (dis > 1) {
this.clearrepeatval()
}
}
@@ -85,7 +91,7 @@ Page({
},
// 提交
formSubmit(e) {
if(!e.detail.value.phone){
if (!e.detail.value.phone) {
this.data.flag = false
wx.showToast({
title: '请输入手机号',
@@ -95,7 +101,7 @@ Page({
return
} else {
let pattern = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
if(!pattern.test(e.detail.value.phone)){
if (!pattern.test(e.detail.value.phone)) {
wx.showToast({
title: '请输入正确的手机号!',
icon: 'none',
@@ -107,7 +113,7 @@ Page({
this.data.flag = true
}
}
if(!e.detail.value.password){
if (!e.detail.value.password) {
this.data.flag = false
wx.showToast({
title: '请输入密码',
@@ -118,7 +124,7 @@ Page({
} else {
this.data.flag = true
}
if(!e.detail.value.captcha){
if (!e.detail.value.captcha) {
this.data.flag = false
wx.showToast({
title: '请输入验证码',
@@ -126,7 +132,7 @@ Page({
duration: 2000
})
return
}else{
} else {
this.data.flag = true
}
console.log('form发生了submit事件,携带数据为:', e.detail.value)
@@ -137,10 +143,10 @@ Page({
captcha: e.detail.value.captcha,
rsaPublicKey: this.data.rsaPublicKey,
}
if(this.data.flag){
if (this.data.flag) {
UserApi.passWordLogin(params).then(res => {
if(res.success){
if(res.message == '请先用手机号登录'){
if (res.success) {
if (res.message == '请先用手机号登录') {
wx.showToast({
title: '首次登录请用验证码方式登录',
icon: 'none'
@@ -149,7 +155,7 @@ Page({
wx.navigateBack()
}, 2000);
return
}else{
} else {
// 绑定微信
this.wxBindPhone()
// 存token和userInfo
@@ -161,12 +167,27 @@ Page({
key: 'userInfo',
data: res.result.userInfo
})
// 跳转首页
wx.switchTab({
url: '../home/home',
// 判断是否是微信扫描二维码签到 的登录 如果是 需要跳转到签到页面
wx.getStorage({
key: 'isSignLogin',
success(res) {
console.log(res.data)
if (res.data) {
wx.navigateTo({
url: `../scanSign/scanSign?isLoginSignIn=${res.data}`,
})
}
},
fail() {
console.log('fail');
// 跳转首页
wx.switchTab({
url: '../home/home',
})
}
})
}
}else{
} else {
wx.showToast({
title: res.message,
icon: 'none'
@@ -175,7 +196,7 @@ Page({
this.handleChangeCheckCode()
}, 2000);
}
}).catch(err=>{
}).catch(err => {
wx.showToast({
title: err.message,
icon: 'none'
@@ -185,23 +206,23 @@ Page({
},
// 绑定微信
wxBindPhone(){
wxBindPhone() {
const that = this
// 获取openid进行手机号和微信的绑定
wxBind((res)=>{
wxBind((res) => {
let params = {
openId: encrypt(that.data.rsaPublicKey, res.result.openid),
rsaPublicKey: that.data.rsaPublicKey
}
// 需要判断是否绑定过微信,再进行绑定请求
UserApi.wxBind(params).then(res=>{})
UserApi.wxBind(params).then(res => {})
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
@@ -219,14 +240,14 @@ Page({
const that = this
wx.getStorage({
key: 'rsaPublicKey',
success (res) {
success(res) {
that.setData({
rsaPublicKey: res.data
})
},
fail: function(){
fail: function () {
// 缓存中没有登录过默认app.json的登录页
}
})
}
})
})
+1 -1
View File
@@ -127,7 +127,7 @@ Page({
})
MeetingApi.meetingList({
workingGroupProjectId: this.data.id,
column: 'pm.createTime',
column: 'createTime',
order: 'desc'
}).then(res => {
if (res.success) {
+53 -13
View File
@@ -1,7 +1,8 @@
import UserApi from '../../assets/js/http/userApi'
import {baseUrl, URL_CONFIG} from '../../assets/js/project.config.js'
import {
isLogin
isLogin,
isLoginSignIn
} from '../../assets/js/common'
Page({
@@ -80,10 +81,10 @@ Page({
// 微信扫码 判断是否登录
if(options.q) {
let url = decodeURIComponent(options.q)
let meetingId = url.split('=')[1]
// 登录过的就直接签到 否则跳转登录页
isLogin( () => {
let url = decodeURIComponent(options.q)
let meetingId = url.split('=')[1]
isLoginSignIn( () => {
// 通过会议id 获取签到信息
UserApi.scanCode({
meetingId
@@ -115,7 +116,8 @@ Page({
})
}
}).catch(err => {})
})
},meetingId)
}
// 这里是会议详情的跳转签到
if(options.type === 'meetingDetail'){
@@ -123,10 +125,10 @@ Page({
UserApi.scanCode({
meetingId
}).then(res => {
wx.showToast({
title: '获取签到信息...',
icon: 'loading'
})
// wx.showToast({
// title: '获取签到信息...',
// icon: 'loading'
// })
if (res.success) {
that.setData({
form:res.result
@@ -148,10 +150,10 @@ Page({
that.setData({
form:res.result
})
wx.showToast({
title: '未查到报名信息...',
icon: 'loading'
})
// wx.showToast({
// title: '未查到报名信息...',
// icon: 'loading'
// })
// 未查到报名信息
that.setData({
isSigned: 0,
@@ -178,6 +180,44 @@ Page({
form
})
}
// 这里是微信扫描失败 重新登录后 跳转签到页面执行的逻辑 isLoginSignIn是会议id
if(options.isLoginSignIn){
//请出缓存中的 isLoginSignIn 防止下次登录出现问题
wx.removeStorage({
key: 'isLoginSignIn',
})
let meetingId = options.isLoginSignIn
UserApi.scanCode({
meetingId
}).then(res => {
if (res.success) {
that.setData({
form:res.result
})
let src
if(res.result.checkFile){ // 签到名回显
src = baseUrl + URL_CONFIG + 'sys/common/download/' + res.result.checkFile
}else{
src = ''
}
this.setData({
isSigned: 1,
src
})
// wx.navigateTo({ // 已报名
// url: `../scanSign/scanSign?signed=1&meeting=${result}`,
// })
} else {
that.setData({
form:res.result
})
// 未查到报名信息
that.setData({
isSigned: 0,
})
}
}).catch(err => {})
}
},
/**