diff --git a/apis/index.js b/apis/index.js index 9be41a3..33e6bb6 100644 --- a/apis/index.js +++ b/apis/index.js @@ -10,8 +10,8 @@ import router from '../router' // 基础配置 const config = { - apiUrl : 'https://douhuo.douhuofalv.com/api/', - // apiUrl : 'https://api.douhuotest.douhuofalv.com/api/', //测试环境 + // apiUrl : 'https://douhuo.douhuofalv.com/api/', + apiUrl : 'https://api.douhuotest.douhuofalv.com/api/', //测试环境 timeout : 60000 } diff --git a/dhdg-pay/index.html b/dhdg-pay/index.html new file mode 100644 index 0000000..4b2d93c --- /dev/null +++ b/dhdg-pay/index.html @@ -0,0 +1,56 @@ + + + + + + + 抖火收银台 + + + +
+ 抖火法律 +

抖火收银台

+ + + + +
+ + + \ No newline at end of file diff --git a/dhdg-pay/logo.png b/dhdg-pay/logo.png new file mode 100644 index 0000000..a37edc1 Binary files /dev/null and b/dhdg-pay/logo.png differ diff --git a/manifest.json b/manifest.json index 8aa2bff..60af05f 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "name" : "抖火", "appid" : "__UNI__C305C03", "description" : "纵有疾风起,人生不言弃", - "versionName" : "1.4.4", + "versionName" : "1.4.5", "versionCode" : 104, "transformPx" : false, /* 5+App特有相关 */ diff --git a/pages/pay/pay.vue b/pages/pay/pay.vue index 7a9c40d..259a7ba 100644 --- a/pages/pay/pay.vue +++ b/pages/pay/pay.vue @@ -16,24 +16,10 @@ - - @@ -44,6 +30,13 @@ + + @@ -73,6 +73,28 @@ + + + + 支付二维码 + + + + + + 请使用{{payQrType == 'app' ? '微信': '支付宝'}}扫码 + + + + + + @@ -97,49 +119,16 @@ orderNo : '', balance : 0, isDeduction : false, - deductionVal: '' + deductionVal: '', + // 二维码支付 + payCodeShow : false, + payQrUrl : '', + payQrType : '' }; }, onShow() { if(this.getState && this.trade_id != ''){ - // 查询支付状态 - uni.showLoading({ - title: '查询支付结果...', - mask : true - }) - let outTime; - let resNumb = 0; - outTime = setInterval(() => { - if(resNumb >= 3){ - clearInterval(outTime) - uni.showToast({ - title: '暂未查询到你的支付订单', - icon : 'none' - }) - return - } - umsState(this.trade_id).then(res => { - resNumb++ - if(res.state === 'success'){ - clearInterval(outTime) - wx.showModal({ - title : '提示', - content : '支付成功', - showCancel : false, - confirmColor: '#446EFE', - success : () => { - this.onRrmoveItem() - } - }) - } - }).catch(err => { - clearInterval(outTime) - uni.showToast({ - title: err.message, - icon : 'none' - }) - }) - }, 2000) + this.onGetOrderPayState() } }, created() { @@ -183,6 +172,53 @@ }) }, methods: { + // 查询订单状态 + onGetOrderPayState(){ + // 查询支付状态 + uni.showLoading({ + title: '查询支付结果...', + mask : true + }) + let outTime; + let resNumb = 0; + outTime = setInterval(() => { + if(resNumb >= 3){ + clearInterval(outTime) + uni.showToast({ + title: '暂未查询到你的支付订单', + icon : 'none' + }) + return + } + umsState(this.trade_id).then(res => { + resNumb++ + if(res.state === 'success'){ + clearInterval(outTime) + wx.showModal({ + title : '提示', + content : '支付成功', + showCancel : false, + confirmColor: '#446EFE', + success : () => { + this.onRrmoveItem() + } + }) + } + }).catch(err => { + clearInterval(outTime) + uni.showToast({ + title: err.message, + icon : 'none' + }) + }) + }, 2000) + }, + // 取消支付 + onCancel(){ + this.payCodeShow = false, + this.payQrUrl = '', + this.payQrType = '' + }, // 抵扣金额 onDeductionSwitch(e){ this.deductionVal = '' @@ -203,9 +239,21 @@ if(this.payType == 'diff') this.onDiffCoinPay() break; case 'code': - uni.showToast({ - title: '付款码支付暂未开放,请敬期待', - icon : 'none' + uni.showActionSheet({ + itemList:["微信付款码", "支付宝付款码"], + success : actionRes => { + console.log(actionRes.tapIndex) + if(actionRes.tapIndex === 0){ + if(this.payType == 'price') this.onDgPay('app', true) + if(this.payType == 'diff') this.onDgDiffPay('app', true) + if(this.payType == 'free') this.onDgFreePay('app', true) + } + if(actionRes.tapIndex === 1){ + if(this.payType == 'price') this.onDgPay('app_alipay', true) + if(this.payType == 'diff') this.onDgDiffPay('app_alipay', true) + if(this.payType == 'free') this.onDgFreePay('app_alipay', true) + } + } }) break; case 'wx': @@ -219,19 +267,19 @@ if(this.payType == 'free') this.onFreePay('app_alipay') break; case 'dgwx': - if(this.payType == 'price') this.onDgPay('app') - if(this.payType == 'diff') this.onDgDiffPay('app') - if(this.payType == 'free') this.onDgFreePay('app') + if(this.payType == 'price') this.onDgPay('app', false) + if(this.payType == 'diff') this.onDgDiffPay('app', false) + if(this.payType == 'free') this.onDgFreePay('app', false) break; case 'dgali': - if(this.payType == 'price') this.onDgPay('app_alipay') - if(this.payType == 'diff') this.onDgDiffPay('app_alipay') - if(this.payType == 'free') this.onDgFreePay('app_alipay') + if(this.payType == 'price') this.onDgPay('app_alipay', false) + if(this.payType == 'diff') this.onDgDiffPay('app_alipay', false) + if(this.payType == 'free') this.onDgFreePay('app_alipay', false) break } }, // 斗拱支付 - onDgPay(type){ + onDgPay(type, code){ uni.showLoading({ title: '加载中...', mask : true @@ -242,15 +290,24 @@ fire : this.deductionVal || 0, app_schema : 'doufire://' }).then(res => { + let { params, trade_id } = res; + uni.hideLoading() + // 二维码支付 + if(code){ + this.onDgPayCode(type, params, trade_id) + return + } + // 转跳付款 + this.getState = true + this.trade_id = trade_id if(type == 'app'){ - let jumpUrl = JSON.parse(res.miniapp_data) + let jumpUrl = JSON.parse(params.miniapp_data) plus.runtime.openURL(jumpUrl.scheme_code) } if(type == 'app_alipay'){ - plus.runtime.openURL(res.jump_url) + plus.runtime.openURL(params.jump_url) } }).catch(err => { - console.log(err) uni.showToast({ title: err.message, icon : 'none' @@ -260,7 +317,7 @@ }) }, // 斗拱补差价 - onDgDiffPay(type){ + onDgDiffPay(type, code){ uni.showLoading({ title: '加载中...', mask : true @@ -271,12 +328,22 @@ fire : this.deductionVal || 0, app_schema : 'doufire://' }).then(res => { + let { params, trade_id } = res; + uni.hideLoading() + // 二维码支付 + if(code){ + this.onDgPayCode(type, params, trade_id) + return + } + // 转跳付款 + this.getState = true + this.trade_id = trade_id if(type == 'app'){ - let jumpUrl = JSON.parse(res.miniapp_data) + let jumpUrl = JSON.parse(params.miniapp_data) plus.runtime.openURL(jumpUrl.scheme_code) } if(type == 'app_alipay'){ - plus.runtime.openURL(res.jump_url) + plus.runtime.openURL(params.jump_url) } }).catch(err => { uni.showToast({ @@ -288,17 +355,31 @@ }) }, // 斗拱自由服务包 - onDgFreePay(type){ + onDgFreePay(type, code){ + uni.showLoading({ + title: '加载中...', + mask : true + }) dgFree(this.orderId, { type, app_schema : 'doufire://' }).then(res => { + let { params, trade_id } = res; + uni.hideLoading() + // 二维码支付 + if(code){ + this.onDgPayCode(type, params, trade_id) + return + } + // 转跳付款 + this.getState = true + this.trade_id = trade_id if(type == 'app'){ - let jumpUrl = JSON.parse(res.miniapp_data) + let jumpUrl = JSON.parse(params.miniapp_data) plus.runtime.openURL(jumpUrl.scheme_code) } if(type == 'app_alipay'){ - plus.runtime.openURL(res.jump_url) + plus.runtime.openURL(params.jump_url) } }).catch(err => { uni.showToast({ @@ -309,6 +390,13 @@ uni.hideLoading() }) }, + // 抖拱二维码付款 + onDgPayCode(type, params, trade_id){ + this.trade_id = trade_id + this.payQrUrl = type == 'app_alipay' ? params.jump_url : 'https://dg-pay.douhuofalv.com?miniurlcode=' + encodeURIComponent(JSON.parse(params.miniapp_data).scheme_code) + this.payQrType = type + this.payCodeShow = true + }, // 银联三方支付 onUmsPay(type){ uni.showLoading({ @@ -463,6 +551,36 @@