From f278510f835af0d809a593432c490473e0af3a1a Mon Sep 17 00:00:00 2001 From: xpz2018 <107107461@qq.com> Date: Fri, 15 Jan 2021 14:50:27 +0800 Subject: [PATCH] no message --- pages/api/payment.js | 4 +- pages/api/request.js | 75 ++++++----- pages/api/user.js | 4 +- pages/api/ztb.js | 4 - pages/home/password/index.js | 239 +++++++++++++++------------------- pages/home/setting/index.wxml | 8 +- pages/ztbvip/index.js | 8 +- pages/ztbvip/index.wxml | 7 +- project.config.json | 2 +- 9 files changed, 157 insertions(+), 194 deletions(-) diff --git a/pages/api/payment.js b/pages/api/payment.js index 9537a11..c7010cf 100644 --- a/pages/api/payment.js +++ b/pages/api/payment.js @@ -5,9 +5,9 @@ import { mGet, mPost } from "./request" const app = getApp() const pconfig = { - baseUrl: app.release ? `https://psc.qniao.cn` : `http://psc-dev.qniao.cn` + baseUrl: app.release ? `http://api-client-ztb.qniao.cn` : `http://47.113.118.47:9000` } -// *******************************************************************账户业务*********************************************************** +// *******************************************************账户业务*********************************************************** const getBankcardInfo = (cardNo) => mGet(`/payment-settlement-center/bankcard/bankcard/home/${cardNo}`, null, pconfig) const ocrBankcard = (params) => mPost(`/payment-settlement-center/bankcard/get/ocr/bankcard`, params, pconfig) const verifyBankcard = (params) => mPost(`/payment-settlement-center/bankcard/post/verify/bankverify`, params, pconfig) diff --git a/pages/api/request.js b/pages/api/request.js index f77e51c..9ad8b43 100644 --- a/pages/api/request.js +++ b/pages/api/request.js @@ -50,7 +50,6 @@ axios.interceptors.response.use( }, (err) => { // 做一些请求错误 - console.error(err) return Promise.reject(err) } ) @@ -67,7 +66,40 @@ function handleResponse({ data, status }) { } const STATUS = { "200"() { - return handleResult(data) + if (data.code === 0) { + return Promise.resolve(data) + } + if (data.code === 401) { + app.globalData.token = null + app.globalData.userToken = null + app.globalData.userInfo = null + wx.removeStorageSync('Authorization') + event.emit('EventMessage', { what: 888, desc: 'Logout' }) + let pages = getCurrentPages() //当前页面栈 + let prevPage = pages[pages.length - 1] //当前页面 + if (prevPage.route != 'pages/login/index') { + wx.showModal({ + title: '温馨提示', + content: '登录信息已经过期,请重新登录', + showCancel: false, + success: function (res) { + if (res.confirm) { + wx.navigateTo({ url: '/pages/login/index' }) + } + } + }) + } + var message = 'Token异常' + if (data.message) { + message = data.message + } + return Promise.reject(message) + } + var message = '数据错误' + if (data.message) { + message = data.message + } + return Promise.reject(message) }, "400"() { return Promise.reject('请求错误') @@ -89,41 +121,8 @@ function handleResponse({ data, status }) { return STATUS[status] ? STATUS[status]() : Promise.reject('请求错误') } -function handleResult(result) { - if (result.code === 0) { - return result - } - if (result.code === 401) { - app.globalData.token = null - app.globalData.userToken = null - app.globalData.userInfo = null - wx.removeStorageSync('Authorization') - event.emit('EventMessage', { what: 888, desc: 'Logout' }) - let pages = getCurrentPages() //当前页面栈 - let prevPage = pages[pages.length - 1] //当前页面 - if (prevPage.route != 'pages/login/index') { - wx.showModal({ - title: '温馨提示', - content: '登录信息已经过期,请重新登录', - showCancel: false, - success: function (res) { - if (res.confirm) { - wx.navigateTo({ url: '/pages/login/index' }) - } - } - }) - } - var message = 'Token异常' - if (result.message) { - message = result.message - } - return Promise.reject(message) - } - var message = '数据错误' - if (result.message) { - message = result.message - } - return Promise.reject(message) +function handleResult(data) { + } export default axios @@ -140,7 +139,7 @@ export function mGet(url, params, config) { return new Promise((resolve, reject) => { axios.get(url, params, config).then((res) => { resolve(res) - }).catch((err) => { + }).catch(err => { reject(err) }) }) diff --git a/pages/api/user.js b/pages/api/user.js index 3028ef7..d4eabd7 100644 --- a/pages/api/user.js +++ b/pages/api/user.js @@ -17,6 +17,7 @@ const wechatApplet = (params) => mPost('/uec/get/wechat-applet-session', params, const loginCaptcha = (params) => mPost(`/uec/authorize/by-captcha`, params, config) const loginPwd = (params) => mPost(`/uec/authorize/by-password`, params, config) const postCaptcha = (params) => mPost(`/uec/get/auth-captcha`, params, config) +const setPassword = (params) => mPost(`/uec/user/set/sign-in-password`, params, config) const getUserInfo = (params) => mGet('/uec/get/user-info', params, config) const getAuthSession = () => mGet('/uec/create/identity-auth-session', null, config) const certificateImage = (params) => mPost('/uec/recognize/certificate-img', params, config) @@ -190,5 +191,6 @@ export { certificateImage, certificateIdentity, phoneWechat, - loginWechat + loginWechat, + setPassword } \ No newline at end of file diff --git a/pages/api/ztb.js b/pages/api/ztb.js index d8781cd..dc44308 100644 --- a/pages/api/ztb.js +++ b/pages/api/ztb.js @@ -93,8 +93,6 @@ const getBillDetail = (id) => mGet(`/recycle-service/get/bill-detail/${id}`, nul const sendCaptcha = (params) => mPost(`/recycle-service/send/captcha`, params, zconfig) const modifyMobile = (params) => mPost(`/recycle-service/user/modify/mobile`, params, zconfig) const modifyMemberInfo = (params) => mPost(`/recycle-service/user/update/member-info`, params, zconfig) -const setPassword = (params) => mPost(`/recycle-service/user/set/sign-in-password`, params, zconfig) -const resetPassword = (params) => mPost(`/user-centre/commonLogin/resetPassword`, params, zconfig) const getMessageList = (params) => mGet(`/message-center/message/get/message-list`, params, zconfig) const getNotificationList = (params) => mGet(`/message-center/message/get/notification-list`, params, zconfig) const readMessage = (params) => mPost(`/message-center/message/read`, params, zconfig) @@ -189,8 +187,6 @@ export { sendCaptcha, modifyMobile, modifyMemberInfo, - setPassword, - resetPassword, getMessageList, getNotificationList, readMessage, diff --git a/pages/home/password/index.js b/pages/home/password/index.js index 6fca1b9..0869e10 100644 --- a/pages/home/password/index.js +++ b/pages/home/password/index.js @@ -1,138 +1,105 @@ -// // pages/home/password/index.js -// // 页面已经废弃,因为UEC的修改,暂时不会提供修改密码的功能 -// import { $wuxCountDown } from '../../../components/index' -// import { setPassword } from '../../api/ztb' -// const request = require('../../../utils/request') //导入模块 -// const util = require('../../../utils/util') -// const md5 = require('../../../utils/md5') -// const app = getApp() +// pages/home/password/index.js +// 页面已经废弃,因为UEC的修改,暂时不会提供修改密码的功能 +import { $wuxCountDown } from '../../../components/index' +import { postCaptcha, setPassword } from "../../api/user" +const util = require('../../../utils/util') +const md5 = require('../../../utils/md5') +const app = getApp() -// Page({ -// /** -// * 页面的初始数据 -// */ -// data: { -// second: null, -// codeEnable: true, -// pwdType: 'password', -// pwd_icon: 'attention', -// form: { -// mobile: null, -// password: null, -// verifyCode: null -// }, -// requesting: false, -// first: false -// }, +Page({ + /** + * 页面的初始数据 + */ + data: { + second: null, + codeEnable: true, + pwdType: 'password', + pwd_icon: 'attention', + form: { + mobile: null, + password: null, + verifyCode: null + }, + requesting: false, + first: false + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + this.setData({ ['form.mobile']: app.globalData.userInfo.mobile }) + if(options.from){ + this.setData({ first: true }) + } + }, + bindForm: function (e) { + this.data.form[e.target.id] = e.detail.value + }, + changePwd: function (e) { + if (this.data.pwdType === 'password') { + this.setData({ pwdType: 'text', pwd_icon: 'attentionforbid' }) + } else { + this.setData({ pwdType: 'password', pwd_icon: 'attention' }) + } + }, + fetchCode: function () { + if (util.isEmpty(this.data.form.mobile)) { + util.showToast('请输入手机号码') + return + } + if (this.second && this.second.interval) return !1 + wx.showLoading({ title: '正在获取', mask: true }) + postCaptcha({ verifiableAccount: this.data.form.mobile, verifiableAccountType: 1, purpose: 2 }).then(result => { + wx.hideLoading() + this.setData({ codeEnable: false }) + util.showToast('验证码已经发送') + this.second = new $wuxCountDown({ + date: +(new Date) + 60000, + onEnd() { + this.setData({ second: '重新获取验证码', codeEnable: true }) + }, + render(date) { + const sec = this.leadingZeros(date.sec, 2) + ' 秒 ' + date.sec !== 0 && this.setData({ second: sec }) + } + }) + }).catch(error => { + wx.hideLoading() + util.showToast(error) + }) + }, + submitForm: function () { + if (this.data.requesting) { + return + } + if (util.isEmpty(this.data.form.mobile) && !this.data.first) { + util.showToast('请输入手机号码') + return + } + if (util.isEmpty(this.data.form.password)) { + util.showToast('请输入密码') + return + } + if (util.isEmpty(this.data.form.verifyCode) && !this.data.first) { + util.showToast('请输入验证码') + return + } + wx.showLoading({ title: '处理中', mask: true }) + this.data.requesting = true + setPassword(this.data.form).then(res => { + wx.hideLoading() + util.showBackToast('设置成功') + }).catch(error => { + wx.hideLoading() + this.data.requesting = false + util.showToast(error) + }) + }, + onUnload: function(){ + if(this.wuxCountDown){ + this.wuxCountDown.stop() + this.wuxCountDown = null + } + } -// /** -// * 生命周期函数--监听页面加载 -// */ -// onLoad: function (options) { -// this.setData({ -// ['form.mobile']: app.globalData.userInfo.mobile -// }) -// if(options.from){ -// this.setData({ -// first: true -// }) -// } -// }, -// bindForm: function (e) { -// this.data.form[e.target.id] = e.detail.value -// }, -// changePwd: function (e) { -// if (this.data.pwdType === 'password') { -// this.setData({ -// pwdType: 'text' -// }) -// this.setData({ -// pwd_icon: 'attentionforbid' -// }) -// } else { -// this.setData({ -// pwdType: 'password' -// }) -// this.setData({ -// pwd_icon: 'attention' -// }) -// } -// }, -// fetchCode: function () { -// if (util.isEmpty(this.data.form.mobile)) { -// util.showToast('请输入手机号码') -// return -// } -// if (this.second && this.second.interval) return !1 -// wx.showLoading({ title: '正在获取', mask: true }) -// // //commonLogin/sendVerifyCode 发送验证码 -// request.post('/user-centre/commonLogin/sendVerifyCode', { -// mobile: this.data.form.mobile, -// codeType: '7', -// type: 'yzmjc' -// }).then(result => { -// wx.hideLoading() -// this.setData({ codeEnable: false }) -// util.showToast('验证码已经发送') -// this.second = new $wuxCountDown({ -// date: +(new Date) + 60000, -// onEnd() { -// this.setData({ second: '重新获取验证码', codeEnable: true }) -// }, -// render(date) { -// const sec = this.leadingZeros(date.sec, 2) + ' 秒 ' -// date.sec !== 0 && this.setData({ second: sec }) -// } -// }) -// }).catch(error => { -// wx.hideLoading() -// util.showToast(error) -// }) -// }, -// submitForm: function () { -// if (this.data.requesting) { -// return -// } -// if (util.isEmpty(this.data.form.mobile) && !this.data.first) { -// util.showToast('请输入手机号码') -// return -// } -// if (util.isEmpty(this.data.form.password)) { -// util.showToast('请输入密码') -// return -// } -// if (util.isEmpty(this.data.form.verifyCode) && !this.data.first) { -// util.showToast('请输入验证码') -// return -// } -// wx.showLoading({ title: '处理中', mask: true }) -// this.data.requesting = true -// if(this.data.first){ -// // var data = { password : md5.hexMD5(this.data.form.password).toUpperCase() } -// setPassword({ password : this.data.form.password }).then(res => { -// wx.hideLoading() -// util.showBackToast('设置成功') -// }).catch(error => { -// wx.hideLoading() -// this.data.requesting = false -// util.showToast(error) -// }) -// } else { -// resetPassword(this.data.form).then(res => { -// wx.hideLoading() -// util.showBackToast('设置成功') -// }).catch(error => { -// wx.hideLoading() -// this.data.requesting = false -// util.showToast(error) -// }) -// } -// }, -// onUnload: function(){ -// if(this.wuxCountDown){ -// this.wuxCountDown.stop() -// this.wuxCountDown = null -// } -// } - -// }) \ No newline at end of file +}) \ No newline at end of file diff --git a/pages/home/setting/index.wxml b/pages/home/setting/index.wxml index e4e85f0..108341f 100644 --- a/pages/home/setting/index.wxml +++ b/pages/home/setting/index.wxml @@ -8,12 +8,12 @@ - - + + diff --git a/pages/ztbvip/index.js b/pages/ztbvip/index.js index 81ba390..9d1457e 100644 --- a/pages/ztbvip/index.js +++ b/pages/ztbvip/index.js @@ -5,7 +5,6 @@ const event = require('../../utils/event.js') const app = getApp() Page({ - /** * 页面的初始数据 */ @@ -17,7 +16,6 @@ Page({ divIndex:null, vipInfo: null }, - /** * 生命周期函数--监听页面加载 */ @@ -25,7 +23,7 @@ Page({ this.setData({ safeBottom: app.globalData.safeBottom, userInfo: app.globalData.userInfo }) getMemberExpenseList().then(res => { this.setData({ iconList: res.data, divIndex:res.data[0].id }) - }) + }).catch(err => { }) this.wuxDialog = this.wuxDialog || this.selectComponent('#wux-dialog') }, onShow: function () { @@ -39,11 +37,11 @@ Page({ userInfo: app.globalData.userInfo, userName: util.isEmpty(app.globalData.userInfo.userName) ? '' : app.globalData.userInfo.userName.substring(0, 14) }) - }) + }).catch(err => { }) getMemberInfo().then(res => { this.setData({ vipInfo: res.data, ['vipInfo.memberExpiredAt']: res.data.memberExpiredAt.substring(0, 10) }) wx.hideLoading() - }).catch(error => { + }).catch(err => { wx.hideLoading() }) }, diff --git a/pages/ztbvip/index.wxml b/pages/ztbvip/index.wxml index 329084b..4e42b48 100644 --- a/pages/ztbvip/index.wxml +++ b/pages/ztbvip/index.wxml @@ -3,7 +3,8 @@ 纸通宝会员 - + + @@ -48,7 +49,7 @@ - + 选择购买的会员产品 @@ -67,7 +68,7 @@ - + diff --git a/project.config.json b/project.config.json index 386bf7f..15b7d85 100644 --- a/project.config.json +++ b/project.config.json @@ -40,7 +40,7 @@ "useApiHostProcess": true }, "compileType": "miniprogram", - "libVersion": "2.13.1", + "libVersion": "2.14.4", "appid": "wx7a4a8415e6821108", "projectname": "zhitongbao-mini", "debugOptions": {