diff --git a/src/store/index.js b/src/store/index.js index 3473b4c..fb94e52 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -50,10 +50,13 @@ export default new Vuex.Store({ actions: { getUserInfo (store) { - request.post('/api/malluser/info').then(res => { - if (res.code === 0) { - store.commit('setUserInfo', res.data) - } + return new Promise(resolve => { + request.post('/api/malluser/info').then(res => { + if (res.code === 0) { + store.commit('setUserInfo', res.data) + resolve(res.data) + } + }) }) } }, diff --git a/src/utils/index.js b/src/utils/index.js index 737774a..61a5abf 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -1,4 +1,6 @@ import request from '../api' +import store from '../store' +import { Message } from 'element-ui' const dict = { url: "/dictionary/queryValsByCodeList", @@ -88,9 +90,30 @@ const dateUtil = { } } +const userCheck = () => { + store.dispatch('getUserInfo').then(res => { + return new Promise((resolve, reject) => { + if (res.data.flag != 1) { + Message.error('您的账号未激活或已失效,请激活后使用') + this.$store.commit('setActiveDlgShow', true) + reject('您的账号未激活或已失效,请激活后使用') + return false + } + if (res.data.type != 4 && this.$store.state.mallId != this.$store.state.userInfo.mallId) { + Message.error('您当前登录的TEMU账号与会员绑定账号不一致') + reject('您当前登录的TEMU账号与会员绑定账号不一致') + return false + } + + resolve(res.data) + }) + }) +} + export default { dict, dateUtil, + userCheck } diff --git a/src/view/Learning.vue b/src/view/Learning.vue index 9908b06..2db5460 100644 --- a/src/view/Learning.vue +++ b/src/view/Learning.vue @@ -61,6 +61,9 @@ }, created () { + this.$store.dispatch('getUserInfo').then(e => { + console.log(e) + }) this.getCateList() this.getList() }, @@ -89,7 +92,6 @@ }, collection (id, isFavorite) { - console.log(isFavorite) this.$confirm(isFavorite === '0' ? '确定收藏该文章?' : '确定取消收藏?', '温馨提示', { confirmButtonText: '确定', callback: action => { diff --git a/src/view/NormalSendGoods.vue b/src/view/NormalSendGoods.vue index 7d8832b..a8cfe49 100644 --- a/src/view/NormalSendGoods.vue +++ b/src/view/NormalSendGoods.vue @@ -279,46 +279,50 @@ } return; } - this.$http.post('/api/malluser/info').then(res => { - if (res.code == 0) { - this.$store.commit('setUserInfo', res.data) - if (res.data.flag != 1) { - Message.error('您的账号未激活或已失效,请激活后使用') - this.$store.commit('setActiveDlgShow', true) - return; - } - if (res.data.type != 4 && this.$store.state.mallId != this.$store.state.userInfo.mallId) { - Message.error('您当前登录的TEMU账号与会员绑定账号不一致') - return; - } - if (this.choosedList.length <= 0) { - Message.error('请选择备货单'); - return; - } - this.robTotal = this.choosedList.length - this.isBegin = true; - this.timer = []; - - for (let i = 0;i < this.choosedList.length; i++) { - setTimeout(() => { - let t = setInterval(this.robFunc(this.choosedList[i].subPurchaseOrderSn, this.choosedList[i].mallId), 1000); - this.timer.push({id: this.choosedList[i].subPurchaseOrderSn, timer: t}) - }, 100 * i) - } - - let _this = this; - let tt = setInterval(function() { - if (_this.choosedList.length == 0) { - _this.isBegin = false; - clearInterval(tt); - } - }, 1000) - } else { - console.log("获取用户信息失败") + this.$userCheck.then(() => { + if (this.choosedList.length <= 0) { + Message.error('请选择备货单'); + return; } - }); + this.robTotal = this.choosedList.length + this.isBegin = true; + this.timer = []; + + for (let i = 0;i < this.choosedList.length; i++) { + setTimeout(() => { + let t = setInterval(this.robFunc(this.choosedList[i].subPurchaseOrderSn, this.choosedList[i].mallId), 1000); + this.timer.push({id: this.choosedList[i].subPurchaseOrderSn, timer: t}) + }, 100 * i) + } + + let _this = this; + let tt = setInterval(function() { + if (_this.choosedList.length == 0) { + _this.isBegin = false; + clearInterval(tt); + } + }, 1000) + }).catch((err) => { + console.log(err) + }) + // this.$http.post('/api/malluser/info').then(res => { + // if (res.code == 0) { + // this.$store.commit('setUserInfo', res.data) + // if (res.data.flag != 1) { + // Message.error('您的账号未激活或已失效,请激活后使用') + // this.$store.commit('setActiveDlgShow', true) + // return; + // } + // if (res.data.type != 4 && this.$store.state.mallId != this.$store.state.userInfo.mallId) { + // Message.error('您当前登录的TEMU账号与会员绑定账号不一致') + // return; + // } + // } else { + // console.log("获取用户信息失败") + // } + // }); }, robFunc(sn, mallId) { let _this = this;