|
@@ -41,122 +41,124 @@ var reloadFunc = function(){
|
|
|
|
|
|
// 添加 确认按钮的点击事件
|
|
|
$('.content .addkeyWord .btn button:nth-child(2)').on('click', function () {
|
|
|
- var keyWord = $('.addkeyWord input.enterOne').val();
|
|
|
- if(keyWord==""){
|
|
|
- return
|
|
|
- }
|
|
|
- if(kws_arr[keyWord]!=undefined){
|
|
|
- weui.toast('您设置的关键词已存在,请调整后再添加。', {
|
|
|
- duration: 2000,
|
|
|
- className: 'custom-toast',
|
|
|
- callback: function () { console.log('close') }
|
|
|
- });
|
|
|
- return
|
|
|
- }
|
|
|
- if(kws_name.length > 20){
|
|
|
- weui.toast('关键词不能超过20字', {
|
|
|
- duration: 2000,
|
|
|
- className: 'custom-toast',
|
|
|
- callback: function () { console.log('close') }
|
|
|
- });
|
|
|
- }
|
|
|
- kws_name = keyWord;
|
|
|
- kws_index = $(".showKeyWord li").length;
|
|
|
- if(kws_index==0){
|
|
|
- //分类首次添加关键词需重新获取分类索引
|
|
|
- classify_index = a_items.length;
|
|
|
- }
|
|
|
- var _index = 0;
|
|
|
- if($(".showKeyWord li").length>0){
|
|
|
- _index = Number($(".showKeyWord li:first").find(".editKeyWord").attr("dataIndex")) + Number(1);
|
|
|
- }
|
|
|
- classify_name = $('.classify-r .classify-detail').text();
|
|
|
- //保存关键词
|
|
|
- kws_count = parseInt(kws_count) + 1;
|
|
|
- if(kws_count>300){
|
|
|
- weui.toast('您设置的关键词已超出最高上限,请调整后再添加。', {
|
|
|
- duration: 2000,
|
|
|
- className: 'custom-toast',
|
|
|
- callback: function () { console.log('close') }
|
|
|
- });
|
|
|
- }else if (saveData("SK")){
|
|
|
- // 设置状态 首次添加关键词
|
|
|
- if(a_items.length==0){
|
|
|
- setEmptyHistory();
|
|
|
- }
|
|
|
- //
|
|
|
- doSessionData("",_index);
|
|
|
- $(".add-keyword-container .addNewKeyword i").show();
|
|
|
- //点击保存关键词,查看缓存中存的附加词 和排除词。
|
|
|
- $(".kws_count").text(kws_count);
|
|
|
- var html = `<li><div class="one"><div>
|
|
|
- <span>
|
|
|
- <strong> 关键词:</strong>
|
|
|
- <p class="key">${keyWord}</p>
|
|
|
- </span>`
|
|
|
- if (addition_kws.length>0){
|
|
|
- html +='<span>'
|
|
|
- +'<strong> 附加词:</strong>'
|
|
|
- +'<p class="addition">'+addition_kws.join(" ")+'</p>'
|
|
|
- +'</span>'
|
|
|
- }
|
|
|
- if (not_kws.length>0){
|
|
|
- html +='<span>'
|
|
|
- +'<strong> 排除词:</strong>'
|
|
|
- +'<p class="notkey">'+not_kws.join(" ")+'</p>'
|
|
|
- +'</span>'
|
|
|
- }
|
|
|
- html +=`</div>
|
|
|
- <button class="editKeyWord" dataIndex=`+_index+`><i class="iconfont icon-xiugai"></i> 修改</button>
|
|
|
- </div>
|
|
|
- <div class="modify">
|
|
|
- <textarea name="" rows="1" placeholder="" maxlength="20">${keyWord}</textarea>`
|
|
|
- if (addition_kws.length>0){
|
|
|
- html +=`<button class="addAdjunctWord" onClick="toappendkey(this)">编辑 附加词<i>(`+addition_kws.length+`)</i></button>`
|
|
|
- }else{
|
|
|
- html +=`<button class="addAdjunctWord" onClick="toappendkey(this)">添加 附加词</button>`
|
|
|
- }
|
|
|
- if (not_kws.length>0){
|
|
|
- html +=`<button class="addAdjunctWord" onClick="tonotkey(this)">编辑 排除词<i>(`+not_kws.length+`)</i></button>`
|
|
|
- }else{
|
|
|
- html +=`<button class="addAdjunctWord" onClick="tonotkey(this)">添加 排除词</button>`
|
|
|
- }
|
|
|
- html +=`<button class="deleteKey">删除</button><button class="ascertainKey" dataIndex=`+_index+` onclick="saveK(this)">确定</button></div></li>`
|
|
|
- $('.showKeyWord > ul').prepend(html);
|
|
|
- // 添加完成隐藏输入框
|
|
|
- $(".enter.addkeyWord").hide();
|
|
|
- // 还原状态
|
|
|
- $('.enter.addkeyWord > input').val('')
|
|
|
- //把kws_name,kws_index,addition_kws,not_kws初始化
|
|
|
- kws_index = 0;
|
|
|
- kws_name = "";
|
|
|
- addition_kws = [];
|
|
|
- not_kws = [];
|
|
|
- //
|
|
|
- var buttonDOM = $('.enter.addkeyWord .btn button')[1]
|
|
|
- buttonDOM.style.opacity = .5
|
|
|
- buttonDOM.setAttribute("disabled", true)
|
|
|
- //保存关键词 查看关键词数量 未分类 超过20 100提示
|
|
|
- if(classify_name.indexOf("未分类")>-1){
|
|
|
- if((kws_tips==1&&$(".showKeyWord li").length>=20)||(kws_tips==20&&$(".showKeyWord li").length>=100)){
|
|
|
- //未分类 20个关键词提示,100个关键词提示
|
|
|
- showMeg();
|
|
|
- var param = {};
|
|
|
- param.classify_index = classify_index;
|
|
|
- if(kws_tips==1){
|
|
|
- param.kws_tips = 20;
|
|
|
- }else if(kws_tips==20){
|
|
|
- param.kws_tips = 100;
|
|
|
- }
|
|
|
- $.post("/subscribepay/afterPay/updateUserTips",param,function(r){
|
|
|
- if(r.flag){
|
|
|
- kws_tips = param.kws_tips;
|
|
|
- $(".classify").attr("tips",kws_tips);
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ setTimeout(function(){
|
|
|
+ var keyWord = $('.addkeyWord input.enterOne').val();
|
|
|
+ if(keyWord==""){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(kws_arr[keyWord]!=undefined){
|
|
|
+ weui.toast('您设置的关键词已存在,请调整后再添加。', {
|
|
|
+ duration: 2000,
|
|
|
+ className: 'custom-toast',
|
|
|
+ callback: function () { console.log('close') }
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(kws_name.length > 20){
|
|
|
+ weui.toast('关键词不能超过20字', {
|
|
|
+ duration: 2000,
|
|
|
+ className: 'custom-toast',
|
|
|
+ callback: function () { console.log('close') }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ kws_name = keyWord;
|
|
|
+ kws_index = $(".showKeyWord li").length;
|
|
|
+ if(kws_index==0){
|
|
|
+ //分类首次添加关键词需重新获取分类索引
|
|
|
+ classify_index = a_items.length;
|
|
|
+ }
|
|
|
+ var _index = 0;
|
|
|
+ if($(".showKeyWord li").length>0){
|
|
|
+ _index = Number($(".showKeyWord li:first").find(".editKeyWord").attr("dataIndex")) + Number(1);
|
|
|
+ }
|
|
|
+ classify_name = $('.classify-r .classify-detail').text();
|
|
|
+ //保存关键词
|
|
|
+ kws_count = parseInt(kws_count) + 1;
|
|
|
+ if(kws_count>300){
|
|
|
+ weui.toast('您设置的关键词已超出最高上限,请调整后再添加。', {
|
|
|
+ duration: 2000,
|
|
|
+ className: 'custom-toast',
|
|
|
+ callback: function () { console.log('close') }
|
|
|
+ });
|
|
|
+ }else if (saveData("SK")){
|
|
|
+ // 设置状态 首次添加关键词
|
|
|
+ if(a_items.length==0){
|
|
|
+ setEmptyHistory();
|
|
|
+ }
|
|
|
+ //
|
|
|
+ doSessionData("",_index);
|
|
|
+ $(".add-keyword-container .addNewKeyword i").show();
|
|
|
+ //点击保存关键词,查看缓存中存的附加词 和排除词。
|
|
|
+ $(".kws_count").text(kws_count);
|
|
|
+ var html = `<li><div class="one"><div>
|
|
|
+ <span>
|
|
|
+ <strong> 关键词:</strong>
|
|
|
+ <p class="key">${keyWord}</p>
|
|
|
+ </span>`
|
|
|
+ if (addition_kws.length>0){
|
|
|
+ html +='<span>'
|
|
|
+ +'<strong> 附加词:</strong>'
|
|
|
+ +'<p class="addition">'+addition_kws.join(" ")+'</p>'
|
|
|
+ +'</span>'
|
|
|
+ }
|
|
|
+ if (not_kws.length>0){
|
|
|
+ html +='<span>'
|
|
|
+ +'<strong> 排除词:</strong>'
|
|
|
+ +'<p class="notkey">'+not_kws.join(" ")+'</p>'
|
|
|
+ +'</span>'
|
|
|
+ }
|
|
|
+ html +=`</div>
|
|
|
+ <button class="editKeyWord" dataIndex=`+_index+`><i class="iconfont icon-xiugai"></i> 修改</button>
|
|
|
+ </div>
|
|
|
+ <div class="modify">
|
|
|
+ <textarea name="" rows="1" placeholder="" maxlength="20">${keyWord}</textarea>`
|
|
|
+ if (addition_kws.length>0){
|
|
|
+ html +=`<button class="addAdjunctWord" onClick="toappendkey(this)">编辑 附加词<i>(`+addition_kws.length+`)</i></button>`
|
|
|
+ }else{
|
|
|
+ html +=`<button class="addAdjunctWord" onClick="toappendkey(this)">添加 附加词</button>`
|
|
|
+ }
|
|
|
+ if (not_kws.length>0){
|
|
|
+ html +=`<button class="addExclusion" onClick="tonotkey(this)">编辑 排除词<i>(`+not_kws.length+`)</i></button>`
|
|
|
+ }else{
|
|
|
+ html +=`<button class="addExclusion" onClick="tonotkey(this)">添加 排除词</button>`
|
|
|
+ }
|
|
|
+ html +=`<button class="deleteKey">删除</button><button class="ascertainKey" dataIndex=`+_index+` onclick="saveK(this)">确定</button></div></li>`
|
|
|
+ $('.showKeyWord > ul').prepend(html);
|
|
|
+ // 添加完成隐藏输入框
|
|
|
+ $(".enter.addkeyWord").hide();
|
|
|
+ // 还原状态
|
|
|
+ $('.enter.addkeyWord > input').val('')
|
|
|
+ //把kws_name,kws_index,addition_kws,not_kws初始化
|
|
|
+ kws_index = 0;
|
|
|
+ kws_name = "";
|
|
|
+ addition_kws = [];
|
|
|
+ not_kws = [];
|
|
|
+ //
|
|
|
+ var buttonDOM = $('.enter.addkeyWord .btn button')[1]
|
|
|
+ buttonDOM.style.opacity = .5
|
|
|
+ buttonDOM.setAttribute("disabled", true)
|
|
|
+ //保存关键词 查看关键词数量 未分类 超过20 100提示
|
|
|
+ if(classify_name.indexOf("未分类")>-1){
|
|
|
+ if((kws_tips==1&&$(".showKeyWord li").length>=20)||(kws_tips==20&&$(".showKeyWord li").length>=100)){
|
|
|
+ //未分类 20个关键词提示,100个关键词提示
|
|
|
+ showMeg();
|
|
|
+ var param = {};
|
|
|
+ param.classify_index = classify_index;
|
|
|
+ if(kws_tips==1){
|
|
|
+ param.kws_tips = 20;
|
|
|
+ }else if(kws_tips==20){
|
|
|
+ param.kws_tips = 100;
|
|
|
+ }
|
|
|
+ $.post("/subscribepay/afterPay/updateUserTips",param,function(r){
|
|
|
+ if(r.flag){
|
|
|
+ kws_tips = param.kws_tips;
|
|
|
+ $(".classify").attr("tips",kws_tips);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },150)
|
|
|
})
|
|
|
// 编辑
|
|
|
$(".showKeyWord").on('click', '.editKeyWord', function (e) {
|