【个人中心】

1、完成个人信息的接入
pull/1/MERGE
YunaiV 2023-08-19 17:00:08 +08:00
parent e42f376bc2
commit 5e4a9f8cc2
6 changed files with 72 additions and 52 deletions

6
api/member/user.js Normal file
View File

@ -0,0 +1,6 @@
import request from "@/utils/request.js";
// 获得用户收件地址
export function getUserInfo() {
return request.get('app-api/member/user/get');
}

View File

@ -7,6 +7,11 @@ export function isFavoriteExists(spuId) {
});
}
// 获得商品收藏数量
export function getFavoriteCount() {
return request.get('app-api/product/favorite/get-count');
}
// 添加商品收藏
export function createFavorite(spuId) {
return request.post('app-api/product/favorite/create', {

View File

@ -27,3 +27,8 @@ export function getCouponTemplateList(spuId, useType) {
export function getCouponTemplatePage(data) {
return request.get("app-api/promotion/coupon-template/page", data);
}
// 获得未使用的优惠劵数量
export function getUnusedCouponCount() {
return request.get("app-api/promotion/coupon/get-unused-count");
}

View File

@ -1,8 +1,7 @@
import request from "@/utils/request.js";
import Cache from "@/utils/cache.js"
/**
* 获取用户信息
*
*/
export function getUserInfo(){
return request.get('user');
@ -10,7 +9,6 @@ export function getUserInfo(){
/**
* 设置用户分享
*
*/
export function userShare(){
return request.post('user/share');

View File

@ -6,46 +6,46 @@
<view class="head pad30">
<view class="user-card">
<view class="user-info">
<image class="avatar" :src='userInfo.avatar' v-if="userInfo.avatar && uid"
@click="goEdit()"></image>
<!-- 头像 -->
<image class="avatar" :src='userInfo.avatar' v-if="userInfo.avatar" @click="goEdit" />
<image v-else class="avatar" src="/static/images/f.png" mode="" @click="goEdit()"></image>
<!-- 昵称 -->
<view class="info">
<view class="name" v-if="!uid" @tap="openAuto">
请点击登录
</view>
<view class="name" v-if="uid">
<view class="name" v-if="!isLogin" @tap="openAuto"></view>
<view class="name" v-else>
{{ userInfo.nickname }}
<!-- TODO 芋艿vip 逻辑 -->
<view class="vip" v-if="userInfo.vip">
<image :src="userInfo.vipIcon" alt="">
<view style="margin-left: 10rpx;" class="vip-txt">{{userInfo.vipName || ''}}
<image :src="userInfo.vipIcon" alt="" />
<view style="margin-left: 10rpx;" class="vip-txt">{{userInfo.vipName || ''}}</view>
</view>
</view>
</view>
<view class="num" v-if="userInfo.phone && uid" @click="goEdit()">
<view class="num-txt">{{userInfo.phone}}</view>
<!-- 手机 -->
<view class="num" v-if="userInfo.mobile" @click="goEdit">
<view class="num-txt">{{userInfo.mobile}}</view>
<view class="icon">
<image src="/static/images/edit.png" mode=""></image>
<image src="/static/images/edit.png" mode="" />
</view>
</view>
<view class="phone" v-if="!userInfo.phone && isLogin" @tap="bindPhone"></view>
<view class="phone" v-else-if="isLogin" @tap="bindPhone"></view>
</view>
</view>
<view class="num-wrapper">
<!-- TODO 芋艿钱包 -->
<view class="num-item" @click="goMenuPage('/pages/users/user_money/index')">
<text
class="num">{{userInfo.nowMoney && uid ?Number(userInfo.nowMoney).toFixed(2):0}}</text>
<text class="num">{{ userInfo.nowMoney ? Number(userInfo.nowMoney).toFixed(2) : 0 }}</text>
<view class="txt">余额</view>
</view>
<view class="num-item" @click="goMenuPage('/pages/users/user_integral/index')">
<text class="num">{{userInfo.integral && uid ? userInfo.integral: 0}}</text>
<text class="num">{{ userInfo.point ? userInfo.point: 0 }}</text>
<view class="txt">积分</view>
</view>
<view class="num-item" @click="goMenuPage('/pages/users/user_coupon/index')">
<text class="num">{{userInfo.couponCount && uid ? userInfo.couponCount : 0}}</text>
<text class="num">{{ couponCount }}</text>
<view class="txt">优惠券</view>
</view>
<view class="num-item" @click="goMenuPage('/pages/users/user_goods_collection/index')">
<text class="num">{{userInfo.collectCount && uid ? userInfo.collectCount : 0}}</text>
<text class="num">{{ favoriteCount }}</text>
<view class="txt">收藏</view>
</view>
</view>
@ -95,7 +95,8 @@
<view class="list-box">
<block v-for="(item,index) in menus" :key="index">
<navigator class="item" :url="item.url" hover-class="none"
v-if="!(item.url ==='/pages/service/index' || (item.url === '/pages/users/user_spread_user/index' && !userInfo.isPromoter))">
v-if="!(item.url ==='/pages/service/index'
|| (item.url === '/pages/users/user_spread_user/index' && !userInfo.isPromoter))">
<image :src="item.picUrl"></image>
<text>{{ item.name }}</text>
</navigator>
@ -131,11 +132,13 @@
import * as TradeOrderApi from '@/api/trade/order.js';
import * as AfterSaleApi from '@/api/trade/afterSale.js';
import * as DecorateApi from '@/api/promotion/decorate.js';
import * as ProductFavoriteApi from '@/api/product/favorite.js';
import * as CouponApi from '@/api/promotion/coupon.js';
const app = getApp();
export default {
components: {
},
computed: mapGetters(['isLogin', 'chatUrl', 'userInfo', 'uid']),
computed: mapGetters(['isLogin', 'chatUrl', 'userInfo']),
data() {
return {
orderMenu: [{
@ -178,6 +181,9 @@
menus: [], //
servicePic: '/static/images/customer.png',
favoriteCount: 0, //
couponCount: 0, //
sysHeight: sysHeight,
// #ifdef MP
pageHeight: '100%',
@ -188,13 +194,6 @@
}
},
onLoad() {
if (!this.isLogin) {
// #ifdef H5
toLogin()
// #endif
return
}
// #ifdef H5
this.$set(this, 'pageHeight', app.globalData.windowHeight);
// #endif
@ -209,13 +208,11 @@
}
});
// #endif
if (that.isLogin) {
if (this.isLogin) {
this.getMyMenus();
// this.setVisit();
this.getUserInfo();
this.getOrderData();
this.$store.dispatch('USERINFO');
} else {
toLogin();
}
},
methods: {
@ -231,6 +228,17 @@
kefuClick() {
location.href = this.chatUrl;
},
getUserInfo() {
//
this.$store.dispatch('USERINFO');
//
ProductFavoriteApi.getFavoriteCount().then(res => {
this.favoriteCount = res.data;
})
CouponApi.getUnusedCouponCount().then(res => {
this.couponCount = res.data;
})
},
getOrderData() {
TradeOrderApi.getOrderCount().then(res => {
this.orderMenu.forEach((item) => {
@ -292,13 +300,13 @@
},
//
goEdit() {
if (this.isLogin == false) {
if (!this.isLogin) {
toLogin();
} else {
return;
}
uni.navigateTo({
url: '/pages/users/user_info/index'
})
}
},
//
goSignIn() {

View File

@ -1,6 +1,4 @@
import {
getUserInfo
} from "../../api/user.js";
import * as UserApi from '@/api/member/user.js';
import {
LOGIN_STATUS,
UID,
@ -83,10 +81,10 @@ const actions = {
commit
}, force) {
return new Promise(reslove => {
getUserInfo().then(res => {
UserApi.getUserInfo().then(res => {
commit("UPDATE_USERINFO", res.data);
reslove(res.data);
});
})
}).catch(() => {
});