前端小程序

这个提交包含在:
可乐加冰
2026-09-14 17:24:53 +08:00
父节点 bb69a43a0f
当前提交 019630f12c
共有 2629 个文件被更改,包括 403657 次插入 和 0 次删除

查看文件

@@ -0,0 +1,158 @@
<template>
<view v-if="displayList.length" class="user-promo-swiper">
<!-- 单图直接渲染,避免 swiper 嵌套导致真机有 src 但不显示 -->
<image
v-if="displayList.length === 1"
class="user-promo-swiper__img"
:src="currentImage"
mode="widthFix"
:lazy-load="false"
show-menu-by-longpress
@tap="onTap(0)"
@error="onImageError"
></image>
<swiper
v-else
class="user-promo-swiper__swiper"
:style="{ height: bannerHeight + 'rpx' }"
:indicator-dots="displayList.length > 1"
:circular="displayList.length > 1"
:autoplay="displayList.length > 1"
interval="5000"
duration="500"
>
<swiper-item
v-for="(item, index) in displayList"
:key="item.image || index"
@tap="onTap(index)"
>
<image
class="user-promo-swiper__slide"
:src="item.image"
mode="aspectFill"
:lazy-load="false"
></image>
</swiper-item>
</swiper>
</view>
</template>
<script>
import { mapGetters } from 'vuex';
import { IMG_URL } from '@/env.js';
function normalizeImageUrl(url, baseUrl = IMG_URL) {
if (!url || typeof url !== 'string') {
return '';
}
const value = url.trim();
if (/^https?:\/\//i.test(value)) {
return value;
}
if (value.startsWith('//')) {
return `https:${value}`;
}
const base = (baseUrl || '').replace(/\/$/, '');
return value.startsWith('/') ? `${base}${value}` : `${base}/${value}`;
}
function getDefaultList(baseUrl = IMG_URL) {
const base = `${baseUrl}/uploads/demo/xiongge`;
return [
{
image: `${base}/user-promo-banner-1.jpg`,
path: '/pages/index/index'
},
{
image: `${base}/user-promo-banner-2.jpg`,
path: '/pages/app/score/list'
}
];
}
export default {
data() {
return {
fallbackIndex: 0
};
},
computed: {
...mapGetters(['userTemplate']),
promoBannerModule() {
return (this.userTemplate || []).find(item => item.type === 'banner');
},
displayList() {
const list = this.promoBannerModule?.content?.list || [];
const valid = list
.filter(item => item && item.image)
.map(item => ({
...item,
image: normalizeImageUrl(item.image, this.$IMG_URL)
}))
.filter(item => item.image);
return valid.length ? valid : getDefaultList(this.$IMG_URL);
},
bannerHeight() {
const height = Number(this.promoBannerModule?.content?.height);
return height > 0 ? height : 163;
},
fallbackImages() {
return getDefaultList(this.$IMG_URL).map(item => item.image);
},
currentImage() {
const item = this.displayList[0];
if (!item) {
return '';
}
if (this.fallbackIndex === 0) {
return item.image;
}
return this.fallbackImages[this.fallbackIndex - 1] || item.image;
}
},
watch: {
displayList() {
this.fallbackIndex = 0;
}
},
methods: {
onTap(index) {
const item = this.displayList[index];
if (item && item.path) {
this.$tools.routerTo(item.path);
}
},
onImageError() {
if (this.fallbackIndex < this.fallbackImages.length) {
this.fallbackIndex += 1;
}
}
}
};
</script>
<style lang="scss">
.user-promo-swiper {
width: 100%;
background: #fff;
border-radius: $brand-card-radius;
overflow: hidden;
box-shadow: $brand-shadow;
}
.user-promo-swiper__img {
width: 100%;
display: block;
vertical-align: top;
}
.user-promo-swiper__swiper {
width: 100%;
}
.user-promo-swiper__slide {
width: 100%;
height: 100%;
display: block;
}
</style>

查看文件

@@ -0,0 +1,554 @@
<template>
<view>
<view class="sh-userinfo-box">
<view class="head-wrap" :style="headWrapStyle">
<shopro-navbar
backIconName=""
:backTextStyle="{ color: '#FFFFFF', fontSize: '34rpx', fontWeight: '600' }"
backText="个人中心"
:background="navBackground"
></shopro-navbar>
<view class="user-head u-flex u-row-between u-col-center">
<view class="info-box u-flex u-col-center" @tap="onProfileTap">
<view class="head-img-wrap">
<image
class="head-img"
:src="userInfo.avatar || $IMG_URL + '/imgs/base_avatar.png'"
mode="aspectFill"
></image>
<button
v-if="showRefresh"
@tap.stop="showModal = true"
class="u-reset-button refresh-btn u-flex u-row-center u-col-center"
>
<text class="u-iconfont uicon-reload"></text>
</button>
</view>
<view class="user-meta">
<text class="user-name u-ellipsis-1">{{ userInfo.nickname || '请登录' }}</text>
<view v-if="isLogin" class="user-sub-row u-flex u-col-center">
<text class="user-id">ID: {{ userInfo.id }}</text>
<text class="user-referrer u-ellipsis-1">推荐人: {{ referrerText }}</text>
</view>
<view v-if="isLogin && roleTags.length" class="user-role-tags u-flex u-flex-wrap">
<view
class="role-tag"
v-for="(tag, index) in roleTags"
:key="`${tag}-${index}`"
>{{ tag }}</view>
</view>
<text v-else-if="!isLogin" class="user-desc">登录享受更多会员权益</text>
</view>
</view>
<view v-if="isLogin" class="user-head__actions">
<button class="u-reset-button action-icon-btn" @tap="jump('/pages/user/set')">
<text class="u-iconfont uicon-setting"></text>
</button>
<button class="u-reset-button sign-btn u-flex u-row-center u-col-center" @tap="jump('/pages/activity/sign/index')">
<text class="u-iconfont uicon-calendar sign-btn__icon"></text>
<text class="sign-btn__text">签到</text>
</button>
</view>
</view>
<view class="asset-bar u-flex">
<view class="asset-item u-flex-1 u-flex-col u-col-center" @tap="jump('/pages/user/wallet/index')">
<text class="asset-value font-OPPOSANS">{{ userInfo.money || '0.00' }}</text>
<text class="asset-label">余额(元)</text>
</view>
<view class="asset-divider"></view>
<view class="asset-item u-flex-1 u-flex-col u-col-center" @tap="jump('/pages/user/wallet/score-balance')">
<text class="asset-value font-OPPOSANS">{{ userInfo.score || '0' }}</text>
<text class="asset-label">积分</text>
</view>
<view class="asset-divider"></view>
<view class="asset-item u-flex-1 u-flex-col u-col-center" @tap="jump('/pages/app/coupon/list')">
<text class="asset-value font-OPPOSANS">{{ userOtherData.coupons_num || '0' }}</text>
<text class="asset-label">优惠券</text>
</view>
</view>
</view>
</view>
<!-- 绑定手机 -->
<!-- <view class="notice-box u-flex u-row-between u-p-30"
v-if="userInfo.verification && !userInfo.verification.mobile" @tap="bindMobile">
<view class="notice-detail">点击绑定手机号,确保账户安全</view>
<button class="u-reset-button bindPhone">去绑定</button>
</view> -->
<!-- <view class="notice-box u-flex u-row-between u-p-30"
v-if="userInfo.verification && !userInfo.verification.mobile" @tap="bindMobile">
<view class="notice-detail" v-if="!userInfo.mobile">点击绑定手机号,确保账户安全</view>
<view class="notice-detail" v-if="userInfo.mobile">当前手机号 {{userInfo.mobile}}</view>
<button class="u-reset-button bindPhone" v-if="!userInfo.mobile">去绑定</button>
<button class="u-reset-button bindPhone" v-if="userInfo.mobile">重新绑定</button>
</view> -->
<!-- 更新信息 -->
<view class="cu-modal" :class="{ show: showModal }" @tap="showModal = false">
<view class="cu-dialog" style="width: 600rpx;">
<view class="modal-box">
<view class="modal-head">提示</view>
<view class="modal-content">更新微信信息?</view>
<view class="modal-bottom u-flex u-col-center">
<button class="u-reset-button modal-btn cancel-btn" :hover-stay-time="100"
hover-class="btn-hover" @tap="showModal = false">取消</button>
<button class="u-reset-button modal-btn save-btn" :hover-stay-time="100"
hover-class="btn-hover" @tap="refreshWechatUser">确定</button>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
/**
* 自定义之个人信息
* @property {Object} detail - 个人信息
*/
import {
mapMutations,
mapActions,
mapState,
mapGetters
} from 'vuex';
import wechat from '@/shopro/wechat/wechat';
import theme from '@/shopro/config/theme.js';
const LEGACY_HEADER_COLORS = ['#FFA33E', '#ff1926', '#FF0e25', '#ff0e25', '#EFC480', '#001F54', '#003399', '#0066CC', '#0055AA'];
export default {
components: {},
data() {
return {
showModal: false,
platform: this.$platform.get(), //当前平台。
isFixed: false,
navBackground: {
background: 'none'
}
};
},
mounted() {},
props: {
detail: {},
scrollTop: {
type: Number,
default: 0
}
},
watch: {
scrollTop(val) {
this.isFixed = val > 50;
this.navBackground.background = val > 50
? `linear-gradient(180deg, ${theme.navy} 0%, ${theme.navyLight} 100%)`
: 'none';
}
},
computed: {
...mapGetters(['isLogin', 'userInfo', 'userOtherData', 'agentInfo']),
headBackgroundColor() {
const color = (this.detail && this.detail.color) || '';
if (!color || LEGACY_HEADER_COLORS.includes(color.toUpperCase()) || LEGACY_HEADER_COLORS.includes(color)) {
return theme.headerGradient;
}
return color;
},
headWrapStyle() {
if (this.detail && this.detail.image) {
return {
background: `url(${this.detail.image}) no-repeat center / 100% 100%`
};
}
return {
background: `linear-gradient(180deg, ${theme.navy} 0%, ${theme.navyLight} 100%)`
};
},
showRefresh() {
if (this.isLogin) {
if (this.platform === 'wxOfficialAccount') {
return this.userInfo.verification?.wxOfficialAccount;
}
if (this.platform === 'wxMiniProgram') {
return this.userInfo.verification.wxMiniProgram;
}
if (this.platform === 'App') {
return this.userInfo.verification.wxOpenPlatform;
}
}
return false;
},
referrerText() {
if (!this.isLogin) {
return '';
}
const parent = this.userInfo.parent_user;
if (parent && parent.nickname) {
return parent.nickname;
}
if (!this.userInfo.parent_user_id) {
return '无';
}
return '暂无';
},
roleTags() {
if (Array.isArray(this.userInfo.role_tags) && this.userInfo.role_tags.length) {
return this.userInfo.role_tags;
}
const tags = [];
if (this.userInfo.group && this.userInfo.group.name) {
tags.push(this.userInfo.group.name);
}
if (this.agentInfo && this.agentInfo.agent_level && this.agentInfo.agent_level.name) {
tags.push(this.agentInfo.agent_level.name);
}
return tags;
}
},
methods: {
...mapActions(['getUserInfo', 'showAuthModal']),
onProfileTap() {
if (this.isLogin) {
this.$Router.push('/pages/user/info');
return;
}
this.showAuthModal('accountLogin');
},
jump(path, query) {
this.$Router.push({
path: path,
query: query
});
},
// 点击分享
onShare() {
this.$emit('onShare');
},
// 同步用户信息
async refreshWechatUser() {
this.showModal = false;
let token = await wechat.refresh();
token && this.getUserInfo(token);
},
// 跳转门店(功能已关闭)
goStore() {
return;
},
// 绑定手机号
bindMobile() {
this.showAuthModal('bindMobile');
}
}
};
</script>
<style lang="scss">
// 更新信息
.modal-box {
width: 600rpx;
.btn-hover {
background-color: rgb(230, 230, 230);
}
.modal-head {
padding-top: 48rpx;
font-weight: 500;
text-align: center;
color: $u-main-color;
}
.modal-content {
padding: 48rpx;
font-size: 30rpx;
text-align: center;
color: $u-content-color;
}
.modal-bottom {
.modal-btn {
flex: 1;
height: 100rpx;
line-height: 100rpx;
font-size: 32rpx;
box-sizing: border-box;
cursor: pointer;
text-align: center;
border-radius: 4rpx;
}
.cancel-btn {
color: #666666;
}
.save-btn {
color: $brand-primary;
}
}
}
.sh-userinfo-box {
position: relative;
padding-bottom: 0;
.head-wrap {
width: 100%;
padding: 0 $brand-page-gutter 28rpx;
box-sizing: border-box;
}
.user-head {
width: 100%;
padding-top: 8rpx;
align-items: flex-start;
.info-box {
flex: 1;
min-width: 0;
align-items: flex-start;
.head-img-wrap {
position: relative;
flex-shrink: 0;
.refresh-btn {
position: absolute;
padding: 0;
width: 36rpx;
height: 36rpx;
border-radius: 50%;
background: $brand-primary;
top: -4rpx;
right: -4rpx;
.uicon-reload {
font-size: 20rpx;
color: #fff;
}
}
}
.head-img {
width: 112rpx;
height: 112rpx;
border-radius: 50%;
background: #eee;
border: 3rpx solid rgba(255, 255, 255, 0.35);
}
.user-meta {
margin-left: 20rpx;
min-width: 0;
flex: 1;
padding-top: 4rpx;
}
.user-name {
display: block;
font-size: 34rpx;
font-weight: 600;
line-height: 1.3;
color: $brand-text-on-primary;
max-width: 420rpx;
}
.user-sub-row {
margin-top: 10rpx;
max-width: 100%;
}
.user-id,
.user-referrer {
font-size: 22rpx;
color: rgba(255, 255, 255, 0.78);
line-height: 1.3;
}
.user-id {
flex-shrink: 0;
margin-right: 20rpx;
}
.user-referrer {
flex: 1;
min-width: 0;
}
.user-role-tags {
margin-top: 12rpx;
gap: 10rpx;
}
.role-tag {
padding: 4rpx 14rpx;
border-radius: 8rpx;
font-size: 20rpx;
line-height: 1.4;
color: rgba(255, 255, 255, 0.92);
background: rgba(255, 255, 255, 0.14);
border: 1rpx solid rgba(255, 255, 255, 0.22);
}
.user-desc {
display: block;
margin-top: 10rpx;
font-size: 22rpx;
color: rgba(255, 255, 255, 0.72);
line-height: 1.3;
}
}
.user-head__actions {
flex-shrink: 0;
margin-left: 12rpx;
padding-top: 4rpx;
display: flex;
flex-direction: column;
align-items: center;
}
.action-icon-btn {
width: 56rpx;
height: 56rpx;
border-radius: 50%;
background: transparent;
.uicon-setting {
font-size: 40rpx;
color: rgba(255, 255, 255, 0.92);
}
}
.sign-btn {
margin-top: 16rpx;
min-width: 108rpx;
height: 52rpx;
padding: 0 18rpx;
border-radius: 26rpx;
background: rgba(255, 255, 255, 0.92);
&__icon {
font-size: 24rpx;
color: $brand-primary;
margin-right: 6rpx;
}
&__text {
font-size: 24rpx;
color: $brand-primary;
font-weight: 500;
}
}
}
.asset-bar {
margin-top: 28rpx;
padding: 8rpx 0 4rpx;
}
.asset-item {
min-width: 0;
}
.asset-value {
font-size: 36rpx;
font-weight: 600;
color: #fff;
line-height: 1.2;
}
.asset-label {
margin-top: 8rpx;
font-size: 22rpx;
color: rgba(255, 255, 255, 0.72);
}
.asset-divider {
width: 1rpx;
height: 56rpx;
background: rgba(255, 255, 255, 0.22);
align-self: center;
}
}
// 绑定微信公众号
.notice-box {
width: 750rpx;
height: 70rpx;
background: rgba(253, 239, 216, 1);
padding: 0 35rpx;
.notice-detail {
font-size: 24rpx;
font-weight: 400;
color: rgba(204, 149, 59, 1);
}
.bindPhone {
width: 135rpx;
line-height: 52rpx;
background: linear-gradient(90deg, #1677FF, #4096FF);
border-radius: 26rpx;
padding: 0;
font-size: 26rpx;
font-weight: 500;
color: rgba(255, 255, 255, 1);
}
}
</style>
}
</style>
</style>