diff --git a/api/payment.js b/api/payment.js
new file mode 100644
index 0000000..a9c946f
--- /dev/null
+++ b/api/payment.js
@@ -0,0 +1,35 @@
+/**
+ * Copyright © 2020-present LiuDanYang. All rights Reserved.
+ */
+import { mGet, mPost } from "./request"
+const app = getApp()
+const urls = ['https://api-client-psc-dev.qniao.cn', 'https://api-client-psc-test.qniao.cn', 'https://api-client-psc.qniao.cn']
+
+const pconfig = {
+ baseUrl: urls[app.evn]
+}
+// *******************************************************账户业务***********************************************************
+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)
+const getBankCardList = () => mGet(`/payment-settlement-center/bankcard/getBankCardList`, null, pconfig)
+const deleteBankcard = (id) => mPost(`/payment-settlement-center/bankcard/delete/bankCard/${id}`, null, pconfig)
+const getTradeOrder = (id) => mGet(`/payment-settlement-center/get/payment-order/by-trade-order-id/${id}`, null, pconfig)
+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,
+ getBankcardInfo,
+ ocrBankcard,
+ verifyBankcard,
+ getBankCardList,
+ deleteBankcard,
+ getTradeOrder,
+ paymentFor,
+ getBalanceInfo,
+ getWithdrawalList,
+ paymentOrder
+}
\ No newline at end of file
diff --git a/api/saas.js b/api/saas.js
index bbc1598..3efd498 100644
--- a/api/saas.js
+++ b/api/saas.js
@@ -6,7 +6,7 @@ const app = getApp()
const urls = [`https://api-client-ztb-dev.qniao.cn`, `https://api-client-ztb-test.qniao.cn`, `https://api-client-ztb.qniao.cn`]
const sconfig = {
- baseUrl: urls[app.release % 3]
+ baseUrl: urls[app.evn % 3]
}
// *****************************************账户业务**********************************************
const loginToken = (params) => mPost(`/recycle-user-center/authorize/get/product-line-token/by/login-token`, params, sconfig)
@@ -33,6 +33,7 @@ const getCustomerList = (params) => mGet(`/ztb-factory/factory/get/customer-list
const editCustomer = (params) => mPost(`/ztb-factory/factory/edit/customer`, params, sconfig)
const deleteCustomer = (id) => mPost(`/ztb-factory/factory/delete/customer/${id}`, null, sconfig)
const getCustomerInfo = (id) => mGet(`/ztb-factory/factory/wechat-applet/get/customer-detail/${id}`, null, sconfig)
+const bindCustomer = (params) => mPost(`/ztb-factory/user/binding/factory-customer`, params, sconfig)
export {
sconfig,
@@ -57,6 +58,7 @@ export {
editCustomer,
deleteCustomer,
getCustomerInfo,
+ bindCustomer,
getPaperList,
repeatOrder,
getStatisticsInfo
diff --git a/api/user.js b/api/user.js
index 2932775..5463886 100644
--- a/api/user.js
+++ b/api/user.js
@@ -3,13 +3,14 @@
*/
import { mGet, mPost } from "./request"
import { sconfig } from "./saas"
+import { pconfig } from "./payment"
const util = require('../utils/util')
const storage = require('../utils/storage')
const app = getApp()
const urls = [`https://uec-dev.qniao.cn`, `https://uec-test.qniao.cn`, `https://uec.qniao.cn`]
const config = {
- baseUrl: urls[app.release]
+ baseUrl: urls[app.evn]
}
const wechatApplet = (params) => mPost('/uec/get/wechat-applet-session', params, config)
const loginCaptcha = (params) => mPost(`/uec/authorize/by-captcha`, params, config)
@@ -180,6 +181,7 @@ function phoneWechat(form) {
function finalizeToken(){
config.header = null
sconfig.header = null
+ pconfig.header = null
}
export {
diff --git a/app.js b/app.js
index da44485..b262d8d 100644
--- a/app.js
+++ b/app.js
@@ -1,6 +1,6 @@
//app.js
App({
- release: 2, // 0: 开发版本;1:测试版本;2:生产版本
+ evn: 2, // 0: 开发版本;1:测试版本;2:生产版本
tmplIds: [''],
version: 152,
xAppId: '503258978847953926',
diff --git a/pages/client/bank-add/index.js b/pages/client/bank-add/index.js
index 3c832cd..dc47bd7 100644
--- a/pages/client/bank-add/index.js
+++ b/pages/client/bank-add/index.js
@@ -1,25 +1,106 @@
// pages/client/bank-add/index.js
-import { postCaptcha, verifyCode } from "../../../api/user"
+import { getBankcardInfo, ocrBankcard, verifyBankcard } from "../../../api/payment"
+import { postCaptcha } from "../../../api/user"
+const util = require('../../../utils/util')
+const event = require('../../../utils/event')
+const app = getApp()
+
Page({
/**
* 页面的初始数据
*/
data: {
second: '获取验证码',
+ userInfo: null,
+ form: {
+ phone: null, //银行卡预留手机号
+ cardName: null, //银行名称
+ cardNo: null, //卡号
+ openingBank: null,
+ cardType: null, //银行卡类型
+ idno: null, //身份证号
+ name: null, //持卡人姓名
+ verificationCode: null, //验证码
+ isExist: 0, //查询银行卡是否重复1重复0不重复
+ type: 2
+ },
+ bankName: null,
+ cardType: null,
+ codeEnable: true
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
-
+ this.setData({ ['form.name']: app.userInfo.realName })
+ },
+ bindForm: function (e) {
+ this.data.form[e.target.id] = e.detail.value
+ if (e.target.id == 'cardNo') {
+ this.setData({
+ ['form.cardName']: null,
+ bankName: null,
+ ['form.cardType']: null,
+ ['form.type']: 2,
+ cardType: null
+ })
+ } else if (e.target.id == 'phone') {
+ this.setData({ codeEnable: util.isEmpty(e.detail.value) })
+ }
+ },
+ checkCardNo: function(cardNo){
+ cardNo = cardNo.replace(/\s+/g, '')
+ getBankcardInfo(cardNo).then(result => {
+ this.setData({
+ ['form.cardName']: result.data.bank,
+ ['form.type']: 4,
+ bankName: result.data.bankName,
+ ['form.cardType']: result.data.cardType,
+ cardType: this.getCardType(result.data.cardType)
+ })
+ }).catch(error => {
+ util.showToast(error)
+ })
+ },
+ getCardType: function(type){
+ if('DC' == type){
+ return '储蓄卡'
+ }
+ if('CC' == type){
+ return '信用卡'
+ }
+ if('SCC' == type){
+ return '准贷记卡'
+ }
+ if('PC' == type){
+ return '预付费卡'
+ }
+ return ''
},
fetchCaptcha: function(){
- if (!(/^1\d{10}$/.test(this.data.form.account)) || this.data.form.account.length < 11) {
+ if (util.isEmpty(this.data.bankName) && !util.isEmpty(this.data.form.cardNo)) {
+ this.checkCardNo(this.data.form.cardNo)
+ return
+ }
+ if (util.isEmpty(this.data.form.name)) {
+ util.showToast('请输入持卡人姓名')
+ return
+ }
+ if (util.isEmpty(this.data.form.cardNo)) {
+ util.showToast('请输入银行卡卡号')
+ return
+ }
+ if (util.isEmpty(this.data.form.phone)) {
+ util.showToast('请输入手机号码')
+ return
+ }
+ if (!(/^1\d{10}$/.test(this.data.form.phone)) || this.data.form.phone.length < 11) {
util.showToast('请输入11位手机号码')
return
}
+ this.data.form.cardNo = this.data.form.cardNo.replace(/\s+/g, '')
wx.showLoading({ title: '正在获取', mask: true })
- postCaptcha({ verifiableAccount: this.data.form.account, verifiableAccountType: 1, purpose: 1 }).then(result => {
+ postCaptcha({ verifiableAccount: this.data.form.phone, verifiableAccountType: 1, purpose: 4 }).then(result => {
wx.hideLoading()
this.setData({ codeEnable: false })
util.showToast('验证码已经发送')
@@ -40,4 +121,72 @@ Page({
onFinished: function(){
this.setData({ second: '重新获取验证码', codeEnable: true })
},
+ submitForm: function(){
+ if (util.isEmpty(this.data.form.name)) {
+ util.showToast('请输入持卡人姓名')
+ return
+ }
+ if (util.isEmpty(this.data.form.cardNo)) {
+ util.showToast('请输入银行卡卡号')
+ return
+ }
+ if (util.isEmpty(this.data.bankName) && !util.isEmpty(this.data.form.cardNo)) {
+ this.checkCardNo(this.data.form.cardNo)
+ return
+ }
+ if (util.isEmpty(this.data.form.phone) && this.data.form.type == 4) {
+ util.showToast('请输入手机号码')
+ return
+ }
+ if (this.data.form.type == 4 && (!(/^1\d{10}$/.test(this.data.form.phone)) || this.data.form.phone.length < 11)) {
+ util.showToast('请输入11位手机号码')
+ return
+ }
+ if (util.isEmpty(this.data.form.verificationCode) && this.data.form.type == 4) {
+ util.showToast('请输入验证码')
+ return
+ }
+ wx.showLoading({ title: '处理中', mask: true })
+ verifyBankcard(this.data.form).then(res => {
+ wx.hideLoading()
+ if(res.data.trxstatus == 1){
+ util.showBackToast('添加成功')
+ event.emit('EventMessage', { what: 201, desc: 'AddCard' })
+ } else{
+ util.showToast('银行卡添加失败')
+ }
+ }).catch(error => {
+ wx.hideLoading()
+ util.showToast(error)
+ })
+ },
+ scanCard: function(){
+ var that = this
+ wx.chooseImage({
+ count: 1, //默认9
+ sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
+ sourceType: ['album', 'camera'], //从相册选择
+ success: (res) => {
+ const fileSystemManager = wx.getFileSystemManager()
+ fileSystemManager.readFile({
+ filePath: res.tempFilePaths[0], // 例如图片临时路径
+ encoding: 'base64',
+ success(res) {
+ that.ocrBankcard(res.data)
+ }
+ })
+ }
+ })
+ },
+ ocrBankcard: function(base64Image){
+ wx.showLoading({ title: '处理中', mask: true })
+ ocrBankcard({base64Image}).then(res => {
+ wx.hideLoading()
+ this.setData({ ['form.cardNo']: res.data.card_num })
+ this.checkCardNo(res.data.card_num)
+ }).catch(error => {
+ wx.hideLoading()
+ util.showToast(error)
+ })
+ }
})
\ No newline at end of file
diff --git a/pages/client/bank-add/index.wxml b/pages/client/bank-add/index.wxml
index e44a7df..79bce9c 100644
--- a/pages/client/bank-add/index.wxml
+++ b/pages/client/bank-add/index.wxml
@@ -9,18 +9,17 @@
持卡人姓名:
-
+
银行卡卡号:
-
+
-
- {{bankName}}
+
+ {{bankName}}
{{cardType}}
@@ -31,7 +30,7 @@
验证码:
-
diff --git a/pages/client/bank-list/index.js b/pages/client/bank-list/index.js
index 7ea58c2..2c2ad51 100644
--- a/pages/client/bank-list/index.js
+++ b/pages/client/bank-list/index.js
@@ -1,7 +1,8 @@
// pages/client/bank-list/index.js
import Dialog from '../../../components/dialog/dialog'
-import { getBankCardList, deleteBankCard, checkPayPassword, bankCardDefault } from "../../../api/saas"
+import { getBankCardList, deleteBankcard } from "../../../api/payment"
const util = require('../../../utils/util')
+const event = require('../../../utils/event')
const app = getApp()
Page({
@@ -14,12 +15,24 @@ Page({
{ id: 1, name: '设为默认' },
{ id: 2, name: '解除绑定' }
],
+ nowIndex: -1,
+ bankList: []
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
-
+ wx.showLoading({ title: '加载中', mask: true })
+ getBankCardList().then(result => {
+ console.log(result)
+ this.setData({ bankList: result.data, height: app.globalData.fragmentHeight })
+ wx.hideLoading()
+ }).catch(err => {
+ wx.hideLoading()
+ this.setData({ height: app.globalData.fragmentHeight })
+ util.showToast(err)
+ console.log(err)
+ })
},
showActionSheet(e) {
this.data.nowIndex = e.currentTarget.dataset.index
@@ -39,6 +52,23 @@ Page({
this.setData({ show: false })
},
onSelect: function({detail}) {
- console.log(detail)
+ if(detail.id == 2){
+ Dialog.alert({ title: '温馨提示', message: '确定解除绑定该银行卡?' }).then(() => {
+ this.unbindCard()
+ })
+ }
},
+ unbindCard: function () {
+ wx.showLoading({ title: '处理中', mask: true })
+ var item = this.data.bankList[this.data.nowIndex]
+ deleteBankcard(item.id).then(res => {
+ wx.hideLoading()
+ util.showToast('解除成功')
+ this.data.bankList.splice(this.data.nowIndex, 1);
+ this.setData({ bankList: this.data.bankList })
+ }).catch(err => {
+ wx.hideLoading()
+ util.showToast(err)
+ })
+ }
})
\ No newline at end of file
diff --git a/pages/client/factory-list/index.js b/pages/client/factory-list/index.js
index 0322bbb..b387c96 100644
--- a/pages/client/factory-list/index.js
+++ b/pages/client/factory-list/index.js
@@ -1,66 +1,89 @@
-// pages/client/factory-list/index.js
-Page({
+// pages/client/order-list/index.js
+import { getFactoryOrderList } from "../../../api/saas"
+const util = require('../../../utils/util')
+const app = getApp()
+Page({
/**
* 页面的初始数据
*/
data: {
-
+ height: app.globalData.fragmentHeight,
+ loading: true,
+ requesting: false,
+ finished: false,
+ top: 0,
+ orderList: [],
+ form: {
+ funcType: 0,
+ pageNum: 1,
+ pageSize: 10
+ }
},
-
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
-
- },
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
+ this.setData({ height: app.globalData.fragmentHeight })
+ this.fetchOrderList()
},
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
+ onRefreshList: function () {
+ this.setData({
+ orderList: [],
+ ['form.pageNum']: 1,
+ loading: true,
+ finished: false
+ })
+ this.fetchOrderList()
},
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
+ //1:待定价,2:待过皮重,3:待过磅审核,4:待付款,5:已完成
+ fetchOrderList: function () {
+ if (this.data.requesting || this.data.finished) {
+ return
+ }
+ if (this.data.loading) {
+ this.data.requesting = true
+ } else {
+ this.setData({ requesting: true })
+ }
+ getFactoryOrderList(this.data.form).then(result => {
+ if (result.data && result.data.records.length) {
+ var respList = result.data.records
+ // 对返回的消息列表进行处理,将同一天的消息显示在一起
+ let nowList = `orderList[${this.data.orderList.length}]`
+ var num = this.data.form.pageNum
+ var finished = ((num - 1) * this.data.form.pageSize + respList.length) >= result.data.total
+ if(this.data.form.pageNum == 1){
+ this.setData({
+ [nowList]: respList,
+ ['form.pageNum']: (num + 1),
+ top: 0,
+ finished,
+ requesting: false,
+ loading: false
+ })
+ } else {
+ this.setData({
+ [nowList]: respList,
+ ['form.pageNum']: (num + 1),
+ finished,
+ requesting: false,
+ loading: false
+ })
+ }
+ } else {
+ this.setData({ finished: true, requesting: false, loading: false })
+ }
+ }).catch(err => {
+ this.setData({ requesting: false, loading: false })
+ util.showToast(err)
+ })
},
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
-
+ lookItem: function (e) {
+ var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index]
+ if(item.status == 2 || item.status == 3 || item.status == 4 || item.status == 5){
+ wx.navigateTo({ url: '/pages/process/order-info/index?id=' + item.id })
+ }
}
+
})
\ No newline at end of file
diff --git a/pages/client/factory-list/index.json b/pages/client/factory-list/index.json
index 8835af0..96f92d6 100644
--- a/pages/client/factory-list/index.json
+++ b/pages/client/factory-list/index.json
@@ -1,3 +1,9 @@
{
- "usingComponents": {}
+ "usingComponents": {
+ "refresh-view": "/components/refresher/index",
+ "van-cell": "/components/cell/index",
+ "van-divider": "/components/divider/index",
+ "van-loading": "/components/loading/index",
+ "van-dialog": "/components/dialog/index"
+ }
}
\ No newline at end of file
diff --git a/pages/client/factory-list/index.wxml b/pages/client/factory-list/index.wxml
index 47c682b..ed93ec8 100644
--- a/pages/client/factory-list/index.wxml
+++ b/pages/client/factory-list/index.wxml
@@ -1,4 +1,41 @@
- 我的打包厂
+ 我的打包站
+
+
+
+
+
+
+
+ {{loading? '正在加载' : '暂无数据'}}
+
+
+
+
+ {{item.tipsTime}}
+
+
+
+
+ 客户名称:{{item.factoryCustomerName}}
+ ({{item.factoryCustomerMobile}})
+
+ 毛重:{{item.totalWeight}}KG
+
+
+ 待付款
+
+
+ 已完成
+
+
+
+
+
+
+
+ {{finished?'到底啦~':'加载中...'}}
+
+
diff --git a/pages/client/order-list/index.js b/pages/client/order-list/index.js
index 7be100e..c989896 100644
--- a/pages/client/order-list/index.js
+++ b/pages/client/order-list/index.js
@@ -1,66 +1,109 @@
// pages/client/order-list/index.js
-Page({
+import { getFactoryOrderList } from "../../../api/saas"
+const util = require('../../../utils/util')
+const app = getApp()
+Page({
/**
* 页面的初始数据
*/
data: {
-
+ height: app.globalData.fragmentHeight,
+ loading: true,
+ requesting: false,
+ finished: false,
+ top: 0,
+ orderList: [],
+ form: {
+ funcType: 0,
+ pageNum: 1,
+ pageSize: 10
+ },
+ lastTime: null
},
-
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
-
- },
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
+ this.setData({ height: app.globalData.fragmentHeight })
+ this.fetchOrderList()
},
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
+ onRefreshList: function () {
+ this.setData({
+ orderList: [],
+ ['form.pageNum']: 1,
+ loading: true,
+ finished: false
+ })
+ this.data.lastTime = null
+ this.fetchOrderList()
},
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
+ //1:待定价,2:待过皮重,3:待过磅审核,4:待付款,5:已完成
+ fetchOrderList: function () {
+ if (this.data.requesting || this.data.finished) {
+ return
+ }
+ if (this.data.loading) {
+ this.data.requesting = true
+ } else {
+ this.setData({ requesting: true })
+ }
+ getFactoryOrderList(this.data.form).then(result => {
+ if (result.data && result.data.records.length) {
+ var respList = result.data.records
+ // 对返回的消息列表进行处理,将同一天的消息显示在一起
+ for (let i = 0; i < respList.length; i++) {
+ if (util.isEmpty(this.data.lastTime)) {
+ this.data.lastTime = respList[i].createTime
+ if (this.data.lastTime.length > 10) {
+ this.data.lastTime = this.data.lastTime.substring(0, 10)
+ }
+ respList[i].tipsTime = this.data.lastTime
+ } else {
+ var itemTime = respList[i].createTime
+ if (itemTime.length > 10) {
+ itemTime = itemTime.substring(0, 10)
+ }
+ if (this.data.lastTime !== itemTime) {
+ respList[i].tipsTime = itemTime
+ }
+ this.data.lastTime = itemTime
+ }
+ }
+ let nowList = `orderList[${this.data.orderList.length}]`
+ var num = this.data.form.pageNum
+ var finished = ((num - 1) * this.data.form.pageSize + respList.length) >= result.data.total
+ if(this.data.form.pageNum == 1){
+ this.setData({
+ [nowList]: respList,
+ ['form.pageNum']: (num + 1),
+ top: 0,
+ finished,
+ requesting: false,
+ loading: false
+ })
+ } else {
+ this.setData({
+ [nowList]: respList,
+ ['form.pageNum']: (num + 1),
+ finished,
+ requesting: false,
+ loading: false
+ })
+ }
+ } else {
+ this.setData({ finished: true, requesting: false, loading: false })
+ }
+ }).catch(err => {
+ this.setData({ requesting: false, loading: false })
+ util.showToast(err)
+ })
},
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
-
+ lookItem: function (e) {
+ var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index]
+ if(item.status == 2 || item.status == 3 || item.status == 4 || item.status == 5){
+ wx.navigateTo({ url: '/pages/process/order-info/index?id=' + item.id })
+ }
}
+
})
\ No newline at end of file
diff --git a/pages/client/order-list/index.json b/pages/client/order-list/index.json
index 8835af0..96f92d6 100644
--- a/pages/client/order-list/index.json
+++ b/pages/client/order-list/index.json
@@ -1,3 +1,9 @@
{
- "usingComponents": {}
+ "usingComponents": {
+ "refresh-view": "/components/refresher/index",
+ "van-cell": "/components/cell/index",
+ "van-divider": "/components/divider/index",
+ "van-loading": "/components/loading/index",
+ "van-dialog": "/components/dialog/index"
+ }
}
\ No newline at end of file
diff --git a/pages/client/order-list/index.wxml b/pages/client/order-list/index.wxml
index f90d553..c617765 100644
--- a/pages/client/order-list/index.wxml
+++ b/pages/client/order-list/index.wxml
@@ -2,3 +2,40 @@
订单列表
+
+
+
+
+
+
+
+ {{loading? '正在加载' : '暂无数据'}}
+
+
+
+
+ {{item.tipsTime}}
+
+
+
+
+ 客户名称:{{item.factoryCustomerName}}
+ ({{item.factoryCustomerMobile}})
+
+ 毛重:{{item.totalWeight}}KG
+
+
+ 待付款
+
+
+ 已完成
+
+
+
+
+
+
+
+ {{finished?'到底啦~':'加载中...'}}
+
+
\ No newline at end of file
diff --git a/pages/client/withdrawal/index.js b/pages/client/withdrawal/index.js
index 82c3228..4028f38 100644
--- a/pages/client/withdrawal/index.js
+++ b/pages/client/withdrawal/index.js
@@ -1,66 +1,161 @@
// pages/client/withdrawal/index.js
-Page({
+import Dialog from '../../../components/dialog/dialog'
+import { getBalanceInfo, getWithdrawalList, getBankCardList, paymentOrder } from '../../../api/payment'
+const util = require('../../../utils/util')
+const math = require('../../../utils/math')
+const event = require('../../../utils/event')
+const app = getApp()
+Page({
/**
* 页面的初始数据
*/
data: {
-
+ safeBottom: app.globalData.safeBottom,
+ accountMoney: 0, //用户余额
+ sumMoney: 0, //用户余额
+ expendMoney: '',
+ xsaccountMoney: 0, //显示余额
+ banckCardList: [], //用户银行卡列表
+ banckList: [],
+ orderList: [],
+ checkIds: [],
+ chooseBankCard: null
},
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
-
+ onLoad: function () {
+ this.getUserInfo()
+ this.fetchCardList()
+ event.on('EventMessage', this, this.onEvent)
},
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
+ onEvent: function(message){
+ if (message.what == 201) {
+ this.fetchCardList()
+ }
},
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
+ fetchCardList: function(){
+ getBankCardList().then(res => {
+ var list = []
+ for (let index = 0; index < res.data.length; index++) {
+ const element = res.data[index]
+ list.push({ text: element.bankName + '(' + element.cardNoSuffix + ')', value: element.id })
+ }
+ 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 })
+ }
+ })
},
-
/**
- * 生命周期函数--监听页面隐藏
+ * 获取用户数据
*/
- onHide: function () {
-
+ getUserInfo: function () {
+ wx.showLoading({ title: '加载中', mask: true })
+ getBalanceInfo().then(result => {
+ this.setData({ accountMoney: result.data.accountMoney, xsaccountMoney: math.minus(result.data.accountMoney, result.data.frozenMoney) })
+ }).catch(err => {
+ console.log(err)
+ })
+ getWithdrawalList().then(result => {
+ wx.hideLoading()
+ this.data.sumMoney = 0
+ for (let index = 0; index < result.data.length; index++) {
+ const element = result.data[index]
+ if(element.status == 0){
+ this.data.sumMoney = math.plus(this.data.sumMoney, element.money)
+ }
+ }
+ this.setData({ orderList: result.data, sumMoney: this.data.sumMoney })
+ }).catch(err => {
+ wx.hideLoading()
+ })
},
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
+ allExpend: function () {
+ var sum = 0
+ this.data.checkIds = []
+ for (let index = 0; index < this.data.orderList.length; index++) {
+ const element = this.data.orderList[index]
+ if(element.status == 0){
+ element.check = true
+ this.data.checkIds.push(element.id)
+ sum = math.plus(sum, element.money)
+ }
+ }
+ this.setData({ orderList: this.data.orderList, expendMoney: sum || '' })
},
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
+ chooseCard: function () {
+ if (this.data.chooseBankCard) {
+ this.pickerView.showPicker(this.data.banckList, this.data.chooseBankCard.cardId)
+ } else {
+ Dialog.alert({ title: '温馨提示', message: '您还没有绑定银行卡,请先去绑定银行卡' }).then(() => {
+ wx.navigateTo({ url: '/pages/client/bank-add/index' })
+ })
+ }
},
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
+ onCardChange: function(e){
+ if(!e.detail){
+ return
+ }
+ this.setData({
+ ['chooseBankCard.cardName']: this.data.banckCardList[e.detail.current].bankName,
+ ['chooseBankCard.cardId']: this.data.banckCardList[e.detail.current].id
+ })
},
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
-
+ onPickerChange: function (e) {
+ if(!e.detail){
+ return
+ }
+ this.setData({ ['chooseBankCard.cardName']: e.detail.text, ['chooseBankCard.cardId']: e.detail.value })
+ },
+ checkoutAmount: function () {
+ if (Number(this.data.expendMoney) <= 0) {
+ util.showToast('提现金额必须大于0')
+ return
+ }
+ if (!this.data.chooseBankCard || !this.data.chooseBankCard.cardId) {
+ util.showToast('请选择一张银行卡')
+ return
+ }
+ wx.showLoading({ title: '加载中', mask: true })
+ paymentOrder({ bankId: this.data.chooseBankCard.cardId, ids: this.data.checkIds }).then(res => {
+ wx.hideLoading()
+ if(res.data.markedWords){
+ Dialog.alert({ title: '温馨提示', message: res.data.markedWords }).then(() => {
+ wx.navigateBack()
+ })
+ } else {
+ Dialog.alert({ title: '温馨提示', message: '提现申请已经提交,请等待提现结果。' }).then(() => {
+ wx.navigateBack()
+ })
+ }
+ }).catch(err => {
+ wx.hideLoading()
+ util.showToast(err)
+ })
+ },
+ checkList: function(e){
+ var item = this.data.orderList[e.currentTarget.dataset.index]
+ if(item.status != 0){
+ return
+ }
+ var checked = !item.check
+ var sum = 0
+ this.data.checkIds = []
+ for (let index = 0; index < this.data.orderList.length; index++) {
+ const element = this.data.orderList[index]
+ if(index == e.currentTarget.dataset.index){
+ element.check = !element.check
+ }
+ if(element.check){
+ sum = math.plus(sum, element.money)
+ this.data.checkIds.push(element.id)
+ }
+ }
+ this.setData({ ['orderList[' + e.currentTarget.dataset.index + '].check']: checked, expendMoney: sum || '' })
+ },
+ onUnload: function(){
+ event.remove('EventMessage', this)
}
+
})
\ No newline at end of file
diff --git a/pages/client/withdrawal/index.json b/pages/client/withdrawal/index.json
index 5630f65..49d50c8 100644
--- a/pages/client/withdrawal/index.json
+++ b/pages/client/withdrawal/index.json
@@ -2,6 +2,7 @@
"usingComponents": {
"van-cell": "/components/cell/index",
"van-cell-group": "/components/cell-group/index",
+ "van-dialog": "/components/dialog/index",
"van-button": "/components/button/index"
}
}
\ No newline at end of file
diff --git a/pages/client/withdrawal/index.wxml b/pages/client/withdrawal/index.wxml
index 445be01..e397eae 100644
--- a/pages/client/withdrawal/index.wxml
+++ b/pages/client/withdrawal/index.wxml
@@ -1,27 +1,36 @@
+
申请提现
-
+
+ 提现到账:对私预计两小时内到账,对公预计下一个工作日内到账
+ 提现申请后T+1个工作日到账(周六、周日及节假日顺延到工作日),如有疑问请联系客服400-6881-001
+
+
+
+
+
+ 到账银行卡
+
+
+
提现金额
¥
-
+
- 账户余额¥{{formate.numberFormat2(xsaccountMoney)}}
+ 账户余额¥{{formate.formateAmount(xsaccountMoney)}}
全部提现
-
-
- 到账银行卡
-
-
提现
-
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/pages/home/customer-info/index.js b/pages/home/customer-info/index.js
index 15a6863..66e530d 100644
--- a/pages/home/customer-info/index.js
+++ b/pages/home/customer-info/index.js
@@ -11,7 +11,8 @@ Page({
data: {
form: null,
base64: null,
- showEmbedded: false
+ showEmbedded: false,
+ customerName: ''
},
/**
* 生命周期函数--监听页面加载
@@ -34,9 +35,14 @@ Page({
registCustomer: function(){
wx.showLoading({ title: '加载中', mask: true })
const params = { id: 6 }
- params.metaData = { factoryId: app.userInfo.factoryId, factoryName: app.userInfo.factoryName, factoryCustomerId: this.data.form.id }
+ params.metaData = {
+ factoryId: app.userInfo.factoryId,
+ factoryName: app.userInfo.factoryName,
+ factoryCustomerId: this.data.form.id,
+ factoryCustomerName: this.data.form.name
+ }
generateCode(params).then(result => {
- this.setData({ showEmbedded: true, base64: result.data })
+ this.setData({ showEmbedded: true, base64: result.data, customerName: this.data.form.name })
wx.hideLoading()
}).catch(err => {
wx.hideLoading()
diff --git a/pages/home/customer-info/index.wxml b/pages/home/customer-info/index.wxml
index a72ecc1..ad4aba1 100644
--- a/pages/home/customer-info/index.wxml
+++ b/pages/home/customer-info/index.wxml
@@ -53,7 +53,11 @@
- 为保证企业账户安全,二维码仅在3小时内有效,失效后,可重新生成。
+
+ 邀请
+ {{customerName}}
+ 邀请注册纸通宝
+
\ No newline at end of file
diff --git a/pages/home/customer-info/index.wxss b/pages/home/customer-info/index.wxss
index db91716..fd5a5bd 100644
--- a/pages/home/customer-info/index.wxss
+++ b/pages/home/customer-info/index.wxss
@@ -1 +1,8 @@
-/* pages/home/customer-info/index.wxss */
\ No newline at end of file
+/* pages/home/customer-info/index.wxss */
+.wrapper {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ height: 100%;
+ padding: 0px 15%;
+}
\ No newline at end of file
diff --git a/pages/home/customer-list/index.js b/pages/home/customer-list/index.js
index 84631d1..2930a1e 100644
--- a/pages/home/customer-list/index.js
+++ b/pages/home/customer-list/index.js
@@ -21,7 +21,8 @@ Page({
pageSize: 10
},
base64: null,
- showEmbedded: false
+ showEmbedded: false,
+ customerName: ''
},
/**
* 生命周期函数--监听页面加载
@@ -97,9 +98,14 @@ Page({
var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index]
wx.showLoading({ title: '加载中', mask: true })
const form = { id: 6 }
- form.metaData = { factoryId: app.userInfo.factoryId, factoryName: app.userInfo.factoryName, factoryCustomerId: item.id }
+ form.metaData = {
+ factoryId: app.userInfo.factoryId,
+ factoryName: app.userInfo.factoryName,
+ factoryCustomerId: item.id,
+ factoryCustomerName: item.name
+ }
generateCode(form).then(result => {
- this.setData({ showEmbedded: true, base64: result.data })
+ this.setData({ showEmbedded: true, base64: result.data, customerName: item.name })
wx.hideLoading()
}).catch(err => {
wx.hideLoading()
diff --git a/pages/home/customer-list/index.wxml b/pages/home/customer-list/index.wxml
index 62bff39..545722a 100644
--- a/pages/home/customer-list/index.wxml
+++ b/pages/home/customer-list/index.wxml
@@ -41,7 +41,11 @@
- 为保证企业账户安全,二维码仅在3小时内有效,失效后,可重新生成。
+
+ 邀请
+ {{customerName}}
+ 邀请注册纸通宝
+
\ No newline at end of file
diff --git a/pages/home/customer-list/index.wxss b/pages/home/customer-list/index.wxss
index cc34e01..0bf8566 100644
--- a/pages/home/customer-list/index.wxss
+++ b/pages/home/customer-list/index.wxss
@@ -1 +1,8 @@
-/* pages/home/customer/index.wxss */
\ No newline at end of file
+/* pages/home/customer/index.wxss */
+.wrapper {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ height: 100%;
+ padding: 0px 15%;
+}
\ No newline at end of file
diff --git a/pages/login/index.js b/pages/login/index.js
index 4257575..821490f 100644
--- a/pages/login/index.js
+++ b/pages/login/index.js
@@ -1,7 +1,8 @@
//获取应用实例
import Dialog from '../../components/dialog/dialog'
import { config, wechatApplet, loginWechat, postCaptcha, loginCaptcha, loginPwd, verifyCode, applyEmplyee } from "../../api/user"
-import { sconfig, loginToken, getUserInfo, bindingAdmin } from "../../api/saas"
+import { sconfig, loginToken, getUserInfo, bindingAdmin, bindCustomer } from "../../api/saas"
+import { pconfig } from "../../api/payment"
const util = require('../../utils/util')
const storage = require('../../utils/storage')
const app = getApp()
@@ -24,7 +25,7 @@ Page({
regist: false,
metaData: null,
code: null
- // code: '?mark=ztb_saas&QrCodeRecordId=554641854092677120'
+ // code: '?mark=ztb_saas&QrCodeRecordId=561997269805699072'
},
/************************************** 初始化登录流程 ********************************************/
onLoad: function (options) {
@@ -93,6 +94,7 @@ Page({
// token 切换流程
loginToken({loginToken: authorization}).then(result => {
sconfig.header = { 'Authorization': 'QNT ' + result.data }
+ pconfig.header = { 'Authorization': 'QNT ' + result.data }
getUserInfo().then(result => {
wx.hideLoading()
app.userInfo = result.data
@@ -104,9 +106,12 @@ Page({
})
} else if(this.data.metaData){
// 这里要进行账号的绑定,对工厂进行绑定;或者进行申请操作;
+ if(this.data.metaData.qrPage == '/page/index/register'){
+ this.data.metaData.userName = this.data.metaData.factoryCustomerName || '默认姓名'
+ }
this.setData({ loging: false, metaData: this.data.metaData })
} else {
- if(app.userInfo.factoryId){
+ if(!app.userInfo.factoryId){
wx.redirectTo({ url: '/pages/index/index' })
} else {
wx.redirectTo({ url: '/pages/client/index/index' })
@@ -308,6 +313,18 @@ Page({
this.setData({loging: false})
util.showToast(error)
})
+ } else if(this.data.metaData.qrPage == '/page/index/register'){
+ this.data.metaData.factorycustomerId = this.data.metaData.factoryCustomerId
+ bindCustomer(this.data.metaData).then(result => {
+ this.data.metaData = null
+ wx.hideLoading()
+ this.setData({loging: false})
+ wx.redirectTo({ url: '/pages/client/index/index' })
+ }).catch(error => {
+ wx.hideLoading()
+ this.setData({loging: false})
+ util.showToast(error)
+ })
} else {
Dialog.alert({ title: '温馨提示', message: '扫码错误,请重新扫码。' }).then(() => {
})
diff --git a/pages/login/index.wxml b/pages/login/index.wxml
index cd7d9ab..9d3f8cd 100644
--- a/pages/login/index.wxml
+++ b/pages/login/index.wxml
@@ -11,7 +11,7 @@
现邀请您成为{{metaData.factoryName}}的员工
-
+
{{metaData.factoryName}}邀请您成为纸通宝注册会员