|
@@ -58,7 +58,8 @@ import uniPopup from '@/components/uni-popup/uni-popup.vue';
|
|
|
import uniCopy from '@/utils/uni-copy.js';
|
|
|
|
|
|
import { mapState, mapMutations } from 'vuex';
|
|
|
-import { saveUrl, interceptor } from '@/utils/loginUtils.js';
|
|
|
+import { saveUrl, interceptor } from '@/utils/loginUtils.js';
|
|
|
+import { getUserInfo } from '@/api/user.js';
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
@@ -67,8 +68,38 @@ export default {
|
|
|
},
|
|
|
computed:{
|
|
|
...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
|
|
|
+ },
|
|
|
+ onShow() {
|
|
|
+ //判断是否已经登录
|
|
|
+ if (this.hasLogin) {
|
|
|
+ this.loadBaseData();
|
|
|
+ } else {
|
|
|
+ uni.showModal({
|
|
|
+ title: '登录',
|
|
|
+ content: '您未登录,是否马上登陆?',
|
|
|
+ success: e => {
|
|
|
+ if (e.confirm) {
|
|
|
+ interceptor();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: e => {
|
|
|
+ console.log(e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
- methods: {
|
|
|
+ methods: {
|
|
|
+ ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
|
|
|
+ loadBaseData() {
|
|
|
+ getUserInfo({})
|
|
|
+ .then(({ data }) => {
|
|
|
+ console.log(data,'UserInfo+++++++++++++++++')
|
|
|
+ this.setUserInfo(data);
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ console.log(e);
|
|
|
+ });
|
|
|
+ },
|
|
|
navTo(url) {
|
|
|
if (!this.hasLogin) {
|
|
|
// 保存地址
|