|
@@ -103,7 +103,7 @@ import router from '@system.router'
|
|
|
import prompt from '@system.prompt'
|
|
|
import storage from '@system.storage'
|
|
|
|
|
|
-import { getChargeList, getUserInfo, checkWxOrder } from '../../api'
|
|
|
+import { getChargeList, getUserInfo, checkWxOrder,advertOrders,getBannerData } from '../../api'
|
|
|
import { configWxPay, configAliPay } from '../../helper'
|
|
|
import { getAppConfig } from '../../api/utils.js'
|
|
|
let getConfig
|
|
@@ -129,8 +129,12 @@ export default {
|
|
|
showLoading: false,
|
|
|
checked: false,
|
|
|
loginPhone: '',
|
|
|
+ need_check_order:false,
|
|
|
haslogin: '',
|
|
|
isVip: '',
|
|
|
+ pay_order_id:"",
|
|
|
+ trade_no:"",
|
|
|
+ pay_success:false,
|
|
|
last: null,
|
|
|
payType: [
|
|
|
{
|
|
@@ -228,19 +232,35 @@ export default {
|
|
|
let cur_pay_type = this.curPayType
|
|
|
let product_id = this.rechargeList[this.curSelect].product_id
|
|
|
let ret = null
|
|
|
+ this.need_check_order = false;
|
|
|
+ this.pay_order_id = "";
|
|
|
+ this.trade_no = "";
|
|
|
if (cur_pay_type === 1) {
|
|
|
ret = await configAliPay({
|
|
|
product_id: product_id,
|
|
|
bid: this.bid,
|
|
|
send_order_id: this.send_order_id
|
|
|
})
|
|
|
+ // console.log('al111111111111111111111111',res);
|
|
|
+ this.trade_no = ret.order;
|
|
|
+ this.showToastByCode(ret.code);
|
|
|
} else {
|
|
|
ret = await configWxPay({
|
|
|
product_id: product_id,
|
|
|
bid: this.bid,
|
|
|
send_order_id: this.send_order_id
|
|
|
})
|
|
|
+ this.trade_no = ret.order;
|
|
|
+ this.pay_order_id =ret.order;
|
|
|
+ this.need_check_order = true;
|
|
|
+ // this.back_click = 0;
|
|
|
+ // console.log('wx111111111111111111111',res);
|
|
|
+ // if (fb && typeof fb === 'object')
|
|
|
}
|
|
|
+
|
|
|
+ // this.pay_order_id =ret.order;
|
|
|
+ // console.log('00000000000000000',ret,"paytype d",cur_pay_type);
|
|
|
+ return false;
|
|
|
// 成功支付后的回调操作
|
|
|
if (ret.code === '9000') this.showWaitingWrap(ret)
|
|
|
else this.showToastByCode(ret.code)
|
|
@@ -279,15 +299,26 @@ export default {
|
|
|
if (data.index === 0) this.checkOrder(order)
|
|
|
},
|
|
|
cancel: () => {
|
|
|
+
|
|
|
console.log('cancel')
|
|
|
}
|
|
|
})
|
|
|
+
|
|
|
+ return false;
|
|
|
},
|
|
|
showToastByCode(code) {
|
|
|
this.showLoading = false
|
|
|
+ this.pay_success = false;
|
|
|
let msg = '支付成功!'
|
|
|
+
|
|
|
switch (code) {
|
|
|
case '9000':
|
|
|
+ this.pay_success = true;
|
|
|
+ try{
|
|
|
+ advertOrders(this.trade_no);
|
|
|
+ }catch(e){
|
|
|
+ console.log(e);
|
|
|
+ }
|
|
|
;(msg = '支付成功!'), router.back()
|
|
|
break
|
|
|
case '8000':
|
|
@@ -297,7 +328,7 @@ export default {
|
|
|
msg = '订单支付失败!'
|
|
|
break
|
|
|
case '5000':
|
|
|
- msg = '订单重复!'
|
|
|
+ msg = '订单重复!'
|
|
|
break
|
|
|
case '6001':
|
|
|
msg = '您已取消支付'
|
|
@@ -314,12 +345,97 @@ export default {
|
|
|
prompt.showToast({ message: msg })
|
|
|
},
|
|
|
onShow() {
|
|
|
- this.getUserInfo()
|
|
|
+ this.getUserInfo();
|
|
|
+ if(this.need_check_order && this.pay_order_id){
|
|
|
+ this.checkOrderNew(this.pay_order_id);
|
|
|
+ }
|
|
|
+ },async checkOrderNew(order){
|
|
|
+ console.log("需要查询订单",order);
|
|
|
+ // this.showLoading = true;
|
|
|
+ let fb = await checkWxOrder(order);
|
|
|
+ console.log('查询结果:',fb);
|
|
|
+ if (fb && typeof fb === 'object'){
|
|
|
+ this.showToastByCode('9000')
|
|
|
+ }else{
|
|
|
+ this.showToastByCode('6001')
|
|
|
+ }
|
|
|
},
|
|
|
onHide() {
|
|
|
//this.$app.$def.createShortcut(true);
|
|
|
+ },onBackPress(){
|
|
|
+ if (this.pay_back && !this.pay_success) {
|
|
|
+ this.getActivity();
|
|
|
+ return true;
|
|
|
+ }else{
|
|
|
+ this.getLastpage();
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ },async getActivity(){
|
|
|
+ // let back = await getBannerData(5);
|
|
|
+ // console.log(back,JSON.stringify(back) === "{}",JSON.stringify(back));
|
|
|
+ let back = [];
|
|
|
+ if(JSON.stringify(back) === "{}" || JSON.stringify(back) === "[]"){
|
|
|
+ console.log('000000000000000000000');
|
|
|
+ let taht = this;
|
|
|
+ prompt.showDialog({
|
|
|
+ title: '温馨提示',
|
|
|
+ message: '每日完成任务,可以免费获取书币~',
|
|
|
+ buttons: [
|
|
|
+ {
|
|
|
+ text: '去做任务',
|
|
|
+ color: '#EF5952'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: '我知道了',
|
|
|
+ color: '#999'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ success: function(data) {
|
|
|
+ if (data.index === 1) {
|
|
|
+ taht.getLastpage();
|
|
|
+ } else {
|
|
|
+ router.push({
|
|
|
+ uri: '/views/Task'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ cancel: function() {
|
|
|
+ console.log('取消前往')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ router.push({
|
|
|
+ uri: back.redirect_url,
|
|
|
+ params:back.param
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ },getLastpage(){
|
|
|
+ let backPage = {};
|
|
|
+ try{
|
|
|
+ let page = router.getState();
|
|
|
+ let allPage = router.getPages();
|
|
|
+
|
|
|
+ console.log('page = ',page,'all pages',allPage,'length',allPage.length);
|
|
|
+ for(var k = allPage.length -1; k >= 0;k--){
|
|
|
+ if(allPage[k].name != page.name && allPage[k].name != "views/Phone"){
|
|
|
+ backPage = allPage[k];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch(e){
|
|
|
+ backPage = {};
|
|
|
+ // console.log('back err',e);
|
|
|
+ }
|
|
|
+ console.log(backPage,backPage.length,typeof backPage);
|
|
|
+ if(JSON.stringify(backPage) === '{}'){
|
|
|
+ router.replace({ uri: "/views/Index" });
|
|
|
+ }else{
|
|
|
+ router.back(backPage);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
},
|
|
|
- onBackPress() {
|
|
|
+ onBackPressOld() {
|
|
|
if (this.pay_back) {
|
|
|
prompt.showDialog({
|
|
|
title: '温馨提示',
|