Authored by weiqingting

Merge branch 'release/1.6' of http://git.dev.yoho.cn/platform/yohobuy-portal-fe into release/1.6

/**
* Created by JiangMin on 2016/4/19.
*/
var $ = require('jquery');
var common = require('../common/common');
var $ = require('jquery'),
common = require('../common/common');
/**
* 列表显示数据
* @type {common.grid}
... ... @@ -19,29 +19,41 @@ var g = new common.grid({
//列表显示
columns: [
{
display: "创建时间", name: "createTime"
display: "创建时间",
name: "createTime"
},
{display: "发券名称", name: "name"},
{display: "优惠券ID", name: "couponsIds",render:function(item){
var couponsIds=[];
for(var i=0;i<item.couponsIds.length;i++){
couponsIds.push(item.couponsIds[i].id);
{
display: "发券名称",
name: "name"
},
{
display: "优惠券ID",
name: "couponsIds",
render: function (item) {
var couponsIds = [];
for (var i = 0; i < item.couponsIds.length; i++) {
couponsIds.push(item.couponsIds[i].id);
}
return couponsIds.join(",");
}
return couponsIds.join(",");
}},
},
{
display: "token值", name: "couponSendToken", render: function (item) {
return '<div class="col-sm-12"><input class="col-sm-10" style="border: 0px" id="couponSendToken' + item.__index + '" value="' + item.couponSendToken + '" readonly/>' +
'<input class="col-sm-2 btn couponSendToken" value="复制" data-index="' + item.__index + '"/></div>'
}
display: "token值",
name: "couponSendToken",
render: function (item) {
return '<div class="col-sm-12"><input class="col-sm-10" style="border: 0px" id="couponSendToken' + item.__index + '" value="' + item.couponSendToken + '" readonly/>' +
'<input class="col-sm-2 btn couponSendToken" value="复制" data-index="' + item.__index + '"/></div>'
}
},
{
display: "操作", name: "", render: function (item) {
var arr = [];
arr.push('<a class="btn btn-info update" data-index="' + item.__index + '">编辑</a>');
arr.push('<a class="btn btn-danger delete" data-index="' + item.__index + '">删除</a>');
return arr.join('');
}
display: "操作",
name: "",
render: function (item) {
var arr = [];
arr.push('<a class="btn btn-info update" data-index="' + item.__index + '">编辑</a>');
arr.push('<a class="btn btn-danger delete" data-index="' + item.__index + '">删除</a>');
return arr.join('');
}
}
]
});
... ... @@ -54,6 +66,7 @@ var Bll = {
__render: function (selecter, templater, data) {
$(selecter).html(common.util.__template2($("#" + templater).html(), data));
},
//弹框
toast: function (module, hint) {
Bll.module = module;
var d = new common.dialog({
... ... @@ -75,7 +88,6 @@ var Bll = {
} else {
Bll.module.couponsIds = ids.join(",");
}
//console.log("最终上传数据Bll.module",Bll.module);
if (edit.validate() && flag) {
common.util.__ajax({
url: "/couponSendManager/addOrUpdate",
... ... @@ -109,19 +121,22 @@ var Bll = {
});
}
};
/*监听输入框变化*/
/**
* 监听输入框变化
*/
$(document).on("change", ".observe", function () {
var $this = $(this);
var name = $this.data("field") ? $this.data("field") : $this.data("name");
var name = $this.data("field");
Bll.module = common.util.__buildobj(name, '.', Bll.module, function (obj, name1) {
if (name.indexOf('id') > -1) {
obj[name1] = $this.val();
obj["text"] = $this.find("option[value='" + $this.val() + "']").text();
obj["text"] = $this.find("option[value='" + $this.val() + "']").text();
}
obj[name1] = $this.val();
});
//console.log(" 监听值变化Bll.module", Bll.module);
});
/*添加一行*/
$(document).on("click", ".addBtn", function () {
Bll.module.couponsIds.push({
... ... @@ -130,13 +145,19 @@ $(document).on("click", ".addBtn", function () {
});
Bll.renderDialog("template");
});
/*删除行*/
/**
* 删除行
*/
$(document).on("click", ".delBtn", function () {
var index = $(this).data("index");
Bll.module.couponsIds.splice(index, 1);
Bll.renderDialog("template");
});
//添加--点击事件
/**
* 添加--点击事件
*/
$('#add-content').on('click', function () {
var item = {
"id": "",
... ... @@ -151,7 +172,10 @@ $('#add-content').on('click', function () {
};
Bll.toast(item, "添加");
});
//编辑--点击事件
/**
* 编辑--点击事件
*/
$(document).on('click', '.update', function () {
var item = g.rows[$(this).data("index")];
var item1 = {
... ... @@ -162,7 +186,10 @@ $(document).on('click', '.update', function () {
};
Bll.toast(item1, "修改");
});
//删除--点击事件
/**
* 删除--点击事件
*/
$(document).on('click', '.delete', function () {
var item = g.rows[$(this).data("index")];
common.dialog.confirm("警告",
... ... @@ -179,11 +206,17 @@ $(document).on('click', '.delete', function () {
});
});
});
//查询按钮--点击事件
/**
* 查询按钮--点击事件
*/
$(document).on('click', '#filter-btn', function () {
g.reload(1);
});
//复制token点击事件
/**
* 复制token点击事件
*/
$(document).on('click', '.couponSendToken', function () {
var index = $(this).data("index");
var id = "couponSendToken" + index;
... ... @@ -192,12 +225,16 @@ $(document).on('click', '.couponSendToken', function () {
document.execCommand("Copy"); // 执行浏览器复制命令
common.util.__tip("Token链接已复制好,可贴粘", "success")
});
//查看token使用方法
/**
* 查看token使用方法
*/
$(document).on('click', '#token', function () {
var a = new common.dialog({
title: "<h4>token使用方法</h4>",
width: '50%',
content: '<p>活动开发人员使用Token时,按照对应格式写在页面中,示例代码:</p>&lt;a class="yoho-conpon" href="javascript:;" data-token="29-6ea9ab1baa0efb9e19094440c317e21b"&gt;领券按钮&lt;/a&gt;<h5>注:必须引入 JS 插件</h5>'
content: '<p>活动开发人员使用Token时,按照对应格式写在页面中,示例代码:</p>&lt;a class="yoho-conpon" ' +
'href="javascript:;" data-token="29-6ea9ab1baa0efb9e19094440c317e21b"&gt;领券按钮&lt;/a&gt;<h5>注:必须引入 JS 插件</h5>'
});
});
... ...
... ... @@ -527,12 +527,13 @@ $(document).on("click", ".removepic", function () {
var isg = typeof(i) === "number" ? true : false;
//推荐商品组
if (isg) {
Bll.module.contentData.data[i].list.splice($(this).data("index"), 1);
Bll.module.contentData.data[i].cover = {};
if (Bll.module.contentData.data[i].list.length == 0) {
Bll.module.contentData.data.splice(i, 1);
Bll.module.contentData.data[i].cover.cover = "";
Bll.module.contentData.data[i].cover.maxSortId = "";
}
else{
Bll.module.contentData.data[i].list.splice($(this).data("index"), 1);
Bll.module.contentData.data[i].cover = {};
else {
Bll.module.contentData.data[i].cover.cover = Bll.module.contentData.data[i].list[0].src;
Bll.module.contentData.data[i].cover.maxSortId = Bll.module.contentData.data[i].list[0].maxSortId;
}
... ...
... ... @@ -96,7 +96,6 @@ var Bll = {
Bll.module.contentData.data = common.util.__buildobj(names, '.', Bll.module.contentData.data, function (o, name) {
o[name] = obj.data;
});
console.log(Bll.module.contentData.data);
});
},
//获取品牌
... ... @@ -245,9 +244,7 @@ $(document).on("click", ".del", function () {//删除
/*编辑*/
$(document).on("click", ".edit", function () {
var index = $(this).data("index");
console.log("index",index);
var item = Bll.contentDatas[index];
console.log("item",item);
Bll.module = $.extend(true, {}, item);
Bll.toast(index, Bll.module);
});
... ... @@ -425,7 +422,6 @@ $(document).on("click", "#sub_btn", function () {
data.rId = param;
data.content = JSON.stringify(data.content);
data.data_id = JSON.stringify(data.data_id);
//console.log("最终保存data",data);
common.util.__ajax({
url: "/resources/addResContent",
data: data
... ... @@ -571,16 +567,15 @@ $(document).on("click", ".removepic", function () {
var $parent = $(this).parents("ul.imagegroup");
var i = $parent.data("i");//组标志
var isg = typeof(i) === "number" ? true : false;
//console.log("i",i,"isg",isg);
//推荐商品组
if (isg) {
//console.log(Bll.module.contentData.data[i]);
Bll.module.contentData.data[i].list.splice($(this).data("index"), 1);
Bll.module.contentData.data[i].cover = {};
if (Bll.module.contentData.data[i].list.length == 0) {
Bll.module.contentData.data.splice(i, 1);
}else{
//console.log("222");
Bll.module.contentData.data[i].list.splice($(this).data("index"), 1);
Bll.module.contentData.data[i].cover = {};
Bll.module.contentData.data[i].cover.cover = "";
Bll.module.contentData.data[i].cover.maxSortId = "";
}
else {
Bll.module.contentData.data[i].cover.cover = Bll.module.contentData.data[i].list[0].src;
Bll.module.contentData.data[i].cover.maxSortId = Bll.module.contentData.data[i].list[0].maxSortId;
}
... ...
... ... @@ -197,7 +197,7 @@ function editorIconEvent(title,id){
function findDecoration(){
common.util.__ajax(
{
url:'/store/shop-decoration-find',
url:'/shop/ShopsDecoratorRest/findShopsDecoratorDetail',
data: {
"shopsId": shopsId
}
... ... @@ -244,7 +244,7 @@ function findDecoration(){
//Ajax最新上架商品
function findTopNewProducts(){
common.util.__ajax({
url:'/store/shop-decoration-newProducts',
url:'/shop/ShopsDecoratorRest/findNewProductList',
data: {
"shopsId": jsonMain.shopsId,
"size": 20
... ... @@ -258,7 +258,7 @@ function findTopNewProducts(){
//Ajax热销商品
function findTopHotProducts(){
common.util.__ajax({
url:'/store/shop-decoration-hotProducts',
url:'/shop/ShopsDecoratorRest/findHotProductList',
data: {
"shopsId": jsonMain.shopsId,
"size": 20
... ... @@ -272,7 +272,7 @@ function findTopHotProducts(){
//Ajax热销商品---APP
function findTopHotProducts_APP(){
common.util.__ajax({
url:'/store/shop-decoration-hotProducts',
url:'/shop/ShopsDecoratorRest/findHotProductList',
data: {
"shopsId": jsonMain.shopsId,
"size": 20
... ... @@ -287,7 +287,7 @@ function findTopHotProducts_APP(){
function saveDecoration(submitStatus){
console.log(jsonMain);
common.util.__ajax({
url:'/store/shop-decoration-save',
url:'/shop/ShopsDecoratorRest/saveShopsDecorator',
data: {
"submitStatus": submitStatus,
"shopsId": jsonMain.shopsId,
... ... @@ -313,7 +313,7 @@ function saveDecoration(submitStatus){
function checkDecoration(checkStatus,comment){
if(comment){ //驳回
common.util.__ajax({
url:'/store/shop-decoration-check',
url:'/shop/ShopsDecoratorRest/auditShopsDecorator',
data: {
"id": _id,
"checkStatus": checkStatus,
... ... @@ -327,7 +327,7 @@ function checkDecoration(checkStatus,comment){
},true);
}else{ //通过
common.util.__ajax({
url:'/store/shop-decoration-check',
url:'/shop/ShopsDecoratorRest/auditShopsDecorator',
data: {
"id": _id,
"checkStatus": checkStatus
... ...
... ... @@ -10,7 +10,7 @@ exports.res = [
src:'/store/shop'
},
{//保存装修模板,提交审核模板
route:"/store/shop-decoration-save",
route:"/shop/ShopsDecoratorRest/saveShopsDecorator",
method:"POST",
url:"/ShopsDecoratorRest/saveShopsDecorator",
params:[
... ... @@ -22,7 +22,7 @@ exports.res = [
]
},
{//查询装修模板内容
route:"/store/shop-decoration-find",
route:"/shop/ShopsDecoratorRest/findShopsDecoratorDetail",
method:"POST",
url:"/ShopsDecoratorRest/findShopsDecoratorDetail",
params:[
... ... @@ -30,7 +30,7 @@ exports.res = [
]
},
{//审核
route:"/store/shop-decoration-check",
route:"/shop/ShopsDecoratorRest/auditShopsDecorator",
method:"POST",
url:"/ShopsDecoratorRest/auditShopsDecorator",
params:[
... ... @@ -39,16 +39,8 @@ exports.res = [
{name: 'comment', type: 'String'}
]
},
{//查询店铺品牌
route:"/store/shop-decoration-brands",
method:"POST",
url:"/ShopsDecoratorRest/findBrandsByShopsId",
params:[
{name: 'shopsId', type: 'Number'}
]
},
{//最新上架的商品
route:"/store/shop-decoration-newProducts",
route:"/shop/ShopsDecoratorRest/findNewProductList",
method:"POST",
url:"/ShopsDecoratorRest/findNewProductList",
params:[
... ... @@ -57,7 +49,7 @@ exports.res = [
]
},
{//热销商品
route:"/store/shop-decoration-hotProducts",
route:"/shop/ShopsDecoratorRest/findHotProductList",
method:"POST",
url:"/ShopsDecoratorRest/findHotProductList",
params:[
... ... @@ -65,7 +57,7 @@ exports.res = [
{name: 'size', type: 'Number'}
]
},
{/*店铺审核装修*/
{/*店铺装修审核*/
route:'/supplier/store/ajax/shenhezx',
method:'POST',
url:'/ShopsDecoratorRest/findAuditShopsDecorator',
... ...
... ... @@ -32,7 +32,7 @@
</div>
<a id="filter-btn" href="javascript:;" class="btn btn-info">查询</a>
<a id="filter-all" href="/couponSendManager/queryList" class="btn btn-info">全部</a>
<a class="btn pull-right" id="token" href="javascript:;" style="color: red">查看token使用方法>></a>
<a class="btn pull-right" id="token" href="javascript:;" style="color: red">查看token使用方法>></a>
</div>
</div>
</div>
... ... @@ -45,15 +45,17 @@
<label class="col-sm-2 control-label">发券名称</label>
<div class="col-sm-10">
<input type="text" value="[[name]]" class="form-control observe" data-name="name" data-field="[[name]]" placeholder="发券名称" required="required"/>
<input type="text" value="[[name]]" class="form-control observe" data-field="name" placeholder="发券名称"
required="required"/>
</div>
</div>
[[each couponsIds as item index]]
<div class="form-group">
<label class="col-sm-2 control-label" >优惠券ID</label>
<label class="col-sm-2 control-label">优惠券ID</label>
<div class="col-sm-7">
<select name="couponsIds" class="col-sm-10 observe select2-offscreen couponsIds" data-field="couponsIds.[[index]].id" data-index="[[index]]">
<select name="couponsIds" class="col-sm-10 observe select2-offscreen couponsIds"
data-field="couponsIds.[[index]].id" data-index="[[index]]">
<option value='[[item.id]]'>[[item.text||item.id||'请选择优惠券ID']]</option>
</select>
</div>
... ...
... ... @@ -324,6 +324,7 @@
</div>
[[/each]]
</div>
[[each module.contentData.data[0].list as item index]]
<div class="col-sm-6">
<img src="[[item.src]]" title="[[item.id]]">
... ... @@ -503,6 +504,7 @@
</div>
</div>
</script>
<script type="text/template" id="template_dialog_remgoodsgroup">
... ...