|
@@ -1,418 +1,407 @@
|
|
|
+var vm = new Vue({
|
|
|
+ delimiters: ['${', '}'],
|
|
|
+ el: '#app',
|
|
|
+ data: {
|
|
|
+ conf: {
|
|
|
+ keywordMax: 300
|
|
|
+ },
|
|
|
+ batchDeleteState: false, // 是否在批量删除状态
|
|
|
+ userData: {}, // getUserInfo接口用户原始数据
|
|
|
+ keywordsGroupList: [], // 所有关键词列表
|
|
|
+ groupNameList: [], // 关键词分类名称列表
|
|
|
+ // 当前信息
|
|
|
+ filter: {
|
|
|
+ loaded: false, // 是否请求加载完成
|
|
|
+ pickerShow: false, //picker是否显示
|
|
|
+ groupName: '', // 为空表示全部
|
|
|
+ allKeywordsList: [], // 筛选前的数组
|
|
|
+ keywordsList: [], // 筛选后的数组
|
|
|
+ },
|
|
|
+ dialog: {
|
|
|
+ fastImport: false, // 快速导入弹框
|
|
|
+ upgrade: false // 关键词升级提示弹框
|
|
|
+ },
|
|
|
+ tip: {
|
|
|
+ fastImport: true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ fastImportTipShow: function () {
|
|
|
+ return this.filter.allKeywordsList.length === 0 && this.filter.loaded && this.tip.fastImport
|
|
|
+ },
|
|
|
+ listShow: function () {
|
|
|
+ return this.filter.keywordsList.length !== 0 && this.filter.loaded
|
|
|
+ },
|
|
|
+ emptyShow: function () {
|
|
|
+ return this.filter.keywordsList.length === 0 && this.filter.loaded
|
|
|
+ },
|
|
|
+ selectedCount: function () {
|
|
|
+ var selectedArr = this.getSelectedArr()
|
|
|
+ return selectedArr.length
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created: function () {
|
|
|
+ this.getKeywordsGroupList(true)
|
|
|
+ },
|
|
|
+ mounted: function () {},
|
|
|
+ methods: {
|
|
|
+ showLoading: function () {
|
|
|
+ return this.$toast.loading({
|
|
|
+ duration: 0,
|
|
|
+ forbidClick: true,
|
|
|
+ message: 'loading...',
|
|
|
+ })
|
|
|
+ },
|
|
|
+ showToast: function (message) {
|
|
|
+ return this.$toast({
|
|
|
+ duration: 1500,
|
|
|
+ forbidClick: true,
|
|
|
+ message: message,
|
|
|
+ })
|
|
|
+ },
|
|
|
+ showDialog: function (conf) {
|
|
|
+ var defaultConf = {
|
|
|
+ title: '提示',
|
|
|
+ message: 'message',
|
|
|
+ className: 'j-confirm-dialog',
|
|
|
+ showConfirmButton: true,
|
|
|
+ showCancelButton: true,
|
|
|
+ confirmButtonColor: '#2abed1'
|
|
|
+ }
|
|
|
+ if (conf) {
|
|
|
+ Object.assign(defaultConf, conf)
|
|
|
+ }
|
|
|
+ return this.$dialog.confirm(defaultConf)
|
|
|
+ },
|
|
|
+ // 对象转form
|
|
|
+ qsStringify: function (t) {
|
|
|
+ var arr = []
|
|
|
+ for (var k in t) {
|
|
|
+ arr.push(`${k}=${t[k]}`)
|
|
|
+ }
|
|
|
+ return arr.join('&')
|
|
|
+ },
|
|
|
+ getKeywordsGroupList: function (needLoading) {
|
|
|
+ var _this = this
|
|
|
+ if (needLoading) {
|
|
|
+ var loading = this.showLoading()
|
|
|
+ }
|
|
|
+ $.ajax({
|
|
|
+ type: 'POST',
|
|
|
+ url: '/subscribepay/afterPay/getUserInfo?t=' + Date.now(),
|
|
|
+ success: function (res) {
|
|
|
+ if (needLoading) {
|
|
|
+ loading && loading.clear()
|
|
|
+ }
|
|
|
+ if (res && res.userData) {
|
|
|
+ _this.userData = res.userData
|
|
|
+ if (res.userData && res.userData.o_vipjy) {
|
|
|
+ // 整理数据
|
|
|
+ var groupList = _this.addInfoToKeyItem(res.userData.o_vipjy.a_items)
|
|
|
+ var groupNameList = _this.getGroupNameList(groupList)
|
|
|
+ _this.keywordsGroupList = groupList
|
|
|
+ _this.groupNameList = groupNameList
|
|
|
+ _this.doFilter(_this.filter.groupName)
|
|
|
+ _this.filter.allKeywordsList = _this.filterKeywordsList()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: function () {
|
|
|
+ if (needLoading) {
|
|
|
+ loading && loading.clear()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ complete: function () {
|
|
|
+ _this.filter.loaded = true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 向关键词中添加一些信息
|
|
|
+ addInfoToKeyItem: function (groupList) {
|
|
|
+ if (!Array.isArray(groupList)) return []
|
|
|
|
|
|
-var reloadFunc = function(){
|
|
|
-
|
|
|
- //去空格方法
|
|
|
- // String.prototype.trim = function () {
|
|
|
- // return this.replace(/(^\s*)|(\s*$)/g, ' ');
|
|
|
- // }
|
|
|
-
|
|
|
- // 疑问解答相关操作
|
|
|
- $('.knowBtn').on('click', function () {
|
|
|
- $(".problemPop").hide()
|
|
|
- })
|
|
|
- $(".problem").on('click', function () {
|
|
|
- $(".problemPop").css("display", 'flex');
|
|
|
- })
|
|
|
-
|
|
|
- $(".enterOne").focus(function () {
|
|
|
- $(".btnChoose").show();
|
|
|
- })
|
|
|
+ groupList.forEach(function (keywordsList, index) {
|
|
|
+ if (Array.isArray(keywordsList.a_key)) {
|
|
|
+ keywordsList.a_key.forEach(function (keyword, iindex) {
|
|
|
+ // 添加一些其他信息
|
|
|
+ keyword.groupName = keywordsList.s_item // 分类名
|
|
|
+ keyword.groupIndex = index // 该关键词所在分类 在分类列表中的索引
|
|
|
+ keyword.keyIndex = iindex // 该关键词在其所在分类中的索引
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
- // 输入框自适应高度
|
|
|
- $('textarea').each(function(i,dom){
|
|
|
- dom.style.height = dom.scrollHeight +'px';
|
|
|
- })
|
|
|
- $("textarea").on("input", function() {
|
|
|
- this.style.height = 'auto';
|
|
|
- this.style.height = this.scrollHeight + "px";
|
|
|
- })
|
|
|
+ return groupList
|
|
|
+ },
|
|
|
+ getGroupNameList: function (keywordsGroupList) {
|
|
|
+ var groupNameList = []
|
|
|
+ if (!Array.isArray(keywordsGroupList)) return groupNameList
|
|
|
+ keywordsGroupList.forEach(function (item, index) {
|
|
|
+ var count = Array.isArray(item.a_key) ? item.a_key.length : 0
|
|
|
+ groupNameList.push({
|
|
|
+ name: item.s_item, // 分类名
|
|
|
+ count: count // 分类下有多少个关键词
|
|
|
+ })
|
|
|
+ })
|
|
|
+ return groupNameList
|
|
|
+ },
|
|
|
+ calcKeyInfo: function (item) {
|
|
|
+ // 匹配方式 item.matchway 0/null精准 1模糊
|
|
|
+ var key = item.key
|
|
|
+ var notkey = []
|
|
|
+ if (Array.isArray(item.appendkey)) {
|
|
|
+ key = key.concat(item.appendkey)
|
|
|
+ }
|
|
|
+ if (Array.isArray(item.notkey)) {
|
|
|
+ notkey = item.notkey
|
|
|
+ }
|
|
|
|
|
|
- // 添加keyWords检查输入框内是否有文字,如果有才能点击添加按钮
|
|
|
- $('.content .addkeyWord input.enterOne').on('input', function () {
|
|
|
- var buttonDOM = $(this).siblings()[1].children[1]
|
|
|
- if ($.trim($(this).val()).length >= 1) {
|
|
|
- buttonDOM.style.opacity = 1
|
|
|
- buttonDOM.removeAttribute("disabled")
|
|
|
+ return {
|
|
|
+ key: key.join(' '),
|
|
|
+ notkey: notkey.join(' '),
|
|
|
+ matchWay: item.matchway == 1 ? '模糊' : '精准',
|
|
|
+ matchWayClass: item.matchway == 1 ? 'tag-orange' : 'tag-green'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ showFilterPicker: function (f) {
|
|
|
+ this.filter.pickerShow = f
|
|
|
+ },
|
|
|
+ checkThisGroup: function (item) {
|
|
|
+ var groupName = ''
|
|
|
+ if (item) {
|
|
|
+ groupName = item.name
|
|
|
+ } else {
|
|
|
+ groupName = ''
|
|
|
+ }
|
|
|
+ this.doFilter(groupName)
|
|
|
+ this.showFilterPicker(false)
|
|
|
+ },
|
|
|
+ doFilter: function (groupName) {
|
|
|
+ this.filter.groupName = groupName
|
|
|
+ var rList = this.filterKeywordsList(groupName)
|
|
|
+ this.filter.keywordsList = rList
|
|
|
+ },
|
|
|
+ // 筛选分类列表
|
|
|
+ filterKeywordsList: function (filterName) {
|
|
|
+ var list = []
|
|
|
+ // 筛选关键词
|
|
|
+ this.keywordsGroupList.forEach(function (keywordsList) {
|
|
|
+ if (Array.isArray(keywordsList.a_key)) {
|
|
|
+ keywordsList.a_key.forEach(function (keyword) {
|
|
|
+ // 筛选全部(筛选词为空),需要把关键词所属分类信息记录
|
|
|
+ if (!filterName) {
|
|
|
+ list.push(keyword)
|
|
|
+ } else {
|
|
|
+ if (filterName === keywordsList.s_item) {
|
|
|
+ list.push(keyword)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 给新的list添加checked
|
|
|
+ list = JSON.parse(JSON.stringify(list))
|
|
|
+ list.forEach(function (item) {
|
|
|
+ item.checked = false
|
|
|
+ item.calcInfo = this.calcKeyInfo(item)
|
|
|
+ }.bind(this))
|
|
|
+ return list
|
|
|
+ },
|
|
|
+ clickKeyCard: function (item) {
|
|
|
+ if (this.batchDeleteState) {
|
|
|
+ // 执行点击选中逻辑
|
|
|
+ // 如果关键词组下有关键词,则不能点击
|
|
|
+ item.checked = !item.checked
|
|
|
+ } else {
|
|
|
+ // type: edit编辑、add新增
|
|
|
+ // gIndex: groupIndex 该关键词所在分类 在分类列表中的索引
|
|
|
+ // kIndex: keyIndex 该关键词在其所在分类中的索引
|
|
|
+ location.href = `/front/vipsubscribe/toSetInfoPage?type=edit&gIndex=${item.groupIndex}&kIndex=${item.keyIndex}`
|
|
|
+ }
|
|
|
+ },
|
|
|
+ batchDeleteStateChange: function () {
|
|
|
+ this.batchDeleteState = !this.batchDeleteState
|
|
|
+ },
|
|
|
+ batchDelete: function () {
|
|
|
+ var _this = this
|
|
|
+ if (this.selectedCount <= 0) return
|
|
|
+ this.showDialog({
|
|
|
+ title: '',
|
|
|
+ message: '确定删除所选' + this.selectedCount + '个关键词吗?',
|
|
|
+ className: 'j-confirm-dialog text-center',
|
|
|
+ }).then(function () {
|
|
|
+ console.log('确认批量删除关键词')
|
|
|
+ _this.batchDeleteConfirmed()
|
|
|
+ })
|
|
|
+ .catch(function() {
|
|
|
+ console.log('取消批量删除关键词')
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getSelectedArr: function () {
|
|
|
+ var selectedArr = []
|
|
|
+ this.filter.keywordsList.forEach(function (item) {
|
|
|
+ if (item.checked) {
|
|
|
+ selectedArr.push(item)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return selectedArr
|
|
|
+ },
|
|
|
+ getDeleteKey: function () {
|
|
|
+ var deleteKeyArr = {}
|
|
|
+ var deleteKey = {}
|
|
|
+ var selectedArr = this.getSelectedArr()
|
|
|
+ selectedArr.forEach(function (item) {
|
|
|
+ var groupIndex = item.groupIndex
|
|
|
+ var keyIndex = item.keyIndex
|
|
|
+ if (deleteKeyArr[groupIndex]) {
|
|
|
+ deleteKeyArr[groupIndex].push(keyIndex)
|
|
|
} else {
|
|
|
- buttonDOM.style.opacity = .5
|
|
|
- buttonDOM.setAttribute("disabled", true)
|
|
|
+ deleteKeyArr[groupIndex] = [keyIndex]
|
|
|
}
|
|
|
- })
|
|
|
-
|
|
|
- // 添加 确认按钮的点击事件
|
|
|
- $('.content .addkeyWord .btn button:nth-child(2)').on('click', function () {
|
|
|
- setTimeout(function(){
|
|
|
- var keyWord = $.trim($('.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 = $.trim($('.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" addArr=\''+addition_kws+'\'>'+addition_kws.join(" ")+'</p>'
|
|
|
- +'</span>'
|
|
|
- }
|
|
|
- if (not_kws.length>0){
|
|
|
- html +='<span>'
|
|
|
- +'<strong> 排除词:</strong>'
|
|
|
- +'<p class="notkey" notArr=\''+not_kws+'\'>'+not_kws.join(" ")+'</p>'
|
|
|
- +'</span>'
|
|
|
- }
|
|
|
- html +="</div>"
|
|
|
- +"<button class=\"editKeyWord\" onClick=\"editKeyWord(this)\" 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\" onClick=\"deleteKey(this)\">删除</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) {
|
|
|
-// kws_name = $.trim($(this).parent().find('.key').text());
|
|
|
-// //当前关键词数组的位置 是数组的总长度-当前所在的位置-1 数组正序索引
|
|
|
-// kws_index = $('.showKeyWord li').length - $(this).parent().parent("li").index() -1;
|
|
|
-// if($(this).prev('div').find(".addition").text()!=""){
|
|
|
-// addition_kws = $(this).prev('div').find(".addition").attr("addArr").split(",")
|
|
|
-// }else{
|
|
|
-// addition_kws = []
|
|
|
-// }
|
|
|
-// if ($(this).prev('div').find(".notkey").text()!=""){
|
|
|
-// not_kws = $(this).prev('div').find(".notkey").attr("notArr").split(",")
|
|
|
-// }else{
|
|
|
-// not_kws = []
|
|
|
-// }
|
|
|
-// $('.enter.addkeyWord').hide()
|
|
|
-// var oSpan = $(this).parent().siblings().children('textarea');
|
|
|
-// var val = $.trim($(oSpan).val());
|
|
|
-// $(this).parent().hide()
|
|
|
-// $(this).parent().siblings().show().parent().siblings().children('.modify').hide().siblings('.one').show()
|
|
|
-// $(oSpan).val('').focus().val(val)
|
|
|
-// $(".add-keyword-container .addNewKeyword i").hide()
|
|
|
-// })
|
|
|
+ })
|
|
|
|
|
|
-// // 编辑删除
|
|
|
-// $('.showKeyWord').on('click', '.deleteKey', function (e) {
|
|
|
-// var delFlag = false;
|
|
|
-// var _index = Number($(this).next(".ascertainKey").attr("dataindex"));
|
|
|
-// var jQueryDOM = $(this).parents('li')
|
|
|
-// weui.confirm('确定要删除关键词?', {
|
|
|
-// buttons: [{
|
|
|
-// label: '取消',
|
|
|
-// type: 'default',
|
|
|
-// onClick: function () { console.log('不删了') }
|
|
|
-// }, {
|
|
|
-// label: '确定',
|
|
|
-// type: 'primary',
|
|
|
-// onClick: function () {
|
|
|
-// if (delFlag) {
|
|
|
-// return
|
|
|
-// }
|
|
|
-// delFlag = true;
|
|
|
-// if(saveData('DK')){
|
|
|
-// kws_count -= 1;
|
|
|
-// $(".kws_count").text(kws_count);
|
|
|
-// jQueryDOM.remove();
|
|
|
-// if($(".showKeyWord ul").find('li').length==0){
|
|
|
-// $(".enter.addkeyWord").find(".btnChoose button").eq(0).html('添加 附加词');
|
|
|
-// $(".enter.addkeyWord").find(".btnChoose button").eq(1).html('添加 排除词');
|
|
|
-// $(".enter.addkeyWord").find("input").val("");
|
|
|
-// }else{
|
|
|
-// $(".add-keyword-container .addNewKeyword i").show();
|
|
|
-// }
|
|
|
-// hasWords();
|
|
|
-// doSessionData('DK',_index);
|
|
|
-// //把kws_name,kws_index,addition_kws,not_kws初始化
|
|
|
-// kws_index = 0;
|
|
|
-// kws_name = "";
|
|
|
-// addition_kws = [];
|
|
|
-// not_kws = [];
|
|
|
-// }else{
|
|
|
-// weui.toast('无法删除', {
|
|
|
-// duration: 2000,
|
|
|
-// className: 'custom-toast',
|
|
|
-// callback: function () { console.log('close') }
|
|
|
-// });
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }]
|
|
|
-// });
|
|
|
-// console.log('删除关键词:', $(this).parent().find('textarea').val())
|
|
|
-
|
|
|
-// })
|
|
|
- // 编辑确定
|
|
|
- // $('.showKeyWord').on('click', '.ascertainKey', function (e) {
|
|
|
- // var $this = $(this)
|
|
|
- // var keyWord = $(this).siblings('textarea').val()
|
|
|
- // if(keyWord.length > 20){
|
|
|
- // weui.toast('关键词不能超过20字', {
|
|
|
- // duration: 2000,
|
|
|
- // className: 'custom-toast',
|
|
|
- // callback: function () { console.log('close') }
|
|
|
- // });
|
|
|
- // }else{
|
|
|
- // $this.parent().siblings().find('.key').text(keyWord)
|
|
|
- // $this.parent().hide().siblings().show()
|
|
|
- // $('.addKeyWord').show()
|
|
|
- // }
|
|
|
- // })
|
|
|
-
|
|
|
- //防止键盘把当前输入框给挡住
|
|
|
- var u = navigator.userAgent;
|
|
|
- var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
|
|
|
- var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
|
|
|
- if(isAndroid){
|
|
|
- //防止键盘把当前输入框给挡住
|
|
|
- window.addEventListener('resize', function () {
|
|
|
- if (document.activeElement.tagName == 'INPUT' || document.activeElement.tagName == 'TEXTAREA') {
|
|
|
- window.setTimeout(function () {
|
|
|
- document.activeElement.scrollIntoViewIfNeeded();
|
|
|
- }, 0);
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- (/iphone|ipod|ipad/i.test(navigator.appVersion)) && document.addEventListener('blur', function(e) {
|
|
|
- // 这里加了个类型判断,因为a等元素也会触发blur事件
|
|
|
- ['input', 'textarea'].includes(e.target.localName) && document.body.scrollIntoView(false)
|
|
|
- }, true)
|
|
|
-
|
|
|
- // 显示关键词分类弹框
|
|
|
- $('.classify-r').on('click', function(){
|
|
|
- modalOne();
|
|
|
- })
|
|
|
- // 显示快速导入弹框
|
|
|
- $('.classify-fast').on('click', function(){
|
|
|
- modalTwo();
|
|
|
- })
|
|
|
- // 关键词分类 - 去设置按钮点击事件
|
|
|
- $('.classify-fast-pop .dialog__btn_confirm').on('click', function() {
|
|
|
- $.ajax({
|
|
|
- type: "POST",
|
|
|
- url: "/subscribepay/afterPay/fastImport",
|
|
|
- data: {c_index:classify_index,k_index:$(".showKeyWord li").length,c_name:$(".classify-detail").text()},
|
|
|
- dataType: "json",
|
|
|
- async: false,
|
|
|
- traditional: true,
|
|
|
- success: function(r){
|
|
|
- $('.classify-fast-pop').hide();
|
|
|
- if(r.flagInt==1){
|
|
|
- sessionStorage.fastimport = r.flagInt;
|
|
|
- $(".classify-fast").hide();
|
|
|
- var kwcount = r.kwMap.length;
|
|
|
- var newCount = parseInt($(".addNewKeyword .kws_count").text())+parseInt(kwcount);
|
|
|
- $(".kws_count").text(newCount);
|
|
|
- weui.toast('成功导入'+kwcount+'个关键词', {
|
|
|
- duration: 2000,
|
|
|
- className: 'custom-toast',
|
|
|
- callback: function () { console.log('close') }
|
|
|
- });
|
|
|
- //if($(".classify .classify-detail").text()=="未分类"){
|
|
|
- var _keyArr = r.kwMap;
|
|
|
- var p = $(".showKeyWord li").length;
|
|
|
- if($(".showKeyWord li").length==0){
|
|
|
- var classifyArr = {"s_item":"未分类","a_key":[]}
|
|
|
- a_items.push(classifyArr);
|
|
|
- }else{
|
|
|
- a_items[classify_index]["s_item"]="未分类";
|
|
|
- }
|
|
|
- for (var i = 0; i< _keyArr.length; i++) {
|
|
|
- a_items[classify_index]["a_key"].push(_keyArr[i]);
|
|
|
- kws_arr[_keyArr[i]["key"].join(" ")] = p+"-"+classify_index
|
|
|
- var kwsHtml = '';
|
|
|
- var nk_showClass = 'hide';//是否显示排除词个数
|
|
|
- var nk_remark = '添加';
|
|
|
- var notkeylth = 0;
|
|
|
- kwsHtml +='<li>'
|
|
|
- kwsHtml +='<div class="one" style="">'
|
|
|
- kwsHtml +='<div>'
|
|
|
- +'<span><strong> 关键词:</strong>'
|
|
|
- +'<p class="key">'+_keyArr[i]["key"].join(" ")+'</p></span>'
|
|
|
- if (_keyArr[i]["notkey"]!=undefined&&_keyArr[i]["notkey"].length>0){
|
|
|
- nk_showClass = "";
|
|
|
- nk_remark = '编辑';
|
|
|
- notkeylth = _keyArr[i]["notkey"].length;
|
|
|
- kwsHtml +='<span>'
|
|
|
- +'<strong> 排除词:</strong>'
|
|
|
- +'<p class="notkey" notArr=\''+_keyArr[i]["notkey"]+'\'>'+_keyArr[i]["notkey"].join(" ")+'</p>'
|
|
|
- +'</span>'
|
|
|
- }
|
|
|
- kwsHtml +='</div>'
|
|
|
- +'<button class="editKeyWord" dataIndex="'+p+'"><i class="iconfont icon-xiugai"></i> 修改</button>'
|
|
|
- +'</div>'
|
|
|
-
|
|
|
- if(modifyFlag&&i==kws_index){
|
|
|
- kwsHtml +='<div class="modify" style="display:block;">'
|
|
|
- if(not_kws.length>0){
|
|
|
- notkeylth = not_kws.length;
|
|
|
- }
|
|
|
- }else{
|
|
|
- kwsHtml +='<div class="modify" style="display: none;">'
|
|
|
- }
|
|
|
- kwsHtml +='<textarea name="" rows="1" placeholder="" maxlength="20">'+_keyArr[i]["key"].join(" ")+'</textarea>'
|
|
|
- +'<button class="addAdjunctWord" onclick="toappendkey(this)">添加 附加词 <i class="appendkey hide">(0)</i></button>'
|
|
|
- +'<button class="addExclusion" onclick="tonotkey(this)">'+nk_remark+' 排除词 <i class="notkey '+nk_showClass+'">('+notkeylth+')</i></button>'
|
|
|
- +'<button class="deleteKey" onClick="deleteKey(this)">删除</button>'
|
|
|
- +'<button class="ascertainKey" dataIndex="'+p+'" onclick="saveK(this)">确定</button>'
|
|
|
- +'</div>'
|
|
|
- +'</li>'
|
|
|
- $(kwsHtml).prependTo(".showKeyWord ul");
|
|
|
- p = parseInt(p) + 1;
|
|
|
- }
|
|
|
- //}
|
|
|
- }else{
|
|
|
- weui.toast('导入失败', {
|
|
|
- duration: 2000,
|
|
|
- className: 'custom-toast',
|
|
|
- callback: function () { console.log('close') }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- })
|
|
|
- // 关键词分类 - 取消按钮点击事件
|
|
|
- $('.classify-fast-pop .dialog__btn_cancel').on('click', function() {
|
|
|
- $('.classify-fast-pop').hide();
|
|
|
- })
|
|
|
- //
|
|
|
+ for (var key in deleteKeyArr) {
|
|
|
+ if (Array.isArray(deleteKeyArr[key])) {
|
|
|
+ deleteKey[key] = deleteKeyArr[key].join(',')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return deleteKey
|
|
|
+ },
|
|
|
+ batchDeleteConfirmed: function () {
|
|
|
+ var deleteKey = this.getDeleteKey()
|
|
|
+ var loading = this.showLoading()
|
|
|
+ var _this = this
|
|
|
+ $.ajax({
|
|
|
+ url: '/subscribepay/afterPay/setUserInfo',
|
|
|
+ type: 'POST',
|
|
|
+ data: {
|
|
|
+ pageType: 'keyWords',
|
|
|
+ actionType: 'DK',
|
|
|
+ delete_key: JSON.stringify(deleteKey)
|
|
|
+ },
|
|
|
+ success: function (res) {
|
|
|
+ loading && loading.clear()
|
|
|
+ if (res.flag) {
|
|
|
+ _this.showToast('删除成功')
|
|
|
+ _this.getKeywordsGroupList()
|
|
|
+ _this.batchDeleteState = false
|
|
|
+ } else {
|
|
|
+ _this.showToast(res.msg ? res.msg : '删除失败' )
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: function () {
|
|
|
+ loading && loading.clear()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ beforeKeySwipeCellClose: function (e) {
|
|
|
+ // position 为关闭时点击的位置
|
|
|
+ // instance 为对应的 SwipeCell 实例
|
|
|
+ var position = e.position
|
|
|
+ var instance = e.instance
|
|
|
+ var index = e.name
|
|
|
|
|
|
- $('.classify-edit-pop .classify-keyword').bind('input propertychange', function() {
|
|
|
- var s = $('input.classify-keyword').val()
|
|
|
- // 去空格
|
|
|
- s = s.trim()
|
|
|
- if (s.length === 0) {
|
|
|
- $('.weui-dialog__ft .dialog__btn_confirm').addClass("opacity6");
|
|
|
- return
|
|
|
+ switch (position) {
|
|
|
+ case 'left': {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ case 'cell': {
|
|
|
+ instance.close()
|
|
|
+ break
|
|
|
}
|
|
|
- $('.weui-dialog__ft .dialog__btn_confirm').removeClass("opacity6");
|
|
|
- })
|
|
|
- // 关键词分类 - 确定按钮点击事件
|
|
|
- $('.classify-edit-pop .dialog__btn_confirm').on('click', function() {
|
|
|
- classify_name = $.trim($('input.classify-keyword').val());
|
|
|
- // 去空格
|
|
|
- classify_name = classify_name.trim();
|
|
|
- if (classify_name.length === 0) {
|
|
|
- return
|
|
|
+ case 'outside': {
|
|
|
+ instance.close()
|
|
|
+ break
|
|
|
}
|
|
|
- //分类名称是否已存在
|
|
|
- if($.inArray(classify_name, classify_arr)>-1){
|
|
|
- weui.toast('此分类名称已存在', {
|
|
|
- duration: 2000,
|
|
|
- className: 'custom-toast',
|
|
|
- callback: function () { console.log('close') }
|
|
|
- });
|
|
|
- return
|
|
|
+ case 'right': {
|
|
|
+ this.delThisKey(index, instance)
|
|
|
+ break
|
|
|
}
|
|
|
- if(classify_name.length > 20){
|
|
|
- classify_name = classify_name.substring(0,20);
|
|
|
- }
|
|
|
- $(this).removeClass("opacity6");
|
|
|
- $('.classify-r .classify-detail').text(classify_name);
|
|
|
- // 关闭弹框后要重置input内容
|
|
|
- $('.classify-edit-pop').hide();
|
|
|
- $('input.classify-keyword').val('');
|
|
|
- if($(".showKeyWord li").length>0){
|
|
|
- kws_name = classify_name;
|
|
|
- saveData('SC')
|
|
|
- kws_name = "";
|
|
|
- a_items[classify_index]["s_item"] = classify_name;
|
|
|
- setTimeout(function(){
|
|
|
- doSessionData();
|
|
|
- },300)
|
|
|
+ default: {
|
|
|
+ break
|
|
|
}
|
|
|
- })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 删除单个关键词
|
|
|
+ * @param {number} index 当前关键词在列表中的index
|
|
|
+ * @param {Object} instance SwipeCell的实例
|
|
|
+ */
|
|
|
+ delThisKey: function (index, instance) {
|
|
|
+ var _this = this
|
|
|
+ // 需要找到当前关键词组的item
|
|
|
+ var key = this.filter.keywordsList[index]
|
|
|
+ this.showDialog({
|
|
|
+ title: '',
|
|
|
+ message: '确定删除当前关键词?',
|
|
|
+ confirmButtonText: '删除',
|
|
|
+ className: 'j-confirm-dialog text-center'
|
|
|
+ }).then(function () {
|
|
|
+ // 点击确定,将当前关键词在批量选选择中,选中
|
|
|
+ key.checked = true
|
|
|
+ _this.batchDeleteConfirmed()
|
|
|
+ }).catch(function () {
|
|
|
+ console.log('取消删除关键词')
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 根据分类名,得到分类索引
|
|
|
+ getGroupIndexWithGroupName: function (gn) {
|
|
|
+ var groupIndex = -1
|
|
|
+ this.keywordsGroupList.forEach(function(item, index) {
|
|
|
+ console.log(item)
|
|
|
+ if (gn === item.s_item) {
|
|
|
+ groupIndex = index
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return groupIndex
|
|
|
+ },
|
|
|
+ addKeyWord: function () {
|
|
|
+ var query = {
|
|
|
+ type: 'add'
|
|
|
+ }
|
|
|
+ // 新增,往哪个分组下新增(默认往未分组下新增)
|
|
|
+ var groupIndex = this.getGroupIndexWithGroupName(this.filter.groupName)
|
|
|
+ if (groupIndex != -1) {
|
|
|
+ query.gIndex = groupIndex
|
|
|
+ }
|
|
|
|
|
|
- // 关键词分类 - 取消按钮点击事件
|
|
|
- $('.classify-edit-pop .dialog__btn_cancel').on('click', function() {
|
|
|
- $('.classify-edit-pop').hide()
|
|
|
- $('input.classify-keyword').val('')
|
|
|
- })
|
|
|
-}
|
|
|
+ var queryString = this.qsStringify(query)
|
|
|
+ location.href = '/front/vipsubscribe/toSetInfoPage' + '?' + queryString
|
|
|
+ },
|
|
|
+ toKeyManagePage: function () {
|
|
|
+ location.href = '/front/vipsubscribe/toSetManagePage'
|
|
|
+ },
|
|
|
+ fastImportDialogShow: function () {
|
|
|
+ this.dialog.fastImport = true
|
|
|
+ },
|
|
|
+ fastImport: function () {
|
|
|
+ var _this = this
|
|
|
+ var loading = this.showLoading()
|
|
|
+ $.ajax({
|
|
|
+ type: 'POST',
|
|
|
+ url: '/subscribepay/afterPay/fastImport',
|
|
|
+ data: {
|
|
|
+ c_index: _this.keywordsGroupList.length,
|
|
|
+ c_name: '未分类'
|
|
|
+ },
|
|
|
+ success: function (r) {
|
|
|
+ loading && loading.clear()
|
|
|
+ if (r.flagInt == 1) {
|
|
|
+ _this.showToast('成功导入' + r.kwMap.length + '个关键词')
|
|
|
+ _this.getKeywordsGroupList()
|
|
|
+ } else {
|
|
|
+ _this.showToast('导入失败')
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ JyObj.checkLab(); //刷新搜索首页和订阅首页
|
|
|
+ sessionStorage.reloadHomePage = true;
|
|
|
+ sessionStorage.reloadSubPage = true;
|
|
|
+ } catch (e) {}
|
|
|
+ },
|
|
|
+ error: function () {
|
|
|
+ loading && loading.clear()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+})
|