10 changed files with 174 additions and 561 deletions
Split View
Diff Options
-
4pages/api/payment.js
-
4pages/api/saas.js
-
3pages/home/index/index.js
-
271pages/home/password/index.js
-
14pages/login/index.js
-
25pages/paper/index.js
-
1pages/withdrawal/balance/index.js
-
81pages/withdrawal/checkout/index.js
-
7pages/withdrawal/vcheckout/index.js
-
325utils/request.js
@ -1,139 +1,138 @@ |
|||
// pages/home/password/index.js
|
|||
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 { setPassword } from '../../api/ztb'
|
|||
// const request = require('../../../utils/request') //导入模块
|
|||
// const util = require('../../../utils/util')
|
|||
// const md5 = require('../../../utils/md5')
|
|||
// const app = getApp()
|
|||
|
|||
Page({ |
|||
// Page({
|
|||
// /**
|
|||
// * 页面的初始数据
|
|||
// */
|
|||
// data: {
|
|||
// second: null,
|
|||
// codeEnable: true,
|
|||
// pwdType: 'password',
|
|||
// pwd_icon: 'attention',
|
|||
// form: {
|
|||
// mobile: null,
|
|||
// password: null,
|
|||
// verifyCode: null
|
|||
// },
|
|||
// requesting: false,
|
|||
// first: false
|
|||
// },
|
|||
|
|||
/** |
|||
* 页面的初始数据 |
|||
*/ |
|||
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'
|
|||
// })
|
|||
// 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
|
|||
// }
|
|||
// }
|
|||
|
|||
/** |
|||
* 生命周期函数--监听页面加载 |
|||
*/ |
|||
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){ |
|||
// /user/set/sign-in-password设置登录密码
|
|||
// 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 |
|||
} |
|||
} |
|||
|
|||
}) |
|||
// })
|
|||
@ -1,51 +1,26 @@ |
|||
const app = getApp() |
|||
const event = require('../../utils/event.js') |
|||
|
|||
Page({ |
|||
data: { |
|||
TabList: [ |
|||
// { index: 0, value: 'main', icon: 'form', badge: 0, name: '首页' },
|
|||
{ index: 0, value: 'order', icon: 'form', badge: 0, name: '订单' }, |
|||
{ index: 1, value: 'home', icon: 'my', badge: 0, name: '我的' } |
|||
], |
|||
pageIndex: 0, |
|||
safeBottom: app.globalData.safeBottom |
|||
}, |
|||
/** |
|||
* 生命周期函数--监听页面加载 |
|||
*/ |
|||
onLoad: function (options) { |
|||
this.setData({safeBottom: app.globalData.safeBottom }) |
|||
event.on('EventMessage', this, this.onEvent) |
|||
// 检查用户是否设置过密码;
|
|||
if(options.pwd == 0){ |
|||
wx.navigateTo({ url: '/pages/home/password/index?from=home' }) |
|||
} |
|||
}, |
|||
|
|||
//事件处理函数
|
|||
onNavChange(e) { |
|||
// 处理用户的登录校验
|
|||
this.setData({ pageIndex: Number(e.currentTarget.dataset.tab) }) |
|||
var pageView = this.selectComponent('#' + this.data.TabList[this.data.pageIndex].value); |
|||
pageView.onRestart() |
|||
}, |
|||
/** |
|||
* 生命周期函数--监听页面显示 |
|||
*/ |
|||
onShow: function () { |
|||
var pageView = this.selectComponent('#' + this.data.TabList[this.data.pageIndex].value); |
|||
if (pageView) { |
|||
pageView.onRestart() |
|||
} |
|||
}, |
|||
onEvent: function (message) { |
|||
|
|||
}, |
|||
/** |
|||
* 生命周期函数--监听页面卸载 |
|||
*/ |
|||
onUnload: function () { |
|||
event.remove('EventMessage', this) |
|||
} |
|||
}) |
|||
@ -1,325 +0,0 @@ |
|||
// const socketHttp = "wss://*****.com/wss"
|
|||
const event = require('./event.js') |
|||
const util = require('./util.js') |
|||
const storage = require('./storage.js') |
|||
const app = getApp() |
|||
const urlList = ['/recycle-service', '/payment-settlement-center', '/message-center', '/information-center'] |
|||
var modal = false |
|||
|
|||
function fun(url, method, data, header) { |
|||
data = data || {} |
|||
var flag = false |
|||
for (let index = 0; index < urlList.length; index++) { |
|||
if(url.indexOf(urlList[index]) != -1){ |
|||
flag = true |
|||
break |
|||
} |
|||
} |
|||
if(util.isEmpty(app.globalData.token)){ |
|||
var authorization = wx.getStorageSync('Authorization') |
|||
if (authorization) { |
|||
app.globalData.token = authorization |
|||
} |
|||
} |
|||
if(util.isEmpty(app.globalData.userToken)){ |
|||
var userToken = wx.getStorageSync('userToken') |
|||
if (userToken) { |
|||
app.globalData.userToken = userToken |
|||
} |
|||
} |
|||
if(flag){ |
|||
header = { |
|||
'X-APP-ID': app.xAppId, |
|||
'Authorization': 'QNT ' + app.globalData.token, |
|||
appversion: app.version |
|||
} |
|||
} else { |
|||
header = { |
|||
'X-APP-ID': app.xAppId, |
|||
'user-token': '' + app.globalData.userToken, |
|||
appversion: app.version |
|||
} |
|||
} |
|||
let promise = new Promise(function (resolve, reject) { |
|||
wx.request({ |
|||
url: app.httpUrl + url, |
|||
header: header, |
|||
data: data, |
|||
method: method, |
|||
success: function (result) { |
|||
if (typeof result.data === "object") { |
|||
if (result.data.code === 0) { |
|||
resolve(result.data) |
|||
} else if (result.data.code === 401) { |
|||
app.globalData.token = null |
|||
app.globalData.userToken = null |
|||
wx.removeStorageSync('accessToken') |
|||
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' && !modal) { |
|||
wx.showModal({ |
|||
title: '温馨提示', |
|||
content: '登录信息已经过期,请重新登录', |
|||
showCancel: false, |
|||
success: function (res) { |
|||
if (res.confirm) { |
|||
wx.navigateTo({ url: '/pages/login/index' }) |
|||
} |
|||
}, |
|||
complete: function(){ |
|||
modal = false |
|||
} |
|||
}) |
|||
modal = true |
|||
} |
|||
var message = '网络错误' |
|||
if (result.data.message) { |
|||
message = result.data.message |
|||
} |
|||
reject(message) |
|||
} else { |
|||
var message = '数据错误' |
|||
if (result.data.message) { |
|||
message = result.data.message |
|||
} |
|||
reject(message) |
|||
} |
|||
} else { |
|||
reject('网络异常') |
|||
} |
|||
}, |
|||
fail: function (err) { |
|||
// util.showToast(JSON.stringify(err))
|
|||
reject('网络异常') |
|||
} |
|||
}) |
|||
}) |
|||
return promise |
|||
} |
|||
|
|||
function upload(url, name, filePath) { |
|||
let header = { |
|||
'token': app.globalData.userToken |
|||
} |
|||
let promise = new Promise(function (resolve, reject) { |
|||
wx.uploadFile({ |
|||
url: app.httpUrl + url, |
|||
filePath: filePath, |
|||
name: name, |
|||
header: header, |
|||
success: function (res) { |
|||
resolve(res) |
|||
}, |
|||
fail: reject |
|||
}) |
|||
}) |
|||
return promise |
|||
} |
|||
// ****************************************************************************************************************************************
|
|||
// /authorize/by-wechat-applet小程序登录
|
|||
function loginWechat(form) { |
|||
let promise = new Promise(function (resolve, reject) { |
|||
if (!form.encryptedData) { |
|||
wx.showToast({ |
|||
title: '授权被拒绝,获取微信用户失败', |
|||
icon: "none" |
|||
}) |
|||
reject |
|||
return |
|||
} |
|||
wx.showLoading({ |
|||
title: '登录中', |
|||
mask: true |
|||
}) |
|||
var tempToken = storage.get('tempToken') |
|||
if(!util.isEmpty(tempToken)){ |
|||
form.tmpAuthToken = tempToken |
|||
unionWechat(form, resolve, reject) |
|||
} else { |
|||
wx.login({ |
|||
success: res => { |
|||
// 获取openId
|
|||
wx.request({ |
|||
header: { 'X-APP-ID': app.xAppId }, |
|||
url: app.httpUrl + '/recycle-service/authorize/wechat-applet/user', |
|||
data: { authCode: res.code }, |
|||
method: 'POST', |
|||
success: function (result) { |
|||
if (result.data.code == 0) { |
|||
form.tmpAuthToken = result.data.data.tmpAuthToken |
|||
storage.put('tempToken', form.tmpAuthToken, 98) |
|||
// 微信登录,获取unionId
|
|||
unionWechat(form, resolve, reject) |
|||
} else { |
|||
wx.hideLoading() |
|||
wx.showToast({ |
|||
title: '登录失败,请稍后再试', |
|||
icon: "none" |
|||
}) |
|||
reject |
|||
} |
|||
}, |
|||
fail: function (sessionResp) { |
|||
wx.hideLoading() |
|||
wx.showToast({ |
|||
title: '登录失败,请稍后再试', |
|||
icon: "none" |
|||
}) |
|||
reject |
|||
} |
|||
}) |
|||
}, |
|||
fail: function (loginResp) { |
|||
wx.hideLoading() |
|||
wx.showToast({ |
|||
title: '登录失败,请稍后再试', |
|||
icon: "none" |
|||
}) |
|||
reject |
|||
} |
|||
}) |
|||
} |
|||
}) |
|||
return promise |
|||
} |
|||
|
|||
function unionWechat(form, resolve, reject) { |
|||
wx.request({ |
|||
header: { 'X-APP-ID': app.xAppId }, |
|||
url: app.httpUrl + '/recycle-service/authorize/by-wechat-applet', |
|||
data: form, |
|||
method: 'POST', |
|||
success: function (result) { |
|||
wx.hideLoading() |
|||
if (result.data.code == 0) { |
|||
storage.remove('tempToken') |
|||
resolve(result.data) |
|||
} else { |
|||
reject(result.data) |
|||
} |
|||
}, |
|||
fail: function () { |
|||
wx.hideLoading() |
|||
wx.showToast({ |
|||
title: '获取用户信息,请稍后再试', |
|||
icon: "none" |
|||
}) |
|||
reject |
|||
}, |
|||
}) |
|||
} |
|||
// ****************************************************************************************************************************************
|
|||
// 通过微信的方式登录,onGotPhoneNumber中统一处理
|
|||
function gotPhoneNumber(form, resolve, reject) { |
|||
// 获取手机号码 /authorize/encrypt/mobile
|
|||
wx.request({ |
|||
header: { 'X-APP-ID': app.xAppId }, |
|||
url: app.httpUrl + '/recycle-service/authorize/encrypt/mobile', |
|||
data: form, |
|||
method: 'POST', |
|||
success: function (result) { |
|||
// 绑定手机号码,进行登录
|
|||
wx.hideLoading() |
|||
if (result.data.code != 0) { |
|||
wx.showToast({ |
|||
title: '登录失败,请稍后再试', |
|||
icon: "none" |
|||
}) |
|||
reject |
|||
return |
|||
} |
|||
result.data.tmpAuthToken = form.tmpAuthToken |
|||
resolve(result.data) |
|||
}, |
|||
fail: function (phoneResp) { |
|||
wx.hideLoading() |
|||
wx.showToast({ |
|||
title: '登录失败,请稍后再试', |
|||
icon: "none" |
|||
}) |
|||
reject |
|||
} |
|||
}) |
|||
} |
|||
|
|||
function phoneWechat(form) { |
|||
let promise = new Promise(function (resolve, reject) { |
|||
if (!form.encryptedData) { |
|||
wx.showToast({ |
|||
title: '授权被拒绝,登录失败', |
|||
icon: "none" |
|||
}) |
|||
reject |
|||
return |
|||
} |
|||
wx.showLoading({ |
|||
title: '登录中', |
|||
mask: true |
|||
}) |
|||
// 没有获取到openId,获取之后进行登录
|
|||
wx.login({ |
|||
success: res => { |
|||
// 获取openId
|
|||
wx.request({ |
|||
header: { 'X-APP-ID': app.xAppId }, |
|||
url: app.httpUrl + '/recycle-service/authorize/wechat-applet/user', |
|||
data: { authCode: res.code }, |
|||
method: 'POST', |
|||
success: function (result) { |
|||
if (result.data.code == 0) { |
|||
form.tmpAuthToken = result.data.data.tmpAuthToken |
|||
// 获取手机号码
|
|||
gotPhoneNumber(form, resolve, reject) |
|||
} else { |
|||
wx.hideLoading() |
|||
wx.showToast({ |
|||
title: '登录失败,请稍后再试', |
|||
icon: "none" |
|||
}) |
|||
reject |
|||
} |
|||
}, |
|||
fail: function (sessionResp) { |
|||
wx.hideLoading() |
|||
wx.showToast({ |
|||
title: '登录失败,请稍后再试', |
|||
icon: "none" |
|||
}) |
|||
reject |
|||
} |
|||
}) |
|||
}, |
|||
fail: function (loginResp) { |
|||
wx.hideLoading() |
|||
wx.showToast({ |
|||
title: '登录失败,请稍后再试', |
|||
icon: "none" |
|||
}) |
|||
reject |
|||
} |
|||
}) |
|||
}) |
|||
return promise |
|||
} |
|||
|
|||
module.exports = { |
|||
"get": function (url, data, header) { |
|||
return fun(url, "GET", data, header) |
|||
}, |
|||
"post": function (url, data, header) { |
|||
return fun(url, "POST", data, header) |
|||
}, |
|||
"put": function (url, data, header) { |
|||
return fun(url, "PUT", data, header) |
|||
}, |
|||
"delete": function (url, data, header) { |
|||
return fun(url, "DELETE", data, header) |
|||
}, |
|||
upload: function (url, name, filePath) { |
|||
return upload(url, name, filePath) |
|||
}, |
|||
phoneWechat: phoneWechat, |
|||
loginWechat: loginWechat |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save