Authored by 陶雨

活动分享管理

/**
* Created by ty on 2016/7/6.
* 活动分享管理
*/
module.exports = function (app) {
/*活动分享管理首页*/
app.get("/operations/webshare/index", "operations.webshare.Index", function () {
this.$extend = {
moduleName: "活动分享管理",
pageName: "活动分享列表管理"
}
});
/*添加活动分享页面*/
app.get("/operations/webshare/add", "operations.webshare.Edit", function () {
this.$extend = {
moduleName: "活动分享管理",
pageName: "添加活动分享",
url: "/webShare/addWebShare"
}
});
/*编辑活动分享*/
app.get("/operations/webshare/edit/:id", "operations.webshare.Edit", function (req) {
this.$extend = {
moduleName: "活动分享管理",
pageName: "编辑活动分享",
id: req.params.id,
url: "/webShare/updateWebShare"
}
});
/*首页列表*/
app.post("/webShare/getWebShareList", "webshare_getWebShareList");
/*新增活动分享 [注意在shareImage加上客户端需要的imageView参数]*/
app.post("/webShare/addWebShare", "webshare_addWebShare");
/*更新活动分享*/
app.post("/webShare/updateWebShare", "webshare_updateWebShare");
/*根据id查询数据*/
app.post("/webShare/selectWebShare", "webshare_selectWebShare");
}
\ No newline at end of file
... ...
/**
* Created by ty on 2016/7/6.
* 活动分享管理
*/
module.exports = {
namespace: "webshare",
apis: {
getWebShareList: {
title: "活动分享列表",
url: "/webShare/getWebShareList",
params: [
{name: "id", type: "number"},
{name: "status", type: "string"},
{name: "title", type: "string"},
{name: "page", type: "number"},
{name: "size", type: "number", default: 20}
]
},
addWebShare: {
title: "新增活动分享",
url: "/webShare/addWebShare",
params: [
{name: "title", type: "string"},
{name: "shareTitleMain", type: "string"},
{name: "shareTitleSub", type: "string"},
{name: "shareImage", type: "string"},
{name: "shareUrl", type: "string"},
{name: "status", type: "string"}
]
},
updateWebShare: {
title: "更新活动分享",
url: "/webShare/updateWebShare",
params: [
{name: "id", type: "number"},
{name: "title", type: "string"},
{name: "shareTitleMain", type: "string"},
{name: "shareTitleSub", type: "string"},
{name: "shareImage", type: "string"},
{name: "shareUrl", type: "string"},
{name: "status", type: "string"}
]
},
selectWebShare: {
title: "根据id查询数据",
url: "/webShare/selectWebShare",
params: [
{name: "id", type: "number"}
]
}
}
}
... ...
<%include '../../../common/views/__ui/header'%>
<%include '../../../common/views/__partail/ListHeader'%>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title"><%pageName%></h4>
</div><!-- panel-heading -->
<div class="panel-body">
<div class="row" id="edit-content" data-id="<%id%>" url="<%url%>">
</div><!-- row -->
</div><!-- panel-body -->
<div class="panel-footer">
<div class="row">
<div class="col-sm-9 col-sm-offset-3">
<a id="save_btn" class="btn btn-primary mr5">保存</a>
<a href="/operations/webshare/index" class="btn btn-primary mr5">取消</a>
</div>
</div>
</div><!-- panel-footer -->
</div>
<script type="text/template" id="edit-template">
<div class="form-group">
<label class="col-sm-1 control-label">分享名称</label>
<div class="col-sm-9">
<input type="text" name="title" class="form-control observe" placeholder="活动分享名称" required="" value="[[title]]" data-field="title">
<p style="color:#999">注:分享名称必填</p>
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label">分享主标题</label>
<div class="col-sm-9">
<input type="text" name="share_title_main" class="form-control observe" placeholder="分享主标题" value="[[shareTitleMain]]" data-field="shareTitleMain">
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label">分享副标题</label>
<div class="col-sm-9">
<input type="text" name="share_title_sub" class="form-control observe" placeholder="分享副标题" value="[[shareTitleSub]]" data-field="shareTitleSub">
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label">分享图片</label>
<div class="col-sm-9">
<input type="file" name="shareImage" data-field="shareImage" value="[[shareImage]]" />
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label">跳转链接</label>
<div class="col-sm-9">
<input type="text" name="share_url" class="form-control observe" placeholder="跳转链接" required="" value="[[shareUrl]]" data-field="shareUrl">
<p style="color:#999">注:必填,链接中不能有英文单引号</p>
</div>
</div><!-- form-group -->
<div class="form-group" hidden id="choose-status">
<label class="col-sm-1 control-label">状态</label>
<div class="col-sm-9">
<select name="status" id="status" style="width:120px;" tabindex="-1" value="[[status]]" class="form-control observe" data-field="status">
<option value="">选择状态</option>
<option value="0">关闭</option>
<option value="1">开启</option>
</select>
</div>
</div>
</script>
\ No newline at end of file
... ...
<%include '../../../common/views/__ui/header'%>
<%include '../../../common/views/__partail/ListHeader'%>
<div class="contentpanel">
<div class="panel panel-default" style="margin-bottom:10px;">
<div class="panel-heading">
<div id="basicForm" class="form-horizontal form-bordered form-inline" data-id="<%id%>">
<div class="form-group">
<a href="/operations/webshare/add" class="btn btn-info btn-xs">添加活动分享</a>
</div>
</div>
</div>
<div class="panel-body" id="condition">
<div class="panel-col">
<input type="text" class="form-control" name="product_skn" placeholder="分享id" id="shareId-filter">
</div>
<div class="panel-col">
<input type="text" class="form-control" name="product_skn" placeholder="标题" id="title-filter">
</div>
<div class="panel-col">
<select name="status" id="status-filter" tabindex="-1" class="form-control">
<option value="">选择状态</option>
<option value="0">关闭</option>
<option value="1">开启</option>
</select>
</div>
<a id="filter-btn" class="btn btn-info">筛选</a>
<a href="<%url%>" class="btn btn-info">全部</a>
</div>
</div>
<div class="panel panel-primary-head" id="content-list">
</div>
</div>
\ No newline at end of file
... ...
/**
* Created by ty on 2016/7/6.
* 活动分享编辑
*/
var $ = require('jquery'),
common = require('../../../common/common');
var id = $("#edit-content").data("id"),
url = $("#edit-content").attr("url"),
module = {},
edit = new common.edit2("#edit-content",{bucket: "taobaocms"});
if(id) {
common.util.__ajax({
async: false,
url: "/webShare/selectWebShare",
data: {id: id}
}, function (res) {
module = res.data;
},true);
}
$("#edit-content").html(common.util.__template2($("#edit-template").html(), module));
edit.init();
edit.on("file_onComplete", function (obj) {
module[obj.field] = obj.data;
});
if(id) {
$("#choose-status").show();
new common.dropDown({el: "#status"});
}
//监听数据变化
$(document).on("change", ".observe", function () {
module[$(this).data("field")] = $(this).val();
});
//保存数据
$(document).on("click", "#save_btn", function () {
if(edit.validate()) {
common.util.__ajax({
url: url,
data: module
}, function () {
setTimeout(function () {
location.href = "/operations/webshare/index";
},600);
});
}
});
\ No newline at end of file
... ...
/**
* Created by ty on 2016/7/6.
* 活动分享管理
*/
var $ = require('jquery'),
common = require('../../../common/common');
new common.dropDown({el:"#status-filter"});
var statusEnum = ["开启", "关闭"];
var g = new common.grid({
el: '#content-list',
parms: function () {
return {
id: common.util.__input("shareId-filter"),
status: common.util.__input("status-filter"),
title: common.util.__input("title-filter")
};
},
columns: [
{display: "ID", name: "id"},
{display: "标题", name: "title"},
{display: "分享主标题", name: "shareTitleMain"},
{display: "分享副标题", name: "shareTitleSub"},
{display: "分享图片", render: function (item) {
if(item.shareImage) {
var src = item.shareImage.replace("{mode}", "2").replace("{width}", "80").replace("{height}", "80");
return '<img src="'+ src +'" width="80px" height="80px" />';
}
}},
{display: "状态", render: function (item) {
if(item.status == 1) {
return "已开启";
} else {
return "已关闭";
}
}},
{display: "创建时间", render: function (item) {
return common.util.__dateFormat(new Date(item.createTime * 1000), "yyyy-MM-dd hh:mm:ss");
}},
{
display: '操作',
render: function (item) {
var HtmArr = [];
HtmArr.push('<a href="/operations/webshare/edit/'+ item.id +'" class="btn btn-primary btn-xs">编辑</a>');
HtmArr.push('<a data-index="'+ item.__index +'" class="btn btn-danger btn-xs auditStatus">'+ statusEnum[item.status] +'</a>');
return HtmArr.join('');
}
}
]
});
g.init("/webShare/getWebShareList");
//筛选
$(document).on("click", "#filter-btn", function () {
g.reload(1);
});
//更改状态
$(document).on("click", ".auditStatus", function () {
var item = g.rows[$(this).data("index")];
item.status = 1 - item.status;
common.util.__ajax({
url: "/webShare/updateWebShare",
data: item
}, function () {
g.reload();
});
});
\ No newline at end of file
... ...