|
@@ -7,9 +7,7 @@
|
|
|
></image>
|
|
|
<div class="contain">
|
|
|
<text class="promotion-title" if="{{activity.isForever!='1'}}"
|
|
|
- >活动时间:{{ activity.startTime.substring(0, 10) }} 至
|
|
|
- {{ activity.endTime.substring(0, 10) }}</text
|
|
|
- >
|
|
|
+ >活动时间:{{ activity.startTime.substring(0, 10) }} 至 {{ activity.endTime.substring(0, 10)}}</text>
|
|
|
<div
|
|
|
class="charge-item {{currentIdx==$idx?'charge-on':''}}"
|
|
|
for="{{activity.products}}"
|
|
@@ -48,8 +46,10 @@
|
|
|
</div>
|
|
|
<div class="rule">
|
|
|
<text class="rule-bd">活动说明</text>
|
|
|
- <text>1.此充值为书币充值,1元=100书币</text>
|
|
|
- <text>2.书币为虚拟物品,一经充值不得退款</text>
|
|
|
+ <text>1.充值后书币到账可能有延迟,1小时内未到账请到个人中心联系客服</text>
|
|
|
+ <text>2.未满18周岁的未成年人应在法定监护人同意后进行充值</text>
|
|
|
+ <text>3.此充值为书币充值,1元=100书币</text>
|
|
|
+ <text>4.充值书币,鉴于网络服务性质特殊属于不宜退货商品,不适用无理由退换规定</text>
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- <div class="loading-wrap" if="showLoading">
|
|
@@ -111,15 +111,16 @@
|
|
|
</template>
|
|
|
<script>
|
|
|
import { configWxPay, configAliPay } from '../../helper'
|
|
|
-import { getAcitivity, getUserInfo, checkWxOrder } from '../../api'
|
|
|
+import { getAcitivity, getUserInfo, checkWxOrder ,advertOrders} from '../../api'
|
|
|
import { getAppConfig, getToken } from '../../api/utils'
|
|
|
import router from '@system.router'
|
|
|
import prompt from '@system.prompt'
|
|
|
+import storage from '@system.storage'
|
|
|
|
|
|
export default {
|
|
|
public: {
|
|
|
token: '',
|
|
|
- send_order_id: ''
|
|
|
+ pay_back: 0,
|
|
|
},
|
|
|
private: {
|
|
|
showPay: false,
|
|
@@ -127,14 +128,24 @@ export default {
|
|
|
payType: 0,
|
|
|
currentProduct: null,
|
|
|
currentIdx: 0,
|
|
|
- showLoading: false
|
|
|
+ showLoading: false,
|
|
|
+ pay_order_id:"",
|
|
|
+ trade_no:"",
|
|
|
+ haslogin: '',
|
|
|
+ loginPhone: '',
|
|
|
+ pay_success:false,
|
|
|
+ need_check_order:false,
|
|
|
},
|
|
|
- onInit() {
|
|
|
- //getAppConfig(this);
|
|
|
+ async onInit() {
|
|
|
+ // getAppConfig(this);
|
|
|
this.getUserInfo()
|
|
|
setTimeout(() => {
|
|
|
this.getAcitvy()
|
|
|
}, 1000)
|
|
|
+
|
|
|
+ getConfig = getAppConfig(this)
|
|
|
+ let { pay_back_alert_show } = await getConfig('task_center')
|
|
|
+ this.pay_back = pay_back_alert_show
|
|
|
},
|
|
|
changePayType(type, evt) {
|
|
|
evt.stopPropagation()
|
|
@@ -150,34 +161,77 @@ export default {
|
|
|
this.currentProduct = this.activity.products[0]
|
|
|
},
|
|
|
wantCharge() {
|
|
|
- this.showPay = true
|
|
|
+ // console.log("this.send_order_id",this.send_order_id,"this.haslogin",this.haslogin,'this,loginphone',this.loginPhone);
|
|
|
+ if (!(this.send_order_id || (this.haslogin && this.loginPhone))) {
|
|
|
+ prompt.showDialog({
|
|
|
+ title: '友情提示',
|
|
|
+ message: '您还未绑定手机号,请绑定手机号后在进行相关操作',
|
|
|
+ buttons: [
|
|
|
+ {
|
|
|
+ text: '前往绑定',
|
|
|
+ color: '#33dd44'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ success: function(data) {
|
|
|
+ router.push({
|
|
|
+ uri: '/views/Phone'
|
|
|
+ })
|
|
|
+ },
|
|
|
+ cancel: function() {
|
|
|
+ console.log('取消绑定')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ this.showPay = true
|
|
|
+ }
|
|
|
},
|
|
|
async getUserInfo() {
|
|
|
+ try{
|
|
|
+ this.loginPhone = (await storage.get({ key: 'loginPhone' })).data
|
|
|
+ this.haslogin = (await storage.get({ key: 'hasLogin' })).data
|
|
|
let userinfo = await getUserInfo()
|
|
|
- this.send_order_id = userinfo.send_order_id || this.send_order_id
|
|
|
+ if(userinfo){
|
|
|
+ console.log('userinfo',userinfo);
|
|
|
+ this.send_order_id = userinfo.send_order_id;
|
|
|
+ }
|
|
|
+ }catch(e){
|
|
|
+ // console.log('11111111111111',e);
|
|
|
+ }
|
|
|
},
|
|
|
chooseItem(product, idx) {
|
|
|
this.currentProduct = product
|
|
|
this.currentIdx = idx
|
|
|
},
|
|
|
async goPay(evt) {
|
|
|
+
|
|
|
evt.stopPropagation()
|
|
|
+
|
|
|
let cur_pay_type = this.payType
|
|
|
let product_id = this.currentProduct.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,
|
|
|
send_order_id: this.send_order_id,
|
|
|
activity_token: this.token
|
|
|
})
|
|
|
+ this.trade_no = ret.order;
|
|
|
+ this.showToastByCode(ret.code);
|
|
|
} else {
|
|
|
ret = await configWxPay({
|
|
|
product_id: product_id,
|
|
|
send_order_id: this.send_order_id,
|
|
|
activity_token: this.token
|
|
|
})
|
|
|
+ this.trade_no = ret.order;
|
|
|
+ this.pay_order_id =ret.order;
|
|
|
+ this.need_check_order = true;
|
|
|
}
|
|
|
+
|
|
|
+ return false;
|
|
|
// 成功支付后的回调操作
|
|
|
if (ret.code === '9000') this.showWaitingWrap(ret)
|
|
|
else this.showToastByCode(ret.code)
|
|
@@ -204,13 +258,37 @@ export default {
|
|
|
router.back()
|
|
|
}
|
|
|
}, 2000)
|
|
|
+ },async onShow() {
|
|
|
+ // console.log('11111111111111111111111-onshow');
|
|
|
+ await 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);
|
|
|
+ // this.showToastByCode('9000')
|
|
|
+ if (fb && typeof fb === 'object'){
|
|
|
+ this.showToastByCode('9000')
|
|
|
+ }else{
|
|
|
+ this.showToastByCode('6001')
|
|
|
+ }
|
|
|
},
|
|
|
showToastByCode(code) {
|
|
|
this.showLoading = false
|
|
|
+ this.pay_success = false;
|
|
|
let msg = '支付成功!'
|
|
|
switch (code) {
|
|
|
case '9000':
|
|
|
- ;(msg = '支付成功!'), router.back()
|
|
|
+ this.pay_success = true;
|
|
|
+ try{
|
|
|
+ advertOrders(this.trade_no);
|
|
|
+ }catch(e){
|
|
|
+ console.log(e);
|
|
|
+ }
|
|
|
+ msg = '支付成功!'
|
|
|
break
|
|
|
case '8000':
|
|
|
msg = '订单已提交,请等待结果'
|
|
@@ -257,7 +335,65 @@ export default {
|
|
|
console.log('cancel')
|
|
|
}
|
|
|
})
|
|
|
- }
|
|
|
+ },onBackPress(){
|
|
|
+ // console.log(this.pay_success,this.pay_success);
|
|
|
+ if (!this.pay_success) {
|
|
|
+ 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('取消前往')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return true;
|
|
|
+ }else{
|
|
|
+ this.getLastpage();
|
|
|
+ }
|
|
|
+ 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" && allPage[k].name != "views/Pay"){
|
|
|
+ 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;
|
|
|
+ },
|
|
|
}
|
|
|
</script>
|
|
|
|