Browse Source

no message

featrue/v4.1
xpz2018 5 years ago
parent
commit
e07f85227e
10 changed files with 174 additions and 561 deletions
  1. 4
      pages/api/payment.js
  2. 4
      pages/api/saas.js
  3. 3
      pages/home/index/index.js
  4. 271
      pages/home/password/index.js
  5. 14
      pages/login/index.js
  6. 25
      pages/paper/index.js
  7. 1
      pages/withdrawal/balance/index.js
  8. 81
      pages/withdrawal/checkout/index.js
  9. 7
      pages/withdrawal/vcheckout/index.js
  10. 325
      utils/request.js

4
pages/api/payment.js

@ -17,6 +17,7 @@ const getTradeOrder = (id) => mGet(`/payment-settlement-center/get/payment-order
const paymentFor = (params) => mPost(`/payment-settlement-center/pay`, params, pconfig)
const getBalanceInfo = () => mGet(`/payment-settlement-center/balance/get/balance`, null, pconfig)
const getWithdrawalList = () => mGet(`/payment-settlement-center/balance/get/order-withdrawal-list`, null, pconfig)
const paymentOrder = (params) => mPost(`/payment-settlement-center/balance/order/withdraw`, params, pconfig)
export {
pconfig,
@ -28,5 +29,6 @@ export {
getTradeOrder,
paymentFor,
getBalanceInfo,
getWithdrawalList
getWithdrawalList,
paymentOrder
}

4
pages/api/saas.js

@ -34,6 +34,7 @@ const personalAuth = (params) => mPost(`/user-centre/front/customer/personalAuth
const postFeedback = (params) => mPost(`/saas-user/account/feedback`, params, sconfig)
const getWithdrawList = (params) => mGet(`/saas-user/account/withdraw/list`, params, sconfig)
const getWithdrawInfo = (id) => mGet(`/saas-user/account/withdraw/${id}`, null, sconfig)
const postWithdraw = (params) => mPost(`/saas-user/account/withdraw`, params, sconfig)
export {
sconfig,
@ -61,5 +62,6 @@ export {
personalAuth,
postFeedback,
getWithdrawList,
getWithdrawInfo
getWithdrawInfo,
postWithdraw
}

3
pages/home/index/index.js

@ -1,5 +1,6 @@
// pages/stock/index.js
import { getBaseInfo, getBalanceInfo, getMessageNumber } from "../../api/ztb"
import { getBaseInfo, getMessageNumber } from "../../api/ztb"
import { getBalanceInfo } from "../../api/payment"
const util = require('../../../utils/util')
const event = require('../../../utils/event')
const math = require('../../../utils/math')

271
pages/home/password/index.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
}
}
})
// })

14
pages/login/index.js

@ -2,8 +2,10 @@
import { $wuxCountDown } from '../../components/index'
import { config, postCaptcha, loginCaptcha, wechatApplet, getUserInfo, loginWechat } from "../api/user"
import { zconfig, loginToken } from "../api/ztb"
import { pconfig } from "../api/payment"
import { mconfig } from "../api/moment"
import { sconfig } from "../api/saas"
const storage = require('../../utils/storage')
const request = require('../../utils/request') //导入模块
const util = require('../../utils/util')
const event = require('../../utils/event')
const app = getApp()
@ -59,9 +61,8 @@ Page({
this.setData({ loging: false})
loginToken({loginToken: app.globalData.token}).then(result => {
zconfig.header = { 'Authorization': 'QNT ' + result.data.token }
console.log(zconfig)
// cconfig.header = { 'Authorization': 'QNT ' + result.data }
// pconfig.header = { 'Authorization': 'QNT ' + result.data }
pconfig.header = { 'Authorization': 'QNT ' + result.data.token }
mconfig.header = { 'Authorization': 'QNT ' + result.data.token }
// 登录流程完成;
wx.hideLoading()
wx.navigateBack()
@ -170,11 +171,6 @@ Page({
util.showToast(error)
})
},
onGotPhoneNumber: function (e) {
request.phoneWechat(e.detail).then(result => {
this.setData({ ['form.account']: result.data.phoneNumber, mobileEnable: true })
})
},
readAgreement: function () {
wx.navigateTo({ url: '/pages/html/agreement/index' })
},

25
pages/paper/index.js

@ -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
pages/withdrawal/balance/index.js

@ -1,6 +1,5 @@
// pages/withdrawal/balance/index.js
import { getBalanceInfo } from "../../api/payment"
const request = require('../../../utils/request') //导入模块
const math = require('../../../utils/math')
Page({

81
pages/withdrawal/checkout/index.js

@ -1,9 +1,9 @@
// pages/withdrawal/checkout/index.js
import { $wuxKeyBoard, $wuxDialog } from '../../../components/index'
const request = require('../../../utils/request') //导入模块
import { checkPayPassword, getBalanceInfo, getBankCardList } from "../../api/payment"
import { $wuxKeyBoard, $wuxDialog } from '../../../components/index'
const util = require('../../../utils/util')
// const md5 = require('../../../utils/md5')
const math = require('../../../utils/math.js')
const math = require('../../../utils/math')
Page({
@ -26,28 +26,8 @@ Page({
this.pickerView = this.pickerView || this.selectComponent('#picker-view')
this.getUserInfo()
},
onShow: function () {
this.getBankCardList()
this.checkPayPassword()
},
/**
* 获取用户数据
*/
getUserInfo: function () {
// /account/balance 用户余额
request.get('/saas-user/account/balance').then(res => {
this.setData({
accountMoney: res.data.accountMoney,
xsaccountMoney: math.minus(res.data.accountMoney, res.data.frozenMoney)
})
})
},
/**
* 获取用户银行卡列表
*/
getBankCardList: function () {
request.get('/saas-user/account/getBankCardList').then(res => {
getBankCardList().then(res => {
var list = []
for (let index = 0; index < res.data.length; index++) {
const element = res.data[index]
@ -56,41 +36,36 @@ Page({
value: element.id
})
}
this.setData({
banckCardList: res.data,
banckList: list
})
this.setData({ banckCardList: res.data, banckList: list })
if (this.data.banckCardList[0] && this.data.banckCardList[0].cardName) {
const element = this.data.banckCardList[0]
var defaultCard = {
cardId: element.id,
cardName: element.bankName + '(' + element.cardNoSuffix + ')'
}
this.setData({
chooseBankCard: defaultCard
})
var defaultCard = { cardId: element.id, cardName: element.bankName + '(' + element.cardNoSuffix + ')' }
this.setData({ chooseBankCard: defaultCard })
}
})
},
/**
* 检测是否设置支付密码
*/
checkPayPassword() {
request.get('/saas-user/account/checkPayPassword').then(res => {
checkPayPassword().then(res => {
this.data.isSetPwd = 1
}).catch(err => {
this.data.isSetPwd = -1
})
},
bindAndSet(e) {
this.setData({
expendMoney: e.detail.value
/**
* 获取用户数据
*/
getUserInfo: function () {
// /account/balance 用户余额
getBalanceInfo().then(res => {
this.setData({
accountMoney: res.data.accountMoney,
xsaccountMoney: math.minus(res.data.accountMoney, res.data.frozenMoney)
})
})
},
bindAndSet(e) {
this.setData({ expendMoney: e.detail.value })
},
allExpend: function () {
this.setData({
expendMoney: this.data.xsaccountMoney
})
this.setData({ expendMoney: this.data.xsaccountMoney })
},
chooseCard: function () {
if (this.data.chooseBankCard) {
@ -170,16 +145,8 @@ Page({
}
},
withdrawalMoney: function (pwd) {
wx.showLoading({
title: '加载中',
mask: true
})
request.post('/saas-user/account/withdraw', {
bankId: this.data.chooseBankCard.cardId,
money: this.data.expendMoney,
// password: md5.hexMD5(pwd).toUpperCase()
password: pwd
}).then(res => {
wx.showLoading({ title: '加载中', mask: true })
postWithdraw({ bankId: this.data.chooseBankCard.cardId, money: this.data.expendMoney, password: pwd }).then(res => {
wx.hideLoading()
util.showBackToast('提现成功')
}).catch(err => {

7
pages/withdrawal/vcheckout/index.js

@ -1,13 +1,11 @@
// pages/withdrawal/checkout/index.js
import { getBalanceInfo, getWithdrawalList, getBankCardList } from '../../api/payment'
import { $wuxDialog } from '../../../components/index'
const request = require('../../../utils/request') //导入模块
const util = require('../../../utils/util')
const math = require('../../../utils/math.js')
const math = require('../../../utils/math')
const app = getApp()
Page({
/**
* 页面的初始数据
*/
@ -133,8 +131,7 @@ Page({
return
}
wx.showLoading({ title: '加载中', mask: true })
var form = { bankId: this.data.chooseBankCard.cardId, ids: this.data.checkIds }
request.post('/payment-settlement-center/balance/order/withdraw', form).then(res => {
paymentOrder({ bankId: this.data.chooseBankCard.cardId, ids: this.data.checkIds }).then(res => {
wx.hideLoading()
if(res.data.markedWords){
$wuxDialog().open({

325
utils/request.js

@ -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
}
Loading…
Cancel
Save