Merge branch 'feature/task1.0.0' into 'msb_test'

Feature/task1.0.0

See merge request yanxuan-frontend/shop-pc!38
merge-requests/42/merge
肖广 3 years ago
commit fd74d83201

@ -147,11 +147,17 @@ export default {
Message.error("请勾选同意《用户协议》和《隐私协议》");
return;
}
const { result } = await ApiPostLogin({
const { result, error } = await ApiPostLogin({
...this.form,
clientId: 1,
systemId: 3,
});
if (error !== null) {
Message.error(
error.message || "登录失败,请检查手机号或验证码是否正确"
);
return;
}
if (result) {
this.dialogTableVisible = false;
this.$store.commit("setToken", result.token);

@ -122,7 +122,7 @@ export default {
this.$router.push("/account/address");
break;
case MENU_VALUE.LOGON_OUT:
this.$store.commit("setLoginOut");
this.$store.dispatch("logout");
}
},

@ -60,9 +60,9 @@
class="main__details-skill flex flex-right flex-middle"
>
距结束仅剩
<span>{{ getSurplus.lefth }}</span>
<span>{{ getSurplus.leftm }}</span>
<span>{{ getSurplus.lefts }}</span>
<span>{{ surplus.lefth }}</span>
<span>{{ surplus.leftm }}</span>
<span>{{ surplus.lefts }}</span>
</div>
<div class="main__details-msg">
<div class="main__details-msg--price flex flex-middle">
@ -83,9 +83,9 @@
>
<span class="skill-txt">即将开始秒杀</span>
<div class="skill-2" v-if="isToday()">
<span>{{ getSurplus.lefth }}</span>
<span>{{ getSurplus.leftm }}</span>
<span>{{ getSurplus.lefts }}</span>
<span>{{ surplus.lefth }}</span>
<span>{{ surplus.leftm }}</span>
<span>{{ surplus.lefts }}</span>
</div>
<span class="skill-1" v-else>{{ getBeginTime() }}</span>
</div>
@ -196,6 +196,9 @@ export default {
productActivityVO: {},
},
surplus: {},
timer: null,
startTime: "",
endTime: "",
};
},
async created() {
@ -212,21 +215,21 @@ export default {
!vm.detailData.productActivityVO.isStartActivity &&
vm.isToday()
) {
let startTime = new Date(
vm.startTime = new Date(
vm.detailData.productActivityVO.currentTime
).getTime();
let endTime = new Date(
vm.endTime = new Date(
vm.detailData.productActivityVO.activityStartTime
).getTime();
vm.setSurplus(startTime, endTime);
vm.setSurplus();
} else if (vm.detailData.productActivityVO.isStartActivity) {
let startTime = new Date(
vm.startTime = new Date(
vm.detailData.productActivityVO.currentTime
).getTime();
let endTime = new Date(
vm.endTime = new Date(
vm.detailData.productActivityVO.activityEndTime
).getTime();
vm.setSurplus(startTime, endTime);
vm.setSurplus();
}
},
computed: {
@ -277,15 +280,15 @@ export default {
leftObj["lefts"] = Math.floor((leftObj["lefttime"] / 1000) % 60); //
return leftObj;
},
setSurplus(startTime, endTime) {
setSurplus() {
let vm = this;
vm.surplus = getSurplus(startTime, endTime);
vm.surplus = vm.getSurplus(vm.startTime, vm.endTime);
if (vm.timer) {
return false;
}
vm.timer = setInterval(() => {
vm.startTime += 1000;
vm.surplus = getSurplus(vm.startTime, vm.endTime);
vm.surplus = vm.getSurplus(vm.startTime, vm.endTime);
if (vm.surplus.lefttime <= 0) {
clearInterval(vm.timer);
location.reload();
@ -564,9 +567,9 @@ export default {
&-msg {
width: 714px;
height: 127px;
min-height: 127px;
background: #f8f8f8;
padding: 30px 20px 0;
padding: 30px 20px;
.msg-txt {
font-size: 14px;
font-family: Microsoft YaHei-Regular, Microsoft YaHei;

@ -31,6 +31,10 @@ export const ApiPutUser = (data) =>
* @param {*} data
*/
export const ApiPostLogin = (data) => ToAsyncAwait(axios.post(`${BASE_URL}/user/login`, data));
/**
* 退出登录
*/
export const ApiPostLogout = () => ToAsyncAwait(axiosTk.get(`${BASE_URL}/user/logout`));
/**
* 获取手机验证码
* @param {*} params

@ -16,15 +16,15 @@ export default function ({$axios, store, route}, inject) {
config.headers.Authorization = store.state.token;
return config;
});
$axiosTk.onResponse(response => {
$axiosTk.onResponse(async response => {
const result = response.data;
if(response.status === 200){
if(result.code === 'SUCCESS'){
return result.data;
}
if(result.code === 'TOKEN_FAIL'){
alert('这里要弹登录')
store.commit('setLoginOut');
await store.dispatch('logout');
store.commit('setLoginVisible');
return result;
}
return Promise.reject(result);

@ -6,7 +6,7 @@
* @Description: file content
*/
import { TOKEN_KEY } from "@/constants";
import { ApiGetCurrentUser } from "@/plugins/api/account";
import { ApiGetCurrentUser, ApiPostLogout } from "@/plugins/api/account";
const ONE_DAY = 86400000; // 一天的毫秒数 24 * 60 * 60 * 1000;
const state = () => ({
@ -48,6 +48,12 @@ const actions = {
commit("setUserInfo", result);
}
},
// 退出登录
async logout({ commit }) {
await ApiPostLogout();
commit("setLoginOut");
},
};
export { state, mutations, actions };

Loading…
Cancel
Save