Commit 068fece20a3efce3118b7d88fd98c9ef223b98fe

Authored by 杨泽宇
1 parent 7f070d45

change rules and category

Showing 1 changed file with 81 additions and 27 deletions
src/js/audios.js
1 1 import * as all from "./config";
2   -require('./../css/test.css')
  2 +require("./../css/test.css");
3 3 // Init Vue
4 4 const Audio = {
5 5 data() {
... ... @@ -51,6 +51,15 @@ const Audio = {
51 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 65 uploadUrl: "",
... ... @@ -68,11 +77,33 @@ const Audio = {
68 77 // 作品类型为【词】的时候可以不上传文件
69 78 handleChange(data) {
70 79 if (data == 1279) {
  80 + // 优秀作词榜
71 81 this.rules.audioFile[0].required = false;
72 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 103 this.rules.audioFile[0].required = true;
75 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 173 const fileSaveObj = {
143 174 videoId: null,
144 175  
145   - multipleCategory: 100005,
146   - // tag: 'test',
  176 + multipleCategory: 100005 + "/" + this.getCategoryText(this.form.channelId),
147 177 tag: this.getChannelText(this.form.channelId),
148 178 ts: this.getTs(),
149 179 timestamp: this.getTimeStamp(),
... ... @@ -155,7 +185,7 @@ const Audio = {
155 185 fileSize: this.form.audioFile.raw.size,
156 186 ts: this.getTs(),
157 187 timestamp: this.getTimeStamp(),
158   - multipleCategory: 100005,
  188 + multipleCategory: 100005 + "/" + this.getCategoryText(this.form.channelId),
159 189 // masterId: all.secretUrls.masterIdDev,
160 190 masterId: all.secretUrls.masterIdMaster,
161 191 };
... ... @@ -197,21 +227,27 @@ const Audio = {
197 227 params: all.parseQueryString(apiStringSignDone),
198 228 })
199 229 .then((res) => {
200   - let apiComplete = all.secretUrls.base + all.secretUrls.callback;
  230 + let apiComplete =
  231 + all.secretUrls.base + all.secretUrls.callback;
201 232 let apiStringSignComplete = all.signFunction(
202 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 240 return all.request({
206 241 url: apiComplete,
207   - method: 'get',
  242 + method: "get",
208 243 params: all.parseQueryString(apiStringSignComplete),
209   - })
210   - }).then(data => {
  244 + });
  245 + })
  246 + .then((data) => {
211 247 that.form.audioId = data.data.data.obj;
212 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 260 return this.getToken();
225 261 })
226 262 .then((d) => {
227   - if (d && d.data && typeof d.data == 'string') {
  263 + if (d && d.data && typeof d.data == "string") {
228 264 this.token = d.data;
229   - }
  265 + }
230 266 return this.initMd5(this.form.audioFile.raw);
231 267 })
232 268 .then((n) => {
... ... @@ -251,7 +287,12 @@ const Audio = {
251 287 });
252 288 })
253 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 296 fileSaveObj.videoId = res.data.data.obj.vid;
256 297 fileWholeObj.fileKey = res.data.data.obj.originPath;
257 298 all.putExtra.params["x:name"] = fileWholeObj.fileKey;
... ... @@ -292,8 +333,8 @@ const Audio = {
292 333 getParamsList(params) {
293 334 let list = [];
294 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 338 } else {
298 339 list.push(`${i}=${params[i]}`);
299 340 }
... ... @@ -311,18 +352,31 @@ const Audio = {
311 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 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 382 // 获取认证token
... ... @@ -344,7 +398,7 @@ const Audio = {
344 398 all
345 399 .request({
346 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 402 method: "post",
349 403 params: this.form,
350 404 withCredentials: true,
... ... @@ -369,7 +423,7 @@ const Audio = {
369 423 })
370 424 .catch((error) => {
371 425 console.log(error);
372   - setTimeout(() => {
  426 + setTimeout(() => {
373 427 // console.log("jump");
374 428 window.location.replace("./failed.html");
375 429 }, 1000);
... ...