Authored by zhaoqing

店铺定时发布

... ... @@ -29,5 +29,8 @@ module.exports = function(app) {
// 更新装修模板
app.post("/shop/ModularDecoratorRest/updateDecoratorTemplate", "modularDecorator_updateDecoratorTemplate");
// 修改定时任务值
app.post("/shop/ModularDecoratorRest/updatePublishTimeTask", "modularDecorator_updatePublishTimeTask");
}
... ...
... ... @@ -69,6 +69,15 @@ module.exports = {
{name: "templateName", type: "String"},
{name: "modules", type: "String"}
]
},
updatePublishTimeTask: {
title: "更新店铺模板",
url: "/newShopsDecoratorRest/updatePublishTimeTask",
params: [
{name: "templateId", type: "Number"},
{name: "publishTime", type: "Number"},
{name: "timeTaskFlag", type: "Number"}
]
}
}
}
\ No newline at end of file
... ...
... ... @@ -29,7 +29,17 @@
<div class="navbar-header navbar-right navbar-decorator-right">
<span class="shop-name">MADNESS</span>
<a href="javascript:;" class="btn btn-success" id="publishBtn">发布</a>
<div class="btn-group dropdown" style="margin-bottom: 0px">
<button style="width: 120px" class="btn btn-success dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
发布
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1" style="width: 120px;">
<li><a href="javascript:;" class="btn btn-primary" style="margin-left: 2px;" id="publishBtn">立即发布</a></li>
<li><a href="javascript:;" class="btn btn-info" style="margin-left: 2px;" id="timePublishBtn">定时发布</a></li>
<li><a href="javascript:;" class="btn btn-danger" style="margin-left: 2px; padding-left: 10px;" id="removePublishBtn">取消定时发布</a></li>
</ul>
</div>
<a href="javascript:;" class="btn btn-danger" id="quitBtn">退出</a>
</div>
</div>
... ... @@ -44,10 +54,10 @@
<div class="left-footer">
<div class="btn-group save-btn">
<div class="btn-group dropup" style="margin-left:40px">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<button style="width: 100px" type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
存储 <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<ul class="dropdown-menu" role="menu" style="width: 100px;">
<li><a href="javascript:;" class="btn btn-primary" id="updateBtn">保存</a></li>
<li><a href="javascript:;" class="btn btn-info" id="saveBtn">另存为</a></li>
</ul>
... ... @@ -91,7 +101,13 @@
<p class="title">备份模板: </p>
[[each data as item _index]]
[[if item.shopId != 0]]
<div class="decorator-template" data-index=[[_index]] data-id=[[item.templateId]]>
<div class="decorator-template" data-index=[[_index]] data-id=[[item.templateId]] data-status=[[item.status]] data-timeTaskFlag=[[item.timeTaskFlag]]>
[[if item.timeTaskFlag == 2]]
<div class="create-time">
定时发布时间:</br>
[[item.publishTime]]
</div>
[[/if]]
[[if _index == index]]
<div class="selected-template">
[[else]]
... ...
... ... @@ -324,4 +324,12 @@
<!-- 此处的id要与radioname一致,用于初始化数据绑定 -->
<input type="hidden" value="[[displayType||1]]" id="displayType" for="radio" required/>
</div>
</script>
<!-- 模态框(Modal) -->
<script type="text/template" id="timePushDialog">
<input type="text" class="form-control observe" data-field="publishTime" id="publishTime"
placeholder="模板发布时间" >
<div style="margin-top: 15px;color: grey;"><span style="color: red">*</span> 同一店铺的模板,不能设置相同的定时发布时间</div>
</script>
\ No newline at end of file
... ...
... ... @@ -57,6 +57,8 @@ var Bll = {
$.each(shopTemplates, function(_index, template) {
if(defaltFlag){
if(template.status == 2){
$("#timePublishBtn").hide();
$("#removePublishBtn").hide();
defaltFlag = false;
index = _index;
Bll.templateType = template.templateType;
... ... @@ -89,6 +91,7 @@ var Bll = {
Bll.validator = new validator({
shopId: Bll.shopId
});
},
// 切换模板、执行模块的删除、上下移等动作时,需要重新加载模板装修内容
... ... @@ -2006,6 +2009,17 @@ var publishDecoratorTemplate = function() {
// 点击"应用",切换模板
var switchTemplate = function() {
var curTemplate = $('.selected-template').parent();
var status = $(curTemplate).data('status');
var isSystemTemplate = $(curTemplate).data('is-system-template');
if(isSystemTemplate && +isSystemTemplate == 1 || +status == 2) {
$("#timePublishBtn").hide();
$("#removePublishBtn").hide();
}else {
$("#timePublishBtn").show();
$("#removePublishBtn").show();
}
if(Bll.changedModuleMonitor > 0) {
common.dialog.confirm('温馨提示', '装修内容有更新,是否保存为模板?',
function() {
... ... @@ -2425,4 +2439,43 @@ $(document).on('change', '.observe', function() {
let value = +$(this).val();
Bll.recommendProduct[prop] = value;
});
\ No newline at end of file
});
$(document).on('click', '#timePublishBtn', function() {
new common.dialog({
title: "设置模板定时发布时间",
width: "400px",
content: common.util.__template2($("#timePushDialog").html()),
button: [
{
value: "确认", css:"btn-primary",
callback: function () {
var curTemplate = $('.selected-template').parent();
var templateId = $(curTemplate).data('id');
var publishTime = $("#publishTime").val();
common.util.__ajax({
url: '/shop/ModularDecoratorRest/updatePublishTimeTask',
data: {
templateId: templateId,
publishTime: publishTime,
timeTaskFlag: 2
}
}, function () {
if (res.code == 200) {
} else {
common.util.__tip(res.message);
}
});
}
},
{
"value": "取消",
"css": "btn-info"
}
]
});
$("#publishTime").datetimepicker({
timeFormat: 'HH:mm:ss',
showSecond: true
}).data("datepicker");
});
... ...