const app = getApp() let $api = require('../../../utils/ajaxFn.js') let validator = require('../../../utils/validator.js') Page({ data: { isBoss: true, userStyle: {}, prodsList: [], prodName: '', termName: '', verName: '', info: { prodId: '', amt: '', goodsName: '', term: '', zfbVersion: '', userName: '', userMblNo: '' }, amtList: [ { name: '商家到账', number: 0 }, { name: '客户还款总额', number: 0 }, { name: '客户月还款额', number: 0 } ], rateList: [ { name: '智享服务费率', rate: 0 }, { name: '花呗利率', rate: 0 }, { name: '支付利率', rate: 0 } ], }, onLoad() { this.setData({ userStyle: app.userStyle }) this.getList() }, getList(obj) { $api.ajax( '/sib/xcx/order/hbCreateInit', 'POST', (res) => { this.setData({ prodsList: res.data.body.prods, termsList: res.data.body.terms, zfbVersionsList: res.data.body.zfbVersions }) }, (err) => { }, true, { ...obj } ) }, orderhbTrial() { $api.ajax( '/sib/xcx/order/hbTrial', 'POST', (res) => { let body = res.data.body this.setData({ amtList: [{ name: '商家到账', number: body.merAmt }, { name: '客户还款总额', number: body.repayAmt }, { name: '客户月还款额', number: body.monthAmt }], rateList: [ { name: '智享服务费率', rate: body.platRate }, { name: '花呗利率', rate: body.zfbRate }, { name: '支付利率', rate: body.payRate }] }) }, (err) => { }, true, { amt: this.data.info.amt, prodId: this.data.info.prodId, term: this.data.info.term, zfbVersion: this.data.info.zfbVersion } ) }, confirm(e) { let code = e.target.dataset.code, value = e.detail.value, obj = {}; if (code == 1) { obj.amt = value } else if (code == 2) { obj.goodsName = value } else if (code == 3) { obj.userName = value } else { obj.userMblNo = value } this.setData({ info: { ...this.data.info, ...obj } }) if (code == 1) { if (!this.data.info.amt || !this.data.info.prodId || !this.data.info.term || !this.data.info.zfbVersion) { 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.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 }) if (!this.data.info.amt || !this.data.info.prodId || !this.data.info.term || !this.data.info.zfbVersion) { this.setData({ isBoss: false }) } else { this.setData({ isBoss: true }) } if (this.data.isBoss) { this.orderhbTrial() } }, bindObjPickerChangeTerm(e) { this.setData({ termName: this.data.termsList[e.detail.value].name, 'info.term': this.data.termsList[e.detail.value].code }) if (!this.data.info.amt || !this.data.info.prodId || !this.data.info.term || !this.data.info.zfbVersion) { this.setData({ isBoss: false }) } else { this.setData({ isBoss: true }) } if (this.data.isBoss) { this.orderhbTrial() } }, bindObjPickerChangeVer(e) { this.setData({ zfbVersionName: this.data.zfbVersionsList[e.detail.value].name, '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 } ] }) 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({ isBoss: false }) } else { this.setData({ isBoss: true }) } if (this.data.isBoss) { this.orderhbTrial() } }, toQRCode() { this.setData({ 'info.payType': 2 }) 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', 'POST', (res) => { my.reLaunch({ url: `/pages/order/hbfqOrder/hbfqOrder?orderId=${res.data.body.orderId}`, }) }, (err) => { }, true, { ...this.data.info, authCode: res.code } ) }, }); }, getQRCode() { 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 // } // } 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({ url: `../qrCode/qrCode?info=${str}` }); } });