Authored by 姜敏

优惠券活动--初步

... ... @@ -6,6 +6,25 @@
var $ = require('jquery');
common = require('../common/common');
var activity = require('./partials/activity');
new common.dropDown({
el: "#filter-activityType"
});
var startTimeObj;
var endTimeObj;
var e1 = new common.edit2("#basicForm",{
bucket: "couponImage"//真实的);
});
////分享图片
//var e2 = new common.edit("#couponImage", {
// //bucket: "couponImage"//真实的
// bucket: "goodsimg"//
//});
////背景图片
//var e3 = new common.edit("#couponBgImg", {
// //bucket: "couponBgImg"//真实的
// bucket: "goodsimg"//
//});
/**
* 监听输入值的变化
*/
... ... @@ -15,12 +34,62 @@ $(document).on("change", ".observe", function () {
activity = common.util.__buildobj(name, '.', activity, function (obj, name) {
obj[name] = $this.val();
});
//console.log("activity",activity);
});
var Bll={
render:function(){
$("#basicForm").html(common.util.__template2($("#couponListAdd-template").html(), activity));
Bll.__editRender();
},
getTime: function (time) {
var t = new Date(time * 1000);
return common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
},
__editRender: function () {
e1.init();
//e1.init();
//e3.init();
startTimeObj = $("#startTime").fdatepicker({
format: 'yyyy-mm-dd hh:ii:ss',
pickTime: true
}).data("datepicker");
endTimeObj = $("#endTime").fdatepicker({
format: 'yyyy-mm-dd hh:ii:ss',
pickTime: true
}).data("datepicker");
}
};
$("#basicForm").html(common.util.__template2($("#couponListAdd-template").html(), activity));
Bll.render();
/*添加一行*/
$(document).on("click", ".addBtn", function () {
activity.couponIds.push({
"id": ""
});
Bll.render();
});
/**
* 删除行
*/
$(document).on("click", ".delBtn", function () {
var index = $(this).data("index");
if(activity.couponIds.length<=1){
common.util.__tip("至少有一张优惠券","warning")
}
else {
activity.couponIds.splice(index, 1);
Bll.render();
}
});
$(document).on('click',"#save_brand",function(){
console.log("保存数据",activity);
//if(e1.validate()&&e2.validate()&&e3.validate()){
// common.util.__ajax({
// url:"/couponActivity/add",
// data:activity
// }, function (){
//
// } )
//}
});
... ...
... ... @@ -60,7 +60,6 @@ var g = new common.grid({
},{
display: "状态",
render: function (item) {
console.log(item.status);
return status[item.status];
}
}, {
... ...
... ... @@ -15,7 +15,8 @@ var activity = {
isVerify: "N",
instructions: "",
isNewUser: 0,
couponId: ""
couponId: "",
couponIds:[{"id":""}]
};
... ...
... ... @@ -39,16 +39,16 @@
<label class="col-sm-2 control-label">活动名称 <span class="red">*</span></label>
<div class="col-sm-8">
<input type="text" placeholder="名称建议30字以内" prompt="名称" class="form-control observe"
<input type="text" placeholder="活动名称" prompt="活动名称" class="form-control observe"
data-field="actName" required maxlength="30" value="[[actName]]">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">活动类型</label>
<label class="col-sm-2 control-label">活动类型 </label>
<div class="col-sm-8">
<select id="activityType" tabindex="-1" class="select2-offscreen brandBtn-group observe"
value="[[activityType]]" data-field="activityType" required>
<select id="filter-activityType" tabindex="-1" class="select2-offscreen observe"
value="[[activityType]]" data-field="activityType" >
<option value="-1">活动类型</option>
<option value="1">普通活动</option>
<option value="2">APP活动</option>
... ... @@ -61,7 +61,7 @@
<div class="col-sm-8">
<input type="text" placeholder="活动地址" class="form-control observe number" data-field="actUrl"
required value="[[actUrl]]">
value="[[actUrl]]">
</div>
</div>
<div class="form-group">
... ... @@ -70,28 +70,28 @@
<div class="col-sm-6">
<div class="col-sm-6">
<input type="text" class="form-control observe" data-field="startTime" id="startTime"
placeholder="开始时间" value="[[startTime]]" readonly required>
placeholder="开始时间" value="[[startTime]]" readonly >
</div>
<div class="col-sm-6">
<input type="text" class="form-control observe" data-field="endTime" id="endTime"
placeholder="结束时间" value="[[endTime]]" readonly required>
placeholder="结束时间" value="[[endTime]]" readonly >
</div>
</div>
</div>
<div class="form-group">
<div class="form-group" id="couponBgImg">
<label class="col-sm-2 control-label">背景图片</label>
<div class="col-sm-8">
<input type="file" placeholder="背景图片" class="form-control observe number" data-field="bgImageUrl"
required value="[[bgImageUrl]]">
<input type="file" placeholder="背景图片" class="form-control observe number" data-field="bgImageUrl"
value="[[bgImageUrl]]">
<p>图片不是必选项 ,活动类型为APP活动时添加</p>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">分享标题 <span class="red">*</span></label>
<label class="col-sm-2 control-label">分享标题</label>
<div class="col-sm-8">
<input type="text" placeholder="分享标题" prompt="名称" class="form-control observe"
data-field="shareTitile" required maxlength="30" value="[[shareTitile]]">
data-field="shareTitile" maxlength="30" value="[[shareTitile]]">
</div>
</div>
<div class="form-group">
... ... @@ -99,15 +99,15 @@
<div class="col-sm-8">
<textarea class="form-control observe" prompt="分享描述" data-field="shareDescribe" maxlength="100"
placeholder="分享描述" required style="resize: none">[[shareDescribe]]</textarea>
placeholder="分享描述" style="resize: none">[[shareDescribe]]</textarea>
</div>
</div>
<div class="form-group">
<div class="form-group" id="couponImage">
<label class="col-sm-2 control-label">分享图片</label>
<div class="col-sm-8">
<input type="file" placeholder="背景图片" class="form-control observe number" data-field="sharePic"
required value="[[sharePic]]">
<input type="file" value="[[sharePic]]" class="form-control obsserve" id="sharePic" data-field="sharePic" name="sharePic"
placeholder="分享图片" >
<p>支持jpg/png/gif,建议尺寸:640 x 1038,图片不是必选项</p>
</div>
</div>
<div class="form-group">
... ... @@ -115,39 +115,49 @@
<div class="col-sm-8">
<input type="text" placeholder="分享地址" class="form-control observe number" data-field="shareUrl"
required value="[[shareUrl]]">
value="[[shareUrl]]">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">是否授权</label>
<div class="col-sm-8">
<div class="col-sm-2 radio-inline"><input type="radio"class="form-control observe " data-field="isVerify"
required value="Y">
<label></label></div>
<div class="col-sm-2 radio-inline"><input type="radio"class="form-control observe " data-field="isVerify"
required value="N">
<label></label></div>
<label style="cursor: pointer;"><input type="radio" name="isVerify" value="Y" class="observe"></label>
<label style="cursor: pointer;"><input type="radio" name="isVerify" value="N" class="observe"></label>
</div>
<input type="hidden" id="isVerify" value="[[isVerify]]" for="radio" data-field="isVerify">
</div>
<div class="form-group">
<label class="col-sm-2 control-label">活动说明</label>
<div class="col-sm-8">
<textarea class="form-control observe" prompt="分享描述" data-field="instructions" maxlength="100"
placeholder="分享描述" required style="resize: none">[[instructions]]</textarea>
placeholder="分享描述" style="resize: none">[[instructions]]</textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">限制新老客户</label>
<div class="col-sm-8">
<input type="radio"class="form-control observe " data-field="isVerify"
required value=0>不限制
<input type="radio"class="form-control observe " data-field="isVerify"
required value=1>限制新用户
<label style="cursor: pointer;"><input type="radio" name="isNewUser" value="0" class="observe">不限制</label>
<label style="cursor: pointer;"><input type="radio" name="isNewUser" value="1" class="observe">限制新用户</label>
</div>
<input type="hidden" id="isNewUser" value="[[isNewUser]]" for="radio" data-field="isNewUser">
</div>
[[each couponIds as item index]]
<div class="form-group">
<label class="col-sm-2 control-label">优惠券</label>
<div class="col-sm-2">
<input type="text" id="couponId" class="form-control observe" value="[[item.id]]"
placeholder="ID" data-field="couponIds.[[index]].id">
</div>
<div class="col-sm-2">
<a class="col-sm-4 btn btn-primary addBtn" data-index="[[index]]">+</a>
<a class="col-sm-4 col-sm-offset-2 btn btn-danger delBtn" data-index="[[index]]">-</a>
</div>
</div>
[[/each]]
</div>
</div>
<div class="panel-footer">
... ...