Просмотр исходного кода

hide entry of add icon after added

Zhengxiaowei 5 лет назад
Родитель
Сommit
31232c6eaf

+ 1 - 1
src/assets/less/detail.less

@@ -56,7 +56,7 @@
       }
 
       .read {
-        margin-left: 30px;
+        // margin-left: 30px;
         color: #fff;
         background-color: #ff6060;
       }

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

@@ -6,43 +6,60 @@
 	</div>
 </template>
 <script>
+import shortcut from '@system.shortcut';
+import prompt from '@system.prompt';
 
 export default {
 	data: {
-		
+
 	},
 	onInit() {
-		
+
 	},
-	createShortcut(){
+	createShortcut() {
 		// 创建快捷方式
-    this.$app.$def.createShortcut()
+		shortcut.hasInstalled({
+			success: (ret) => {
+				if (!ret) {
+					shortcut.install({
+						message: "添加【追书云】到桌面,方便下次阅读",
+						success: () => {
+							prompt.showToast("添加成功!");
+							this.$emit("addshort", { installed: true });
+						},
+						fail: (code) => {
+							this.$emit("addshort", { installed: false });
+						}
+					})
+				}
+			}
+		})
 	}
 }
 </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>

+ 2 - 2
src/helper/interface.js

@@ -15,13 +15,13 @@ const getDeviceInfo = () => {
   })
 }
 //获取是否创建图标
-const getShortCut = (fn) =>{
+const getShortCut = (fn) => {
   shortcut.hasInstalled({
     success: (ret) => {
       fn(ret);
     }
   })
-  
+
 }
 // 判断用户是否创建图标
 const hasCreateShortCut = (isPayPage = false) => {

+ 1 - 1
src/views/Detail/index.ux

@@ -13,7 +13,7 @@
           </div>
           <text class="words">字数:{{bookWordsFormat(book.book_word_count)}}</text>
           <div class="user-operator">
-            <text class="add" @click="addShelf">{{book.is_on_user_shelf ? '已加入' : '加入书架'}}</text>
+            <!-- <text class="add" @click="addShelf">{{book.is_on_user_shelf ? '已加入' : '加入书架'}}</text> -->
             <text class="read" @click="toRead(book.first_cid)">立即阅读</text>
           </div>
         </div>

+ 5 - 2
src/views/Index/index.ux

@@ -29,7 +29,7 @@
     </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>
+    <short-page if="{{showShortPop}}" @addshort="shortEnd"></short-page>
     <div class="stack-popup" @click="closeWrap" if="showPopup">
       <div class="customer-popup">
         <text class="title">联系客服</text>
@@ -102,11 +102,14 @@ export default {
       this.showShortPop = !value;
     })
   },
+  shortEnd(value) {
+    this.showShortPop = !value.detail.installed;
+  },
   onBackPress() {
     // 退出逻辑
     if (this.$app.$def.data.backClickCount === 0) {
       this.$app.$def.data.backClickCount++;
-      this.$app.$def.createShortcut()
+      this.$app.$def.createShortcut();
       return true;
     }
   },