xuzhiheng 5 年之前
父節點
當前提交
1f23c28384

+ 157 - 32
src/jfw/modules/app/src/web/staticres/jyapp/dataExport/js/keyWord.js

@@ -23,7 +23,7 @@ $(function(){
         }
     }
     hasWords();
-    
+
     //添加按钮
     $(".addKeyWord i").on('click',function(){
         sessionStorage.removeItem("keyWord");
@@ -32,6 +32,7 @@ $(function(){
 
     // 添加keyWords检查输入框内是否有文字,如果有才能点击添加按钮
     $('.addkeyWord input.enterOne').on('input', function() {
+        var buttonDOM = $(this).siblings()[1].children[0];
         if ($(this).val().length >= 20) {
             var s = $(this).val().slice(0,19);
             $(this).val(s)
@@ -41,10 +42,8 @@ $(function(){
                 className: 'text-overflow100',
                 callback: function(){ console.log('close') }
             });
-            return
         }
 
-        var buttonDOM = $(this).siblings()[1].children[0];
         if ($(this).val().length >= 1) {
             buttonDOM.style.opacity = 1;
             buttonDOM.removeAttribute("disabled");
@@ -59,7 +58,7 @@ $(function(){
             $(this).next().find(".exclude").prop("disabled", true);
         }
     });
-    
+
     // $('.exclusion input.enterOne').on('input', function() {
     //     var buttonDOM = $(this).siblings().find('button')[0]
     //     if ($(this).val().length >= 1) {
@@ -70,42 +69,165 @@ $(function(){
     //         buttonDOM.setAttribute("disabled", true)
     //     }
     // })
-    
+
     // 添加 按钮的点击事件
     $('.addkeyWord .btn .save').on('click', function(){
         var keyWord = $('.addkeyWord input.enterOne').val();
+        var keyWordHtml = "";
+        var html = `
+                    <li>
+                        <div class="one">
+                            <div>
+                                <span>
+                                    <strong> 关键词:</strong>
+                                    <p class="key">${ keyWord }</p>
+                                </span>
+                            </div>
+                            <button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
+                        </div>
+                        <div class="modify">
+                            <span class="ios-user-select" contentEditable="true">${ keyWord }</span>
+                            <button class="addAdjunctWord">编辑 附加词</button>
+                            <button class="addExclusion">添加 排除词</button>
+                            <button class="deleteKey">删除</button>
+                            <button class="ascertainKey">确定</button>
+                        </div>
+                    </li>`;
+        if(sessionStorage.keyWord!==""&&sessionStorage.keyWord!==undefined){
+            var keys = JSON.parse(sessionStorage.keyWord);
+            for(var i in keys){
+                var append = keys[i].appended;
+                var exclude = keys[i].exclude;
+                if(keys[i].keyWord === keyWord){
+                    keyWordArr.push(keys[i]);
+                    localStorage.setItem("keyWord", JSON.stringify(keyWordArr));
+                    //
+                    if(append !== undefined && exclude === undefined){
+                        keyWordHtml += `
+                    <li>
+                        <div class="one">
+                            <div>
+                                <span>
+                                    <strong> 关键词:</strong>
+                                    <p class="key">${ keys[i].keyWord }</p>
+                                </span>
+                                <span>
+                                    <strong> 附加词:</strong>
+                                    <p class="addition">${ append }</p>
+                                </span>
+                            </div>
+                            <button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
+                        </div>
+                        <div class="modify">
+                            <span class="ios-user-select" contentEditable="true">${ keys[i].keyWord }</span>
+                            <button class="addAdjunctWord">编辑 附加词</button>
+                            <button class="addExclusion">添加 排除词</button>
+                            <button class="deleteKey">删除</button>
+                            <button class="ascertainKey">确定</button>
+                        </div>
+                    </li>`;
+                    }else if(append === undefined && exclude !== undefined){
+                        keyWordHtml += `
+                    <li>
+                        <div class="one">
+                            <div>
+                                <span>
+                                    <strong> 关键词:</strong>
+                                    <p class="key">${ keys[i].keyWord }</p>
+                                </span>
+                                <span>
+                                    <strong> 排除词:</strong>
+                                    <p class="exclusion">${ exclude }</p>
+                                </span>
+                            </div>
+                            <button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
+                        </div>
+                        <div class="modify">
+                            <span class="ios-user-select" contentEditable="true">${ keys[i].keyWord }</span>
+                            <button class="addAdjunctWord">编辑 附加词</button>
+                            <button class="addExclusion">添加 排除词</button>
+                            <button class="deleteKey">删除</button>
+                            <button class="ascertainKey">确定</button>
+                        </div>
+                    </li>`;
+                    }else if(append !== undefined && exclude !== undefined){
+                        keyWordHtml += `
+                    <li>
+                        <div class="one">
+                            <div>
+                                <span>
+                                    <strong> 关键词:</strong>
+                                    <p class="key">${ keys[i].keyWord }</p>
+                                </span>
+                                <span>
+                                    <strong> 附加词:</strong>
+                                    <p class="addition">${ append }</p>
+                                </span>
+                                <span>
+                                    <strong> 排除词:</strong>
+                                    <p class="exclusion">${ exclude }</p>
+                                </span>
+                            </div>
+                            <button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
+                        </div>
+                        <div class="modify">
+                            <span class="ios-user-select" contentEditable="true">${ keys[i].keyWord }</span>
+                            <button class="addAdjunctWord">编辑 附加词</button>
+                            <button class="addExclusion">添加 排除词</button>
+                            <button class="deleteKey">删除</button>
+                            <button class="ascertainKey">确定</button>
+                        </div>
+                    </li>`;
+                    }else if(append === undefined && exclude === undefined){
+                        keyWordHtml += `
+                    <li>
+                        <div class="one">
+                            <div>
+                                <span>
+                                    <strong> 关键词:</strong>
+                                    <p class="key">${ keys[i].keyWord }</p>
+                                </span>
+                            </div>
+                            <button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
+                        </div>
+                        <div class="modify">
+                            <span class="ios-user-select" contentEditable="true">${ keys[i].keyWord }</span>
+                            <button class="addAdjunctWord">编辑 附加词</button>
+                            <button class="addExclusion">添加 排除词</button>
+                            <button class="deleteKey">删除</button>
+                            <button class="ascertainKey">确定</button>
+                        </div>
+                    </li>`;
+                    }
+                    keyWordHtml = keyWordHtml.replace(/,/g, " ");
+                    //
+                    $('.showKeyWord > ul').prepend(keyWordHtml);
+                    // 隐藏
+                    $(".enter.addkeyWord").hide();
+                    $(".showKeyWord").show();
+                    $(".addKeyWord").show();
+                    $('.enter.addkeyWord > input').val('');
+                    var buttonDOM = $('.enter.addkeyWord .btn button')[0];
+                    buttonDOM.style.opacity = .5;
+                    buttonDOM.setAttribute("disabled", true);
+                    return
+                }
+            }
+        }
         var Obj = {"keyWord": keyWord};
         keyWordArr.push(Obj);
         localStorage.setItem("keyWord", JSON.stringify(keyWordArr));
-        var html = `<li>
-                    <div class="one">
-                        <div>
-                            <span>
-                                <strong> 关键词:</strong>
-                                <p class="key">${ keyWord }</p>
-                            </span>
-                        </div>
-                        <button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
-                    </div>
-                    <div class="modify">
-                        <span contentEditable="true">${ keyWord }</span>
-                        <button class="addAdjunctWord">编辑 附加词</button>
-                        <button class="addExclusion">添加 排除词</button>
-                        <button class="deleteKey">删除</button>
-                        <button class="ascertainKey">确定</button>
-                    </div>
-                </li>`
         $('.showKeyWord > ul').prepend(html);
-
         // 隐藏
         $(".enter.addkeyWord").hide();
         $(".showKeyWord").show();
         $(".addKeyWord").show();
-        $('.enter.addkeyWord > input').val('')
-        var buttonDOM = $('.enter.addkeyWord .btn button')[0]
-        buttonDOM.style.opacity = .5
-        buttonDOM.setAttribute("disabled", true)
-    })
+        $('.enter.addkeyWord > input').val('');
+        var buttonDOM = $('.enter.addkeyWord .btn button')[0];
+        buttonDOM.style.opacity = .5;
+        buttonDOM.setAttribute("disabled", true);
+
+    });
 
     // 编辑
     $(".showKeyWord").on('click', '.editKeyWord',function(e){
@@ -143,7 +265,8 @@ $(function(){
             }
         }
         $(this).parent().hide();
-        $(this).parent().siblings().css('display','block')
+        $(this).parent().siblings().css('display','block');
+        $(".addKeyWord").hide();
     });
 
     // 编辑删除
@@ -163,6 +286,8 @@ $(function(){
                     keyWordArr = keyWordArr.filter((e=>{return e.keyWord!==keyWord}));
                     localStorage.keyWord = JSON.stringify(keyWordArr);
                     jQueryDOM.remove();
+                    sessionStorage.removeItem("keyWord");
+                    $(".addKeyWord").show();
                     hasWords()
                 }
             }]
@@ -204,12 +329,13 @@ $(function(){
             $this.parent().siblings().find('.key').text(keyWord)
             $this.parent().hide().siblings().show()
         }
+        $(".addKeyWord").show();
     })
 
     //去空格方法
     String.prototype.trim = function(){
         return this.replace(/(^\s*)|(\s*$)/g, ' ');
-     }
+    }
 
     //关键词个数
     $('.modify span').keydown(function(){
@@ -244,5 +370,4 @@ $(function(){
         }
     }
 
-
 })

+ 2 - 1
src/jfw/modules/app/src/web/templates/dataExport/dataExport_area.html

@@ -696,10 +696,11 @@
 					 }else{
 					 	$(".reset-btn").show();
 					 }
+					 getResult();
 				 }else{
 					 $(".other").prop("checked", true);
 					 $(".reset-btn").hide();
-					 getResult()
+					 getResult();
 				 }
 				 //
 				 $(".tab_content").find(".city.active").each(function(){

+ 6 - 6
src/jfw/modules/app/src/web/templates/dataExport/dataExport_keyWord.html

@@ -303,7 +303,7 @@
                 var keys = JSON.parse(sessionStorage.keyWord);
                 for(var i in keys){
                     if(keys[i].keyWord===keyWord){
-                        window.location.href = "/front/wx_dataExport/appended?keyWord="+keyWord;
+                        window.location.href = "/jyapp/front/dataExport/appended?keyWord="+keyWord;
                         return
                     }
                 }
@@ -311,7 +311,7 @@
             //
             var obj = [{"keyWord":keyWord}];
             sessionStorage.keyWord = JSON.stringify(obj);
-            window.location.href = "/front/wx_dataExport/appended?keyWord="+keyWord;
+            window.location.href = "/jyapp/front/dataExport/appended?keyWord="+keyWord;
         });
         $(".exclude").on('click', function () {
             var keyWord = $(this).parent().prev().val();
@@ -322,7 +322,7 @@
                 var keys = JSON.parse(sessionStorage.keyWord);
                 for(var i in keys){
                     if(keys[i].keyWord===keyWord){
-                        window.location.href = "/front/wx_dataExport/exclude?keyWord="+keyWord;
+                        window.location.href = "/jyapp/front/dataExport/exclude?keyWord="+keyWord;
                         return
                     }
                 }
@@ -330,18 +330,18 @@
             //
             var obj = [{"keyWord":keyWord}];
             sessionStorage.keyWord = JSON.stringify(obj);
-            window.location.href = "/front/wx_dataExport/exclude?keyWord="+keyWord;
+            window.location.href = "jyapp/front/dataExport/exclude?keyWord="+keyWord;
         });
         //
         $(".showKeyWord").on('click', '.addAdjunctWord',function(e){
             var keyWord = $(this).parent().prev().find('.key').text();
             sessionStorage.removeItem("keyWord");
-            window.location.href = "/front/wx_dataExport/appended?keyWord="+keyWord;
+            window.location.href = "/jyapp/front/dataExport/appended?keyWord="+keyWord;
         });
         $(".showKeyWord").on('click', '.addExclusion',function(e){
             var keyWord = $(this).parent().prev().find('.key').text();
             sessionStorage.removeItem("keyWord");
-            window.location.href = "/front/wx_dataExport/exclude?keyWord="+keyWord;
+            window.location.href = "/jyapp/front/dataExport/exclude?keyWord="+keyWord;
         });
 
         $('.addkeyWord .btn .close').on('click', function () {

+ 19 - 0
src/web/staticres/wx_dataExport/js/keyWord.js

@@ -74,6 +74,25 @@ $(function(){
     $('.addkeyWord .btn .save').on('click', function(){
         var keyWord = $('.addkeyWord input.enterOne').val();
         var keyWordHtml = "";
+        var html = `
+                    <li>
+                        <div class="one">
+                            <div>
+                                <span>
+                                    <strong> 关键词:</strong>
+                                    <p class="key">${ keyWord }</p>
+                                </span>
+                            </div>
+                            <button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
+                        </div>
+                        <div class="modify">
+                            <span class="ios-user-select" contentEditable="true">${ keyWord }</span>
+                            <button class="addAdjunctWord">编辑 附加词</button>
+                            <button class="addExclusion">添加 排除词</button>
+                            <button class="deleteKey">删除</button>
+                            <button class="ascertainKey">确定</button>
+                        </div>
+                    </li>`;
         if(sessionStorage.keyWord!==""&&sessionStorage.keyWord!==undefined){
             var keys = JSON.parse(sessionStorage.keyWord);
             for(var i in keys){

+ 3 - 2
src/web/templates/weixin/dataExport/dataExport_area.html

@@ -661,11 +661,12 @@
 						 $(".other").prop("checked", true);
 					 }else{
 						$(".reset-btn").show();
-					}
+					 }
+					 getResult();
 				 }else{
 					 $(".other").prop("checked", true);
 					$(".reset-btn").hide();
-					 getResult()
+					 getResult();
 				 }
 				 //
 				 $(".tab_content").find(".city.active").each(function(){

+ 1 - 1
src/web/templates/weixin/dataExport/dataExport_keyWord.html

@@ -112,7 +112,7 @@
     </div>
     <script src="{{Msg "seo" "cdn"}}/wx_dataExport/js/zepto.js?v={{Msg "seo" "version"}}"></script>
     <script src="{{Msg "seo" "cdn"}}/wx_dataExport/js/weui.min.js?v={{Msg "seo" "version"}}"></script>
-    <script src="{{Msg "seo" "cdn"}}/wx_dataExport/js/keyWord.js?v={{Msg "seo" "version"}}46"></script>
+    <script src="{{Msg "seo" "cdn"}}/wx_dataExport/js/keyWord.js?v={{Msg "seo" "version"}}49"></script>
     <script>
         initShare({{.T.signature}},{{.T.openid}},2,"jy_wxmyorder",{{.T.nickname}},{{.T.avatar}});
         var keyWordArr = [];