Răsfoiți Sursa

快速导入

wangshan 5 ani în urmă
părinte
comite
a5e5a6a4f9

+ 1 - 0
src/jfw/front/jyshare.go

@@ -3,6 +3,7 @@ package front
 import (
 	jutil "jfw/jyutil"
 	"jfw/public"
+	"log"
 	//"log"
 	"qfw/util/redis"
 	//"strconv"

+ 95 - 2
src/jfw/modules/subscribepay/src/service/afterPay.go

@@ -22,6 +22,93 @@ type AfterPay struct {
 	updateUserTips xweb.Mapper `xweb:"/afterPay/updateUserTips"` //修改用户未分类关键词提醒
 	directSubKWS   xweb.Mapper `xweb:"/afterPay/directSubKWS"`   //搜索列表直接订阅关键词
 	checkOrder     xweb.Mapper `xweb:"/afterPay/checkOrder"`     //是否有未执行的订单
+	fastImport     xweb.Mapper `xweb:"/afterPay/fastImport"`     //快速导入关键词
+}
+
+//
+func (a *AfterPay) FastImport() error {
+	defer qutil.Catch()
+	userId, _ := a.GetSession("userId").(string)
+	flagInt := 0
+	var _keys []map[string]interface{}
+	kwsCount := 0
+	classify_index := 0
+	kws_index := 0
+	if userId != "" {
+		data, ok := util.MQFW.FindById("user", userId, `{"o_jy":1,"o_vipjy":1,"i_vip_fastimport":1}`)
+		if ok && data != nil && len(*data) > 0 {
+			o_jy, _ := (*data)["o_jy"].(map[string]interface{})
+			if o_jy["a_key"] != nil && len(o_jy["a_key"].([]interface{})) > 0 { //普通用户存在设置的关键词
+				_keys = qutil.ObjArrToMapArr(o_jy["a_key"].([]interface{})) //普通用户设置的关键词
+				o_vipjy, _ := (*data)["o_vipjy"].(map[string]interface{})
+				if o_vipjy["a_items"] != nil {
+					a_items := o_vipjy["a_items"].([]interface{})
+					for k, v := range a_items {
+						tmp := qutil.ObjToMap(v.(map[string]interface{}))
+						a_key := (*tmp)["a_key"].([]interface{})
+						kwsCount = kwsCount + len(a_key)
+						if (*tmp)["s_item"] == "未分类" {
+							classify_index = k
+							kws_index = len(a_key)
+						}
+						for _, n := range a_key {
+							ntmp := qutil.ObjToMap(n.(interface{}))
+							nkey := qutil.ObjArrToStringArr((*ntmp)["key"].([]interface{}))
+							for i, m := range _keys {
+								mkey := qutil.ObjArrToStringArr(m["key"].([]interface{}))
+								if strings.Join(nkey, " ") == strings.Join(mkey, " ") {
+									_keys = append(_keys[:i], _keys[i+1:]...)
+								}
+							}
+						}
+					}
+				}
+				if len(_keys) > 0 {
+					if kwsCount >= 300 {
+						flagInt = -3 //超过最大设置量
+					} else {
+						if len(_keys)+kwsCount >= 300 {
+							_keys = _keys[:(300 - kwsCount)]
+						}
+						if classify_index == 0 && kws_index == 0 {
+							//首次添加分类和关键词
+							var o_kws = make(map[string]interface{})
+							classify_name := "未分类"
+							o_kws["s_item"] = classify_name
+							o_kws["i_tips"] = 0
+							o_kws["a_key"] = _keys
+							ok := util.MQFW.UpdateById("user", userId, bson.M{
+								"$push": bson.M{"o_vipjy.a_items": o_kws},
+								"$set":  bson.M{"o_vipjy.l_modifydate": time.Now().Unix(), "i_vip_fastimport": 1},
+							})
+							if ok {
+								flagInt = 1 //导入成功
+							}
+						} else {
+							ok := util.MQFW.UpdateById("user", userId, bson.M{
+								"$push": bson.M{"o_vipjy.a_items." + strconv.Itoa(classify_index) + ".a_key": bson.M{"$each": _keys}},
+								"$set":  bson.M{"o_vipjy.l_modifydate": time.Now().Unix(), "i_vip_fastimport": 1},
+							})
+							if ok {
+								flagInt = 1 //导入成功
+							}
+						}
+					}
+				} else {
+					flagInt = -2 //普通用户的关键词都已存在
+				}
+				log.Println(classify_index, kws_index, _keys)
+
+			} else {
+				flagInt = -1 //普通用户暂未设置关键词
+			}
+		}
+	}
+	a.ServeJson(map[string]interface{}{
+		"flagInt": flagInt,
+		"kwMap":   _keys,
+	})
+	return nil
 }
 
 //
@@ -301,10 +388,16 @@ func (a *AfterPay) GetUserInfo() error {
 	userId, _ := a.GetSession("userId").(string)
 	var userData *map[string]interface{}
 	if userId != "" {
-		userData, _ = util.MQFW.FindById("user", userId, `{"o_vipjy":1,"i_vip_status":1,"l_vip_starttime":1,"l_vip_endtime":1}`)
+		userData, _ = util.MQFW.FindById("user", userId, `{"o_vipjy":1,"o_jy":1,"i_vip_status":1,"l_vip_starttime":1,"l_vip_endtime":1,"i_vip_fastimport":1}`)
 		if *userData != nil && (qutil.IntAll((*userData)["i_vip_status"]) == 1 || qutil.IntAll((*userData)["i_vip_status"]) == 2) {
 			data := qutil.ObjToMap((*userData)["o_vipjy"])
 			i_vip_status := qutil.IntAll((*userData)["i_vip_status"])
+			o_jy, _ := (*data)["o_jy"].(map[string]interface{})
+			if o_jy["a_key"] != nil && len(o_jy["a_key"].([]interface{})) > 0 { //普通用户存在设置的关键词
+				(*userData)["ordinarykc"] = len(o_jy["a_key"].([]interface{}))
+			} else {
+				(*userData)["ordinarykc"] = 0
+			}
 			//区域
 			_buyset := qutil.ObjToMap((*data)["o_buyset"].(interface{}))
 			var area_i = qutil.IntAll((*_buyset)["areacount"])
@@ -371,7 +464,7 @@ func (a *AfterPay) GetUserInfo() error {
 			} else {
 				(*data)["a_infotype"] = ""
 			}
-
+			(*userData)["i_vip_fastimport"] = qutil.IntAll((*userData)["i_vip_fastimport"])
 		}
 		log.Println("userId:", userId)
 		a.ServeJson(map[string]interface{}{

+ 3 - 0
src/jfw/modules/weixin/src/wx/wx.go

@@ -1513,6 +1513,9 @@ func updateIsPush(openid string, status int) {
 
 //
 func vipFastSubscribe(user *map[string]interface{}, keyWord, openId string) (returnValue int, content string, hasOldKey bool) {
+	if keyWord == "" {
+		return
+	}
 	o_vipjy, _ := (*user)["o_vipjy"].(map[string]interface{})
 	var classify_index = 0 //未分类索引
 	//var keys_index = 0     未分类关键词组数量

+ 150 - 2
src/web/staticres/vipsubscribe/css/keyWord.css

@@ -46,7 +46,7 @@
 }
 
 .keyWord .add-keyword-container .classify-tips {
-  padding: .1rem .3rem .3rem;
+  padding: .1rem .3rem .2rem;
   font-size: .26rem;
   color: #888;
   line-height: .38rem;
@@ -470,4 +470,152 @@
     width: 50px;
 }
 .enter.addkeyWord{
-	margin-bottom: .2rem;
+	margin-bottom: .2rem;
+}
+
+.ios-user-select {
+    -webkit-user-select: text;
+}
+.opacity6{
+    opacity: 0.6;
+}
+.keysexplain{
+    position: fixed;
+height: .8rem;
+background: rgba(245,244,249,1);
+width: 100%;
+    font-size: .3rem;
+    padding-top: .18rem;
+    padding-left: .3rem;
+    color: #888;
+}
+.classifyKeysShow{
+    font-size: .25rem;
+    color: #686868;
+    margin-top: 0.1rem;
+    text-overflow: ellipsis;
+    overflow: hidden;
+    display: -webkit-box;
+    -webkit-line-clamp: 1;
+    -webkit-box-orient: vertical;
+}
+.addClassify{
+    height: 1rem;
+    text-align: center;
+    background: #2CB7CA;
+    width: 100%;
+    line-height: 1rem;
+    color:#FFFFFF;
+    font-size: .32rem;
+position:fixed;
+bottom:0px;
+}
+.classify-show-pop .weui-dialog .weui-dialog__hd {
+ padding: 0;
+ text-align: center;
+ font-size: .34rem;
+}
+.classify-show-pop .weui-dialog .weui-dialog__hd {
+    padding-left: .3rem;
+    height: .88rem;
+    line-height: .88rem;
+    background-color: #F4F4F9;
+}
+.classify-show-pop .weui-dialog .weui-dialog__bd {
+    padding: .38rem .1rem;
+    text-align: center;
+    font-size: .32rem;
+    color: #1d1d1d;
+    line-height: .6rem;
+}
+.classify-show-pop .weui-dialog .weui-dialog__bd .classify-keyword {
+    padding: 0 .17rem;
+    height: 0.8rem;
+    width: 100%;
+    font-size: .32rem;
+    border: 1px solid #CECECE;
+}
+
+.classify-show-pop .weui-dialog .weui-dialog__ft {
+    margin-top: .1rem;
+    margin-bottom: .3rem;
+    justify-content: space-around;
+}
+.classify-show-pop .weui-dialog .weui-dialog__ft .dialog__btn {
+    display: inline-block;
+    width: 1.72rem;
+    height: .72rem;
+    line-height: .72rem;
+    color: #fff;
+    font-size: .32rem;
+}
+.classify-show-pop .weui-dialog .weui-dialog__ft .dialog__btn_confirm {
+      background-color: #2CB7CA;
+}
+.classify-show-pop .weui-dialog .weui-dialog__ft .dialog__btn_cancel {
+      background-color: #BFBFC3;
+}
+.classify-show-pop .weui-dialog .weui-dialog__ft:after {
+      border: none;
+}
+.all-classify-column{
+      position: relative;
+      padding-bottom: 1rem;
+}
+.classify-fast{
+    width: 1.7rem;
+    text-align: center;
+    color: #2CB7CA;
+    font-size: 0.2rem;
+    padding: 0rem 0rem 0.1rem;
+    float: right;
+}
+
+.classify-fast-pop .weui-dialog .weui-dialog__hd {
+ padding: 0;
+ text-align: center;
+ font-size: .34rem;
+}
+.classify-fast-pop .weui-dialog .weui-dialog__hd {
+    padding-left: .3rem;
+    height: .88rem;
+    line-height: .88rem;
+    background-color: #F4F4F9;
+}
+.classify-fast-pop .weui-dialog .weui-dialog__bd {
+        padding: .38rem .4rem;
+    text-align: left;
+    font-size: .32rem;
+    color: #1d1d1d;
+    line-height: .45rem;
+    letter-spacing: 0.01rem
+}
+.classify-fast-pop .weui-dialog .weui-dialog__bd p {
+        color: #888;
+    font-size: .2rem;
+    margin-top: .2rem;
+    letter-spacing: 0.01rem;
+}
+
+.classify-fast-pop .weui-dialog .weui-dialog__ft {
+    margin-top: .1rem;
+    margin-bottom: .3rem;
+    justify-content: space-around;
+}
+.classify-fast-pop .weui-dialog .weui-dialog__ft .dialog__btn {
+    display: inline-block;
+    width: 1.72rem;
+    height: .72rem;
+    line-height: .72rem;
+    color: #fff;
+    font-size: .32rem;
+}
+.classify-fast-pop .weui-dialog .weui-dialog__ft .dialog__btn_confirm {
+      background-color: #2CB7CA;
+}
+.classify-fast-pop .weui-dialog .weui-dialog__ft .dialog__btn_cancel {
+      background-color: #BFBFC3;
+}
+.classify-fast-pop .weui-dialog .weui-dialog__ft:after {
+      border: none;
+}

+ 93 - 0
src/web/staticres/vipsubscribe/js/keyWord.js

@@ -268,6 +268,99 @@ var reloadFunc = function(){
     $('.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: {},
+            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">'+_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">删除</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();
+    })
     //
 
     $('.classify-edit-pop .classify-keyword').bind('input propertychange', function() {

+ 48 - 97
src/web/templates/weixin/vipsubscribe/keyWord.html

@@ -12,103 +12,6 @@
     <link rel="stylesheet" href="{{Msg "seo" "cdn"}}/vipsubscribe/css/weui.min.css?v={{Msg "seo" "version"}}">
     <link rel="stylesheet" href="{{Msg "seo" "cdn"}}/vipsubscribe/css/keyWord.css?v={{Msg "seo" "version"}}">
     <style>
-        .ios-user-select {
-            -webkit-user-select: text;
-        }
-        .opacity6{
-            opacity: 0.6;
-        }
-        .keysexplain{
-            position: fixed;
-		    height: .8rem;
-		    background: rgba(245,244,249,1);
-		    width: 100%;
-            font-size: .3rem;
-            padding-top: .18rem;
-            padding-left: .3rem;
-            color: #888;
-        }
-        .classifyKeysShow{
-            font-size: .25rem;
-            color: #686868;
-            margin-top: 0.1rem;
-            text-overflow: ellipsis;
-            overflow: hidden;
-            display: -webkit-box;
-            -webkit-line-clamp: 1;
-            -webkit-box-orient: vertical;
-        }
-        .addClassify{
-            height: 1rem;
-            text-align: center;
-            background: #2CB7CA;
-            width: 100%;
-            line-height: 1rem;
-            color:#FFFFFF;
-            font-size: .32rem;
-			position:fixed;
-			bottom:0px;
-        }
-
-        .classify-show-pop .weui-dialog .weui-dialog__hd {
-          padding: 0;
-          text-align: center;
-          font-size: .34rem;
-      }
-
-      .classify-show-pop .weui-dialog .weui-dialog__hd {
-          padding-left: .3rem;
-          height: .88rem;
-          line-height: .88rem;
-          background-color: #F4F4F9;
-      }
-
-      .classify-show-pop .weui-dialog .weui-dialog__bd {
-          padding: .38rem .1rem;
-          text-align: center;
-          font-size: .32rem;
-          color: #1d1d1d;
-          line-height: .6rem;
-      }
-
-      .classify-show-pop .weui-dialog .weui-dialog__bd .classify-keyword {
-          padding: 0 .17rem;
-          height: 0.8rem;
-          width: 100%;
-          font-size: .32rem;
-          border: 1px solid #CECECE;
-      }
-
-      .classify-show-pop .weui-dialog .weui-dialog__ft {
-          margin-top: .1rem;
-          margin-bottom: .3rem;
-          justify-content: space-around;
-      }
-
-      .classify-show-pop .weui-dialog .weui-dialog__ft .dialog__btn {
-          display: inline-block;
-          width: 1.72rem;
-          height: .72rem;
-          line-height: .72rem;
-          color: #fff;
-          font-size: .32rem;
-      }
-
-      .classify-show-pop .weui-dialog .weui-dialog__ft .dialog__btn_confirm {
-            background-color: #2CB7CA;
-      }
-
-      .classify-show-pop .weui-dialog .weui-dialog__ft .dialog__btn_cancel {
-            background-color: #BFBFC3;
-      }
-
-      .classify-show-pop .weui-dialog .weui-dialog__ft:after {
-            border: none;
-      }
-      .all-classify-column{
-            position: relative;
-            padding-bottom: 1rem;
-      }
     </style>
 </head>
 
@@ -126,6 +29,9 @@
                 <p class="classify-tips">
                     关键词分类便于对同类别关键词做整合管理
                 </p>
+                <p class="classify-fast" style="display:none;">
+                    快速导入
+                </p>
             </div>
             <section class="content">
                 <!-- 添加关键词 -->
@@ -224,6 +130,23 @@
                 </div>
             </div>
         </div>
+        <!-- 快速导入说明 -->
+        <div class="classify-fast-pop dialog-container">
+            <!-- <div class="weui-mask weui-animate-fade-in"></div> -->
+            <div class="weui-dialog weui-animate-fade-in">
+                <div class="weui-dialog__hd">
+                    <strong class="weui-dialog__title">快速导入</strong>
+                </div>
+                <div class="weui-dialog__bd">
+                    快速导入可将免费版招标订阅内所设置的关键词及其排除词将一并导入至“未分类"关键词分类内,无需再次手动输入,简化您的订阅过程。
+					<p style="color:#888;">注:地区与行业分类以VIP订阅设置内为准,不做导入。</p>
+                </div>
+                <div class="weui-dialog__ft">
+                    <a href="javascript:;" class="dialog__btn dialog__btn_confirm">确定</a> 
+                    <a href="javascript:;" class="dialog__btn dialog__btn_cancel">取消</a>
+                </div>
+            </div>
+        </div>
     </div>
     
     <script src="{{Msg "seo" "cdn"}}/js/jquery-3.2.1.min.js?v={{Msg "seo" "version"}}"></script>
@@ -246,6 +169,7 @@
         var classify_arr = [];//分类对象
         var kws_arr = {};//所有关键词对象
         var kws_tips = 0;
+		var fastimport = 0;//快速导入功能
         // 页面状态
         var pageState = {
             //是否第一次设置关键词
@@ -347,6 +271,12 @@
                 kws_index = sessionStorage.kws_index;
                 modifyFlag = true;
                 kws_count = sessionStorage.kws_count;
+				fastimport = parseInt(sessionStorage.fastimport);
+				if(fastimport==0){
+					$(".classify-fast").show();
+				}else{
+					$(".classify-fast").hide();
+				}
                 $(".kws_count").text(kws_count);
                $(".add-keyword-container .addNewKeyword i").hide();
                 toSetKws();
@@ -356,6 +286,15 @@
                     if(r.userData){
                         var _userData = r.userData;
                         var _vipData = _userData["o_vipjy"];
+						var ordinarykc = parseInt(_userData["ordinarykc"])
+						fastimport = parseInt(_userData["i_vip_fastimport"]);
+						if(fastimport==0&&ordinarykc>0){
+							sessionStorage.fastimport = fastimport;
+							$(".classify-fast").show();
+						}else{
+							sessionStorage.fastimport = 1;
+							$(".classify-fast").hide();
+						}
                         modifyFlag = false;
                         if (_vipData["a_items"]!=undefined&&_vipData["a_items"].length>0){
                             a_items = _vipData["a_items"]
@@ -777,6 +716,18 @@
 		    }
 		    $('input.classify-keyword').val(currentClassifyName).focus()
 		}
+		//
+		function modalTwo(){
+		    // 如果是苹果手机,打开时候要设置top
+		    var agent = navigator.userAgent.toLowerCase();
+		    var dialog = $('.classify-fast-pop .weui-dialog')
+		    if( /iphone|ipod|ipad|ios/.test(agent) ){
+		        dialog.css({ 'top': '30%' })
+		    } else {
+		        dialog.css({ 'top': '50%' })
+		    }
+		    $('.classify-fast-pop').show();
+		}
     </script>
     <script src="{{Msg "seo" "cdn"}}/vipsubscribe/js/keyWord.js?v={{Msg "seo" "version"}}23"></script>
     <script>