浏览代码

Merge branch 'master' of iqiyoo:zhuishuyun_quickapp_front

xiabx 5 年之前
父节点
当前提交
bd9d373dc8
共有 8 个文件被更改,包括 361 次插入71 次删除
  1. 0 4
      src/api/utils.js
  2. 46 0
      src/assets/less/pay.less
  3. 17 3
      src/assets/less/reader.less
  4. 4 4
      src/helper/index.js
  5. 15 10
      src/views/Catalog/index.ux
  6. 169 1
      src/views/Home/index.ux
  7. 80 33
      src/views/Pay/index.ux
  8. 30 16
      src/views/Reader/index.ux

+ 0 - 4
src/api/utils.js

@@ -13,12 +13,8 @@ let token = null;
 export const getToken = async () => {
   if (getToken.promise) return getToken.promise;
 
-  console.log("token status", token);
-
   if (!token) token = (await storage.get({ key: "token" })).data;
 
-  console.log("123", token);
-
   // token格式化
   if (token && typeof token === "string") token = JSON.parse(token);
 

+ 46 - 0
src/assets/less/pay.less

@@ -211,6 +211,27 @@
     }
   }
 
+  .notice-wrap {
+    flex-direction: column;
+    padding: 0 24px;
+    margin-top: 20px;
+
+    text {
+      font-size: 24px;
+      color: #999;
+    }
+
+    .title {
+      font-size: 26px;
+      font-weight: bold;
+      color: #333;
+    }
+
+    .notice-item {
+      margin-top: 10px;
+    }
+  }
+
   .stack-wrap {
     margin-bottom: 30px;
 
@@ -221,4 +242,29 @@
       right: 0;
     }
   }
+
+  .loading-wrap {
+    position: fixed;
+    top: 0;
+    bottom: 0;
+    left: 0;
+    right: 0;
+    background-color: rgba(0, 0, 0, .6);
+    justify-content: center;
+    align-items: center;
+
+    .loading-content {
+      width: 300px;
+      height: 100px;
+      border-radius: 6px;
+      background-color: #fff;
+      flex-direction: column;
+      justify-content: center;
+      align-items: center;
+
+      .loading-text {
+        font-size: 26px;
+      }
+    }
+  }
 }

+ 17 - 3
src/assets/less/reader.less

@@ -2,14 +2,14 @@
   flex-direction: column;
   background-color: #e6e6e6;
   width: 100%;
-  
+
   .reader-title {
     margin: 0 24px;
     padding: 40px 0;
     // border-bottom: 2px solid #ccc;
     justify-content: space-between;
     align-items: center;
-    
+
     .title {
       font-weight: bolder;
       color: #1a1a1a;
@@ -57,4 +57,18 @@
       text-align: center;
     }
   }
-}
+}
+.toast {
+  position: fixed;
+  top: 180px;
+  width: 100%;
+  justify-content: center;
+  text {
+    background-color: rgba(#1a1a1a, 0.15);
+    padding: 60px 30px;
+    color: #e6e6e6;
+    font-size: 40px;
+    justify-content: center;
+    border-radius: 5px;
+  }
+}

+ 4 - 4
src/helper/index.js

@@ -61,7 +61,7 @@ let useWxH5Pay = (params) => {
       success: (data) => {
         console.log("success", data);
         // app中返回prepayid web中返回final_url
-        resolve({ code: "0", data: data, order: config.trade_no, message: "订单已经提交" });
+        resolve({ code: "9000", data: data, order: config.trade_no, message: "订单已经提交" });
       },
       fail: (data, code) => {
         console.log("error");
@@ -70,7 +70,7 @@ let useWxH5Pay = (params) => {
       },
       cancel: () => {
         console.log("user cancel");
-        reject({ code: "-1", data: "", message: "user cancel" });
+        reject({ code: "6001", data: "", message: "user cancel" });
       }
     })
   })
@@ -95,7 +95,7 @@ let useWxAppPay = (params) => {
       success: (data) => {
         console.log("success", data);
         // app中返回prepayid web中返回final_url
-        resolve({ code: "0", data: data, order: config.trade_no, message: "订单已经提交" });
+        resolve({ code: "9000", data: data, order: config.trade_no, message: "支付成功" });
       },
       fail: (data, code) => {
         console.log("error");
@@ -104,7 +104,7 @@ let useWxAppPay = (params) => {
       },
       cancel: () => {
         console.log("user cancel");
-        reject({ code: "-1", data: "", message: "user cancel" });
+        reject({ code: "6001", data: "", message: "user cancel" });
       }
     })
   })

+ 15 - 10
src/views/Catalog/index.ux

@@ -47,19 +47,24 @@ export default {
     }
     this.startpage = page;
     getCatalog({ bid: this.bid, page: page, page_size: PER_PAGE_NUM }).then(r => {
-       this.list = r.list
-      this.meta = r.meta 
-      setTimeout(()=>{
+      this.list = r.list
+      this.meta = r.meta
+      setTimeout(() => {
         this.$element('catalog').scrollTo({ index: chapter_sequence_index })
-      },500)
-      
+      }, 500)
+
     })
-    // this.list = Array(100).fill(null).map((_, k) => k);
-    // setTimeout(() => {
-    //   this.$element('catalog').scrollTo({ index: 20 });
-    // }, 1000);
   },
   jumpReader(info) {
+    if (info.is_need_charge == 1) {
+      router.push({
+        uri: "/views/Pay",
+        params: {
+          bid: info.bid,
+        }
+      })
+      return
+    }
     router.push({
       uri: "/views/Reader",
       params: {
@@ -73,7 +78,7 @@ export default {
       prompt.showToast({ message: '已经到底啦' });
       this.end = true;
       return;
-    };
+    }
     let params = {
       bid: '5pNo6A7wqQmB1WgQygDjkOM9VZn2vXeY',
       page: this.meta.current_page + 1,

+ 169 - 1
src/views/Home/index.ux

@@ -126,5 +126,173 @@ export default {
 </script>
 
 <style lang="less">
-@import "../../assets/less/home.less";
+/* @import "../../assets/less/home.less"; */
+.home-wrap {
+  background-color: #fff;
+  flex-direction: column;
+
+  .type-bar {
+    background-color: #fff;
+
+    .type-item {
+      flex: 1;
+      justify-content: center;
+      align-items: center;
+      flex-direction: column;
+      position: relative;
+
+      text {
+        font-size: 30px;
+        color: #999;
+        // padding: 34px 0;
+      }
+
+      .cur {
+        color: #ef5952;
+        font-size: 36px;
+        font-weight: bold;
+      }
+
+      .choose-bar {
+        width: 38px;
+        height: 4px;
+        background-color: #ef5952;
+        border-radius: 2px;
+        margin-top: 10px;
+      }
+    }
+  }
+
+  .search-bar {
+    padding: 24px;
+
+    .search-bar__wrap {
+      flex: 1;
+      background-color: #f7f7f7;
+      height: 62px;
+      padding: 0 14px;
+      border-radius: 30px;
+      align-items: center;
+
+      image {
+        margin-right: 20px;
+        width: 36px;
+        height: 36px;
+      }
+
+      text {
+        flex: 1;
+        font-size: 24px;
+        color: #999;
+      }
+    }
+  }
+
+  .swipe-bar {
+    height: 260px;
+    // background-color: #fff;
+
+    .swipe-item {
+      padding: 0px 24px;
+
+      .swipe-item__info {
+        flex: 1;
+        flex-direction: column;
+        padding-right: 32px;
+
+        .name {
+          font-size: 32px;
+          color: #333;
+        }
+
+        .intro {
+          font-size: 26px;
+          color: #666;
+          margin-top: 36px;
+          lines: 4;
+          text-overflow: ellipsis;
+        }
+
+        .category {
+          font-size: 24px;
+          color: #32a1ff;
+          margin-top: 10px;
+        }
+      }
+
+      .cover {
+        width: 100%;
+        height: 260px;
+        // flex-basis: 180px;
+        // flex-shrink: 0;
+        // height: 240px;
+        border-radius: 6px;
+      }
+    }
+  }
+
+  .book-list__wrap {
+    background-color: #fff;
+    // margin-top: 24px;
+    padding: 0 24px;
+    flex-direction: column;
+
+    .book-list__title {
+      padding: 30px 0;
+      align-items: center;
+
+      text {
+        color: #333;
+        font-size: 32px;
+      }
+    }
+  }
+
+  .book-list {
+    flex: 1;
+    flex-direction: row;
+    flex-wrap: wrap;
+    justify-content: space-between;
+  }
+
+  .book-list__multi {
+    margin-top: 30px;
+    flex-direction: column;
+
+    .book-item {
+      margin-bottom: 30px;
+    }
+
+    .book-info__multi {
+      flex: 1;
+      flex-direction: column;
+      justify-content: flex-start;
+      align-items: flex-start;
+      margin-left: 38px;
+      // margin-bottom: 40px;
+
+      .name {
+        font-size: 32px;
+        color: #333;
+        lines: 1;
+        text-overflow: ellipsis;
+      }
+
+      .intro {
+        font-size: 24px;
+        color: #666;
+        lines: 3;
+        text-overflow: ellipsis;
+        margin-top: 36px;
+        line-height: 36px;
+      }
+    }
+  }
+
+  .book-list__line {
+    justify-content: space-between;
+    align-items: flex-start;
+    border-bottom: 2px solid #f7f7f7;
+  }
+}
 </style>

+ 80 - 33
src/views/Pay/index.ux

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

+ 30 - 16
src/views/Reader/index.ux

@@ -2,27 +2,33 @@
  <import name="wechat-page" src="../../components/wechat/index.ux"></import> 
 <template>
   <div id="reader-content">
-    <div class="reader-wrap" id='list'>
-      <div class="reader-title">
-        <text class="title">{{bookinfo.chapter_name}}</text>
-        <!-- <text class="add-shelf" @click="addShelf">加入书架</text> -->
+    <stack>
+      <div class="reader-wrap" id='list'>
+        <div class="reader-title">
+          <text class="title">{{bookinfo.chapter_name}}</text>
+          <!-- <text class="add-shelf" @click="addShelf">加入书架</text> -->
+        </div>
+        <div class="reader-content">
+          <text class="chapter-text" for='content'>{{$item}}</text>
+        </div>
+        <div class="reader-operator">
+          <text class="operator prev" @click="getPrevChapter">上一章</text>
+          <text class="operator catalog" @click="toCatalog">目录</text>
+          <text class="operator next" @click="getNextChapter">下一章</text>
+        </div>
       </div>
-      <div class="reader-content">
-        <text class="chapter-text" for='content'>{{$item}}</text>
+      <short-page if="{{showShortPop}}" @addshort="shortEnd"></short-page>
+      <!-- <wechat-page></wechat-page> -->
+      <div class='toast' if="{{showtoast}}">
+        <text>正在加载中...</text>
       </div>
-      <div class="reader-operator">
-        <text class="operator prev" @click="getPrevChapter">上一章</text>
-        <text class="operator catalog" @click="toCatalog">目录</text>
-        <text class="operator next" @click="getNextChapter">下一章</text>
-      </div>
-    </div>
-    <short-page if="{{showShortPop}}" @addshort="shortEnd"></short-page>
-    <!-- <wechat-page></wechat-page> -->
+    </stack>
   </div>
 
 </template>
 
 <script>
+import prompt from '@system.prompt';
 import router from "@system.router";
 import storage from '@system.storage';
 import it from "../../helper/interface.js";
@@ -37,7 +43,8 @@ export default {
     bid: '',
     chapter_id: '',
     send_order_id: "",
-    canReadecid: ""
+    canReadecid: "",
+    showtoast: false
   },
   private: {
     bookinfo: {},
@@ -68,12 +75,14 @@ export default {
     this.showShortPop = !value.detail.installed;
   },
   getChapters(bid, chapter_id) {
+    this.showtoast = true
     console.log("router length:", router.getLength());
     getChapters({ bid: bid, chapter_id: chapter_id }).then(r => {
       this.content = r.chapter_content.trim().split(/\n/)
       this.bookinfo = r
       // this.$element('list').scrollTo({ index: 0 })
       this.addShelf();
+      this.showtoast = false
     }).catch(e => {
       console.log('e code')
       console.log(e.data)
@@ -82,10 +91,12 @@ export default {
         chapterOrders({ bid: bid, chapter_id: chapter_id }).then(r => {
           this.content = r.chapter_content.trim().split(/\n/)
           this.bookinfo = r
+          this.showtoast = false
           // this.$element('list').scrollTo({ index: 0 })
         }).catch(f => {
           console.log('f code')
           console.log(f.data)
+          this.showtoast = false
           if (f.data.code == '10014' || f.data.code == '10015') {
             this.getChapters(bid, this.canReadecid)
             router.push({
@@ -99,6 +110,7 @@ export default {
           }
         })
       } else if (e.data.code == '10014' || e.data.code == '10015') {
+        this.showtoast = false
         this.getChapters(bid, this.canReadecid)
         router.push({
           uri: "/views/Pay",
@@ -122,7 +134,9 @@ export default {
   },
   getPrevChapter() {
     console.log("get prev chapter");
-    // this.getChapters(this.bookinfo.bid, this.bookinfo.prev_cid)
+    if (this.bookinfo.prev_cid == 0) {
+      return prompt.showToast({ message: '已经是第一章啦' });
+    }
     router.replace({
       uri: "/views/Reader",
       params: {