From 878f8b52eca55f6f0746cbe827ae25a3174bdbdf Mon Sep 17 00:00:00 2001 From: fengachen <373943794@qq.com> Date: Fri, 7 Jan 2022 14:56:47 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90bug=E3=80=91=20bug=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=20=20=E5=BE=AE=E4=BF=A1=E6=89=AB=E6=8F=8F=E4=BA=8C=E7=BB=B4?= =?UTF-8?q?=E7=A0=81=E7=AD=BE=E5=88=B0=E7=99=BB=E5=BD=95=E5=90=8E=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/js/common.js | 24 ++++ pages/addCompany/addCompany.js | 22 +++- pages/addCompany/addCompany.wxml | 9 +- pages/login/login.js | 123 ++++++++++++------ pages/meeting/meeting.wxml | 2 +- .../meetingDetailSigned.wxml | 4 +- pages/phonePassword/phonePassword.js | 91 ++++++++----- pages/projectDetail/projectDetail.js | 2 +- pages/scanSign/scanSign.js | 66 ++++++++-- 9 files changed, 240 insertions(+), 103 deletions(-) diff --git a/assets/js/common.js b/assets/js/common.js index 3848be2..eb334f7 100644 --- a/assets/js/common.js +++ b/assets/js/common.js @@ -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', + }) + } + }) } \ No newline at end of file diff --git a/pages/addCompany/addCompany.js b/pages/addCompany/addCompany.js index afe0e9d..2050439 100644 --- a/pages/addCompany/addCompany.js +++ b/pages/addCompany/addCompany.js @@ -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]; diff --git a/pages/addCompany/addCompany.wxml b/pages/addCompany/addCompany.wxml index b4b7097..adca8b9 100644 --- a/pages/addCompany/addCompany.wxml +++ b/pages/addCompany/addCompany.wxml @@ -40,21 +40,22 @@ - 邮编: + 邮政编码: - + + - 银行账号: + 银行账号: - 开户行: + 开户行: diff --git a/pages/login/login.js b/pages/login/login.js index 78c2840..e4d883c 100644 --- a/pages/login/login.js +++ b/pages/login/login.js @@ -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({ }) }) } -}) +}) \ No newline at end of file diff --git a/pages/meeting/meeting.wxml b/pages/meeting/meeting.wxml index 11a07d1..161f9d4 100644 --- a/pages/meeting/meeting.wxml +++ b/pages/meeting/meeting.wxml @@ -34,7 +34,7 @@ {{item.meetingName}} - {{item.startTime}} + {{item.startTime}} diff --git a/pages/meetingDetailSigned/meetingDetailSigned.wxml b/pages/meetingDetailSigned/meetingDetailSigned.wxml index a72ed8f..9daee57 100644 --- a/pages/meetingDetailSigned/meetingDetailSigned.wxml +++ b/pages/meetingDetailSigned/meetingDetailSigned.wxml @@ -529,9 +529,9 @@ 签到时间 {{singInPersonInfo.checkInTime}} - + 签到信息 - + diff --git a/pages/phonePassword/phonePassword.js b/pages/phonePassword/phonePassword.js index 06bcfa1..b8df3db 100644 --- a/pages/phonePassword/phonePassword.js +++ b/pages/phonePassword/phonePassword.js @@ -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的登录页 } }) } -}) +}) \ No newline at end of file diff --git a/pages/projectDetail/projectDetail.js b/pages/projectDetail/projectDetail.js index 4492e12..6d74a6d 100644 --- a/pages/projectDetail/projectDetail.js +++ b/pages/projectDetail/projectDetail.js @@ -127,7 +127,7 @@ Page({ }) MeetingApi.meetingList({ workingGroupProjectId: this.data.id, - column: 'pm.createTime', + column: 'createTime', order: 'desc' }).then(res => { if (res.success) { diff --git a/pages/scanSign/scanSign.js b/pages/scanSign/scanSign.js index 1f0adc3..4ffa4ac 100644 --- a/pages/scanSign/scanSign.js +++ b/pages/scanSign/scanSign.js @@ -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 => {}) + } }, /**