فهرست منبع

Merge branch 'dev2.9.8' of http://192.168.3.207:10080/qmx/jy into dev2.9.8

wangkaiyue 5 سال پیش
والد
کامیت
b6e7a175cc

+ 1 - 0
README.md

@@ -6,3 +6,4 @@ web用xweb框架
 v2.9.8
 线上课程
 
+

+ 32 - 17
src/jfw/modules/app/src/app/front/front.go

@@ -145,31 +145,46 @@ func (m *Front) Receive() error {
 		ok = mongodb.Update("message_app", map[string]interface{}{"_id": bson.ObjectIdHex(mid)}, map[string]interface{}{"$inc": map[string]interface{}{field: 1}}, false, false)
 	} else if recType == "C" && mid != "" && len([]rune(mid)) > 12 {
 		field := "i_click"
-		ok = mongodb.Update("message_app", map[string]interface{}{"_id": bson.ObjectIdHex(mid)}, map[string]interface{}{"$inc": map[string]interface{}{field: 1}}, false, false)
-		mongodb.Update("jyapp_notice", map[string]interface{}{
+		//打开计算一次 是否已经打开过
+		if c := mongodb.Count("jyapp_notice", map[string]interface{}{
 			"s_id":     mid, //信息id
 			"s_userid": userId,
-		}, map[string]interface{}{
-			"$set": map[string]interface{}{
-				"i_unread":    0,
-				"l_timestamp": time.Now().Unix(),
-			},
-		}, false, false)
+			"i_unread": 1, //1:未打开;0:已打开
+		}); c == 1 {
+			//更新信息为已读状态
+			mongodb.Update("jyapp_notice", map[string]interface{}{
+				"s_id":     mid, //信息id
+				"s_userid": userId,
+			}, map[string]interface{}{
+				"$set": map[string]interface{}{
+					"i_unread":    0,
+					"l_timestamp": time.Now().Unix(),
+				},
+			}, false, false)
+			//信息总量打开率+1
+			ok = mongodb.Update("message_app", map[string]interface{}{"_id": bson.ObjectIdHex(mid)}, map[string]interface{}{"$inc": map[string]interface{}{field: 1}}, false, false)
+		}
 	} else if recType == "A" && mid != "" && len([]rune(mid)) > 12 {
 		field := "i_delivery"
 		field1 := "i_click"
-		ok = mongodb.Update("message_app", map[string]interface{}{"_id": bson.ObjectIdHex(mid)}, map[string]interface{}{"$inc": map[string]interface{}{field: 1, field1: 1}}, false, false)
-		mongodb.Update("jyapp_notice", map[string]interface{}{
+		//打开计算一次 是否已经打开过
+		if c := mongodb.Count("jyapp_notice", map[string]interface{}{
 			"s_id":     mid, //信息id
 			"s_userid": userId,
-		}, map[string]interface{}{
-			"$set": map[string]interface{}{
-				"i_unread":    0,
-				"l_timestamp": time.Now().Unix(),
-			},
-		}, false, false)
+			"i_unread": 1, //1:未打开;0:已打开
+		}); c == 1 {
+			ok = mongodb.Update("message_app", map[string]interface{}{"_id": bson.ObjectIdHex(mid)}, map[string]interface{}{"$inc": map[string]interface{}{field: 1, field1: 1}}, false, false)
+			mongodb.Update("jyapp_notice", map[string]interface{}{
+				"s_id":     mid, //信息id
+				"s_userid": userId,
+			}, map[string]interface{}{
+				"$set": map[string]interface{}{
+					"i_unread":    0,
+					"l_timestamp": time.Now().Unix(),
+				},
+			}, false, false)
+		}
 	}
-
 	if ok {
 		go mesCaLog(mid, url, userId, recType)
 	} else {

+ 1 - 1
src/jfw/modules/app/src/app/front/me.go

@@ -114,7 +114,7 @@ func (m *Me) Notice() error {
 		mongodb.Update("jyapp_notice", map[string]interface{}{
 			"s_userid": userId,
 			"i_unread": 1,
-			"s_type":   map[string]interface{}{"$ne": "message"},
+			"$and":     []bson.M{bson.M{"s_type": bson.M{"$ne": "message"}}, bson.M{"s_type": bson.M{"$ne": "titleMessage"}}},
 		}, map[string]interface{}{
 			"$set": map[string]interface{}{
 				"i_unread":    0,

+ 37 - 0
src/jfw/modules/app/src/web/staticres/jyapp/js/searchindex.js

@@ -1,3 +1,36 @@
+$(function () {
+	// var vConsole = new VConsole();
+	window.nowTop = function () {
+		// console.log($("#searchIndex").offset(), $("#searchIndex").scrollTop())
+		var nT = $("#home_main").scrollTop()
+		if (nT === 0) {
+			nT = Math.abs($("#searchIndex").offset().top)
+		}
+		return nT
+	}
+	// 判断是否从缓存读取
+	var oldData = sessionStorage.getItem('main-save-dom')
+	var oldDataTime = sessionStorage.getItem('main-list-data-set-time')
+	if (oldData && oldDataTime) {
+		var nowDate = new Date().getTime()
+		if (nowDate - oldDataTime < (5 * 60 * 1000)) {
+			$(".home_data .data_list").html(JSON.parse(oldData))
+			var nowT = sessionStorage.getItem('main-scroll-top')
+			if (nowT) {
+				// $(window).scrollTop(Number(nowT))
+				$("#home_main").scrollTop(Number(nowT));
+				setTimeout(() => {
+					$("#home_main").scrollTop(Number(nowT));
+					sessionStorage.removeItem('main-scroll-top')
+				}, 200)
+			}
+		} else {
+			sessionStorage.removeItem('main-save-dom')
+			sessionStorage.removeItem('main-list-set-time')
+			sessionStorage.removeItem('main-scroll-top')
+		}
+	}
+})
 var SuperSearch = {
 	secondFlag:"",
 	secondList:"",
@@ -2188,6 +2221,9 @@ var SuperSearch = {
 	},
 	HomeToDetails:function(id){
 		if(id!=""){
+			sessionStorage.setItem('main-list-data-set-time', JSON.stringify(new Date().getTime()))
+			sessionStorage.setItem('main-scroll-top', nowTop())
+			sessionStorage.setItem('main-save-dom', JSON.stringify($("#home_main .data_list").html()))
 			window.location.href="/jyapp/article/content/"+id+".html"
 		}
 	},
@@ -2249,6 +2285,7 @@ var SuperSearch = {
 				}
 			}
 		}else{
+			$(".home_data .data_list").html('');
 			$(".no_data").show();
 		}
 	}

+ 2 - 1
src/jfw/modules/app/src/web/staticres/jyapp/me/logoff/css/public.css

@@ -81,7 +81,8 @@ textarea {
 .j-header .header-left {
   color: #5f5e64;
   color: #444;
-  font-size: 0.4rem;
+/*  font-size: 0.4rem;*/
+	font-size: 19px;
 }
 
 .j-header .header-title {

+ 2 - 2
src/jfw/modules/app/src/web/templates/me/notice.html

@@ -46,7 +46,7 @@
 		var userId = {{session "userId"}};
 		//JyObj初始化完成,回调
 		function afterJyObjInit(){
-			$.post("/jyapp/free/notice/list",null,function(r){
+			$.post("/jyapp/free/notice/list?t="+new Date().getTime(),null,function(r){
 				var serverHtml = "";
 				if(r.list != null && r.list != undefined){
 					for(var i=0;i<r.list.length;i++){
@@ -117,7 +117,7 @@
 				var descript = list[i].descript;
 				descript = descript.replace(/\n/g,"<br/>")
 				var userId = list[i].userid;
-				if(userId!=null&&typeof(userId)!="undefined"){
+				if(userId==null||typeof(userId)=="undefined"){
 					userId = "";
 				}
 				html += '<li class="clearfix" data-userid="'+userId+'" data-unread="'+list[i].i_unread+'"  data-category="'+list[i].s_type+'" data-id="'+list[i].id+'" data-link="'+link+'">'

+ 8 - 0
src/jfw/modules/app/src/web/templates/me/setting.html

@@ -9,6 +9,8 @@
     <meta http-equiv="X-UA-Compatible" content="ie=edge">
     <title>设置</title>
     <script src="{{Msg "seo" "cdn"}}/jyapp/me/logoff/js/rem.js?v={{Msg "seo" "version"}}"></script>
+		<link rel="stylesheet" type="text/css" href="{{Msg "seo" "cdn"}}/jyapp/me/css/reset.css?v={{Msg "seo" "version"}}" />
+		<link rel="stylesheet" type="text/css" href="{{Msg "seo" "cdn"}}/jyapp/css/font.css?v={{Msg "seo" "version"}}" />
     <link rel="stylesheet" href="{{Msg "seo" "cdn"}}/jyapp/me/logoff/css/weui.min.css?v={{Msg "seo" "version"}}">
     <link rel="stylesheet" href="{{Msg "seo" "cdn"}}/jyapp/me/logoff/css/base.css?v={{Msg "seo" "version"}}">
     <link rel="stylesheet" href="{{Msg "seo" "cdn"}}/jyapp/me/logoff/iconfont/iconfont.css?v={{Msg "seo" "version"}}">
@@ -24,6 +26,11 @@
 </style>
 
 <body>
+	<!--头部start-->
+	<div class="app-layout-header">
+		<span class="app-back jyapp-icon jyapp-icon-zuojiantou"></span>
+		推送消息设置
+	</div>
     <div class="j-container">
         <div class="j-header" style="z-index: 999;">
             <span class="header-left iconfont icon-fanhui"></span>
@@ -142,6 +149,7 @@
         			updateNoticeSwitch();
         		}
             $(".icon-fanhui").on("click",function(){
+				alert("----")
               history.go(-1);
             })
         })

+ 55 - 1
src/jfw/modules/app/src/web/templates/pdfjs/viewer.html

@@ -40,7 +40,33 @@ See https://github.com/adobe-type-tools/cmap-resources
     <script src="/jyapp/pdfjs/web/viewer.js"></script>
 
   </head>
-
+	<style>
+		#downloadPdf{
+			position: fixed;
+			left: 35%;
+			bottom: 10%;
+		}
+		#downloadInvoice{
+			display: flex;
+			width: 128px;
+			height: 30px;
+			align-items: center;
+			justify-content: center;
+			border-radius: 5px;
+			font-size: 14px;
+			border-radius: 18px;
+			line-height: 30px;
+			border: 1px solid #2cb7ca;
+			color: #2cb7ca;
+			background: transparent;
+		}
+		#secondaryToolbarToggle{
+			display: none;
+		}
+		#toolbarViewerLeft{
+			display: none;
+		}
+	</style>
   <body tabindex="1" class="loadingInProgress">
     <div id="outerContainer">
 
@@ -392,6 +418,34 @@ See https://github.com/adobe-type-tools/cmap-resources
 
     </div> <!-- outerContainer -->
     <div id="printContainer"></div>
+	<div id="downloadPdf">
+		<a id="downloadInvoice" download>下载发票</a>
+	</div>
+	<script src="/jyapp/course/js/jquery.min.js"></script>
+	<script type="text/javascript">
+		$(function(){
+			$("#downloadInvoice").on("click", function(){
+				var url = getParam("file");
+				var link = document.createElement("a");
+				link.href = url;
+				link.download = "电子发票.pdf";
+				document.body.appendChild(link);
+				link.click();
+				document.body.removeChild(link);
+			})
+			
+			function getParam(name) {
+				var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
+				var r = window.location.search.substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配
+				var context = "";
+				if (r != null)
+					context = r[2];
+				reg = null;
+				r = null;
+				return context == null || context == "" || context == "undefined" ? "" : context;
+			}
+		})
+	</script>
   </body>
 </html>
 

+ 2 - 1
src/jfw/modules/app/src/web/templates/vipsubscribe/keyWord.html

@@ -846,7 +846,7 @@
                             addition_kws = [];
                             not_kws = [];
                         } else {
-                            weui.toast('无法删除', {
+                            weui.toast('无法删除或已被删除', {
                                 duration: 2000,
                                 className: 'custom-toast',
                                 callback: function () {
@@ -1016,6 +1016,7 @@
             var reqData = JSON.parse(subVipState);
             reqData.items = a_items_m;
             sessionStorage.setItem('sub_vip_state', JSON.stringify(reqData))
+			sessionStorage.setItem('index_read_cache', '4');
         }
     }
 

+ 1 - 0
src/jfw/modules/app/src/web/templates/weixin/search/mainSearch.html

@@ -4,6 +4,7 @@
 <link href="{{Msg "seo" "cdn"}}/jyapp/css/searchindex.css?v={{Msg "seo" "version"}}" rel="stylesheet">
 <script src="{{Msg "seo" "cdn"}}/jyapp/js/jquery-3.2.1.min.js?v={{Msg "seo" "version"}}"></script>
 {{include "/common/js.html"}}
+<script src="https://cdn.bootcdn.net/ajax/libs/vConsole/3.3.4/vconsole.min.js"></script>
 <script src="{{Msg "seo" "cdn"}}/jyapp/js/dropload.js?v={{Msg "seo" "version"}}"></script>
 <script type="text/javascript" src="{{Msg "seo" "cdn"}}/jyapp/js/searchindex.js?v={{Msg "seo" "version"}}"></script>
 <title>搜索</title>

+ 185 - 78
src/jfw/modules/subscribepay/src/service/afterPay.go

@@ -2,9 +2,11 @@ package service
 
 import (
 	"fmt"
+	"log"
 	qutil "qfw/util"
 	"strconv"
 	"strings"
+	"sync"
 	"time"
 	"util"
 
@@ -12,6 +14,12 @@ import (
 	"gopkg.in/mgo.v2/bson"
 )
 
+type VIPLOCK struct {
+	Lock *sync.Mutex
+}
+
+var VIP_user_lock = map[string]*VIPLOCK{}
+
 //完成支付数据交互接口
 type AfterPay struct {
 	*xweb.Action
@@ -49,7 +57,7 @@ func (a *AfterPay) Modification() error {
 	return nil
 }
 
-//
+//快速导入普通订阅关键词
 func (a *AfterPay) FastImport() error {
 	defer qutil.Catch()
 	userId, _ := a.GetSession("userId").(string)
@@ -60,15 +68,23 @@ func (a *AfterPay) FastImport() error {
 	//	kws_index, _ := a.GetInteger("k_index")
 	classify_name := a.GetString("c_name")
 	if userId != "" {
+		var vip_lock = VIP_user_lock[userId]
+		if vip_lock == nil {
+			vip_lock = &VIPLOCK{}
+			vip_lock.Lock = &sync.Mutex{}
+			VIP_user_lock[userId] = vip_lock
+		}
+		vip_lock.Lock.Lock()
+		defer vip_lock.Lock.Unlock()
 		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 {
+				if o_vipjy["a_items"] != nil && len(o_vipjy["a_items"].([]interface{})) > 0 {
 					a_items := o_vipjy["a_items"].([]interface{})
-					for _, v := range a_items {
+					for k, v := range a_items {
 						tmp := qutil.ObjToMap(v.(map[string]interface{}))
 						a_key := (*tmp)["a_key"].([]interface{})
 						kwsCount = kwsCount + len(a_key)
@@ -76,6 +92,9 @@ func (a *AfterPay) FastImport() error {
 						//							classify_index = k
 						//							kws_index = len(a_key)
 						//						}
+						if classify_name == (*tmp)["s_item"].(string) && k != classify_index {
+							classify_index = k
+						}
 						for _, n := range a_key {
 							ntmp := qutil.ObjToMap(n.(interface{}))
 							nkey := qutil.ObjArrToStringArr((*ntmp)["key"].([]interface{}))
@@ -87,6 +106,8 @@ func (a *AfterPay) FastImport() error {
 							}
 						}
 					}
+				} else {
+					classify_index = 0
 				}
 				if len(_keys) > 0 {
 					if kwsCount >= 300 {
@@ -158,6 +179,14 @@ func (a *AfterPay) DirectSubKWS() error {
 	userId, _ := a.GetSession("userId").(string)
 	flag := "n"
 	if userId != "" {
+		var vip_lock = VIP_user_lock[userId]
+		if vip_lock == nil {
+			vip_lock = &VIPLOCK{}
+			vip_lock.Lock = &sync.Mutex{}
+			VIP_user_lock[userId] = vip_lock
+		}
+		vip_lock.Lock.Lock()
+		defer vip_lock.Lock.Unlock()
 		data, ok := util.MQFW.FindById("user", userId, `{"o_vipjy":1}`)
 		keys := a.GetString("keys")
 		var repleat = false
@@ -239,11 +268,19 @@ func (a *AfterPay) UpdateUserTips() error {
 	if userId != "" {
 		classify_index := a.GetString("classify_index")
 		kws_tips, _ := a.GetInteger("kws_tips")
-		saveData := make(map[string]interface{})
-		saveData["o_vipjy.a_items."+classify_index+".i_tips"] = kws_tips
-		flag = util.MQFW.UpdateById("user", userId, map[string]interface{}{
-			"$set": saveData,
-		})
+		data, ok := util.MQFW.FindById("user", userId, `{"o_vipjy.a_items":1}`)
+		if ok && data != nil && len(*data) > 0 {
+			o_vipjy, _ := (*data)["o_vipjy"].(map[string]interface{})
+			a_items := o_vipjy["a_items"].([]interface{})
+			i, _ := strconv.Atoi(classify_index)
+			if i < len(a_items) {
+				saveData := make(map[string]interface{})
+				saveData["o_vipjy.a_items."+classify_index+".i_tips"] = kws_tips
+				flag = util.MQFW.UpdateById("user", userId, map[string]interface{}{
+					"$set": saveData,
+				})
+			}
+		}
 	}
 	a.ServeJson(map[string]interface{}{
 		"flag": flag,
@@ -273,6 +310,14 @@ func (a *AfterPay) SetUserInfo() error {
 	userId, _ := a.GetSession("userId").(string)
 	var flag = false
 	if userId != "" {
+		var vip_lock = VIP_user_lock[userId]
+		if vip_lock == nil {
+			vip_lock = &VIPLOCK{}
+			vip_lock.Lock = &sync.Mutex{}
+			VIP_user_lock[userId] = vip_lock
+		}
+		vip_lock.Lock.Lock()
+		defer vip_lock.Lock.Unlock()
 		saveData := make(map[string]interface{})
 		//项目匹配
 		if a.GetString("pageType") == "projectMatch" {
@@ -303,97 +348,159 @@ func (a *AfterPay) SetUserInfo() error {
 			saveData["o_vipjy.s_email"] = s_email
 			saveData["o_vipjy.i_matchway"] = i_matchway
 		} else if a.GetString("pageType") == "keyWords" {
+			//保存关键词 多人同时操作导致或其他操作导致 分类索引或者关键词索引传值有误 会导致保存null值出现
+			//分类索引
 			classify_index := a.GetString("classify_index")
+			//分类名称
 			classify_name := strings.Trim(a.GetString("classify_name"), "")
+			//关键词索引
 			kws_index := a.GetString("kws_index")
+			//关键词名称
 			kws_name := strings.Trim(a.GetString("kws_name"), "")
+			//操作类型 SK:保存关键词; DK:删除关键词; SC:保存分类
 			actionType := a.GetString("actionType")
+			//附加词
 			addtion_kws := a.GetSlice("addition_kws")
+			//排除词
 			not_kws := a.GetSlice("not_kws")
+			//是否是首次添加关键词
 			kwscount := a.GetString("kwscount")
-			if len([]rune(kws_name)) > 20 {
-				kws_name = qutil.SubString(kws_name, 0, 20)
-			}
-			if kws_name != "" {
-				var _kws []string
-				for _, kn := range strings.Split(kws_name, " ") {
-					if kn != "" {
-						_kws = append(_kws, kn)
+			//关键词是否存在
+			canDel_k := false
+			//查询用vip关键词信息
+			data, ok := util.MQFW.FindById("user", userId, `{"o_vipjy.a_items":1}`)
+			if ok && data != nil && len(*data) > 0 {
+				o_vipjy, _ := (*data)["o_vipjy"].(map[string]interface{})
+				a_items := o_vipjy["a_items"].([]interface{})
+				i, _ := strconv.Atoi(classify_index)
+				j, _ := strconv.Atoi(kws_index)
+				var classifyArr map[string]interface{}
+				log.Println("前 i:", i, "-----", len(a_items))
+				for ak, av := range a_items {
+					//如果分类名称相同  则操作此分类
+					_av := qutil.ObjToMap(av)
+					if classify_name == qutil.ObjToString((*_av)["s_item"]) {
+						i = ak
+						break
+					}
+				}
+				if i != len(a_items) && len(a_items) != 0 {
+					log.Println("后 i:", i, "-----", len(a_items))
+					//从前端获取的分类索引是否超出了库中分类的总量 如果是  则认为修改此VIP分类最后一位
+					if i > len(a_items) {
+						i = len(a_items) //- 1
+						//新增分类,新增关键词
+						kws_index = "0"
+						kwscount = "0"
+					} else {
+						//获取当前分类
+						classifyArr = a_items[i].(map[string]interface{})
+						//从前端获取的关键词索引大于库中当前分类中的关键词数组总量 则认为修改此分类中关键词组的最后一位
+						if j > len(classifyArr["a_key"].([]interface{})) {
+							kws_index = strconv.Itoa(len(classifyArr["a_key"].([]interface{})))
+						}
+						kwscount = "1"
 					}
+				} else {
+					//i == len(a_items)  新增分类,新增关键词
+					kws_index = "0"
+					kwscount = "0"
+				}
+				classify_index = strconv.Itoa(i)
+				if len([]rune(kws_name)) > 20 {
+					kws_name = qutil.SubString(kws_name, 0, 20)
 				}
-				if actionType == "SK" && len(_kws) > 0 { //保存关键词
-					if len(addtion_kws) > 0 {
-						for i, addval := range addtion_kws {
-							if len([]rune(addval)) > 20 {
-								addval = qutil.SubString(addval, 0, 20)
+				if kws_name != "" {
+					var _kws []string
+					for _, kn := range strings.Split(kws_name, " ") {
+						if kn != "" {
+							_kws = append(_kws, kn)
+						}
+					}
+					if actionType == "SK" && len(_kws) > 0 { //保存关键词
+						//附加词处理 词过长或者为空的情况
+						if len(addtion_kws) > 0 {
+							for i, addval := range addtion_kws {
+								if len([]rune(addval)) > 20 {
+									addval = qutil.SubString(addval, 0, 20)
+								}
+								if addval == "" {
+									addtion_kws = append(addtion_kws[:i], addtion_kws[i+1:]...)
+								}
 							}
-							if addval == "" {
-								addtion_kws = append(addtion_kws[:i], addtion_kws[i+1:]...)
+						}
+						//排除词处理 词过长或者为空的情况
+						if len(not_kws) > 0 {
+							for i, notval := range not_kws {
+								if len([]rune(notval)) > 20 {
+									notval = qutil.SubString(notval, 0, 20)
+								}
+								if notval == "" {
+									not_kws = append(not_kws[:i], not_kws[i+1:]...)
+								}
 							}
 						}
-					}
-					if len(not_kws) > 0 {
-						for i, notval := range not_kws {
-							if len([]rune(notval)) > 20 {
-								notval = qutil.SubString(notval, 0, 20)
+						if kwscount != "0" {
+							//修改关键词
+							saveData["o_vipjy.a_items."+classify_index+".s_item"] = classify_name
+							saveData["o_vipjy.a_items."+classify_index+".a_key."+kws_index+".key"] = _kws
+							saveData["o_vipjy.a_items."+classify_index+".a_key."+kws_index+".appendkey"] = addtion_kws
+							saveData["o_vipjy.a_items."+classify_index+".a_key."+kws_index+".notkey"] = not_kws
+						} else {
+							//首次添加分类和关键词
+							var _key = make(map[string]interface{})
+							var a_key = make([]map[string]interface{}, 1)
+							if classify_name == "" {
+								classify_name = "未分类"
 							}
-							if notval == "" {
-								not_kws = append(not_kws[:i], not_kws[i+1:]...)
+							_key["key"] = _kws
+							_key["appendkey"] = addtion_kws
+							_key["notkey"] = not_kws
+							a_key[0] = _key
+							if len(a_key) > 0 {
+								flag = util.MQFW.UpdateById("user", userId, bson.M{
+									"$push": bson.M{
+										"o_vipjy.a_items." + classify_index + ".a_key": bson.M{
+											"$each": a_key,
+										},
+									},
+									"$set": bson.M{
+										"o_vipjy.l_modifydate":                          time.Now().Unix(),
+										"o_vipjy.a_items." + classify_index + ".s_item": classify_name,
+									},
+								})
 							}
 						}
-					}
-					if kwscount != "0" {
-						//修改关键词
-						saveData["o_vipjy.a_items."+classify_index+".s_item"] = classify_name
-						saveData["o_vipjy.a_items."+classify_index+".a_key."+kws_index+".key"] = _kws
-						saveData["o_vipjy.a_items."+classify_index+".a_key."+kws_index+".appendkey"] = addtion_kws
-						saveData["o_vipjy.a_items."+classify_index+".a_key."+kws_index+".notkey"] = not_kws
-					} else {
-						//首次添加分类和关键词
-						var _key = make(map[string]interface{})
-						var a_key = make([]map[string]interface{}, 1)
-						if classify_name == "" {
-							classify_name = "未分类"
+						//					}
+					} else if actionType == "DK" { //删除关键词
+						for _, kv := range classifyArr["a_key"].([]interface{}) {
+							_kv := qutil.ObjToMap(kv)
+							if strings.Join(qutil.ObjArrToStringArr((*_kv)["key"].([]interface{})), ",") == strings.Join(_kws, ",") {
+								canDel_k = true
+							}
 						}
-						_key["key"] = _kws
-						_key["appendkey"] = addtion_kws
-						_key["notkey"] = not_kws
-						a_key[0] = _key
-						if len(a_key) > 0 {
-							flag = util.MQFW.UpdateById("user", userId, bson.M{
-								"$push": bson.M{
-									"o_vipjy.a_items." + classify_index + ".a_key": bson.M{
-										"$each": a_key,
-									},
-								},
-								"$set": bson.M{
-									"o_vipjy.l_modifydate":                          time.Now().Unix(),
-									"o_vipjy.a_items." + classify_index + ".s_item": classify_name,
-								},
-							})
+						log.Println("canDel_k:", canDel_k)
+						//canDel_k true:存在此关键词 可以进行删除
+						if canDel_k {
+							//一个分类 删除最后一个关键词 则把这个分类也删除
+							if classifyArr != nil && len(classifyArr["a_key"].([]interface{})) == 1 {
+								a_items = append(a_items[:i], a_items[i+1:]...)
+								saveData["o_vipjy.a_items"] = a_items
+							} else if classifyArr != nil && len(classifyArr["a_key"].([]interface{})) > 1 {
+								//一个分类 删除非最后一个关键词  只需要操作此关键词即可
+								a_key := classifyArr["a_key"].([]interface{})
+								a_key = append(a_key[:j], a_key[j+1:]...)
+								saveData["o_vipjy.a_items."+classify_index+".a_key"] = a_key
+							}
 						}
-					}
-					//					}
-				} else if actionType == "DK" { //删除关键词
-					data, ok := util.MQFW.FindById("user", userId, `{"o_vipjy.a_items":1}`)
-					if ok && data != nil && len(*data) > 0 {
-						o_vipjy, _ := (*data)["o_vipjy"].(map[string]interface{})
-						a_items := o_vipjy["a_items"].([]interface{})
-						i, _ := strconv.Atoi(classify_index)
-						classifyArr := a_items[i].(map[string]interface{})
-						if classifyArr != nil && len(classifyArr["a_key"].([]interface{})) == 1 {
-							a_items = append(a_items[:i], a_items[i+1:]...)
-							saveData["o_vipjy.a_items"] = a_items
-						} else if classifyArr != nil && len(classifyArr["a_key"].([]interface{})) > 1 {
-							j, _ := strconv.Atoi(kws_index)
-							a_key := classifyArr["a_key"].([]interface{})
-							a_key = append(a_key[:j], a_key[j+1:]...)
-							saveData["o_vipjy.a_items."+classify_index+".a_key"] = a_key
+					} else if actionType == "SC" { //保存分类
+						if classifyArr["a_key"] != nil && len(classifyArr["a_key"].([]interface{})) > 0 {
+							saveData["o_vipjy.a_items."+classify_index+".s_item"] = classify_name
 						}
 					}
-				} else if actionType == "SC" { //保存分类
-					saveData["o_vipjy.a_items."+classify_index+".s_item"] = classify_name
 				}
+			} else {
+				log.Println(userId, "--vip信息查询出错或为空")
 			}
 		} else if a.GetString("pageType") == "other_buyerclass" {
 			other, _ := a.GetInteger("other")

+ 12 - 6
src/jfw/modules/weixin/src/github.com/wizjin/weixin/weixin.go

@@ -731,6 +731,13 @@ func (wx *Weixin) CreateHandlerFunc(w http.ResponseWriter, r *http.Request) http
 // Process weixin request and send response.
 func (wx *Weixin) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 	startTime := time.Now().Unix()
+	defer func() {
+		entTime := time.Now().Unix()
+		timeDiff := entTime - startTime
+		if timeDiff > 2 {
+			log.Println("ServeHTTP--", r.URL.String(), timeDiff)
+		}
+	}()
 	if !checkSignature(wx.token, w, r) {
 		http.Error(w, "", http.StatusUnauthorized)
 		return
@@ -751,14 +758,13 @@ func (wx *Weixin) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 			log.Println("Weixin parse message failed:", err)
 			http.Error(w, "", http.StatusBadRequest)
 		} else {
-			wx.routeRequest(w, &msg)
+			if msg.Event == EventTemplateSent || msg.Event == EventView {
+				http.Error(w, "", http.StatusNotFound)
+			} else {
+				wx.routeRequest(w, &msg)
+			}
 		}
 	}
-	entTime := time.Now().Unix()
-	timeDiff := entTime - startTime
-	if entTime < 5 {
-		log.Println("ServeHTTP--", r.URL.String(), startTime, entTime, timeDiff)
-	}
 	return
 }
 

+ 3 - 0
src/web/templates/weixin/historypush.html

@@ -1042,6 +1042,9 @@
         .jy-alert-other .weui-dialog__ft{
           text-align:center !important;
         }
+        .weui-dialog{
+          left: 50%;
+        }
     </style>
 </head>
 <body>

+ 1 - 1
src/web/templates/weixin/search/mainSearch.html

@@ -33,7 +33,7 @@
 <link rel="stylesheet" type="text/css" href="{{Msg "seo" "cdn"}}/css/wx/base.css?v={{Msg "seo" "version"}}" />
 <link rel="stylesheet" href="{{Msg "seo" "cdn"}}/swiper/swiper.min.css?v={{Msg "seo" "version"}}">
 <link rel="stylesheet" href="{{Msg "seo" "cdn"}}/css/wx/home.css?v={{Msg "seo" "version"}}">
-<script src="{{Msg "seo" "cdn"}}/swiper/swiper.min.js"></script>
+<script src="{{Msg "seo" "cdn"}}/swiper/swiper.min.js?v={{Msg "seo" "version"}}"></script>
 <script type="text/javascript" src="{{Msg "seo" "cdn"}}/js/bootstrap.min.js"></script>
 <title>搜索</title>
 <script type="text/javascript">

+ 1 - 1
src/web/templates/weixin/vipsubscribe/keyWord.html

@@ -638,7 +638,7 @@
 			            addition_kws = [];
 			            not_kws = [];
                     }else{
-			            weui.toast('无法删除', {
+			            weui.toast('无法删除或已删除', {
 			                duration: 2000,
 			                className: 'custom-toast',
 			                callback: function () { console.log('close') }