wangkaiyue 5 years ago
parent
commit
0f25829f70

+ 8 - 0
src/jfw/front/vipsubscribe.go

@@ -36,6 +36,8 @@ type Subscribepay struct {
 	renewPage    xweb.Mapper `xweb:"/front/vipsubscribe/renewPage/(.*)"` //订阅到期(will:即将到期,exprie:已到期)
 	renewPayPage xweb.Mapper `xweb:"/front/vipsubscribe/renewPayPage"`   //订阅到期续费
 
+	//发票
+	openInvoice xweb.Mapper `xweb:"/front/vipsubscribe/openInvoice/(\\w+)"` //开发票
 }
 
 func init() {
@@ -153,3 +155,9 @@ func (s *Subscribepay) RenewPage(sign string) {
 func (s *Subscribepay) RenewPayPage() {
 	s.Render("/weixin/vipsubscribe/renew_pay.html")
 }
+
+//开发票
+func (s *Subscribepay) OpenInvoice(order_code string) {
+	s.T["order_code"] = order_code
+	s.Render("/weixin/dataExport/dataExport_applyInvoice.html", &s.T)
+}

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

@@ -275,7 +275,6 @@ func (w *WxMyOrder) MyOrder() error {
 			}
 		}
 	}
-	log.Println("------", len(res), "---------", count)
 	w.ServeJson(map[string]interface{}{
 		"res":         res,
 		"count":       count,

+ 3 - 3
src/jfw/modules/app/src/web/staticres/jyapp/dataExport/js/exclusiveWord.js

@@ -104,9 +104,9 @@ $(function(){
     })
 
     //去空格方法
-    String.prototype.trim = function(){
-        return this.replace(/(^\s*)|(\s*$)/g, ' ');
-     }
+    // String.prototype.trim = function(){
+    //     return this.replace(/(^\s*)|(\s*$)/g, ' ');
+    //  }
 
     //排除词个数
     $('.modify span').keydown(function(){

+ 0 - 4
src/jfw/modules/app/src/web/templates/me/index.html

@@ -48,9 +48,6 @@
 			    position: relative;
 			    font-size: 15px;
 			    border-top: 1px solid #E6E6E6;
-			}
-			.email{
-				
 			}
 			#main .order, #main .vip {
 			    margin-top: 13px;
@@ -382,7 +379,6 @@
 		$(".myEmail").click(function(){
 			window.location.href = "#";
 		})
-		vip_
 		//vip订阅入口
 		$(".vip_").click(function(){
 			window.location.href = "#";

+ 13 - 3
src/jfw/modules/subscribepay/src/config.json

@@ -6,9 +6,19 @@
     "webport": "86",
     "weixinrpc": "127.0.0.1:8083",
     "cassandra": {
-        "host": ["192.168.3.207"],
-        "size": 5,
-        "port": 9043
+        "log": {
+            "host": [
+                "192.168.3.207"
+            ],
+            "size": 5,
+            "port": 9042
+        },
+        "push": {
+            "host": [
+                "192.168.3.207"
+            ],
+            "size": 5
+        }
     },
     "mysql": {
         "dbName": "jianyu",

+ 55 - 8
src/jfw/modules/subscribepay/src/service/afterPay.go

@@ -24,13 +24,10 @@ type AfterPay struct {
 func (a *AfterPay) SetUserInfo() error {
 	defer qutil.Catch()
 	userId, _ := a.GetSession("userId").(string)
+	var flag = false
 	if userId != "" {
-		updateQuery := map[string]interface{}{
-			"_id": bson.ObjectIdHex(userId),
-		}
 		saveData := make(map[string]interface{})
 		if a.GetString("pageType") == "infoType" {
-			log.Println(a.GetString("infoTypeArr"))
 			infoTypeArr := a.GetString("infoTypeArr")
 			saveData["o_vipjy.a_infotype"] = strings.Split(infoTypeArr, ",")
 		} else if a.GetString("pageType") == "saveSeniorset" {
@@ -44,11 +41,61 @@ func (a *AfterPay) SetUserInfo() error {
 			saveData["o_vipjy.i_mailpush"] = i_mailpush
 			saveData["o_vipjy.s_email"] = s_email
 			saveData["o_vipjy.i_matchway"] = i_matchway
+		} else if a.GetString("pageType") == "keyWords" {
+			classify_index := a.GetString("classify_index")
+			classify_name := a.GetString("classify_name")
+			kws_index := a.GetString("kws_index")
+			kws_name := a.GetString("kws_name")
+			actionType := a.GetString("actionType")
+			kwscount := a.GetString("kwscount")
+			addtion_kws := a.GetSlice("addition_kws")
+			not_kws := a.GetSlice("not_kws")
+			_kws := strings.Split(kws_name, " ")
+			if actionType == "SK" { //保存关键词
+				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
+					if len(addtion_kws) > 0 {
+						saveData["o_vipjy.a_items."+classify_index+".a_key."+kws_index+".appendkey"] = addtion_kws
+					}
+					if len(not_kws) > 0 {
+						saveData["o_vipjy.a_items."+classify_index+".a_key."+kws_index+".notkey"] = not_kws
+					}
+				} else {
+					//首次添加分类和关键词
+					flag = util.MQFW.UpdateById("user", userId,
+						bson.M{
+							"$push": bson.M{"o_vipjy.a_items." + classify_index + ".a_key": bson.M{"key": _kws, "appendkey": addtion_kws, "notkey": not_kws}},
+							"$set":  bson.M{"o_vipjy.a_items." + classify_index + ".s_item": classify_name, "o_vipjy.l_modifydate": time.Now().Unix()},
+						})
+				}
+			} 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" { //保存分类
+				saveData["o_vipjy.a_items."+classify_index+".s_item"] = classify_name
+			}
+		}
+		if len(saveData) > 0 {
+			flag = util.MQFW.UpdateById("user", userId, map[string]interface{}{
+				"$set": saveData,
+			})
 		}
-		flag := util.MQFW.Update("user", updateQuery, map[string]interface{}{
-			"$set": saveData,
-		}, false, false)
-		log.Println("flag:", flag)
 		a.ServeJson(map[string]interface{}{
 			"flag": flag,
 		})

+ 246 - 8
src/jfw/modules/subscribepay/src/service/order.go

@@ -6,6 +6,11 @@ import (
 
 	"log"
 
+	"jfw/config"
+	"jfw/public"
+	"log"
+	"strconv"
+
 	"strings"
 	"time"
 	"util"
@@ -19,10 +24,26 @@ import (
 type Order struct {
 	*xweb.Action
 	getOrderPayMsg    xweb.Mapper `xweb:"/order/getOrderPayMsg"`    //订单数据展示(支付成功页面)
-	getOrderPayAllMsg xweb.Mapper `xweb:"/order/getOrderPayAllMsg"` //订单数据展示(订单详情页面)
 	trialPay          xweb.Mapper `xweb:"/order/trialPay"`          //试用用户创建订单
+	getOrderPayAllMsg xweb.Mapper `xweb:"/order/getOrderPayAllMsg"` //订单数据展示(订单详情页面)vip
+	myOrder           xweb.Mapper `xweb:"/order/myOrder"`           //查询订单首页
+	myOrderPaging     xweb.Mapper `xweb:"/order/myOrderPaging"`     //查询订单分页
+	deleteOrder       xweb.Mapper `xweb:"/order/deleteOrder"`       //删除订单
+	applyInvoice      xweb.Mapper `xweb:"/order/applyInvoice"`      //开发票
+
 }
 
+var (
+	layout_date             = "2006.01.02"
+	orderStatus_unPaid      = "0"                //订单状态-待支付
+	orderStatus_paid        = "1"                //订单状态-已完成
+	orderStatus_deleted     = "-1"               //订单状态-已删除
+	orderStatus_cancel      = "-2"               //订单状态-已取消
+	tableName_order         = "dataexport_order" //订单表
+	order_pageSize          = 10
+	pagesize_max        int = 10
+)
+
 type orderResult struct {
 	Success bool  //是否成功
 	Err     error //错误
@@ -73,25 +94,28 @@ func (this *Order) GetOrderPayAllMsg() {
 			return &orderResult{false, errors.New("订单号不能为空"), nil}
 		}
 		query := map[string]interface{}{
-			"user_id":    userId,
+			"user_id":    "5db11594f4e498161c85fcf2",
 			"order_code": orderCode,
 			//"order_status": 1,
 		}
-		oData := util.Mysql.FindOne("dataexport_order", query, "prepay_time,pay_time,pay_way,original_price,applybill_status,out_trade_no,filter,product_type,order_status", "")
+		oData := util.Mysql.FindOne("dataexport_order", query, "prepay_time,pay_time,pay_way,original_price,applybill_status,out_trade_no,filter,product_type,order_status,applybill_type,applybill_taxnum,applybill_company", "")
+		log.Println("odata:", oData)
 		//查询订单信息
 		if oData == nil || len(*oData) == 0 {
 			return &orderResult{false, errors.New("未找到此订单"), nil}
 		}
+		//已支付订单查询有效时间   -已取消的也查看有效时间 用于判断再次购买
+		uData, ok := util.MQFW.FindById("user", userId, `{"l_vip_starttime":1,"l_vip_endtime":1}`)
+		if uData == nil || len(*uData) == 0 || !ok {
+			return &orderResult{false, errors.New("数据库查询异常"), nil}
+		}
+		//
 		if qutil.IntAll((*oData)["order_status"]) != 1 {
 			return &orderResult{true, nil, map[string]interface{}{
 				"order": oData,
+				"time":  uData,
 			}}
 		}
-		//已支付订单查询有效时间
-		uData, ok := util.MQFW.FindById("user", userId, `{"l_vip_starttime":1,"l_vip_endtime":1}`)
-		if uData == nil || len(*uData) == 0 || !ok {
-			return &orderResult{false, errors.New("数据库查询异常"), nil}
-		}
 		delete(*uData, "_id")
 		return &orderResult{true, nil, map[string]interface{}{
 			"order":          oData,
@@ -105,6 +129,220 @@ func (this *Order) GetOrderPayAllMsg() {
 	this.ServeJson(r.Format())
 }
 
+//订单列表首页
+func (o *Order) MyOrder() error {
+	//每页显示数
+	userId := o.Session().Get("userId")
+	openid := o.Session().Get("s_m_openid")
+	queryM := map[string]interface{}{}
+	if userId == nil || openid == nil {
+		return errors.New("未登录")
+	} else {
+		queryM["user_id"] = userId
+	}
+	// 0全部 1未支付 2已支付
+	typ := o.GetString("type")
+	if typ != "0" && typ != "" {
+		var status string
+		if typ == "1" {
+			status = orderStatus_unPaid
+		} else if typ == "2" {
+			status = orderStatus_paid
+		} else if typ == "3" {
+			status = orderStatus_cancel
+		}
+		queryM["order_status"] = status
+	} else {
+		queryM["order_status"] = map[string]interface{}{"ne": orderStatus_deleted}
+	}
+	//总数
+	haveNextPage, res, _ := o.Datas(queryM, 1)
+	if res != nil {
+		o.SetRes(res, queryM)
+	}
+	o.ServeJson(map[string]interface{}{
+		"res":         res,
+		"pageSize":    order_pageSize,
+		"hasNextPage": haveNextPage,
+	})
+	return nil
+}
+
+//订单列表分页
+func (o *Order) MyOrderPaging() error {
+	userId := o.Session().Get("userId")
+	openid := o.Session().Get("s_m_openid")
+	queryM := map[string]interface{}{}
+	if userId == nil || openid == nil {
+		return errors.New("未登录")
+	} else {
+		queryM["user_id"] = userId
+	}
+	// 0全部 1未支付 2已支付
+	typ := o.GetString("type")
+	pageNum, _ := o.GetInteger("pageNum")
+	if typ != "0" && typ != "" {
+		var status string
+		if typ == "1" {
+			status = orderStatus_unPaid
+		} else if typ == "2" {
+			status = orderStatus_paid
+		} else if typ == "3" {
+			status = orderStatus_cancel
+		}
+		queryM["order_status"] = status
+	} else {
+		queryM["order_status"] = map[string]interface{}{"ne": orderStatus_deleted}
+	}
+	haveNextPage, res, _ := o.Datas(queryM, pageNum)
+	if res != nil {
+		o.SetRes(res, queryM)
+	}
+	o.ServeJson(map[string]interface{}{
+		"hasNextPage": haveNextPage,
+		"res":         res,
+	})
+	return nil
+}
+
+//删除或取消订单
+func (o *Order) DeleteOrder() error {
+	if userId := o.GetSession("userId"); userId != nil {
+		queryMap := map[string]interface{}{
+			"id":      o.GetString("id"),
+			"user_id": userId.(string),
+		}
+		queryM := map[string]interface{}{}
+		queryM["user_id"] = userId
+		nextPage := false
+		// 0全部 1未支付 2已支付
+		typ := o.GetString("type")
+		cancel := o.GetString("cancel")
+		pageNum, _ := o.GetInteger("pageNum")
+		if typ != "0" && typ != "" {
+			var status string
+			if typ == "1" {
+				status = orderStatus_unPaid
+			} else if typ == "2" {
+				status = orderStatus_paid
+			} else if typ == "3" {
+				status = orderStatus_cancel
+			}
+			queryM["order_status"] = status
+		} else {
+			queryM["order_status"] = map[string]interface{}{"ne": orderStatus_deleted}
+		}
+		haveNextPage, res, _ := o.Datas(queryM, pageNum)
+		if len(res) > 0 {
+			res = res[0:1]
+			//用于删除订单后 判断新增的订单之后 是否有下一页
+			nextPage = true
+		}
+		if res != nil {
+			o.SetRes(res, queryM)
+		}
+		var boo = false
+		if cancel == "cancel" {
+			//取消订单
+			boo = public.Mysql.Update(tableName_order, queryMap, map[string]interface{}{"order_status": -2})
+		} else {
+			//删除订单
+			boo = public.Mysql.Update(tableName_order, queryMap, map[string]interface{}{"order_status": -1})
+		}
+		o.ServeJson(map[string]interface{}{
+			"success":     boo,
+			"res":         res,
+			"hasNextPage": haveNextPage,
+			"nextPage":    nextPage,
+		})
+	}
+	return nil
+}
+
+//开发票
+func (o *Order) ApplyInvoice() error {
+	var applyBill_status int
+	var order_code, applyBill_company, applyBill_taxnum, applyBill_type string
+	var updateBl bool = false
+	order_code = o.GetString("order_code")
+	//获取数据
+	applyBill_type = o.GetString("demo-radio") //个人 单位
+	queryMap := map[string]interface{}{
+		"order_code": order_code,
+	}
+	if applyBill_type == "个人" {
+		applyBill_status = 1
+		updateBl = public.Mysql.Update(tableName_order, queryMap, map[string]interface{}{"applyBill_status": applyBill_status})
+
+	} else if applyBill_type == "单位" {
+		applyBill_status = 1                                 //状态
+		applyBill_company = o.GetString("applyBill_company") //公司名
+		applyBill_taxnum = o.GetString("applyBill_taxnum")   //纳税人识别号
+		updateBl = public.Mysql.Update(tableName_order, queryMap, map[string]interface{}{
+			"applyBill_company": applyBill_company,
+			"applyBill_taxnum":  applyBill_taxnum,
+			"applyBill_status":  applyBill_status,
+			"applyBill_type":    1,
+		}) //修改操作
+	}
+	//判断条件
+	if updateBl {
+		go func() {
+			orderdata := public.Mysql.FindOne(tableName_order, map[string]interface{}{
+				"order_code": order_code,
+			}, "id,filter,user_mail,user_phone,product_type,data_spec,filter_id,order_code,data_count,order_status,order_money,out_trade_no,applybill_type,applybill_company,applybill_taxnum,user_openid,create_time,pay_time,pay_way", "")
+			tt := time.Now()
+			pay_time := qutil.FormatDate(&tt, qutil.Date_Full_Layout)
+			public.SendMailToBJFinance(orderdata, pay_time, "", 2, config.GmailAuth)
+		}()
+	}
+	o.ServeJson(map[string]interface{}{
+		"flag": updateBl,
+	})
+	return nil
+}
+
+func (o *Order) SetRes(res []map[string]interface{}, queryM map[string]interface{}) {
+	for _, v := range res {
+		filter_publishtime := v["filter_publishtime"]
+		if filter_publishtime != nil || filter_publishtime != "" {
+			timeArr := strings.Split(filter_publishtime.(string), "_")
+			if len(timeArr) == 2 {
+				start, err := strconv.ParseInt(timeArr[0], 10, 64)
+				end, erro := strconv.ParseInt(timeArr[1], 10, 64)
+				if err == nil && erro == nil {
+					v["filter_publishtime"] = qutil.FormatDateByInt64(&start, layout_date) + "-" + qutil.FormatDateByInt64(&end, layout_date)
+				}
+			}
+		}
+		v["filter_id"] = qutil.SE.Encode2Hex(v["filter_id"].(string))
+		orderMoney := v["order_money"]
+		if orderMoney != nil {
+			v["order_money"] = float64(orderMoney.(int64)) / 100
+		}
+		if v["id"] != nil && orderMoney != nil && v["order_code"] != nil {
+			v["token"] = public.GetWaitPayToken(v["id"].(int64), int(orderMoney.(int64)), v["order_code"].(string), v["pay_way"].(string), queryM["user_id"].(string))
+		}
+	}
+}
+
+//查询数据
+func (o *Order) Datas(queryM map[string]interface{}, pageNum int) (haveNextPage bool, result []map[string]interface{}, err error) {
+	res := *public.Mysql.Find(tableName_order, queryM, "id,order_code,filter_publishtime,create_time,data_spec,filter_id,filter_keys,order_money,data_count,order_status,pay_way", "create_time desc", -1, 0)
+	if len(res) > 0 {
+		start := (pageNum - 1) * pagesize_max
+		end := pageNum * pagesize_max
+		if end > len(res) {
+			end = len(res)
+		}
+		if start < len(res) {
+			result = res[start:end]
+		}
+	}
+	haveNextPage = len(result) >= pagesize_max
+	return
+}
+
 //获取支付单号
 func getPayTransactionId(payWay, tradeNo string) (transaction_id string) {
 	if payWay == "" || tradeNo == "" {

+ 26 - 12
src/web/staticres/vipsubscribe/js/additionWord.js

@@ -48,8 +48,11 @@ $(function(){
     // 添加 按钮的点击事件
     $('.addkeyWord .btn button').on('click', function(){
         var timestamp = new Date().getTime();//动态生成不同的id,因为id唯一不能重复,所以 用时间戳 代替  防止重复
-        console.log(timestamp)
-        var keyWord = $('.addkeyWord input.enterOne').val()
+        var keyWord = $('.addkeyWord input.enterOne').val();
+        _addindex = -1;
+        //保存新附加词
+        _addkws = keyWord;
+        saveSession();
         var html = `<li>
                         <div class="one">
                             <div>
@@ -66,7 +69,6 @@ $(function(){
                         </div>
                     </li>`
         $('.showKeyWord > ul').prepend(html)
-        
         // 隐藏
         $(".addkeyWord").hide();
         $('.showKeyWord').show();
@@ -83,7 +85,6 @@ $(function(){
         $('.addKeyWord').hide()
 
         let oSpan = $(this).parent().siblings().children('textarea');
-        console.log($(oSpan).val())
         let val = $(oSpan).val()
         $(this).parent().siblings().show().parents('li').siblings().children('.modify').hide().siblings('.one').show()
         $(oSpan).val('').focus().val(val) 
@@ -93,7 +94,9 @@ $(function(){
 
     // 编辑 删除
     $('.showKeyWord').on('click', '.deleteKey', function(e) {
-        var jQueryDOM = $(this).parents('li')
+        var jQueryDOM = $(this).parents('li');
+        _addkws = $(this).siblings('textarea').val();
+        _addindex = $(".showKeyWord li").length - $(this).parent().parent('li').index() - 1;
         weui.confirm('确定要删除附加词?', {
             buttons: [{
                 label: '取消',
@@ -103,9 +106,10 @@ $(function(){
                 label: '确定',
                 type: 'primary',
                 onClick: function () {
-                    jQueryDOM.remove()
-                    hasWords()
-                    $('.addKeyWord').show()
+                    jQueryDOM.remove();
+                    hasWords();
+                    $('.addKeyWord').show();
+                    saveSession("D");
                 }
             }]
         });
@@ -113,10 +117,20 @@ $(function(){
     // 编辑 确定
     $('.showKeyWord').on('click', '.ascertainKey', function(e) {
         $('.addKeyWord').show()
-        var keyWord = $(this).siblings('textarea').val()
-        $(this).parent().siblings().find('.key').text(keyWord)
-        $(this).parent().hide().siblings().show()
-        console.log(keyWord)
+        var keyWord = $(this).siblings('textarea').val();
+        if(keyWord.length > 20){
+            weui.toast('每组附加词不能超过20字', {
+                duration: 2000,
+                className: 'custom-toast',
+                callback: function () { console.log('close') }
+            });
+        }else{
+            _addindex = $(".showKeyWord li").length - $(this).parent().parent('li').index() - 1;
+            _addkws = keyWord;
+            saveSession();
+            $(this).parent().siblings().find('.key').text(keyWord)
+            $(this).parent().hide().siblings().show()
+        }
     })
 
     //防止键盘把当前输入框给挡住

+ 18 - 8
src/web/staticres/vipsubscribe/js/exclusiveWord.js

@@ -61,6 +61,10 @@ $(function(){
    
     $('.addkeyWord .btn button').on('click', function(){
         var keyWord = $('.addkeyWord input.enterOne').val()
+        _notindex = -1;
+        //保存新附加词
+        _notkws = keyWord;
+        saveSession();
         var html = `<li>
                         <div class="one">
                             <div>
@@ -102,7 +106,9 @@ $(function(){
 
     // 编辑 删除
     $('.showKeyWord').on('click', '.deleteKey', function(e) {
-        var jQueryDOM = $(this).parents('li')
+        var jQueryDOM = $(this).parents('li');
+        _notkws = $(this).siblings('textarea').val();
+        _notindex = $(".showKeyWord li").length - $(this).parent().parent('li').index() - 1;
         weui.confirm('确定要删除关键词?', {
             buttons: [{
                 label: '取消',
@@ -114,7 +120,8 @@ $(function(){
                 onClick: function () {
                     jQueryDOM.remove()
                     hasWords()
-                    $('.addKeyWord').show()
+                    $('.addKeyWord').show();
+                    saveSession("D");
                 }
             }]
         });
@@ -122,18 +129,21 @@ $(function(){
     })
     // 编辑 确定
     $('.showKeyWord').on('click', '.ascertainKey', function(e) {
-        var $this = $(this)
-        var keyWord = $(this).siblings('textarea').val()
+        var $this = $(this);
+        var keyWord = $(this).siblings('textarea').val();
         if(keyWord.length > 20){
-            weui.toast('关键词不能超过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()
+            $this.parent().siblings().find('.key').text(keyWord);
+            $this.parent().hide().siblings().show();
+            $('.addKeyWord').show();
+            _notindex = $(".showKeyWord li").length - $(this).parent().parent('li').index() - 1;
+            _notkws = keyWord;
+            saveSession();
         }
     })
 

+ 129 - 64
src/web/staticres/vipsubscribe/js/keyWord.js

@@ -17,16 +17,6 @@ $(function () {
         $(".btnChoose").show();
     })
 
-    hasWords()
-    function hasWords() {
-        var showKeyWordLength = $(".showKeyWord ul").find('li').length;
-        if (showKeyWordLength === 0) {
-            $(".addkeyWord").show();
-        } else {
-            $(".addkeyWord").hide();
-        }
-    }
-
     // 输入框自适应高度
     $('textarea').each(function(i,dom){
         dom.style.height = dom.scrollHeight +'px';
@@ -37,7 +27,7 @@ $(function () {
     })
 
     // 添加keyWords检查输入框内是否有文字,如果有才能点击添加按钮
-    $('.addkeyWord input.enterOne').on('input', function () {
+    $('.content .addkeyWord input.enterOne').on('input', function () {
         var buttonDOM = $(this).siblings()[1].children[0]
         if ($(this).val().length >= 1) {
             buttonDOM.style.opacity = 1
@@ -49,42 +39,92 @@ $(function () {
     })
 
     // 添加 确认按钮的点击事件
-    $('.addkeyWord .btn button').on('click', function () {
-        var keyWord = $('.addkeyWord input.enterOne').val()
-        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>
+    $('.content .addkeyWord .btn button').on('click', function () {
+        var keyWord = $('.addkeyWord input.enterOne').val();
+        kws_name = keyWord;
+        kws_index = $(".showKeyWord li").length;
+        if(kws_index==0){
+            //分类首次添加关键词需重新获取分类索引
+            classify_index = a_items.length;
+        }
+        classify_name = $('.classify-r .classify-detail').text();
+        //保存关键词
+        kws_count = parseInt(kws_count) + 1;
+        if(kws_count>300){
+            alert("您设置的关键词已超出最高上限,请调整后再添加。")
+        }else if (saveData("SK")){
+            //点击保存关键词,查看缓存中存的附加词 和排除词。
+            $(".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"><i class="iconfont icon-xiugai"></i> 修改</button>
                         </div>
                         <div class="modify">
-                            <textarea  name=""  rows="1"  placeholder="" maxlength="20">${keyWord}</textarea>
-                            <button class="addAdjunctWord">编辑 附加词</button>
-                            <button class="addExclusion">添加 排除词</button>
-                            <button class="deleteKey">删除</button>
-                            <button class="ascertainKey">确定</button>
-                        </div>
-                    </li>`
-        $('.showKeyWord > ul').prepend(html)
-        // 添加完成隐藏输入框
-        $(".addkeyWord").hide()
-        // 还原状态
-        $('.enter.addkeyWord > input').val('')
-        var buttonDOM = $('.enter.addkeyWord .btn button')[0]
-        buttonDOM.style.opacity = .5
-        buttonDOM.setAttribute("disabled", true)
-        // 设置状态
-        setEmptyHistory()
+                        <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" onclick="saveK(this,1)">确定</button>
+                            </div>
+                        </li>`
+            $('.showKeyWord > ul').prepend(html);
+            // 添加完成隐藏输入框
+            $(".enter.addkeyWord").hide();
+            // 还原状态
+            $('.enter.addkeyWord > input').val('')
+            var buttonDOM = $('.enter.addkeyWord .btn button')[0]
+            buttonDOM.style.opacity = .5
+            buttonDOM.setAttribute("disabled", true)
+            // 设置状态 首次添加关键词
+            if(a_items.length==0){
+                setEmptyHistory();
+            }
+            //
+            doSessionData();
+        }
     })
     // 编辑
     $(".showKeyWord").on('click', '.editKeyWord', function (e) {
+        kws_name = $(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").text().split(" ")
+        }else{
+            addition_kws = []
+        }
+        if ($(this).prev('div').find(".notkey").text()!=""){
+            not_kws = $(this).prev('div').find(".notkey").text().split(" ")
+        }else{
+            not_kws = []
+        }
         $('.enter.addkeyWord').hide()
         let oSpan = $(this).parent().siblings().children('textarea');
-        console.log($(oSpan).val())
         let val = $(oSpan).val()
         $(this).parent().hide()
         $(this).parent().siblings().show().parent().siblings().children('.modify').hide().siblings('.one').show()
@@ -104,9 +144,16 @@ $(function () {
                 label: '确定',
                 type: 'primary',
                 onClick: function () {
-                    jQueryDOM.remove()
-                    hasWords()
-                    $('.addKeyWord').show()
+                    if(saveData('DK')){
+                        kws_count -= 1;
+                        $(".kws_count").text(kws_count);
+                        jQueryDOM.remove();
+                        hasWords();
+                        $('.addKeyWord').show();
+                        doSessionData('DK');
+                    }else{
+                        alert("无法删除")
+                    }
                 }
             }]
         });
@@ -114,21 +161,21 @@ $(function () {
 
     })
     // 编辑确定
-    $('.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()
-        }
-    })
+    // $('.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()
+    //     }
+    // })
     
     //防止键盘把当前输入框给挡住
     $('input[type="text"],textarea').focus(function () {
@@ -151,22 +198,40 @@ $(function () {
         }
         $('.classify-edit-pop').show()
         var currentClassifyName = $(this).find('.classify-detail').text()
+        if(currentClassifyName=="未分类"){
+            currentClassifyName = ""
+        }
         $('input.classify-keyword').val(currentClassifyName).focus()
     })
+    //
 
-    // 关键词分类 - 确定按钮点击事件
-    $('.classify-edit-pop .dialog__btn_confirm').on('click', function() {
+    $('.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
         }
-        
-        $('.classify-r .classify-detail').text(s)
+        $('.weui-dialog__ft .dialog__btn_confirm').removeClass("opacity6");
+    })
+    // 关键词分类 - 确定按钮点击事件
+    $('.classify-edit-pop .dialog__btn_confirm').on('click', function() {
+        classify_name = $('input.classify-keyword').val();
+        // 去空格
+        classify_name = classify_name.trim();
+        if (classify_name.length === 0) {
+            return
+        }
+        $(this).removeClass("opacity6");
+        $('.classify-r .classify-detail').text(classify_name);
         // 关闭弹框后要重置input内容
-        $('.classify-edit-pop').hide()
-        $('input.classify-keyword').val('')
+        $('.classify-edit-pop').hide();
+        $('input.classify-keyword').val('');
+        if($(".showKeyWord li").length>0){
+            saveData('SC')
+            a_items[classify_index]["s_item"] = classify_name;
+        }
     })
 
     // 关键词分类 - 取消按钮点击事件

+ 2 - 8
src/web/templates/weixin/dataExport/dataExport_applyInvoice.html

@@ -327,13 +327,7 @@
 					}
 				}
 				if (submitBl){
-					$.ajax({
-						type:'post',
-						url:'/front/wxMyOrder/wxApplyInvoice',
-						data:formParam+"&demo-radio="+$(".type").html(),
-						cache:false,
-						dataType:'json', 
-					 	success:function(data){ 
+					$.post('/front/wxMyOrder/wxApplyInvoice',formParam+"&demo-radio="+$(".type").html(),function(data){ 
 										if(data.flag){
 											//window.location.href="/front/wxMyorder/wxPaySuccess/" + {{.T.order_code}}
 											sessionStorage.applysuccess="1";
@@ -354,7 +348,7 @@
 											}, 2000);
 										}
 								}
-					})
+					)
 				}
 			}
             

+ 0 - 10
src/web/templates/weixin/dataExport/dataExport_invoiceSuccess.html

@@ -53,16 +53,6 @@
 			 
 			}
 			
-//			//禁止手机物理返回键
-//			$(document).ready(function() {
-//		  if (window.history && window.history.pushState) {
-//		    $(window).on('popstate', function () {
-//		       window.history.pushState('forward', null, '#');
-//		       window.history.forward(1); });
-//		     }
-//	       window.history.pushState('forward', null, '#'); //在IE中必须得有这两行
-//	       window.history.forward(1);
-//		   });
         </script>
 	{{include "/common/baiducc.html"}}
     </body>

+ 180 - 252
src/web/templates/weixin/dataExport/dataExport_toMyOrder.html

@@ -462,18 +462,13 @@
 			                    text: '确定',
 			                    btnClass: 'btn-primary-0',
 			                    action: function() {
-			                        $.ajax({
-			                            type: "post",
-			                            url: "/front/wxMyorder/wxDeleteOrder",
-			                            data: {"id":id,"pageNum":pageIndex,"type":typ},
-			                            dataType: 'json',
-			                            success: function(data){
+			                        $.post("/subscribepay/order/deleteOrder", {"id":id,"pageNum":pageIndex,"type":typ},function(data){
 			                                if(data && data["success"]){
 			                                    var self = $(obj).parent().parent();
 			                                    var parent = self.parent();
 			                                	deleteIndex=self.index();
 			                                	//删除索引存入缓存
-			                                	sessionStorage.setItem("deleteIndex",deleteIndex);
+			                                	//sessionStorage.setItem("deleteIndex",deleteIndex);
 			                                	dataCache.splice(deleteIndex,1)
 			                                	if(data.res!=null){
 			                                		dataCache.push(data.res[0])
@@ -489,13 +484,9 @@
 			                                                text: '确定',
 			                                                btnClass: 'btn-primary-2',
 			                                                action: function() {
-			                                                	if(parent.children("div").length<10){
-			                                                		$(".dropload-refresh").text("没有更多了");
-			                                                	}
 			                                                    if(parent.children("div").length==0){
 			                                                    	nodataHtml=""
 																	nodataHtml+='<div style="text-align:center;">';
-																	//nodataHtml+='<div style="display:flex;justify-content:center;align-items: center;">';
 																	nodataHtml+='<img src="/wx_dataExport/images/fish.png" style="width: 2.8rem;height: 2.8rem;margin-top: 45%;">'
 																	nodataHtml+='<div style="color: #888;font-size: .32rem;text-align:center;">暂无数据</div></div>'
 			                                                        $(".card_lists").append(nodataHtml);
@@ -527,8 +518,6 @@
 											                        	 		publishTime=timestampToTime(publishtime_);
 											                        	 		publishTime=publishTime+"前全部";
 											                        	 	}
-											                        	 }else{
-											                        	 	 //publishTime= publishTime.replace(/\./g,"/")
 											                        	 }
 																	}
 											                        //1标准字段包 2高级字段包
@@ -558,7 +547,6 @@
 											                        	iconHtml=""
 											                        	iconHtml+='<div class="card-footer">'
 																					+'<a onclick="onceMore(this)" class="btn cancle">再次购买</a>'
-																					//+'<a href="/front/wxMyOrder/wxToOrderDetail/'+orderCode+'" class="btn cancle">查看详情</a>'
 																				+'</div>'
 											                        }
 											                        //订单总数
@@ -583,9 +571,6 @@
 												                        var keysLen = keysArr.length;for(var j=0;j<keysLen;j++){
 												                            keysHtml += "<span>" + keysArr[j] + "&nbsp</span>";
 												                        }
-//												                        if(keysArr.length>2){
-//												                            keysHtml += "<span>...</span>";
-//												                        }
 												                 	}else{
 												                 		keysHtml=""
 												                 	}
@@ -596,8 +581,6 @@
 																						+orderHtml
 																					+'</div>'
 																					+'<div class="card-content">'
-																						//+'<a href="javascript:;" class="media">'
-																						//+'<a href="/front/wxMyOrder/wxToOrderDetail/'+orderCode+'" eid='+orderCode+' class="media">'
 																						+'<a  eid='+orderCode+' class="media">'
 																							+'<div class="media-img">'
 																								+'<img src="/dataExport/image/historical_data.png">'
@@ -617,11 +600,12 @@
 																				+'</div>'
 																	
 																		}
-																		//$(".card_lists").append(listhtml);
 																		//删除完成后补的订单仍可点击
 																		appendList($(listhtml))
 			                                                    	}
-			                                                   
+				                                                    if(parent.children("div").length<10){
+				                                                		$(".dropload-refresh").text("没有更多了");
+				                                                	}
 			                                                }
 			                                            }
 			                                        }
@@ -629,11 +613,7 @@
 			                                }else{
 			                                    alertS("删除失败,请联系管理员!");
 			                                }
-			                            },
-			                            error: function(xhr, type){
-			                                console.log("delete err");
-			                            }
-			                        });
+		                            })
 			                    }
 			                },
 			                cancel: {
@@ -654,12 +634,7 @@
 			                    text: '确定',
 			                    btnClass: 'btn-primary-0',
 			                    action: function() {
-			                        $.ajax({
-			                            type: "post",
-			                            url: "/front/wxMyorder/wxDeleteOrder",
-			                            data: {"id":id,"pageNum":pageIndex,"type":typ,"cancel":"cancel"},
-			                            dataType: 'json',
-			                            success: function(data){
+			                        $.post("/subscribepay/order/deleteOrder", {"id":id,"pageNum":pageIndex,"type":typ,"cancel":"cancel"},function(data){
 			                                if(data && data["success"]){
 			                                    $.alert({
 			                                        title:"提示信息",
@@ -685,11 +660,7 @@
 			                                }else{
 			                                    alertS("删除失败,请联系管理员!");
 			                                }
-			                            },
-			                            error: function(xhr, type){
-			                                console.log("delete err");
-			                            }
-			                        });
+		                            });
 			                    }
 			                },
 			                cancel: {
@@ -712,6 +683,7 @@
 		            }
 		        });
 		    }
+	    
 			clickFlag=true;
 			$(function() {
 				sessionStorage.removeItem("applysuccess");
@@ -839,27 +811,16 @@
 				}else{
 					queryOrder();
 				}
-					
 //				}
-				
-				
-
-			/*------------------------------------------------------------------*/	
+			})
+			
 				//查询订单ajax
 				//typ  0全部 1未支付 2已支付
 				function queryOrder(typ,objD){
 //					sessionStorage.removeItem("payMsg")
 //					sessionStorage.removeItem("deleteIndex")
 					var result = true;
-					$.ajax({
-						type:"post",
-						url:"/front/wxMyOrder/myOrder",
-						data:{
-							"type":typ
-						},
-						async:false,
-						dataType: 'json',
-						success:function(data){
+					$.post("/subscribepay/order/myOrder",{"type":typ},function(data){
 							$(".loading_").hide();
 							var list=data.res;
 							dataCache =data.res;
@@ -871,72 +832,188 @@
 								result = false; 
 								nodataHtml=""
 								nodataHtml+='<div style="text-align:center;">';
-								//nodataHtml+='<div style="display:flex;justify-content:center;align-items: center;">';
 								nodataHtml+='<img src="/wx_dataExport/images/fish.png" style="width: 2.8rem;height: 2.8rem;margin-top: 45%;">'
 								nodataHtml+='<div style="color: #888;font-size: .32rem;text-align:center;">暂无数据</div></div>'
-								//appendList(nodataHtml);
 								$(".card_lists").append(nodataHtml);
-//								if(!result){
-//									return
-//								}
 							}
-						},
-						error: function(xhr, type){
-			                console.log("query err");
-			            }
-					});	
+						})
 					//return 的是 暂无数据的情况noDataHtml 
 					if(!result){
 						$(".dropload-down").hide()
 						return
 					}
-					if(hasNextPage){
-					//setTimeout(function(){
-						wxflag = $(' .main').dropload({
-					        scrollArea : $(".main"),
-					        loadDownFn : function(me){
-								$.ajax({
-									type: 'post',
-									url: '/front/wxMyOrder/myOrder/myOrderPaging',
-									data: {"pageNum": pageIndex,"type":typ},
-									dataType: 'json',
-									success: function(data){
-										//没有数据
-										if(data.res==null||data.res.length==0){
-											noMoreData(me);
-										}else{
-											dataCache=dataCache.concat(data.res);
-											pageIndex++;
-											structureHtml(data.res);
-											if(data.hasNextPage){
-												// 每次数据插入,必须重置
-												me.resetload();
-											}else{
+					setTimeout(function(){
+						if(hasNextPage){
+							wxflag = $(' .main').dropload({
+						        scrollArea : $(".main"),
+						        loadDownFn : function(me){
+									$.post('/subscribepay/order/myOrderPaging', {"pageNum": pageIndex,"type":typ},function(data){
+											//没有数据
+											if(data.res==null||data.res.length==0){
 												noMoreData(me);
+											}else{
+												dataCache=dataCache.concat(data.res);
+												pageIndex++;
+												structureHtml(data.res);
+												if(data.hasNextPage){
+													// 每次数据插入,必须重置
+													me.resetload();
+												}else{
+													noMoreData(me);
+												}
 											}
-										}
-									},
-									error: function(xhr, type){
-										noMoreData(me);
+										});
+								}
+							});
+						}else{
+							wxflag = $('.main').dropload({
+						        scrollArea : window,
+						        loadDownFn : function(me){
+									if(wxflag == null){
+										wxflag = me;
 									}
-								});
-							}
-						});
-				//	},200);
-				}else{
-					wxflag = $('.main').dropload({
-				        scrollArea : window,
-				        loadDownFn : function(me){
-							if(wxflag == null){
-								wxflag = me;
-							}
-							noMoreData(me);
-				        }
-				    });
-					noMoreData(wxflag);
-				}
+									noMoreData(me);
+						        }
+						    });
+							noMoreData(wxflag);
+						}
+					},300)
 				}
 				
+				function structureHtml(object){
+					var listhtml='';
+					var psss = 0;
+					for(var index in object){
+					    var obj=object[index];
+				    	count++;
+						var id = obj.id;
+						//订单编号
+                        var orderCode = obj.order_code;
+                        //创建时间
+                        var createTime=obj.create_time;
+                        createTime =createTime.replace(/-/g,".")
+                        //选择时间
+                        var publishTime = obj.filter_publishtime;
+                        if(!publishTime){
+                            publishTime = "全部";
+                        }else{
+							if(publishTime.length==11){
+                        	 	if(publishTime.slice(0,1)!="_"){
+                        	 		var publishtime_=publishTime.slice(0,10);
+                        	 		publishTime=timestampToTime(publishtime_);
+                        	 		publishTime=publishTime+"-";
+                        	 	}else{
+                        	 		var publishtime_=publishTime.slice(1,11);
+                        	 		publishTime=timestampToTime(publishtime_);
+                        	 		publishTime=publishTime+"前全部";
+                        	 	}
+                        	 }
+						}
+                        //1标准字段包 2高级字段包
+                        var spec = obj.data_spec;
+                        if(spec==1){
+                        	spec ="标准字段包";
+                        }else if(spec ==2){
+                        	spec="高级字段包";
+                        }
+                        //订单总数
+                        var data_count=obj.data_count;
+                        //订单金额
+                        var orderMoney = obj.order_money;
+                        //金额格式化 小数点前 1,000
+                        orderMoney=orderMoney+"";
+       	             	orderMoney_1=toThousands(orderMoney.split(".")[0]);
+						orderMoney_2=orderMoney.split(".")[1];
+       	             	if(orderMoney_2){
+       	             		orderMoney=orderMoney_1+"."+orderMoney_2;
+       	             	}else{
+       	             		orderMoney=orderMoney_1;
+       	             	}
+                        //
+                        var token = obj.token;
+                        //订单状态 0待支付 1已完成 -1删除
+                        var orderStatus =  obj.order_status;
+						if(sessionStorage&&sessionStorage.getItem("paySuccess_"+obj.order_code)!=null){
+							orderStatus = sessionStorage.getItem("paySuccess_"+obj.order_code);
+							if (orderTabActive==1&&orderStatus==1){
+								gopayIndex = index;
+								psss=obj.order_code;
+								continue;
+							}else{
+								sessionStorage.removeItem("paySuccess_"+obj.order_code);
+							}
+						}
+                        if(orderStatus==0){
+                        	orderStatus="待付款"
+                        	orderHtml=""
+                        	orderHtml+='<span class="status notpay">'+orderStatus+'</span>'
+                    		orderHtml+="<a class=\"shanchu iconfont  icon-shanchu\" title=\"删除订单\" onclick=\"deleteOrder(" + id +",this)\"></a>";
+                        	iconHtml=""
+                        	iconHtml+='<div class="card-footer">'
+										+'<a  class="btn cancle" onclick="cancelOrder('+id+',this)">取消订单</a>'
+										+'<a href="javascript:void(0)" onclick="goPay(this)" class="btn pay" filterid="'+obj.filter_id+'" token="'+token+'" id="'+id+'">去支付</a>'
+									+'</div>'
+                        }else if(orderStatus==1){
+                        	orderStatus="已完成";
+                        	orderHtml=""
+                        	orderHtml+='<span class="status">'+orderStatus+'</span>'
+                    		orderHtml+="<a class=\"shanchu iconfont  icon-shanchu\" title=\"删除订单\" onclick=\"deleteOrder(" + id +",this)\"></a>";
+                        	iconHtml=""
+                        	iconHtml+='<div class="card-footer">'
+										+'<a  onclick="onceMore(this)" class="btn cancle">再次购买</a>'
+									+'</div>'
+                        }else if(orderStatus==-2){
+                        	orderStatus="已取消";
+                        	orderHtml="";
+                        	orderHtml+='<span class="status">'+orderStatus+'</span>'
+                        	orderHtml+="<a class=\"shanchu iconfont  icon-shanchu\" title=\"删除订单\" onclick=\"deleteOrder(" + id +",this)\"></a>";
+                        	iconHtml="";
+                        	iconHtml+='<div class="card-footer">'
+										+'<a onclick="onceMore(this)" class="btn cancle">再次购买</a>'
+									+'</div>'
+                        }
+                        //关键词
+						if(obj.filter_keys && obj.filter_keys.split(",").length>0){
+							var keysHtml="";
+	                        var keysArr = obj.filter_keys.split(",");
+	                        var keysLen = keysArr.length;
+	                        for(var j=0;j<keysLen;j++){
+	                            keysHtml += "<span>" + keysArr[j] + "&nbsp</span>";
+	                        }
+	                 	}else{
+	                 		keysHtml=""
+	                 	}
+	                 	
+						listhtml+='<div class="card">'
+										+'<div class="card-header">'
+											+'<span class="time" style="color:#888888">'+createTime+'</span>'
+											+orderHtml
+										+'</div>'
+										+'<div class="card-content">'
+											+'<a  eid='+orderCode+' class="media">'
+												+'<div class="media-img">'
+													+'<img src="/dataExport/image/historical_data.png">'
+												+'</div>'
+												+'<div class="media-info">'
+													+'<p class="item-ifo ellipsis">关键词:'+ keysHtml+'</p>'
+													+'<p class="item-ifo ellipsis">数据量:'+ data_count +'条</p>'
+													+'<p class="item-ifo ellipsis">数据规格:'+spec+'</p>'
+													+'<p class="item-ifo ellipsis">筛选日期:'+publishTime+'</p>'
+												+'</div>'
+											+'</a>'
+											+'<div class="price">'
+												+'<strong class="current">¥'+orderMoney+'</strong>'
+											+'</div>'
+										+'</div>'
+										+iconHtml
+								+'</div>'
+						}
+					appendList($(listhtml));
+//					if(sessionStorage&&sessionStorage.getItem("paySuccess_"+psss)!=null&&orderTabActive==1){
+//						sessionStorage.removeItem("paySuccess_"+psss);
+//						getOneMore(gopayIndex);
+//					}
+				}
 				
 				function noMoreData(me){
 					if(me == null){
@@ -951,155 +1028,6 @@
 					// 即使加载出错,也得重置
 					me.resetload();
 				}
-		
-				function structureHtml(object){
-						var listhtml='';
-						var psss = 0;
-						for(var index in object){
-						    var obj=object[index];
-					    	count++;
-							var id = obj.id;
-							//订单编号
-	                        var orderCode = obj.order_code;
-	                        //创建时间
-	                        var createTime=obj.create_time;
-	                        createTime =createTime.replace(/-/g,".")
-	                        //选择时间
-	                        var publishTime = obj.filter_publishtime;
-	                        if(!publishTime){
-	                            publishTime = "全部";
-	                        }else{
-								if(publishTime.length==11){
-	                        	 	if(publishTime.slice(0,1)!="_"){
-	                        	 		var publishtime_=publishTime.slice(0,10);
-	                        	 		publishTime=timestampToTime(publishtime_);
-	                        	 		publishTime=publishTime+"-";
-	                        	 	}else{
-	                        	 		var publishtime_=publishTime.slice(1,11);
-	                        	 		publishTime=timestampToTime(publishtime_);
-	                        	 		publishTime=publishTime+"前全部";
-	                        	 	}
-	                        	 }else{
-	                        	 	 //publishTime= publishTime.replace(/\./g,"/")
-	                        	 }
-							}
-	                        //1标准字段包 2高级字段包
-	                        var spec = obj.data_spec;
-	                        if(spec==1){
-	                        	spec ="标准字段包";
-	                        }else if(spec ==2){
-	                        	spec="高级字段包";
-	                        }
-	                        //订单总数
-	                        var data_count=obj.data_count;
-	                        //订单金额
-	                        var orderMoney = obj.order_money;
-	                        //金额格式化 小数点前 1,000
-	                        orderMoney=orderMoney+"";
-           	             	orderMoney_1=toThousands(orderMoney.split(".")[0]);
-							orderMoney_2=orderMoney.split(".")[1];
-           	             	if(orderMoney_2){
-           	             		orderMoney=orderMoney_1+"."+orderMoney_2;
-           	             	}else{
-           	             		orderMoney=orderMoney_1;
-           	             	}
-	                        //
-	                        var token = obj.token;
-	                        //订单状态 0待支付 1已完成 -1删除
-	                        //+'<span class="status notpay">'+orderStatus+'</span>'
-	                        var orderStatus =  obj.order_status;
-							if(sessionStorage&&sessionStorage.getItem("paySuccess_"+obj.order_code)!=null){
-								orderStatus = sessionStorage.getItem("paySuccess_"+obj.order_code);
-								if (orderTabActive==1&&orderStatus==1){
-									gopayIndex = index;
-									psss=obj.order_code;
-									continue;
-								}else{
-									sessionStorage.removeItem("paySuccess_"+obj.order_code);
-								}
-							}
-	                        if(orderStatus==0){
-	                        	orderStatus="待付款"
-	                        	orderHtml=""
-	                        	orderHtml+='<span class="status notpay">'+orderStatus+'</span>'
-                        		orderHtml+="<a class=\"shanchu iconfont  icon-shanchu\" title=\"删除订单\" onclick=\"deleteOrder(" + id +",this)\"></a>";
-	                        	iconHtml=""
-	                        	iconHtml+='<div class="card-footer">'
-											+'<a  class="btn cancle" onclick="cancelOrder('+id+',this)">取消订单</a>'
-											+'<a href="javascript:void(0)" onclick="goPay(this)" class="btn pay" filterid="'+obj.filter_id+'" token="'+token+'" id="'+id+'">去支付</a>'
-										+'</div>'
-	                        }else if(orderStatus==1){
-	                        	orderStatus="已完成";
-	                        	orderHtml=""
-	                        	orderHtml+='<span class="status">'+orderStatus+'</span>'
-                        		orderHtml+="<a class=\"shanchu iconfont  icon-shanchu\" title=\"删除订单\" onclick=\"deleteOrder(" + id +",this)\"></a>";
-	                        	iconHtml=""
-	                        	iconHtml+='<div class="card-footer">'
-											+'<a  onclick="onceMore(this)" class="btn cancle">再次购买</a>'
-										+'</div>'
-	                        }else if(orderStatus==-2){
-	                        	orderStatus="已取消";
-	                        	orderHtml="";
-	                        	orderHtml+='<span class="status">'+orderStatus+'</span>'
-	                        	orderHtml+="<a class=\"shanchu iconfont  icon-shanchu\" title=\"删除订单\" onclick=\"deleteOrder(" + id +",this)\"></a>";
-	                        	iconHtml="";
-	                        	iconHtml+='<div class="card-footer">'
-											+'<a onclick="onceMore(this)" class="btn cancle">再次购买</a>'
-										+'</div>'
-	                        }
-	                        //关键词
-							if(obj.filter_keys && obj.filter_keys.split(",").length>0){
-								var keysHtml="";
-		                        var keysArr = obj.filter_keys.split(",");
-		                        var keysLen = keysArr.length;
-		                        for(var j=0;j<keysLen;j++){
-		                            keysHtml += "<span>" + keysArr[j] + "&nbsp</span>";
-		                        }
-//		                        if(keysArr.length>4){
-//		                            keysHtml += "<span>...</span>";
-//		                        }
-		                 	}else{
-		                 		keysHtml=""
-		                 	}
-							
-							listhtml+='<div class="card">'
-											+'<div class="card-header">'
-												+'<span class="time" style="color:#888888">'+createTime+'</span>'
-											//	+'<span class="status notpay" style="color:#888888">'+orderStatus+'</span>'
-												+orderHtml
-											+'</div>'
-											+'<div class="card-content">'
-												//+'<a href="javascript:;" class="media">'
-												//+'<a href="/front/wxMyOrder/wxToOrderDetail/'+orderCode+'" eid='+orderCode+' class="media">'
-												+'<a  eid='+orderCode+' class="media">'
-													+'<div class="media-img">'
-														+'<img src="/dataExport/image/historical_data.png">'
-													+'</div>'
-													+'<div class="media-info">'
-														+'<p class="item-ifo ellipsis">关键词:'+ keysHtml+'</p>'
-														+'<p class="item-ifo ellipsis">数据量:'+ data_count +'条</p>'
-														+'<p class="item-ifo ellipsis">数据规格:'+spec+'</p>'
-														+'<p class="item-ifo ellipsis">筛选日期:'+publishTime+'</p>'
-													+'</div>'
-												+'</a>'
-												+'<div class="price">'
-													//+'<span class="initial">原价:¥'+orderMoney+'</span>'
-													+'<strong class="current">¥'+orderMoney+'</strong>'
-												+'</div>'
-											+'</div>'
-											+iconHtml
-										+'</div>'
-							
-						}
-					//appendList($("<div>"+listhtml+"</div>"));
-					appendList($(listhtml));
-					if(sessionStorage&&sessionStorage.getItem("paySuccess_"+psss)!=null&&orderTabActive==1){
-						sessionStorage.removeItem("paySuccess_"+psss);
-						getOneMore(gopayIndex);
-					}
-				}
-				
-			})
 		</script>
 	{{include "/common/baiducc.html"}}
 	</body>

+ 1 - 1
src/web/templates/weixin/my.html

@@ -92,7 +92,7 @@
 			initShare({{.T.signature}},{{.T.openid}},2,"jy_wxmyorder",{{.T.nickname}},{{.T.avatar}});
 			$(function(){
 				$(".vip").on("click",function(){
-		        	window.location.href="#";	//vip订阅入口
+		        	window.location.href="/front/vipsubscribe/toPurchasePage";	//vip订阅入口
 		        })
 		        $(".myorder").on("click",function(){
 		        	window.location.href="/weixin/pay/toMyWxOrder?v=01";

+ 69 - 41
src/web/templates/weixin/vipsubscribe/additionWord.html

@@ -7,11 +7,11 @@
         content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
     <meta http-equiv="X-UA-Compatible" content="ie=edge">
     <title>附加词</title>
-    <script src="../js/rem.js"></script>
-    <link rel="stylesheet" href="../css/base.css">
-    <link rel="stylesheet" href="../iconfont/iconfont.css">
-    <link rel="stylesheet" href="../css/weui.min.css">
-    <link rel="stylesheet" href="../css/addition_exclusive_word.css">
+    <script src="/vipsubscribe/js/rem.js"></script>
+    <link rel="stylesheet" href="/vipsubscribe/css/base.css">
+    <link rel="stylesheet" href="/vipsubscribe/iconfont/iconfont.css">
+    <link rel="stylesheet" href="/vipsubscribe/css/weui.min.css">
+    <link rel="stylesheet" href="/vipsubscribe/css/addition_exclusive_word.css">
 </head>
 
 <body>
@@ -20,7 +20,7 @@
         <section class="content">
             <p class="title">示例:开发(附加词)</p>
             <!-- 添加附加词 -->
-            <div class="enter addkeyWord">
+            <div class="enter addkeyWord" style="display: none;">
                 <input type="text" class="enterOne" placeholder="请输入附加词" />
                 <div class="btn">
                     <button disabled>确认</button>
@@ -28,39 +28,9 @@
             </div>
 
             <!-- 添加附加词显示列表 -->
-            <div class="showKeyWord">
+            <div class="showKeyWord" style="display: none;">
                 <ul>
-                    <li>
-                        <div class="one">
-                            <div>
-                                <span>
-                                    <p class="key">abcde</p>
-                                </span>
-                            </div>
-                            <button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
-                        </div>
-                        <div class="modify">
-                            <textarea  name=""  rows="1"  placeholder="" >abcde</textarea>
-                            <!-- <span contentEditable="true" id="option1">abcde</span> -->
-                            <button class="deleteKey">删除</button>
-                            <button class="ascertainKey">确定</button>
-                        </div>
-                    </li>
-                    <li>
-                        <div class="one">
-                            <div>
-                                <span>
-                                    <p class="key">abcde</p>
-                                </span>
-                            </div>
-                            <button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
-                        </div>
-                        <div class="modify">
-                            <textarea  name=""  rows="1"  placeholder="" maxlength="20" >abcde</textarea>
-                            <button class="deleteKey">删除</button>
-                            <button class="ascertainKey">确定</button>
-                        </div>
-                    </li>
+                    
                 </ul>
             </div>
             <div class="problem">
@@ -95,9 +65,67 @@
             </div>
         </div>
     </div>
-    <script src="../js/jquery-2.1.4.js"></script>
-    <script src="../js/weui.min.js"></script>
-    <script src="../js/additionWord.js"></script>
+    <script src="/js/jquery-3.2.1.min.js?v=1412"></script>
+    <script src="/vipsubscribe/js/weui.min.js"></script>
+    <script src="/vipsubscribe/js/additionWord.js"></script>
+    <script type="text/javascript">
+        var addition_kws = []//附加词
+        var _addkws = "";
+        var _addindex = -1;
+        $(function() {
+            if(sessionStorage&&sessionStorage.addition_kws!=undefined){
+                addition_kws = JSON.parse(sessionStorage.addition_kws);
+                appendHtml(addition_kws);
+            }else{
+                $(".enter.addkeyWord").show();
+                $(".showKeyWord").hide();
+            }
+        })
+        //
+        function appendHtml(data){
+            if (data.length>0){
+                var additionHtml = '';
+                for (var i = data.length - 1; i >= 0; i--) {
+                    additionHtml +='<li>'
+                                    +'<div class="one">'
+                                    +'<div>'
+                                    +'<span>'
+                                    +'<p class="key">'+data[i]+'</p>'
+                                    +'</span>'
+                                    +'</div>'
+                                    +'<button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>'
+                                    +'</div>'
+                                    +'<div class="modify">'
+                                    +'<textarea  name=""  rows="1"  placeholder="" maxlength="20" >'+data[i]+'</textarea>'
+                                    +'<button class="deleteKey">删除</button>'
+                                    +'<button class="ascertainKey">确定</button>'
+                                    +'</div>'
+                                    +'</li>'
+                }
+                $(".showKeyWord ul").html(additionHtml);
+                $(".enter.addkeyWord").hide();
+                $(".showKeyWord").show();
+            }else{
+                $(".enter.addkeyWord").show();
+                $(".showKeyWord").hide();
+            }
+        }
+        //
+        function saveSession(t){
+            if (_addkws!=""){
+                if(t!="D"){
+                    if(_addindex>0){
+                        addition_kws[_addindex] = _addkws
+                    }else{
+                        addition_kws.push(_addkws)
+                    }
+                }else{
+                    addition_kws.splice(_addindex,1)
+                }
+                sessionStorage.addition_kws = JSON.stringify(addition_kws)
+           }
+        }
+    </script>
 </body>
 
 </html>

+ 67 - 38
src/web/templates/weixin/vipsubscribe/exclusiveWord.html

@@ -7,11 +7,11 @@
         content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
     <meta http-equiv="X-UA-Compatible" content="ie=edge">
     <title>排除词</title>
-    <script src="../js/rem.js"></script>
-    <link rel="stylesheet" href="../css/base.css">
-    <link rel="stylesheet" href="../iconfont/iconfont.css">
-    <link rel="stylesheet" href="../css/weui.min.css">
-    <link rel="stylesheet" href="../css/addition_exclusive_word.css">
+    <script src="/vipsubscribe./js/rem.js"></script>
+    <link rel="stylesheet" href="/vipsubscribe/css/base.css">
+    <link rel="stylesheet" href="/vipsubscribe/iconfont/iconfont.css">
+    <link rel="stylesheet" href="/vipsubscribe/css/weui.min.css">
+    <link rel="stylesheet" href="/vipsubscribe/css/addition_exclusive_word.css">
 </head>
 
 <body>
@@ -29,36 +29,7 @@
             <!-- 添加排除词显示列表 -->
             <div class="showKeyWord">
                 <ul>
-                    <li>
-                        <div class="one">
-                            <div>
-                                <span>
-                                    <p class="key">abcde</p>
-                                </span>
-                            </div>
-                            <button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
-                        </div>
-                        <div class="modify">
-                            <textarea  name=""  rows="1"  placeholder="" >abcde</textarea>
-                            <button class="deleteKey">删除</button>
-                            <button class="ascertainKey">确定</button>
-                        </div>
-                    </li>
-                    <li>
-                        <div class="one">
-                            <div>
-                                <span>
-                                    <p class="key">abcde</p>
-                                </span>
-                            </div>
-                            <button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
-                        </div>
-                        <div class="modify">
-                            <textarea  name=""  rows="1"  placeholder="" >abcde</textarea>
-                            <button class="deleteKey">删除</button>
-                            <button class="ascertainKey">确定</button>
-                        </div>
-                    </li>
+                    
                 </ul>
             </div>
             <div class="problem">
@@ -93,9 +64,67 @@
             </div>
         </div>
     </div>
-    <script src="../js/jquery-2.1.4.js"></script>
-    <script src="../js/weui.min.js"></script>
-    <script src="../js/exclusiveWord.js"></script>
+    <script src="/js/jquery-3.2.1.min.js?v=1412"></script>
+    <script src="/vipsubscribe/js/weui.min.js"></script>
+    <script src="/vipsubscribe/js/exclusiveWord.js"></script>
+    <script type="text/javascript">
+        var not_kws = []//附加词
+        var _notkws = "";
+        var _notindex = -1;
+        $(function() {
+            if(sessionStorage&&sessionStorage.not_kws!=undefined){
+                not_kws = JSON.parse(sessionStorage.not_kws);
+                appendHtml(not_kws);
+            }else{
+                $(".enter.addkeyWord").show();
+                $(".showKeyWord").hide();
+            }
+        })
+        //
+        function appendHtml(data){
+            if (data.length>0){
+                var additionHtml = '';
+                for (var i = data.length - 1; i >= 0; i--) {
+                    additionHtml +='<li>'
+                                    +'<div class="one">'
+                                    +'<div>'
+                                    +'<span>'
+                                    +'<p class="key">'+data[i]+'</p>'
+                                    +'</span>'
+                                    +'</div>'
+                                    +'<button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>'
+                                    +'</div>'
+                                    +'<div class="modify">'
+                                    +'<textarea  name=""  rows="1"  placeholder="" maxlength="20" >'+data[i]+'</textarea>'
+                                    +'<button class="deleteKey">删除</button>'
+                                    +'<button class="ascertainKey">确定</button>'
+                                    +'</div>'
+                                    +'</li>'
+                }
+                $(".showKeyWord ul").html(additionHtml);
+                $(".enter.addkeyWord").hide();
+                $(".showKeyWord").show();
+            }else{
+                $(".enter.addkeyWord").show();
+                $(".showKeyWord").hide();
+            }
+        }
+        //
+        function saveSession(t){
+            if (_notkws!=""){
+                if(t!="D"){
+                    if(_notindex>0){
+                        not_kws[_notindex] = _notkws
+                    }else{
+                        not_kws.push(_notkws)
+                    }
+                }else{
+                    not_kws.splice(_notindex,1)
+                }
+                sessionStorage.not_kws = JSON.stringify(not_kws)
+           }
+        }
+    </script>
 </body>
 
 </html>

+ 332 - 64
src/web/templates/weixin/vipsubscribe/keyWord.html

@@ -16,6 +16,9 @@
         .ios-user-select {
             -webkit-user-select: text;
         }
+        .opacity6{
+            opacity: 0.6;
+        }
     </style>
 </head>
 
@@ -40,8 +43,8 @@
                     <input type="text" class="enterOne" placeholder="请输入关键词" maxlength="100" />
                     <!-- <textarea style="resize:none;" rows="1"  class="enterOne" name="" id=""  placeholder="请输入关键词" maxlength="100"></textarea> -->
                     <div class="btnChoose" style="display:none;">
-                        <button onclick="window.location.href='/front/vipsubscribe/toSetadditionPage'">添加 附加词</button>
-                        <button onclick="window.location.href='/front/vipsubscribe/toSetexclusivePage'">添加 排除词</button>
+                        <button onclick="toappendkey(this)">添加 附加词</button>
+                        <button onclick="tonotkey(this)">添加 排除词</button>
                     </div>
                     <div class="btn">
                         <button disabled>确认</button>
@@ -67,7 +70,7 @@
 
         <div class="addKeyWord addNewKeyword" style="display: none;">
             <i class="iconfont icon-tianjia"></i>
-            <p> 关键词添加数量:<em style="color: #2cb7ca;" class="kwscount">0 </em>/ 300</p>
+            <p> 关键词添加数量:<em style="color: #2cb7ca;" class="kws_count">0 </em>/ 300</p>
         </div>
 
         <!-- 疑难问题弹窗 -->
@@ -105,19 +108,26 @@
                     <input type="text" class="classify-keyword" placeholder="输入分类名称">
                 </div>
                 <div class="weui-dialog__ft">
-                    <a href="javascript:;" class="dialog__btn dialog__btn_confirm">确定</a> 
+                    <a href="javascript:;" class="dialog__btn dialog__btn_confirm opacity6">确定</a> 
                     <a href="javascript:;" class="dialog__btn dialog__btn_cancel">取消</a>
                 </div>
             </div>
         </div>
     </div>
     
-    
     <script src="/js/jquery-3.2.1.min.js?v=1412"></script>
+    <script src="/js/jquery.cookie.js"></script>
     <script src="/vipsubscribe/js/weui.min.js"></script>
     <script>
-        var a_items = [];
-        var o_selected = {};
+        var a_items = [];//全部数据
+        var classify_name = "";//分类名称
+        var classify_index = 0;//分类索引
+        var kws_name = "";//分类关键词内容
+        var kws_index = 0;//分类关键词索引
+        var kws_count = 0;//关键词个数
+        var modifyFlag = false;//附加词 排除词变动
+        var addition_kws = []; //附加词
+        var not_kws = []; //排除词
         // 页面状态
         var pageState = {
             //是否第一次设置关键词
@@ -128,27 +138,46 @@
         })
         //获取数据
         function init(){
-            //获取用户设置信息类型
-            $.post("/subscribepay/afterPay/getUserInfo",{},function(r){
-                if(r.userData){
-                    var _userData = r.userData;
-                    var _vipData = _userData["o_vipjy"];
-                    a_items = _vipData["a_items"]
-                        console.log(a_items)
-                        console.log(a_items.length)
-                    if (a_items!=undefined&&a_items.length>0){
-                        pageState.isFirstSetKeyword = false;
-                        appendHtml(a_items);
+            if(sessionStorage&&sessionStorage.kwspage){
+                if(sessionStorage.addition_kws!=undefined){
+                    addition_kws = JSON.parse(sessionStorage.addition_kws);
+                }
+                if(sessionStorage.not_kws!=undefined){
+                    not_kws = JSON.parse(sessionStorage.not_kws);
+                }
+                showKorshowC(sessionStorage.kwspage);
+                a_items = JSON.parse(sessionStorage.a_items)
+                classify_name = sessionStorage.classify_name;
+                classify_index = sessionStorage.classify_index;
+                kws_name = sessionStorage.kws_name;
+                kws_index = sessionStorage.kws_index;
+                modifyFlag = true;
+                kws_count = sessionStorage.kws_count;
+                $(".kws_count").text(kws_count);
+                ///$('.addKeyWord').hide()
+                toSetKws();
+            }else{
+                //获取用户设置信息类型
+                $.post("/subscribepay/afterPay/getUserInfo",{},function(r){
+                    if(r.userData){
+                        var _userData = r.userData;
+                        var _vipData = _userData["o_vipjy"];
+                        modifyFlag = false;
+                        a_items = _vipData["a_items"]
+                        if (a_items!=undefined&&a_items.length>0){
+                            pageState.isFirstSetKeyword = false;
+                            appendHtml(a_items);
+                        }else{
+                            pageState.isFirstSetKeyword = true;
+                        }
+                        hasWords();
                     }else{
                         pageState.isFirstSetKeyword = true;
                     }
-                }else{
-                    pageState.isFirstSetKeyword = true;
-                }
-                showKorshowC(pageState.isFirstSetKeyword);
-            })
+                    showKorshowC(pageState.isFirstSetKeyword);
+                })
+            }
         }
-
         //关键词和分类列表切换
         function showKorshowC(state){
             if (state) {
@@ -162,15 +191,15 @@
         }
         //分类列表
         function appendHtml(kwsdata){
+            kws_count = 0;
             var classifyHtml = '';
-            var kwscount = 0;
             for (var i = 0;  i < kwsdata.length; i++) {
-                console.log( kwsdata[i])
                 var s_item = kwsdata[i]["s_item"]
+                if(s_item==""){
+                    s_item = "未分类"
+                }
                 var a_key = kwsdata[i]["a_key"]
-                o_selected[s_item]=a_key
-                kwscount += a_key.length;
-                console.log("a_key:"+a_key.length)
+                kws_count += a_key.length;
                 classifyHtml +='<li class="classify-item">'
                             +'<span class="classify-item-l">'+s_item+'</span>'
                             +'<span class="classify-item-r">'
@@ -183,35 +212,262 @@
             if(classifyHtml!=""){
                 $(".classify-list").html(classifyHtml);
             }
-            $(".kwscount").text(kwscount);
+            $(".kws_count").text(kws_count);
+        }
+        //是否有关键词
+        function hasWords() {
+            var showKeyWordLength = $(".showKeyWord ul").find('li').length;
+            if (showKeyWordLength === 0) {
+                $(".content .addkeyWord").show();
+            } else {
+                $(".content .addkeyWord").hide();
+            }
         }
         //修改关键词内容
-        function toSetKws(_key){
-            // $(".content .addkeyWord").hide();
-            console.log(o_selected[_key])
-            $(".classify-detail").text(_key);
+        function toSetKws(){
+            if(kws_index==-1){
+                var edhtml = '<input type="text" class="enterOne" placeholder="请输入关键词" maxlength="100">'
+                            +'<div class="btnChoose">'
+                if(addition_kws.length>0){
+                    edhtml +='<button onclick="toappendkey(this)">编辑 附加词<i>('+addition_kws.length+')</i></button>'
+                }else{
+                    edhtml +='<button onclick="toappendkey(this)">添加 附加词</button>'
+                }
+                if(not_kws.length>0){
+                    edhtml +='<button onclick="tonotkey(this)">编辑 排除词<i>('+not_kws.length+')</i></button>'
+                }else{
+                    edhtml +='<button onclick="tonotkey(this)">添加 排除词</button>'
+                }
+                edhtml +='</div>'
+                        +'<div class="btn">'
+                        +'<button style="opacity: 1;">确认</button>'
+                        +'</div>'
+                $(".enter.addkeyWord").html(edhtml);
+                setTimeout(function(){
+                    $(".enter.addkeyWord").find("input").val(kws_name)
+                    $(".enter.addkeyWord").show();
+                },200)
+            }
+            if(classify_name==""){
+                $(".classify-detail").text("未分类");
+            }else{
+                $(".classify-detail").text(classify_name);
+            }
             var kwsHtml = '';
-            var _keyArr = o_selected[_key];
-            for(var i=0;i<_keyArr.length;i++){
-                console.log(_keyArr[i])
-                kwsHtml +='<li>'
-                            +'<div class="one" style="">'
-                            +'<div><span><strong> 关键词:</strong>'
-                            +'<p class="key">'+_keyArr[i]["key"]+'</p></span></div>'
-                            +'<button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>'
-                            +'</div>'
-                            +'<div class="modify" style="display: none;">'
-                            +'<textarea name="" rows="1" placeholder="" maxlength="20">eee</textarea>'
-                            +'<button class="addAdjunctWord">编辑 附加词</button>'
-                            +'<button class="addExclusion">添加 排除词</button>'
-                            +'<button class="deleteKey">删除</button>'
-                            +'<button class="ascertainKey">确定</button>'
-                            +'</div>'
-                            +'</li>'
+            if( a_items[classify_index]!=undefined){
+                var _keyArr = a_items[classify_index]["a_key"];
+                for (var i = _keyArr.length - 1; i >= 0; i--) {
+                    var ak_showClass = 'hide';//是否显示附加词个数
+                    var nk_showClass = 'hide';//是否显示排除词个数
+                    var ak_remark = '添加';
+                    var nk_remark = '添加';
+                    var appendkeylth = 0;
+                    var notkeylth = 0;
+                    kwsHtml +='<li>'
+                    if(modifyFlag&&i==kws_index){
+                        kwsHtml +='<div class="one" style="display:none;">'
+                        _keyArr[i]["appendkey"] = addition_kws;
+                        _keyArr[i]["notkey"] = not_kws;
+                    }else{
+                        kwsHtml +='<div class="one" style="">'
+                    }
+                    kwsHtml +='<div>'
+                                +'<span><strong> 关键词:</strong>'
+                                +'<p class="key">'+_keyArr[i]["key"].join(" ")+'</p></span>'
+                    if (_keyArr[i]["appendkey"]!=undefined&&_keyArr[i]["appendkey"].length>0){
+                        ak_showClass = "";
+                        ak_remark = '编辑';
+                        appendkeylth = _keyArr[i]["appendkey"].length;
+                        kwsHtml +='<span>'
+                                    +'<strong> 附加词:</strong>'
+                                    +'<p class="addition">'+_keyArr[i]["appendkey"].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="'+i+'"><i class="iconfont icon-xiugai"></i> 修改</button>'
+                                +'</div>'
+                     
+                    if(modifyFlag&&i==kws_index){
+                        kwsHtml +='<div class="modify" style="display:block;">'
+                        if(addition_kws.length>0){
+                            appendkeylth = addition_kws.length;
+                        }
+                        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)">'+ak_remark+' 附加词 <i class="appendkey '+ak_showClass+'">('+appendkeylth+')</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" onclick="saveK(this,'+i+')">确定</button>'
+                                +'</div>'
+                                +'</li>'
+                }
+                $(".showKeyWord ul").html(kwsHtml);
             }
+            hasWords();
             // 发送请求刷新数据,在ajax回调中执行
-            $('.add-keyword-container').show()
-            $('.all-classify-column').hide()
+            $('.add-keyword-container').show();
+            $('.all-classify-column').hide();
+            clearSesstion();
+        }
+        //跳转附加词
+        function toappendkey(th){
+            if(!$('.enter.addkeyWord').is(':hidden')){
+                if($('.addkeyWord input.enterOne').val()==""){
+                    return
+                }
+                kws_index = -1
+                kws_name = $('.addkeyWord input.enterOne').val();
+            }else{
+               if($(th).parent(".modify").find("textarea").val()==""){
+                 return
+               }
+                kws_name = $(th).parent(".modify").find("textarea").val();
+            }
+            setSesstion();
+            window.location.href="/front/vipsubscribe/toSetadditionPage";
+        }
+        //
+        function tonotkey(th){
+            if(!$('.enter.addkeyWord').is(':hidden')){
+                if($('.addkeyWord input.enterOne').val()==""){
+                    return
+                }
+                kws_index = -1
+                kws_name = $('.addkeyWord input.enterOne').val();
+            }else{
+               if($(th).parent(".modify").find("textarea").val()==""){
+                 return
+               }
+                kws_name = $(th).parent(".modify").find("textarea").val();
+            }
+            setSesstion();
+            window.location.href='/front/vipsubscribe/toSetexclusivePage';
+        }
+        //保存缓存
+        function setSesstion(){
+            sessionStorage.kwspage = true;//关键词页面标识
+            sessionStorage.kws_name = kws_name;//当前关键词
+            sessionStorage.classify_name = classify_name;//当前分类
+            sessionStorage.kws_index = kws_index;//当前关键词索引
+            sessionStorage.classify_index = classify_index;//当前分类索引
+            sessionStorage.a_items = JSON.stringify(a_items);//当前数据
+            sessionStorage.addition_kws =  JSON.stringify(addition_kws);//当前编辑关键词附加词
+            sessionStorage.not_kws =  JSON.stringify(not_kws);//当前编辑关键词排除词
+
+            sessionStorage.kws_count=kws_count;//关键词个数
+        }
+        //
+        function clearSesstion(){
+            if(!sessionStorage){
+                return;
+            }
+            sessionStorage.removeItem("kwspage");
+            sessionStorage.removeItem("kws_name");
+            sessionStorage.removeItem("classify_name");
+            sessionStorage.removeItem("kws_index");
+            sessionStorage.removeItem("classify_index");
+            sessionStorage.removeItem("a_items");
+            sessionStorage.removeItem("addition_kws");
+            sessionStorage.removeItem("not_kws");
+            sessionStorage.removeItem("kws_count");
+        }
+        //保存关键词
+        function saveK(th,i){
+            var $this = $(th);
+            kws_name = $(th).siblings('textarea').val();
+            if(kws_name.length > 20){
+                weui.toast('关键词不能超过20字', {
+                    duration: 2000,
+                    className: 'custom-toast',
+                    callback: function () { console.log('close') }
+                });
+            }else{
+                if(saveData('SK')){
+                    $this.parent().siblings().find('.key').text(kws_name)
+                    $this.parent().hide().siblings().show()
+                    $('.addKeyWord').show();
+                    //
+                    doSessionData();
+                }else{
+                    alert("保存出错,稍后再试")
+                }
+            }
+        }
+        //保存数据
+        function saveData(actionType){
+            var _flag = false;
+            var kwscount = $(".content .showKeyWord li").length;
+            var param = {};
+            param.pageType = "keyWords";
+            param.classify_index = classify_index;
+            param.classify_name = classify_name;
+            param.kws_index = kws_index;
+            param.kws_name = kws_name;
+            param.actionType = actionType;
+            param.kwscount = kwscount;
+            param.addition_kws = addition_kws;
+            param.not_kws = not_kws;
+            $.ajax({
+                type: "POST",
+                url: "/subscribepay/afterPay/setUserInfo",
+                data: param,
+                dataType: "json",
+                async: false,
+                traditional: true,
+                success: function(r){
+                    if(r.flag){
+                        console.log("保存成功")
+                        _flag = r.flag;
+                    }
+                }
+            });
+            return _flag
+        }
+        //处理缓存数据
+        function doSessionData(t){
+            if(t!="DK"){
+                if(kws_index == ($(".showKeyWord li").length-1)){
+                    //新加
+                    var karr = {"key":kws_name.split(" "),"appendkey":addition_kws,"notkey":not_kws}
+                    var keyM = [];
+                    keyM.push(karr);
+                    var classifyArr = {"s_item":classify_name,"a_key":keyM}
+                    if (kws_index==0){
+                        a_items.push(classifyArr);
+                    }else{
+                        a_items[classify_index]["a_key"].push(karr);
+                    }
+                }else{
+                    a_items[classify_index]["a_key"][kws_index]["key"]= kws_name.split(' ')
+                    a_items[classify_index]["a_key"][kws_index]["appendkey"]= addition_kws
+                    a_items[classify_index]["a_key"][kws_index]["notkey"]= not_kws
+                }
+            }else{
+                if (a_items[classify_index]["a_key"].length==1){
+                    a_items.splice(classify_index,1);
+                }else{
+                    a_items[classify_index]["a_key"].splice(kws_index,1);
+                }
+            }
+            //把kws_name,kws_index,addition_kws,not_kws初始化
+            kws_index = 0;
+            kws_name = "";
+            addition_kws = [];
+            not_kws = [];
         }
     </script>
     <script src="/vipsubscribe/js/keyWord.js"></script>
@@ -219,6 +475,7 @@
         // 设置一条空记录,用户第一次进入添加关键词点击确定时候调用
         function setEmptyHistory() {
             if (pageState.isFirstSetKeyword) {
+                    console.log("33333333333")
                 history.pushState({}, "","")
                 pageState.isFirstSetKeyword = false
             }
@@ -229,36 +486,47 @@
             $(".addNewKeyword i").on('click', function () {
                 // 如果是在分类列表点击添加(此时关键词列表是隐藏的)
                 // isClassifyColumnShow = true说明是添加新分类
-                var isClassifyColumnShow = $('.add-keyword-container').is(':hidden')
+                var isClassifyColumnShow = $('.add-keyword-container').is(':hidden');
                 if (isClassifyColumnShow) {
-                    history.pushState({}, "","")
+                    console.log("11111111111111111")
+                    history.pushState({}, "","");
+                    classify_index = $(".classify-list li").length;
                     // 还原有数据
-                    $('.classify .classify-detail').text('未分类')
-                    $('.add-keyword-container .showKeyWord ul').html('')
+                    $('.classify .classify-detail').text('未分类');
+                    $('.add-keyword-container .showKeyWord ul').html('');
                     
                 }
-                $('.add-keyword-container').show()
-                $('.all-classify-column').hide()
+                $('.add-keyword-container').show();
+                $('.all-classify-column').hide();
                 
                 // 显示添加关键词的输入框
-                $(".enter.addkeyWord").show()
-                $('.enterOne').focus()
+                $(".enter.addkeyWord").find(".btnChoose button").eq(0).html('添加 附加词');
+                $(".enter.addkeyWord").find(".btnChoose button").eq(1).html('添加 附加词');
+                $(".enter.addkeyWord").find("input").val("");
+                $(".enter.addkeyWord").show();
+                $('.enterOne').focus();
             })
 
             // 点击分类目录的每一项,进入对应列表
             $('.classify-list').on('click', '.classify-item-r', function() {
                 // 添加一条空历史记录
+                    console.log("2222222222")
                 history.pushState({}, "","");
-                var classifyName = $(this).parent().find('.classify-item-l').text()
+                classify_name = $(this).parent().find('.classify-item-l').text();
+                classify_index = $(this).parent("li").index()
                 //展示此关键词信息
-                toSetKws(classifyName);
+                toSetKws();
             })
         })
         window.addEventListener('popstate', function(event){
-
+            if(a_items.length==0){
+                window.history.go(-1)
+            }
             var loading = weui.loading('loading...', {
                 className: 'custom-classname'
             })
+            //重新加载数据
+            init();
             // 用定时器模拟请求耗时
             setTimeout(function () {
                 loading.hide(function() {

+ 2 - 2
src/web/templates/weixin/vipsubscribe/messageType.html

@@ -145,8 +145,8 @@
         //是否 修改
         $(function(){
             //获取用户设置信息类型
-             $.post("/subscribepay/afterPay/getUserInfo",{},function(r){
-                 if(r.userData){
+            $.post("/subscribepay/afterPay/getUserInfo",{},function(r){
+                if(r.userData){
                     var _userData = r.userData;
                     var _vipData = _userData["o_vipjy"];
                     var a_infotype = _vipData["a_infotype"]

+ 11 - 2
src/web/templates/weixin/vipsubscribe/vip_index.html

@@ -72,7 +72,7 @@
                             <img src="/vipsubscribe/image/keyword.png?v={{Msg "seo" "version"}}" alt="">
                             <span>关键词</span>
                         </div>
-                        <a href="/front/vipsubscribe/toSetKeyWordPage" class="media_right">
+                        <a href="/front/vipsubscribe/toSetKeyWordPage" class="media_right" id="keywords">
                             
                         </a>
                     </div>
@@ -152,7 +152,7 @@
                    var _userData = r.userData;
                    var _vipData = _userData["o_vipjy"];
                    var _vipstatus = _userData["i_vip_status"];
-                   console.log(_userData)
+                   // console.log(_userData)
                    if(_vipstatus&&_vipstatus=="1"){
                         $('.free7days_pic').append("<style>.free7days_pic::after{display:inline-block}</style>");
                    }else{
@@ -183,6 +183,15 @@
                             pushText = "每日推送"
                         }
                         $("#pushSet").text(pushText);
+                        var a_items = _vipData["a_items"]
+                        var s_items = ""
+                        for (var i = a_items.length - 1; i >= 0; i--) {
+                            if(s_items!=""){
+                                s_items += " "
+                            }
+                            s_items  += a_items[i]["s_item"]
+                        }
+                        $("#keywords").text(s_items);
                    }
                 }
            })

+ 37 - 17
src/web/templates/weixin/vipsubscribe/vip_order_detail.html

@@ -39,15 +39,15 @@
                         <p class="text ellipsis">产品类型:<span class="productType"></span></p>
                         <p class="text ellipsis">价格:¥<span class="price"></span></p>
                         <!----- 未开发票状态 ----->
-                        <p class="text ellipsis invoice">发票:<a href="invoice.html" class="invoicing" style="display:none">开发票</a></p>
+                        <p class="text ellipsis invoice">发票:<a class="invoicing" style="display:none">开发票</a></p>
                         <!----- 已开发飘状态 ----->
                         <!--  单位发票-->
                         <div class="unit" style="display: none;">
                             <p><span>发票类型:</span><span>普通发票(电子发票)</span></p>
-                            <p><span>发票内容:</span><span>明细</span></p>
+                            <p><span>发票内容</span><span>明细</span></p>
                             <p><span>发票抬头:</span><span>单位</span></p>
-                            <p><span>单位名称:</span><span>某某网络科技有限公司某某网络科技有限公司某某网络科技有限公司某某网络科技有</span></p>
-                            <p><span>纳税人识别号:</span><span>97632813007812341T</span></p>
+                            <p><span>单位名称:</span><span class="company_name"></span></p>
+                            <p><span>纳税人识别号:</span><span class="taxpayer_number"></span></p>
                         </div>
                         <!-- 个人发票 -->
                         <div class="person" style="display: none;">
@@ -93,6 +93,7 @@
             </div>
         </main>
         <!-- 当状态为待付款时显示去支付按钮 -->
+        <!--当状态为已取消时显示再次购买按钮-->
         <a href="#" class="button align" style="display:none">去支付</a>
     </div>
 </body>
@@ -207,7 +208,7 @@ if(signature && signature.length == 4){
               }
             })
           })
-        }else{
+        }else if (r.data.order.order_status==1){
           $("#pageTitle").text("已完成");
           //支付时间
           $(".line_paytime").css("display","");
@@ -230,9 +231,22 @@ if(signature && signature.length == 4){
           if(r.data.order.applybill_status==0){ 
             //已支付未申请发票
             $(".invoice .invoicing").css("display","");
+            $(".invoicing").on("click",function(){
+            	window.location.href="/front/vipsubscribe/openInvoice/"+orderCode;
+            });
           }else{
             //已支付已申请发票
-            alert("铺发票信息")
+			$(".invoice").css("display","none");
+            switch (r.data.order.applybill_type){
+            	case 0:
+            	$(".person").css("display","");
+            	break;
+            	case 1:
+            	$(".unit").css("display","");
+            	$(".company_name").html(r.data.order.applybill_company);
+            	$(".taxpayer_number").html(r.data.order.applybill_taxnum);
+            	break;
+            }
           } 
           
           //有效周期
@@ -241,6 +255,12 @@ if(signature && signature.length == 4){
           if(r.data.time.l_vip_starttime&&r.data.time.l_vip_endtime){
             $(".serviceTime").text(formatEffectiveDate(r.data.time.l_vip_starttime,r.data.time.l_vip_endtime))
           }
+        }else if(r.data.order.order_status==-2){
+    		$("#pageTitle").text("已取消");
+     		$(".invoice").css("display","none");//隐藏开发票
+     		if(!(r.data.time.l_vip_starttime&&r.data.time.l_vip_endtime)){
+           		$(".align").css("display","").html("再次购买");
+          	}
         }
                 
       }
@@ -261,18 +281,18 @@ if(signature && signature.length == 4){
   						},500)
   					}else if(r.err_msg == "get_brand_wcpay_request:cancel"){
   						//取消支付 可以再次支付
-              canpay=true;
-              alert("开发环境【支付跳转完成】")
-              try{
-  							window.location.replace("/front/vipsubscribe/toPaySuccessPage?orderCode="+ordercode);
-              }catch(e){
-                alert(e)
-              }
+			            canpay=true;
+			            alert("开发环境【支付跳转完成】")
+			            try{
+			  				window.location.replace("/front/vipsubscribe/toPaySuccessPage?orderCode="+ordercode);
+		            	}catch(e){
+			                alert(e)
+		                }
   					}else{
-              weui.toast("系统异常,请稍微再试",{
-                duration: 2000,
-                className: 'custom-toast',
-              });
+		                weui.toast("系统异常,请稍微再试",{
+		               		duration: 2000,
+		                	className: 'custom-toast',
+		              	});
   				  }
   			});
   		}