From 576be8c8d9978b3d8d432d01f8da2cbf43a556ca Mon Sep 17 00:00:00 2001 From: liangjin <liangjin@finlean.com> Date: Tue, 16 Mar 2021 17:55:04 +0800 Subject: [PATCH] 重构 --- pages/hbfqPage/orderInfo/orderInfo.js | 216 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 181 insertions(+), 35 deletions(-) diff --git a/pages/hbfqPage/orderInfo/orderInfo.js b/pages/hbfqPage/orderInfo/orderInfo.js index 7510ba0..a3047da 100644 --- a/pages/hbfqPage/orderInfo/orderInfo.js +++ b/pages/hbfqPage/orderInfo/orderInfo.js @@ -1,6 +1,7 @@ const app = getApp() let $api = require('../../../utils/ajaxFn.js') +let validator = require('../../../utils/validator.js') Page({ data: { isBoss: true, @@ -11,12 +12,12 @@ verName: '', info: { prodId: '', - amt:'', - goodsName:'', - term:'', - zfbVersion:'', - userName:'', - userMblNo:'' + amt: '', + goodsName: '', + term: '', + zfbVersion: '', + userName: '', + userMblNo: '' }, amtList: [ { name: '商家到账', number: 0 }, @@ -37,7 +38,7 @@ }, getList(obj) { $api.ajax( - '/sib/xcx/order/hbCreateInit', + '/zic/order/hbCreateInit', 'POST', (res) => { this.setData({ @@ -53,7 +54,7 @@ }, orderhbTrial() { $api.ajax( - '/sib/xcx/order/hbTrial', + '/zic/order/hbTrial', 'POST', (res) => { let body = res.data.body @@ -96,21 +97,36 @@ this.setData({ isBoss: false }) + } else { + this.setData({ + isBoss: true + }) } if (this.data.isBoss) { this.orderhbTrial() } } - }, bindObjPickerChangeProd(e) { - this.setData({ prodName: this.data.prodsList[e.detail.value].name, - 'info.prodId': this.data.prodsList[e.detail.value].code + 'info.prodId': this.data.prodsList[e.detail.value].code, + 'info.term': '', + 'info.zfbVersion': '', + termName: '', + zfbVersionName: '', + amtList: [ + { name: '商家到账', number: 0 }, + { name: '客户还款总额', number: 0 }, + { name: '客户月还款额', number: 0 } + ], + rateList: [ + { name: '智享服务费率', rate: 0 }, + { name: '花呗利率', rate: 0 }, + { name: '支付利率', rate: 0 } + ] }) this.getList({ prodId: this.data.info.prodId }) - console.log(this.data.info.amt, this.data.info.prodId, this.data.info.term, this.data.info.zfbVersion) if (!this.data.info.amt || !this.data.info.prodId || !this.data.info.term || !this.data.info.zfbVersion) { this.setData({ isBoss: false @@ -129,7 +145,6 @@ termName: this.data.termsList[e.detail.value].name, 'info.term': this.data.termsList[e.detail.value].code }) - console.log(this.data.info.amt, this.data.info.prodId, this.data.info.term, this.data.info.zfbVersion) if (!this.data.info.amt || !this.data.info.prodId || !this.data.info.term || !this.data.info.zfbVersion) { this.setData({ isBoss: false @@ -146,9 +161,20 @@ bindObjPickerChangeVer(e) { this.setData({ zfbVersionName: this.data.zfbVersionsList[e.detail.value].name, - 'info.zfbVersion': this.data.zfbVersionsList[e.detail.value].code + 'info.zfbVersion': this.data.zfbVersionsList[e.detail.value].code, + 'info.term': '', + termName: '', + amtList: [ + { name: '商家到账', number: 0 }, + { name: '客户还款总额', number: 0 }, + { name: '客户月还款额', number: 0 } + ], + rateList: [ + { name: '智享服务费率', rate: 0 }, + { name: '花呗利率', rate: 0 }, + { name: '支付利率', rate: 0 } + ] }) - console.log(this.data.info.amt, this.data.info.prodId, this.data.info.term, this.data.info.zfbVersion) this.getList({ prodId: this.data.info.prodId, zfbVersion: this.data.info.zfbVersion }) if (!this.data.info.amt || !this.data.info.prodId || !this.data.info.term || !this.data.info.zfbVersion) { this.setData({ @@ -167,22 +193,77 @@ this.setData({ 'info.payType': 2 }) - for (let key in this.data.info) { - if (!this.data.info[key]) { - my.showToast({ - type: 'none', - content: '请完整输入信息', - duration: 2000, - }); - return - } + let info = this.data.info + if (!validator.checkbdMoney(info.amt)||info.amt==0) { + my.showToast({ + type: 'none', + content: '请输入0.01-100000之间分期本金', + duration: 2000, + }); + return + } + if (validator.checkValEmpty(info.goodsName)) { + my.showToast({ + type: 'none', + content: '请输入商品名称', + duration: 2000, + }); + return + } + if (validator.checkValEmpty(info.prodId)) { + my.showToast({ + type: 'none', + content: '请选择付息方式', + duration: 2000, + }); + return + } + if (validator.checkValEmpty(info.zfbVersion)) { + my.showToast({ + type: 'none', + content: '请选择办单通道', + duration: 2000, + }); + return + } + if (validator.checkValEmpty(info.term)) { + my.showToast({ + type: 'none', + content: '请选择分期期数', + duration: 2000, + }); + return + } + if (validator.checkValEmpty(info.userName)) { + my.showToast({ + type: 'none', + content: '请输入客户姓名', + duration: 2000, + }); + return + } + if (validator.checkValEmpty(info.userMblNo)) { + my.showToast({ + type: 'none', + content: '请输入客户手机号', + duration: 2000, + }); + return + } + if (!validator.checkPhone(info.userMblNo)) { + my.showToast({ + type: 'none', + content: '请输入正确的客户手机号', + duration: 2000, + }); + return } my.scan({ scanType: ['qrCode', 'barCode'], success: (res) => { console.log(res) $api.ajax( - '/sib/xcx/order/createHb', + '/zic/order/createHb', 'POST', (res) => { my.reLaunch({ @@ -193,7 +274,7 @@ true, { ...this.data.info, - authCode: res.resultStr + authCode: res.code } ) }, @@ -203,15 +284,80 @@ this.setData({ 'info.payType': 1 }) - for (let key in this.data.info) { - if (!this.data.info[key]) { - my.showToast({ - type: 'none', - content: '请完整输入信息', - duration: 2000, - }); - return - } + // for (let key in this.data.info) { + // if (!this.data.info[key]) { + // my.showToast({ + // type: 'none', + // content: '请完整输入信息', + // duration: 2000, + // }); + // return + // } + // } + let info = this.data.info + if (!validator.checkbdMoney(info.amt)||info.amt==0) { + my.showToast({ + type: 'none', + content: '请输入0.01-100000之间分期本金', + duration: 2000, + }); + return + } + if (validator.checkValEmpty(info.goodsName)) { + my.showToast({ + type: 'none', + content: '请输入商品名称', + duration: 2000, + }); + return + } + if (validator.checkValEmpty(info.prodId)) { + my.showToast({ + type: 'none', + content: '请选择付息方式', + duration: 2000, + }); + return + } + if (validator.checkValEmpty(info.zfbVersion)) { + my.showToast({ + type: 'none', + content: '请选择办单通道', + duration: 2000, + }); + return + } + if (validator.checkValEmpty(info.term)) { + my.showToast({ + type: 'none', + content: '请选择分期期数', + duration: 2000, + }); + return + } + if (validator.checkValEmpty(info.userName)) { + my.showToast({ + type: 'none', + content: '请输入客户姓名', + duration: 2000, + }); + return + } + if (validator.checkValEmpty(info.userMblNo)) { + my.showToast({ + type: 'none', + content: '请输入客户手机号', + duration: 2000, + }); + return + } + if (!validator.checkPhone(info.userMblNo)) { + my.showToast({ + type: 'none', + content: '请输入正确的客户手机号', + duration: 2000, + }); + return } let str = JSON.stringify(this.data.info) my.navigateTo({ -- Gitblit v1.8.0