operations.shopsVersionUpdate.Index.js
5.43 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
webpackJsonp([133],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/**
* Created by ty on 2016/6/3.
*/
var $ = __webpack_require__(1),
common = __webpack_require__(2);
var VersionData = {};
const iphoneUrl = "itms-services://?action=download-manifest&url=https://cdn.yoho.cn/applist/yohovendor/ios/manifest.plist";
new common.dropDown({el: "#clientType"});
var g = new common.grid({
el: "#list-content",
parms: function () {
return {
appVersion: common.util.__input('appVersion'),
clientType: common.util.__input('clientType')
};
},
columns: [
{display: "ID", name: "id"},
{display: "APP版本", name: "version"},
{display: "提醒内容", name: "content"},
{display: "跳转链接", name: "url"},
{display: "客户端类型", name: "clientType", render: function(item) {
if(item.clientType != null && item.clientType.trim() != "") {
var platform = item.clientType;
var temp = platform.replace("iphone", "IOS手机").replace("ipad", "IOS Pad")
.replace("android", "安卓手机").replace("androidpad", "安卓Pad")
.replace(/,/g, " ");
return temp;
}
}},
{display: "状态", name: "status", render: function(item) {
if(item.status == 1) {
return "已开启";
} else if(item.status == 0) {
return "已关闭";
}
}},
{
display: "操作",name: "", render: function (item) {
var arr = [];
if(item.status == 0) {
arr.push('<a class="btn btn-success btn-xs change-status" data-index="' + item.__index + '">开启</a>');
} else {
arr.push('<a class="btn btn-danger btn-xs change-status" data-index="' + item.__index + '">关闭</a>');
}
arr.push('<a class="btn btn-warning btn-xs del" data-index="' + item.__index + '">删除</a>');
return arr.join("");
}
}
]
});
g.init('/AppVersionRest/getAppVersionList');
var Bll = {
toast:function(url, item, hint) {
var e = new common.edit2("#base-form");
var dialog = common.dialog.confirm(hint,
common.util.__template2($("#template").html(), item),
function() {
if(e.validate()) {
VersionData.status = $("#status").val();
VersionData.url = $("#url").val();
console.log(VersionData);
common.util.__ajax({
url: url,
data: VersionData
}, function (res) {
dialog.close();
g.reload();
});
}
return false;
});
$("#appFile").ajaxfileupload({
'action': '/ajax/upload',
'params': {
bucket: "yohobuyzip",
__type: "fileupload-upload"
},
onComplete: function (response) {
if (response.status && response.code == 200) {
if(response.data){
$("#url").attr("value", response.data);
}
} else {
common.util.__tip(response.message);
}
},
valid_extensions: ["ipa", "apk"]
})
new common.dropDown({el: "#types"});
e.bind();
}
};
$(document).on('click', '#addAppVersion', function() {
VersionData = {};
Bll.toast("/AppVersionRest/setAppVersion", VersionData, "上传APP包");
});
$(document).on("change", ".observe", function () {
var name = $(this).data("field");
var val = $(this).val();
VersionData[name] = val;
if(name == "clientType") {
if (val == "iphone" || val == "ipad") {
$("#url").val(iphoneUrl);
$("#url").attr("disabled","disabled");
$("#appFile").hide();
$("#fileBtn").hide();
} else if(val == "android") {
$("#url").val("http://cdn.yoho.cn/applist/yohovendor/android/yhvendor081902.apk");
$("#appFile").show();
$("#fileBtn").show();
$("#url").removeAttr("disabled");
}else{
$("#url").val("");
$("#url").attr("disabled","disabled");
$("#appFile").hide();
$("#fileBtn").hide();
}
}
});
$(document).on("click", ".change-status", function () {
VersionData = g.rows[$(this).data("index")];
VersionData.status = 1 - VersionData.status;
common.util.__ajax({
url: "/AppVersionRest/editAppVersion",
data: {id: VersionData.id, status: VersionData.status}
}, function (res) {
g.reload();
});
});
$(document).on("click", ".del", function () {
VersionData = g.rows[$(this).data("index")];
common.dialog.confirm("警告",
"确认删除?",
function() {
common.util.__ajax({
url: "/AppVersionRest/delAppVersion",
data: {id: VersionData.id}
}, function () {
g.reload();
});
});
});
$(document).on("click", "#filter-btn", function () {
g.reload(1);
});
/***/ }
]);