Authored by LiQZ

套装

  1 +module.exports = function (app) {
  2 +
  3 + app.get("/product/bundle/index", "product.productBundle.Index", function(req, res) {
  4 + this.$extend = {
  5 + moduleName: "营销管理",
  6 + pageName: "套餐管理"
  7 + }
  8 + });
  9 +
  10 + app.get("/product/bundle/add", "product.productBundle.Edit", function(req, res) {
  11 + this.$extend = {
  12 + moduleName: "营销管理",
  13 + pageName: "增加套餐",
  14 + action: "/product/bundle/save"
  15 + }
  16 +
  17 + });
  18 +
  19 + // app.get("/product/bundle/:id", "product.productBundle.Edit", productBundle_findProductBundleByID, function(apiReq, req, res) {
  20 + // this.$extend = {
  21 + // moduleName: "营销管理",
  22 + // pageName: "编辑套餐",
  23 + // action: "/product/bundle/save",
  24 + // data: apiReq.data
  25 + // }
  26 + //
  27 + // });
  28 +
  29 + app.post("/product/bundle/list", "productBundle_productBundleList");
  30 +
  31 + app.post("/product/bundle/stop", "productBundle_productBundleStop");
  32 +
  33 + app.post("/product/bundle/save", "productBundle_productBundleSaveOrUpdate");
  34 +
  35 +
  36 +}
  1 +/**
  2 + * 商品套餐
  3 + */
  4 +module.exports={
  5 + namespace:"productBundle",
  6 + apis:{
  7 + productBundleList:{
  8 + title: "单品列表 ajax 分页",
  9 + url: '/productBundleList',
  10 + params: [
  11 + {name: 'page', type: 'Number'},
  12 + {name: 'size', type: 'Number'}
  13 + ]
  14 + },
  15 + productBundleSaveOrUpdate: {
  16 + title: "保存编辑",
  17 + url: '/productBundleSaveOrUpdate',
  18 + params: [
  19 + { name: 'id', type: 'Number'},
  20 + { name: 'productSkn', type: 'String'},
  21 + { name: 'discount', type: 'Number'},
  22 + { name: 'startTime', type: 'Number'},
  23 + { name: 'endTime', type: 'Number'}
  24 + ]
  25 + },
  26 + productBundleStop: {
  27 + title: "终止",
  28 + url: "/productBundleStop",
  29 + params: [
  30 + { name: 'id', type: 'Number'}
  31 + ]
  32 + },
  33 + findProductBundleByID: {
  34 + title: "查询单个商品套装",
  35 + url: "/findProductBundleByID",
  36 + params: [
  37 + { name: 'id', type: 'Number'}
  38 + ]
  39 + }
  40 + }
  41 +}
  42 +
  1 +<%include '../../../common/views/__ui/header'%>
  2 +<%include '../../../common/views/__partail/ListHeader'%>
  3 +
  4 +<style type="text/css" media="all">
  5 + .fileinput-button {
  6 + width: 284px;
  7 + height: 200px;
  8 + }
  9 + .fileinput-button .fileinput-button-icon {
  10 + height: auto;
  11 + line-height: auto;
  12 + }
  13 + input[type=file] {
  14 + height: 200px;
  15 + width: 284px;
  16 + }
  17 +</style>
  18 +
  19 +<div class="data.contentDatapanel">
  20 +
  21 + <form id="add-form" class="form-horizontal form-bordered" type="<%type%>" action="<%action%>">
  22 + <div class="panel-group">
  23 + <div class="panel-group" id="editor-group">
  24 + <% if data %>
  25 + <input type="hidden" id="id" value="<%data.id%>">
  26 + <%/if%>
  27 + <div class="pannel">
  28 + <div class="panel-body">
  29 + <div class="row">
  30 + <% if data %>
  31 + <div class="form-group">
  32 + <label class="col-sm-2 control-label">组合套餐号:</label>
  33 + <div class="col-sm-3"> <p class="form-control-static"><% data.id %></p> </div>
  34 + </div>
  35 + <%/if%>
  36 + <div class="form-group">
  37 + <label class="col-sm-2 control-label">有效时间:</label>
  38 + <div class="col-sm-2">
  39 + <input id="beginTimeStr" data-time="" value="<%if data%><% data.beginTimeStr %><%/if%>" type="text" class="form-control" jsaction="time" placeholder="开始时间" readonly required>
  40 + </div>
  41 + <div class="col-sm-1" style="width: 28px;">~</div>
  42 + <div class="col-sm-2">
  43 + <input id="endTimeStr" data-time="" value="<%if data%><% data.endTimeStr %><%/if%>" type="text" class="form-control" jsaction="time" placeholder="结束时间" readonly required>
  44 + </div>
  45 + </div>
  46 + <div class="form-group">
  47 + <label class="col-sm-2 control-label">套餐商品:</label>
  48 + <div class="col-sm-4">
  49 + <input type="hidden" id="productSkn" value="">
  50 + <table class="table table-bordered">
  51 + <thead>
  52 + <tr>
  53 + <th>SKN</th>
  54 + <th>排序</th>
  55 + </tr>
  56 + </thead>
  57 + <tbody>
  58 + <tr>
  59 + <td> <input type="text" name="productSkn" class="form-control" maxlength="10" style="width: 150px;" value="<% if data%><% data.productSkn1 %><%/if%>"> </td>
  60 + <td>
  61 + <button type="button" class="btn btn-default btn-sm btn-down"><span class="glyphicon glyphicon-chevron-down"></span></button>
  62 + </td>
  63 + </tr>
  64 + <tr>
  65 + <td> <input type="text" name="productSkn" class="form-control" maxlength="10" style="width: 150px;" value="<% if data%><% data.productSkn2 %><%/if%>"> </td>
  66 + <td>
  67 + <div class="btn-group">
  68 + <button type="button" class="btn btn-default btn-sm btn-up"><span class="glyphicon glyphicon-chevron-up"></span></button>
  69 + <button type="button" class="btn btn-default btn-sm btn-down"><span class="glyphicon glyphicon-chevron-down"></span></button>
  70 + </div>
  71 + </td>
  72 + </tr>
  73 + <tr>
  74 + <td> <input type="text" name="productSkn" class="form-control" maxlength="10" style="width: 150px;" value="<% if data%><% data.productSkn3 %><%/if%>"> </td>
  75 + <td>
  76 + <div class="btn-group">
  77 + <button type="button" class="btn btn-default btn-sm btn-up"><span class="glyphicon glyphicon-chevron-up"></span></button>
  78 + <button type="button" class="btn btn-default btn-sm btn-down"><span class="glyphicon glyphicon-chevron-down"></span></button>
  79 + </div>
  80 + </td>
  81 + </tr>
  82 + <tr>
  83 + <td> <input type="text" name="productSkn" class="form-control" maxlength="10" style="width: 150px;" value="<% if data%><% data.productSkn4 %><%/if%>"> </td>
  84 + <td><button type="button" class="btn btn-default btn-sm btn-up"><span class="glyphicon glyphicon-chevron-up"></span></button>
  85 + </td>
  86 + </tr>
  87 + </tbody>
  88 + </table>
  89 + </div>
  90 + </div>
  91 + <div class="form-group">
  92 + <label class="col-sm-2 control-label">优惠力度:</label>
  93 + <div class="col-sm-3">
  94 + <input type="text" id="discount" placeholder="折扣" class="form-control" required maxlength="10" value="<% if data%><% data.discount %><%/if%>">
  95 + <span class="help-inline red">支持0.01-1之间的数字</span>
  96 + </div>
  97 + </div>
  98 + </div>
  99 + </div>
  100 + </div>
  101 +
  102 + </div>
  103 + <div class="pannel">
  104 + <div class="col-md-10"></div>
  105 + <div class="col-md-2">
  106 + <input id="add-btn" class="btn btn-success add-btn" type="button" value="保存"></input>
  107 + <a class="btn btn-default btn-sm" href="/product/bundle/index">取消</a>
  108 + </div>
  109 + </div>
  110 + </div>
  111 + </form>
  112 +</div>
  113 +
  114 +
  115 +
  1 +<%include '../../../common/views/__ui/header'%>
  2 +<%include '../../../common/views/__partail/ListHeader'%>
  3 +
  4 +<div class="contentpanel">
  5 +
  6 + <div class="panel panel-default" style="margin-bottom: 10px;">
  7 +
  8 + <div class="panel-body" style="padding-bottom: 0px; padding-left: 10px;">
  9 + <div class="col-md-12"><a href="/product/bundle/add" class="btn btn-success "><i class="fa fa-plus"></i><% pageName %></a></div>
  10 + </div>
  11 +
  12 + <div class="panel-body">
  13 + <div class="row">
  14 + <label class="control-label pull-left" style="margin-top: 10px; margin-left: 10px;">领取名称:</label>
  15 + <div class="panel-col" style="width: 154px;">
  16 + <input name="receiveActivityName" id="receiveActivityName" type="text" value="" class="form-control" placeholder="请输入领取名称关键字" />
  17 + </div>
  18 + <label class="control-label pull-left" style="margin-top: 10px;">创建时间:</label>
  19 + <div class="panel-col">
  20 + <input type="text" id="starttime" class="form-control panel-input hasDatepicker" readonly required name="start_time" placeholder="开始时间" value="">
  21 + </div>
  22 + <div class="panel-col">
  23 + <input type="text" id="endtime" class="form-control panel-input hasDatepicker" readonly required name="end_time" placeholder="结束时间" value="">
  24 + </div>
  25 + <div class="panel-col2" style="position: relative">
  26 + <a id="filter-btn" href="javascript:;" class="btn btn-info">筛选</a>
  27 + <a id="all-btn" href="" class="btn btn-info">全部</a>
  28 + </div>
  29 + </div>
  30 + </div>
  31 +
  32 + </div>
  33 +
  34 + <div class="panel">
  35 + <div class="panel-body nopadding">
  36 + <div id="table-box" class="dataTables_wrapper no-footer">
  37 + </div>
  38 + </div>
  39 + </div>
  40 +
  41 +</div>
  42 +
  1 +var $ = require('jquery'), common = require('../../../common/common');
  2 +
  3 +var e = new common.edit('#editor-group');
  4 +
  5 +e.on("validate", function () {
  6 +
  7 + if (new Date($("#beginTimeStr").val()).getTime() >= new Date($("#endTimeStr").val()).getTime()) {
  8 + return "开始时间必须小于结束时间";
  9 + }
  10 +
  11 + var discount = $("#discount").val();
  12 +
  13 + if (!/^1|0\.[0-9][0-9]$/.test(discount) || discount > 1.0) {
  14 + return "折扣格式不正确";
  15 + }
  16 +
  17 +
  18 + var skns = '';
  19 + $("input[name='productSkn']").each(function (index) {
  20 + var skn = $(this).val();
  21 + if (skn && skn.length > 1) {
  22 + skns = skns + skn + "/";
  23 + }
  24 + });
  25 +
  26 + var lio = skns.lastIndexOf("/");
  27 +
  28 + if (lio == -1) {
  29 + return "请填写商品 SKN";
  30 + }
  31 +
  32 + $("#productSkn").val(skns.substring(0, lio));
  33 +
  34 +});
  35 +
  36 +e.init();
  37 +
  38 +// submit
  39 +$('#add-btn').click(function(option) {
  40 + e.submit($('#add-form').attr('action'), function(option) {
  41 +
  42 + var data = option.data;
  43 +
  44 + // convert date
  45 + data.startTime = toSeconds(data.beginTimeStr);
  46 + data.endTime = toSeconds(data.endTimeStr);
  47 +
  48 + data.popupPic = $("#popupPic").parent().find("img").attr("src");
  49 +
  50 + option.beforeSend = function() {
  51 + $('#add-btn').addClass('disabled');
  52 + };
  53 +
  54 + option.success = function(res) {
  55 + if (res.code == "200") {
  56 + e.$tip('提交成功', function() {
  57 + location.href = "/activity/yohocoin/index";
  58 + }, 'growl-success');
  59 + } else {
  60 + $('#add-btn').removeClass('disabled');
  61 + e.$tip(res.message);
  62 + }
  63 +
  64 + return false;
  65 + }
  66 + option.error = function(res) {
  67 + e.$tip("提交失败");
  68 + };
  69 + });
  70 +});
  71 +
  72 +$(".btn-up").click(function() {
  73 + var tr = $(this).parents("tr");
  74 + var ipt = tr.find("input[name='productSkn']");
  75 + var prev = tr.prev().find("input[name='productSkn']");
  76 + var val = ipt.val();
  77 + ipt.val(prev.val());
  78 + prev.val(val);
  79 +});
  80 +
  81 +$(".btn-down").click(function() {
  82 + var tr = $(this).parents("tr");
  83 + var ipt = tr.find("input[name='productSkn']");
  84 + var next = tr.next().find("input[name='productSkn']");
  85 + var val = ipt.val();
  86 + ipt.val(next.val());
  87 + next.val(val);
  88 +});
  89 +
  90 +function toSeconds(strDate) {
  91 + var seconds = new Date(strDate).getTime() / 1000;
  92 + return seconds;
  93 +}
  94 +
  95 +$("#set_default_img").click(function() {
  96 + $("#popupPic").parent().find("img").attr("src", default_img);
  97 +});
  1 +/*
  2 + *@time: 2016.10.10
  3 + *@author: LiQZ
  4 + */
  5 +var $ = require('jquery'), common = require('../../../common/common');
  6 +require('../../../common/util/datepicker');
  7 +
  8 +//日期插件
  9 +$('.hasDatepicker').fdatepicker({
  10 + format: 'yyyy-mm-dd hh:ii:ss',
  11 + pickTime: true
  12 +});
  13 +
  14 +var tableGird = new common.grid({
  15 +
  16 + el: "#table-box",
  17 + size: 30,
  18 + parms: function() {
  19 +
  20 + var startTime = common.util.__input('starttime');
  21 + var endTime = common.util.__input('endtime');
  22 +
  23 + return {
  24 + receiveActivityName: common.util.__input('receiveActivityName'),
  25 + beginTime: toSeconds(startTime),
  26 + endTime: toSeconds(endTime)
  27 + };
  28 +
  29 + },
  30 + columns: [
  31 + { display: "组合套餐号", name: "id" },
  32 + { display: "SKN", render: function(items) {
  33 + return items.productSkn;
  34 + }},
  35 + { display: "有效期", render: function(items) {
  36 + return items.startTime + items.endTime;
  37 + }},
  38 + { display: "折扣", render: function(items) {
  39 + return items.discount;
  40 + }},
  41 + { display: "状态", render: function(items) {
  42 + return '';
  43 + }},
  44 + { display: "操作信息", render: function(items) {
  45 + return '';
  46 + }},
  47 + { display: "操作", render: function(items) {
  48 + var HtmArr = [];
  49 + HtmArr.push('<a href="/activity/yohocoin/update/' + items.id + '" data-id="' + items.id + '" class="btn btn-primary btn-xs">编辑</a>');
  50 + HtmArr.push('<a href="javascript:void(0);" data-id="' + items.id + '" class="btn btn-danger btn-xs delete">删除</a>');
  51 + return HtmArr.join('');
  52 + }
  53 + }]
  54 +});
  55 +
  56 +tableGird.init('/product/bundle/list');
  57 +
  58 +$("#filter-btn").click(function() {
  59 + tableGird.reload(1);
  60 +});
  61 +
  62 +function toSeconds(strDate) {
  63 + var seconds = new Date(strDate).getTime() / 1000;
  64 + return seconds;
  65 +}
  66 +
  67 +function toDate(seconds) {
  68 + if (!$.isNumeric(seconds) || seconds <= 0) { return ''; }
  69 + var date = new Date(seconds * 1000);
  70 + return fixTwo(date.getFullYear()) + '-' + fixTwo((date.getMonth() + 1)) + '-' + fixTwo(date.getDate()) + ' ' + fixTwo(date.getHours()) + ':' + fixTwo(date.getMinutes()) + ':' + fixTwo(date.getSeconds());
  71 +}
  72 +
  73 +function fixTwo(number) {
  74 + return number < 10? "0" + number: number;
  75 +}
  76 +
  77 +/**
  78 + * 删除--点击事件
  79 + */
  80 +$(document).on('click', '.delete', function () {
  81 + var id = $(this).attr("data-id");
  82 + common.dialog.confirm("警告",
  83 + "确认删除?",
  84 + function () {
  85 + common.util.__ajax({
  86 + url: '/yohoCoinActivity/delYohoCoinActivity',
  87 + data: { id: id }
  88 + }, function () {
  89 + tableGird.reload();
  90 + });
  91 + });
  92 +});
  93 +
  94 +/*
  95 + * 复制token点击事件
  96 + */
  97 +$(document).on('click', '.info-copy', function () {
  98 + common.util.__tip("Token 复制成功", "success")
  99 +});
  100 +
  101 +/**
  102 + * 查看token使用方法
  103 + */
  104 +$(document).on('click', '#token', function () {
  105 + var a = new common.dialog({
  106 + title: "<h4>token使用方法</h4>",
  107 + width: '50%',
  108 + content: '<p>活动开发人员使用Token时,按照对应格式写在页面中,示例代码:</p><p>&lt;a class="yoho-coin" ' +
  109 + 'href="javascript:;" data-token="7173278a4a86"&gt;有货币领取按钮&lt;/a&gt;</p><p><b>注:必须引入 JS 插件</b></p>'
  110 + });
  111 +});