【门店端】 提交

This commit is contained in:
Ghost
2025-04-09 09:34:27 +08:00
parent 3d49092cf7
commit c78ded8a7c
31 changed files with 10541 additions and 1 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,374 @@
<template>
<view class="login-container" v-if="show" style="margin-top: var(--status-bar-height);">
<view class="login-wrapper">
<!-- 标签切换 -->
<u-tabs
:list="tabList"
:current="currentTab === 'verification' ? 0 : 1"
@change="tabChange"
:is-scroll="false"
inactive-color="#666"
active-color="#333"
item-style="height: 45px;"
bg-color="#f5f7fa"
></u-tabs>
<!-- 提示文本 -->
<view class="tip-text">
您所在地区仅支持 手机号 / 微信 / Apple 登录
</view>
<!-- 手机号输入 -->
<u-input
v-model="phoneNumber"
:clearable="true"
type="number"
placeholder="手机号"
prefixIcon="phone"
:border="true"
maxlength="11"
>
<template slot="prefix">
<text style="margin-right: 10px; color: #333; padding-right: 10px; border-right: 1px solid #eee">+86</text>
</template>
</u-input>
<!-- 验证码或密码输入 -->
<view v-if="currentTab === 'verification'" style="margin-top: 15px;">
<u-input
v-model="verificationCode"
:clearable="true"
type="number"
placeholder="验证码"
:border="true"
maxlength="6"
>
<template slot="suffix">
<u-button
size="mini"
:text="codeSending ? `${countDown}秒后重发` : '发送验证码'"
type="primary"
:disabled="codeSending || !phoneNumber || phoneNumber.length !== 11"
@click="sendVerificationCode"
style="margin-left: 5px; min-width: 100px;"
></u-button>
</template>
</u-input>
</view>
<view v-if="currentTab === 'password'" style="margin-top: 15px;">
<u-input
v-model="password"
type="password"
:password="!showPassword"
placeholder="密码"
:border="true"
>
<template slot="suffix">
<u-icon
:name="showPassword ? 'eye-fill' : 'eye-off'"
size="22"
color="#c0c4cc"
@click="showPassword = !showPassword"
></u-icon>
</template>
</u-input>
</view>
<!-- 用户协议 -->
<view class="agreement-container">
<u-checkbox
v-model="agreedTerms"
shape="circle"
active-color="#4080ff"
></u-checkbox>
<text class="agreement-text">已阅读并同意</text>
<text class="agreement-link" @tap="openProtocol">用户协议</text>
<text class="agreement-text"></text>
<text class="agreement-link" @tap="openPrivacy">隐私政策</text>
</view>
<!-- 登录按钮 -->
<u-button
text="登录"
type="primary"
shape="circle"
:disabled="!isFormValid"
@click="handleLogin"
:custom-style="{marginTop: '20px', marginBottom: '25px'}"
></u-button>
<!-- 分隔线 -->
<u-divider text="或" :hairline="true"></u-divider>
<!-- 第三方登录 -->
<view class="third-party-login">
<u-button
text="使用微信登录"
shape="circle"
@click="handleWechatLogin"
:ripple="true"
:custom-style="{backgroundColor: '#07c160', color: '#ffffff', marginBottom: '15px'}"
>
<template slot="default">
<u-icon name="weixin-fill" color="#ffffff" size="18" style="margin-right: 5px;"></u-icon>
<text>使用微信登录</text>
</template>
</u-button>
<u-button
text="使用 Apple 登录"
shape="circle"
@click="handleAppleLogin"
:ripple="true"
:custom-style="{backgroundColor: '#000000', color: '#ffffff'}"
>
<template slot="default">
<u-icon name="apple-fill" color="#ffffff" size="18" style="margin-right: 5px;"></u-icon>
<text>使用 Apple 登录</text>
</template>
</u-button>
</view>
<!-- 联系我们 -->
<view class="contact-us" @tap="handleContact">
联系我们
</view>
</view>
</view>
</template>
<script>
export default {
name: 'LoginRegister',
props: {
show: {
type: Boolean,
default: false
}
},
data() {
return {
tabList: [{name: '验证码登录'}, {name: '密码登录'}],
currentTab: 'verification', // verification 或 password
phoneNumber: '',
verificationCode: '',
password: '',
showPassword: false,
agreedTerms: false,
codeSending: false,
countDown: 60
}
},
computed: {
isFormValid() {
const phoneValid = this.phoneNumber && this.phoneNumber.length === 11;
if (this.currentTab === 'verification') {
return phoneValid && this.verificationCode && this.agreedTerms;
} else {
return phoneValid && this.password && this.agreedTerms;
}
}
},
methods: {
tabChange(index) {
this.currentTab = index === 0 ? 'verification' : 'password';
},
openProtocol() {
uni.showToast({
title: '打开用户协议',
icon: 'none'
});
},
openPrivacy() {
uni.showToast({
title: '打开隐私政策',
icon: 'none'
});
},
sendVerificationCode() {
if (this.codeSending) return;
if (!this.phoneNumber || this.phoneNumber.length !== 11) {
uni.showToast({
title: '请输入正确的手机号',
icon: 'none'
});
return;
}
this.codeSending = true;
this.countDown = 60;
// 模拟发送验证码
uni.showToast({
title: '验证码已发送',
icon: 'success'
});
// 倒计时
const timer = setInterval(() => {
this.countDown--;
if (this.countDown <= 0) {
clearInterval(timer);
this.codeSending = false;
}
}, 1000);
},
handleLogin() {
if (!this.isFormValid) return;
// 验证手机号格式
if (!/^1\d{10}$/.test(this.phoneNumber)) {
uni.showToast({
title: '请输入正确的手机号',
icon: 'none'
});
return;
}
// 根据当前登录方式验证
if (this.currentTab === 'verification') {
if (!this.verificationCode || this.verificationCode.length !== 6) {
uni.showToast({
title: '请输入6位验证码',
icon: 'none'
});
return;
}
} else {
if (!this.password || this.password.length < 6) {
uni.showToast({
title: '密码不能少于6位',
icon: 'none'
});
return;
}
}
// 模拟登录过程
uni.showLoading({
title: '登录中...'
});
setTimeout(() => {
uni.hideLoading();
uni.showToast({
title: '登录成功',
icon: 'success',
duration: 1500,
success: () => {
// 登录成功后关闭登录页
setTimeout(() => {
this.$emit('close');
// 模拟返回用户信息
const userInfo = {
id: '123456',
nickname: '用户_' + Math.floor(Math.random() * 10000),
phone: this.phoneNumber,
avatar: ''
};
this.$emit('login-success', userInfo);
}, 1500);
}
});
}, 1500);
},
handleWechatLogin() {
uni.showToast({
title: '微信登录功能暂未实现',
icon: 'none'
});
},
handleAppleLogin() {
uni.showToast({
title: 'Apple登录功能暂未实现',
icon: 'none'
});
},
handleContact() {
uni.showToast({
title: '联系方式: support@example.com',
icon: 'none'
});
}
}
}
</script>
<style lang="scss">
.login-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 10001;
display: flex;
justify-content: center;
align-items: center;
}
.login-wrapper {
width: 100%;
height: 100%;
background-color: #fff;
border-radius: 0;
padding: 20px;
box-sizing: border-box;
display: flex;
flex-direction: column;
animation: slideInFromBottom 0.3s ease;
}
@keyframes slideInFromBottom {
from {
transform: translateY(100%);
}
to {
transform: translateY(0);
}
}
.tip-text {
font-size: 14px;
color: #666;
margin: 15px 0 20px;
line-height: 1.5;
}
.agreement-container {
display: flex;
align-items: center;
margin-top: 15px;
}
.agreement-text {
font-size: 12px;
color: #999;
margin-left: 5px;
}
.agreement-link {
font-size: 12px;
color: #4080ff;
margin: 0 4px;
}
.third-party-login {
display: flex;
flex-direction: column;
margin: 20px 0 30px;
}
.contact-us {
text-align: center;
color: #666;
font-size: 14px;
margin-top: auto;
padding: 15px 0;
}
</style>

View File

@@ -0,0 +1,386 @@
<template>
<view v-if="show" class="package-detail-container" style="margin-top: var(--status-bar-height);">
<!-- 头部 -->
<view class="header">
<view class="back-icon" @tap="closePage">
<u-icon name="arrow-left" color="#333" size="26"></u-icon>
</view>
<view class="title">{{packageData.name}}</view>
<view class="close-icon" @tap="closePage">
<u-icon name="close" color="#333" size="24"></u-icon>
</view>
</view>
<!-- 套餐价格 -->
<view class="price-card">
<view class="price-title">套餐价格</view>
<view class="price-content">
<view class="main-price">
<text class="price-symbol">¥</text>
<text class="price-value">{{packageData.price}}</text>
</view>
<view class="original-price-tag">原价</view>
</view>
<view class="original-price" v-if="packageData.originalPrice !== packageData.price">
<text class="crossed-price">¥{{packageData.originalPrice}}</text>
</view>
</view>
<!-- 套餐详情 -->
<view class="detail-card">
<view class="detail-title">套餐详情</view>
<view class="detail-item" v-for="item in packageData.details" :key="item.label">
<text class="detail-label">{{item.label}}</text>
<text class="detail-value">{{item.value}}</text>
</view>
</view>
<!-- 套餐特权 -->
<view class="privilege-card">
<view class="detail-title">套餐特权</view>
<view class="privilege-item" v-for="item in packageData.privileges" :key="item">
<view class="privilege-icon">
<u-icon name="checkmark" color="#0080ff" size="16"></u-icon>
</view>
<text class="privilege-text">{{item}}</text>
</view>
</view>
<!-- 立即购买按钮 -->
<view class="buy-button">
<u-button
type="primary"
text="立即购买"
shape="circle"
@click="handleBuy"
:custom-style="{
width: '90%',
height: '44px',
marginTop: '20px',
marginBottom: '30px'
}"
></u-button>
</view>
<!-- 购买说明 -->
<view class="purchase-info">
<text class="info-text">流量将在购买后24小时内接入</text>
</view>
</view>
</template>
<script>
import { trafficApi } from '../api/modules/traffic';
export default {
name: 'PackageDetail',
props: {
show: {
type: Boolean,
default: false
},
packageData: {
type: Object,
default: () => ({
id: 1,
name: '基础流量包',
price: 980,
originalPrice: 990,
specs: '20人/月·30天',
details: [
{ label: '每月流量', value: '20人/月' },
{ label: '套餐时长', value: '30天' },
{ label: '总流量', value: '600人' }
],
privileges: [
'引流到微信',
'每日流量报告',
'基础客户标签'
]
})
}
},
data() {
return {
// 订单信息
orderInfo: null,
// 购买状态
buying: false
}
},
methods: {
closePage() {
this.$emit('close');
},
async handleBuy() {
if (this.buying) return;
this.buying = true;
uni.showLoading({
title: '创建订单...',
mask: true
});
try {
// 调用创建订单接口
const response = await trafficApi.createOrder(this.packageData.id);
// 隐藏加载中
uni.hideLoading();
if (response.code === 200) {
this.orderInfo = response.data;
// 显示订单创建成功提示
uni.showToast({
title: '订单创建成功',
icon: 'success',
duration: 2000
});
// 模拟跳转到支付页面
setTimeout(() => {
this.showPaymentModal();
}, 1000);
} else {
// 显示错误信息
uni.showToast({
title: response.msg || '创建订单失败',
icon: 'none',
duration: 2000
});
}
} catch (err) {
// 隐藏加载中
uni.hideLoading();
// 显示错误信息
uni.showToast({
title: '网络异常,请稍后重试',
icon: 'none',
duration: 2000
});
console.error('创建订单错误:', err);
} finally {
this.buying = false;
}
},
// 显示支付弹窗
showPaymentModal() {
if (!this.orderInfo) return;
uni.showModal({
title: '订单支付',
content: `订单号: ${this.orderInfo.orderNo}\n金额: ¥${this.orderInfo.amount}\n支付方式: ${this.orderInfo.payType === 'wechat' ? '微信支付' : '其他支付方式'}`,
confirmText: '去支付',
cancelText: '取消',
success: (res) => {
if (res.confirm) {
// 模拟支付成功
uni.showLoading({
title: '支付处理中'
});
setTimeout(() => {
uni.hideLoading();
uni.showToast({
title: '支付成功',
icon: 'success',
duration: 2000
});
// 关闭页面
setTimeout(() => {
this.closePage();
// 触发购买成功事件,通知父组件刷新数据
this.$emit('buy-success');
}, 1500);
}, 2000);
}
}
});
}
}
}
</script>
<style lang="scss">
.package-detail-container {
position: fixed;
top: 0;
right: 0;
width: 100%;
height: 100%;
background-color: #f5f7fa;
z-index: 10000;
overflow-y: auto;
transform-origin: right;
animation: slideInFromRight 0.3s ease;
}
@keyframes slideInFromRight {
from {
transform: translateX(100%);
}
to {
transform: translateX(0);
}
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 15px;
background-color: #fff;
border-bottom: 1px solid #eee;
position: sticky;
top: 0;
z-index: 1;
}
.back-icon {
width: 60px;
display: flex;
align-items: center;
}
.title {
font-size: 17px;
font-weight: 500;
flex: 1;
text-align: center;
}
.close-icon {
width: 60px;
display: flex;
justify-content: flex-end;
}
.price-card {
margin: 15px;
padding: 15px;
background-color: #e6f4ff;
border-radius: 10px;
}
.price-title {
font-size: 15px;
font-weight: 500;
color: #333;
margin-bottom: 10px;
}
.price-content {
display: flex;
align-items: center;
}
.main-price {
display: flex;
align-items: baseline;
}
.price-symbol {
font-size: 18px;
font-weight: bold;
color: #0080ff;
}
.price-value {
font-size: 28px;
font-weight: bold;
color: #0080ff;
}
.original-price-tag {
margin-left: 15px;
padding: 2px 10px;
background-color: #fff;
border-radius: 4px;
font-size: 12px;
color: #666;
}
.original-price {
margin-top: 5px;
}
.crossed-price {
font-size: 14px;
color: #999;
text-decoration: line-through;
}
.detail-card, .privilege-card {
margin: 15px;
padding: 15px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.detail-title {
font-size: 15px;
font-weight: 500;
color: #333;
margin-bottom: 15px;
}
.detail-item {
display: flex;
justify-content: space-between;
padding: 10px 0;
border-bottom: 1px solid #f5f5f5;
}
.detail-item:last-child {
border-bottom: none;
}
.detail-label {
color: #333;
font-size: 14px;
}
.detail-value {
color: #666;
font-size: 14px;
}
.privilege-item {
display: flex;
align-items: center;
margin-bottom: 12px;
}
.privilege-icon {
margin-right: 8px;
display: flex;
align-items: center;
}
.privilege-text {
font-size: 14px;
color: #333;
}
.buy-button {
display: flex;
justify-content: center;
margin-top: 20px;
}
.purchase-info {
text-align: center;
margin-bottom: 30px;
}
.info-text {
font-size: 12px;
color: #999;
}
</style>

View File

@@ -0,0 +1,754 @@
<template>
<view v-if="show" class="side-menu-container" style="margin-top: var(--status-bar-height);">
<view class="side-menu-mask" @tap="closeSideMenu"></view>
<view class="side-menu">
<view class="side-menu-header">
<text class="side-menu-title">艺施赋能</text>
<text class="close-icon" @tap="closeSideMenu">
<u-icon name="close" color="#333" size="24"></u-icon>
</text>
</view>
<!-- 功能模块 -->
<view class="function-module">
<view class="function-grid">
<!-- 第一行 -->
<view class="function-row">
<view class="function-item pink" :class="{'function-item-disabled': !functionStatus['autoLike']}" @tap="handleFunctionClick('autoLike')">
<text class="iconfont icon-dianzan function-icon" style="color: #ff6699; font-size: 26px;"></text>
<text class="function-name">自动点赞</text>
<text class="function-status" :style="functionStatus['autoLike'] ? 'color: #ff6699; font-size: 12px;' : 'color: #999; font-size: 12px;'">
{{ functionStatus['autoLike'] ? '已启用' : '已禁用' }}
</text>
</view>
<view class="function-item purple" :class="{'function-item-disabled': !functionStatus['momentsSync']}" @tap="handleFunctionClick('momentsSync')">
<text class="iconfont icon-tupian function-icon" style="color: #9966ff; font-size: 26px;"></text>
<text class="function-name">朋友圈同步</text>
<text class="function-status" :style="functionStatus['momentsSync'] ? 'color: #9966ff; font-size: 12px;' : 'color: #999; font-size: 12px;'">
{{ functionStatus['momentsSync'] ? '已启用' : '已禁用' }}
</text>
</view>
<view class="function-item green" :class="{'function-item-disabled': !functionStatus['autoCustomerDev']}" @tap="handleFunctionClick('autoCustomerDev')">
<text class="iconfont icon-yonghu function-icon" style="color: #33cc99; font-size: 26px;"></text>
<text class="function-name">自动开发客户</text>
<text class="function-status" :style="functionStatus['autoCustomerDev'] ? 'color: #33cc99; font-size: 12px;' : 'color: #999; font-size: 12px;'">
{{ functionStatus['autoCustomerDev'] ? '已启用' : '已禁用' }}
</text>
</view>
</view>
<!-- 第二行 -->
<view class="function-row">
<view class="function-item orange" :class="{'function-item-disabled': !functionStatus['groupMessageDeliver']}" @tap="handleFunctionClick('groupMessageDeliver')">
<text class="iconfont icon-xiaoxi function-icon" style="color: #ff9966; font-size: 26px;"></text>
<text class="function-name">群消息推送</text>
<text class="function-status" :style="functionStatus['groupMessageDeliver'] ? 'color: #ff9966; font-size: 12px;' : 'color: #999; font-size: 12px;'">
{{ functionStatus['groupMessageDeliver'] ? '已启用' : '已禁用' }}
</text>
</view>
<view class="function-item blue" :class="{'function-item-disabled': !functionStatus['autoGroup']}" @tap="handleFunctionClick('autoGroup')">
<text class="iconfont icon-yonghuqun function-icon" style="color: #6699ff; font-size: 26px;"></text>
<text class="function-name">自动建群</text>
<text class="function-status" :style="functionStatus['autoGroup'] ? 'color: #6699ff; font-size: 12px;' : 'color: #999; font-size: 12px;'">
{{ functionStatus['autoGroup'] ? '已启用' : '已禁用' }}
</text>
</view>
<view class="function-item" style="visibility: hidden;">
<!-- 空白占位 -->
</view>
</view>
</view>
</view>
<!-- 采购中心 -->
<view class="module-section">
<view class="module-title">采购中心</view>
<view class="module-list">
<view class="module-item" @tap="showTrafficPurchase">
<view class="module-left">
<view class="module-icon blue">
<text class="iconfont icon-shangsheng" style="color: #5096ff; font-size: 24px;"></text>
</view>
<view class="module-info">
<text class="module-name">流量采购</text>
<text class="module-desc">自动导入流量到微信</text>
</view>
</view>
</view>
<view class="module-item" @tap="showSupplyChainPurchase">
<view class="module-left">
<view class="module-icon yellow">
<text class="iconfont icon-gouwuchekong" style="color: #ffc107; font-size: 24px;"></text>
</view>
<view class="module-info">
<text class="module-name">供应链采购</text>
<text class="module-desc">管理供应链业务</text>
</view>
</view>
</view>
</view>
</view>
<!-- 数据中心 -->
<view class="module-section">
<view class="module-title">数据中心</view>
<view class="module-list">
<view class="module-item" @tap="showDataStatistics">
<view class="module-left">
<view class="module-icon blue">
<text class="iconfont icon-shujutongji" style="color: #5096ff; font-size: 24px;"></text>
</view>
<view class="module-info">
<text class="module-name">数据统计</text>
<text class="module-desc">查看业务数据统计</text>
</view>
</view>
</view>
<view class="module-item" @tap="showCustomerManagement">
<view class="module-left">
<view class="module-icon blue">
<text class="iconfont icon-yonghuqun" style="color: #5096ff; font-size: 24px;"></text>
</view>
<view class="module-info">
<text class="module-name">客户管理</text>
<text class="module-desc">管理客户资料信息</text>
</view>
</view>
</view>
<view class="module-item" @tap="showSettings">
<view class="module-left">
<view class="module-icon gray">
<text class="iconfont icon-shezhi" style="color: #888; font-size: 24px;"></text>
</view>
<view class="module-info">
<text class="module-name">系统设置</text>
<text class="module-desc">配置系统参数</text>
</view>
</view>
</view>
</view>
</view>
<!-- 底部登录按钮 -->
<view class="bottom-button" @tap="isLoggedIn ? logout() : showLoginPage()">
<text class="iconfont" :class="isLoggedIn ? 'icon-tuichu' : 'icon-denglu'" :style="isLoggedIn ? 'color: #333; font-size: 18px;' : 'color: #333; font-size: 18px;'"></text>
<text class="login-text">{{ isLoggedIn ? '退出登录' : '登录/注册' }}</text>
</view>
</view>
<!-- 流量采购页面 -->
<traffic-purchase :show="showTrafficPage" @close="closeTrafficPurchase"></traffic-purchase>
<!-- 供应链采购页面 -->
<supply-chain-purchase :show="showSupplyChainPage" @close="closeSupplyChainPurchase"></supply-chain-purchase>
<!-- 系统设置页面 -->
<system-settings :show="showSystemSettingsPage" @close="closeSystemSettings"></system-settings>
<!-- 数据统计页面 -->
<data-statistics :show="showDataStatisticsPage" @close="closeDataStatistics"></data-statistics>
<!-- 客户管理页面 -->
<customer-management :show="showCustomerManagementPage" @close="closeCustomerManagement"></customer-management>
<!-- 登录注册页面 -->
<login-register
:show="showLoginPageFlag"
@close="closeLoginPage"
@login-success="handleLoginSuccess"
></login-register>
</view>
</template>
<script>
import TrafficPurchase from './TrafficPurchase.vue';
import SupplyChainPurchase from './SupplyChainPurchase.vue';
import SystemSettings from './SystemSettings.vue';
import LoginRegister from './LoginRegister.vue';
import DataStatistics from './DataStatistics.vue';
import CustomerManagement from './CustomerManagement.vue';
import { hasValidToken, clearToken, redirectToLogin } from '../api/utils/auth';
import { request } from '../api/config';
export default {
name: "SideMenu",
components: {
TrafficPurchase,
SupplyChainPurchase,
SystemSettings,
LoginRegister,
DataStatistics,
CustomerManagement
},
props: {
show: {
type: Boolean,
default: false
}
},
data() {
return {
functionStatus: {
'autoLike': false,
'momentsSync': false,
'autoCustomerDev': false,
'groupMessageDeliver': false,
'autoGroup': false
},
showTrafficPage: false,
showSupplyChainPage: false,
showSystemSettingsPage: false,
showDataStatisticsPage: false,
showCustomerManagementPage: false,
showLoginPageFlag: false,
isLoggedIn: false, // 用户登录状态
userInfo: null // 用户信息
}
},
watch: {
// 侧边栏显示时检查登录状态
show(newVal) {
if (newVal) {
this.checkLoginStatus();
}
}
},
onShow() {
// 获取用户登录状态
this.checkLoginStatus();
// 获取功能开关状态
this.getFunctionStatus();
},
created() {
// 获取用户登录状态
this.checkLoginStatus();
// 获取功能开关状态
this.getFunctionStatus();
},
methods: {
// 检查登录状态
checkLoginStatus() {
// 使用token判断登录状态
this.isLoggedIn = hasValidToken();
// 如果已登录,尝试获取用户信息
if (this.isLoggedIn) {
try {
const memberStr = uni.getStorageSync('member');
if (memberStr) {
this.userInfo = JSON.parse(memberStr);
}
} catch (e) {
console.error('获取用户信息失败', e);
this.userInfo = null;
}
} else {
this.userInfo = null;
}
console.log(this.userInfo);
},
// 退出登录
logout() {
// 清除token和用户信息
clearToken();
// 清除旧的userInfo兼容
try {
uni.removeStorageSync('userInfo');
} catch(e) {
console.error('清除用户信息失败', e);
}
// 重置登录状态
this.userInfo = null;
this.isLoggedIn = false;
// 关闭侧边栏
this.closeSideMenu();
// 提示退出成功
uni.showToast({
title: '已退出登录',
icon: 'success',
duration: 1500
});
// 跳转到登录页
setTimeout(() => {
redirectToLogin();
}, 1000);
},
closeSideMenu() {
this.$emit('close');
},
// 获取功能开关状态
async getFunctionStatus() {
try {
const res = await request({
url: '/v1/store/system-config/switch-status',
method: 'GET'
});
if (res.code === 200 && res.data) {
// 更新功能状态
this.functionStatus = {
'autoLike': res.data.autoLike || false,
'momentsSync': res.data.momentsSync || false,
'autoCustomerDev': res.data.autoCustomerDev || false,
'groupMessageDeliver': res.data.groupMessageDeliver || false,
'autoGroup': res.data.autoGroup || false
};
console.log('功能状态已更新:', this.functionStatus);
} else {
console.error('获取功能状态失败:', res.msg);
}
} catch (err) {
console.error('获取功能状态异常:', err);
}
},
handleFunctionClick(name) {
// 切换功能状态
this.functionStatus[name] = !this.functionStatus[name];
// 显示提示的中文名称映射
const nameMap = {
'autoLike': '自动点赞',
'momentsSync': '朋友圈同步',
'autoCustomerDev': '自动开发客户',
'groupMessageDeliver': '群消息推送',
'autoGroup': '自动建群'
};
// 准备更新状态
const newStatus = this.functionStatus[name];
// 调用接口更新状态
request({
url: '/v1/store/system-config/update-switch-status',
method: 'POST',
data: {
switchName: name,
}
}).then(res => {
if (res.code === 200) {
// 更新本地状态
this.functionStatus[name] = newStatus;
// 显示提示
uni.showToast({
title: newStatus ? `${nameMap[name]}已启用` : `${nameMap[name]}已禁用`,
icon: 'none'
});
// 重新获取所有功能状态
this.getFunctionStatus();
} else {
// 显示错误提示
uni.showToast({
title: res.msg || '操作失败',
icon: 'none'
});
}
}).catch(err => {
console.error('更新功能状态失败:', err);
uni.showToast({
title: '网络异常,请稍后重试',
icon: 'none'
});
});
},
handleModuleClick(name) {
if (name === '供应链采购') {
this.showSupplyChainPage = true;
} else if (name === '数据统计') {
this.showDataStatistics();
} else if (name === '客户管理') {
this.showCustomerManagement();
} else {
uni.showToast({
title: `访问${name}`,
icon: 'none'
});
}
},
showTrafficPurchase() {
// 显示流量采购页面
this.showTrafficPage = true;
},
closeTrafficPurchase() {
// 只关闭流量采购页面,保持侧边菜单打开
this.showTrafficPage = false;
},
showSupplyChainPurchase() {
// 显示供应链采购页面
this.showSupplyChainPage = true;
},
closeSupplyChainPurchase() {
// 只关闭供应链采购页面,保持侧边菜单打开
this.showSupplyChainPage = false;
},
showSystemSettings() {
// 显示系统设置页面
this.showSystemSettingsPage = true;
},
closeSystemSettings() {
// 关闭系统设置页面
this.showSystemSettingsPage = false;
},
showDataStatistics() {
// 显示数据统计页面
this.showDataStatisticsPage = true;
},
closeDataStatistics() {
// 关闭数据统计页面
this.showDataStatisticsPage = false;
},
showCustomerManagement() {
// 显示客户管理页面
this.showCustomerManagementPage = true;
},
closeCustomerManagement() {
// 关闭客户管理页面
this.showCustomerManagementPage = false;
},
showLoginPage() {
// 关闭侧边菜单
this.closeSideMenu();
// 跳转到登录页面
redirectToLogin();
},
closeLoginPage() {
// 关闭登录/注册页面
this.showLoginPageFlag = false;
},
handleLoginSuccess(userInfo) {
// 处理登录成功事件
this.isLoggedIn = true;
this.userInfo = userInfo;
uni.showToast({
title: '登录成功',
icon: 'success'
});
},
handleLogin() {
// 修改原有方法,调用显示登录页面
this.showLoginPage();
},
goToUserCenter() {
// 跳转到用户中心页面
uni.navigateTo({
url: '/pages/login/user'
});
// 关闭侧边栏
this.closeSideMenu();
},
showSettings() {
// 显示系统设置页面
this.showSystemSettingsPage = true;
}
}
}
</script>
<style lang="scss">
.side-menu-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 9999;
}
.side-menu-mask {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: rgba(0, 0, 0, 0.5);
z-index: 1;
}
.side-menu {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #fff;
z-index: 2;
display: flex;
flex-direction: column;
animation: slideIn 0.3s ease;
overflow-y: auto;
transition: transform 0.3s ease;
}
@keyframes slideIn {
from {
transform: translateX(-100%);
}
to {
transform: translateX(0);
}
}
.side-menu-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px 15px;
border-bottom: 1px solid #f5f5f5;
}
.side-menu-title {
font-size: 18px;
font-weight: 500;
}
.close-icon {
font-size: 24px;
color: #666;
padding: 0 10px;
}
.function-module {
padding: 15px;
}
.function-grid {
display: flex;
flex-direction: column;
margin: 0 -5px;
}
.function-row {
display: flex;
width: 100%;
margin-bottom: 10px;
}
.function-item {
flex: 1;
margin: 0 5px;
border-radius: 10px;
padding: 15px 12px;
display: flex;
flex-direction: column;
align-items: center;
box-sizing: border-box;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
border: 1px solid rgba(0, 0, 0, 0.05);
}
.function-icon {
font-size: 24px;
margin-bottom: 8px;
display: flex;
justify-content: center;
align-items: center;
}
.iconfont.function-icon {
font-size: 28px;
color: inherit;
height: 28px;
width: 28px;
display: flex;
justify-content: center;
align-items: center;
}
.function-name {
font-size: 12px;
color: #333;
margin-bottom: 5px;
font-weight: 500;
}
.function-status {
font-size: 12px;
color: #666;
padding: 2px 0;
}
.function-item-disabled {
opacity: 0.7;
background-color: #f5f5f5 !important;
}
.pink {
background-color: #ffecf1;
}
.purple {
background-color: #f5ecff;
}
.green {
background-color: #e5fff2;
}
.orange {
background-color: #fff7ec;
}
.blue {
background-color: #ecf5ff;
}
.yellow {
background-color: #fffcec;
}
.gray {
background-color: #f5f5f5;
}
.module-section {
padding: 10px 15px;
}
.module-title {
font-size: 16px;
font-weight: 500;
margin-bottom: 10px;
}
.module-list {
border-radius: 10px;
background-color: #fff;
overflow: hidden;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}
.module-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 15px;
border-bottom: 1px solid #f5f5f5;
}
.module-item:last-child {
border-bottom: none;
}
.module-left {
display: flex;
align-items: center;
}
.module-icon {
width: 40px;
height: 40px;
border-radius: 8px;
display: flex;
justify-content: center;
align-items: center;
margin-right: 10px;
font-size: 20px;
}
.module-info {
display: flex;
flex-direction: column;
}
.module-name {
font-size: 16px;
color: #333;
margin-bottom: 3px;
}
.module-desc {
font-size: 12px;
color: #999;
}
.bottom-button {
margin-top: auto;
margin: 20px 15px;
padding: 12px 0;
border-radius: 5px;
background-color: #fff;
border: 1px solid #e5e5e5;
display: flex;
justify-content: center;
align-items: center;
}
.login-icon {
font-size: 16px;
margin-right: 5px;
}
.login-text {
font-size: 15px;
color: #333;
}
.user-info {
display: flex;
align-items: center;
padding: 15px;
border-bottom: 1px solid #f5f5f5;
}
.avatar {
width: 40px;
height: 40px;
border-radius: 50%;
margin-right: 10px;
}
.user-details {
flex: 1;
}
.nickname {
font-size: 16px;
color: #333;
margin-bottom: 5px;
}
.member-info {
font-size: 12px;
color: #999;
}
.level-tag {
padding: 2px 5px;
border-radius: 5px;
background-color: #e5e5e5;
margin-right: 5px;
}
.vip {
background-color: #ffd700;
}
.points {
font-size: 12px;
color: #999;
}
.not-logged-in {
padding: 15px;
border-bottom: 1px solid #f5f5f5;
}
.login-tip {
font-size: 12px;
color: #999;
}
</style>

View File

@@ -0,0 +1,424 @@
<template>
<view class="supply-chain-wrapper">
<view v-if="show" class="supply-chain-container" style="margin-top: var(--status-bar-height);">
<!-- 头部 -->
<view class="header">
<view class="back-icon" @tap="closePage">
<u-icon name="arrow-left" color="#333" size="26"></u-icon>
</view>
<view class="title">供应链采购</view>
<view class="close-icon" @tap="closePage">
<u-icon name="close" color="#333" size="24"></u-icon>
</view>
</view>
<!-- 套餐卡片区域 -->
<view class="package-list">
<view
v-for="item in packages"
:key="item.id"
class="package-card"
@tap="openPackageDetail(item)"
>
<view class="package-content">
<view class="cart-icon">
<text class="cart-text">
<u-icon name="shopping-cart" size='35px' color='#CA8A04'></u-icon>
</text>
</view>
<view class="package-info">
<view class="package-name">
{{item.name}}
<text v-if="item.specialTag" class="special-tag">{{item.specialTag}}</text>
</view>
<view class="package-price">
<text class="price-value">¥{{item.price}}</text>
<text class="original-price" v-if="item.originalPrice !== item.price">¥{{item.originalPrice}}</text>
</view>
<view class="advance-payment" v-if="item.advancePayment">预付款: ¥{{item.advancePayment}}</view>
</view>
<view class="discount-tag" v-if="item.discount">{{item.discount}}</view>
</view>
</view>
</view>
</view>
<!-- 套餐详情页面 -->
<supply-item-detail
:show="showPackageDetail"
:package-data="currentPackage"
@close="closePackageDetail"
></supply-item-detail>
</view>
</template>
<script>
import SupplyItemDetail from './SupplyItemDetail.vue';
export default {
name: 'SupplyChainPurchase',
components: {
'supply-item-detail': SupplyItemDetail
},
props: {
show: {
type: Boolean,
default: false
}
},
data() {
return {
// 套餐数据
packages: [
{
id: 1,
name: '基础套餐',
price: '2980',
originalPrice: '3725',
discount: '8折',
specialTag: '',
advancePayment: '745',
services: [
{
name: '头部护理SPA',
price: '598',
originalPrice: '718',
duration: '60分钟',
image: '/static/spa1.png'
},
{
name: '臂油SPA',
price: '618',
originalPrice: '838',
duration: '90分钟',
image: '/static/spa2.png'
},
{
name: '法/LAWF型颜度护理',
price: '1580',
originalPrice: '1896',
duration: '120分钟',
image: '/static/spa3.png'
}
],
details: [
{ label: '采购额度', value: '3000元' },
{ label: '套餐时长', value: '30天' },
{ label: '采购种类', value: '标准品类' }
],
privileges: [
'标准采购价格',
'7天内发货',
'基础供应商渠道'
]
},
{
id: 2,
name: '进级套餐',
price: '6980',
originalPrice: '9971',
discount: '7折',
specialTag: '',
advancePayment: '',
services: [
{
name: '进阶头部护理SPA',
price: '898',
originalPrice: '1218',
duration: '90分钟',
image: '/static/spa1.png'
},
{
name: '全身SPA',
price: '1618',
originalPrice: '2138',
duration: '120分钟',
image: '/static/spa2.png'
},
{
name: '高级LAWF型颜度护理',
price: '2880',
originalPrice: '3596',
duration: '150分钟',
image: '/static/spa3.png'
},
{
name: '肌肤管理',
price: '1290',
originalPrice: '1590',
duration: '60分钟',
image: '/static/spa4.png'
}
],
details: [
{ label: '采购额度', value: '7000元' },
{ label: '套餐时长', value: '30天' },
{ label: '采购种类', value: '全部品类' }
],
privileges: [
'优惠采购价格',
'3天内发货',
'优质供应商渠道',
'专属采购顾问'
]
},
{
id: 3,
name: '尊享套餐',
price: '19800',
originalPrice: '33000',
discount: '6折',
specialTag: '品优惠',
advancePayment: '',
services: [
{
name: '尊享头部护理SPA',
price: '1298',
originalPrice: '1818',
duration: '120分钟',
image: '/static/spa1.png'
},
{
name: '尊享全身SPA',
price: '2618',
originalPrice: '3738',
duration: '180分钟',
image: '/static/spa2.png'
},
{
name: '奢华LAWF型颜度护理',
price: '4880',
originalPrice: '6996',
duration: '210分钟',
image: '/static/spa3.png'
},
{
name: '尊享肌肤管理',
price: '2490',
originalPrice: '3290',
duration: '90分钟',
image: '/static/spa4.png'
},
{
name: '私人定制美容方案',
price: '5990',
originalPrice: '8990',
duration: '全天候',
image: '/static/spa5.png'
}
],
details: [
{ label: '采购额度', value: '20000元' },
{ label: '套餐时长', value: '30天' },
{ label: '采购种类', value: '全部品类(含限定)' }
],
privileges: [
'最优采购价格',
'24小时内发货',
'顶级供应商渠道',
'一对一专属顾问',
'供应链优化方案',
'库存管理系统'
]
}
],
// 套餐详情页面
showPackageDetail: false,
// 当前选中的套餐
currentPackage: null
}
},
methods: {
closePage() {
this.$emit('close');
},
// 打开套餐详情
openPackageDetail(packageData) {
this.currentPackage = packageData;
this.showPackageDetail = true;
},
// 关闭套餐详情
closePackageDetail() {
this.showPackageDetail = false;
}
}
}
</script>
<style lang="scss">
.supply-chain-container {
position: fixed;
top: 0;
right: 0;
width: 100%;
height: 100%;
background-color: #fff;
z-index: 10000;
overflow-y: auto;
transform-origin: right;
animation: slideInFromRight 0.3s ease;
}
@keyframes slideInFromRight {
from {
transform: translateX(100%);
}
to {
transform: translateX(0);
}
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 15px;
background-color: #fff;
border-bottom: 1px solid #eee;
position: sticky;
top: 0;
z-index: 1;
}
.back-icon {
width: 60px;
display: flex;
align-items: center;
}
.title {
font-size: 17px;
font-weight: 500;
flex: 1;
text-align: center;
}
.close-icon {
width: 60px;
display: flex;
justify-content: flex-end;
}
.package-list {
padding: 15px;
}
.package-card {
margin-bottom: 15px;
background-color: #fff;
border-radius: 12px;
overflow: hidden;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
border: 1px solid #FFEDA0;
}
.package-card:hover {
background-color: #FFFEF0;
}
.package-content {
padding: 18px 15px;
display: flex;
justify-content: space-between;
align-items: center;
position: relative;
}
.cart-icon {
position: relative;
left: 0;
top: 0;
width: 50px;
height: 50px;
background-color: #FFFDD0;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
margin-right: 15px;
}
.cart-text {
font-size: 20px;
color: #E8A317;
}
.package-info {
flex: 1;
padding-left: 0;
margin-right: 45px;
}
.package-name {
font-size: 16px;
font-weight: 500;
color: #333;
margin-bottom: 5px;
display: flex;
align-items: center;
}
.package-price {
display: flex;
align-items: baseline;
margin-bottom: 5px;
}
.price-value {
font-size: 22px;
font-weight: bold;
color: #E8A317;
}
.original-price {
font-size: 15px;
color: #999;
text-decoration: line-through;
margin-left: 8px;
}
.advance-payment {
font-size: 14px;
color: #666;
margin-top: 5px;
}
.discount-tag {
position: absolute;
right: 15px;
top: 50%;
transform: translateY(-50%);
padding:0 20px;
height: 30px;
background-color: #FFE55A;
color: #c35300;
border-radius: 30px;
font-size: 16px;
font-weight: 500;
display: flex;
justify-content: center;
align-items: center;
}
.special-tag {
position: relative;
display: inline-block;
margin-left: 8px;
padding: 2px 6px;
background-color: #FFDF32;
color: #333;
border-radius: 4px;
font-size: 12px;
font-weight: 500;
line-height: 1;
}
.supply-chain-wrapper {
position: relative;
width: 100%;
height: 100%;
}
</style>

View File

@@ -0,0 +1,368 @@
<template>
<view class="supply-detail-wrapper">
<view v-if="show" class="supply-detail-container" style="margin-top: var(--status-bar-height);">
<!-- 头部 -->
<view class="header">
<view class="back-icon" @tap="closePage">
<u-icon name="arrow-left" color="#333" size="26"></u-icon>
</view>
<view class="title">{{packageData.name}}</view>
<view class="close-icon" @tap="closePage">
<u-icon name="close" color="#333" size="24"></u-icon>
</view>
</view>
<!-- 套餐价格信息 -->
<view class="price-card">
<view class="price-title">套餐价格</view>
<view class="price-info">
<view class="current-price">
<text class="price-symbol">¥</text>
<text class="price-value">{{packageData.price}}</text>
</view>
<view class="original-price" v-if="packageData.originalPrice !== packageData.price">¥{{packageData.originalPrice}}</view>
</view>
<view class="advance-info" v-if="packageData.advancePayment">
预付款: ¥{{packageData.advancePayment}}
</view>
</view>
<!-- 套餐内容 -->
<view class="service-section">
<view class="section-title">套餐内容</view>
<view class="service-count">{{packageData.services ? packageData.services.length : 0}}服务</view>
<!-- 服务列表 -->
<view class="service-list">
<view
v-for="(service, index) in packageData.services"
:key="index"
class="service-item"
>
<view class="service-left">
<view class="service-icon">
<u-icon name="heart" color="#FF6600" size="24"></u-icon>
</view>
</view>
<view class="service-right">
<view class="service-name">{{service.name}}</view>
<view class="service-price">
<text class="price-symbol">¥</text>
<text class="service-price-value">{{service.price}}</text>
<text class="service-original-price" v-if="service.originalPrice">¥{{service.originalPrice}}</text>
</view>
<view class="service-duration">{{service.duration}}</view>
</view>
</view>
</view>
</view>
<!-- 购买按钮 -->
<view class="buy-button-container">
<button class="buy-button" @tap="handleBuy">立即购买</button>
</view>
<!-- 购买说明 -->
<view class="buy-notice">
<text class="notice-text">订单将由操作人处理详情请联系客服</text>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'SupplyItemDetail',
props: {
show: {
type: Boolean,
default: false
},
packageData: {
type: Object,
default: () => ({
id: 1,
name: '基础套餐',
price: '2980',
originalPrice: '3725',
advancePayment: '745',
discount: '8折',
services: [
{
name: '头部护理SPA',
price: '598',
originalPrice: '718',
duration: '60分钟',
image: '/static/spa1.png'
},
{
name: '臂油SPA',
price: '618',
originalPrice: '838',
duration: '90分钟',
image: '/static/spa2.png'
},
{
name: '法/LAWF型颜度护理',
price: '1580',
originalPrice: '1896',
duration: '120分钟',
image: '/static/spa3.png'
}
]
})
}
},
methods: {
closePage() {
this.$emit('close');
},
handleBuy() {
uni.showLoading({
title: '处理中...'
});
// 模拟购买流程
setTimeout(() => {
uni.hideLoading();
uni.showToast({
title: '购买成功',
icon: 'success'
});
// 延迟关闭页面
setTimeout(() => {
this.closePage();
}, 1500);
}, 2000);
}
}
}
</script>
<style lang="scss">
.supply-detail-container {
position: fixed;
top: 0;
right: 0;
width: 100%;
height: 100%;
background-color: #f5f7fa;
z-index: 10000;
overflow-y: auto;
transform-origin: right;
animation: slideInFromRight 0.3s ease;
}
@keyframes slideInFromRight {
from {
transform: translateX(100%);
}
to {
transform: translateX(0);
}
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 15px;
background-color: #fff;
border-bottom: 1px solid #eee;
position: sticky;
top: 0;
z-index: 1;
}
.back-icon {
width: 60px;
display: flex;
align-items: center;
}
.title {
font-size: 17px;
font-weight: 500;
flex: 1;
text-align: center;
}
.close-icon {
width: 60px;
display: flex;
justify-content: flex-end;
}
.price-card {
margin: 15px;
padding: 15px;
background-color: #FFFBE6;
border-radius: 10px;
}
.price-title {
font-size: 14px;
color: #333;
margin-bottom: 10px;
}
.price-info {
display: flex;
align-items: baseline;
}
.current-price {
display: flex;
align-items: baseline;
}
.price-symbol {
font-size: 16px;
font-weight: bold;
color: #FF6600;
}
.price-value {
font-size: 28px;
font-weight: bold;
color: #FF6600;
}
.original-price {
margin-left: 10px;
font-size: 16px;
color: #999;
text-decoration: line-through;
}
.advance-info {
margin-top: 8px;
font-size: 14px;
color: #666;
}
.service-section {
margin: 15px;
background-color: #fff;
border-radius: 10px;
overflow: hidden;
}
.section-title {
padding: 15px;
border-bottom: 1px solid #f5f5f5;
font-size: 16px;
font-weight: 500;
}
.service-count {
position: absolute;
right: 30px;
top: 15px;
font-size: 12px;
color: #666;
background-color: #f5f5f5;
padding: 2px 8px;
border-radius: 10px;
}
.service-list {
padding: 0 15px;
}
.service-item {
display: flex;
padding: 15px 0;
border-bottom: 1px solid #f5f5f5;
}
.service-item:last-child {
border-bottom: none;
}
.service-left {
width: 60px;
height: 60px;
border-radius: 8px;
overflow: hidden;
margin-right: 15px;
background-color: #f5f5f5;
}
.service-icon {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.service-right {
flex: 1;
}
.service-name {
font-size: 15px;
font-weight: 500;
color: #333;
margin-bottom: 5px;
}
.service-price {
display: flex;
align-items: baseline;
margin-bottom: 5px;
}
.service-price-value {
font-size: 16px;
font-weight: bold;
color: #FF6600;
}
.service-original-price {
font-size: 14px;
color: #999;
text-decoration: line-through;
margin-left: 5px;
}
.service-duration {
font-size: 12px;
color: #999;
}
.buy-button-container {
margin: 20px 15px;
}
.buy-button {
width: 100%;
height: 45px;
line-height: 45px;
text-align: center;
background-color: #FFBE00;
color: #ffffff;
font-size: 16px;
font-weight: 500;
border-radius: 25px;
border: none;
}
.buy-notice {
text-align: center;
margin-bottom: 30px;
}
.notice-text {
font-size: 12px;
color: #999;
}
.supply-detail-wrapper {
position: relative;
width: 100%;
height: 100%;
}
</style>

View File

@@ -0,0 +1,189 @@
<template>
<view class="system-settings-wrapper">
<view v-if="show" class="system-settings-container" style="margin-top: var(--status-bar-height);">
<!-- 头部 -->
<view class="header">
<view class="back-icon" @tap="closePage">
<u-icon name="arrow-left" color="#333" size="26"></u-icon>
</view>
<view class="title">系统设置</view>
<view class="close-icon" @tap="closePage">
<u-icon name="close" color="#333" size="24"></u-icon>
</view>
</view>
<!-- 设置区域 -->
<view class="settings-section">
<view class="section-card">
<u-cell-group :border="false">
<u-cell title="通知设置" :border-bottom="true" is-link @click="handleSettingTap('通知设置')"></u-cell>
<u-cell title="消息提醒" :border-bottom="true" is-link @click="handleSettingTap('消息提醒')"></u-cell>
<u-cell title="声音设置" :border-bottom="true" is-link @click="handleSettingTap('声音设置')"></u-cell>
<u-cell title="勿扰模式" :border-bottom="false" is-link @click="handleSettingTap('勿扰模式')"></u-cell>
</u-cell-group>
</view>
<view class="section-card">
<u-cell-group :border="false">
<u-cell title="账号安全" :border-bottom="true" is-link @click="handleSettingTap('账号安全')"></u-cell>
<u-cell title="修改密码" :border-bottom="true" is-link @click="handleSettingTap('修改密码')"></u-cell>
<u-cell title="隐私设置" :border-bottom="true" is-link @click="handleSettingTap('隐私设置')"></u-cell>
<u-cell title="账号绑定" :border-bottom="false" is-link @click="handleSettingTap('账号绑定')"></u-cell>
</u-cell-group>
</view>
<view class="section-card">
<u-cell-group :border="false">
<u-cell title="通用" :border-bottom="true" is-link @click="handleSettingTap('通用')"></u-cell>
<u-cell title="清除缓存" :border-bottom="true" is-link @click="handleSettingTap('清除缓存')"></u-cell>
<u-cell title="检查更新" :border-bottom="true" is-link @click="handleSettingTap('检查更新')"></u-cell>
<u-cell title="关于我们" :border-bottom="false" is-link @click="handleSettingTap('关于我们')"></u-cell>
</u-cell-group>
</view>
</view>
<!-- 退出登录按钮 -->
<view class="logout-button-wrapper">
<u-button type="error" shape="circle" @click="handleLogout">退出登录</u-button>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'SystemSettings',
props: {
show: {
type: Boolean,
default: false
}
},
data() {
return {
}
},
methods: {
closePage() {
this.$emit('close');
},
handleSettingTap(setting) {
// 处理各个设置项的点击事件
uni.showToast({
title: `点击了${setting}`,
icon: 'none'
});
},
handleLogout() {
// 直接执行退出登录操作不再使用Modal确认
// 清除用户信息
try {
uni.removeStorageSync('userInfo');
console.log('用户信息已清除');
} catch(e) {
console.error('清除用户信息失败', e);
}
// 关闭设置页面
this.closePage();
// 提示退出成功
uni.showToast({
title: '已退出登录',
icon: 'success',
duration: 1500
});
// 跳转到登录页
setTimeout(() => {
uni.reLaunch({
url: '/pages/login/index'
});
}, 1000);
}
}
}
</script>
<style lang="scss">
.system-settings-container {
position: fixed;
top: 0;
right: 0;
width: 100%;
height: 100%;
background-color: #f5f7fa;
z-index: 10000;
overflow-y: auto;
transform-origin: right;
animation: slideInFromRight 0.3s ease;
}
@keyframes slideInFromRight {
from {
transform: translateX(100%);
}
to {
transform: translateX(0);
}
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 15px;
background-color: #fff;
border-bottom: 1px solid #eee;
position: sticky;
top: 0;
z-index: 1;
}
.back-icon {
width: 60px;
display: flex;
align-items: center;
}
.title {
font-size: 17px;
font-weight: 500;
flex: 1;
text-align: center;
}
.close-icon {
width: 60px;
display: flex;
justify-content: flex-end;
}
.placeholder-icon {
width: 60px;
}
.settings-section {
padding: 15px;
}
.section-card {
background-color: #fff;
border-radius: 10px;
overflow: hidden;
margin-bottom: 15px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}
.logout-button-wrapper {
padding: 20px 30px;
}
.system-settings-wrapper {
position: relative;
width: 100%;
height: 100%;
}
</style>

View File

@@ -0,0 +1,631 @@
<template>
<view class="traffic-purchase-wrapper">
<view v-if="show" class="traffic-purchase-container" style="margin-top: var(--status-bar-height);">
<!-- 头部 -->
<view class="header">
<view class="back-icon" @tap="closePage">
<u-icon name="arrow-left" color="#333" size="26"></u-icon>
</view>
<view class="title">流量采购</view>
<view class="close-icon" @tap="closePage">
<u-icon name="close" color="#333" size="24"></u-icon>
</view>
</view>
<!-- 本月使用情况 -->
<view class="usage-card">
<view class="usage-title">本月流量使用情况
<text v-if="usageData.packageName" class="package-type">({{usageData.packageName}})</text>
</view>
<!-- 使用情况加载中 -->
<view v-if="usageLoading" class="usage-loading">
<text>加载使用情况...</text>
</view>
<!-- 使用情况错误 -->
<view v-else-if="usageError" class="usage-error">
<text>{{usageError}}</text>
<button class="retry-button-small" @tap="fetchRemainingFlow">刷新</button>
</view>
<!-- 使用情况数据 -->
<template v-else>
<view class="usage-row">
<text>流量使用</text>
<text>{{usageData.totalFlow - usageData.remainingFlow}}/{{usageData.totalFlow}}</text>
</view>
<view class="usage-progress">
<view class="progress-bar" :style="{width: usageData.flowPercentage + '%'}"></view>
</view>
<view class="usage-row">
<text>剩余有效期</text>
<text>{{usageData.remainingDays}}</text>
</view>
<view class="usage-date">
<text>有效期: {{usageData.startTime}} ~ {{usageData.expireTime}}</text>
</view>
</template>
</view>
<!-- 使用警告 -->
<view v-if="usageData.flowPercentage > 70 && !usageLoading && !usageError" class="warning-box">
<view class="warning-icon">
<text class="iconfont icon-warning" style="color: #fff; font-size: 14px;"></text>
</view>
<view class="warning-content">
<view class="warning-title">流量即将用完</view>
<view class="warning-text">本月流量仅剩{{usageData.remainingFlow}}建议购买流量包以保证业务连续性</view>
</view>
</view>
<!-- 套餐选择 -->
<view class="section-title">选择流量套餐</view>
<!-- 加载状态 -->
<view v-if="loading" class="loading-container">
<image src="/static/loading.gif" mode="aspectFit" class="loading-image"></image>
<text class="loading-text">加载中...</text>
</view>
<!-- 错误提示 -->
<view v-else-if="error" class="error-container">
<image src="/static/error.png" mode="aspectFit" class="error-image"></image>
<text class="error-text">{{error}}</text>
<button class="retry-button" @tap="fetchFlowPackages">重试</button>
</view>
<!-- 使用v-for循环渲染流量包 -->
<view
v-else
v-for="item in packages"
:key="item.id"
class="package-card"
@tap="openPackageDetail(item)"
>
<view class="package-header">
<view class="package-left">
<view class="package-icon" :style="{backgroundColor: item.iconColor}">
<text class="iconfont" :class="item.iconClass" style="color: #0080ff; font-size: 24px;"></text>
</view>
<view class="package-info">
<view class="package-name">
{{item.name}}
<text v-if="item.specialTag" class="special-tag">{{item.specialTag}}</text>
</view>
<view class="package-price">
<text class="current-price">¥{{item.price}}</text>
<text class="original-price" v-if="item.originalPrice !== item.price">¥{{item.originalPrice}}</text>
</view>
<view class="package-specs">{{item.specs}}</view>
</view>
</view>
<view class="discount-tag">{{item.discount}}</view>
</view>
</view>
</view>
<!-- 流量包详情页面 -->
<package-detail
:show="showPackageDetail"
:package-data="currentPackage"
@close="closePackageDetail"
@buy-success="handleBuySuccess"
></package-detail>
</view>
</template>
<script>
import PackageDetail from './PackageDetail.vue';
import { trafficApi } from '../api/modules/traffic';
export default {
name: 'TrafficPurchase',
components: {
'package-detail': PackageDetail
},
props: {
show: {
type: Boolean,
default: false
}
},
data() {
return {
// 流量包数据
packages: [],
// 流量包详情页面
showPackageDetail: false,
// 当前选中的流量包
currentPackage: null,
// 加载状态
loading: false,
// 错误信息
error: null,
// 本月使用情况数据
usageData: {
packageName: '',
remainingFlow: 0,
totalFlow: 0,
flowPercentage: 0,
remainingDays: 0,
totalDays: 0,
timePercentage: 0,
expireTime: '',
startTime: ''
},
// 本月使用情况加载状态
usageLoading: false,
// 本月使用情况错误信息
usageError: null
}
},
watch: {
show(newVal) {
if (newVal) {
this.fetchFlowPackages();
this.fetchRemainingFlow();
}
}
},
methods: {
closePage() {
this.$emit('close');
},
// 打开流量包详情
openPackageDetail(packageData) {
this.currentPackage = packageData;
this.showPackageDetail = true;
},
// 关闭流量包详情
closePackageDetail() {
this.showPackageDetail = false;
},
// 获取流量包数据
async fetchFlowPackages() {
if (this.loading) return;
this.loading = true;
this.error = null;
uni.showLoading({
title: '加载中...',
mask: true
});
try {
const response = await trafficApi.getFlowPackages();
if (response.code === 200) {
// 处理返回的数据
this.packages = response.data.map(item => ({
id: item.id,
name: item.name,
price: parseFloat(item.price),
originalPrice: parseFloat(item.originalPrice),
specs: `${item.monthlyFlow}人/月·${item.duration}个月`,
iconClass: this.getIconClass(item.tag),
iconColor: '#ecf5ff',
discount: item.discount,
specialTag: item.tag,
details: [
{ label: '每月流量', value: `${item.monthlyFlow}人/月` },
{ label: '套餐时长', value: `${item.duration}个月` },
{ label: '总流量', value: `${item.totalFlow}` }
],
privileges: item.privileges
}));
} else {
this.error = response.msg || '获取数据失败';
}
} catch (err) {
this.error = '获取流量包数据失败,请稍后重试';
console.error('获取流量包数据错误:', err);
} finally {
this.loading = false;
uni.hideLoading();
}
},
// 根据标签获取对应的图标类名
getIconClass(tag) {
const iconMap = {
'入门级': 'icon-shujutongji',
'热销': 'icon-shuju',
'尊享': 'icon-data'
};
return iconMap[tag] || 'icon-shujutongji';
},
// 获取本月流量使用情况
async fetchRemainingFlow() {
if (this.usageLoading) return;
this.usageLoading = true;
this.usageError = null;
try {
const response = await trafficApi.getRemainingFlow();
if (response.code === 200) {
this.usageData = response.data;
} else {
this.usageError = response.msg || '获取使用情况失败';
console.error('获取使用情况失败:', response.msg);
}
} catch (err) {
this.usageError = '获取使用情况失败,请稍后重试';
console.error('获取使用情况错误:', err);
} finally {
this.usageLoading = false;
}
},
// 处理购买成功事件
handleBuySuccess() {
// 刷新流量使用情况和套餐列表
this.fetchRemainingFlow();
this.fetchFlowPackages();
// 提示购买成功
uni.showToast({
title: '购买成功,流量已更新',
icon: 'success',
duration: 2000
});
}
}
}
</script>
<style lang="scss">
.traffic-purchase-container {
position: fixed;
top: 0;
right: 0;
width: 100%;
height: 100%;
background-color: #f5f7fa;
z-index: 10000;
overflow-y: auto;
transform-origin: right;
animation: slideInFromRight 0.3s ease;
}
@keyframes slideInFromRight {
from {
transform: translateX(100%);
}
to {
transform: translateX(0);
}
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 15px;
background-color: #fff;
border-bottom: 1px solid #eee;
position: sticky;
top: 0;
z-index: 1;
}
.back-icon {
width: 60px;
font-size: 15px;
color: #333;
}
.back-text {
font-weight: 500;
}
.title {
font-size: 17px;
font-weight: 500;
flex: 1;
text-align: center;
}
.close-icon {
width: 60px;
text-align: right;
display: flex;
justify-content: flex-end;
padding-right: 10px;
}
.usage-card {
margin: 15px;
padding: 15px;
background-color: #ecf5ff;
border-radius: 10px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
border: 1px solid #d4e8ff;
}
.usage-title {
font-size: 16px;
font-weight: 500;
margin-bottom: 15px;
.package-type {
font-size: 14px;
color: #0080ff;
font-weight: normal;
margin-left: 5px;
}
}
.usage-row {
display: flex;
justify-content: space-between;
margin-bottom: 10px;
font-size: 14px;
color: #333;
}
.usage-progress {
height: 10px;
background-color: #f0f0f0;
border-radius: 5px;
margin: 10px 0 15px;
overflow: hidden;
}
.progress-bar {
height: 100%;
background-color: #0080ff;
border-radius: 5px;
}
.warning-box {
margin: 15px;
padding: 12px 15px;
background-color: #fff9e6;
border-radius: 8px;
display: flex;
align-items: center;
}
.warning-icon {
width: 20px;
height: 20px;
border-radius: 50%;
background-color: #ff9900;
color: #fff;
display: flex;
justify-content: center;
align-items: center;
margin-right: 10px;
flex-shrink: 0;
}
.warning-content {
flex: 1;
}
.warning-title {
font-size: 14px;
font-weight: 500;
color: #ff9900;
margin-bottom: 5px;
}
.warning-text {
font-size: 12px;
color: #666;
line-height: 1.5;
}
.section-title {
margin: 20px 15px 10px;
font-size: 16px;
font-weight: 500;
color: #333;
}
.package-card {
margin: 10px 15px;
background-color: #fff;
border-radius: 12px;
overflow: hidden;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
border: 1px solid #e6f4ff;
position: relative;
transition: all 0.2s ease;
}
.package-card:hover {
background-color: #f8faff;
}
.package-header {
padding: 18px 15px;
display: flex;
justify-content: space-between;
align-items: center;
}
.package-left {
display: flex;
align-items: center;
}
.package-icon {
width: 45px;
height: 45px;
background-color: #f0f7ff;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
margin-right: 12px;
font-size: 18px;
}
.package-info {
display: flex;
flex-direction: column;
}
.package-name {
font-size: 15px;
font-weight: 500;
color: #333;
margin-bottom: 4px;
display: flex;
align-items: center;
}
.package-price {
display: flex;
align-items: baseline;
margin-bottom: 4px;
}
.current-price {
font-size: 22px;
font-weight: bold;
color: #0080ff;
}
.original-price {
font-size: 15px;
color: #999;
text-decoration: line-through;
margin-left: 8px;
}
.package-specs {
font-size: 12px;
color: #666;
}
.original-tag {
position: relative;
display: inline-block;
margin-left: 8px;
padding: 2px 6px;
background-color: #f5f5f5;
border-radius: 4px;
font-size: 14px;
color: #666;
font-weight: 500;
}
.discount-tag {
position: absolute;
right: 15px;
top: 50%;
transform: translateY(-50%);
padding:0 20px;
height: 30px;
background-color: #e6f4ff;
color: #0080ff;
border-radius: 30px;
font-size: 16px;
font-weight: 500;
display: flex;
justify-content: center;
align-items: center;
}
.special-tag {
background-color: #BFDBFE;
color: #3152B8;
padding: 2px 6px;
border-radius: 4px;
font-size: 12px;
font-weight: 500;
margin-left: 8px;
}
.traffic-purchase-wrapper {
position: relative;
width: 100%;
height: 100%;
}
.loading-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 40rpx 0;
.loading-image {
width: 60rpx;
height: 60rpx;
}
.loading-text {
margin-top: 20rpx;
font-size: 28rpx;
color: #666;
}
}
.error-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 40rpx 0;
.error-image {
width: 80rpx;
height: 80rpx;
}
.error-text {
margin: 20rpx 0;
font-size: 28rpx;
color: #ff4d4f;
}
.retry-button {
margin-top: 20rpx;
padding: 10rpx 30rpx;
font-size: 28rpx;
color: #fff;
background-color: #2979ff;
border-radius: 8rpx;
}
}
.usage-loading {
text-align: center;
color: #666;
font-size: 14px;
margin-bottom: 10px;
}
.usage-error {
text-align: center;
color: #ff4d4f;
font-size: 14px;
margin-bottom: 10px;
display: flex;
flex-direction: column;
align-items: center;
}
.retry-button-small {
margin-top: 10px;
padding: 4px 15px;
font-size: 14px;
color: #fff;
background-color: #2979ff;
border-radius: 4px;
display: inline-block;
line-height: 1.5;
}
.usage-date {
font-size: 12px;
color: #666;
margin-top: 10px;
text-align: right;
}
</style>