Authored by liyalin

5.6 店铺装修基础模板

... ... @@ -23,6 +23,7 @@ module.exports = {
{name: "platform", type: "Number"},
{name: "appType", type: "Number"},
{name: "templateName", type: "String"},
{name: "templateType", type: "String"},
{name: "modules", type: "String"},
{name: "flag", type: "Number"}
]
... ...
... ... @@ -30,6 +30,11 @@
<img src="/static/assets/images/decorator/app-product-list.png" alt="#">
</div>
[[/if]]
[[if item.moduleType == 'ProductListImg']]
<div class="app-product-list" non-delete="true" non-added="true" data-type="ProductListImg" data-title="编辑商品列表模块" data-index="[[index]]">
<img src="/static/assets/images/decorator/app-product-list.png" alt="#">
</div>
[[/if]]
[[/each]]
<div id="app-dragable"> <!-- 可拖拽的模块区域 -->
... ... @@ -186,9 +191,11 @@
</div>
<!-- 增加模块区域 -->
[[if templateType == '2']]
<div class="btn add-modular-area" title="添加模块" style="[[data.length > 1 ? 'margin-top: -5px;': '']]">
<span class="glyphicon glyphicon-plus" style="top: -4px;"></span>
</div>
[[/if]]
</div>
</script>
... ...
... ... @@ -147,11 +147,18 @@
[[/if]]
</div>
[[/if]]
[[if item.moduleType == 'ProductListImg']]
<div class="recommend-product" non-delete="true" non-added="true" data-type="ProductListImg" data-title="编辑推荐商品模块" data-index="[[index]]">
<img src="/static/assets/images/decorator/pc-product-list.png" alt="#" class="logo">
</div>
[[/if]]
[[/each]]
</div>
[[if templateType == '2']]
<div class="btn add-modular-area" title="添加模块" data-style-area="2">
<span class="glyphicon glyphicon-plus" style="top: -4px;"></span>
</div>
[[/if]]
</div>
</div>
</script>
\ No newline at end of file
... ...
/**
* Created by wangqianjun on 16/3/22.
*/
'use strict';
var $ = require('jquery'),
common = require('../../../common/common');
var g = new common.grid({
el: '#color-list',
columns: [
{display: "ID", name: "uid"},
{display: "作者", name: "username"},
{display: "描述", name: "authorDesc"},
{display: "作者头像", name: "colorValue", render: function (item) {
item.avatar = common.util.__template(item.avatar,{mode:2,width:100,height:100});
return '<img style="width:40px; height:40px" src="'+item.avatar+'"/>';
}},
{display: "名下文章", name: "articleCount"},
{
display: '操作',
//}
name: "status",
render: function (items) {
var HtmArr = [];
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-primary btn-xs info-modify">编辑</a>');
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs info-del">删除</a>');
return HtmArr.join('');
}
}
]
});
g.init('/guang/author/getList');
//==================== 按钮点击事件 =====================//
//添加
$(document).on('click', '#add-btn', function() {
articleCategoryOP("新增", '/guang/author/addAuthor', {});
});
//编辑
$(document).on('click', '.info-modify', function() {
var item = g.rows[$(this).data("index")];
articleCategoryOP("修改", '/guang/author/updateAuthor', item);
});
//删除
$(document).on('click', '.info-del', function() {
var item = g.rows[$(this).data("index")];
common.dialog.confirm("温馨提示","确定要删除该作者?" , function() {
common.util.__ajax({
url: '/guang/author/delAuthor',
data: {
uid: item.uid,
}
}, function(res) {
if (res.code == 200) {
g.reload();
} else {
common.util.__tip(res.message);
}
});
});
});
function articleCategoryOP(prefix, url, item) {
var a =new common.edit(".confirm", {
"bucket" : "author"
});
common.dialog.confirm(prefix+'作者', common.util.__template2($("#template").html(), item), function () {
//
return a.submit(url,function(option){
option.success=function(res){
if(res.code=="200"){
a.$tip("提交成功", function() {
g.reload();
}, 'growl-success');
}else{
a.$tip(res.message);
}
return false;
},
option.error=function(res){
a.$tip(res.message);
}
});
});
a.init();
}
\ No newline at end of file
/**
* Created by wangqianjun on 16/3/22.
*/
var $ = require('jquery');
common = require('../../../common/common');
datepicker = require('../../../common/util/datepicker');
var ENUM = {
GenderEnum: {
'1': '男',
'2': '女',
'3': '通用'
},
StatusEnum: {
'-1': '已关闭',
0: '未发布',
1: '已发布'
},
BLKEnum: {
0: '否',
1: '是'
}
};
//下拉框
new common.dropDown({
el: "#articleGender"
});
new common.dropDown({
el: "#authorId",
ajax: 'guangGetAuthorList'
});
new common.dropDown({
el: "#maxSortId",
ajax: 'guangGetSortList'
});
new common.dropDown({
el: "#status"
});
new common.dropDown({
el: '#orderBy'
});
//日期插件
$('.hasDatepicker').fdatepicker({
format: 'yyyy-mm-dd'
});
var Timmer = {
toast: function (content, fn) {
common.dialog.confirm("定时发布", content, function () {
//console.log("fn()",fn());
common.util.__ajax({
url: '/guang/article/timmer',
data: fn()
}, function (res) {
if (res.code == '200') {
g.reload();
}
});
});
}
};
var g = new common.grid({
el: '#basicTable',
size: 10,
parms: function () {
return {
articleTitle: common.util.__input('articleTitle'),
articleGender: common.util.__input('articleGender'),
authorId: common.util.__input('authorId'),
maxSortId: common.util.__input('maxSortId'),
status: $('#status').val(),//common.util.__input('status'),
orderBy: common.util.__input('orderBy'),
startTime: common.util.__input('starttime'),
endTime: common.util.__input('endtime'),
appType: common.util.__input('appType')
};
},
columns: [{
display: 'ID',
name: "id"
}, {
display: "缩略图",
render: function (item) {
item.coverImage = common.util.__template(item.coverImage, {mode: 2, width: 100, height: 100});
return '<img src="' + item.coverImage + '" width="100" />'
}
}, {
display: '文章标题',
//name: "articleTitle",
width: '15%',
render: function (item) {
return '<span class="text-overflow"">' + item.articleTitle + '</span>'
}
}, {
display: '分类',
name: "maxSortName"
}, {
display: '性别',
render: function (item) {
return "<p>" + ENUM.GenderEnum[item.articleGender] + "</p>";
}
}, {
display: '作者',
name: "authorName"
}, {
display: '状态',
render: function (item) {
var sta = ENUM.StatusEnum[item.status];
if(item.status == 1 && common.util.__compareDate(Date.now(), item.publishTime * 1000)) {
//检查是否为定时发布,当未到达所设定时间时,即使status为1,也显示‘未发布’
sta = "未发布";
} else {
}
return "<p>" + sta + "</p>";
}
}, {
display: "创建时间",
render: function (item) {
if (item.createTime && item.createTime !== 0) {
var t = new Date(item.createTime * 1000);
var formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm");
return "<p>" + formatted + "</p>";
}
else {
return "";
}
}
}, {
display: "发布时间",
render: function (item) {
//console.log(item.publishTime);
if (item.publishTime && item.publishTime !== 0) {
var t = new Date(item.publishTime * 1000);
var formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm");
return "<p>" + formatted + "</p>";
}
else {
return "";
}
}
}, {
display: 'BLK',
render: function (item) {
return "<p>" + ENUM.BLKEnum[item.appType] + "</p>";
}
},{
display: '操作',
//}
name: "status",
render: function (items) {
var HtmArr = [];
HtmArr.push('<a data-index="' + items.__index + '" href="/guang/article/contentEdit/' + items.id + '" class="btn btn-info btn-xs info-modify">编辑</a>');
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-primary btn-xs info-time">定时</a>');
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs info-del">删除</a>');
if (items.status == 1) {
if(common.util.__compareDate(Date.now(), items.publishTime * 1000)) {
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-success btn-xs info-open">发布</a>');
} else {
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-warning btn-xs info-close">关闭</a>');
}
} else {
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-success btn-xs info-open">发布</a>');
}
if (items.isRecommend == 1) {
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-warning btn-xs info-recommend-cancel">取消推荐</a>');
} else {
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-success btn-xs info-recommend">推荐</a>');
}
return HtmArr.join('');
}
}]
});
g.init('/guang/article/list');
//==================== 按钮点击事件 =====================//
$("#filter-btn").click(function () {
g.reload(1);
});
//关闭资讯
$(document).on('click', '.info-close', function () {
var item = g.rows[$(this).data("index")];
common.util.__ajax({
url: '/guang/article/operation',
data: {
id: item.id,
status: -1
}
}, function (res) {
if (res.code == 200) {
common.util.__tip('关闭资讯成功', 'success');
g.reload();
} else {
common.util.__tip(res.message);
}
}, true);
});
//打开资讯
$(document).on('click', '.info-open', function () {
var item = g.rows[$(this).data("index")];
common.util.__ajax({
url: '/guang/article/operation',
data: {
id: item.id,
status: 1
}
}, function (res) {
if (res.code == 200) {
common.util.__tip('开启资讯成功', 'success');
g.reload();
} else {
common.util.__tip(res.message);
}
}, true);
});
//推荐
$(document).on('click', '.info-recommend', function () {
var item = g.rows[$(this).data("index")];
common.util.__ajax({
url: '/guang/article/operation',
data: {
id: item.id,
isRecommend: 1
}
}, function (res) {
if (res.code == 200) {
common.util.__tip('成功推荐', 'success');
g.reload();
} else {
common.util.__tip(res.message);
}
}, true);
});
//取消推荐
$(document).on('click', '.info-recommend-cancel', function () {
var item = g.rows[$(this).data("index")];
common.util.__ajax({
url: '/guang/article/operation',
data: {
id: item.id,
isRecommend: 0
}
}, function (res) {
if (res.code == 200) {
common.util.__tip('成功取消推荐', 'success');
g.reload();
} else {
common.util.__tip(res.message);
}
}, true);
});
//定时
$(document).on("click", ".info-time", function () {
var item = g.rows[$(this).data("index")];
var item1= $.extend(true,{},item);
if(item.publishTime&&item.publishTime!=0){
var t = new Date(item.publishTime * 1000);
item1.publishTime= common.util.__dateFormat(t, "yyyy-MM-dd hh:mm");
}
else{
item1.publishTime="yyyy-MM-dd hh:mm"
}
var data = function () {
var dateString = common.util.__input('datepicker');
if (dateString === '' || $.trim(dateString) === '') {
return "请填写时间";
}
return {
publishTime: dateString,
id: item.id
};
};
Timmer.toast(common.util.__template2($("#template").html(), item1), data);
$('#datepicker').fdatepicker({
format: 'yyyy-mm-dd hh:ii',
pickTime: true
});
});
// 删除
$(document).on("click", ".info-del", function () {
var item = g.rows[$(this).data("index")];
common.dialog.confirm("温馨提示", "您确定要删除吗?", function () {
common.util.__ajax({
url: '/guang/article/del',
data: {
id: item.id
}
}, function () {
g.reload();
});
});
});
... ... @@ -5,14 +5,23 @@ var $ = require('jquery'),
base = require('./partials/Base');
// 默认系统模板
var systemTemplates =
var systemTemplates_1 =
{
shopId: 0,
templateName: '系统默认',
templateId: 1,
createTime: '2016-12-14 14:42:00'
templateName: '基础模板',
templateId: 3,
createTime: '2016-12-14 14:42:00',
templateType: '1',
};
var systemTemplates_2 =
{
shopId: 0,
templateName: '经典模板',
templateId: 1,
createTime: '2016-12-14 14:42:00',
templateType: '2',
};
var shopTemplates = [];
... ... @@ -43,6 +52,7 @@ var Bll = {
$.each(shopTemplates, function(_index, template) {
if(template.flag && template.flag === 1) {
index = _index;
Bll.templateType = template.templateType;
return;
}
});
... ... @@ -71,6 +81,14 @@ var Bll = {
// 切换模板、执行模块的删除、上下移等动作时,需要重新加载模板装修内容
// index: 重载模板前,操作的模块在列表中的索引,用于调整滚动条至操作模块的位置
reloadMain: function(index) {
var curTemplate = $('.selected-template').parent();
var selIndex = $(curTemplate).data('index');
$.each(shopTemplates, function(_index, template) {
if(_index === selIndex) {
Bll.templateType = template.templateType;
return;
}
});
if(+t.active) {
Bll.renderDecoratorPCTemplate();
} else {
... ... @@ -140,7 +158,8 @@ var Bll = {
template.createTime = common.util.__dateFormat(new Date(template.createTime * 1000), 'yyyy-MM-dd hh:mm:ss');
}
});
shopTemplates.unshift(systemTemplates);
shopTemplates.unshift(systemTemplates_2);
shopTemplates.unshift(systemTemplates_1);
}
}, true)
},
... ... @@ -152,7 +171,11 @@ var Bll = {
var index = $(curTemplate).data('index');
// index = 0:系统模板,默认数据即可,不查询
if(index == 0) {
Bll.moduleDataList = Bll.base.getDefaultModuleData(+t.active ? 0 : 1);
Bll.moduleDataList = Bll.base.getDefaultModuleData(+t.active ? 0 : 1, 0);
return;
}
if(index == 1) {
Bll.moduleDataList = Bll.base.getDefaultModuleData(+t.active ? 0 : 1, 1);
return;
}
... ... @@ -187,7 +210,7 @@ var Bll = {
},
renderDecoratorPCTemplate: function() {
$('.decorator-right').html(common.util.__template2($('#pc-template').html(), {data: Bll.moduleDataList}));
$('.decorator-right').html(common.util.__template2($('#pc-template').html(), {data: Bll.moduleDataList, templateType: Bll.templateType}));
new common.dragSort.create(document.getElementById('pc-dragable-975'), {
animation: 150
});
... ... @@ -197,7 +220,7 @@ var Bll = {
},
renderDecoratorAppTemplate: function() {
$('.decorator-right').html(common.util.__template2($('#app-template').html(), {data: Bll.moduleDataList}));
$('.decorator-right').html(common.util.__template2($('#app-template').html(), {data: Bll.moduleDataList, templateType: Bll.templateType}));
new common.dragSort.create(document.getElementById('app-dragable'), {
animation: 150,
... ... @@ -1526,7 +1549,7 @@ var handleDecoratorTemplate = function() {
}
// 这些模块可能没有模块数据,只是根据标识去渲染。如果检测到没有数据,增加默认数据
let noDataModuleArray = ['ProductList', 'ShopNavbar', 'ProductSort'];
let noDataModuleArray = ['ProductList', 'ShopNavbar', 'ProductSort', "ProductListImg"];
$.each(Bll.moduleDataList, function(index, module) {
// 根据模块的排序,重新生成order
... ... @@ -1597,6 +1620,7 @@ var saveTemplate = function(flag, name, cb) {
platform: +t.active ? 0 : 1,
appType: Bll.appType,
templateName: name,
templateType: Bll.templateType,
modules: JSON.stringify(Bll.moduleDataList),
flag: flag
}
... ...
... ... @@ -111,6 +111,17 @@ base.prototype = {
}
],
defaultModuleDataBase: [
{
dataValid: false, // 系统模板,默认只包含模块信息,并不包含模块内容;新增的模块,也不包含模块内容。默认数据是非法的
moduleType: "ShopBanner",
},
{
dataValid: false,
moduleType: "ProductListImg",
}
],
/**
* 根据模块区域获取可添加的模块列表信息
* styleArea: 模块区域标识,0--APP端,1--PC端160区域,2--PC端975区域
... ... @@ -136,7 +147,11 @@ base.prototype = {
return statusDesc;
},
getDefaultModuleData: function(platform) {
getDefaultModuleData: function(platform, index) {
if (index == 0) {
let temp = JSON.stringify(this.defaultModuleDataBase);
return JSON.parse(temp);
} else {
if(platform === 0) {
// PC端
let temp = JSON.stringify(this.defaultModuleData);
... ... @@ -146,6 +161,7 @@ base.prototype = {
return JSON.parse(temp);
}
}
}
}
module.exports = base;
\ No newline at end of file
... ...