优化user store、完成部分个人中心

This commit is contained in:
TOP糯米 2023-03-08 00:21:49 +08:00
parent c8f2ed12f3
commit 242d58d8b8
3 changed files with 39 additions and 20 deletions

View File

@ -19,11 +19,16 @@ export default {
} }
}).then((response) => { }).then((response) => {
uni.setStorageSync("open_id", response.data.openid); uni.setStorageSync("open_id", response.data.openid);
resolve(response.data); return resolve(response.data);
}); });
} }
}); });
// #endif // #endif
// #ifdef H5
return resolve({
openid: "mobile_000000000000000000"
});
// #endif
}); });
}, },
/** /**

View File

@ -2,18 +2,24 @@
<app-layout title="我的" btnType="unset"> <app-layout title="我的" btnType="unset">
<view class="member-header"> <view class="member-header">
<view class="headimg"> <view class="headimg">
<image class="img-src" :src="info.headimg" mode="aspectFill" /> <image class="img-src" :src="require('@/static/temp/member/1.png')" mode="aspectFill" />
</view> </view>
<view class="member-desc"> <view class="member-desc" v-if="isLogin">
<text class="nickname">{{ info.nickname }}</text> <text class="nickname">{{ userInfo.nickname || "微信用户" }}</text>
<view class="mobile"> <view class="mobile">
<text class="text">{{ info.mobile }}</text> <text class="text">{{ userInfo.mobile }}</text>
</view>
</view>
<view class="member-desc" v-else @click="utils.toPage('/pages/auth/auth')">
<text class="nickname">请登录后再操作</text>
<view class="mobile">
<text class="text">点击去登录</text>
</view> </view>
</view> </view>
</view> </view>
<view class="menu-container"> <view class="menu-container">
<view class="common-form-widget-group"> <view class="common-form-widget-group">
<view class="widget-item" @click="utils.toPage('/pages/address/address?openType=list')"> <view class="widget-item" @click="toPage('/pages/address/address?openType=list')">
<text class="iconfont icon-dingwei icon"></text> <text class="iconfont icon-dingwei icon"></text>
<text class="title limit-line clamp-1">我的地址</text> <text class="title limit-line clamp-1">我的地址</text>
<text class="iconfont icon-jinru more"></text> <text class="iconfont icon-jinru more"></text>
@ -28,7 +34,7 @@
<text class="title limit-line clamp-1">联系客服</text> <text class="title limit-line clamp-1">联系客服</text>
<text class="iconfont icon-jinru more"></text> <text class="iconfont icon-jinru more"></text>
</view> </view>
<view class="widget-item" @click="utils.toPage('/pages/member/setting')"> <view class="widget-item" @click="toPage('/pages/member/setting')">
<text class="iconfont icon-shezhixitongshezhigongnengshezhishuxing icon"></text> <text class="iconfont icon-shezhixitongshezhigongnengshezhishuxing icon"></text>
<text class="title limit-line clamp-1">设置</text> <text class="title limit-line clamp-1">设置</text>
<text class="iconfont icon-jinru more"></text> <text class="iconfont icon-jinru more"></text>
@ -40,19 +46,17 @@
<text class="title limit-line clamp-1">我是师傅</text> <text class="title limit-line clamp-1">我是师傅</text>
<text class="iconfont icon-jinru more"></text> <text class="iconfont icon-jinru more"></text>
</view> </view>
<view class="widget-item" @click="utils.toPage('/pages/service/other/project')"> <view class="widget-item" @click="toPage('/pages/service/other/project')">
<text class="iconfont icon-cailiaogongcheng icon"></text> <text class="iconfont icon-cailiaogongcheng icon"></text>
<text class="title limit-line clamp-1">工程安装</text> <text class="title limit-line clamp-1">工程安装</text>
<text class="iconfont icon-jinru more"></text> <text class="iconfont icon-jinru more"></text>
</view> </view>
<view class="widget-item" @click="utils.toPage('/pages/service/other/business')"> <view class="widget-item" @click="toPage('/pages/service/other/business')">
<text class="iconfont icon-qiye icon"></text> <text class="iconfont icon-qiye icon"></text>
<text class="title limit-line clamp-1">企业安装合作</text> <text class="title limit-line clamp-1">企业安装合作</text>
<text class="iconfont icon-jinru more"></text> <text class="iconfont icon-jinru more"></text>
</view> </view>
</view> </view>
</view> </view>
</app-layout> </app-layout>
</template> </template>
@ -65,19 +69,15 @@ export default {
data() { data() {
return { return {
utils: this.$utils, utils: this.$utils,
info: {
nickname: "微信用户",
mobile: "131****6080",
headimg: require("@/static/temp/member/1.png"),
},
}; };
}, },
components: { components: {
AppLayout, AppLayout,
}, },
computed: { computed: {
...mapState("user", { ...mapState({
userInfo: (state) => state.userInfo, isLogin: (state) => state.user.token.length > 0,
userInfo: (state) => state.user.info,
}), }),
}, },
onLoad() {}, onLoad() {},
@ -85,7 +85,15 @@ export default {
onReady() {}, onReady() {},
onReachBottom() {}, onReachBottom() {},
onPullDownRefresh() {}, onPullDownRefresh() {},
methods: {}, methods: {
toPage(url) {
if (!this.isLogin) {
this.$store.commit("user/showLoginModal", true);
return;
}
this.$utils.toPage(url);
},
},
}; };
</script> </script>

View File

@ -5,7 +5,13 @@ export default {
showLoginModal: false, showLoginModal: false,
openId: "", openId: "",
token: "", token: "",
info: null, info: {
id: 0,
nickname: "",
openid: "",
mobile: "",
create_time: 0,
},
}, },
getters: {}, getters: {},
mutations: { mutations: {