|
@@ -16,16 +16,28 @@ axios.interceptors.response.use(function (response) {
|
|
|
return 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', true)
|
|
|
|
|
+ store.commit('setToken', lastToken)
|
|
|
|
|
+ store.commit('setUserInfo', JSON.parse(lastUserInfoStr))
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// export async function reportVisit() {
|
|
// export async function reportVisit() {
|
|
|
// const res = await axios({
|
|
// const res = await axios({
|
|
|
// method: 'get',
|
|
// method: 'get',
|
|
|
-// url: `${process.env.VUE_APP_API_PREFIX}/api/show/addVisit`,
|
|
|
|
|
|
|
+// url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/show/addVisit`,
|
|
|
// })
|
|
// })
|
|
|
// }
|
|
// }
|
|
|
// export async function fetchVisitInfo() {
|
|
// export async function fetchVisitInfo() {
|
|
|
// const res = await axios({
|
|
// const res = await axios({
|
|
|
// method: 'get',
|
|
// method: 'get',
|
|
|
-// url: `${process.env.VUE_APP_API_PREFIX}/api/show/getVisit`,
|
|
|
|
|
|
|
+// url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/show/getVisit`,
|
|
|
// })
|
|
// })
|
|
|
// return res.data.data
|
|
// return res.data.data
|
|
|
// }
|
|
// }
|
|
@@ -33,7 +45,7 @@ export async function login(account, password) {
|
|
|
const pwdEncrypted = encodeStr(Base64.encode(password))
|
|
const pwdEncrypted = encodeStr(Base64.encode(password))
|
|
|
const res = await axios({
|
|
const res = await axios({
|
|
|
method: 'post',
|
|
method: 'post',
|
|
|
- url: `${process.env.VUE_APP_API_PREFIX}/api/show/login`,
|
|
|
|
|
|
|
+ url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/show/login`,
|
|
|
data: {
|
|
data: {
|
|
|
userName: account,
|
|
userName: account,
|
|
|
password: pwdEncrypted,
|
|
password: pwdEncrypted,
|
|
@@ -51,7 +63,7 @@ export async function login(account, password) {
|
|
|
export async function logout() {
|
|
export async function logout() {
|
|
|
const res = await axios({
|
|
const res = await axios({
|
|
|
method: 'get',
|
|
method: 'get',
|
|
|
- url: `${process.env.VUE_APP_API_PREFIX}/api/cms/game/logout`,
|
|
|
|
|
|
|
+ url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/cms/game/logout`,
|
|
|
headers: {
|
|
headers: {
|
|
|
token: store.state.token,
|
|
token: store.state.token,
|
|
|
}
|
|
}
|
|
@@ -66,7 +78,7 @@ export async function checkLoginStatusAndProcess() {
|
|
|
if (lastToken && lastUserInfoStr) {
|
|
if (lastToken && lastUserInfoStr) {
|
|
|
const res = await axios({
|
|
const res = await axios({
|
|
|
method: 'get',
|
|
method: 'get',
|
|
|
- url: `${process.env.VUE_APP_API_PREFIX}/api/show/checkLogin`,
|
|
|
|
|
|
|
+ url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/show/checkLogin`,
|
|
|
headers: {
|
|
headers: {
|
|
|
token: lastToken,
|
|
token: lastToken,
|
|
|
}
|
|
}
|
|
@@ -89,7 +101,7 @@ export async function signUp(account, phone, password) {
|
|
|
const pwdEncrypted = encodeStr(Base64.encode(password))
|
|
const pwdEncrypted = encodeStr(Base64.encode(password))
|
|
|
const res = await axios({
|
|
const res = await axios({
|
|
|
method: 'post',
|
|
method: 'post',
|
|
|
- url: `${process.env.VUE_APP_API_PREFIX}/api/show/register`,
|
|
|
|
|
|
|
+ url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/show/register`,
|
|
|
data: {
|
|
data: {
|
|
|
password: pwdEncrypted,
|
|
password: pwdEncrypted,
|
|
|
phone,
|
|
phone,
|
|
@@ -106,7 +118,7 @@ export async function signUp(account, phone, password) {
|
|
|
export async function findPassowrd(account, phone) {
|
|
export async function findPassowrd(account, phone) {
|
|
|
const res = await axios({
|
|
const res = await axios({
|
|
|
method: 'post',
|
|
method: 'post',
|
|
|
- url: `${process.env.VUE_APP_API_PREFIX}/api/show/findPass`,
|
|
|
|
|
|
|
+ url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/show/findPass`,
|
|
|
data: {
|
|
data: {
|
|
|
phone,
|
|
phone,
|
|
|
userName: account,
|
|
userName: account,
|
|
@@ -123,7 +135,7 @@ export async function changePassword(newPassword, oldPassword) {
|
|
|
const pwdOldEncrypted = encodeStr(Base64.encode(oldPassword))
|
|
const pwdOldEncrypted = encodeStr(Base64.encode(oldPassword))
|
|
|
const res = await axios({
|
|
const res = await axios({
|
|
|
method: 'post',
|
|
method: 'post',
|
|
|
- url: `${process.env.VUE_APP_API_PREFIX}/api/cms/game/update/pass`,
|
|
|
|
|
|
|
+ url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/cms/game/update/pass`,
|
|
|
data: {
|
|
data: {
|
|
|
newPassword: pwdNewEncrypted,
|
|
newPassword: pwdNewEncrypted,
|
|
|
oldPassword: pwdOldEncrypted,
|
|
oldPassword: pwdOldEncrypted,
|
|
@@ -142,7 +154,7 @@ export async function changePassword(newPassword, oldPassword) {
|
|
|
export async function getGameRuleList() {
|
|
export async function getGameRuleList() {
|
|
|
const res = await axios({
|
|
const res = await axios({
|
|
|
method: 'get',
|
|
method: 'get',
|
|
|
- url: `${process.env.VUE_APP_API_PREFIX}/api/show/rule/getList?rnd=${Math.random()}`,
|
|
|
|
|
|
|
+ url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/show/rule/getList?rnd=${Math.random()}`,
|
|
|
params: {
|
|
params: {
|
|
|
type: 'game',
|
|
type: 'game',
|
|
|
},
|
|
},
|
|
@@ -156,7 +168,7 @@ export async function getGameRuleList() {
|
|
|
export async function getScoreLimit() {
|
|
export async function getScoreLimit() {
|
|
|
const res = await axios({
|
|
const res = await axios({
|
|
|
method: 'get',
|
|
method: 'get',
|
|
|
- url: `${process.env.VUE_APP_API_PREFIX}/api/show/rule/getList?rnd=${Math.random()}`,
|
|
|
|
|
|
|
+ url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/show/rule/getList?rnd=${Math.random()}`,
|
|
|
params: {
|
|
params: {
|
|
|
type: 'day',
|
|
type: 'day',
|
|
|
},
|
|
},
|
|
@@ -170,7 +182,7 @@ export async function getScoreLimit() {
|
|
|
export async function getScore() {
|
|
export async function getScore() {
|
|
|
const res = await axios({
|
|
const res = await axios({
|
|
|
method: 'get',
|
|
method: 'get',
|
|
|
- url: `${process.env.VUE_APP_API_PREFIX}/api/cms/game/getPoint?rnd=${Math.random()}`,
|
|
|
|
|
|
|
+ url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/cms/game/getPoint?rnd=${Math.random()}`,
|
|
|
headers: {
|
|
headers: {
|
|
|
token: store.state.token,
|
|
token: store.state.token,
|
|
|
}
|
|
}
|
|
@@ -184,7 +196,7 @@ export async function getScore() {
|
|
|
export async function addScore(score) {
|
|
export async function addScore(score) {
|
|
|
const res = await axios({
|
|
const res = await axios({
|
|
|
method: 'post',
|
|
method: 'post',
|
|
|
- url: `${process.env.VUE_APP_API_PREFIX}/api/cms/game/point/add`,
|
|
|
|
|
|
|
+ url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/cms/game/point/add`,
|
|
|
data: {
|
|
data: {
|
|
|
score,
|
|
score,
|
|
|
type: 'game',
|
|
type: 'game',
|
|
@@ -204,11 +216,78 @@ export async function addScore(score) {
|
|
|
export async function getExamQuestionList() {
|
|
export async function getExamQuestionList() {
|
|
|
const res = await axios({
|
|
const res = await axios({
|
|
|
method: 'get',
|
|
method: 'get',
|
|
|
- url: `${process.env.VUE_APP_API_PREFIX}/api/show/question/getList`,
|
|
|
|
|
|
|
+ url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/show/question/getList`,
|
|
|
})
|
|
})
|
|
|
if (res.data.code !== 0) {
|
|
if (res.data.code !== 0) {
|
|
|
throw (`获取答题列表失败:${res.data.msg}`)
|
|
throw (`获取答题列表失败:${res.data.msg}`)
|
|
|
} else {
|
|
} else {
|
|
|
return res.data.data
|
|
return res.data.data
|
|
|
}
|
|
}
|
|
|
|
|
+}
|
|
|
|
|
+/*
|
|
|
|
|
+createTime: "2024-01-08 19:07:01"
|
|
|
|
|
+creatorId: 1
|
|
|
|
|
+creatorName: ""
|
|
|
|
|
+id: 11
|
|
|
|
|
+isEnabled: 1
|
|
|
|
|
+name: "可乐"
|
|
|
|
|
+recordDate: null
|
|
|
|
|
+rtf: "<p>可乐</p><p>123</p><p></p><div class=\"media-wrap image-wrap\"><img src=\"https://sit-cnzhengquan.4dage.com/prize/11/img/20240109_0935085055.png\"/></div><p></p>"
|
|
|
|
|
+score: 10
|
|
|
|
|
+stock: 10
|
|
|
|
|
+thumb: "/prize/11/thumb/20240109_0929514233.png"
|
|
|
|
|
+updateTime: "2024-01-09 09:35:10"
|
|
|
|
|
+*/
|
|
|
|
|
+export async function getPrizeList(pageNum, pageSize) {
|
|
|
|
|
+ const res = await axios({
|
|
|
|
|
+ method: 'post',
|
|
|
|
|
+ url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/cms/game/prize/pageList`,
|
|
|
|
|
+ data: {
|
|
|
|
|
+ pageNum,
|
|
|
|
|
+ pageSize,
|
|
|
|
|
+ },
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ token: store.state.token,
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ if (res.data.code !== 0) {
|
|
|
|
|
+ throw (`获取奖品列表失败:${res.data.msg}`)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return res.data.data
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+export async function getBonusPointRecord() {
|
|
|
|
|
+ const res = await axios({
|
|
|
|
|
+ method: 'get',
|
|
|
|
|
+ url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/cms/game/point/getList`,
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ token: store.state.token,
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ if (res.data.code !== 0) {
|
|
|
|
|
+ throw (`获取积分记录失败:${res.data.msg}`)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return res.data.data
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+export async function redeem(description, name, phone, prizeId, score) {
|
|
|
|
|
+ const res = await axios({
|
|
|
|
|
+ method: 'post',
|
|
|
|
|
+ url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/cms/game/prize/redeem`,
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ token: store.state.token,
|
|
|
|
|
+ },
|
|
|
|
|
+ data: {
|
|
|
|
|
+ description,
|
|
|
|
|
+ name,
|
|
|
|
|
+ phone,
|
|
|
|
|
+ prizeId,
|
|
|
|
|
+ score: -1 * score,
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ if (res.data.code !== 0) {
|
|
|
|
|
+ throw (`奖品兑换失败:${res.data.msg}`)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return res.data.data
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|