Selaa lähdekoodia

优化快捷方式逻辑

xiabx 5 vuotta sitten
vanhempi
commit
ad4d48ca8c
4 muutettua tiedostoa jossa 43 lisäystä ja 37 poistoa
  1. 29 26
      src/components/short/index.ux
  2. 3 1
      src/helper/interface.js
  3. 6 6
      src/views/Index/index.ux
  4. 5 4
      src/views/Reader/index.ux

+ 29 - 26
src/components/short/index.ux

@@ -9,40 +9,43 @@
 
 export default {
 	data: {
-		
+
 	},
 	onInit() {
-		
+
 	},
-	createShortcut(){
+	createShortcut() {
 		// 创建快捷方式
-    this.$app.$def.createShortcut()
+		this.$app.$def.createShortcut(false, (value) => {
+			this.$app.$def.data.backClickCount = Number(value);
+			this.$dispatch('hasShort')
+		})
 	}
 }
 </script>
 
 
 <style lang="less" scoped>
-	.short{
-		&-wrap{
-			position: fixed;
-			bottom: 140px;
-			height: 80px;
-			justify-content: center;
-			width: 100%;
-		}
-		&-content{
-			background-color: #EF5952;
-			border-radius: 40px;
-			width: 600px;
-			align-items: center;
-			justify-content: center;
-		}
-		&-text {
-			color:#fff;
-			font-size: 30px;
-			font-weight: bold;
-			text-align: center;
-		}
-	}
+.short {
+  &-wrap {
+    position: fixed;
+    bottom: 140px;
+    height: 80px;
+    justify-content: center;
+    width: 100%;
+  }
+  &-content {
+    background-color: #ef5952;
+    border-radius: 40px;
+    width: 600px;
+    align-items: center;
+    justify-content: center;
+  }
+  &-text {
+    color: #fff;
+    font-size: 30px;
+    font-weight: bold;
+    text-align: center;
+  }
+}
 </style>

+ 3 - 1
src/helper/interface.js

@@ -24,7 +24,7 @@ const getShortCut = (fn) =>{
   
 }
 // 判断用户是否创建图标
-const hasCreateShortCut = (isPayPage = false) => {
+const hasCreateShortCut = (isPayPage = false,fn) => {
   shortcut.hasInstalled({
     success: (ret) => {
       if (!ret) {
@@ -32,8 +32,10 @@ const hasCreateShortCut = (isPayPage = false) => {
           message: "添加【追书云】到桌面,方便下次阅读",
           success: () => {
             prompt.showToast("添加成功!");
+            fn && fn(true);
           },
           fail: (code) => {
+            console.log('asdddddddd',code);
             if (code === SHORT_CUT_FORBIDDEN_INFO && !isPayPage) app.exit();
           }
         })

+ 6 - 6
src/views/Index/index.ux

@@ -28,8 +28,8 @@
       </div>
     </div>
     <image src="../../assets/imgs/sign_show.png" class="sign-icon" @click="changeSignPop"> </image>
-    <sign-page if="{{showSignPop}}"></sign-page>
-    <short-page if="{{showShortPop}}"></short-page>
+    <sign-page if="showSignPop"></sign-page>
+    <short-page if="showShortPop" @hasShort="hasShort"></short-page>
     <div class="stack-popup" @click="closeWrap" if="showPopup">
       <div class="customer-popup">
         <text class="title">联系客服</text>
@@ -90,11 +90,8 @@ export default {
   },
   onInit() {
     this.$on('dispathEvt', this.changeSignPop);
+    this.$on('hasShort',this.changeShortCut);
     //今日已签到过不在弹框签到
-    console.log("app backClickCount", this.$app.$def.data.backClickCount);
-    if (this.$app.$def.data.backClickCount === 0) {
-      this.showShortPop = true;
-    }
     this.getCoustom();
   },
   onShow() {
@@ -117,6 +114,9 @@ export default {
   onMenuPress() {
     this.$app.$def.showMenu();
   },
+  changeShortCut(){
+    this.showShortPop=false;
+  },
   async getCoustom() {
     let res = await getCustomQrcode();
     this.cutomerQrcode = res.url;

+ 5 - 4
src/views/Reader/index.ux

@@ -39,10 +39,8 @@ export default {
   },
   onInit() {
     this.getChapters(this.bid, this.chapter_id)
-    this.addShelf()
-    if (this.$app.$def.data.backClickCount === 0) {
-      this.showShortPop = true;
-    }
+    this.addShelf();
+    this.$on('hasShort',this.changeShortCut);
   },
   onShow() {
     it.getShortCut((value) => {
@@ -55,6 +53,9 @@ export default {
       r.is_on ? '' : postUserShelfBooks({ bid: this.bid })
     })
   },
+  changeShortCut(){
+    this.showShortPop=false;
+  },
   getChapters(bid, chapter_id) {
     getChapters({ bid: bid, chapter_id: chapter_id }).then(r => {
       this.content = r.chapter_content.trim().split(/\n/)