Преглед изворни кода

feat: wx.app三级也收藏添加标签完善

cuiyalong пре 4 година
родитељ
комит
1957924ec9

+ 43 - 34
src/jfw/modules/app/src/web/templates/weixin/wxinfocontent.html

@@ -10,6 +10,7 @@
     <link href="{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/wxswordfish/style.css?v={{Msg "seo" "version"}}" rel="stylesheet">
     <link rel="stylesheet" type="text/css" href="{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/css/share.css?v={{Msg "seo" "version"}}"/>
     <link rel="stylesheet" type="text/css" href="{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/css/wxinfocontent.css?v={{Msg "seo" "version"}}1"/>
+    <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/vant@2.8.2/lib/index.css">
 
     <script src="{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/local/jquery.min.js"></script>
     <script src="{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/local/fastclick.min.js"></script>
@@ -26,6 +27,9 @@
 <div class="loading_" id="loading" style="display: none;">
     <p><span></span></p>
 </div>
+<div id="jyKeepComponent">
+    <keep-component ref="vKeepComponent" @on-change-keep="changeKeepStatus" :bid="nowOpenBid" :first="false"></keep-component>
+</div>
 <div class="share1">
 
     <!-- 复制提示 star -->
@@ -613,6 +617,9 @@
         </div>
     </div>
 </div>
+<script src=//cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.min.js></script>
+<script src=//cdn.jsdelivr.net/npm/vant@2.8.2/lib/vant.min.js></script>
+<script src=/common-module/keep-tags/keep-tags-template.js></script>
 <script>
     var	shareimgflag = true;
     var area = {{.T.obj.area}}
@@ -1838,6 +1845,38 @@
       {{end}}
     })
 
+    var vKeepComponent = new Vue({
+        delimiters: ['${', '}'],
+        el: '#jyKeepComponent',
+        data: {
+            nowOpenBid: ''
+        },
+        methods: {
+            changeBid (id, type) {
+                this.nowOpenBid = id
+                this.$refs.vKeepComponent.ajaxAddKeep(id, type)
+            },
+            changeKeepStatus (type) {
+                changeCollectStatus(type)
+            }
+        }
+    })
+
+    
+    function changeCollectStatus (f) {
+        var $collButton = $('.collec_star')
+        var $icon = $collButton.children('.icon')
+        var $text = $collButton.children('.icon-text')
+        if (f) {
+            // 收藏
+            $icon.removeClass('weishoucang').addClass('shoucang')
+            $text.text('已收藏')
+        } else {
+            // 取消收藏
+            $icon.removeClass('shoucang').addClass('weishoucang')
+            $text.text('收藏')
+        }
+    }
     getCollectionState()
     function getCollectionState () {
         $.ajax({
@@ -1849,8 +1888,7 @@
             success: function (res) {
                 if (res.error_code === 0 && res.data) {
                     if (res.data.length) {
-                        $('.collec_star').children('.icon').removeClass('weishoucang').addClass('shoucang')
-                        $('.collec_star').children('.icon-text').text('已收藏')
+                        changeCollectStatus(true)
                     }
                 }
             }
@@ -1860,40 +1898,11 @@
         var $this = $(this)
         var $icon = $this.children('.icon')
         var $text = $this.children('.icon-text')
-        // 说明未收藏,点击收藏
-        var data = {
-            baction: '',
-            binfo: [{ bid: id }]
-        }
         var shoucang = $icon.hasClass('weishoucang')
-        if (shoucang) {
-            // 说明未收藏,点击收藏
-            data.baction = 'C'
-        } else {
-            data.baction = 'R'
+        // 说明未收藏,点击收藏
+        if (vKeepComponent) {
+            vKeepComponent.changeBid(id, shoucang)
         }
-        $.ajax({
-            url: '/publicapply/bidcoll/action',
-            type: 'POST',
-            contentType: 'application/json',
-            data: JSON.stringify(data),
-            success: function (res) {
-                if (res.error_code === 0 && res.data) {
-                    if (shoucang) {
-                        $icon.removeClass('weishoucang').addClass('shoucang')
-                        $text.text('已收藏')
-                        webToast("已收藏至“我的-标讯收藏”","middle", 1500);
-                        if (vKeepComponent) {
-                            vKeepComponent.changeBid(attrData.sid, !isStartStatus)
-                        }
-                    } else {
-                        $icon.removeClass('shoucang').addClass('weishoucang')
-                        $text.text('收藏')
-                        webToast("已取消收藏","middle", 1500);
-                    }
-                }
-            }
-        })
     })
 </script>
 {{include "/common/baiducc.html"}}

+ 60 - 58
src/web/templates/weixin/wxinfocontent_rec.html

@@ -6,6 +6,7 @@
 <link href="{{Msg "seo" "cdn"}}/css/wxcontentinfo.css?v={{Msg "seo" "version"}}1" rel="stylesheet">
 <link href="{{Msg "seo" "cdn"}}/css/bootstrap.min.css" rel="stylesheet">
 <link href="{{Msg "seo" "cdn"}}/wxswordfish/style.css?v={{Msg "seo" "version"}}" rel="stylesheet">
+<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/vant@2.8.2/lib/index.css">
 <script src="{{Msg "seo" "cdn"}}/js/jquery-3.2.1.min.js?v={{Msg "seo" "version"}}"></script>
 {{include "/common/weixin.html"}}
 <script src="{{Msg "seo" "cdn"}}/js/n_rem.js"></script>
@@ -589,7 +590,9 @@ pre {
 </style>
 </head>
 <body>
-<!--<div onclick="window.location.href='/supportJy'" style="font-size:15px;background-color: #FFB900;line-height: 50px;z-index: 2000;color: #fff;bottom: 0px;right: 0px;left:0px;position: fixed;"><img src="/images/search/laba.png" style="width: 23px;margin:0px 10px;">好几天没有推送消息了,真相是......</div>-->
+<div id="jyKeepComponent">
+    <keep-component ref="vKeepComponent" @on-change-keep="changeKeepStatus" :bid="nowOpenBid" :first="false"></keep-component>
+</div>
 <!-- 开启推送 -->
 <div class="open" onClick="window.location.href='/front/applysub/index'">
 	<a>一直收不到消息推送?激活一下就好!</a>
@@ -964,10 +967,9 @@ pre {
 		<span class="null-no">否</span>
 	</div>
 </div>
-<!--<script type="text/javascript">
-var ucbs_source="wx_rec",ucbsId="{{.T.obj.ucbsId}}";
-</script>
-<script type="text/javascript" src="/js/ucbs.js?v={{Msg "seo" "version"}}"></script>-->
+<script src=//cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.min.js></script>
+<script src=//cdn.jsdelivr.net/npm/vant@2.8.2/lib/vant.min.js></script>
+<script src=/common-module/keep-tags/keep-tags-template.js></script>
 <script>
 sessionStorage.removeItem("remind"); //开标提醒标识
 var inithgt = 45;//tab高度
@@ -2194,63 +2196,63 @@ function fromwhere(text){
   }
   return ad
 }
-    getCollectionState()
-    function getCollectionState () {
-        $.ajax({
-            url: '/publicapply/bidcoll/isColl',
-            type: 'POST',
-            data: {
-                bids: id
-            },
-            success: function (res) {
-                if (res.error_code === 0 && res.data) {
-                    if (res.data.length) {
-                        $('.collec_star').children('.icon').removeClass('weishoucang').addClass('shoucang')
-                        $('.collec_star').children('.icon-text').text('已收藏')
-                    }
-                }
-            }
-        })
-    }
-    $('.collec_star').on('click', function () {
-        var $this = $(this)
-        var $icon = $this.children('.icon')
-        var $text = $this.children('.icon-text')
-        // 说明未收藏,点击收藏
-        var data = {
-            baction: '',
-            binfo: [{ bid: id }]
-        }
-        var shoucang = $icon.hasClass('weishoucang')
-        if (shoucang) {
-            // 说明未收藏,点击收藏
-            data.baction = 'C'
-        } else {
-            data.baction = 'R'
+var vKeepComponent = new Vue({
+    delimiters: ['${', '}'],
+    el: '#jyKeepComponent',
+    data: {
+        nowOpenBid: ''
+    },
+    methods: {
+        changeBid (id, type) {
+            this.nowOpenBid = id
+            this.$refs.vKeepComponent.ajaxAddKeep(id, type)
+        },
+        changeKeepStatus (type) {
+            changeCollectStatus(type)
         }
-        $.ajax({
-            url: '/publicapply/bidcoll/action',
-            type: 'POST',
-            contentType: 'application/json',
-            data: JSON.stringify(data),
-            success: function (res) {
-                if (res.error_code === 0 && res.data) {
-                    if (shoucang) {
-                        $icon.removeClass('weishoucang').addClass('shoucang')
-                        $text.text('已收藏')
-                        EasyAlert.show("已收藏至“我的-标讯收藏”");
-                        if (vKeepComponent) {
-                            vKeepComponent.changeBid(attrData.sid, !isStartStatus)
-                        }
-                    } else {
-                        $icon.removeClass('shoucang').addClass('weishoucang')
-                        $text.text('收藏')
-                        EasyAlert.show("已取消收藏");
-                    }
+    }
+})
+
+function changeCollectStatus (f) {
+    var $collButton = $('.collec_star')
+    var $icon = $collButton.children('.icon')
+    var $text = $collButton.children('.icon-text')
+    if (f) {
+        // 收藏
+        $icon.removeClass('weishoucang').addClass('shoucang')
+        $text.text('已收藏')
+    } else {
+        // 取消收藏
+        $icon.removeClass('shoucang').addClass('weishoucang')
+        $text.text('收藏')
+    }
+}
+getCollectionState()
+function getCollectionState () {
+    $.ajax({
+        url: '/publicapply/bidcoll/isColl',
+        type: 'POST',
+        data: {
+            bids: id
+        },
+        success: function (res) {
+            if (res.error_code === 0 && res.data) {
+                if (res.data.length) {
+                    changeCollectStatus(true)
                 }
             }
-        })
+        }
     })
+}
+$('.collec_star').on('click', function () {
+    var $this = $(this)
+    var $icon = $this.children('.icon')
+    var $text = $this.children('.icon-text')
+    var shoucang = $icon.hasClass('weishoucang')
+    if (vKeepComponent) {
+        vKeepComponent.changeBid(id, shoucang)
+    }
+})
 </script>
 {{include "/common/baiducc.html"}}
 </body>