Authored by 马力

Merge branch 'dev-weibo-card' into grey

@@ -57,4 +57,8 @@ module.exports = function (app) { @@ -57,4 +57,8 @@ module.exports = function (app) {
57 57
58 // 查询优惠券操作记录 58 // 查询优惠券操作记录
59 app.post("/coupon/getOperationRecords", "CouponList_getOperationRecords"); 59 app.post("/coupon/getOperationRecords", "CouponList_getOperationRecords");
  60 +
  61 + // 更新第三方信息
  62 + app.post("/coupon/updateCouponsUseRule", "CouponList_updateCouponsUseRule");
  63 +
60 }; 64 };
@@ -81,6 +81,15 @@ module.exports = { @@ -81,6 +81,15 @@ module.exports = {
81 params: { 81 params: {
82 couponsId: {type: Number} 82 couponsId: {type: Number}
83 } 83 }
  84 + },
  85 + updateCouponsUseRule: {
  86 + title: "更新第三方信息",
  87 + url: "/coupon/updateCouponsUseRule",
  88 + params: {
  89 + couponId: {type: Number},
  90 + thirdType: {type: Number},
  91 + thirdId: {type: String}
  92 + }
84 } 93 }
85 } 94 }
86 -};  
  95 +};
@@ -235,6 +235,27 @@ @@ -235,6 +235,27 @@
235 </table> 235 </table>
236 </div> 236 </div>
237 </script> 237 </script>
  238 +<script id="third-template" type="text/template" charset="utf-8">
  239 + <div class="row" id="baseform">
  240 + <div class="form-group">
  241 + <label class="col-sm-2 control-label">第三方类型 </label>
  242 + <div class="col-sm-8">
  243 + <input type="hidden" name="couponId" id="couponId" value="{{couponId}}"/>
  244 + <select name="thirdType" id="thirdType" {{if thirdType == 1}}disabled{{/if}} tabindex="-1" class="select2-offscreen" style="width: 100px;">
  245 + <option value="1" {{if thirdType == 1}}selected{{/if}}>微信</option>
  246 + <option value="2" {{if thirdType == 2}}selected{{/if}}>支付宝</option>
  247 + <option value="3" {{if thirdType != 1 && thirdType != 2}}selected{{/if}}>微博</option>
  248 + </select>
  249 + </div>
  250 + </div>
  251 + <div class="form-group">
  252 + <label class="col-sm-2 control-label">第三方 ID</label>
  253 + <div class="col-sm-8">
  254 + <input id="thirdId" class="form-control panel-input" value="{{thirdId}}" {{if thirdType == 1}}readonly{{/if}} type="text" placeholder="第三方 ID">
  255 + </div>
  256 + </div>
  257 + </div>
  258 +</script>
238 <%include '../../../common/views/__ui/footer'%> 259 <%include '../../../common/views/__ui/footer'%>
239 260
240 261
@@ -3,8 +3,8 @@ @@ -3,8 +3,8 @@
3 */ 3 */
4 4
5 'use strict'; 5 'use strict';
6 -var $ = require('jquery'),  
7 - common = require('../../../common/common'); 6 +var $ = require('jquery'), common = require('../../../common/common');
  7 +var artTemplate = common.artTemplate;
8 /** 8 /**
9 * 全局变量 9 * 全局变量
10 * couponTypes 优惠券类型 10 * couponTypes 优惠券类型
@@ -18,12 +18,14 @@ var useLimitTypes = ["无限制", "货物件数限制", "订单金额限制"]; @@ -18,12 +18,14 @@ var useLimitTypes = ["无限制", "货物件数限制", "订单金额限制"];
18 // var customTypes = ["新客户", "银卡会员", "金卡会员", "白金卡会员", "普通用户(不含新客)"]; 18 // var customTypes = ["新客户", "银卡会员", "金卡会员", "白金卡会员", "普通用户(不含新客)"];
19 var customTypes={1:"新客户",2:"银卡会员", 3:"金卡会员", 4:"白金卡会员", 5:"普通用户(不含新客)",9:"学生"}; 19 var customTypes={1:"新客户",2:"银卡会员", 3:"金卡会员", 4:"白金卡会员", 5:"普通用户(不含新客)",9:"学生"};
20 var shopPriceLimitsTable={1:"成交价低于吊牌价三折",2:"限量商品"}; 20 var shopPriceLimitsTable={1:"成交价低于吊牌价三折",2:"限量商品"};
  21 +var thirdTypeEnum={1:"微信", 2:"支付宝", 3: "微薄"};
21 22
22 var ENUM = { 23 var ENUM = {
23 status: {0: '待审核', 1: '审核通过', 2: '驳回', '-1': '过期', 3: '作废'},//全部 24 status: {0: '待审核', 1: '审核通过', 2: '驳回', '-1': '过期', 3: '作废'},//全部
24 tips: {"0": 0, "1": 0, "2": 0, "3": 0, "4": 0, "all": 0} 25 tips: {"0": 0, "1": 0, "2": 0, "3": 0, "4": 0, "all": 0}
25 }; 26 };
26 var columnname = "all"; 27 var columnname = "all";
  28 +
27 /** 29 /**
28 * 初始化下拉框 30 * 初始化下拉框
29 */ 31 */
@@ -121,6 +123,9 @@ var g = new common.grid({ @@ -121,6 +123,9 @@ var g = new common.grid({
121 arr.push("<p>优惠结果:" + item.couponAmount + "</p>"); 123 arr.push("<p>优惠结果:" + item.couponAmount + "</p>");
122 arr.push("<p>数量:" + item.couponNum + "</p>"); 124 arr.push("<p>数量:" + item.couponNum + "</p>");
123 arr.push("<p>部门:" + item.departmentName + "</p>"); 125 arr.push("<p>部门:" + item.departmentName + "</p>");
  126 + if (item.couponsUseRuleVo && item.couponsUseRuleVo.thirdType) {
  127 + arr.push("<p>第三方(" + thirdTypeEnum[item.couponsUseRuleVo.thirdType] + "): " + item.couponsUseRuleVo.thirdId+ "</p>");
  128 + }
124 return arr.join(''); 129 return arr.join('');
125 } 130 }
126 }, 131 },
@@ -236,6 +241,8 @@ var Bll = { @@ -236,6 +241,8 @@ var Bll = {
236 btns.push(buttons[array[i]]) 241 btns.push(buttons[array[i]])
237 } 242 }
238 243
  244 + // 绑定第三方 id
  245 + btns.push('<a class="btn btn-warning btn-xs operation-third" data-coupon-id="' + id + '" data-index="' + index + '">绑定三方</a>');
239 // 增加查看操作记录按钮 246 // 增加查看操作记录按钮
240 btns.push('<a class="btn btn-primary btn-xs operation-records" data-coupon-id="' + id + '">操作记录</a>'); 247 btns.push('<a class="btn btn-primary btn-xs operation-records" data-coupon-id="' + id + '">操作记录</a>');
241 return btns; 248 return btns;
@@ -359,6 +366,47 @@ $(document).on('click', '.coupon-info', function () { @@ -359,6 +366,47 @@ $(document).on('click', '.coupon-info', function () {
359 366
360 Bll.toastInfo(item1, '优惠券详情'); 367 Bll.toastInfo(item1, '优惠券详情');
361 }); 368 });
  369 +// 绑定第三方
  370 +$(document).on('click', '.operation-third', function() {
  371 +
  372 + var item = g.rows[$(this).data("index")];
  373 + var obj = {};
  374 + if (item.couponsUseRuleVo && item.couponsUseRuleVo.thirdType) {
  375 + obj = item.couponsUseRuleVo;
  376 + }
  377 + obj["couponId"] = item.id;
  378 +
  379 + var e = new common.edit("#baseform");
  380 +
  381 + var url = "/coupon/updateCouponsUseRule";
  382 +
  383 + var dialog = common.dialog.confirm("绑定第三方 ID", artTemplate("third-template", obj), function() {
  384 +
  385 + e.submit(url, function (option) {
  386 +
  387 + console.log(option.data);
  388 +
  389 + option.success=function() {
  390 + dialog.close();
  391 + g.reload();
  392 + };
  393 + option.error=function(){};
  394 + });
  395 +
  396 + return false;
  397 + });
  398 +
  399 + // e.on("validate", function() {
  400 + // var thirdId = $("#baseform").find("#thirdId").val();
  401 + // if ($.trim(thirdId).length == 0) {
  402 + // return "请输入第三方 ID";
  403 + // }
  404 + // });
  405 +
  406 + e.init();
  407 +
  408 + new common.dropDown({ el: "#thirdType" });
  409 +});
362 410
363 // 查看操作记录 411 // 查看操作记录
364 $(document).on('click', '.operation-records', function() { 412 $(document).on('click', '.operation-records', function() {