Commit 068fece20a3efce3118b7d88fd98c9ef223b98fe
1 parent
7f070d45
change rules and category
Showing
1 changed file
with
81 additions
and
27 deletions
src/js/audios.js
| 1 | import * as all from "./config"; | 1 | import * as all from "./config"; |
| 2 | -require('./../css/test.css') | 2 | +require("./../css/test.css"); |
| 3 | // Init Vue | 3 | // Init Vue |
| 4 | const Audio = { | 4 | const Audio = { |
| 5 | data() { | 5 | data() { |
| @@ -51,6 +51,15 @@ const Audio = { | @@ -51,6 +51,15 @@ const Audio = { | ||
| 51 | message: "请上传音频文件以获取音频ID", | 51 | message: "请上传音频文件以获取音频ID", |
| 52 | }, | 52 | }, |
| 53 | ], | 53 | ], |
| 54 | + singer: [ | ||
| 55 | + { required: false, trigger: "change", message: "请输入歌手名字" }, | ||
| 56 | + ], | ||
| 57 | + lyricist: [ | ||
| 58 | + { required: false, trigger: "change", message: "请输入作词人名字" }, | ||
| 59 | + ], | ||
| 60 | + songwriter: [ | ||
| 61 | + { required: false, trigger: "change", message: "请输入作曲人名字" }, | ||
| 62 | + ], | ||
| 54 | }, | 63 | }, |
| 55 | 64 | ||
| 56 | uploadUrl: "", | 65 | uploadUrl: "", |
| @@ -68,11 +77,33 @@ const Audio = { | @@ -68,11 +77,33 @@ const Audio = { | ||
| 68 | // 作品类型为【词】的时候可以不上传文件 | 77 | // 作品类型为【词】的时候可以不上传文件 |
| 69 | handleChange(data) { | 78 | handleChange(data) { |
| 70 | if (data == 1279) { | 79 | if (data == 1279) { |
| 80 | + // 优秀作词榜 | ||
| 71 | this.rules.audioFile[0].required = false; | 81 | this.rules.audioFile[0].required = false; |
| 72 | this.rules.audioId[0].required = false; | 82 | this.rules.audioId[0].required = false; |
| 73 | - } else { | 83 | + this.rules.singer[0].required = false; |
| 84 | + this.rules.songwriter[0].required = false; | ||
| 85 | + this.rules.lyricist[0].required = true; | ||
| 86 | + } else if (data == 1278) { | ||
| 87 | + // 成品 | ||
| 88 | + this.rules.singer[0].required = true; | ||
| 89 | + this.rules.audioFile[0].required = true; | ||
| 90 | + this.rules.audioId[0].required = true; | ||
| 91 | + this.rules.lyricist[0].required = false; | ||
| 92 | + this.rules.songwriter[0].required = false; | ||
| 93 | + } else if (data == 1280) { | ||
| 94 | + // 作曲 | ||
| 95 | + this.rules.songwriter[0].required = true; | ||
| 96 | + this.rules.audioFile[0].required = true; | ||
| 97 | + this.rules.audioId[0].required = true; | ||
| 98 | + this.rules.singer[0].required = false; | ||
| 99 | + this.rules.lyricist[0].required = false; | ||
| 100 | + } else if (data == 1281) { | ||
| 101 | + // 其他 | ||
| 102 | + this.rules.songwriter[0].required = false; | ||
| 74 | this.rules.audioFile[0].required = true; | 103 | this.rules.audioFile[0].required = true; |
| 75 | this.rules.audioId[0].required = true; | 104 | this.rules.audioId[0].required = true; |
| 105 | + this.rules.singer[0].required = false; | ||
| 106 | + this.rules.lyricist[0].required = false; | ||
| 76 | } | 107 | } |
| 77 | }, | 108 | }, |
| 78 | // 文件数量超上限响应 | 109 | // 文件数量超上限响应 |
| @@ -142,8 +173,7 @@ const Audio = { | @@ -142,8 +173,7 @@ const Audio = { | ||
| 142 | const fileSaveObj = { | 173 | const fileSaveObj = { |
| 143 | videoId: null, | 174 | videoId: null, |
| 144 | 175 | ||
| 145 | - multipleCategory: 100005, | ||
| 146 | - // tag: 'test', | 176 | + multipleCategory: 100005 + "/" + this.getCategoryText(this.form.channelId), |
| 147 | tag: this.getChannelText(this.form.channelId), | 177 | tag: this.getChannelText(this.form.channelId), |
| 148 | ts: this.getTs(), | 178 | ts: this.getTs(), |
| 149 | timestamp: this.getTimeStamp(), | 179 | timestamp: this.getTimeStamp(), |
| @@ -155,7 +185,7 @@ const Audio = { | @@ -155,7 +185,7 @@ const Audio = { | ||
| 155 | fileSize: this.form.audioFile.raw.size, | 185 | fileSize: this.form.audioFile.raw.size, |
| 156 | ts: this.getTs(), | 186 | ts: this.getTs(), |
| 157 | timestamp: this.getTimeStamp(), | 187 | timestamp: this.getTimeStamp(), |
| 158 | - multipleCategory: 100005, | 188 | + multipleCategory: 100005 + "/" + this.getCategoryText(this.form.channelId), |
| 159 | // masterId: all.secretUrls.masterIdDev, | 189 | // masterId: all.secretUrls.masterIdDev, |
| 160 | masterId: all.secretUrls.masterIdMaster, | 190 | masterId: all.secretUrls.masterIdMaster, |
| 161 | }; | 191 | }; |
| @@ -197,21 +227,27 @@ const Audio = { | @@ -197,21 +227,27 @@ const Audio = { | ||
| 197 | params: all.parseQueryString(apiStringSignDone), | 227 | params: all.parseQueryString(apiStringSignDone), |
| 198 | }) | 228 | }) |
| 199 | .then((res) => { | 229 | .then((res) => { |
| 200 | - let apiComplete = all.secretUrls.base + all.secretUrls.callback; | 230 | + let apiComplete = |
| 231 | + all.secretUrls.base + all.secretUrls.callback; | ||
| 201 | let apiStringSignComplete = all.signFunction( | 232 | let apiStringSignComplete = all.signFunction( |
| 202 | apiComplete, | 233 | apiComplete, |
| 203 | - that.getParamsList({ ...fileBaseObj, ...fileSaveObj, ...{timestamp: that.getTimeStamp()} }) | 234 | + that.getParamsList({ |
| 235 | + ...fileBaseObj, | ||
| 236 | + ...fileSaveObj, | ||
| 237 | + ...{ timestamp: that.getTimeStamp() }, | ||
| 238 | + }) | ||
| 204 | ); | 239 | ); |
| 205 | return all.request({ | 240 | return all.request({ |
| 206 | url: apiComplete, | 241 | url: apiComplete, |
| 207 | - method: 'get', | 242 | + method: "get", |
| 208 | params: all.parseQueryString(apiStringSignComplete), | 243 | params: all.parseQueryString(apiStringSignComplete), |
| 209 | - }) | ||
| 210 | - }).then(data => { | 244 | + }); |
| 245 | + }) | ||
| 246 | + .then((data) => { | ||
| 211 | that.form.audioId = data.data.data.obj; | 247 | that.form.audioId = data.data.data.obj; |
| 212 | that.percent = 100; | 248 | that.percent = 100; |
| 213 | - that.postCms() | ||
| 214 | - }) | 249 | + that.postCms(); |
| 250 | + }); | ||
| 215 | }, | 251 | }, |
| 216 | }; | 252 | }; |
| 217 | 253 | ||
| @@ -224,9 +260,9 @@ const Audio = { | @@ -224,9 +260,9 @@ const Audio = { | ||
| 224 | return this.getToken(); | 260 | return this.getToken(); |
| 225 | }) | 261 | }) |
| 226 | .then((d) => { | 262 | .then((d) => { |
| 227 | - if (d && d.data && typeof d.data == 'string') { | 263 | + if (d && d.data && typeof d.data == "string") { |
| 228 | this.token = d.data; | 264 | this.token = d.data; |
| 229 | - } | 265 | + } |
| 230 | return this.initMd5(this.form.audioFile.raw); | 266 | return this.initMd5(this.form.audioFile.raw); |
| 231 | }) | 267 | }) |
| 232 | .then((n) => { | 268 | .then((n) => { |
| @@ -251,7 +287,12 @@ const Audio = { | @@ -251,7 +287,12 @@ const Audio = { | ||
| 251 | }); | 287 | }); |
| 252 | }) | 288 | }) |
| 253 | .then((res) => { | 289 | .then((res) => { |
| 254 | - if (res && res.data && res.data.data && res.data.data.code == 0) { | 290 | + if ( |
| 291 | + res && | ||
| 292 | + res.data && | ||
| 293 | + res.data.data && | ||
| 294 | + res.data.data.code == 0 | ||
| 295 | + ) { | ||
| 255 | fileSaveObj.videoId = res.data.data.obj.vid; | 296 | fileSaveObj.videoId = res.data.data.obj.vid; |
| 256 | fileWholeObj.fileKey = res.data.data.obj.originPath; | 297 | fileWholeObj.fileKey = res.data.data.obj.originPath; |
| 257 | all.putExtra.params["x:name"] = fileWholeObj.fileKey; | 298 | all.putExtra.params["x:name"] = fileWholeObj.fileKey; |
| @@ -292,8 +333,8 @@ const Audio = { | @@ -292,8 +333,8 @@ const Audio = { | ||
| 292 | getParamsList(params) { | 333 | getParamsList(params) { |
| 293 | let list = []; | 334 | let list = []; |
| 294 | for (let i in params) { | 335 | for (let i in params) { |
| 295 | - if(i == 'hash' || i == 'key' || i == 'x:name') { | ||
| 296 | - list.push(`${i}=${encodeURI(params[i])}`) | 336 | + if (i == "hash" || i == "key" || i == "x:name") { |
| 337 | + list.push(`${i}=${encodeURI(params[i])}`); | ||
| 297 | } else { | 338 | } else { |
| 298 | list.push(`${i}=${params[i]}`); | 339 | list.push(`${i}=${params[i]}`); |
| 299 | } | 340 | } |
| @@ -311,18 +352,31 @@ const Audio = { | @@ -311,18 +352,31 @@ const Audio = { | ||
| 311 | Math.floor(Math.random() * 10000).toString() | 352 | Math.floor(Math.random() * 10000).toString() |
| 312 | ); | 353 | ); |
| 313 | }, | 354 | }, |
| 355 | + // 通过作品类型id获取作品分类,用于上传视频的??参数 | ||
| 356 | + getCategoryText(id) { | ||
| 357 | + if (id == 1278) { | ||
| 358 | + return "533"; | ||
| 359 | + } | ||
| 360 | + if (id == 1280) { | ||
| 361 | + return "534"; | ||
| 362 | + } | ||
| 363 | + if (id == 1281) { | ||
| 364 | + return "532"; | ||
| 365 | + } | ||
| 366 | + }, | ||
| 367 | + // 通过作品类型id获取作品类型,用于上传视频的tag | ||
| 314 | getChannelText(id) { | 368 | getChannelText(id) { |
| 315 | - if(id == 1278) { | ||
| 316 | - return '热歌榜' | 369 | + if (id == 1278) { |
| 370 | + return "热歌榜"; | ||
| 317 | } | 371 | } |
| 318 | - if(id == 1279) { | ||
| 319 | - return '优秀作词榜' | 372 | + if (id == 1279) { |
| 373 | + return "优秀作词榜"; | ||
| 320 | } | 374 | } |
| 321 | - if(id == 1280) { | ||
| 322 | - return '优秀作曲榜' | 375 | + if (id == 1280) { |
| 376 | + return "优秀作曲榜"; | ||
| 323 | } | 377 | } |
| 324 | - if(id == 1281) { | ||
| 325 | - return '其他' | 378 | + if (id == 1281) { |
| 379 | + return "其他"; | ||
| 326 | } | 380 | } |
| 327 | }, | 381 | }, |
| 328 | // 获取认证token | 382 | // 获取认证token |
| @@ -344,7 +398,7 @@ const Audio = { | @@ -344,7 +398,7 @@ const Audio = { | ||
| 344 | all | 398 | all |
| 345 | .request({ | 399 | .request({ |
| 346 | // url: "http://cmstest.cnlive.com:8768/contentApi/audioSave", | 400 | // url: "http://cmstest.cnlive.com:8768/contentApi/audioSave", |
| 347 | - url: 'https://cms.cnlive.com/api/contentApi/audioSave', | 401 | + url: "https://cms.cnlive.com/api/contentApi/audioSave", |
| 348 | method: "post", | 402 | method: "post", |
| 349 | params: this.form, | 403 | params: this.form, |
| 350 | withCredentials: true, | 404 | withCredentials: true, |
| @@ -369,7 +423,7 @@ const Audio = { | @@ -369,7 +423,7 @@ const Audio = { | ||
| 369 | }) | 423 | }) |
| 370 | .catch((error) => { | 424 | .catch((error) => { |
| 371 | console.log(error); | 425 | console.log(error); |
| 372 | - setTimeout(() => { | 426 | + setTimeout(() => { |
| 373 | // console.log("jump"); | 427 | // console.log("jump"); |
| 374 | window.location.replace("./failed.html"); | 428 | window.location.replace("./failed.html"); |
| 375 | }, 1000); | 429 | }, 1000); |