|
@@ -49,6 +49,12 @@
|
|
|
</block>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <div class="notice-wrap">
|
|
|
+ <text class="title">提示:</text>
|
|
|
+ <text class="notice-item">1.书币属虚拟商品,一经购买不得退换</text>
|
|
|
+ <text class="notice-item">2.充值后书币到账可能有延迟,1小时内未到账请到个人中心联系客服</text>
|
|
|
+ <text class="notice-item">3.工作时间:周一 周四 周五 9:00-21:00,周二 周三 周六 周日 9:00-18:00</text>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</tab-content>
|
|
|
</tabs>
|
|
@@ -62,6 +68,12 @@
|
|
|
<text class="go-to-pay" @click="toPay">立即充值</text>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <div class="loading-wrap" if="showLoading">
|
|
|
+ <div class="loading-content">
|
|
|
+ <progress type="circular"></progress>
|
|
|
+ <text class="loading-text">{{loadingText}}</text>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -82,8 +94,10 @@ export default {
|
|
|
curSelect: 0,
|
|
|
balance: 0,
|
|
|
send_order_id: 0,
|
|
|
- total: "50元",
|
|
|
+ total: "0元",
|
|
|
+ loadingText: "订单查询中...",
|
|
|
isInPay: false,
|
|
|
+ showLoading: false,
|
|
|
payType: [
|
|
|
{
|
|
|
name: "支付宝",
|
|
@@ -121,46 +135,57 @@ export default {
|
|
|
async toPay() {
|
|
|
let cur_pay_type = this.curPayType;
|
|
|
let product_id = this.rechargeList[this.curSelect].product_id;
|
|
|
- console.log(cur_pay_type);
|
|
|
- this.isInPay = true;
|
|
|
+ let ret = null;
|
|
|
if (cur_pay_type === 1) {
|
|
|
- let ret = await configAliPay({ product_id: product_id, bid: this.bid, send_order_id: this.send_order_id });
|
|
|
- this.showToastByCode(ret.code);
|
|
|
- if (ret.code === "9000") {
|
|
|
- router.back();
|
|
|
- }
|
|
|
+ ret = await configAliPay({ product_id: product_id, bid: this.bid, send_order_id: this.send_order_id });
|
|
|
}
|
|
|
else {
|
|
|
- let wx_ret = await configWxPay({ product_id: product_id, bid: this.bid, send_order_id: this.send_order_id });
|
|
|
- console.log("isInPay", this.isInPay);
|
|
|
- this.isInPay = false;
|
|
|
- console.log("wx_ret", wx_ret);
|
|
|
- console.log("isInPay", this.isInPay);
|
|
|
- // 查询订单
|
|
|
- this.checkOrderIfNotApp(wx_ret);
|
|
|
+ ret = await configWxPay({ product_id: product_id, bid: this.bid, send_order_id: this.send_order_id });
|
|
|
}
|
|
|
+ // 成功支付后的回调操作
|
|
|
+ if (ret.code === "9000") this.showWaitingWrap(ret);
|
|
|
+ else this.showToastByCode(ret.code);
|
|
|
},
|
|
|
- checkOrderIfNotApp(order_info) {
|
|
|
- console.log(order_info);
|
|
|
+ checkOrder(order_info) {
|
|
|
+ this.showLoading = true;
|
|
|
let { data, order } = order_info;
|
|
|
- // if (data.final_url) {
|
|
|
- // // h5支付回调
|
|
|
- // console.log("check h5 order");
|
|
|
- // let times = 0;
|
|
|
- // this.timer = setInterval(async () => {
|
|
|
- // if (times === 10) clearInterval(this.timer), this.showToastByCode("6004");
|
|
|
- // else {
|
|
|
- // times++;
|
|
|
- // let fb = await checkWxOrder(order);
|
|
|
- // if (fb) clearInterval(this.timer), this.showToastByCode("9000");
|
|
|
- // }
|
|
|
- // }, 1000)
|
|
|
- // } else if (data.prepayid) {
|
|
|
- // // app支付回调
|
|
|
- // this.showToastByCode("9000");
|
|
|
- // }
|
|
|
+ let times = 10;
|
|
|
+ this.loadingText = `订单查询中...${times}s`;
|
|
|
+ this.timer = setInterval(async () => {
|
|
|
+ if (times === 0) clearInterval(this.timer), this.showToastByCode("6004");
|
|
|
+ else {
|
|
|
+ times--;
|
|
|
+ this.loadingText = `订单查询中...${times}s`;
|
|
|
+ let fb = await checkWxOrder(order);
|
|
|
+ if (fb && typeof fb === "object") clearInterval(this.timer), this.showToastByCode("9000");
|
|
|
+ }
|
|
|
+ }, 1000);
|
|
|
+ },
|
|
|
+ showWaitingWrap(order) {
|
|
|
+ prompt.showDialog({
|
|
|
+ title: "支付结果",
|
|
|
+ message: "请确认支付结果",
|
|
|
+ buttons: [
|
|
|
+ {
|
|
|
+ text: "完成",
|
|
|
+ color: "#EF5952"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: "支付遇到问题",
|
|
|
+ color: "#999"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ success: (data) => {
|
|
|
+ if (data.index === 0) this.checkOrder(order);
|
|
|
+ else this.showToastByCode("6004");
|
|
|
+ },
|
|
|
+ cancel: () => {
|
|
|
+ console.log("cancel");
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
showToastByCode(code) {
|
|
|
+ this.showLoading = false;
|
|
|
let msg = "支付成功!";
|
|
|
switch (code) {
|
|
|
case "9000": msg = "支付成功!"; break;
|
|
@@ -180,6 +205,28 @@ export default {
|
|
|
},
|
|
|
onHide() {
|
|
|
this.$app.$def.createShortcut(true);
|
|
|
+ },
|
|
|
+ async onBackPress() {
|
|
|
+ // 查询订单的过程如果用户返回
|
|
|
+ if (this.showLoading) {
|
|
|
+ let ret = await prompt.showDialog({
|
|
|
+ title: "警告",
|
|
|
+ message: "订单正在查询中,是否确认退出?",
|
|
|
+ buttons: [
|
|
|
+ {
|
|
|
+ text: "退出",
|
|
|
+ color: "#EF5952"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: "取消",
|
|
|
+ color: "#999"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ });
|
|
|
+ if (ret.data.index === 1) return true;
|
|
|
+ else router.back();
|
|
|
+ }
|
|
|
+ else router.back();
|
|
|
}
|
|
|
}
|
|
|
</script>
|