251 行
5.3 KiB
Vue
251 行
5.3 KiB
Vue
<template>
|
|
<view class="user-tools-wrap brand-card" v-if="mergedTools.length">
|
|
<view class="section-head u-flex u-row-between u-col-center">
|
|
<text class="section-title">我的服务</text>
|
|
</view>
|
|
<view class="service-grid">
|
|
<view
|
|
class="service-item u-flex-col u-col-center"
|
|
v-for="menu in mergedTools"
|
|
:key="menu.name"
|
|
@tap="handleTap(menu)"
|
|
>
|
|
<view class="service-icon-wrap u-flex u-row-center u-col-center">
|
|
<text class="u-iconfont" :class="menu.icon"></text>
|
|
</view>
|
|
<text class="service-name u-ellipsis-1">{{ menu.name }}</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import { mapGetters } from 'vuex';
|
|
import { isHiddenTool } from '@/shopro/utils/hidden-tools';
|
|
|
|
const DEFAULT_TOOLS = [{
|
|
name: '分销中心',
|
|
path: '/pages/app/commission/index',
|
|
icon: 'uicon-share',
|
|
group: 'member',
|
|
desc: '推广赚差价'
|
|
}, {
|
|
name: '区域服务商',
|
|
path: '/pages/app/regional-agent/index',
|
|
icon: 'uicon-map',
|
|
group: 'member',
|
|
desc: '申请区域服务商'
|
|
}, {
|
|
name: '积分商城',
|
|
path: '/pages/app/score/list',
|
|
icon: 'uicon-gift',
|
|
group: 'member',
|
|
desc: '积分兑好礼'
|
|
}, {
|
|
name: '浏览足迹',
|
|
path: '/pages/user/view-log',
|
|
icon: 'uicon-map',
|
|
group: 'record',
|
|
desc: '最近浏览记录'
|
|
}, {
|
|
name: '我的收藏',
|
|
path: '/pages/user/favorite',
|
|
icon: 'uicon-star',
|
|
group: 'record',
|
|
desc: '收藏的心仪好物'
|
|
}, {
|
|
name: '地址管理',
|
|
path: '/pages/user/address/list',
|
|
icon: 'uicon-map-fill',
|
|
group: 'service',
|
|
desc: '管理收货地址'
|
|
}, {
|
|
name: '常见问题',
|
|
path: '/pages/public/faq',
|
|
icon: 'uicon-question',
|
|
group: 'help',
|
|
desc: '快速了解使用帮助'
|
|
}, {
|
|
name: '问题反馈',
|
|
path: '/pages/public/feedback',
|
|
icon: 'uicon-chat',
|
|
group: 'help',
|
|
desc: '提交意见与建议'
|
|
}, {
|
|
name: '系统设置',
|
|
path: '/pages/user/set',
|
|
icon: 'uicon-setting',
|
|
group: 'help',
|
|
desc: '账号与隐私设置'
|
|
}];
|
|
|
|
const TOOL_NAME_ALIAS = {
|
|
'区域代理': '区域服务商'
|
|
};
|
|
|
|
const EXTRA_ICON_MAP = {
|
|
'在线客服': 'uicon-server-man',
|
|
'开启直播': 'uicon-play-circle',
|
|
'我的预约': 'uicon-calendar'
|
|
};
|
|
|
|
export default {
|
|
props: {
|
|
list: {
|
|
type: Array,
|
|
default: () => []
|
|
}
|
|
},
|
|
computed: {
|
|
...mapGetters(['userInfo']),
|
|
mergedTools() {
|
|
const apiMap = {};
|
|
(this.list || []).forEach(item => {
|
|
if (item?.name) {
|
|
const key = TOOL_NAME_ALIAS[item.name] || item.name;
|
|
apiMap[key] = { ...item, name: key };
|
|
}
|
|
});
|
|
|
|
const catalogNames = DEFAULT_TOOLS.map(item => item.name);
|
|
const merged = DEFAULT_TOOLS.map(def => {
|
|
const remote = apiMap[def.name] || {};
|
|
return {
|
|
...def,
|
|
...remote,
|
|
path: remote.path || def.path,
|
|
icon: def.icon,
|
|
group: def.group,
|
|
desc: def.desc
|
|
};
|
|
});
|
|
|
|
Object.keys(apiMap).forEach(name => {
|
|
if (catalogNames.includes(name)) return;
|
|
if (name === '开启直播' && this.userInfo?.is_live != 1) return;
|
|
const remote = apiMap[name];
|
|
merged.push({
|
|
name,
|
|
path: remote.path || '',
|
|
icon: EXTRA_ICON_MAP[name] || 'uicon-list',
|
|
group: 'service',
|
|
desc: remote.path_name || '点击进入'
|
|
});
|
|
});
|
|
|
|
return merged.filter(item => {
|
|
if (isHiddenTool(item)) return false;
|
|
return item.name !== '开启直播' || this.userInfo?.is_live == 1;
|
|
});
|
|
}
|
|
},
|
|
methods: {
|
|
handleTap(menu) {
|
|
if (menu.name === '在线客服') {
|
|
this.openService();
|
|
return;
|
|
}
|
|
this.jump(menu);
|
|
},
|
|
jump(data) {
|
|
if (isHiddenTool(data)) {
|
|
uni.showToast({ title: '功能已关闭', icon: 'none' });
|
|
return;
|
|
}
|
|
if (data.name === '我的预约' && !data.path) {
|
|
data.path = '/pages/user/rob-order';
|
|
}
|
|
if (data.name === '开启直播' && !data.path) {
|
|
data.path = '/pages/user/live';
|
|
}
|
|
if (!data.path) {
|
|
uni.showToast({ title: '功能暂未开放', icon: 'none' });
|
|
return;
|
|
}
|
|
this.$tools.routerTo(data.path);
|
|
},
|
|
openService() {
|
|
// #ifdef MP-WEIXIN
|
|
wx.openCustomerServiceChat({
|
|
extInfo: {
|
|
url: 'https://work.weixin.qq.com/kfid/kfc5aec53d2111b588a'
|
|
},
|
|
corpId: 'wwc5f08e271cf73fb2',
|
|
success() {},
|
|
fail() {}
|
|
});
|
|
// #endif
|
|
|
|
// #ifdef APP-PLUS
|
|
plus.share.getServices(res => {
|
|
const wechat = res.find(v => v.id === 'weixin');
|
|
if (wechat) {
|
|
wechat.openCustomerServiceChat({
|
|
corpid: 'wwc5f08e271cf73fb2',
|
|
url: 'https://work.weixin.qq.com/kfid/kfc5aec53d2111b588a'
|
|
}, () => {}, () => {});
|
|
} else {
|
|
uni.showToast({ title: '当前环境不支持微信操作', icon: 'none' });
|
|
}
|
|
}, () => {
|
|
uni.showToast({ title: '获取服务失败', icon: 'none' });
|
|
});
|
|
// #endif
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.user-tools-wrap {
|
|
padding: 24rpx 16rpx 20rpx;
|
|
}
|
|
|
|
.section-head {
|
|
padding: 0 12rpx 20rpx;
|
|
}
|
|
|
|
.section-title {
|
|
font-size: 28rpx;
|
|
font-weight: 600;
|
|
color: $brand-text;
|
|
}
|
|
|
|
.service-grid {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.service-item {
|
|
width: 25%;
|
|
padding: 16rpx 8rpx;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.service-icon-wrap {
|
|
width: 88rpx;
|
|
height: 88rpx;
|
|
border-radius: 50%;
|
|
background: $brand-primary-light;
|
|
margin-bottom: 12rpx;
|
|
|
|
.u-iconfont {
|
|
font-size: 40rpx;
|
|
color: $brand-primary;
|
|
}
|
|
}
|
|
|
|
.service-icon-img {
|
|
width: 48rpx;
|
|
height: 48rpx;
|
|
}
|
|
|
|
.service-name {
|
|
width: 100%;
|
|
text-align: center;
|
|
font-size: 22rpx;
|
|
color: $brand-text;
|
|
line-height: 1.3;
|
|
}
|
|
</style>
|