|
@@ -0,0 +1,191 @@
|
|
|
+import axios from "axios"
|
|
|
+import { encodeStr } from "@/pass.js"
|
|
|
+import { Base64 } from "js-base64"
|
|
|
+import store from "@/store/index.js"
|
|
|
+import router from "@/router"
|
|
|
+
|
|
|
+// axios.interceptors.response.use(function (response) {
|
|
|
+// // 2xx 范围内的状态码都会触发该函数。
|
|
|
+// if (response.data.code === 5001 || response.data.code === 5002) {
|
|
|
+// store.commit('logoutCallback')
|
|
|
+// router.push({ name: 'HomeView' })
|
|
|
+// return Promise.reject('登录态过期')
|
|
|
+// }
|
|
|
+// return response
|
|
|
+// }, function (error) {
|
|
|
+// return error
|
|
|
+// })
|
|
|
+
|
|
|
+// export function getUserFromStorageIfNeed() {
|
|
|
+// if (!store.state.token || !store.state.userInfo) {
|
|
|
+// const lastToken = localStorage.getItem('token')
|
|
|
+// const lastUserInfoStr = localStorage.getItem('userInfo')
|
|
|
+// if (lastToken && lastUserInfoStr) {
|
|
|
+// store.commit('setLoginStatus', store.getters.loginStatusEnum.wxUser)
|
|
|
+// store.commit('setToken', lastToken)
|
|
|
+// store.commit('setUserInfo', JSON.parse(lastUserInfoStr))
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+// export function reportVisitPage(pageId) {
|
|
|
+// return axios({
|
|
|
+// method: 'post',
|
|
|
+// url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/show/visit/addVisit`,
|
|
|
+// data: {
|
|
|
+// device: 'pc',
|
|
|
+// id: pageId,
|
|
|
+// }
|
|
|
+// })
|
|
|
+// }
|
|
|
+// export async function login(account, password, verifiCode) {
|
|
|
+// const pwdEncrypted = encodeStr(Base64.encode(password))
|
|
|
+// const res = await axios({
|
|
|
+// method: 'post',
|
|
|
+// url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/show/login`,
|
|
|
+// data: {
|
|
|
+// userName: account,
|
|
|
+// password: pwdEncrypted,
|
|
|
+// randCode: verifiCode,
|
|
|
+// },
|
|
|
+// })
|
|
|
+// if (res.data.code !== 0) {
|
|
|
+// store.commit('setLoginStatus', false)
|
|
|
+// throw (`登录失败:${res.data.msg}`)
|
|
|
+// } else {
|
|
|
+// store.commit('setLoginStatus', true)
|
|
|
+// store.commit('setToken', res.data.data.token)
|
|
|
+// store.commit('setUserInfo', res.data.data.user)
|
|
|
+// }
|
|
|
+// }
|
|
|
+// export async function logout() {
|
|
|
+// const res = await axios({
|
|
|
+// method: 'get',
|
|
|
+// url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/cms/game/logout`,
|
|
|
+// headers: {
|
|
|
+// token: store.state.token,
|
|
|
+// }
|
|
|
+// })
|
|
|
+// if (res?.data?.code === 0) {
|
|
|
+// store.commit('logoutCallback')
|
|
|
+// }
|
|
|
+// }
|
|
|
+// export async function checkLoginStatusAndProcess() {
|
|
|
+// const lastToken = localStorage.getItem('token')
|
|
|
+// const lastUserInfoStr = localStorage.getItem('userInfo')
|
|
|
+// if (lastToken && lastUserInfoStr) {
|
|
|
+// const res = await axios({
|
|
|
+// method: 'get',
|
|
|
+// url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/show/checkLogin`,
|
|
|
+// headers: {
|
|
|
+// token: lastToken,
|
|
|
+// }
|
|
|
+// })
|
|
|
+// if (res?.data?.code === 0 && res?.data?.data) {
|
|
|
+// store.commit('setLoginStatus', store.getters.loginStatusEnum.notLogin)
|
|
|
+// store.commit('setToken', lastToken)
|
|
|
+// store.commit('setUserInfo', JSON.parse(lastUserInfoStr))
|
|
|
+// return true
|
|
|
+// } else {
|
|
|
+// store.commit('logoutCallback')
|
|
|
+// return false
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// store.commit('logoutCallback')
|
|
|
+// return false
|
|
|
+// }
|
|
|
+// }
|
|
|
+// export async function sendEmail(address) {
|
|
|
+// const res = await axios({
|
|
|
+// method: 'post',
|
|
|
+// url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/show/sendEmail`,
|
|
|
+// data: {
|
|
|
+// userName: address,
|
|
|
+// },
|
|
|
+// })
|
|
|
+// if (res.data.code !== 0) {
|
|
|
+// throw (`${res.data.msg}`)
|
|
|
+// } else {
|
|
|
+// return
|
|
|
+// }
|
|
|
+// }
|
|
|
+// export async function signUp(account, phone, password, verifiCode) {
|
|
|
+// const pwdEncrypted = encodeStr(Base64.encode(password))
|
|
|
+// const res = await axios({
|
|
|
+// method: 'post',
|
|
|
+// url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/show/register`,
|
|
|
+// data: {
|
|
|
+// password: pwdEncrypted,
|
|
|
+// phone,
|
|
|
+// userName: account,
|
|
|
+// verifyPassword: pwdEncrypted,
|
|
|
+// randCode: verifiCode,
|
|
|
+// },
|
|
|
+// })
|
|
|
+// if (res.data.code !== 0) {
|
|
|
+// throw (`注册失败:${res.data.msg}`)
|
|
|
+// } else {
|
|
|
+// return
|
|
|
+// }
|
|
|
+// }
|
|
|
+// export async function findPassowrd(account, phone, verifiCode) {
|
|
|
+// const res = await axios({
|
|
|
+// method: 'post',
|
|
|
+// url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/show/findPass`,
|
|
|
+// data: {
|
|
|
+// phone,
|
|
|
+// userName: account,
|
|
|
+// randCode: verifiCode,
|
|
|
+// },
|
|
|
+// })
|
|
|
+// if (res.data.code !== 0) {
|
|
|
+// throw (`找回密码失败:${res.data.msg}`)
|
|
|
+// } else {
|
|
|
+// return
|
|
|
+// }
|
|
|
+// }
|
|
|
+// export async function changePassword(newPassword, oldPassword, verifiCode) {
|
|
|
+// const pwdNewEncrypted = encodeStr(Base64.encode(newPassword))
|
|
|
+// const pwdOldEncrypted = encodeStr(Base64.encode(oldPassword))
|
|
|
+// const res = await axios({
|
|
|
+// method: 'post',
|
|
|
+// url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/cms/game/update/pass`,
|
|
|
+// data: {
|
|
|
+// newPassword: pwdNewEncrypted,
|
|
|
+// oldPassword: pwdOldEncrypted,
|
|
|
+// randCode: verifiCode,
|
|
|
+// },
|
|
|
+// headers: {
|
|
|
+// token: store.state.token,
|
|
|
+// }
|
|
|
+// })
|
|
|
+// if (res.data.code !== 0) {
|
|
|
+// throw (`密码修改失败:${res.data.msg}`)
|
|
|
+// } else {
|
|
|
+// return
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+// export function uploadBlob(blob) {
|
|
|
+// const file = new window.File(
|
|
|
+// [blob],
|
|
|
+// '锡善云城-证书.jpg',
|
|
|
+// { type: 'image/jpeg', }
|
|
|
+// )
|
|
|
+
|
|
|
+// const formData = new FormData()
|
|
|
+// formData.append("type", 'img')
|
|
|
+// formData.append("file", file)
|
|
|
+
|
|
|
+// return axios({
|
|
|
+// method: 'post',
|
|
|
+// url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/cms/game/upload`,
|
|
|
+// headers: {
|
|
|
+// token: store.state.token,
|
|
|
+// 'Content-Type': 'multipart/form-data',
|
|
|
+// },
|
|
|
+// data: formData
|
|
|
+// }).then((res) => {
|
|
|
+// return res.data.data.filePath
|
|
|
+// })
|
|
|
+// }
|