parent
e42f376bc2
commit
5e4a9f8cc2
|
@ -0,0 +1,6 @@
|
||||||
|
import request from "@/utils/request.js";
|
||||||
|
|
||||||
|
// 获得用户收件地址
|
||||||
|
export function getUserInfo() {
|
||||||
|
return request.get('app-api/member/user/get');
|
||||||
|
}
|
|
@ -7,6 +7,11 @@ export function isFavoriteExists(spuId) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获得商品收藏数量
|
||||||
|
export function getFavoriteCount() {
|
||||||
|
return request.get('app-api/product/favorite/get-count');
|
||||||
|
}
|
||||||
|
|
||||||
// 添加商品收藏
|
// 添加商品收藏
|
||||||
export function createFavorite(spuId) {
|
export function createFavorite(spuId) {
|
||||||
return request.post('app-api/product/favorite/create', {
|
return request.post('app-api/product/favorite/create', {
|
||||||
|
|
|
@ -27,3 +27,8 @@ export function getCouponTemplateList(spuId, useType) {
|
||||||
export function getCouponTemplatePage(data) {
|
export function getCouponTemplatePage(data) {
|
||||||
return request.get("app-api/promotion/coupon-template/page", data);
|
return request.get("app-api/promotion/coupon-template/page", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获得未使用的优惠劵数量
|
||||||
|
export function getUnusedCouponCount() {
|
||||||
|
return request.get("app-api/promotion/coupon/get-unused-count");
|
||||||
|
}
|
||||||
|
|
|
@ -1,17 +1,15 @@
|
||||||
import request from "@/utils/request.js";
|
import request from "@/utils/request.js";
|
||||||
import Cache from "@/utils/cache.js"
|
|
||||||
/**
|
/**
|
||||||
* 获取用户信息
|
* 获取用户信息
|
||||||
*
|
*/
|
||||||
*/
|
|
||||||
export function getUserInfo(){
|
export function getUserInfo(){
|
||||||
return request.get('user');
|
return request.get('user');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置用户分享
|
* 设置用户分享
|
||||||
*
|
*/
|
||||||
*/
|
|
||||||
export function userShare(){
|
export function userShare(){
|
||||||
return request.post('user/share');
|
return request.post('user/share');
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,46 +6,46 @@
|
||||||
<view class="head pad30">
|
<view class="head pad30">
|
||||||
<view class="user-card">
|
<view class="user-card">
|
||||||
<view class="user-info">
|
<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>
|
<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 class="info">
|
||||||
请点击登录
|
<view class="name" v-if="!isLogin" @tap="openAuto">请点击登录</view>
|
||||||
</view>
|
<view class="name" v-else>
|
||||||
<view class="name" v-if="uid">
|
{{ userInfo.nickname }}
|
||||||
{{userInfo.nickname}}
|
<!-- TODO 芋艿:vip 逻辑 -->
|
||||||
<view class="vip" v-if="userInfo.vip">
|
<view class="vip" v-if="userInfo.vip">
|
||||||
<image :src="userInfo.vipIcon" alt="">
|
<image :src="userInfo.vipIcon" alt="" />
|
||||||
<view style="margin-left: 10rpx;" class="vip-txt">{{userInfo.vipName || ''}}
|
<view style="margin-left: 10rpx;" class="vip-txt">{{userInfo.vipName || ''}}</view>
|
||||||
</view>
|
|
||||||
</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">
|
<view class="icon">
|
||||||
<image src="/static/images/edit.png" mode=""></image>
|
<image src="/static/images/edit.png" mode="" />
|
||||||
</view>
|
</view>
|
||||||
</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>
|
</view>
|
||||||
<view class="num-wrapper">
|
<view class="num-wrapper">
|
||||||
|
<!-- TODO 芋艿:钱包 -->
|
||||||
<view class="num-item" @click="goMenuPage('/pages/users/user_money/index')">
|
<view class="num-item" @click="goMenuPage('/pages/users/user_money/index')">
|
||||||
<text
|
<text class="num">{{ userInfo.nowMoney ? Number(userInfo.nowMoney).toFixed(2) : 0 }}</text>
|
||||||
class="num">{{userInfo.nowMoney && uid ?Number(userInfo.nowMoney).toFixed(2):0}}</text>
|
|
||||||
<view class="txt">余额</view>
|
<view class="txt">余额</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="num-item" @click="goMenuPage('/pages/users/user_integral/index')">
|
<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 class="txt">积分</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="num-item" @click="goMenuPage('/pages/users/user_coupon/index')">
|
<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 class="txt">优惠券</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="num-item" @click="goMenuPage('/pages/users/user_goods_collection/index')">
|
<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 class="txt">收藏</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
@ -95,7 +95,8 @@
|
||||||
<view class="list-box">
|
<view class="list-box">
|
||||||
<block v-for="(item,index) in menus" :key="index">
|
<block v-for="(item,index) in menus" :key="index">
|
||||||
<navigator class="item" :url="item.url" hover-class="none"
|
<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>
|
<image :src="item.picUrl"></image>
|
||||||
<text>{{ item.name }}</text>
|
<text>{{ item.name }}</text>
|
||||||
</navigator>
|
</navigator>
|
||||||
|
@ -131,11 +132,13 @@
|
||||||
import * as TradeOrderApi from '@/api/trade/order.js';
|
import * as TradeOrderApi from '@/api/trade/order.js';
|
||||||
import * as AfterSaleApi from '@/api/trade/afterSale.js';
|
import * as AfterSaleApi from '@/api/trade/afterSale.js';
|
||||||
import * as DecorateApi from '@/api/promotion/decorate.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();
|
const app = getApp();
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
},
|
},
|
||||||
computed: mapGetters(['isLogin', 'chatUrl', 'userInfo', 'uid']),
|
computed: mapGetters(['isLogin', 'chatUrl', 'userInfo']),
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
orderMenu: [{
|
orderMenu: [{
|
||||||
|
@ -178,6 +181,9 @@
|
||||||
menus: [], // 用户菜单
|
menus: [], // 用户菜单
|
||||||
servicePic: '/static/images/customer.png',
|
servicePic: '/static/images/customer.png',
|
||||||
|
|
||||||
|
favoriteCount: 0, // 收藏数量
|
||||||
|
couponCount: 0, // 优惠劵数量
|
||||||
|
|
||||||
sysHeight: sysHeight,
|
sysHeight: sysHeight,
|
||||||
// #ifdef MP
|
// #ifdef MP
|
||||||
pageHeight: '100%',
|
pageHeight: '100%',
|
||||||
|
@ -188,13 +194,6 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
if (!this.isLogin) {
|
|
||||||
// #ifdef H5
|
|
||||||
toLogin()
|
|
||||||
// #endif
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
this.$set(this, 'pageHeight', app.globalData.windowHeight);
|
this.$set(this, 'pageHeight', app.globalData.windowHeight);
|
||||||
// #endif
|
// #endif
|
||||||
|
@ -209,13 +208,11 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// #endif
|
// #endif
|
||||||
if (that.isLogin) {
|
if (this.isLogin) {
|
||||||
this.getMyMenus();
|
this.getMyMenus();
|
||||||
// this.setVisit();
|
// this.setVisit();
|
||||||
|
this.getUserInfo();
|
||||||
this.getOrderData();
|
this.getOrderData();
|
||||||
this.$store.dispatch('USERINFO');
|
|
||||||
} else {
|
|
||||||
toLogin();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -231,6 +228,17 @@
|
||||||
kefuClick() {
|
kefuClick() {
|
||||||
location.href = this.chatUrl;
|
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() {
|
getOrderData() {
|
||||||
TradeOrderApi.getOrderCount().then(res => {
|
TradeOrderApi.getOrderCount().then(res => {
|
||||||
this.orderMenu.forEach((item) => {
|
this.orderMenu.forEach((item) => {
|
||||||
|
@ -292,13 +300,13 @@
|
||||||
},
|
},
|
||||||
// 编辑页面
|
// 编辑页面
|
||||||
goEdit() {
|
goEdit() {
|
||||||
if (this.isLogin == false) {
|
if (!this.isLogin) {
|
||||||
toLogin();
|
toLogin();
|
||||||
} else {
|
return;
|
||||||
uni.navigateTo({
|
|
||||||
url: '/pages/users/user_info/index'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/users/user_info/index'
|
||||||
|
})
|
||||||
},
|
},
|
||||||
// 签到
|
// 签到
|
||||||
goSignIn() {
|
goSignIn() {
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import {
|
import * as UserApi from '@/api/member/user.js';
|
||||||
getUserInfo
|
|
||||||
} from "../../api/user.js";
|
|
||||||
import {
|
import {
|
||||||
LOGIN_STATUS,
|
LOGIN_STATUS,
|
||||||
UID,
|
UID,
|
||||||
|
@ -27,7 +25,7 @@ const mutations = {
|
||||||
state.token = opt.token;
|
state.token = opt.token;
|
||||||
Cache.set(LOGIN_STATUS, opt.token);
|
Cache.set(LOGIN_STATUS, opt.token);
|
||||||
},
|
},
|
||||||
SETUID(state,val){
|
SETUID(state,val){
|
||||||
state.uid = val;
|
state.uid = val;
|
||||||
Cache.set(UID, val);
|
Cache.set(UID, val);
|
||||||
},
|
},
|
||||||
|
@ -83,12 +81,12 @@ const actions = {
|
||||||
commit
|
commit
|
||||||
}, force) {
|
}, force) {
|
||||||
return new Promise(reslove => {
|
return new Promise(reslove => {
|
||||||
getUserInfo().then(res => {
|
UserApi.getUserInfo().then(res => {
|
||||||
commit("UPDATE_USERINFO", res.data);
|
commit("UPDATE_USERINFO", res.data);
|
||||||
reslove(res.data);
|
reslove(res.data);
|
||||||
});
|
})
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
|
|
||||||
});
|
});
|
||||||
// debugger
|
// debugger
|
||||||
// if (state.userInfo !== null && !force)
|
// if (state.userInfo !== null && !force)
|
||||||
|
|
Loading…
Reference in New Issue