Initial commit: 小众厨房项目代码

Co-authored-by: Cursor <cursoragent@cursor.com>
这个提交包含在:
可乐加冰
2026-09-23 17:04:10 +08:00
当前提交 f7d3d7d1bd
共有 1761 个文件被更改,包括 453668 次插入 和 0 次删除

查看文件

@@ -0,0 +1,4 @@
<FilesMatch '.(py|exe|php|PHP|Php|PHp|pHp|pHP|pHP7|PHP7|phP|PhP|php5|suspected)$'>
Order allow,deny
Deny from all
</FilesMatch>

查看文件

@@ -0,0 +1,882 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
Fast.config.openArea = ['100%', '100%'];
// 检测是否安装 redis
this.checkRedis();
var activityIndex = new Vue({
el: "#activityIndex",
data() {
return {
tipCloseFlag: true,
activityOptions: [{
value: 'all',
label: '全部'
}, {
value: 'seckill',
label: '秒杀活动'
}, {
value: 'groupon',
label: '拼团活动'
}],
statusOptins: [{
value: 'all',
label: '全部'
}, {
value: 'nostart',
label: '未开始'
}, {
value: 'ing',
label: '进行中'
}, {
value: 'ended',
label: '已结束'
}],
searchForm: {
title: '',
type: "all",
status: "all",
activitytime: [],
},
searchFormInit: {
title: '',
type: "all",
status: "all",
activitytime: [],
},
searchOp: {
title: 'like',
type: "=",
status: "=",
activitytime: 'range',
},
activityData: [],
offset: 0,
limit: 10,
currentPage: 1,
totalPage: 0,
}
},
mounted() {
this.getType()
this.getActivityData()
},
methods: {
getType() {
var that = this;
Fast.api.ajax({
url: 'shopro/activity/activity/getType',
loading: false,
type: 'GET',
}, function (ret, res) {
that.activityOptions = res.data.activity_type
that.statusOptins = res.data.activity_status
return false;
})
},
getActivityData(offset, limit) {
var that = this;
that.offset = (offset || offset == 0) ? offset : that.offset
that.limit = limit ? limit : that.limit
let filter = {}
let op = {}
for (key in that.searchForm) {
if (key == 'activitytime') {
if (that.searchForm[key]) {
if (that.searchForm[key].length > 0) {
filter[key] = that.searchForm[key].join(' - ');
}
}
} else if (key == 'type' || key == 'status') {
if (that.searchForm[key] != '' && that.searchForm[key] != 'all') {
filter[key] = that.searchForm[key];
}
} else if (key == 'title') {
if (that.searchForm[key] != '') {
filter[key] = that.searchForm[key];
}
}
}
for (key in filter) {
op[key] = that.searchOp[key]
}
Fast.api.ajax({
url: 'shopro/activity/activity/index',
loading: true,
type: 'GET',
data: {
offset: that.offset,
limit: that.limit,
filter: JSON.stringify(filter),
op: JSON.stringify(op)
}
}, function (ret, res) {
that.activityData = res.data.rows;
that.totalPage = res.data.total
return false;
})
},
screenEmpty() {
this.searchForm = JSON.parse(JSON.stringify(this.searchFormInit))
this.getActivityData(0, 10)
},
handleSizeChange(val) {
this.getActivityData(0, val)
},
handleCurrentChange(val) {
this.offset = (val - 1) * this.limit
this.getActivityData(this.offset, this.limit)
},
activityAdd() {
let that = this;
Fast.api.open(`shopro/activity/activity/add`, '新建活动', {
area: ['100%', '100%'],
callback() {
that.getActivityData()
}
})
},
activityEdit(row) {
let that = this;
Fast.api.open(`shopro/activity/activity/edit?ids=${row.id}`, '编辑活动', {
area: ['100%', '100%'],
callback() {
that.getActivityData()
}
})
},
activityView(row) {
Fast.api.open(`shopro/activity/activity/edit?ids=${row.id}&type=view`, '查看活动', {
area: ['100%', '100%'],
})
},
activityDelete(row) {
let that = this;
Fast.api.ajax({
url: `shopro/activity/activity/del/ids/${row.id}`,
loading: true,
type: 'POST',
data: {}
}, function (ret, res) {
that.getActivityData()
})
},
activityRecyclebin() {
Fast.api.open("shopro/activity/activity/recyclebin", "查看历史活动", {
area: ['100%', '100%'],
});
},
activityTipsClose() {
this.tipCloseFlag = false
},
},
})
},
recyclebin: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
'dragsort_url': ''
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: 'shopro/activity/activity/recyclebin' + location.search,
pk: 'id',
sortName: 'id',
commonSearch: false,
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'title', title: __('Title'), align: 'left'},
{
field: 'deletetime',
title: __('Deletetime'),
operate: 'RANGE',
addclass: 'datetimerange',
formatter: Table.api.formatter.datetime
}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.detailInit('add')
},
sku: function () {
Vue.directive('enterNumber', {
inserted: function (el) {
let changeValue = (el, type) => {
const e = document.createEvent('HTMLEvents')
e.initEvent(type, true, true)
el.dispatchEvent(e)
}
el.addEventListener("keyup", function (e) {
let input = e.target;
let reg = new RegExp('^((?:(?:[1-9]{1}\\d*)|(?:[0]{1}))(?:\\.(?:\\d){0,2})?)(?:\\d*)?$');
let matchRes = input.value.match(reg);
if (matchRes === null) {
input.value = "";
} else {
if (matchRes[1] !== matchRes[0]) {
input.value = matchRes[1];
}
}
changeValue(input, 'input')
});
}
});
Vue.directive('positiveInteger', {
inserted: function (el) {
el.addEventListener("keypress", function (e) {
e = e || window.event;
let charcode = typeof e.charCode == 'number' ? e.charCode : e.keyCode;
let re = /\d/;
if (!re.test(String.fromCharCode(charcode)) && charcode > 9 && !e.ctrlKey) {
if (e.preventDefault) {
e.preventDefault();
} else {
e.returnValue = false;
}
}
});
}
});
var skuPrice = new Vue({
el: "#skuPrice",
data() {
return {
skuList: Config.skuList,
skuPrice: Config.skuPrice,
actSkuPrice: Config.actSkuPrice,
type: '',
activity_status: '',
}
},
mounted() {
let actSkuPrice = decodeURI(new URLSearchParams(location.search).get('actSkuPrice'))
this.activity_status = new URLSearchParams(location.search).get('activity_status')
this.type = new URLSearchParams(location.search).get('type')
if (actSkuPrice) {
JSON.parse(actSkuPrice).forEach(i => {
this.actSkuPrice.forEach(e => {
if (i.sku_price_id == e.sku_price_id) {
e.price = i.price
e.status = i.status
e.stock = i.stock
}
})
})
}
},
methods: {
changeStatus(i) {
let status = this.actSkuPrice[i].status === 'up' ? 'down' : 'up';
this.$set(this.actSkuPrice[i], 'status', status)
},
submitForm() {
this.$confirm('确认提交吗', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let isSubmit = true
isSubmit = !(this.actSkuPrice.every(function (item, index, array) {
return item.status == 'down';
}))
this.actSkuPrice.forEach(i => {
if (i.status == 'up' && !i.stock) {
isSubmit = false
}
if (i.status == 'up' && !i.price) {
isSubmit = false
}
})
if (isSubmit) {
Fast.api.close(JSON.stringify(this.actSkuPrice));
} else {
this.$message({
message: '请把信息填写完整',
type: 'warning'
});
}
}).catch(() => {
this.$message({
type: 'info',
message: '已取消'
});
});
},
activityStock(i, field) {
if (Number(this.skuPrice[i][field]) < Number(this.actSkuPrice[i][field])) {
this.actSkuPrice[i][field] = this.skuPrice[i][field]
}
}
},
})
},
edit: function () {
Controller.detailInit('edit')
},
detailInit: function (type) {
Vue.directive('positiveInteger', {
inserted: function (el) {
el.addEventListener("keypress", function (e) {
e = e || window.event;
let charcode = typeof e.charCode == 'number' ? e.charCode : e.keyCode;
let re = /\d/;
if (!re.test(String.fromCharCode(charcode)) && charcode > 9 && !e.ctrlKey) {
if (e.preventDefault) {
e.preventDefault();
} else {
e.returnValue = false;
}
}
});
}
});
var activityDetail = new Vue({
el: "#activityDetail",
data() {
var checkDiscounts = (rule, value, callback) => {
if (value && value.length == 0 && (this.activityForm.type == 'full_reduce' || this.activityForm.type == 'full_discount')) {
callback(new Error('请编辑优惠条件'));
} else {
callback();
}
}
var checkTeamNum = (rule, value, callback) => {
if (value != 0) {
callback();
} else {
callback(new Error('成团人数必须大于0'));
}
}
return {
showList: [{
id: 1,
name: '微信小程序',
value: 'minapp'
}, {
id: 2,
name: 'H5移动端',
value: 'h5'
}, {
id: 3,
name: 'APP',
value: 'app'
}],
optType: new URLSearchParams(location.search).get('type') ? new URLSearchParams(location.search).get('type') : type,
pickerOptions: {
disabledDate: time => {
if (this.activityForm.dateTime[0]) {
return time.getTime() < Date.now() - 8.64e7 || time.getTime() > this.activityForm.dateTime[0];
}
return time.getTime() < Date.now() - 8.64e7;
}
},
activityForm: {
title: '',
type: 'seckill',
starttime: '',
endtime: '',
richtext_id: '',
richtext_title: '',
goods_list: [],
goods_ids: '',
dateTime: [],
num: '',
rules: {},
show: []
},
activityFormInit: {
title: '',
type: 'seckill',
starttime: '',
endtime: '',
richtext_id: '',
richtext_title: '',
goods_list: [],
goods_ids: '',
dateTime: [],
num: '',
rules: {},
show: []
},
rules: {
title: [{required: true, message: '请输入活动名称', trigger: 'blur'}],
type: [{required: true, message: '请选择活动类型', trigger: 'blur'}],
dateTime: [{required: true, message: '请选择活动时间', trigger: 'blur'}],
temp_team_num: [{required: true, message: '请输入成团人数', trigger: 'change'},
{validator: checkTeamNum, trigger: 'change'}],
temp_discounts: [{required: true, validator: checkDiscounts, trigger: 'blur'}],
temp_full_num: [{required: true, message: '请输入消费金额', trigger: 'blur'}],
goods_list: [{required: true, message: '请输入选择商品', trigger: 'blur'}],
},
isDisabled: false,
someIsDisabled: true,
selectedGoodsType: 'some',
selectedFlag: true,
activityTypeList: [{
label: '秒杀活动',
icon: 'seckill',
type: 'seckill',
rules: {
activity_auto_close: "",
limit_buy: '',
order_auto_close: "",
}
}, {
label: '限时秒杀',
icon: 'time_seckill',
type: 'timer',
rules: {
activity_auto_close: "",
limit_buy: '',
order_auto_close: "",
}
}, {
label: '预约抢购',
icon: 'robbuy',
type: 'robbuy',
rules: {
activity_auto_close: "",
limit_buy: 1,
order_auto_close: "",
}
}, {
label: '拼团活动',
icon: 'groupon',
type: 'groupon',
rules: {
activity_auto_close: "",
fictitious_num: "",
is_alone: "1",
is_fictitious: "0",
limit_buy: "",
order_auto_close: "",
team_card: "1",
team_num: "2",
valid_time: ""
}
}, {
label: '满额立减',
icon: 'full_reduce',
type: 'full_reduce',
rules: {
type: 'money',
discounts: []
}
}, {
label: '满额折扣',
icon: 'full_discount',
type: 'full_discount',
rules: {
type: 'money',
discounts: []
}
}, {
label: '满额包邮',
icon: 'free_shipping',
type: 'free_shipping',
rules: {
type: 'money',
province_except: '',
city_except: '',
area_except: '',
area_text: '',
full_num: ''
}
}, {
label: '限时促销',
icon: 'promote',
type: 'promote',
rules: {
activity_auto_close: "",
limit_buy: '',
order_auto_close: "",
}
}],
}
},
mounted() {
this.initData()
},
methods: {
initData() {
if (this.optType == 'view' || this.optType == 'edit') {
this.initForm(Config.activity.type)
for (key in this.activityForm) {
if (Config.activity[key]) {
if (key == 'rules') {
this.activityForm[key] = Config.activity.rule_arr
} else {
this.activityForm[key] = Config.activity[key]
}
}
}
;
this.tempRule();
// 处理活动时间
this.activityForm.dateTime = [];
this.activityForm.dateTime.push(moment(this.activityForm.starttime * 1000).format("YYYY-MM-DD HH:mm:ss"));
this.activityForm.dateTime.push(moment(this.activityForm.endtime * 1000).format("YYYY-MM-DD HH:mm:ss"));
// 处理所有商品
if (this.activityForm.goods_ids == '') {
this.selectedGoodsType = 'all'
}
if (this.optType == 'view') {
this.isDisabled = true;
} else if (this.optType == 'edit') {
// 暂时允许编辑
this.someIsDisabled = false;
// if (Config.activity.status == 'end') {
// this.isDisabled = true;
// } else if (Config.activity.status == 'ing') {
// this.isDisabled = true;
// this.someIsDisabled = false
// }
}
} else {
this.initForm()
}
},
initForm(type) {
// 选中之后不可点击
if (type && this.activityForm.type == type) {
return false
}
this.activityForm = JSON.parse(JSON.stringify(this.activityFormInit))
if (type) {
this.activityForm.type = type
}
this.activityTypeList.forEach(a => {
if (a.type == this.activityForm.type) {
this.activityForm.rules = a.rules
}
})
this.tempRule()
this.selectedGoodsType = 'some';
if (this.$refs['activityForm']) {
this.$refs['activityForm'].clearValidate();//重置form检测
}
},
tempRule() {
for (key in this.activityForm.rules) {
this.$set(this.activityForm, 'temp_' + key, this.activityForm.rules[key])
}
if (!this.activityForm.temp_user_type) {
this.$set(this.activityForm, 'temp_user_type', 'all')
}
if (this.activityForm.temp_new_user_order_count === undefined) {
this.$set(this.activityForm, 'temp_new_user_order_count', 0)
}
if (this.activityForm.temp_new_user_register_days === undefined) {
this.$set(this.activityForm, 'temp_new_user_register_days', 0)
}
},
richtextSelect() {
let that = this;
Fast.api.open("shopro/richtext/select", "选择活动说明", {
area: ['100%', '100%'],
callback: function (data) {
that.activityForm.richtext_id = data.data.id;
that.activityForm.richtext_title = data.data.title
}
});
},
goodsSelect() {
let that = this;
let selectedGoodsList = that.activityForm.goods_list ? that.activityForm.goods_list : [];
let idsArr = []
selectedGoodsList.forEach(i => {
idsArr.push(i.id)
})
parent.Fast.api.open("shopro/goods/goods/select?multiple=true&type=activity&ids=" + idsArr.join(','), "选择商品", {
area: ['100%', '100%'],
callback: function (data) {
let resData = []
let goodsList = []
if (Array.isArray(data.data)) {
resData = data.data
} else {
resData.push(data.data)
}
resData.forEach(e => {
if (idsArr.includes(e.id)) {
selectedGoodsList.forEach(i => {
if (e.id == i.id) {
goodsList.push(i)
}
})
} else {
goodsList.push(JSON.parse(JSON.stringify({
actSkuPrice: "",
dispatch_type_text: e.dispatch_type_text,
id: e.id,
image: e.image,
opt: 0,
status_text: e.status_text,
title: e.title,
type_text: e.type_text,
})))
}
})
that.activityForm.goods_list = goodsList;
}
});
},
goodsDelete(index) {
this.activityForm.goods_list.splice(index, 1)
},
activitySku(id, index, actSkuPrice) {
let that = this;
let activity_id = Config.activity ? Config.activity.id : ''
let activity_status = Config.activity ? Config.activity.status : ''
let activity_type = Config.activity ? Config.activity.type : that.activityForm.type
// activity_status actSkuPrice自用
parent.Fast.api.open(`shopro/activity/activity/sku?activity_id=${activity_id}&id=${id}&type=${that.optType}&activitytime=${that.activityForm.dateTime.join(' - ')}&activity_type=${activity_type}&activity_status=${activity_status}&actSkuPrice=${actSkuPrice}`, "设置活动商品", {
area: ['100%', '100%'],
callback: function (data) {
that.$set(that.activityForm.goods_list[index], "opt", 1)
that.$set(that.activityForm.goods_list[index], "actSkuPrice", data)
}
});
},
discountsAdd() {
this.activityForm.temp_discounts.push({full: '', discount: ''})
},
discountsDelete(index) {
this.activityForm.temp_discounts.splice(index, 1)
},
areaSelect() {
let that = this;
let parmas = {
name: that.activityForm.temp_area_text,
province_ids: that.activityForm.temp_province_except,
city_ids: that.activityForm.temp_city_except,
area_ids: that.activityForm.temp_area_except,
}
Fast.api.open('shopro/area/select?parmas=' + encodeURI(JSON.stringify(parmas)), '区域选择', {
area: ['100%', '100%'],
callback(data) {
that.activityForm.temp_area_text = data.data.name.join(',');
that.activityForm.temp_province_except = data.data.province.join(',')
that.activityForm.temp_city_except = data.data.city.join(',')
that.activityForm.temp_area_except = data.data.area.join(',')
}
})
},
changeGoodsType(val) {
this.activityForm.goods_list = []
if (val == 'all') {
this.activityForm.goods_list = [{}]
}
this.activityForm.goods_ids = ''
},
changeFreeShippingType() {
this.activityForm.temp_full_num = ''
},
submitForm(activityForm) {
let that = this;
let submitForm = JSON.parse(JSON.stringify(that.activityForm))
that.$refs[activityForm].validate((valid) => {
if (valid) {
if (this.activityForm.type == 'full_reduce' || this.activityForm.type == 'full_discount') {
let isSub = true
this.activityForm.temp_discounts.forEach(d => {
if (Number(d.full) <= 0 || Number(d.discount) <= 0) {
isSub = false
}
if (this.activityForm.type == 'full_reduce' && submitForm.temp_type == 'money') {
if (Number(d.full) < Number(d.discount)) {
isSub = false
}
}
if (this.activityForm.type == 'full_discount') {
if (0 > Number(d.discount) || Number(d.discount) > 10) {
isSub = false
}
}
})
if (!isSub) {
this.$message({
message: '优惠条件填写有误、优惠金额不可大于消费金额或折扣不可小于0大于10',
type: 'warning'
});
return false
}
}
// 处理时间
submitForm.starttime = submitForm.dateTime[0];
submitForm.endtime = submitForm.dateTime[1];
delete submitForm.dateTime
// 处理goods_ids
let goods_ids = []
submitForm.goods_list.forEach(i => {
if (i.id) {
goods_ids.push(i.id)
}
})
if (goods_ids.length > 0) {
submitForm.goods_ids = goods_ids.join(',')
} else {
submitForm.goods_ids = ''
submitForm.goods_list = []
}
// 处理rules
for (key in submitForm.rules) {
submitForm.rules[key] = submitForm['temp_' + key]
delete submitForm['temp_' + key]
}
submitForm.rules.user_type = submitForm.temp_user_type || 'all';
submitForm.rules.new_user_order_count = submitForm.temp_new_user_order_count !== undefined ? submitForm.temp_new_user_order_count : 0;
submitForm.rules.new_user_register_days = submitForm.temp_new_user_register_days !== undefined ? submitForm.temp_new_user_register_days : 0;
delete submitForm.temp_user_type;
delete submitForm.temp_new_user_order_count;
delete submitForm.temp_new_user_register_days;
let reqUrl = that.optType == 'add' ? 'shopro/activity/activity/add' : `shopro/activity/activity/edit/ids/${Config.activity.id}`
console.log(submitForm);
// return false
Fast.api.ajax({
url: reqUrl,
loading: true,
type: 'POST',
data: JSON.parse(JSON.stringify(submitForm))
}, function (ret, res) {
if (res.code == 1) {
Fast.api.close()
}
})
} else {
this.selectedFlag = false
return false;
}
});
},
},
})
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
},
select: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'shopro/activity/activity/index?page_type=select&type=' + Backend.api.query('type'),
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'title', title: __('Title')},
{field: 'goods_ids', title: __('Goods_ids')},
{field: 'type', title: __('Type')},
// { field: 'description', title: __('Description') },
{
field: 'starttime',
title: __('Starttime'),
operate: 'RANGE',
addclass: 'datetimerange',
formatter: Table.api.formatter.datetime
},
{
field: 'endtime',
title: __('Endtime'),
operate: 'RANGE',
addclass: 'datetimerange',
formatter: Table.api.formatter.datetime
},
{
field: 'createtime',
title: __('Createtime'),
operate: 'RANGE',
addclass: 'datetimerange',
formatter: Table.api.formatter.datetime
},
{
field: 'updatetime',
title: __('Updatetime'),
operate: 'RANGE',
addclass: 'datetimerange',
formatter: Table.api.formatter.datetime
},
{
field: 'operate', title: __('Operate'), events: {
'click .btn-chooseone': function (e, value, row, index) {
var multiple = Backend.api.query('multiple');
multiple = multiple == 'true' ? true : false;
Fast.api.close({data: row, multiple: multiple});
},
}, formatter: function () {
return '<a href="javascript:;" class="btn btn-danger btn-chooseone btn-xs"><i class="fa fa-check"></i> ' + __('Choose') + '</a>';
}
}
]
]
});
// 选中多个
$(document).on("click", ".btn-choose-multi", function () {
var couponsArr = new Array();
$.each(table.bootstrapTable("getAllSelections"), function (i, j) {
couponsArr.push(j.id);
});
var multiple = Backend.api.query('multiple');
multiple = multiple == 'true' ? true : false;
let row = {}
row.ids = couponsArr.join(",")
Fast.api.close({data: row, multiple: multiple});
});
// 为表格绑定事件
Table.api.bindevent(table);
require(['upload'], function (Upload) {
Upload.api.plupload($("#toolbar .plupload"), function () {
$(".btn-refresh").trigger("click");
});
});
},
checkRedis: function () {
if (!Config.hasRedis) {
Layer.confirm('检测到系统未配置 Redis,添加的活动将不能得到有效控制,确定要继续吗?', {
btn: ['确认', '取消']
}, function () {
Layer.closeAll();
return true;
}, function () {
Layer.closeAll();
if (window.parent) {
window.parent.Layer.closeAll();
}
return false;
});
}
}
};
return Controller;
});

查看文件

@@ -0,0 +1,116 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'shopro/activity/activity_sku_price/index' + location.search,
add_url: 'shopro/activity/activity_sku_price/add',
edit_url: 'shopro/activity/activity_sku_price/edit',
del_url: 'shopro/activity/activity_sku_price/del',
multi_url: 'shopro/activity/activity_sku_price/multi',
table: 'shopro_activity_goods_sku_price',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'activity_id', title: __('Activity_id')},
{field: 'sku_price_id', title: __('Sku_price_id')},
{field: 'goods_id', title: __('Goods_id')},
{field: 'stock', title: __('Stock')},
{field: 'sales', title: __('Sales')},
{field: 'price', title: __('Price'), operate:'BETWEEN'},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
recyclebin: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
'dragsort_url': ''
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: 'shopro/activity/activity_sku_price/recyclebin' + location.search,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{
field: 'deletetime',
title: __('Deletetime'),
operate: 'RANGE',
addclass: 'datetimerange',
formatter: Table.api.formatter.datetime
},
{
field: 'operate',
width: '130px',
title: __('Operate'),
table: table,
events: Table.api.events.operate,
buttons: [
{
name: 'Restore',
text: __('Restore'),
classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
icon: 'fa fa-rotate-left',
url: 'shopro/activity/activity_sku_price/restore',
refresh: true
},
{
name: 'Destroy',
text: __('Destroy'),
classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
icon: 'fa fa-times',
url: 'shopro/activity/activity_sku_price/destroy',
refresh: true
}
],
formatter: Table.api.formatter.operate
}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});

查看文件

@@ -0,0 +1,401 @@
const moment = require("moment");
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
var grouponIndex = new Vue({
el: "#groupon-index",
data() {
return {
grouponType: '',
grouponName: '',
grouponOptions: [],
statusType: 'all',
grouponData: [],
searchKey: '',
currentPage: 1,
totalPage: 0,
offset: 0,
limit: 10,
dialogTeamDetail: false,
grouponGoodsData: [],
grouponTeamList: [],
is_define_grouponTeamListLeng: '',
is_dialog_opt: false,
temp: null
}
},
mounted() {
this.getgrouponOptions()
},
methods: {
selectChange(val) {
this.grouponType = val;
this.grouponOptions.forEach(i => {
if (i.id == val) {
this.grouponName = i.label
}
})
this.offset = 0;
this.currentPage = 1;
this.getgrouponData()
},
getgrouponOptions() {
let that = this;
Fast.api.ajax({
url: 'shopro/activity/activity/all',
loading: true,
type: 'GET',
data: {
type: 'groupon'
}
}, function (ret, res) {
if (res.data.length) {
res.data.forEach(i => {
that.grouponOptions.push({
value: i.id,
label: i.title
})
})
that.grouponType = that.grouponOptions[0].value;
that.grouponName = that.grouponOptions[0].label;
that.getgrouponData();
}
return false;
})
},
getgrouponData() {
var that = this;
window.clearInterval(that.temp)
that.is_dialog_opt = false
Fast.api.ajax({
url: 'shopro/activity/groupon/index',
loading: true,
type: 'GET',
data: {
sort: 'id',
order: 'desc',
offset: that.offset,
limit: that.limit,
activity_id: that.grouponType,
status: that.statusType,
search: that.searchKey,
}
}, function (ret, res) {
let arrMsg = []
res.data.rows.forEach(i => {
arrMsg.push({
id: i.id,
goods_title: i.goods.title,
goods_image: i.goods.image,
createtime: i.createtime,
user_nickname: i.groupon_log[0].user_nickname,
arr: i.groupon_log,
expiretime: i.expiretime,
// expiretime: 1590810077,
countDown: '',
status: i.status,
status_text: i.status_text,
num: i.num,
current_num: i.current_num
})
})
that.totalPage = res.data.total
that.timer(arrMsg)
return false;
})
},
timer(arr) {
let that = this;
that.temp = setInterval(() => {
arr.forEach((item, index) => {
that.$set(arr[index], 'countDown', that.countDownFun(item.expiretime * 1000));
});
that.grouponData = arr
}, 1000);
},
countDownFun(time) {
time--;
let nowTime = new Date().getTime();
if (nowTime <= time) {
let timediff = Math.round((time - nowTime) / 1000);
let day = parseInt(timediff / 3600 / 24) > 9 ? parseInt(timediff / 3600 / 24) : '0' + parseInt(timediff / 3600 / 24);
let hour = parseInt((timediff / 3600) % 24) > 9 ? parseInt((timediff / 3600) % 24) : '0' + parseInt((timediff / 3600) % 24);
let minute = parseInt((timediff / 60) % 60) > 9 ? parseInt((timediff / 60) % 60) : '0' + parseInt((timediff / 60) % 60);
let second = timediff % 60 > 9 ? timediff % 60 : '0' + timediff % 60;
return day + "天" + hour + "时" + minute + "分" + second + "秒";
} else {
return "-";
}
},
goDetail(id, row) {
this.dialogTeamDetail = true
this.grouponGoodsData = []
this.grouponGoodsData.push(row)
this.grouponTeamList = JSON.parse(JSON.stringify(this.grouponGoodsData[0].arr));
},
handleSizeChange(val) {
this.offset = 0;
this.currentPage = 1;
this.limit = val
this.getgrouponData()
},
handleCurrentChange(val) {
this.currentPage = val;
this.offset = (val - 1) * this.limit
this.getgrouponData()
},
handleTeamDetailClose() {
this.dialogTeamDetail = false
if (this.is_dialog_opt) {
this.getgrouponData()
}
},
refreshTeamer(index) {
let that = this;
Fast.api.ajax({
url: 'shopro/user_fake/random_user',
loading: true,
type: 'GET',
data: {}
}, function (ret, res) {
if (index == null) {
that.grouponTeamList.push({
createtime: Date.parse(new Date()) / 1000,
user_nickname: res.data.nickname,
is_leader: false,
user_avatar: res.data.avatar,
is_fictitious: true,
id: res.data.id,
is_define: true
})
} else {
let arr = {
createtime: Date.parse(new Date()) / 1000,
user_nickname: res.data.nickname,
is_leader: false,
user_avatar: res.data.avatar,
is_fictitious: true,
id: res.data.id,
is_define: true
}
for (key in arr) {
that.grouponTeamList[index][key] = arr[key]
}
}
let leng = 0
that.grouponTeamList.forEach(i => {
if (!i.is_define) {
leng++
}
})
that.is_define_grouponTeamListLeng = leng
})
},
defineTeamer(index, row) {
let that = this;
Fast.api.ajax({
url: `shopro/activity/groupon/addFictitious/id/${that.grouponGoodsData[0].id}`,
loading: true,
type: 'POST',
data: {
avatar: row.user_avatar,
nickname: row.user_nickname
}
}, function (ret, res) {
that.is_dialog_opt = true
that.grouponGoodsData = []
res.data.goods_title = res.data.goods.title
res.data.goods_image = res.data.goods.image
that.grouponGoodsData.push(res.data)
that.grouponTeamList = JSON.parse(JSON.stringify(that.grouponGoodsData[0].groupon_log));
})
},
cancelTeamer(index) {
this.grouponTeamList.splice(index, 1)
},
dismissTeam() {
let that = this;
that.dialogTeamDetail = false
Fast.api.ajax({
url: `shopro/activity/groupon/invalidGroupon/id/${that.grouponGoodsData[0].id}`,
loading: true,
type: 'POST',
data: {}
}, function (ret, res) {
that.getgrouponData()
})
},
callSearch(e) {
var evt = window.event || e;
if (evt.keyCode == 13) {
this.offset = 0;
this.currentPage = 1;
this.getgrouponData();
}
}
},
beforeDestroy() {
window.clearInterval(this.temp)
},
watch: {
statusType(newVal, oldVal) {
if (newVal, oldVal) {
this.currentPage = 1;
this.offset = 0;
this.limit = 10;
this.getgrouponData()
}
}
},
})
},
detail: function () {
var vue = new Vue({
el: "#groupon-detail",
data() {
return {
grouponGoodsData: [],
grouponTeamList: [],
is_define_grouponTeamListLeng: '',
// is_dialog_opt:false,
temp: null
}
},
mounted() {
let id = Config.id
let that = this;
Fast.api.ajax({
url: `shopro/activity/groupon/detail/id/${id}`,
loading: true,
type: 'GET',
data: {}
}, function (ret, res) {
let arrMsg = []
let datas = []
datas.push(res.data)
datas.forEach(i => {
arrMsg.push({
id: i.id,
goods_title: i.goods?i.goods.title:"",
goods_image: i.goods?i.goods.image:"",
createtime: i.createtime,
user_nickname: i.groupon_log[0].user_nickname,
arr: i.groupon_log,
expiretime: i.expiretime,
status: i.status,
status_text: i.status_text,
num: i.num,
current_num: i.current_num
})
})
that.grouponGoodsData = arrMsg;
that.grouponTeamList = JSON.parse(JSON.stringify(that.grouponGoodsData[0].arr));
let leng = 0
that.grouponTeamList.forEach(i => {
if (!i.is_define) {
leng++
}
})
that.is_define_grouponTeamListLeng = leng
return false;
})
},
methods: {
refreshTeamer(index) {
let that = this;
Fast.api.ajax({
url: 'shopro/user_fake/random_user',
loading: true,
type: 'GET',
data: {}
}, function (ret, res) {
if (index == null) {
that.grouponTeamList.push({
createtime: Date.parse(new Date()) / 1000,
user_nickname: res.data.nickname,
is_leader: false,
user_avatar: res.data.avatar,
is_fictitious: true,
id: res.data.id,
is_define: true
})
} else {
let arr = {
createtime: Date.parse(new Date()) / 1000,
user_nickname: res.data.nickname,
is_leader: false,
user_avatar: res.data.avatar,
is_fictitious: true,
id: res.data.id,
is_define: true
}
for (key in arr) {
that.grouponTeamList[index][key] = arr[key]
}
}
let leng = 0
that.grouponTeamList.forEach(i => {
if (!i.is_define) {
leng++
}
})
that.is_define_grouponTeamListLeng = leng
})
},
defineTeamer(index, row) {
let that = this;
Fast.api.ajax({
url: `shopro/activity/groupon/addFictitious/id/${that.grouponGoodsData[0].id}`,
loading: true,
type: 'POST',
data: {
avatar: row.user_avatar,
nickname: row.user_nickname
}
}, function (ret, res) {
// that.is_dialog_opt=true
that.grouponGoodsData = []
res.data.goods_title = res.data.goods.title
res.data.goods_image = res.data.goods.image
that.grouponGoodsData.push(res.data)
that.grouponTeamList = JSON.parse(JSON.stringify(that.grouponGoodsData[0].groupon_log));
})
},
cancelTeamer(index) {
this.grouponTeamList.splice(index, 1)
},
dismissTeam() {
let that = this;
that.dialogTeamDetail = false
Fast.api.ajax({
url: `shopro/activity/groupon/invalidGroupon/id/${that.grouponGoodsData[0].id}`,
loading: true,
type: 'POST',
data: {}
}, function (ret, res) {
Fast.api.close({
data: 123
})
})
},
}
})
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});

查看文件

@@ -0,0 +1,306 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
let vue = new Vue({
el: '#vue',
data: {
activityList: [],
loadingText: '拼命加载中...',
formLoading: false,
// 添加编辑
title: '',
addDialog: false,
// 表格当前页数据
tableData: [],
// 多选数组
multipleSelection: [],
// 搜索条件
key: '',
// 默认每页数据量
pageSize: 20,
// 当前页码
currentPage: 1,
// 默认数据总数
totalCount: 0,
// 列表加载遮罩
listLoading: false,
// 搜索字段
search: {
startTime: '',
endTime: '',
keyword: '',
type: '',
sort: 'id',
aid: '',
is_rob: ''
},
// 字段信息
formData: {},
searchOpt: [{
id: 1,
value: '活动标题'
}, {
id: 2,
value: '用户昵称'
}, {
id: 3,
value: '手机号码'
}, {
id: 4,
value: '商品标题'
}],
isRobOpt: [{
id: 1,
value: '获得'
}, {
id: 2,
value: '未获得'
}],
// 时间格式化
dateFormat: function (row, column) {
var date = row[column.property];
if (date === undefined || date === 0) {
return '';
}
return moment(date * 1000).format("YYYY-MM-DD HH:mm:ss");
}
},
created() {
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.sort);
},
methods: {
// 刷新页面
refreshPage() {
this.search = {
startTime: '',
endTime: '',
keyword: '',
type: '',
sort: 'id',
status: '',
};
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.sort);
},
handleClearSelect(field) {
// 重新加载
this.$set(this.search, field, '');
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.sort);
},
handleClearSearchInp() {
if (this.search.type) {
// 重新加载
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.sort);
}
},
// 提交
submit() {
// 提交
let loading = this.$loading({
lock: true,
text: '正在提交中...',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.3)'
});
$.ajax({
url: 'shopro/activity/rob_order/add',
type: 'POST',
data: this.formData,
success: res => {
loading.close();
if (res.code === 200) {
this.$message.success(res.msg);
this.addDialog = false;
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.sort);
} else {
this.$message.warning(res.msg);
}
}
})
},
// 添加/编辑
openAddDialog(type, item) {
this.addDialog = true;
if (type === 'add') {
this.title = '添加';
this.formData = {
id: 0,
};
} else {
this.title = '编辑';
this.formData = {
id: item.id,
is_ok: item.is_ok.toString()
};
}
},
// 从服务器读取数据
loadData(key, currentPage, pageSize, sort) {
this.listLoading = true;
$.getJSON('shopro/activity/rob_order/index', {
keyword: key,
type: this.search.type,
aid: this.search.aid,
is_rob: this.search.isRob,
start_time: this.search.startTime,
end_time: this.search.endTime,
page: currentPage,
rows: pageSize,
sort: sort,
}, data => {
this.totalCount = data.total;
this.tableData = data.list;
this.activityList = data.activityList;
this.listLoading = false;
});
},
// 排序
sortChange(e) {
},
// 搜索
searchData() {
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.sort);
},
// 每页显示数据量变更
handleSizeChange(val) {
this.pageSize = val;
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.sort);
},
// 页码变更
handleCurrentChange(val) {
this.currentPage = val;
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.sort);
},
// 多选响应
handleSelectionChange(val) {
this.multipleSelection = val;
},
// 抢购状态改变
handleRobStatus(row) {
// 提交
let loading = this.$loading({
lock: true,
text: '正在更改中...',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.3)'
});
$.ajax({
url: 'shopro/activity/rob_order/status',
data: {
id: row.id,
status: row.is_rob
},
type: 'GET',
success: res => {
loading.close();
if (res.code === 200) {
this.$message.success(res.msg);
} else {
this.$message.warning(res.msg);
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.sort);
}
},
error: function (er) {
}
});
},
// 批量删除
del() {
if (this.multipleSelection.length === 0) {
this.$message.warning('请选择至少一个预约进行删除!');
return;
}
var array = [];
this.multipleSelection.forEach((row) => {
array.push(row.id);
});
this.$confirm('您确定要删除所选的预约吗?', '温馨提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let loading = this.$loading({
lock: true,
text: '正在删除中..',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.3)'
});
$.ajax({
url: 'shopro/activity/rob_order/dell',
data: "id=" + array,
type: "POST",
dataType: 'json',
success: res => {
loading.close();
if (res.code === 200) {
this.$message.success(res.msg);
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.sort);
} else {
this.$message.warning(res.msg);
}
},
error: function (er) {
}
});
}).catch(() => {
});
},
// 单条删除
dell(id) {
this.$confirm('您确定要删除此预约吗?', '温馨提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let loading = this.$loading({
lock: true,
text: '正在删除中..',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.3)'
});
$.ajax({
url: 'shopro/activity/rob_order/dell',
data: {
id
},
type: "POST",
dataType: 'json',
success: res => {
loading.close();
if (res.code === 200) {
this.$message.success(res.msg);
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.sort);
} else {
this.$message.warning(res.msg);
}
},
error: function (er) {
}
});
}).catch(() => {
});
},
}
});
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});