Skip to content

Commit 8fb0d9c

Browse files
authored
Create app_version.vue
1 parent c58e021 commit 8fb0d9c

File tree

1 file changed

+153
-0
lines changed

1 file changed

+153
-0
lines changed

client/app_version.vue

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
<template>
2+
<div class="container">
3+
<form role="form" id="selectid"><strong>请选择appID:</strong>
4+
<div class="form-group">
5+
<select v-model="value" @change="changeFuncApp(value)" class="form-control">
6+
<!--<option value="1">1</option>-->
7+
<option v-for="mapp in myapp" v-bind:value="mapp.id">{{mapp.id}}</option>
8+
</select>
9+
<!--<span>Selected: {{ value }}</span>-->
10+
</div>
11+
</form>
12+
<table class="table" >
13+
<caption><strong>APK下版本号</strong></caption>
14+
<thead>
15+
<tr>
16+
<th>id</th>
17+
<th>verCode</th>
18+
<th>apkPath</th>
19+
<th>releaseNotes</th>
20+
<th class="col-2">操作</th>
21+
</tr>
22+
</thead>
23+
<tbody>
24+
<tr class="success">
25+
<td><input v-model="editing.id" placeholder="可以不填"/></td>
26+
<td><input v-model="editing.verCode" placeholder="必须填写"/></td>
27+
<td><input v-model="editing.apkPath" placeholder="APK下载地址"/></td>
28+
<td><input v-model="editing.releaseNotes" placeholder="可以不填,更新说明"/></td>
29+
<td>
30+
<button class="btn btn-info" @click="addApp" >添加</button>
31+
</td>
32+
</tr>
33+
<tr class="info" v-for="app in apps">
34+
<td><input v-model="app.id" @keyup="updateApp(app) | debounce 500"/></td>
35+
<td><input v-model="app.verCode" @keyup="updateApp(app) | debounce 500"/></td>
36+
<td><input v-model="app.apkPath" @keyup="updateApp(app) | debounce 500"/></td>
37+
<td><input v-model="app.releaseNotes" @keyup="updateApp(app) | debounce 500"/></td>
38+
<td>
39+
<button class="btn btn-danger" @click="remove(app)">删除</button>
40+
</td>
41+
</tr>
42+
</tbody>
43+
</table>
44+
</div>
45+
</template>
46+
47+
<script>
48+
var apps;
49+
module.exports = {
50+
props: ["appid"],
51+
http: {
52+
root: '/api/v1'
53+
},
54+
events: {
55+
"remove-app": function (app) {
56+
var self = this;
57+
if (confirm(app.id + "确定删除?")) {
58+
apps.delete({id: app.id}, function (data, status, request) {
59+
self.fetchApps();
60+
});
61+
}
62+
}
63+
},
64+
data: function () {
65+
return {
66+
msg: 'Replaceing',
67+
apps: [],
68+
myapp: [],
69+
value: "",
70+
editing: {
71+
id: "",
72+
verCode: "",
73+
apkPath: "",
74+
releaseNotes: "",
75+
appId: ""
76+
}
77+
}
78+
},
79+
methods: {
80+
addApp: function () {
81+
var self = this;
82+
var verCode = self.editing.verCode;
83+
console.log(verCode);
84+
var apkPath = self.editing.apkPath;
85+
var releaseNotes = self.editing.releaseNotes;
86+
if (verCode) {
87+
apps.save({}, {
88+
verCode: verCode,
89+
apkPath: apkPath,
90+
releaseNotes: releaseNotes
91+
}, function (data, status, request) {
92+
self.editing = data;
93+
self.fetchApps();
94+
});
95+
}
96+
},
97+
updateApp: function (app) {
98+
if (app.id || app.id.length > 0) {
99+
apps.update({id: app.id}, app, function (data, status, request) {
100+
console.log("saved");
101+
})
102+
}
103+
},
104+
selectApp: function (app) {
105+
this.editing = app;
106+
},
107+
fetchApps: function () {
108+
var self = this;
109+
apps.query({}, function (items, status, request) {
110+
self.apps = items;
111+
})
112+
},
113+
remove: function (app) {
114+
this.$dispatch("remove-app", app);
115+
},
116+
changeFuncApp: function (value) {
117+
var self = this;
118+
var access_token = localStorage.getItem('access_token');
119+
console.log(access_token);
120+
// GET request
121+
var httpurl = '/api/v1/apps?access_token=' + access_token;
122+
self.$http({url: httpurl, method: 'GET'}).then(function (response) {
123+
// success callback
124+
self.myapp = response.data;
125+
}, function (response) {
126+
// error callback
127+
});
128+
var access_token = localStorage.getItem('access_token');
129+
var resurl = 'apps/' + value + '/appversions/:id?access_token=' + access_token;
130+
console.log('resurl : ' + resurl);
131+
apps = self.$resource(resurl);
132+
this.fetchApps();
133+
}
134+
},
135+
ready: function () {
136+
var self = this;
137+
var access_token = localStorage.getItem('access_token');
138+
console.log(access_token);
139+
140+
// GET request
141+
var httpurl = '/api/v1/apps?access_token=' + access_token;
142+
self.$http({url: httpurl, method: 'GET'}).then(function (response) {
143+
// success callback
144+
self.myapp = response.data;
145+
console.log(self.myapp[0]);
146+
console.log(JSON.stringify(self.myapp[0]));
147+
self.changeFuncApp(self.myapp[0].id);
148+
}, function (response) {
149+
// error callback
150+
});
151+
}
152+
}
153+
</script>

0 commit comments

Comments
 (0)