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

feat:app搜索优化一键订阅功能

yangfeng пре 3 година
родитељ
комит
ade1709b14

+ 88 - 1
src/jfw/modules/app/src/web/staticres/jyapp/js/searchindex.js

@@ -58,7 +58,74 @@ function updateJump2() {
         }
     })
 }
-
+var vOneKeySubComponent  = new Vue({
+  delimiters: ['${', '}'],
+  el: '#oneKeySubCom',
+  data: {
+    subDialog: false,
+    showAreaPicker: false,
+    sub: {
+      showArea: true,
+      keyWords: '',
+      region: '',
+      remindChecd: false
+    },
+    regionData: [
+      '安徽','澳门','北京','重庆','福建','广东','广西','贵州','甘肃','河北','湖北','黑龙江','海南','河南','湖南','吉林','江苏','江西','辽宁','内蒙古','宁夏',
+      '青海','山西','陕西','上海','山东','四川','天津','台湾','西藏','新疆','香港','云南','浙江'
+    ],
+    freeSubArea: false
+  },
+  computed: {
+    subDisabled: function () {
+      if (this.sub.showArea) {
+        return !this.sub.region
+      } else {
+        return false
+      }
+    }
+  },
+  methods: {
+    onConfirm: function() {
+      // console.log(this.$refs.subAreaPicker.getValues(), '333');
+      var value = this.$refs.subAreaPicker.getValues()
+      this.sub.region = value[0];
+      this.showAreaPicker = false;
+    },
+    // 一键订阅、暂不订阅
+    oneKeySub: function(type) {
+      var _this = this
+      var data = type ? {
+        isNoSubscribe: 'Y', // 一键订阅
+        subsequentPrompt: _this.sub.remindChecd ? 'Y' : 'N',
+        key: _this.sub.keyWords,
+        area: _this.sub.region
+      } : {
+        isNoSubscribe: 'N', // 暂不订阅
+        subsequentPrompt: _this.sub.remindChecd ? 'Y' : 'N'
+      }
+      $.ajax({
+        type:'post',
+        url: '/bigmember/subscribe/freeUser/subscribeSearch',
+        data: data,
+        success: function(r){
+          if (r.data && r.data.status) {
+            if (type) { // 选择的一键订阅
+              _this.subDialog = false
+              _this.successDialog = true
+              _this.$toast('订阅关键词成功')
+            } else { // 选择的暂不订阅
+              _this.subDialog = false
+            }
+          } else {
+            // console.log('一键订阅失败', r.error_code);
+            _this.subDialog = false
+          }
+        }
+      })
+    }
+  }
+})
 $(function () {
     // var vConsole = new VConsole();
     if (mySysIsIos()) {//ios登陆后页面不刷新;导致重复登陆
@@ -1154,6 +1221,26 @@ var SuperSearch = {
                                 SuperSearch.noMoreData();
                                 $(".loading_").hide();
                                 return;
+                            } else {
+                              // 免费用户是否弹出一键订阅弹框
+                              var _this = this
+                              $.ajax({
+                                type:'get',
+                                url:'/bigmember/subscribe/freeUser/searchSubscribe',
+                                success: function(r){
+                                  if (r.data) {
+                                    vOneKeySubComponent.sub.showArea = r.data.areaSet
+                                    vOneKeySubComponent.freeSubArea = r.data.freeArea
+                                    vOneKeySubComponent.sub.keyWords = SuperSearch.s_words
+                                    // console.log(SuperSearch.s_words, vOneKeySubComponent, 'SuperSearch.s_words');
+                                    if (r.data.prompt) {
+                                      vOneKeySubComponent.subDialog = true
+                                    } else {
+                                      vOneKeySubComponent.subDialog = false
+                                    }
+                                  }
+                                }
+                              })
                             }
                             var html = SuperSearch.getHtml(data["list"], SuperSearch.reqParam["pageNum"]);
                             // 每次数据插入,必须重置

+ 134 - 0
src/jfw/modules/app/src/web/templates/weixin/search/tabSearch.html

@@ -654,6 +654,102 @@
         .keywordpopup{
           z-index: 2100;
         }
+        .onekey-sub-dialog .van-dialog__header{
+          padding-top: 24px;
+          color: #171826;
+          font-size: .36rem;
+        }
+        .onekey-sub-dialog .sub-dialog-message{
+          font-size: .3rem;
+          color: #5F5E64;
+          line-height: .44rem;
+          text-align: justify;
+        }
+        .onekey-sub-dialog .van-cell{
+          margin-top: .32rem;
+          border: 1px solid rgba(0, 0, 0, 0.1);
+          border-radius: 4px;
+          font-size: .3rem;
+        }
+        .onekey-sub-dialog .sub-dialog-checkbox{
+          margin: .48rem 0 .2rem;
+        }
+        .onekey-sub-dialog .van-checkbox__icon--checked .van-icon{
+          color: #fff;
+          background: #2ABED1;
+          border-color: #2ABED1;
+        }
+        .onekey-sub-dialog .sub-dialog-checkbox .van-checkbox__label{
+          font-size: .24rem;
+          color: #9B9CA3;
+        }
+        .onekey-sub-dialog .van-dialog__content{
+          padding: 0;
+        }
+        .onekey-sub-dialog .sub-dialog-content{
+          padding: 0.16rem 0.6rem
+        }
+        .onekey-sub-dialog .sub-dialog-footer{
+          position: relative;
+          display: flex;
+          overflow: hidden;
+          -webkit-user-select: none;
+          user-select: none;
+        }
+        .onekey-sub-dialog .sub-dialog-footer::after{
+          position: absolute;
+          box-sizing: border-box;
+          content: ' ';
+          pointer-events: none;
+          top: -50%;
+          right: -50%;
+          bottom: -50%;
+          left: -50%;
+          border: 0 solid #ebedf0;
+          -webkit-transform: scale(.5);
+          transform: scale(.5);
+          border-top-width: 1px;
+        }
+        .onekey-sub-dialog .sub-button{
+          position: relative;
+          flex: 1;
+          height: 48px;
+          margin: 0;
+          border: 0;
+          font-size: .36rem;
+          line-height: 26px;
+          background: transparent;
+        }
+        .onekey-sub-dialog .sub-button::before{
+          position: absolute;
+          top: 50%;
+          left: 50%;
+          width: 100%;
+          height: 100%;
+          background-color: #000;
+          border: inherit;
+          border-color: #000;
+          border-radius: inherit;
+          -webkit-transform: translate(-50%,-50%);
+          transform: translate(-50%,-50%);
+          opacity: 0;
+          content: ' ';
+        }
+        .onekey-sub-dialog .sub-button-confirm{
+          color: #2ABED1;
+        }
+        .onekey-sub-dialog .sub-button-confirm:disabled{
+          opacity: 0.5;
+        }
+        .sub-area-picker .van-picker-column__item{
+          width: 100%;
+        }
+        .sub-area-picker .van-picker__cancel,.sub-area-picker .van-picker__confirm{
+          font-size: 16px;
+        }
+        .sub-area-picker .van-picker__confirm{
+          color: #2ABED1;
+        }
 </style>
 
 <!--S-Loading-->
@@ -1738,6 +1834,44 @@
     <div id="tempDiv" style="display:none;"></div>
 </div>
 <div class="collection" id="date-picker-other-box"></div>
+<div id="oneKeySubCom">
+  <van-dialog class-name="onekey-sub-dialog" v-model="subDialog" width="303px" title="订阅搜索词" :show-confirm-button="false">
+    <div class="sub-dialog-content">
+      <div class="sub-dialog-message">剑鱼标讯推荐您将搜索词 <span style="color: #2ABED1;">“${sub.keyWords}”</span> 添加到您的订阅中,以保证及时接收项目信息。</div>
+      <van-field
+        v-if="sub.showArea"
+        readonly
+        clickable
+        name="picker"
+        :value="sub.region"
+        placeholder="请选择订阅区域"
+        @click="showAreaPicker = true"
+        is-link
+      ></van-field>
+      <div class="sub-dialog-checkbox">
+        <van-checkbox v-model="sub.remindChecd" icon-size="18px">后续不再提醒</van-checkbox>
+      </div>
+    </div>
+    <div class="sub-dialog-footer">
+      <button @click="oneKeySub(false)" type="button" class="sub-button sub-button-cancel van-hairline--right">暂不订阅</button>
+      <button @click="oneKeySub(true)" type="button" class="sub-button sub-button-confirm" :disabled="subDisabled">一键订阅</button>
+    </div>
+  </van-dialog>
+  <van-popup v-model="showAreaPicker" position="bottom" style="border-radius: 16px 16px 0 0;">
+    <van-picker 
+      ref="subAreaPicker"
+      class="sub-area-picker"
+      :show-toolbar="false"
+      :columns="regionData"
+    ></van-picker>
+    <div class="jyshxbottom sl-jyshxbottom">
+      <ul class="text-center j-button-group">
+          <li class="jydqreset j-button-cancel" @click="showAreaPicker = false">取消</li>
+          <li class="jydqsure j-button-confirm" @click="onConfirm">确定</li>
+      </ul>
+  </div>
+  </van-popup>
+</div>
 <!--S-底部提示-->
 <div class="resbm hidden" id="resbm">
     <div class="resbm0">

+ 2 - 2
src/web/templates/pc/supsearch.html

@@ -2353,12 +2353,12 @@ document.querySelector(".searchControl").oncopy = function(){
         var _this = this
         var data = type ? {
           isNoSubscribe: 'Y', // 一键订阅
-          subsequentPrompt: _this.remindChecd ? 'Y' : 'N',
+          subsequentPrompt: _this.sub.remindChecd ? 'Y' : 'N',
           key: $("#zbSeatchT [name='keywords']").val().trim(),
           area: _this.sub.region
         } : {
           isNoSubscribe: 'N', // 暂不订阅
-          subsequentPrompt: _this.remindChecd ? 'Y' : 'N'
+          subsequentPrompt: _this.sub.remindChecd ? 'Y' : 'N'
         }
         $.ajax({
           type:'post',