Browse Source

活动支付逻辑修改

wangzq 2 năm trước cách đây
mục cha
commit
993139de92
2 tập tin đã thay đổi với 357 bổ sung14 xóa
  1. 207 0
      src/components/book/read_recom.ux
  2. 150 14
      src/views/Activity/index.ux

+ 207 - 0
src/components/book/read_recom.ux

@@ -0,0 +1,207 @@
+<template>
+  <div class="back-recom-box">
+    <div class="container">
+      <div class="close-box">
+        <image class="close-icon" @click="closeRecomBox" src="/assets/imgs/close.png"></image>
+      </div>
+      <div class="recom-title-box">
+        <text class="recom-title">超多人都在看的小说</text>
+      </div>
+      <div class="book-content">
+        <div for="{{recom_list}}" class="book-info-content">
+          <div class="book-image">
+            <image class="book-cover" src="{{$item.cover_url}}"></image>
+          </div>
+          <div class="book-info" onclick="toRead($item)">
+            <text class="book-name">{{ $item.book_name }}</text>
+            <text class="book-desc">{{ $item.book_summary }}</text>
+            <div class="book-option-box">
+              <text class="book-info-desc">{{ getInfo($item) }}</text>
+              <div class="book-read-btn-box">
+                <text class="book-read-btn">立即阅读</text>
+              </div>
+            </div>
+          </div>
+        </div>
+        <div class="change-box" @click="changeBook">
+          <text class="change-txt">换一换</text>
+          <image class="change-icon" src="/assets/imgs/change_icon.png"></image>
+        </div>
+      </div>
+    </div>
+  </div>
+</template>
+<script>
+import router from '@system.router'
+import { clickRecommendBooks} from "../../api";
+export default {
+  data: {
+    recom_list: [],
+  },
+
+  props: ['recom_list'],
+
+  onInit() {
+    // console.log('111111111111111111111', this.recom_list);
+  }, closeRecomBox() {
+      console.log('点击关闭');
+    this.$emit("addshort",{op:"close",is_close:true});
+  }, toRead(book) {
+    this.clickRecommendBooks(book.book_id);
+    router.push({
+      uri: '/views/Reader',
+      params: {
+        bid: book.book_id,
+        chapter_id: book.first_cid
+      }
+    })
+  }, getInfo(book) {
+    // return book.book_author + (book.book_end_satstu == 1 ? "·完结·" : "·连载·") + (book.book_word_count > 10000 ? (book.book_word_count / 10000).toFixed(2) + "万" : book.book_word_count) + "字";
+    return (book.book_end_satstu == 1 ? "完结·" : "连载·") + (book.book_word_count > 10000 ? (book.book_word_count / 10000).toFixed(2) + "万" : book.book_word_count) + "字";
+  },changeBook(){
+    // console.log('点击自组件');
+    this.$emit("addshort",{op:"change_book",is_close:false});
+   
+  },async clickRecommendBooks(bid){
+      clickRecommendBooks(bid);
+  }
+}
+</script>
+
+<style  lang="less" scoped>
+.change-box {
+  width: 100%;
+  margin-top: 41px;
+  justify-content: center;
+  flex-direction: row;
+}
+.change-icon{
+  width: 19px;
+  height: 19px;
+  object-fit: fill;
+  margin: 11px;
+}
+
+.change-txt {
+  width: 78px;
+  height: 37px;
+  font-size: 26px;
+  font-family: PingFangSC-Regular, PingFang SC;
+  font-weight: 400;
+  color: #f45e41;
+  line-height: 37px;
+}
+.back-recom-box {
+  flex-direction: column-reverse;
+  position: fixed;
+  width: 100%;
+  height: 100%;
+  bottom: 0px;
+  justify-content: center;
+  align-items: center;
+  background-color: rgba(24, 19, 19, 0.6);
+}
+.container {
+  width: 630px;
+  height: 887px;
+  background-color: #ffffff;
+  border-radius: 30px;
+  flex-direction: column;
+}
+.close-box {
+  width: 100%;
+  margin: 30px 0px 23px 0px;
+  flex-direction: row-reverse;
+}
+.close-icon {
+  width: 21px;
+  height: 21px;
+  margin-right: 30px;
+}
+.recom-title-box {
+  width: 100%;
+  justify-content: center;
+}
+.recom-title {
+  font-size: 34px;
+  font-family: PingFangSC-Semibold, PingFang SC;
+  font-weight: 600;
+  color: #333333;
+  line-height: 48px;
+}
+.book-content {
+  margin: 31px 34px 0 41px;
+  flex-direction: column;
+}
+.book-info-content {
+  flex-direction: row;
+  margin-top: 30px;
+  justify-content: space-between;
+}
+.book-image {
+  width: 132px;
+  height: 176px;
+  margin-right: 30px;
+  border-radius: 4px;
+}
+.book-cover {
+  width: 100%;
+  height: 100%;
+  object-fit: fill;
+  border-radius: 4px;
+}
+.book-info {
+  width: 393px;
+  flex-direction: column;
+}
+.book-name {
+  width: 393px;
+  lines: 1;
+  height: 45px;
+  font-size: 32px;
+  font-family: PingFangSC-Regular, PingFang SC;
+  font-weight: 400;
+  color: #333333;
+  line-height: 45px;
+}
+.book-desc {
+  margin: 11px 0px;
+  lines: 2;
+  width: 393px;
+  height: 66px;
+  font-size: 24px;
+  font-family: PingFangSC-Regular, PingFang SC;
+  font-weight: 400;
+  color: #666666;
+  line-height: 33px;
+  justify-content: space-around;
+}
+.book-option-box {
+  width: 393px;
+  margin-top: 18px;
+  justify-content: space-between;
+}
+.book-info-desc {
+  font-size: 24px;
+  font-family: PingFangSC-Regular, PingFang SC;
+  font-weight: 400;
+  color: #666666;
+  line-height: 33px;
+}
+.book-read-btn-box {
+  justify-content: center;
+  width: 118px;
+  padding: 0px 2px;
+  background-color: rgba(240, 90, 59, 0.2);
+  border-radius: 4px;
+}
+.book-read-btn {
+  height: 30px;
+  font-size: 22px;
+  font-family: PingFangSC-Regular, PingFang SC;
+  font-weight: 400;
+  color: #f05a3b;
+  line-height: 30px;
+  text-align: center;
+}
+</style>

+ 150 - 14
src/views/Activity/index.ux

@@ -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>