Explorar el Código

back home if direct into reader

Zhengxiaowei hace 5 años
padre
commit
7e233568f1
Se han modificado 2 ficheros con 10 adiciones y 2 borrados
  1. 4 2
      src/api/utils.js
  2. 6 0
      src/views/Reader/index.ux

+ 4 - 2
src/api/utils.js

@@ -46,8 +46,10 @@ export const login = async () => {
   let device_no = (await device.getUserId()).data.userId;
   let device_info = (await device.getInfo()).data;
   let send_order_id = (await storage.get({ key: "send_order_id" })).data;
-  let timestamp = parseInt(new Date().valueOf() / 1000)
-  let queryString = `device_info=${JSON.stringify(device_info)}&device_no=${device_no}&send_order_id=${send_order_id}&timestamp=${timestamp}&key=${signKey}`;
+  let timestamp = parseInt(new Date().valueOf() / 1000);
+  let queryString = "";
+  if (send_order_id) queryString = `device_info=${JSON.stringify(device_info)}&device_no=${device_no}&send_order_id=${send_order_id}&timestamp=${timestamp}&key=${signKey}`;
+  else queryString = `device_info=${JSON.stringify(device_info)}&device_no=${device_no}&timestamp=${timestamp}&key=${signKey}`;
   let data = qs.stringify({
     device_info: JSON.stringify(device_info),
     device_no: device_no,

+ 6 - 0
src/views/Reader/index.ux

@@ -68,6 +68,7 @@ export default {
     this.showShortPop = !value.detail.installed;
   },
   getChapters(bid, chapter_id) {
+    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
@@ -151,6 +152,11 @@ export default {
         canReadecid: this.bookinfo.chapter_id
       }
     })
+  },
+  onBackPress() {
+    if (router.getLength() === 1) {
+      router.replace({ uri: "/views/Index" });
+    }
   }
 }
 </script>