lex 1 year ago
parent
commit
a746aeb234

+ 1 - 1
src/App.vue

@@ -28,7 +28,7 @@ export default {
     const locationHash = window.location.hash;
     const locationHash = window.location.hash;
     // console.log(this.$route.path, locationHash);
     // console.log(this.$route.path, locationHash);
     this.loading = true;
     this.loading = true;
-    if (locationHash.indexOf("#/order") == -1) {
+    if (locationHash.indexOf("#/order") == -1 && locationHash.indexOf("#/shareCreation") == -1) {
       try {
       try {
         let Authorization = this.getQueryVariable("Authorization") || null;
         let Authorization = this.getQueryVariable("Authorization") || null;
         if (window.location.hash.indexOf("+") >= 0) {
         if (window.location.hash.indexOf("+") >= 0) {

+ 30 - 0
src/common/common.js

@@ -1,3 +1,5 @@
+import { sessionStorage as storage, localStorage as lStorage } from "js-storage";
+
 export const getRandomKey = () => {
 export const getRandomKey = () => {
   let key = "" + new Date().getTime() + Math.floor(Math.random() * 1000000);
   let key = "" + new Date().getTime() + Math.floor(Math.random() * 1000000);
   return key;
   return key;
@@ -226,4 +228,32 @@ export const getSecondRPM = (second, type) => {
     return mm + ":" + dd;
     return mm + ":" + dd;
   }
   }
 };
 };
+
+// 存登录token
+export const setTempAuthToken = (token) => {
+  storage.set("token", token);
+};
+
+export const setAuthToken = (token) => {
+  storage.set("token", token);
+  lStorage.set("ltoken", token);
+  lStorage.set("userInfo", token);
+  lStorage.set("Authorization", token);
+};
+
+// 删除登录token
+export const removeAuthToken = (type) => {
+  if (type == "IStorage") {
+    lStorage.remove("ltoken");
+    lStorage.remove("userInfo");
+    lStorage.remove("Authorization");
+  } else if (type == "storage") {
+    storage.remove("token");
+  } else {
+    storage.remove("token");
+    lStorage.remove("ltoken");
+    lStorage.remove("userInfo");
+    lStorage.remove("Authorization");
+  }
+};
 export { browser, calcMinute, getSTD, getYMD, getDateList, _debounce, _throttle, validStudentUrl, changeTwoDecimal };
 export { browser, calcMinute, getSTD, getYMD, getDateList, _debounce, _throttle, validStudentUrl, changeTwoDecimal };

+ 5 - 11
src/helpers/request.js

@@ -16,19 +16,11 @@ instance.interceptors.request.use((config) => {
   config.data = cleanDeep(config.data);
   config.data = cleanDeep(config.data);
   config.params = cleanDeep(config.params);
   config.params = cleanDeep(config.params);
 
 
-  if (
-    config.method.toLocaleUpperCase() === "POST" &&
-    config.requestType === "form"
-  ) {
+  if (config.method.toLocaleUpperCase() === "POST" && config.requestType === "form") {
     config.data = qs.stringify(config.data);
     config.data = qs.stringify(config.data);
   }
   }
-  let Authorization =
-    storage.get("token") ||
-    localStorage.getItem("Authorization") ||
-    localStorage.getItem("userInfo");
-  Authorization = Authorization
-    ? Authorization[0].toUpperCase() + Authorization.slice(1)
-    : Authorization;
+  let Authorization = storage.get("token") || localStorage.getItem("Authorization") || localStorage.getItem("userInfo");
+  Authorization = Authorization ? Authorization[0].toUpperCase() + Authorization.slice(1) : Authorization;
   if (config.baseURL !== "/api-auth" && Authorization) {
   if (config.baseURL !== "/api-auth" && Authorization) {
     config.headers = {
     config.headers = {
       ...config.headers,
       ...config.headers,
@@ -54,12 +46,14 @@ instance.interceptors.response.use(
         // 支付时会用到的自定交code
         // 支付时会用到的自定交code
         return res.data;
         return res.data;
       } else if (res.data.code == 403) {
       } else if (res.data.code == 403) {
+        storage.remove("token");
         window.localStorage.removeItem("userInfo"); // 删除用户信息
         window.localStorage.removeItem("userInfo"); // 删除用户信息
         window.localStorage.removeItem("Authorization"); // 删除用户信息
         window.localStorage.removeItem("Authorization"); // 删除用户信息
         // android ios 注册方法
         // android ios 注册方法
         postMessage({
         postMessage({
           api: "login",
           api: "login",
         });
         });
+        return Promise.reject(res.data);
       } else {
       } else {
         if (res.config.hint !== true) {
         if (res.config.hint !== true) {
           Toast(res.data.msg || "接口返回错误");
           Toast(res.data.msg || "接口返回错误");

+ 2 - 1
src/views/creation/api.js

@@ -73,8 +73,9 @@ export const api_userMusicRemove = (params) => {
 };
 };
 
 
 /** 授权验证 */
 /** 授权验证 */
-export const api_verification = (params) => {
+export const api_verification = () => {
   return request.get("/api-auth/checkToken", {
   return request.get("/api-auth/checkToken", {
+    baseURL: "/api-auth",
     headers: {
     headers: {
       "content-type": "application/x-www-form-urlencoded",
       "content-type": "application/x-www-form-urlencoded",
     },
     },

+ 34 - 41
src/views/creation/index-share.vue

@@ -112,7 +112,8 @@ import { getSecondRPM, browser, getGradeCh } from "@/common/common";
 import videoTcplayer from "@/components/video-tcplayer";
 import videoTcplayer from "@/components/video-tcplayer";
 import MEmpty from "@/components/MEmpty";
 import MEmpty from "@/components/MEmpty";
 import { postMessage } from "@/helpers/native-message";
 import { postMessage } from "@/helpers/native-message";
-import { api_userMusicRemove, api_openUserMusicPage, api_userMusicStar, api_openUserMusicDetail } from "./api";
+import { sessionStorage as storage } from "js-storage";
+import { api_userMusicRemove, api_openUserMusicPage, api_userMusicStar, api_openUserMusicDetail, api_verification } from "./api";
 import LoginModel from "./login-model";
 import LoginModel from "./login-model";
 const audioDom = new Audio();
 const audioDom = new Audio();
 audioDom.controls = true;
 audioDom.controls = true;
@@ -153,45 +154,7 @@ export default {
   },
   },
   async mounted() {
   async mounted() {
     document.title = "作品详情";
     document.title = "作品详情";
-    try {
-      const res = await api_openUserMusicDetail(this.id);
-
-      this.musicDetail = res.data || {};
-
-      this.getStarList();
-      // 判断是视频还是音频
-      if (res.data.videoUrl.lastIndexOf("mp4") !== -1) {
-        this.playType = "Video";
-      } else {
-        this.playType = "Audio";
-        // 初始化
-        this.$nextTick(() => {
-          this.initAudio();
-        });
-      }
-    } catch (e) {
-      //
-      if (e.code === 999) {
-        this.messageStatus = true;
-        this.message = e.msg;
-        // this.$dialog
-        //   .alert({
-        //     message: e.msg,
-        //     theme: "round-button",
-        //     confirmButtonColor: "#2DC7AA",
-        //   })
-        //   .then(() => {
-        //     if (browser().isApp) {
-        //       postMessage({
-        //         api: "goBack",
-        //       });
-        //     } else {
-        //       this.$router.back();
-        //     }
-        //   });
-        // return;
-      }
-    }
+    this.__init();
 
 
     // window.onpagehide = function() {
     // window.onpagehide = function() {
     //   if (audioDom) {
     //   if (audioDom) {
@@ -235,6 +198,36 @@ export default {
     }
     }
   },
   },
   methods: {
   methods: {
+    async __init() {
+      if (!this.loginTag) {
+        storage.remove("token");
+        window.localStorage.removeItem("userInfo"); // 删除用户信息
+        window.localStorage.removeItem("Authorization"); // 删除用户信息
+      }
+      try {
+        const res = await api_openUserMusicDetail(this.id);
+
+        this.musicDetail = res.data || {};
+
+        this.getStarList();
+        // 判断是视频还是音频
+        if (res.data.videoUrl.lastIndexOf("mp4") !== -1) {
+          this.playType = "Video";
+        } else {
+          this.playType = "Audio";
+          // 初始化
+          this.$nextTick(() => {
+            this.initAudio();
+          });
+        }
+      } catch (e) {
+        //
+        if (e.code === 999) {
+          this.messageStatus = true;
+          this.message = e.msg;
+        }
+      }
+    },
     onDetail(item) {
     onDetail(item) {
       if (audioDom) {
       if (audioDom) {
         audioDom.currentTime = 0;
         audioDom.currentTime = 0;
@@ -392,7 +385,7 @@ export default {
     }
     }
   },
   },
   watch: {
   watch: {
-    $router(to) {
+    $route(to) {
       this.id = to.query.id;
       this.id = to.query.id;
       this.playType = "";
       this.playType = "";
       this.params.page = 1;
       this.params.page = 1;

+ 1 - 1
src/views/creation/share-model/index.vue

@@ -69,7 +69,7 @@ export default {
     };
     };
   },
   },
   mounted() {
   mounted() {
-    this.config = location.origin + "/mdaya/#/shareCreation?id=" + this.musicDetail.id;
+    this.config = location.origin + location.pathname + "#/shareCreation?id=" + this.musicDetail.id;
   },
   },
   methods: {
   methods: {
     async saveImg() {
     async saveImg() {

+ 1 - 1
vue.config.js

@@ -1,4 +1,4 @@
-let targetUrl = "https://dev.gym.lexiaoya.cn";
+let targetUrl = "https://test.gym.lexiaoya.cn";
 // let targetUrl = "http://192.168.3.26:8000";
 // let targetUrl = "http://192.168.3.26:8000";
 // let targetUrl = 'http://192.168.3.20:8000'
 // let targetUrl = 'http://192.168.3.20:8000'
 // let targetUrl = 'https://online.gym.lexiaoya.cn'
 // let targetUrl = 'https://online.gym.lexiaoya.cn'