shop.ShopCategory.Index.js
2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
webpackJsonp([16],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var $ = __webpack_require__(1),
common = __webpack_require__(2);
var currentShopCategoryNum = 0; //店铺销售类目数量
var Bll = {
init: function () {
common.util.__ajax({
url:'/shops/shopCategory/list',
data: {}
}, function (res) {
var data = res.data;
console.log(data);
currentShopCategoryNum = data.length;
$('#showCategory').html(common.util.__template2($("#listTemplate").html(),{data:data})).show();
},true)
},
//新增,编辑销售类目名称
toast: function (type, url, name, id) {
var self = this;
common.dialog.confirm(
type == 0 ? "新增销售类目" : "编辑销售类目",
common.util.__template2($("#addTemplate").html(),{data:name}),
function () {
var categoryName = $('#categoryName').val();
if($.trim(categoryName) != ''){
common.util.__ajax({
url:url,
data: {
categoryId: id,
categoryName: categoryName
}
},function (rs) {
self.init();
});
}else{
common.util.__tip('店铺销售类目名称不能为空!');
return false;
}
}
)
},
//删除销售类目
deleteCategory: function (categoryId) {
var self = this;
common.util.__ajax({
url:'/shops/shopCategory/delete',
data: {
categoryId:categoryId
}
}, function (res) {
self.init();
})
}
};
Bll.init();
//新增类目
$(document).on('click', '.addBtn', function () {
if(currentShopCategoryNum < 20){
Bll.toast(0, '/shops/shopCategory/add', '', null);
}else {
common.util.__tip('店铺最多添加只能添加20个销售类目!');
}
});
//编辑类目名称
$(document).on('click', '.editCategory', function () {
var categoryName = $(this).parent().parent().find('td').eq(1).text();
var categoryId = $(this).data('categoryid');
Bll.toast(1, '/shops/shopCategory/update', categoryName, categoryId);
});
//删除类目
$(document).on('click', '.deleteBtn', function () {
var categoryName = $(this).parent().parent().find('td').eq(1).text();
var categoryId = $(this).data('categoryid');
common.dialog.confirm(
"删除店铺销售类目",
"你确定<b style='color: #ff0000'> 删除 </b>销售类目<b style='color:#428bca'> "+categoryName+" </b>么?",
function () {
Bll.deleteCategory(categoryId);
}
)
});
/***/ }
]);