130 Commits

Author SHA1 Message Date
pikachu1995@126.com
75b20f494d feat(gift-card): 新增提货卡兑换功能
- 新建提货卡选品及确认兑换页面,支持全选和任选模式
- 新增提货卡 API 接口,包含获取、试算和核销端点
- 我的礼品卡页面增加提货卡类型标识及面值展示适配
- 订单取消弹窗针对提货卡订单显示专属提示文案
- 配置 pages.json 新增提货卡兑换页面路由
2026-11-06 15:16:29 +08:00
pikachu1995@126.com
cc71d20aa6 feat(paid-member): 添加付费会员功能模块
- 新增付费会员API接口层,支持会员查询、下单、记录及报价
- 新增付费会员页面,展示权益、推荐商品及购买流程
- 新增付费会员购买记录页面,支持订单状态查看与继续支付
- 新增 PaidMemberPrice 组件用于商品列表和详情页展示会员价
- 个人中心页添加付费会员入口,支持配置化展示标题与背景
- 商品详情页集成会员价展示,支持秒杀和拼团场景下隐藏
- 商品列表组件集成会员价展示,支持批量请求与防竞态
- 支付页适配付费会员支付流程,支持H5轮询与结果回调
- 订单确认页优惠文案更新为"活动优惠(含会员优惠)"
- pages.json 新增付费会员及购买记录页面路由配置
- README 更新升级计划,按时间倒序补充已完成功能明细
2026-11-05 22:37:12 +08:00
pikachu1995@126.com
06af86af3f feat(member): 完善移动端等级权益与经验任务 2026-11-05 21:29:56 +08:00
pikachu1995@126.com
8188a8af7b refactor: 清理停用促销的移动端展示 2026-11-05 15:20:38 +08:00
pikachu1995@126.com
0637f1da1f docs: 标记立减优惠券升级计划为已完成 2026-11-04 14:50:33 +08:00
pikachu1995@126.com
4adcf0a13a feat(coupon): 支持优惠券无门槛使用条件展示
- 优惠券消费阈值为0时显示"无门槛使用"替代"满0元可用"
- 更新商品详情页促销优惠券组件的条件展示逻辑
- 更新购物车优惠券中心页面门槛显示
- 更新优惠券详情页门槛文案处理
- 更新首页领券模板,增加无门槛条件分支
- 更新我的优惠券页面新增门槛描述字段
- 更新店铺页优惠券领取区域门槛显示
- 更新首页优惠券模板组件门槛文案
2026-11-04 14:03:51 +08:00
pikachu1995@126.com
d72f02f7cf feat(wechat): 集成微信原生地址导入、头像选择与昵称填写能力
- 新增微信收货地址导入功能(chooseAddress),含地区匹配与错误处理
- 个人资料页接入微信头像选择(chooseAvatar)与昵称填写(type="nickname")
- 重构收货地址添加页与管理页的UI布局,抽取公共样式 address-page.scss
- 地址页与个人页增加加载失败提示、请求防抖与保存状态反馈
- 下拉刷新改用 Promise.allSettled 避免单接口失败阻断其他数据更新
- manifest 新增 chooseAddress 隐私权限声明,版本号更新至 5.03
2026-11-04 11:09:34 +08:00
pikachu1995@126.com
7b2b045fd4 chore(license): 将项目许可证 更换为 Apache-2.0
- 将 LICENSE 文件内容替换为 Apache License 2.0 完整文本
2026-11-03 17:48:26 +08:00
pikachu1995@126.com
e1a48d6d11 refactor(after-sales): 删除独立售后页面并整合至订单列表
- 删除 afterSales.vue 独立页面,将售后入口统一至 myOrder 页面
- 修改售后相关页面跳转路径为 /pages/order/myOrder?status=5
- 重构 applySuccess 页面,增加微信订阅消息授权与视觉优化
- 重构预存款明细页面,增加收支筛选与日志解析功能
- 新增 store 端 API 基础地址配置
2026-11-02 16:57:29 +08:00
pikachu1995@126.com
1411f15679 refactor(goods): 移除商品详情页配送地址相关功能
- 删除了"送至"地址展示卡片区域
- 移除了配送地址弹窗组件(popupAddress)的引用和导入
- 删除了 delivery 和 addressFlag 响应式变量
- 删除了 deliveryFun 和 closePopupAddress 函数
- 移除了 popupGoods 组件中的 addr 属性传参
- 删除了 shutMask 中地址弹窗的 case 3 逻辑
- 移除了 address.vue 中未登录跳转登录页的 else 分支
2026-10-29 17:17:35 +08:00
pikachu1995@126.com
af7bd78614 feat(withdrawal): 添加提现规则说明以满足审核要求
- 新增提现规则说明卡片组件展示在提现页面底部
- 添加默认规则文本,涵盖提现额度、频次、时间、到账及手续费说明
- 支持从后端接口获取自定义规则,优先展示接口返回内容
- 根据提现渠道动态调整到账账户描述(支付宝/微信零钱)
- 补充规则卡片相关样式,包括标题装饰条及正文排版
2026-10-29 10:55:47 +08:00
pikachu1995@126.com
0170c92f9a style(user): 优化个人中心页面布局与视觉样式
- 顶部沉浸式头部与微信胶囊安全距离适配
- 核心资产栏沉浸式融入主色调,规范金融数字展示
- 订单模块优化图标视觉层级与按压交互
- 服务工具重构为资产与常用、更多服务双卡片分组
2026-10-22 16:41:24 +08:00
pikachu1995@126.com
5e59f2cd3c refactor(category): 重构分类页面UI
- 重构分类页面导航栏,将标题+搜索框改为仅搜索框样式
- 优化分类页面左侧列表与右侧内容区域的布局及视觉样式
- 重写搜索栏宽度计算逻辑
- 优化分类滚动组件、侧边列表、排序栏及子标签栏的交互样式
- 增加分类头部图片条件渲染及商品列表嵌入模式样式
- 关闭商品列表划线价默认显示配置
2026-10-22 15:59:47 +08:00
pikachu1995@126.com
6b59ae3d6e fix: 分类页设置缓存读出后同样过 sanitize 清洗,防篡改/旧结构 2026-10-22 09:51:18 +08:00
pikachu1995@126.com
b589c551bf feat: 分类页支持后台配置的四种导航模板 2026-10-22 09:27:33 +08:00
pikachu1995@126.com
b8a60a9369 feat: m-goods-list 支持商品卡片字段开关 2026-10-22 09:24:00 +08:00
pikachu1995@126.com
1032b6e34d feat: uniapp 读取分类页设置配置(缓存+默认值兜底) 2026-10-22 09:17:58 +08:00
pikachu1995@126.com
0a47f84c32 Merge branch 'feat/appointment-goods' 2026-10-21 15:16:48 +08:00
pikachu1995@126.com
2d4a316129 style(home): 优化首页模板组件间距与店铺卡片视觉样式
- 将所有模板组件的 pageGap/marginBottom 默认值从 10rpx 调整为 0
- 重构店铺卡片样式一为全景大片橱窗布局,添加自营标签与图片加载容错
- 重构店铺卡片样式二为大牌名店街 + 精品橱窗风格,优化商品封面与价格展示
- 促销详情模板添加 isRealGoods 过滤,无有效数据时整块不渲染
- 修复 u-notice-bar 横向滚动模式下 text 需为字符串的类型兼容问题
- 统一将模板中 HTML 实体 > 改为插值表达式避免转义异常
2026-10-21 15:16:25 +08:00
pikachu1995@126.com
b1d3f56f10 Merge branch 'feat/appointment-goods' 2026-10-21 08:25:10 +08:00
pikachu1995@126.com
87477bc32b chore(uniapp): 移除误提交的 .idea 目录并加入 gitignore 2026-10-20 19:02:06 +08:00
pikachu1995@126.com
6c13dc1b65 chore(uniapp): 清理无用文件,删除编辑器配置、Vue3迁移脚本与文档、uni-app-x空目录 2026-10-20 19:01:58 +08:00
pikachu1995@126.com
215754a6de docs(uniapp): 切换开源协议为 MIT 并更新中英文 README 文档 2026-10-20 18:46:58 +08:00
pikachu1995@126.com
c15e954549 perf(uniapp): 小程序主包瘦身,迁移分包静态资源、清理冗余组件与全局样式 2026-10-20 18:46:39 +08:00
pikachu1995@126.com
755f574e8e feat(uniapp): 新增首页组合组件 homeComb 并完善页面及楼层装修样式 2026-10-20 18:46:28 +08:00
pikachu1995@126.com
986625c516 feat(uniapp): 首页楼层模板支持装修样式字段,修复 tpl_notice 样式缺少闭合括号 2026-10-20 14:17:21 +08:00
pikachu1995@126.com
a41936dc00 fix(uniapp): 修复滑块验证 movable-area 嵌套塌陷导致无法拖动 2026-10-20 14:14:46 +08:00
pikachu1995@126.com
eba79a78e8 style(uniapp): 滑块验证组件改版为极简无框风(方案B) 2026-10-20 13:55:09 +08:00
pikachu1995@126.com
a700a3d211 feat(uniapp): 三入口过滤 hidden 楼层不渲染 2026-10-12 15:59:58 +08:00
pikachu1995@126.com
b603f8c451 feat(uniapp): 热区组件应用样式字段
外层背景/边距/页面间距/背景圆角,图片与热区容器内容圆角;缺字段兜底为现状,老页面零视觉变化
2026-10-12 15:38:25 +08:00
pikachu1995@126.com
b773ada7a8 fix(uniapp): 移除文章组件无后端字段支撑的时间与封面展示
ArticleVO 无 createTime/cover 字段,相关模板与样式属于永不渲染的死代码
2026-10-12 11:01:19 +08:00
pikachu1995@126.com
40d42f001d feat(uniapp): 新增文章列表/店铺列表楼层组件 2026-10-12 10:31:31 +08:00
pikachu1995@126.com
a108bb4d13 feat(uniapp): 新增优惠券楼层组件(含未登录跳登录) 2026-10-12 10:29:11 +08:00
pikachu1995@126.com
79433dd766 feat(uniapp): 启用积分商城楼层组件(翻新为view/rpx并接入样式配置) 2026-10-12 10:27:13 +08:00
pikachu1995@126.com
fb10038547 feat(uniapp): 新增辅助空白/辅助线/富文本楼层渲染 2026-10-12 10:26:00 +08:00
pikachu1995@126.com
c6d58f28b7 Merge branch 'feat/appointment-goods' 2026-10-09 16:06:27 +08:00
pikachu1995@126.com
a32f6d2313 style(theme): 统一应用主题样式并更新组件样式变量
- 在多个页面组件中添加动态主题样式绑定
- 将硬编码的颜色值替换为CSS变量和主题配置
- 引入主题样式计算逻辑到各个页面
- 更新优惠券、地址、订单等页面的主题适配
- 替换线性渐变背景为动态主题颜色
- 移除uni_modules组件中的$set方法调用以优化性能
- 更新README中主题色管理状态为已完成
2026-10-09 16:02:11 +08:00
pikachu1995@126.com
9cf9957e5b style(verify-code): 重构输入框样式,提升 Android 设备兼容性
- 继续用隐藏原生输入框,避免与自定义绘制的数字冲突。
- 将输入内容和光标移出可视区域,优化 APP-PLUS 端体验。
2026-10-08 09:50:36 +08:00
pikachu1995@126.com
cc9d5535cf Merge branch 'feat/appointment-goods' 2026-09-30 16:51:04 +08:00
pikachu1995@126.com
74d186ff36 fix: 修复海报面板提示与加载样式
- 更新海报面板提示,仅在有海报列表时显示相关信息。
- 调整加载样式,优化布局与对齐,提升用户体验。
- 修改按钮样式,确保一致性与可读性。
2026-09-30 16:50:43 +08:00
pikachu1995@126.com
a3193c3b68 refactor: 优化购物车与订单页面逻辑
- 更新购物车页面,增强商品展示与交互体验。
- 调整订单页面的状态反馈与用户操作逻辑,确保信息清晰。
- 改进组件样式与布局,提升整体用户体验。
- 修复多个页面中的样式与功能问题,确保一致性与流畅性。
2026-09-29 10:22:57 +08:00
pikachu1995@126.com
e858741bb8 Merge branch 'feat/appointment-goods' 2026-09-28 14:39:32 +08:00
pikachu1995@126.com
0bffe81c6b feat: 更新预约功能与礼品卡支持
- 新增礼品卡页面,支持礼品卡的选择与使用。
- 调整预约下单流程,增强预约信息展示与用户交互。
- 更新支付成功页面的导航逻辑,确保用户体验流畅。
- 优化搜索页面的历史关键词加载逻辑,提升性能。
2026-09-28 14:37:26 +08:00
pikachu1995@126.com
2107e3f03a feat: 补齐预约下单售后链路,并接入礼品卡结算
立即购买先选时段再结算,免物流地址,售后按数量退款;同步接入礼品卡入口。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-20 17:07:27 +08:00
Yer11214
27034902fe 💄 style(verify-code): 调整 APP 端验证码输入框的隐藏方案
- 将原生输入框移出可视区域,避免 Android 设备上原生光标与自绘数字冲突
- 为 xt__verify-code 增加 overflow 隐藏,输入内容与光标不再显示在验证码格上

♻️ refactor(login): 移除 u-code 组件并自实现验证码倒计时

- 用 displayCodeTip 计算属性配合计时器替换 u-code,统一验证码按钮文案展示
- 新增 onBeforeUnmount 清理倒计时定时器,避免内存泄漏
- 重构 fetchCode 发送逻辑,简化校验与错误处理分支
- 更新获取验证码按钮样式为橙色渐变并调整文字颜色

♻️ refactor(live): 为 APP 端补充直播服务占位实现

- 通过条件编译在 APP-PLUS 下提供 LiveChatService 与 LiveMqttService 空实现
- 避免 APP 端引入直播聊天与 MQTT 依赖,仅保留其他平台原有逻辑
2026-09-20 16:41:01 +08:00
Yer11214
42e9b7c15f 🐛 fix(verify-code): 修复输入处理并优化 APP 端样式层级
- 兼容多端事件对象,从 detail.value 或 target.value 中安全取值
- 过滤非数字字符并按 size 截断,避免非法输入与
2026-09-20 15:26:13 +08:00
田香琪
30ce901137 feat(distribution): 新增保存招募邀请 token 的功能
- 添加 `savePendingRecruitToken` 方法,用于在用户登录后保存招募令牌,支持自动申请流程。
- 确保 API 请求使用 PUT 方法并传递招募令牌参数。
2026-09-20 15:17:28 +08:00
田香琪
7cc605bed1 feat(distribution): 优化招募页面数据加载逻辑
- 引入 `savePendingRecruitToken` 方法,确保在用户登录时保存招募令牌。
- 重构数据加载流程,使用异步函数处理页面数据和进度信息,提升用户体验。
- 增强错误处理,确保在加载失败时不影响页面展示。
2026-09-18 17:58:30 +08:00
田香琪
2ad8a7f5a6 Merge branch 'fix/recruit-online-entry-visible' 2026-09-16 09:48:06 +08:00
田香琪
e30ff03b10 feat(distribution): 重构招募页登录态同步
- 将 `isUserLoggedIn` 从计算属性改为响应式变量,便于主动刷新登录状态。
- 新增 `syncLoginState`,在页面加载时按 access token 同步登录态,避免登录后条件与申请入口不同步。
2026-09-16 09:41:15 +08:00
田香琪
ba4e9126e8 feat(distribution): 增强分销入口检查与用户反馈
- 引入自助招募入口检查逻辑,确保用户在访问前获得明确的状态反馈。
- 在分销相关页面中添加分销功能关闭和线上招募关闭的提示信息。
- 优化页面逻辑,确保在不同状态下用户体验的一致性与流畅性。
2026-09-13 16:29:06 +08:00
田香琪
43bf0773bc feat(distribution): 添加上级分销员信息展示与获取逻辑
- 新增上级分销员信息的显示,确保在满足条件时可见。
- 引入获取上级分销员信息的API,优化数据加载流程。
- 更新样式以提升上级信息的可读性和用户体验。
2026-09-11 18:48:04 +08:00
田香琪
f6d4fac35e feat(distribution): 更新分销等级逻辑与条件可见性
- 修改分销等级列表的文档注释,明确包含的条件。
- 在分销等级页面中引入条件可见性逻辑,确保等级规则仅在满足条件时显示。
- 优化获取分销等级的逻辑,确保正确处理和展示等级数据。
2026-09-11 12:59:00 +08:00
田香琪
ef3401a9e4 feat(afterSales): 调整日历组件与发货时间选择逻辑
- 将售后物流页日历改为单选模式,并支持点击遮罩关闭。
- 兼容发货时间确认回调的多种入参格式,选中后正确回写并关闭日历。
2026-09-10 15:35:26 +08:00
田香琪
8f540224bb feat(distribution): 增加分销员申请状态反馈与条件检查
- 新增分销员申请状态反馈,显示申请通过、待审核和未开放状态。
- 优化申请条件检查,确保用户在申请时满足条件并同意协议。
- 调整页面逻辑以改善用户体验,提供清晰的申请状态提示。
2026-09-09 15:17:54 +08:00
田香琪
c12c76f6f5 feat(distribution): 添加分销员状态检查与加载指示
- 在多个分销相关页面中引入分销员状态检查,确保用户在访问前具备有效分销资格。
- 增加加载指示器以改善用户体验,提示用户正在加载数据。
- 更新相关逻辑以处理分销员资格的不同状态,确保用户在不符合条件时获得适当反馈。
2026-09-09 13:21:53 +08:00
田香琪
4fdd266dec fix(grade): 修复格式化利率函数以确保正确计算和返回值
- 更新 formatRate 函数,确保在输入无效时返回 '0'。
- 调整返回值格式,将利率乘以 100 并保留两位小数,优化输出结果。
2026-09-07 11:15:03 +08:00
田香琪
9d18d09cab refactor(login): 重构登录页面以优化用户体验
- 更新登录界面,简化手机号和验证码输入流程。
- 增强帐号密码登录选项的可用性,适配不同客户端。
- 改进隐私协议提示,确保用户清晰了解条款。
- 优化第三方登录入口的展示逻辑,提升界面友好性。
2026-08-19 16:35:58 +08:00
田香琪
4a194ee0a1 chore(api): update buyer API URL for production environment 2026-08-14 17:12:44 +08:00
田香琪
69b8395686 chore(api): update buyer API URL for development environment 2026-08-13 17:41:12 +08:00
田香琪
907ad2d02c Merge branch 'feature/order-delivery-fulfillment' 2026-08-13 17:30:02 +08:00
田香琪
651d1106da refactor(logistics): 重构物流信息展示与处理逻辑
- 更新物流详情页面,简化数据获取流程,增强用户体验。
- 优化订单详情页面,动态展示物流信息,支持不同配送状态。
- 新增配送工具函数,提升代码复用性与可读性。
- 调整样式以改善界面布局,确保信息清晰可读。
2026-08-13 17:23:25 +08:00
pikachu1995@126.com
4b1a09cbc3 feat(distribution): 增强分销功能与界面优化
- 新增银行卡管理页面,支持用户查看与管理银行卡。
- 实现添加、删除及设置默认银行卡功能。
- 优化邀请与加入页面,展示邀请人信息并改进用户提示。
- 更新海报与二维码生成逻辑,提升用户体验。
- 重构多个组件,提高可读性与可维护性。
2026-08-11 15:43:21 +08:00
田香琪
ee6f66cac3 refactor: 更新表单组件以增强上传功能和验证逻辑
- 在 step1.vue、step2.vue 和 step3.vue 中添加上传规则和删除功能
- 优化照片上传的处理逻辑,确保上传后能正确恢复表单状态
- 更新表单验证逻辑,使用 async/await 处理验证过程
- 修改样式以提升用户体验,确保上传组件的可用性和一致性
2026-08-11 10:36:47 +08:00
田香琪
f51fcad9c2 refactor: 更新搜索页面样式和逻辑以支持多端兼容性
- 修改 search.scss 文件,优化样式以适应小程序和 H5/APP-PLUS 端
- 更新 searchPage.vue 文件,调整条件编译指令以支持多端展示
- 移除不必要的计算逻辑,简化代码结构,提高可读性
2026-08-10 14:08:01 +08:00
田香琪
359d1ad24c fix: 修复 App 端 MQTT 运行时兼容问题
- 锁定 MQTT 版本为 5.15.1
- 为 AbortController、AbortSignal 和 navigator.language 添加兼容补丁
- 新增 MQTT App 运行时测试
2026-08-05 18:24:41 +08:00
pikachu1995@126.com
7d3daf2f02 feat(distribution): 实现分销员中心完整功能
- 新增分销业绩统计页面,包含时间范围筛选和自定义日期选择功能
- 重构分销认证页面,改为跳转至招募页面申请分销员身份
- 添加分销商品访问记录功能,支持分享追踪和佣金计算
- 更新分销历史记录页面,优化数据结构和显示字段
- 完全重写分销员首页,包含用户信息、收益统计、等级系统等功能
2026-08-05 18:07:27 +08:00
田香琪
eb40916cf7 refactor: 优化促销商品列表和电子卡券逻辑
- 更新促销商品列表组件,简化商品详情页跳转逻辑
- 移除不必要的礼品卡相关状态管理,确保电子卡券逻辑的清晰性
- 调整 utils/goodsType.js 中的卡密处理函数,专注于当前订单的卡密履约行
- 优化订单详情页的卡密展示逻辑,确保信息准确性
2026-08-05 13:48:21 +08:00
田香琪
370c63afcd feat: 更新电子卡券卡密详情页及相关逻辑
- 修改卡密详情页以支持多种卡密展示,优化卡密信息的结构和样式
- 增加卡密履约状态管理,支持卡密发放状态的显示
- 更新 utils/goodsType.js,增加卡密履约状态的处理逻辑
- 优化数据加载逻辑,确保卡密信息的准确性和完整性
2026-08-03 16:14:05 +08:00
田香琪
94e846af6c feat: 增加礼品卡选择功能及相关逻辑
- 在 api/trade.js 中新增 selectGiftCard 函数以支持礼品卡选择
- 更新多个组件以集成礼品卡功能,包括购物车和订单页面
- 优化商品页面和订单详情展示,支持礼品卡抵扣信息
- 调整相关逻辑以确保礼品卡与其他促销活动的兼容性
2026-08-02 13:49:02 +08:00
田香琪
a6ba2b3dbe feat: 添加电子卡券功能及相关逻辑
- 在 pages.json 中新增卡密详情页面路径
- 在多个组件中实现电子卡券(E_COUPON)逻辑,包括库存管理、结算页面处理、订单详情展示等
- 优化商品页面和订单页面以支持电子卡券的特性,隐藏不适用的功能
- 新增 utils/goodsType.js 文件,集中管理与电子卡券相关的类型和工具函数
- 更新样式以适应电子卡券的展示需求
2026-07-31 13:57:14 +08:00
Yer11214
6754a54f1b Merge branch 'master' of https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp 2026-07-21 14:39:17 +08:00
Yer11214
7626f944ad fix: 更新配置和代码逻辑以提升稳定性和可读性
- 在 manifest.json 和 project.config.json 中启用 postcss 和 enhance 设置
- 在多个 Vue 组件中优化空值处理逻辑,确保更健壮的代码执行
- 调整样式和布局以提升用户体验
2026-07-21 14:39:16 +08:00
chc
27134526a0 登录页错误配置,导致无法登陆 2026-07-14 10:33:29 +08:00
Yer11214
4bb4bbdc6b Merge branch 'uniapp-vue3' of https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp into uniapp-vue3 2026-07-13 18:06:55 +08:00
Yer11214
239855e53b fix: 优化登录导航逻辑以提升用户体验
- 在 filters.js 中简化登录页面导航逻辑,确保根据不同类型的导航调用正确的 URL
- 在 request.js 中调整异常处理,确保 uni.hideLoading() 调用不会导致错误,提升代码健壮性
2026-07-13 18:06:54 +08:00
pikachu1995@126.com
8ed2997fcf Merge branch 'uniapp-vue3' of https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp into uniapp-vue3 2026-07-13 17:09:40 +08:00
pikachu1995@126.com
3ec61f41bc refactor: 更新API路径以使用buyer API 2026-07-13 16:51:57 +08:00
Yer11214
38defd1201 fix: 优化请求处理逻辑以增强稳定性
- 在 request.js 中添加异常处理,确保 uni.hideLoading() 调用不会导致错误
- 清理存储逻辑,提升代码健壮性
2026-07-13 15:59:38 +08:00
Yer11214
7566076fa4 fix: 更新弹窗和商店页面样式以提升用户体验
- 在 popups.vue 中调整图标布局,增加弹窗图标的样式支持
- 在 shopPage.vue 中优化商店名称和消息的对齐方式,提升可读性
- 在 address.vue 中调整导入顺序,确保代码整洁性
2026-07-09 17:15:37 +08:00
Yer11214
41e8cff749 fix: 更新多个组件样式和功能以提升用户体验
- 在 myCollect.vue 中优化收藏页面的布局和样式,增加主题支持
- 在 searchPage.vue 中修复搜索组件的输入值设置逻辑
- 在 coupon/index.vue 中重构优惠券列表的展示逻辑,提升可用性
- 在 m-search-revision.vue 中调整搜索组件的样式和功能,增加清除图标的交互
- 在 pages.json 中禁用下拉刷新功能以改善性能
2026-07-09 16:34:22 +08:00
Yer11214
f727e01ef0 fix: 优化订单详情和购物车列表组件的交互与样式
- 在订单详情中添加复制订单编号的提示,避免空值复制
- 更新购物车列表中的样式,确保价格和数量显示更为美观
- 调整促销信息的展示逻辑,提升用户体验
2026-07-09 11:11:53 +08:00
Yer11214
02b5f246a6 fix: 修复样式导入路径,确保表单样式正确应用
- 在 App.vue 中添加对 uview-form-fix.scss 的导入
- 移除 uni.scss 中的重复导入,优化样式管理
2026-07-09 11:04:17 +08:00
Yer11214
349ffa4f34 refactor: 重构多个组件以支持 Vue 3 语法和功能
- 将多个组件转换为 `<script setup>` 语法,提升可读性和性能
- 优化状态管理和事件处理逻辑,简化代码结构
- 更新样式和布局以适应新组件结构
- 添加新功能和修复已知问题,提升用户体验
2026-07-08 18:37:11 +08:00
Yer11214
4d0b0fb5e4 Merge branch 'uniapp-vue3' of https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp into uniapp-vue3 2026-07-07 17:10:45 +08:00
Yer11214
fc3cad18e6 feat: 添加直播房间页面及相关样式和功能
- 新增直播房间页面,支持竖屏直播模式
- 实现直播播放器和消息展示功能
- 增加购物车按钮和商品推荐展示
- 更新样式以适应新页面布局
- 移除不再使用的 MQTT 相关文件和 API 调用
2026-07-07 17:10:44 +08:00
pikachu1995@126.com
23e3825366 feat: 实现主题管理功能,优化样式和组件 2026-07-07 10:57:04 +08:00
pikachu1995@126.com
686aed848d feat: 添加视频模块并优化多个组件 2026-07-07 09:39:32 +08:00
chc
4e2fcbc1fe Merge branch 'uniapp-vue3' of https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp into uniapp-vue3 2026-07-06 15:53:42 +08:00
chc
e14481ce6b mqtt配置增加 2026-07-06 15:53:40 +08:00
pikachu1995@126.com
6198a6d244 refactor: 优化订单填写页面和评价组件的逻辑与样式
- 移除不必要的返回监听逻辑,简化页面返回处理
- 更新不支持运费提示的显示方式,使用文本替代列表
- 改进评价组件的初始化逻辑,确保更好的用户体验
- 统一数据结构,提升代码可读性
2026-07-06 14:15:06 +08:00
pikachu1995@126.com
90ee7d5b1d Merge branch 'uniapp-vue3' of https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp into uniapp-vue3 2026-07-06 13:53:58 +08:00
pikachu1995@126.com
b1743cefb0 feat: 新增index.html文件并更新多个页面样式和结构 2026-07-06 13:53:54 +08:00
chc
2965800d87 Merge branch 'uniapp-vue3' of https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp into uniapp-vue3 2026-07-01 18:08:02 +08:00
chc
3a44b7243d 直播功能 2026-07-01 18:07:51 +08:00
pikachu1995@126.com
5f293d929d refactor: 更新多个页面的样式和结构 2026-07-01 16:05:08 +08:00
pikachu1995@126.com
6654c1de51 refactor: 更新u-tabs组件使用方式及样式调整 2026-07-01 10:07:55 +08:00
pikachu1995@126.com
dc2bef455a refactor: 移动端升级 Vue3 + uView Plus
将 lilishop-uniapp 从 Vue2/uView 1.6 迁移到 Vue3/uview-plus,优先支持 H5/微商城与微信小程序;移除 vendored uview-ui,改用 npm 依赖、Vuex4 与迁移脚本/补丁,并补充 VUE3_MIGRATION.md 回归清单。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 18:50:38 +08:00
Chopper711
c290c7a329 完善首页 All-In-One 说明 2026-06-14 15:51:33 +08:00
pikachu1995@126.com
d5663cfb4d feat: 新增提现记录功能及相关调整
- 新增提现记录页面并在pages.json中注册路由
- 在存款操作页添加提现记录入口
- 新增两个提现相关的API接口
- 修复发票详情页CSS深度选择器兼容性问题
- 修复操作页面末尾缺失的换行符
2026-05-20 11:30:15 +08:00
Chopper711
b7cfe13ffd update readme 2026-05-17 19:58:12 +08:00
田香琪
134a8b19e4 发票支持增值税专票 2026-04-14 18:24:21 +08:00
pikachu1995@126.com
137232290b fix(分销认证): 移除银行账号和开户行的自定义校验规则
移除对银行账号和开户行的额外校验规则,仅保留必填验证
简化表单验证逻辑,避免因校验规则过于严格导致用户提交失败
2026-03-15 13:50:16 +08:00
pikachu1995@126.com
87743cb77d refactor(商品详情): 简化商品参数展示逻辑 2025-12-22 15:31:05 +08:00
Yer11214
7939998a30 fix: 更新我的积分页面标题
- 将我的积分页面的导航栏标题更新为“我的积分”,以提升用户体验。
2025-10-21 11:01:18 +08:00
Yer11214
1fcc016ccd refactor: 将深度选择器语法更新为v-deep
-在多个Vue和SCSS文件中用::v-deep替换弃用的/deep/选择器,以便更好地与Vue的范围样式兼容。
2025-10-21 10:33:59 +08:00
Yer11214
3219f6d576 feat: 更新用户信息获取逻辑
- 在personMsg.vue中添加onShow生命周期钩子,重新获取用户信息并更新表单数据
- 在bindMobile.vue中绑定手机成功后,获取最新用户信息并更新缓存
- 调整绑定手机按钮的样式以改善用户体验
2025-09-16 10:39:10 +08:00
Yer11214
83da8f3003 Merge branch 'master' of https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp 2025-06-05 17:41:12 +08:00
Yer11214
c858c82950 优化app中应用升级逻辑 2025-06-05 17:40:49 +08:00
Yer11214
f9c7610976 update README.md.
Signed-off-by: Yer11214 <17633066053@163.com>
2025-03-31 03:21:06 +00:00
Chopper711
919af44fda feat: 更新售后细节和用户工具页面 (master)
- 修改afterSalesDetailExpress.vue中gotoGoodsDetail函数参数
- 调整快递公司、快递单号和发货时间选择器样式
- 在tool.vue中添加邀请用户功能和分享弹窗
- 在request.js中增加请求头带上邀请人信息
- 移除tpl_goods.vue中的调试日志
- App.vue增加启动时设置邀请人逻辑
- storage.js新增邀请人信息的存取方法
2025-02-21 18:40:15 +08:00
Chopper711
db7cfcea85 fix: 投诉相关处理 2025-02-21 16:16:57 +08:00
chc
e95aed8e38 延时展示提示信息,防止被删除 2025-01-20 18:35:53 +08:00
chc
24454e2546 获取登录用户功能修复。 2025-01-20 17:40:35 +08:00
chc
0ee03d9fcf 登录后重新获取用户信息,如果抛出异常,清空token缓存,回到我的页面 2025-01-20 16:34:07 +08:00
chc
c93862066b 注销用户提示语句错误 2025-01-20 15:43:23 +08:00
chc
46dbeb77c8 查看分包裹物流 2024-12-25 10:36:47 +08:00
chc
8bcc9de352 修改密码增加验证密码选项 2024-12-18 11:45:31 +08:00
chc
bac8e3a327 修改米缺少提交接口修改 2024-12-18 10:58:06 +08:00
chc
29a20afe93 1.店铺入驻法人证件信息处理2.验证手机号修改密码不需要旧密码 2024-12-18 10:30:58 +08:00
Yer11214
0ef3eb9bf7 修改im bug 2024-12-17 09:46:02 +08:00
Yer11214
ef6f572311 Merge branch 'master' of https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp 2024-11-25 10:20:44 +08:00
Yer11214
c1fce859ce 新增商品详情绑定分销员校验 2024-11-25 10:20:13 +08:00
misworga831
2cd7b7b63f refactor: update goods list fetching to use currentGoodsId 2024-11-21 10:30:31 +08:00
chc
75991db6f6 Merge branch 'master' of https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp 2024-11-11 17:47:39 +08:00
chc
f894b5b1fc 拼团设置 2024-11-11 17:47:31 +08:00
Yer11214
7ae6967b1e 适配管理端活动链接 2024-11-11 15:22:09 +08:00
Yer11214
de94f212c3 选择地址功能添加loading方法 2024-10-18 15:25:37 +08:00
misworga831
d166d5943c fix: 已选择的分销商品,一直显示十个商品,下拉并没有增加 2024-09-23 22:34:06 +08:00
chc
c0e5d75cc6 订单增加部分发货状态 2024-09-18 15:25:32 +08:00
516 changed files with 71634 additions and 70610 deletions

13
.gitignore vendored
View File

@@ -1,13 +1,4 @@
# OSX
#
.DS_Store
node_modules/ node_modules/
unpackage/
#Intellij idea .DS_Store
.idea/ .idea/
/idea/
.vscode/
/unpackage/
.hbuilderx/launch.json
.project.config.json
.project.private.config.json

View File

@@ -1,24 +0,0 @@
{ // launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
// launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数
"version": "0.0",
"configurations": [{
"app-plus" :
{
"launchtype" : "remote"
},
"default" :
{
"launchtype" : "remote"
},
"h5" :
{
"launchtype" : "remote"
},
"mp-weixin" :
{
"launchtype" : "remote"
},
"type" : "uniCloud"
}
]
}

15
.vscode/launch.json vendored
View File

@@ -1,15 +0,0 @@
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}

603
App.vue
View File

@@ -1,253 +1,350 @@
<script> <script setup lang="ts">
/** import config from '@/config/config'
* vuex管理登录状态,具体可以参考官方登录模板示例 import { getClipboardData } from '@/js_sdk/h5-copy/h5-copy.js'
*/ import APPUpdate from '@/plugins/APPUpdate'
import config from "@/config/config"; import storage from '@/utils/storage'
import { import { getThemeSetting, getCategoryPageSetting } from '@/api/common.js'
getClipboardData import {
} from "@/js_sdk/h5-copy/h5-copy.js"; applyTabBarStyle,
import APPUpdate from "@/plugins/APPUpdate"; cacheTheme,
import storage from "@/utils/storage"; loadCachedTheme,
import { normalizeTheme,
mapMutations } from '@/utils/theme'
} from "vuex"; import {
cacheCategoryPageSetting,
loadCachedCategoryPageSetting,
normalizeCategoryPageSetting,
/** } from '@/utils/categoryPageSetting'
* 路由监听并删除路由 import { onLaunch, onShow } from '@dcloudio/uni-app'
* https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.navigateTo.html import { useStore } from '@/store'
* */ import { handleAppLaunchScene } from '@/utils/distributionBind.js'
// #ifdef MP-WEIXIN
wx.onAppRoute((res) => { const store = useStore()
}) // #ifdef MP-WEIXIN
// #endif wx.onAppRoute((res) => {
applyTabBarStyle(store.state.theme && store.state.theme.mainColor, res && res.path)
export default { })
data() { // #endif
return {
config, onLaunch((val) => {
}; initTheme()
}, initCategoryPageSetting()
handleAppLaunchScene(val)
if (val?.query?.inviter) {
/** storage.setInviter(val.query.inviter)
* 监听返回 }
*/
onBackPress(e) { // #ifdef APP-PLUS
console.log("onBackPress-APP", e); plus.globalEvent.addEventListener('newintent', () => {
if (e.from == "backbutton") { checkArguments()
let routes = getCurrentPages(); })
let curRoute = routes[routes.length - 1].options; // #endif
routes.forEach((item) => {
if ( // #ifdef MP-WEIXIN
item.route == "pages/tabbar/cart/cartList" || applyUpdateWeChat()
item.route.indexOf("pages/product/goods") != -1 // #endif
) { })
uni.redirectTo({
url: item.route, onShow(() => {
}); applyTabBarStyle(store.state.theme && store.state.theme.mainColor)
}
}); // #ifndef H5
if (config.enableGetClipboard) {
if (curRoute.addId) { getClipboard()
uni.reLaunch({ }
url: "/pages/tabbar/cart/cartList", // #endif
});
} else { // #ifdef APP-PLUS
uni.navigateBack(); if (storage.getShow()) {
} if (uni.getSystemInfoSync().platform == 'ios') {
return true; //阻止默认返回行为 uni.navigateTo({ url: '/pages/tabbar/screen/fullScreen' })
} }
}, }
methods: { // #endif
...mapMutations(["login"]), })
},
onLaunch: function() { function initTheme() {
// #ifdef APP-PLUS const cached = loadCachedTheme()
this.checkArguments(); // 检测启动参数 if (cached) {
APPUpdate(); store.commit('SET_THEME', cached)
applyTabBarStyle(cached.mainColor)
// 重点是以下: 一定要监听后台恢复 !一定要 }
plus.globalEvent.addEventListener("newintent", (e) => { getThemeSetting()
this.checkArguments(); // 检测启动参数 .then((res) => {
}); if (res.data?.success && res.data.result?.settingValue) {
// #endif try {
const raw = JSON.parse(res.data.result.settingValue)
// #ifdef MP-WEIXIN const theme = normalizeTheme(raw)
this.applyUpdateWeChat(); store.commit('SET_THEME', theme)
// #endif cacheTheme(theme)
}, applyTabBarStyle(theme.mainColor)
} catch (e) {
onShow() { // 主题配置解析失败时使用缓存
// #ifndef H5 }
if(this.config.enableGetClipboard){ }
this.getClipboard(); })
} .catch(() => {})
// #endif }
// #ifdef APP-PLUS
function initCategoryPageSetting() {
if (storage.getShow()) { const cached = loadCachedCategoryPageSetting()
if (uni.getSystemInfoSync().platform == 'ios') { if (cached) {
this.$u.route("/pages/tabbar/screen/fullScreen"); store.commit('SET_CATEGORY_PAGE_SETTING', cached)
}
} getCategoryPageSetting()
} .then((res) => {
// #endif if (res.data?.success) {
}, const setting = normalizeCategoryPageSetting(res.data.result)
methods: { store.commit('SET_CATEGORY_PAGE_SETTING', setting)
/** cacheCategoryPageSetting(setting)
* 微信小程序版本提交更新版本 解决缓存问题 }
*/ })
applyUpdateWeChat() { .catch(() => {})
const updateManager = uni.getUpdateManager(); }
updateManager.onCheckForUpdate(function(res) { function applyUpdateWeChat() {
// 请求完新版本信息的回调 const updateManager = uni.getUpdateManager()
});
updateManager.onCheckForUpdate(() => {})
updateManager.onUpdateReady(function(res) {
uni.showModal({ updateManager.onUpdateReady(() => {
title: "更新提示", uni.showModal({
content: "发现新版本,是否重启应用?", title: '更新提示',
success(res) { content: '发现新版本,是否重启应用?',
if (res.confirm) { success(res) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 if (res.confirm) {
updateManager.applyUpdate(); updateManager.applyUpdate()
} }
}, },
}); })
}); })
updateManager.onUpdateFailed(function(res) {
// 新的版本下载失败 updateManager.onUpdateFailed(() => {})
}); }
},
function launch() {
// TODO 开屏广告 后续优化添加 try {
launch() { const value = uni.getStorageSync('launchFlag')
try { if (!value) {
// 获取本地存储中launchFlag标识 开屏广告 // uni.navigateTo({ url: '/pages/index/agreement' })
const value = uni.getStorageSync("launchFlag"); } else {
if (!value) { const w = plus.webview.open(
// this.$u.route("/pages/index/agreement"); '/hybrid/html/advertise/advertise.html',
} else { '本地地址',
//app启动时打开启动广告页 {
var w = plus.webview.open( top: 0,
"/hybrid/html/advertise/advertise.html", bottom: 0,
"本地地址", { zindex: 999,
top: 0, },
bottom: 0, 'fade-in',
zindex: 999, 500,
}, )
"fade-in", setTimeout(() => {
500 plus.webview.close(w)
); APPUpdate()
//设置定时器,4s后关闭启动广告页 }, 3000)
setTimeout(function() { }
plus.webview.close(w); } catch (e) {
APPUpdate(); uni.setStorage({
}, 3000); key: 'launchFlag',
} data: true,
} catch (e) { success() {
// error console.log('error时存储launchFlag')
uni.setStorage({ },
key: "launchFlag", })
data: true, }
success: function() { }
console.log("error时存储launchFlag");
}, async function getClipboard() {
}); const res = await getClipboardData()
} if (res.indexOf(config.shareLink) != -1 && res != store.state.shareLink) {
}, store.state.shareLink = res
uni.showModal({
/** title: '提示',
* 获取粘贴板数据 content: '检测到一个分享链接是否跳转?',
*/ confirmText: '跳转',
async getClipboard() { success(callback) {
let res = await getClipboardData(); if (callback.confirm) {
const path = res.split(config.shareLink)[1]
/** if (path.indexOf('tabbar') != -1) {
* 解析粘贴板数据 uni.switchTab({ url: path })
*/ } else {
uni.navigateTo({ url: path })
if (res.indexOf(config.shareLink) != -1 && (res != this.$store.state.shareLink)) { }
this.$store.state.shareLink = res }
uni.showModal({ },
title: "提示", })
content: "检测到一个分享链接是否跳转?", }
confirmText: "跳转", }
success: function(callback) {
if (callback.confirm) { function checkArguments() {
const path = res.split(config.shareLink)[1]; // #ifdef APP-PLUS
if (path.indexOf("tabbar") != -1) { setTimeout(() => {
uni.switchTab({ const args = plus.runtime.arguments
url: path, if (args) {
}); const argsStr = decodeURIComponent(args)
} else { const path = argsStr.split('//')[1]
uni.navigateTo({ if (path.indexOf('tabbar') != -1) {
url: path, uni.switchTab({ url: `/${path}` })
}); } else {
} uni.navigateTo({ url: `/${path}` })
} }
}, }
}); })
} // #endif
}, }
</script>
/**
* h5中打开app获取跳转app的链接并跳转 <style lang="scss">
*/ @import "uview-plus/index.scss";
checkArguments() { @import "@/styles/uview-form-fix.scss";
// #ifdef APP-PLUS
setTimeout(() => { // -------适配底部安全区 苹果x系列刘海屏
const args = plus.runtime.arguments;
if (args) { // #ifdef MP-WEIXIN
const argsStr = decodeURIComponent(args); .mp-iphonex-bottom {
const path = argsStr.split("//")[1]; padding-bottom: constant(safe-area-inset-bottom);
if (path.indexOf("tabbar") != -1) { padding-bottom: env(safe-area-inset-bottom);
uni.switchTab({ box-sizing: content-box;
url: `/${path}`, height: auto !important;
}); padding-top: 10rpx;
} else { }
uni.navigateTo({
url: `/${path}`, // #endif
});
} body {
} background-color: $bg-color;
}); }
// #endif
}, /************************ */
}, .w200 {
}; width: 200rpx !important;
</script> }
<style lang="scss"> .flex1 {
@import "uview-ui/index.scss"; flex: 1; //必须父级设置flex
}
// -------适配底部安全区 苹果x系列刘海屏
.light-color {
// #ifdef MP-WEIXIN color: $light-color;
.mp-iphonex-bottom { }
padding-bottom: constant(safe-area-inset-bottom); .main-color {
padding-bottom: env(safe-area-inset-bottom); color: $main-color !important;
box-sizing: content-box; }
height: auto !important; .bg-light-color {
padding-top: 10rpx; background-color: $light-color !important;
} }
.bg-main-color {
// #endif background-color: $main-color !important;
}
body {
background-color: $bg-color; // 渐变主题颜色
} .bg-linear-gradient {
background-image: linear-gradient(25deg, var(--theme-primary, #fa123b), var(--theme-light, #ff6b35), var(--theme-aider, #ff9f28), #ffcc03);
/************************ */ }
.w200 { .uni-tabbar .uni-tabbar__icon {
width: 200rpx !important; width: 20px;
} height: 18px;
}
.flex1 {
flex: 1; //必须父级设置flex .flex {
} display: flex;
</style> }
.btn {
background-color: $light-color;
color: #ffffff;
border-width: 0px;
border: none;
border-radius: 44px;
height: 44px;
box-shadow: none;
font-weight: 400;
font-style: normal;
line-height: 44px;
text-align: center;
&::after {
border: none;
}
}
.button-hover {
opacity: 0.7;
}
.margin {
margin: 10px;
}
.tag {
background-color: rgba(242, 242, 242, 1);
color: #333333;
height: 28px;
border-radius: 28px;
box-shadow: none;
font-family: "PingFangSC-Regular", "PingFang SC", sans-serif;
font-weight: 400;
font-style: normal;
line-height: 28px;
text-align: center;
width: 90px;
}
.c-content {
background-color: #ffffff;
// margin-top: 30rpx;
border-top: 1px solid $border-color-light;
border-bottom: 1px solid $border-color-light;
}
.mt-30 {
margin-top: 30rpx;
}
.border-top {
border-top: 1px solid $border-color-light;
}
.describe {
color: $font-color-light;
font-size: $font-sm;
padding: 30rpx;
}
.flex-center {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.flex-a-c{
align-items: center;
}
.flex-j-sb{
justify-content: space-between;
}
.relative {
position: relative;
}
.wes {
/* 多出部分用省略号表示 , 用于一行 */
overflow: hidden;
word-wrap: normal;
white-space: nowrap;
text-overflow: ellipsis;
}
.wes-2 {
/* 适用于webkit内核和移动端 */
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
}
.wes-3 {
/* 适用于webkit内核和移动端 */
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
overflow: hidden;
}
</style>

866
LICENSE
View File

@@ -1,661 +1,205 @@
GNU AFFERO GENERAL PUBLIC LICENSE Apache License, Version 2.0
Version 3, 19 November 2007
Copyright (c) 2020-2026 Beijing Hongye Huicheng Technology Co., Ltd. (北京宏业汇成科技有限公司)
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies Apache License
of this license document, but changing it is not allowed. Version 2.0, January 2004
http://www.apache.org/licenses/
Preamble
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure 1. Definitions.
cooperation with the community in the case of network server software.
"License" shall mean the terms and conditions for use, reproduction,
The licenses for most software and other practical works are designed and distribution as defined by Sections 1 through 9 of this document.
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to "Licensor" shall mean the copyright owner or entity authorized by
share and change all versions of a program--to make sure it remains free the copyright owner that is granting the License.
software for all its users.
"Legal Entity" shall mean the union of the acting entity and all
When we speak of free software, we are referring to freedom, not other entities that control, are controlled by, or are under common
price. Our General Public Licenses are designed to make sure that you control with that entity. For the purposes of this definition,
have the freedom to distribute copies of free software (and charge for "control" means (i) the power, direct or indirect, to cause the
them if you wish), that you receive source code or can get it if you direction or management of such entity, whether by contract or
want it, that you can change the software or use pieces of it in new otherwise, or (ii) ownership of fifty percent (50%) or more of the
free programs, and that you know you can do these things. outstanding shares, or (iii) beneficial ownership of such entity.
Developers that use our General Public Licenses protect your rights "You" (or "Your") shall mean an individual or Legal Entity
with two steps: (1) assert copyright on the software, and (2) offer exercising permissions granted by this License.
you this License which gives you legal permission to copy, distribute
and/or modify the software. "Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
A secondary benefit of defending all users' freedom is that source, and configuration files.
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to "Object" form shall mean any form resulting from mechanical
incorporate. Many developers of free software are heartened and transformation or translation of a Source form, including but
encouraged by the resulting cooperation. However, in the case of not limited to compiled object code, generated documentation,
software used on network servers, this result may fail to come about. and conversions to other media types.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its "Work" shall mean the work of authorship, whether in Source or
source code to the public. Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
The GNU Affero General Public License is designed specifically to (an example is provided in the Appendix below).
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to "Derivative Works" shall mean any work, whether in Source or Object
provide the source code of the modified version running there to the form, that is based on (or derived from) the Work and for which the
users of that server. Therefore, public use of a modified version, on editorial revisions, annotations, elaborations, or other modifications
a publicly accessible server, gives the public access to the source represent, as a whole, an original work of authorship. For the purposes
code of the modified version. of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
An older license, called the Affero General Public License and the Work and Derivative Works thereof.
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has "Contribution" shall mean any work of authorship, including
released a new version of the Affero GPL which permits relicensing under the original version of the Work and any modifications or additions
this license. to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
The precise terms and conditions for copying, distribution and or by an individual or Legal Entity authorized to submit on behalf of
modification follow. the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
TERMS AND CONDITIONS to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
0. Definitions. and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
"This License" refers to version 3 of the GNU Affero General Public License. excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks. "Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
"The Program" refers to any copyrightable work licensed under this subsequently incorporated within the Work.
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations. 2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
To "modify" a work means to copy from or adapt all or part of the work worldwide, non-exclusive, no-charge, royalty-free, irrevocable
in a fashion requiring copyright permission, other than the making of an copyright license to reproduce, prepare Derivative Works of,
exact copy. The resulting work is called a "modified version" of the publicly display, publicly perform, sublicense, and distribute the
earlier work or a work "based on" the earlier work. Work and such Derivative Works in Source or Object form.
A "covered work" means either the unmodified Program or a work based 3. Grant of Patent License. Subject to the terms and conditions of
on the Program. this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
To "propagate" a work means to do anything with it that, without (except as stated in this section) patent license to make, have made,
permission, would make you directly or secondarily liable for use, offer to sell, sell, import, and otherwise transfer the Work,
infringement under applicable copyright law, except executing it on a where such license applies only to those patent claims licensable
computer or modifying a private copy. Propagation includes copying, by such Contributor that are necessarily infringed by their
distribution (with or without modification), making available to the Contribution(s) alone or by combination of their Contribution(s)
public, and in some countries other activities as well. with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
To "convey" a work means any kind of propagation that enables other cross-claim or counterclaim in a lawsuit) alleging that the Work
parties to make or receive copies. Mere interaction with a user through or a Contribution incorporated within the Work constitutes direct
a computer network, with no transfer of a copy, is not conveying. or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
An interactive user interface displays "Appropriate Legal Notices" as of the date such litigation is filed.
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2) 4. Redistribution. You may reproduce and distribute copies of the
tells the user that there is no warranty for the work (except to the Work or Derivative Works thereof in any medium, with or without
extent that warranties are provided), that licensees may convey the modifications, and in Source or Object form, provided that You
work under this License, and how to view a copy of this License. If meet the following conditions:
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion. (a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
1. Source Code.
(b) You must cause any modified files to carry prominent notices
The "source code" for a work means the preferred form of the work stating that You changed the files; and
for making modifications to it. "Object code" means any non-source
form of a work. (c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
A "Standard Interface" means an interface that either is an official attribution notices from the Source form of the Work,
standard defined by a recognized standards body, or, in the case of excluding those notices that do not pertain to any part of
interfaces specified for a particular programming language, one that the Derivative Works; and
is widely used among developers working in that language.
(d) If the Work includes a "NOTICE" text file as part of its
The "System Libraries" of an executable work include anything, other distribution, then any Derivative Works that You distribute must
than the work as a whole, that (a) is included in the normal form of include a readable copy of the attribution notices contained
packaging a Major Component, but which is not part of that Major within such NOTICE file, excluding those notices that do not
Component, and (b) serves only to enable use of the work with that pertain to any part of the Derivative Works, in at least one
Major Component, or to implement a Standard Interface for which an of the following places: within a NOTICE text file distributed
implementation is available to the public in source code form. A as part of the Derivative Works; within the Source form or
"Major Component", in this context, means a major essential component documentation, if provided along with the Derivative Works; or,
(kernel, window system, and so on) of the specific operating system within a display generated by the Derivative Works, if and
(if any) on which the executable work runs, or a compiler used to wherever such third-party notices normally appear. The contents
produce the work, or an object code interpreter used to run it. of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
The "Corresponding Source" for a work in object code form means all notices within Derivative Works that You distribute, alongside
the source code needed to generate, install, and (for an executable or as an addendum to the NOTICE text from the Work, provided
work) run the object code and to modify the work, including scripts to that such additional attribution notices cannot be construed
control those activities. However, it does not include the work's as modifying the License.
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but You may add Your own copyright statement to Your modifications and
which are not part of the work. For example, Corresponding Source may provide additional or different license terms and conditions
includes interface definition files associated with source files for for use, reproduction, or distribution of Your modifications, or
the work, and the source code for shared libraries and dynamically for any such Derivative Works as a whole, provided Your use,
linked subprograms that the work is specifically designed to require, reproduction, and distribution of the Work otherwise complies with
such as by intimate data communication or control flow between those the conditions stated in this License.
subprograms and other parts of the work.
5. Submission of Contributions. Unless You explicitly state otherwise,
The Corresponding Source need not include anything that users any Contribution intentionally submitted for inclusion in the Work
can regenerate automatically from other parts of the Corresponding by You to the Licensor shall be under the terms and conditions of
Source. this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
The Corresponding Source for a work in source code form is that the terms of any separate license agreement you may have executed
same work. with Licensor regarding such Contributions.
2. Basic Permissions. 6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
All rights granted under this License are granted for the term of except as required for reasonable and customary use in describing the
copyright on the Program, and are irrevocable provided the stated origin of the Work and reproducing the content of the NOTICE file.
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a 7. Disclaimer of Warranty. Unless required by applicable law or
covered work is covered by this License only if the output, given its agreed to in writing, Licensor provides the Work (and each
content, constitutes a covered work. This License acknowledges your Contributor provides its Contributions) on an "AS IS" BASIS,
rights of fair use or other equivalent, as provided by copyright law. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
You may make, run and propagate covered works that you do not of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
convey, without conditions so long as your license otherwise remains PARTICULAR PURPOSE. You are solely responsible for determining the
in force. You may convey covered works to others for the sole purpose appropriateness of using or redistributing the Work and assume any
of having them make modifications exclusively for you, or provide you risks associated with Your exercise of permissions under this License.
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do 8. Limitation of Liability. In no event and under no legal theory,
not control copyright. Those thus making or running the covered works whether in tort (including negligence), contract, or otherwise,
for you must do so exclusively on your behalf, under your direction unless required by applicable law (such as deliberate and grossly
and control, on terms that prohibit them from making any copies of negligent acts) or agreed to in writing, shall any Contributor be
your copyrighted material outside their relationship with you. liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
Conveying under any other circumstances is permitted solely under result of this License or out of the use or inability to use the
the conditions stated below. Sublicensing is not allowed; section 10 Work (including but not limited to damages for loss of goodwill,
makes it unnecessary. work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
3. Protecting Users' Legal Rights From Anti-Circumvention Law. has been advised of the possibility of such damages.
No covered work shall be deemed part of an effective technological 9. Accepting Warranty or Additional Liability. While redistributing
measure under any applicable law fulfilling obligations under article the Work or Derivative Works thereof, You may choose to offer,
11 of the WIPO copyright treaty adopted on 20 December 1996, or and charge a fee for, acceptance of support, warranty, indemnity,
similar laws prohibiting or restricting circumvention of such or other liability obligations and/or rights consistent with this
measures. License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
When you convey a covered work, you waive any legal power to forbid of any other Contributor, and only if You agree to indemnify,
circumvention of technological measures to the extent such circumvention defend, and hold each Contributor harmless for any liability
is effected by exercising rights under this License with respect to incurred by, or claims asserted against, such Contributor by reason
the covered work, and you disclaim any intention to limit operation or of your accepting any such warranty or additional liability.
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of END OF TERMS AND CONDITIONS
technological measures.
APPENDIX: How to apply the Apache License to your work.
4. Conveying Verbatim Copies.
To apply the Apache License to your work, attach the following
You may convey verbatim copies of the Program's source code as you boilerplate notice, with the fields enclosed by brackets "[]"
receive it, in any medium, provided that you conspicuously and replaced with your own identifying information. (Don't include
appropriately publish on each copy an appropriate copyright notice; the brackets!) The text should be enclosed in the appropriate
keep intact all notices stating that this License and any comment syntax for the file format. We also recommend that a
non-permissive terms added in accord with section 7 apply to the code; file or class name and description of purpose be included on the
keep intact all notices of the absence of any warranty; and give all same "printed page" as the copyright notice for easier
recipients a copy of this License along with the Program. identification within third-party archives.
You may charge any price or no price for each copy that you convey, Copyright [yyyy] [name of copyright owner]
and you may offer support or warranty protection for a fee.
Licensed under the Apache License, Version 2.0 (the "License");
5. Conveying Modified Source Versions. you may not use this file except in compliance with the License.
You may obtain a copy of the License at
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the http://www.apache.org/licenses/LICENSE-2.0
terms of section 4, provided that you also meet all of these conditions:
Unless required by applicable law or agreed to in writing, software
a) The work must carry prominent notices stating that you modified distributed under the License is distributed on an "AS IS" BASIS,
it, and giving a relevant date. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
b) The work must carry prominent notices stating that it is limitations under the License.
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.

140
README.en.md Normal file
View File

@@ -0,0 +1,140 @@
<div align="center">
<img src="./icon.png" width="80" alt="Lilishop Logo" />
<h1>Lilishop(PickMall) - Mobile Client (uni-app)</h1>
<p>
<a href="https://github.com/lilishop/lilishop"><img src="https://img.shields.io/github/stars/lilishop/lilishop.svg?style=social&logo=github" alt="GitHub Stars" /></a>
<a href="https://gitee.com/beijing_hongye_huicheng/lilishop"><img src="https://gitee.com/beijing_hongye_huicheng/lilishop/badge/star.svg?theme=dark" alt="Gitee Stars" /></a>
<a href="./LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-blue.svg" alt="License" /></a>
<a href="https://vuejs.org/"><img src="https://img.shields.io/badge/Vue-3-brightgreen.svg" alt="Vue 3" /></a>
<a href="https://uniapp.dcloud.net.cn/"><img src="https://img.shields.io/badge/uni--app-Vue3-blue.svg" alt="uni-app" /></a>
</p>
<p>
<a href="https://pickmall.cn">🏠 Official Website</a> ·
<a href="https://bdwx2tfwwt.feishu.cn/wiki/space/7675179368632617952?ccm_open_type=lark_wiki_spaceLink&open_tab_from=wiki_home">📖 Product Documentation</a> ·
<a href="#2-online-demo">📱 Online Demo</a> ·
<a href="https://github.com/lilishop/lilishop">💻 GitHub</a>
</p>
<p>
<a href="./README.md">简体中文</a> | <b>English</b>
</p>
</div>
> ⭐ **If you like this project, please click `Star` in the top-right corner to support us! Your Star is our greatest motivation for continuous open-source iteration!**
**LILISHOP** is an open-source e-commerce system built with Spring Boot, Vue 3, and uni-app. It supports B2B2C multi-vendor marketplaces, WeChat Mini Programs, H5, Android/iOS Apps, live-streaming e-commerce, affiliate distribution, and flash sales.
### ✨ Why Choose Lilishop
- 🟢 **True Apache-2.0 License**: Free for commercial use and private secondary development without licensing concerns.
- 🚀 **Modern Vue 3 Stack**: Built on `uni-app + Vue 3 + uview-plus 3.x`, leaving legacy Vue 2 templates behind.
- 🧩 **Production-Ready Completeness**: Not a static UI template—fully integrated with B2B2C multi-vendor workflows, visual storefront decoration, IM customer service, flash sales, group buying, affiliate distribution, and live streaming.
---
## 1. Overview
This repository (`lilishop-uniapp`) is the **Mobile Buyer Client** of Lilishop, supporting **H5, WeChat Mini Program, Android, and iOS Apps** from a single codebase powered by **Vue 3** and **uni-app**.
- **Official Website**: <https://pickmall.cn>
- **Documentation**: [Product Documentation](https://bdwx2tfwwt.feishu.cn/wiki/space/7675179368632617952?ccm_open_type=lark_wiki_spaceLink&open_tab_from=wiki_home)
- **Gitee Repository**: <https://gitee.com/beijing_hongye_huicheng>
- **GitHub Main Repository**: <https://github.com/lilishop/lilishop>
---
## 2. Online Demo
> **Note**: The verification code for the demo environment is `111111`.
| WeChat Mini Program | Mobile H5 ([Visit Directly](https://m-b2b2c.pickmall.cn)) |
| :---: | :---: |
| <img src="https://static.pickmall.cn/images/h5-qrcode.png" width="180" alt="WeChat Mini Program QR Code" /> | <img src="https://lilishop-wechat.oss-cn-beijing.aliyuncs.com/h5-qrcode.png" width="180" alt="Mobile H5 QR Code" /> |
| Scan with WeChat | Scan or visit <https://m-b2b2c.pickmall.cn> |
- **PC Mall**: <https://pc-b2b2c.pickmall.cn>
- **Admin Panel**: <https://admin-b2b2c.pickmall.cn> (`admin` / `123456`)
- **Store Panel**: <https://store-b2b2c.pickmall.cn> (`13011111111` / `111111`)
### Mobile UI Preview
| Home | Product List | Product Detail | Checkout | User Center |
| :---: | :---: | :---: | :---: | :---: |
| <img src="https://lilishop-wechat.oss-cn-beijing.aliyuncs.com/image.png" width="160" alt="Home" /> | <img src="https://lilishop-wechat.oss-cn-beijing.aliyuncs.com/image3.png" width="160" alt="Product List" /> | <img src="https://lilishop-wechat.oss-cn-beijing.aliyuncs.com/image4.png" width="160" alt="Product Detail" /> | <img src="https://lilishop-wechat.oss-cn-beijing.aliyuncs.com/image5.png" width="160" alt="Checkout" /> | <img src="https://lilishop-wechat.oss-cn-beijing.aliyuncs.com/image2.png" width="160" alt="User Center" /> |
---
## 3. Core Features & Tech Stack
### Core Features
- **Cross-Platform**: One codebase runs on H5, WeChat Mini Program, Android, and iOS.
- **Multi-Vendor B2B2C**: Supports merchant onboarding and store-level operations.
- **Visual Storefront Decoration**: Dynamic home page & floor layouts (`pages/floor`) and customizable theme colors.
- **Live Streaming & IM**: Integrated with Tencent Cloud IM / MQTT and HLS video streaming.
- **Full E-Commerce Workflow**: Product browsing, cart, promotions (flash sale, group buy, coupons, points, bargain, affiliate), order fulfillment, after-sales, and member center.
### Mobile Tech Stack
| Category | Technology | Description |
| :--- | :--- | :--- |
| Core Framework | `uni-app` + `Vue 3` | Cross-platform framework with Vue 3 support |
| State Management | `Vuex 4` | Global auth, cart, and user state management |
| UI Library | `uview-plus 3.x` | Vue 3 compatible uni-app multi-platform UI library |
| Messaging & IM | `mqtt 5.x` / `@tencentcloud/chat` | Real-time customer service and notification push |
| Video Streaming | `hls.js` | Live streaming playback support |
| CSS Preprocessor | `Sass (SCSS)` | Global theme variables (`uni.scss`) and styling |
---
## 4. Directory Structure
```text
lilishop-uniapp
├── api/ # API module definitions (member, goods, order, promotion, IM, etc.)
├── components/ # Shared business and base components
├── config/ # Global configuration
│ ├── api.js # API base URLs (buyer / im / mqtt)
│ └── config.js # Mall name, Mini Program AppID, AMap Key, theme colors, etc.
├── hybrid/ # Local HTML assets for App WebView
├── js_sdk/ # Third-party and uni-app SDKs
├── lib/ # Base utility libraries
├── pages/ # Pages and sub-packages
│ ├── tabbar/ # Main tabbar pages (Home, Category, Cart, Mine)
│ ├── passport/ # Auth sub-package (Login, Register, Reset Password)
│ ├── product/ # Product detail, list, reviews, store homepage
│ ├── cart/ # Shopping cart and checkout
│ ├── order/ # Order list, detail, after-sales, logistics, invoice
│ ├── promotion/ # Flash sale, group buy, bargain, points mall, distribution, live
│ ├── mine/ # User center, wallet, points, favorites, addresses
│ ├── floor/ # Visual decoration floor components and topic pages
│ └── navigation/ # Navigation and search pages
├── patches/ # patch-package patches for dependencies
├── scripts/ # Build and postinstall runtime patch scripts
├── static/ # Static images and fonts
├── store/ # Vuex store modules
├── styles/ # Global stylesheets
├── uni_modules/ # uni_modules plugins (including uview-plus)
├── utils/ # Request interceptors, encryption, validators, storage helpers
├── App.vue # Root application component
├── main.js # Application entry point
├── manifest.json # uni-app multi-platform configuration
├── pages.json # Page routes, sub-packages, and navigation bar settings
└── uni.scss # Global SCSS variables and theme color definitions
```
---
## 5. Related Repositories
| Repository | Description | Links |
| :--- | :--- | :--- |
| **`lilishop`** | Backend Services (Spring Boot 4 / Java 21) | [Gitee](https://gitee.com/beijing_hongye_huicheng/lilishop) · [GitHub](https://github.com/lilishop/lilishop) |
| **`lilishop-ui`** | PC Mall / Seller / Admin / IM Web Frontend | [Gitee](https://gitee.com/beijing_hongye_huicheng/lilishop-ui) |
| **`lilishop-uniapp`** | Mobile Buyer Client (H5 / Mini Program / App) | [Gitee](https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp) |
| **`docker`** | Docker Compose, Images & SQL Init Scripts | [Gitee](https://gitee.com/beijing_hongye_huicheng/docker) · [MySQL Scripts](https://gitee.com/beijing_hongye_huicheng/docker/tree/master/init/mysql) |
---
## 6. License
Lilishop is licensed under the [Apache-2.0](./LICENSE) License. Copyright © 2020-2026 **Beijing Hongye Huicheng Technology Co., Ltd.**

345
README.md
View File

@@ -1,217 +1,206 @@
## Lilishop B2B2C 商城系统 <div align="center">
<img src="./icon.png" width="80" alt="Lilishop Logo" />
<h1>Lilishop(PickMall) 开源商城系统 - 移动端 (uni-app)</h1>
### 商城介绍 <p>
<a href="https://github.com/lilishop/lilishop"><img src="https://img.shields.io/github/stars/lilishop/lilishop.svg?style=social&logo=github" alt="GitHub Stars" /></a>
<a href="https://gitee.com/beijing_hongye_huicheng/lilishop"><img src="https://gitee.com/beijing_hongye_huicheng/lilishop/badge/star.svg?theme=dark" alt="Gitee Stars" /></a>
<a href="./LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-blue.svg" alt="License" /></a>
<a href="https://vuejs.org/"><img src="https://img.shields.io/badge/Vue-3-brightgreen.svg" alt="Vue 3" /></a>
<a href="https://uniapp.dcloud.net.cn/"><img src="https://img.shields.io/badge/uni--app-Vue3-blue.svg" alt="uni-app" /></a>
</p>
**官网**:https://pickmall.cn <p>
<a href="https://pickmall.cn">🏠 官方网站</a> ·
<a href="https://bdwx2tfwwt.feishu.cn/wiki/space/7675179368632617952?ccm_open_type=lark_wiki_spaceLink&open_tab_from=wiki_home">📖 产品文档</a> ·
<a href="#2-在线演示">📱 在线演示</a> ·
<a href="#7-社区与支持">💬 微信交流群</a>
</p>
**更多 README**:https://gitee.com/beijing_hongye_huicheng/lilishop/blob/master/README.md <p>
<b>简体中文</b> | <a href="./README.en.md">English</a>
</p>
</div>
**演示站点**:https://m-b2b2c.pickmall.cn/ 账号:13011111111 验证码:111111 > ⭐ **如果觉得项目不错,请点击右上角 `Star` 收藏支持!您的 Star 是我们持续开源迭代的最大动力!**
**商城 小程序/公众号/APP**:扫描二维码 **LILISHOP** 是基于 Spring Boot / Vue 3 / uni-app 开发的开源商城系统,支持 B2B2C 多商户商城、微信小程序商城、H5 商城、APP 商城、直播电商、分销返佣、秒杀活动。
![image-20210511171611793](https://static.pickmall.cn/images/h5-qrcode.png) ### ✨ 为什么选择 Lilishop
- 🟢 **真 Apache-2.0 协议**:支持免费商用与私有化闭源二开,无版权后顾之忧。
- 🚀 **Vue 3 全新栈**:基于 `uni-app + Vue 3 + uview-plus 3.x`,告别老旧 Vue 2 模板。
- 🧩 **生产级完整度**:非静态切图模板,完整覆盖 B2B2C 多商户、可视化装修、IM 客服、秒杀拼团、分销直播全闭环。
## lilishop-uniapp如何在本地h5和微信小程序中运行 ---
https://www.bilibili.com/video/BV17K8EemEh2/
## lilishop-uniapp如何打包h5到服务器 ## 1. 项目简介
https://www.bilibili.com/video/BV1CX87exE64/
### 快速开始 **Lilishop** 是一款功能完善的 B2B2C 多商户商城系统,采用前后端分离架构,全端代码开源。
后端基于 **Spring Boot 4**(Java 21)构建,具备高内聚、低耦合的特性,支持分布式部署;前端覆盖 PC、H5、小程序和 APP,基于 **Vue 3** 和 **uni-app** 开发。
#### 阅读文档 本仓库(`lilishop-uniapp`)为 **买家端移动端源码**,一套代码同时支持 **H5、微信小程序、Android / iOS APP**。
`uni-app` https://uniapp.dcloud.net.cn/api/ - **官方网站**: <https://pickmall.cn>
- **官方文档**: [产品文档](https://bdwx2tfwwt.feishu.cn/wiki/space/7675179368632617952?ccm_open_type=lark_wiki_spaceLink&open_tab_from=wiki_home)
- **Gitee 仓库**: <https://gitee.com/beijing_hongye_huicheng>
- **GitHub 主仓库**: <https://github.com/lilishop/lilishop>
`vue2` https://v2.cn.vuejs.org/ ---
`uView v1` https://v1.uviewui.com/ ## 2. 在线演示
#### 环境 > **注意**: 演示站手机验证码统一为 `111111`。演示环境部署于 `master` 分支。
在开发之前保证本地安装了以下软件 | 微信小程序 | 移动端 H5([点击直接访问](https://m-b2b2c.pickmall.cn)) |
`hbulider` https://www.dcloud.io/hbuilderx.html | :---: | :---: |
| <img src="https://static.pickmall.cn/images/h5-qrcode.png" width="180" alt="微信小程序体验码" /> | <img src="https://lilishop-wechat.oss-cn-beijing.aliyuncs.com/h5-qrcode.png" width="180" alt="移动端 H5 体验二维码" /> |
| 微信扫码体验小程序 | 手机扫码或访问 <https://m-b2b2c.pickmall.cn> |
### 技术栈 - **商城 PC 端**: <https://pc-b2b2c.pickmall.cn>
- **平台管理端**: <https://admin-b2b2c.pickmall.cn>
- 账号: `admin` / 密码: `123456`
- **店铺管理端**: <https://store-b2b2c.pickmall.cn>
- 账号: `13011111111` / 密码: `111111`
本项目技术栈为 `uni-app` + `scss` + `ES2015` + `uView` 提前学习和了解这些知识将帮助你更好地上手我们的项目。 ### 移动端界面预览
### 安装 | 商城首页 | 商品列表 | 商品详情 | 填写订单 | 个人中心 |
| :---: | :---: | :---: | :---: | :---: |
| <img src="https://lilishop-wechat.oss-cn-beijing.aliyuncs.com/image.png" width="160" alt="商城首页" /> | <img src="https://lilishop-wechat.oss-cn-beijing.aliyuncs.com/image3.png" width="160" alt="商品列表" /> | <img src="https://lilishop-wechat.oss-cn-beijing.aliyuncs.com/image4.png" width="160" alt="商品详情" /> | <img src="https://lilishop-wechat.oss-cn-beijing.aliyuncs.com/image5.png" width="160" alt="填写订单" /> | <img src="https://lilishop-wechat.oss-cn-beijing.aliyuncs.com/image2.png" width="160" alt="个人中心" /> |
1. 克隆项目到本地 ---
```shell ## 3. 核心特性与技术栈
git clone https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp.git
### 核心特性
- **全端覆盖**: 一套 `uni-app` 代码库支持 H5、微信小程序、Android / iOS APP,大幅降低多端开发与维护成本。
- **商家入驻**: 支持多商家入驻,构建平台化 B2B2C 电商生态。
- **可视化装修**: 支持首页及专题楼层(`pages/floor`)动态可视化配置与主题色切换。
- **即时通讯与直播**: 集成腾讯云 IM / MQTT 消息推送及 HLS 视频流,支持在线客服与直播带货。
- **完整电商闭环**: 涵盖商品浏览、购物车、多种促销(秒杀/拼团/优惠券/积分/砍价/分销)、订单履约、售后维权、会员中心等全流程。
### 移动端技术栈
| 类别 | 技术选型 | 说明 |
| :--- | :--- | :--- |
| 核心框架 | `uni-app` + `Vue 3` | 跨端开发框架(支持 Vue 3 语法与渲染) |
| 状态管理 | `Vuex 4` | 全局登录态、购物车与用户状态管理 |
| UI 组件库 | `uview-plus 3.x` | 适配 Vue 3 的 uni-app 多端 UI 组件库 |
| 即时通讯 | `mqtt 5.x` / `@tencentcloud/chat` | 客服消息与实时通知推送 |
| 音视频流 | `hls.js` | 直播流播放支持 |
| 样式预处理 | `Sass (SCSS)` | 全局主题变量(`uni.scss`)与组件样式定制 |
---
## 4. 目录结构
```text
lilishop-uniapp
├── api/ # 各业务模块接口定义(会员、商品、订单、促销、IM 等)
├── components/ # 公共业务与基础组件
├── config/ # 全局配置目录
│ ├── api.js # 接口域名配置(buyer / im / mqtt)
│ └── config.js # 商城名称、小程序 AppID、高德 Key、主题色等全局参数
├── hybrid/ # App 端本地 HTML 资源(如异常页、WebView 辅助页)
├── js_sdk/ # 第三方及 uni-app 插件 SDK
├── lib/ # 基础工具库封装
├── pages/ # 页面与分包目录
│ ├── tabbar/ # 底部导航主包页面(首页、分类、购物车、我的等)
│ ├── passport/ # 登录、注册、找回密码分包
│ ├── product/ # 商品详情、列表、评价、店铺主页分包
│ ├── cart/ # 购物车与结算页分包
│ ├── order/ # 订单列表、详情、售后、物流、发票分包
│ ├── promotion/ # 秒杀、拼团、砍价、积分商城、分销、直播等营销分包
│ ├── mine/ # 个人中心、钱包、积分、收藏、地址管理分包
│ ├── floor/ # 可视化装修楼层组件与专题页
│ └── navigation/ # 导航与搜索相关页面
├── patches/ # patch-package 第三方依赖补丁
├── scripts/ # 构建与依赖修补脚本(如 postinstall 补丁)
├── static/ # 静态图片与字体资源
├── store/ # Vuex 状态管理
├── styles/ # 公共样式文件
├── uni_modules/ # uni_modules 模块(含 uview-plus 等)
├── utils/ # 请求拦截器、加密、校验、存储等工具函数
├── App.vue # 应用入口组件
├── main.js # 应用初始化入口
├── manifest.json # uni-app 多端应用配置(AppID、权限、SDK 配置等)
├── pages.json # 页面路由、分包加载与导航栏配置
└── uni.scss # 全局 SCSS 变量与主题色定义
``` ```
2. 从`hbulider`中打开项目 ---
```shell ## 5. 配套源码仓库
直接将项目拖进hbulider中点击运行即可
```
### 目录结构 本仓库专注于买家端 **H5 / 小程序 / APP**(`lilishop-uniapp`)。完整系统由以下四个核心仓库组成:
``` | 仓库名称 | 职责说明 | 仓库地址 |
├── api // 接口 | :--- | :--- | :--- |
├── components // 组件 | **`lilishop`** | 后端服务源码(Spring Boot 4 / Java 21) | [Gitee](https://gitee.com/beijing_hongye_huicheng/lilishop) · [GitHub](https://github.com/lilishop/lilishop) |
├── config // 配置文件 | **`lilishop-ui`** | PC 商城 / 商家端 / 运营管理端 / IM Web 前端 | [Gitee](https://gitee.com/beijing_hongye_huicheng/lilishop-ui) |
├── CustomStartPage // 打包配置的开屏页 | **`lilishop-uniapp`** | 买家端 H5 / 微信小程序 / Android & iOS APP | [Gitee](https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp) |
├── CustomStoryboard // ios自定义storyboard启动页 | **`docker`** | 容器化部署编排、镜像与数据库脚本 | [Gitee](https://gitee.com/beijing_hongye_huicheng/docker) · [MySQL 脚本](https://gitee.com/beijing_hongye_huicheng/docker/tree/master/init/mysql) |
├── hybrid // 广告配置页
├── js_sdk // 封装的js_sdk
├── lib // 封装的部分方法
├── pages // 页面
├── plugins // 插件
├── static // 静态资源
├── store // vuex
├── utils // 工具类
├── uview-ui // uview
├── App.vue // 入口页面
├── main.js // 入口文件
├── manifest.json // hbulider配置文件
├── pages.json // 路由配置文件
├── uni.scss // 全局样式
└── vue.config.js // vue配置文件
```
### 运行 ---
#### 运行在 h5 ## 6. 开源与授权
在`hbulider`中点击`运行`->`运行到浏览器`->`选择自己的浏览器九号` 本项目遵循 [Apache-2.0](./LICENSE) 开源协议,版权归 **北京宏业汇成科技有限公司** 所有。允许个人及企业免费用于学习、研究、修改和商业用途(需保留原始版权和许可声明)。
#### 运行在微信小程序 ---
1.需要保证本地要有`微信开发者工具` https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html ## 7. 社区与支持
2.在`hbulider`中点击`运行`->`运行到小程序模拟器`->`微信开发者工具` 运行的时候需要配置小程序的`appid`,配置完成后即可运行 我们欢迎任何形式的交流与贡献。在提问前,请先查阅 [产品文档](https://bdwx2tfwwt.feishu.cn/wiki/space/7675179368632617952?ccm_open_type=lark_wiki_spaceLink&open_tab_from=wiki_home),并参考 [《提问的智慧》](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/master/README-zh_CN.md) 以便高效沟通。
#### 运行 APP - **[在线客服](https://work.weixin.qq.com/kfid/kfc4d8dc24a73c15f44)**
- **微信交流群**:
<img src="https://lilishop-wechat.oss-cn-beijing.aliyuncs.com/wechat.jpg" width="200" alt="微信群" />
##### 运行在安卓 ---
在`hbulider`中点击`运行`->`运行到手机或模拟器`->`选择运行到安卓APP基座` ## 8. 升级计划
##### 运行在 IOS > 更新日期:2026-11-05,依据各端提交记录及当前代码实现同步。
在`hbulider`中点击`运行`->`运行到手机或模拟器`->`选择运行到IOS基座` ### ✅ 已完成特性
### 项目配置/开发
#### config配置
在根目录`config`下的`config`设置中配置了一些默认的配置,可以根据自己的需求进行修改
```
const name = "lilishop"; //全局商城name
const schemeName = "lilishop"; //唤醒app需要的schemeName
export default {
name: name,
schemeLink: `${schemeName}://`, //唤起app地址
downloadLink: "https://pickmall.cn/download-page/index.html", //下载地址,下载app的地址
shareLink: "https://m-b2b2c.pickmall.cn", //分享地址,也就是在h5中默认的复制地址
appid: "", //小程序唯一凭证,即 AppID,可在「微信公众平台 - 设置 - 开发设置」页中获得。(需要已经成为开发者,且帐号没有异常状态)
aMapKey: "", //在高德中申请Web服务key
scanAuthNavigation: ["https://m-b2b2c.pickmall.cn/"], //扫码认证跳转域名配置 会根据此处配置的路由进行跳转
iosAppId: "id1564638363", //AppStore的应用地址id 具体在分享->拷贝链接中查看
logo: "https://lilishop-oss.oss-cn-beijing.aliyuncs.com/4c864e133c2944efad1f7282ac8a3b9e.png", //logo地址
customerServiceMobile: "13161366885", //客服电话
customerServiceEmail: "lili@lili.com", //客服邮箱
imWebSrc: "https://im.pickmall.cn", //IM地址
baseWsUrl: "wss://im-api.pickmall.cn/lili/webSocket", // IM WS 地址
enableGetClipboard: false, //是否启用粘贴板获取 scanAuthNavigation 中的链接,如果匹配则会跳转到对应页面
enableMiniBarStartUpApp: true, //是否在h5中右侧浮空按钮点击启动app
/**
* 如需更换主题请修改此处以及uni.scss中的全局颜色
*/
mainColor: "#ff3c2a", // 主题色
lightColor: "#ff6b35", // 高亮主题色
aiderLightColor: "#ff9f28", // 辅助高亮颜色
defaultUserPhoto: "/static/missing-face.png", // 默认用户头像
enableFetchMobileLogin: false // 是否启用获取手机号登录 如果微信小程序提示封禁手机号获取权限 可将此选项设置成false作为备用登录方案
};
```
#### 组件
在根目录`components`下的`components`设置中配置了一些默认的组件,可以根据自己的需求进行修改或阅读组件详情代码以及README.md文档
#### 页面
在`pages`文件夹写入或修改页面代码,在`pages.json`中去配置页面路由,具体配置可以参考`pages.json` 或参考uni-app的文档
在微信小程序中默认启用分包操作,如果需要在微信小程序中使用分包,需要在`pages.json`中配置分包路径,具体配置可以参考`pages.json` 或参考uni-app的文档
#### 主题
1.现在`config`中设置主题色
2.在`uni.scss`中设置全局颜色
3.替换项目中一些icon以及图片的颜色
### 常见问题
#### 微信小程序移动端启动报错
小程序直播插件报错,在`manifest`中删除代码。
![启动报错](https://docs.pickmall.cn/configure/images/live.png)
#### 微信小程序上传文件过大超出 2MB
1.关闭微信小程序,停止微信小程序运行
2.重新点击运行小程序模拟器,在最下方有一个 `运行时是否压缩代码` 勾选并重新运行
3.如果还是提示超出2MB,重新执行1步骤,然后点击`发行`->`小程序`即可
4.以上1-3步骤都不行,可以尝试删除一些自己开发的代码或本地的静态资源图片
#### 微信小程序在开发者工具中可以使用接口在测试版却不行
1.首先保证是否填写`request`合法域名 在微信小程序后台配置
2.需保证接口为https请求
request合法域名基础配置如下
```
https://buyer-api.pickmall.cn
https://common-api.pickmall.cn
https://im-api.pickmall.cn
https://restapi.amap.com
```
socket合法域名
```
wss://im-api.pickmall.cn
```
uploadFile合法域名
```
https://common-api.pickmall.cn
```
downloadFile合法域名
```
https://buyer-api.pickmall.cn
https://common-api.pickmall.cn
https://im-api.pickmall.cn
https://lilishop-oss.oss-cn-beijing.aliyuncs.com
```
#### 如何配置API
在根目录 `config` -> `api` 中配置开发环境以及生产环境 api 接口地址
#### 运行报错
初次运行时候可能因为本地环境缺少编译插件,这个时候一定要注意看报错信息,根据报错信息安装相应的插件即可
#### 如何配置微信小程序appid
在根目录 `manifest.json` 中配置微信小程序appid
#### 微信登录报错
需检查appId是否配置正确,在后台管理中信任登录的`appId`以及`appSecret`是否配置正确
按可核实的实现或完善时间倒序记录;日期表示代码完成或功能更新时间,不代表生产上线时间。
| 时间 | 功能模块 | 完成内容 |
| :--- | :--- | :--- |
| 2026-11-05 | ✅ 付费会员 | 单一付费会员、开通与续费、有效期、关联权益、商家与商品折扣、平台补贴及付费记录。 |
| 2026-11-04 | ✅ 客户等级体系 / 客户权益 | 等级配置、权益介绍、经验值任务与明细、权益发放及重试,提供默认等级与权益数据。 |
| 2026-11-04 | ✅ 小程序订单管理 | 增加小程序订单查询入口及微信订单自动上报开关。 |
| 2026-11-04 | ✅ 立减优惠券 | 新增立减券,完善优惠券校验、领取与订单优惠计算。 |
| 2026-11-04 | ✅ 商品定时上下架 | 完善定时上下架计划管理、独立列表及执行校验。 |
| 2026-11-04 | ✅ 微信小程序原生能力 | 接入微信地址导入、头像选择和昵称填写。 |
| 2026-11-02 | ✅ 消息模板 | 支持多渠道模板矩阵维护,统一站内信、短信、微信公众号及小程序订阅消息的场景配置和异步发送。 |
| 2026-10-30 | ✅ PC 页面装修 | 重构楼层组件,支持自适应高度、可视化热区绘制及配置交互优化。 |
| 2026-10-29 | ✅ 定时任务管理 | 重构为数据库配置驱动,支持运营后台维护任务。 |
| 2026-10-29 | ✅ 敏感词管理 | 支持按业务场景配置过滤开关,并优化词库加载。 |
| 2026-10-29 | ✅ PC 店铺搜索 | 新增店铺列表,支持商品与店铺双模式搜索。 |
| 2026-10-22 | ✅ 分类设置 | 支持四种分类页模板选择、商品列表展示字段开关及模板图片预览。 |
| 2026-10-20 | ✅ 移动端页面装修 | 完善可视化编辑器,新增首页组合组件及优惠券、店铺、文章等楼层。 |
| 2026-10-09 | ✅ 主题色管理 | 完善主题设置,支持自定义模式。 |
| 2026-10-02 | ✅ 预约服务商品 | 完善预约商品、预约交易及订单详情功能。 |
| 2026-08-05 | ✅ 二级分销 | 由一级分销扩展为二级分销,增加节点配置及分销员中心。 |
| 2026-08-03 | ✅ 卡密商品 | 完善电子卡券履约、订单状态及卡池管理。 |
| 2026-07-23 | ✅ 素材库管理 | 增加文件分类、目录管理及目录归属校验。 |
| 2026-07-20 | ✅ 经营统计报表 | 新增店铺业绩、商品同比环比、销售订单明细及商品销售汇总报表。 |
| 2026-07-13 | ✅ 腾讯云直播 | 接入并完善直播、聊天与直播商品相关功能。 |
| 2026-06-30 | ✅ 移动端技术升级 | 升级 Vue 3 与 uView Plus,适配组件和页面。 |
| 2026-06-29 | ✅ 电子面单发货 | 完善快递鸟电子面单,支持自动携带运单号发货。 |
| 2026-06-05 | ✅ 后端与管理端框架升级 | 5 月 25 日至 6 月 5 日完成 Spring Boot 4、管理端 Vue 3 与 Element Plus 升级。 |
| 2026-05-22 | ✅ 购物卡 | 新增礼品卡接口,以及选择、绑定、激活和列表管理。 |
| 2026-05-20 | ✅ 微信提现 | 完善转账状态查询、确认回调和重试处理,后续补充提现规则说明配置。 |
| 2026-04-16 | ✅ 置顶评论 | 支持评论置顶及商品评价管理。 |
| 2026-04-13 | ✅ 专用发票(发票上传) | 完善发票信息字段、发票详情及管理展示。 |
| 2026-04-01 | ✅ 商品虚拟销量 | 支持按商品规格设置虚拟销量,提供单个及批量设置入口。 |
| 2026-03-30 | ✅ 商品分组 | 新增商品分组管理及商品关联功能。 |
| 2026-03-24 | ✅ 会员分组 | 新增会员分组管理。 |
### 🔜 近期规划中
- 🔜 微信小店对接
- 🔜 抖店对接
- 🔜 微信小程序原生重构与体验对齐(持续完善;已接入预约交易、分类多模板与首页楼层装修)
- 🔜 OpenAPI 开放平台与开发者中心

View File

@@ -37,7 +37,7 @@ export function getLogistics() {
*/ */
export function getAddressCode(cityCode, townName) { export function getAddressCode(cityCode, townName) {
return http.request({ return http.request({
url: api.common + "/common/region/region", url: `${api.buyer}/common/region/region`,
method: Method.GET, method: Method.GET,
needToken: true, needToken: true,
params: { cityCode, townName }, params: { cityCode, townName },

43
api/appointment.js Normal file
View File

@@ -0,0 +1,43 @@
/**
* 预约服务买家端 API
*/
import { http, Method } from '@/utils/request.js'
/** 查询可预约时段 */
export function listSlots(skuId, slotDate) {
return http.request({
url: '/appointment/slots',
method: Method.GET,
needToken: true,
params: { skuId, slotDate },
})
}
/** 绑定预约结算上下文(addToCart 后、createTrade 前) */
export function bindCheckout(data) {
return http.request({
url: '/appointment/checkout/bind',
method: Method.POST,
needToken: true,
data,
})
}
/** 预约商品扩展配置 */
export function getGoodsExt(goodsId) {
return http.request({
url: `/appointment/goods/${goodsId}/ext`,
method: Method.GET,
needToken: false,
})
}
/** 买家预约订单详情(时段、核销码) */
export function getAppointmentOrderDetail(orderSn) {
return http.request({
url: `/appointment/order/${orderSn}`,
method: Method.GET,
needToken: true,
})
}

View File

@@ -39,5 +39,17 @@ export function getArticleDetail(type) {
}); });
} }
/**
* 分页获取文章列表(楼层装修用)
* @param params { pageNumber, pageSize, categoryId? }
*/
export function getArticleList(params) {
return http.request({
url: `/other/article`,
method: Method.GET,
params,
});
}

View File

@@ -1,5 +1,5 @@
/** /**
* 公共API * 公共 API(由 buyer-api 提供)
*/ */
import { http, Method } from "@/utils/request.js"; import { http, Method } from "@/utils/request.js";
import api from "@/config/api.js"; import api from "@/config/api.js";
@@ -10,16 +10,16 @@ import api from "@/config/api.js";
*/ */
export function getRegionsById(id = 0) { export function getRegionsById(id = 0) {
return http.request({ return http.request({
url: `${api.common}/common/region/item/${id}`, url: `${api.buyer}/common/region/item/${id}`,
method: Method.GET, method: Method.GET,
message: false, message: false,
}); });
} }
// 获取IM接口前缀 // 获取 IM 接口前缀
export function getIMDetail() { export function getIMDetail() {
return http.request({ return http.request({
url: `${api.common}/IM`, url: `${api.buyer}/common/IM`,
method: Method.GET, method: Method.GET,
message: false, message: false,
}); });
@@ -29,4 +29,26 @@ export function getIMDetail() {
* 文件上传地址 * 文件上传地址
* @type {string} * @type {string}
*/ */
export const upload = api.common + "/common/upload/file"; export const upload = `${api.buyer}/common/upload/file`;
/**
* 获取主题色配置
*/
export function getThemeSetting() {
return http.request({
url: `${api.buyer}/common/site/theme`,
method: Method.GET,
message: false,
});
}
/**
* 获取分类页配置
*/
export function getCategoryPageSetting() {
return http.request({
url: `${api.buyer}/common/site/category-page`,
method: Method.GET,
message: false,
});
}

233
api/distribution.js Normal file
View File

@@ -0,0 +1,233 @@
/**
* 分销员相关 API
*/
import { http, Method } from '@/utils/request.js'
/**
* 绑定分销员
* @param distributionId 分销员ID
*/
export function getGoodsDistribution(distributionId) {
return http.request({
url: `/distribution/distribution/bindingDistribution/${distributionId}`,
method: Method.GET,
})
}
/**
* 获取当前会员的分销员信息(含待提现、冻结金额等)
*/
export function distribution() {
return http.request({
url: `/distribution/distribution`,
method: Method.GET,
})
}
/** 推广海报上下文(邀请好友锁客) */
export function getPromotionPoster() {
return http.request({
url: `/distribution/distribution/promotion-poster`,
method: Method.GET,
})
}
/** 邀请卡上下文(招募下级分销员) */
export function getInviteCard() {
return http.request({
url: `/distribution/distribution/invite-card`,
method: Method.GET,
})
}
/** 我邀请的下级分销员列表 */
export function getDistributionInvitees(params) {
return http.request({
url: `/distribution/distribution/invite/invitees`,
method: Method.GET,
params,
})
}
/** 分销员业绩统计 */
export function getDistributionPerformance(params) {
return http.request({
url: `/distribution/distribution/performance`,
method: Method.GET,
params,
})
}
/** 我的客户列表 */
export function getDistributionCustomers(params) {
return http.request({
url: `/distribution/distribution/customers`,
method: Method.GET,
params,
})
}
/** 客户详情 */
export function getDistributionCustomerDetail(id) {
return http.request({
url: `/distribution/distribution/customers/${id}`,
method: Method.GET,
})
}
/** 设置/取消客户星标 */
export function updateDistributionCustomerStarred(id, starred) {
return http.request({
url: `/distribution/distribution/customers/${id}/starred`,
method: Method.PUT,
params: { starred },
})
}
/** 分销等级列表(包装 VO:upgradeConditionVisible + grades) */
export function getDistributionGrades() {
return http.request({
url: `/distribution/distribution/grades`,
method: Method.GET,
})
}
/** 分销员提现 */
export function cash(params) {
return http.request({
url: `/distribution/cash`,
method: Method.POST,
params,
})
}
/** 分销员提现历史 */
export function cashLog(params) {
return http.request({
url: `/distribution/cash`,
method: Method.GET,
params,
})
}
/** 推广/邀请订单分页列表 */
export function getDistributionOrders(params) {
return http.request({
url: `/distribution/order/orders`,
method: Method.GET,
params,
})
}
/** 推广/邀请订单详情 */
export function getDistributionOrderDetail(params) {
return http.request({
url: `/distribution/order/orders/detail`,
method: Method.GET,
params,
})
}
/** 获取分销商品设置 */
export function getDistributionGoodsSetting() {
return http.request({
url: `/distribution/goods/setting`,
method: Method.GET,
})
}
/** 获取分销员商品列表 */
export function distributionGoods(params) {
return http.request({
url: `/distribution/goods`,
method: Method.GET,
params,
})
}
/** 获取分销员中心推荐商品 */
export function getDistributionFeaturedGoods() {
return http.request({
url: `/distribution/goods/featured`,
method: Method.GET,
})
}
/** 获取分销商品分享上下文(推广图文) */
export function getDistributionGoodsShareContext(params) {
return http.request({
url: `/distribution/goods/share-context`,
method: Method.GET,
params,
})
}
/** 获取分销商品海报上下文(生成葵花码,服务端记录分享) */
export function getDistributionGoodsPosterContext(params) {
return http.request({
url: `/distribution/goods/poster-context`,
method: Method.GET,
params,
})
}
/** 分享商品访问(记录访问并绑定客户关系) */
export function recordDistributionGoodsVisit(params) {
return http.request({
url: `/distribution/distribution/share-visit`,
method: Method.GET,
params,
})
}
/** 招募页信息 */
export function getRecruitPage() {
return http.request({
url: `/distribution/distribution/recruit/page`,
method: Method.GET,
})
}
/** 招募页邀请人信息(无需登录) */
export function getRecruitInviter(distributionId) {
return http.request({
url: `/distribution/distribution/recruit/inviter`,
method: Method.GET,
params: { distributionId },
})
}
/** 提交招募申请 */
export function submitRecruitApplication(data) {
return http.request({
url: `/distribution/distribution/recruit/apply`,
method: Method.POST,
data,
})
}
/** 招募条件进度 */
export function getRecruitProgress() {
return http.request({
url: `/distribution/distribution/recruit/progress`,
method: Method.GET,
})
}
/** 上报招募邀请 token(登录后供自动申请使用) */
export function savePendingRecruitToken(recruitToken) {
return http.request({
url: `/distribution/distribution/recruit/pending-token`,
method: Method.PUT,
params: { recruitToken },
})
}
/** 上级分销员信息 */
export function getDistributionParent() {
return http.request({
url: `/distribution/distribution/parent`,
method: Method.GET,
})
}

View File

@@ -15,11 +15,11 @@ import { http, Method } from "@/utils/request.js";
} }
/** /**
* 从ES中获取相关商品品牌名称,分类名称及属性 * 获取商品搜索筛选条件
*/ */
export function getGoodsRelated(params) { export function getGoodsRelated(params) {
return http.request({ return http.request({
url: `/goods/goods/es/related`, url: `/goods/goods/search/related`,
method: Method.GET, method: Method.GET,
params, params,
}); });
@@ -37,18 +37,6 @@ export function getGoodsRelated(params) {
}); });
} }
/**
* 获取商品分销
* @param distributionId 商品分销ID
*/
export function getGoodsDistribution(distributionId) {
return http.request({
url: `/distribution/distribution/bindingDistribution/${distributionId}`,
method: Method.GET,
});
}
/** /**
* 获取商品列表 * 获取商品列表
* @param params * @param params
@@ -56,7 +44,7 @@ export function getGoodsRelated(params) {
*/ */
export function getGoodsList(params) { export function getGoodsList(params) {
return http.request({ return http.request({
url: "/goods/goods/es", url: "/goods/goods/search",
method: Method.GET, method: Method.GET,
params, params,
}); });
@@ -118,85 +106,6 @@ export function getCategoryList(id) {
}); });
} }
/**
* 获取当前会员的分销商信息 可根据分销商信息查询待提现金额以及冻结金额等信息
*/
export function distribution() {
return http.request({
url: `/distribution/distribution`,
method: Method.GET,
});
}
/**
* 申请分销商
*/
export function applyDistribution(params) {
return http.request({
url: `/distribution/distribution`,
method: Method.POST,
params,
});
}
/**
* 分销商提现
*/
export function cash(params) {
return http.request({
url: `/distribution/cash`,
method: Method.POST,
params,
});
}
/**
* 分销商提现历史
*/
export function cashLog(params) {
return http.request({
url: `/distribution/cash`,
method: Method.GET,
params
});
}
/**
* 获取分销商分页订单列表
*/
export function distributionOrderList(params) {
return http.request({
url: `/distribution/distribution/distributionOrder`,
method: Method.GET,
params
});
}
/**
* 获取分销商商品列表
*/
export function distributionGoods(params) {
return http.request({
url: `/distribution/goods`,
method: Method.GET,
params,
});
}
/**
* 选择分销商品 分销商品id
*/
export function checkedDistributionGoods(params) {
return http.request({
url: `/distribution/goods/checked/${params.id}`,
method: Method.GET,
params
});
}
/** /**
* 获取 小程序码 * 获取 小程序码
*/ */

65
api/live.js Normal file
View File

@@ -0,0 +1,65 @@
/**
* 直播流相关 API
*/
import { http, Method } from "@/utils/request.js";
/**
* 通过 id 获取直播间详情
* @param {string} id 直播流 ID
*/
export function getLiveRoomById(id) {
return http.request({
url: `live/room/${id}`,
method: Method.GET,
});
}
/**
* 观看的同时注册直播用户
* @param {string} liveRoomId 直播流 ID
*/
export function registerLiveViewUser(liveRoomId) {
return http.request({
url: `live/user/view`,
method: Method.POST,
params: { liveRoomId },
});
}
/**
* 发送直播消息
* @param {object} data LiveMessage
*/
export function sendLiveMessage(data) {
return http.request({
url: `live/message`,
method: Method.POST,
data,
});
}
/**
* 获取直播轮询聚合数据
* @param {string} id 直播流 ID
*/
export function getLivePollingData(id) {
return http.request({
url: `live/room/polling/${id}`,
method: Method.GET,
loading: false,
});
}
/**
* 领取直播间优惠券
* @param {string} liveRoomId 直播流 ID
* @param {string} couponId 优惠券 ID
*/
export function receiveLiveCoupon(liveRoomId, couponId) {
return http.request({
url: `promotion/coupon/receive/live/${liveRoomId}/${couponId}`,
method: Method.GET,
needToken: true,
});
}

View File

@@ -59,7 +59,7 @@ export function getAutoCoup(){
*/ */
export function sendMobile(mobile,type='LOGIN') { export function sendMobile(mobile,type='LOGIN') {
return http.request({ return http.request({
url: `${api.common}/common/sms/${type}/${mobile}`, url: `${api.buyer}/common/sms/${type}/${mobile}`,
method: "GET", method: "GET",
}); });
} }
@@ -95,6 +95,19 @@ export function modifyPass(params) {
}); });
} }
/**
* 修改密码
* @param newPassword
* @param password
*/
export function resetPassword(params) {
return http.request({
url: `/passport/member/resetPassword`,
method: "POST",
params,
});
}
/** /**
* 刷新token * 刷新token
*/ */
@@ -138,4 +151,4 @@ export function logoffConfirm() {
method: "PUT", method: "PUT",
needToken: true, needToken: true,
}) })
} }

View File

@@ -23,6 +23,23 @@ export function withdrawalApply(params) {
}); });
} }
export function getWithdrawApplyPage(params) {
return http.request({
url: "/member/withdrawApply",
method: Method.GET,
needToken: true,
params,
});
}
export function getWithdrawApplyWechatTransferInfo(id) {
return http.request({
url: `/member/withdrawApply/wechat/transfer/${id}`,
method: Method.GET,
needToken: true,
});
}
/** /**
* 支付结果查询 * 支付结果查询
* @param orderType 交易类型,可用值:TRADE,ORDER,RECHARGE * @param orderType 交易类型,可用值:TRADE,ORDER,RECHARGE
@@ -460,3 +477,11 @@ export function withdrawalSettingVO() {
}); });
} }
export function getCurrentMemberBenefits() { return http.request({url:'/member/benefit/current',method:Method.GET,needToken:true}) }
export function getMemberGradeBenefits() { return http.request({url:'/member/memberGrade/list',method:Method.GET,needToken:true}) }
/** 仅返回后台已开启的经验值规则及当前会员累计获得情况。 */
export function getExperienceTasks() { return http.request({ url: '/member/memberGrade/rules', method: Method.GET, needToken: true }) }
/** 当前会员等级、经验值及分页流水;会员身份由服务端登录态确定。 */
export function getExperienceRecords(params) { return http.request({ url: '/member/memberGrade/current', method: Method.GET, params, needToken: true }) }

View File

@@ -110,3 +110,15 @@ export function getLogisticsMessages(params) {
data data
}); });
} }
/**
* 获取微信公众号通知配置及绑定状态
*/
export function getWechatOfficialAccountSetting() {
return http.request({
url: '/message/wechatOfficialAccount',
method: Method.GET,
needToken: true,
});
}

7
api/paid-member.js Normal file
View File

@@ -0,0 +1,7 @@
import { http, Method } from '@/utils/request.js'
export const getPaidMember = () => http.request({ url: '/member/paid/current', method: Method.GET, needToken: true })
export const createPaidMemberOrder = data => http.request({ url: '/member/paid/orders', method: Method.POST, data, needToken: true, header: { 'Content-Type': 'application/json' } })
export const getPaidMemberOrders = params => http.request({ url: '/member/paid/orders', method: Method.GET, params, needToken: true })
export const getPaidMemberOrder = sn => http.request({ url: `/member/paid/orders/${encodeURIComponent(sn)}`, method: Method.GET, needToken: true })
export const cancelPaidMemberOrder = sn => http.request({ url: `/member/paid/orders/${encodeURIComponent(sn)}/cancel`, method: Method.POST, needToken: true })
export const getPaidMemberQuotes = skuIds => http.request({ url: '/member/paid/quotes', method: Method.GET, params: { skuIds: skuIds.join(',') }, needToken: true })

13
api/pickupCard.js Normal file
View File

@@ -0,0 +1,13 @@
/**
* 提货卡选品、试算及一次兑换接口。
* @author Bulbasaur
* @since 2026-11-05
*/
import { http, Method } from '@/utils/request.js'
/** 获取当前会员的卡规则及候选商品。 */
export const getPickupCard = id => http.request({ url: `/promotion/pickupCard/${encodeURIComponent(id)}`, method: Method.GET, needToken: true })
/** 服务端试算,校验商品与地址且不消耗权益。 */
export const previewPickupCard = data => http.request({ url: '/promotion/pickupCard/preview', method: Method.POST, needToken: true, header: { 'content-type': 'application/json' }, data })
/** 原子核销创单,网络重试返回原交易。 */
export const redeemPickupCard = data => http.request({ url: '/promotion/pickupCard/redeem', method: Method.POST, needToken: true, header: { 'content-type': 'application/json' }, data })

View File

@@ -17,6 +17,23 @@ export function getLiveList(params) {
}); });
} }
/**
* 获取直播间详情
* @deprecated 请使用 api/live.js 中的 getLiveRoomById
* @param {number} roomId 直播间房间号
*/
export function getLiveDetail(roomId) {
return http.request({
url: `broadcast/studio`,
method: Method.GET,
params: {
pageNumber: 1,
pageSize: 1,
roomId,
},
});
}
/** /**
* 获取当前拼团活动的未成团的会员 * 获取当前拼团活动的未成团的会员
*/ */
@@ -185,4 +202,40 @@ export function getMineBargainLog(params) {
}); });
} }
/**
* 分页查询当前客户礼品卡
*/
export function getGiftCardCashMemberCardPage(params) {
return http.request({
url: '/promotion/giftCardCash/memberCard',
method: Method.GET,
needToken: true,
params,
})
}
/**
* 绑定礼品卡(卡号 + 兑换码/卡密)
*/
export function bindGiftCardCashMemberCard(data) {
return http.request({
url: '/promotion/giftCardCash/memberCard/bind',
method: Method.POST,
needToken: true,
header: { 'content-type': 'application/json' },
data,
})
}
/**
* 激活礼品卡
*/
export function activateGiftCardCashMemberCard(memberCardId) {
return http.request({
url: `/promotion/giftCardCash/memberCard/${memberCardId}/activate`,
method: Method.POST,
needToken: true,
})
}

View File

@@ -169,6 +169,20 @@ export function setAddressId(addressId,way) {
} }
/**
* 选择礼品卡
* @param way 购物车购买:CART/立即购买:BUY_NOW/拼团:PINTUAN / 积分:POINTS / 砍价:KANJIA
* @param credentialId 礼品卡凭证 id;used=false 且不传则清空全部
*/
export function selectGiftCard(params) {
return http.request({
url: `/trade/carts/select/giftCard`,
method: Method.GET,
needToken: true,
params,
});
}
/** /**
* 创建交易 * 创建交易
*/ */

View File

@@ -0,0 +1,133 @@
<template>
<scroll-view scroll-x scroll-with-animation class="cate-scroller" :scroll-into-view="intoView">
<view
v-for="item in list"
:key="item.id"
:id="'cs-' + item.id"
class="cs-item"
:class="{ active: item.id === currentId, 'cs-item--text': mode === 'text' }"
@click="$emit('change', item)"
>
<template v-if="mode === 'icon'">
<view class="cs-icon-box">
<view class="cs-icon">
<u-image width="80rpx" height="80rpx" shape="circle" :src="item.image" mode="aspectFill">
<template #loading><u-loading-icon></u-loading-icon></template>
</u-image>
</view>
</view>
<text class="cs-name">{{ item.name }}</text>
</template>
<template v-else>
<text class="cs-text-name">{{ item.name }}</text>
<view class="cs-text-line" v-if="item.id === currentId"></view>
</template>
</view>
</scroll-view>
</template>
<script setup lang="ts">
import { computed } from 'vue'
const props = withDefaults(defineProps<{
list?: any[]
currentId?: string | number | null
mode?: 'icon' | 'text'
}>(), {
list: () => [],
currentId: null,
mode: 'icon'
})
defineEmits(['change'])
const intoView = computed(() =>
props.currentId != null ? 'cs-' + props.currentId : ''
)
</script>
<style lang="scss" scoped>
.cate-scroller {
white-space: nowrap;
width: 100%;
background: #ffffff;
border-bottom: 1rpx solid #f2f3f5;
box-sizing: border-box;
flex-shrink: 0;
}
.cs-item {
display: inline-flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 130rpx;
padding: 16rpx 6rpx 14rpx;
vertical-align: top;
box-sizing: border-box;
transition: all 0.2s ease;
}
.cs-icon-box {
width: 92rpx;
height: 92rpx;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
border: 3rpx solid transparent;
box-sizing: border-box;
background: #ffffff;
transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.cs-item.active .cs-icon-box {
border-color: $light-color;
box-shadow: 0 4rpx 12rpx rgba(255, 102, 0, 0.15);
}
.cs-icon {
width: 80rpx;
height: 80rpx;
border-radius: 50%;
overflow: hidden;
background: #f6f7f9;
display: flex;
align-items: center;
justify-content: center;
}
.cs-name {
margin-top: 10rpx;
font-size: 24rpx;
color: #555;
max-width: 120rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
line-height: 1.2;
}
.cs-item.active .cs-name {
color: $light-color;
font-weight: 600;
}
.cs-item--text {
width: auto;
padding: 18rpx 28rpx;
position: relative;
}
.cs-text-name {
font-size: 26rpx;
color: #666;
transition: color 0.2s ease;
}
.cs-item--text.active .cs-text-name {
color: $light-color;
font-weight: 600;
}
.cs-text-line {
position: absolute;
bottom: 6rpx;
left: 50%;
transform: translateX(-50%);
width: 32rpx;
height: 4rpx;
border-radius: 2rpx;
background: $light-color;
}
</style>

View File

@@ -0,0 +1,75 @@
<template>
<scroll-view scroll-y scroll-with-animation class="side-list">
<view
v-for="item in list"
:key="item.id"
class="side-item"
:class="{ active: item.id === currentId }"
@click="$emit('change', item)"
>
<view class="active-indicator" v-if="item.id === currentId"></view>
<text class="side-item-text">{{ item.name }}</text>
</view>
</scroll-view>
</template>
<script setup lang="ts">
withDefaults(defineProps<{
list?: any[]
currentId?: string | number | null
}>(), {
list: () => [],
currentId: null
})
defineEmits(['change'])
</script>
<style lang="scss" scoped>
.side-list {
width: 176rpx;
flex-shrink: 0;
height: 100%;
background-color: #f6f7f9;
border-right: 1rpx solid #ebebeb;
box-sizing: border-box;
}
.side-item {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
min-height: 96rpx;
padding: 16rpx 14rpx;
box-sizing: border-box;
font-size: 26rpx;
color: #666;
text-align: center;
position: relative;
transition: all 0.2s ease;
&.active {
font-weight: 600;
color: $light-color;
background: #ffffff;
}
}
.side-item-text {
line-height: 1.35;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
text-overflow: ellipsis;
}
.active-indicator {
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
width: 6rpx;
height: 36rpx;
border-radius: 0 4rpx 4rpx 0;
background: $light-color;
}
</style>

View File

@@ -0,0 +1,94 @@
<template>
<view class="sort-bar">
<view
class="sort-item"
:class="{ active: sort === 'releaseTime' }"
@click="onClick('releaseTime')"
>
<text class="sort-label">综合</text>
</view>
<view
class="sort-item"
:class="{ active: sort === 'buyCount' }"
@click="onClick('buyCount')"
>
<text class="sort-label">销量</text>
</view>
<view
class="sort-item"
:class="{ active: sort === 'price' }"
@click="onClick('price')"
>
<text class="sort-label">价格</text>
<view class="arrows">
<u-icon
name="arrow-up-fill"
size="7"
:color="sort === 'price' && order === 'asc' ? '#ff6700' : '#bbbbbb'"
></u-icon>
<u-icon
name="arrow-down-fill"
size="7"
:color="sort === 'price' && order === 'desc' ? '#ff6700' : '#bbbbbb'"
></u-icon>
</view>
</view>
</view>
</template>
<script setup lang="ts">
const props = withDefaults(defineProps<{
sort?: string
order?: string
}>(), {
sort: 'releaseTime',
order: 'desc'
})
const emit = defineEmits(['change'])
function onClick(type: string) {
let nextOrder = 'desc'
if (type === 'price') {
nextOrder = props.sort === 'price' && props.order === 'desc' ? 'asc' : 'desc'
}
emit('change', { sort: type, order: nextOrder })
}
</script>
<style lang="scss" scoped>
.sort-bar {
display: flex;
align-items: center;
height: 68rpx;
background: #ffffff;
padding: 0 20rpx;
border-bottom: 1rpx solid #f6f6f6;
box-sizing: border-box;
flex-shrink: 0;
}
.sort-item {
display: flex;
align-items: center;
margin-right: 44rpx;
font-size: 26rpx;
color: #666;
height: 100%;
cursor: pointer;
transition: color 0.2s ease;
&.active {
color: $light-color;
font-weight: 600;
}
}
.sort-label {
font-size: 26rpx;
}
.arrows {
display: flex;
flex-direction: column;
margin-left: 8rpx;
gap: 2rpx;
}
</style>

View File

@@ -0,0 +1,61 @@
<template>
<scroll-view scroll-x scroll-with-animation class="tag-bar" :scroll-into-view="intoView">
<view
v-for="item in list"
:key="item.id"
:id="'tb-' + item.id"
class="tag-item"
:class="{ active: item.id === currentId }"
@click="$emit('change', item)"
>
{{ item.name }}
</view>
</scroll-view>
</template>
<script setup lang="ts">
import { computed } from 'vue'
const props = withDefaults(defineProps<{
list?: any[]
currentId?: string | number | null
}>(), {
list: () => [],
currentId: null
})
defineEmits(['change'])
const intoView = computed(() =>
props.currentId != null ? 'tb-' + props.currentId : ''
)
</script>
<style lang="scss" scoped>
.tag-bar {
white-space: nowrap;
width: 100%;
background: #ffffff;
padding: 12rpx 16rpx 10rpx;
border-bottom: 1rpx solid #f6f6f6;
box-sizing: border-box;
flex-shrink: 0;
}
.tag-item {
display: inline-block;
padding: 6rpx 22rpx;
margin-right: 12rpx;
font-size: 24rpx;
color: #666;
background: #f5f6f8;
border-radius: 24rpx;
line-height: 1.35;
transition: all 0.2s ease;
&.active {
color: #ffffff;
background: $light-color;
font-weight: 500;
}
}
</style>

View File

@@ -0,0 +1,297 @@
<template>
<view class="tpl-goods">
<!-- 模板2/3:顶部一级分类图标横滑 -->
<category-scroller
v-if="template !== 4"
:list="categoryList"
:current-id="currentL1 && currentL1.id"
mode="icon"
@change="onL1Change"
/>
<view class="tpl-main">
<!-- 左侧:模板2/3 为二级分类,模板4 为一级分类 -->
<category-side-list
:list="sideList"
:current-id="sideCurrentId"
@change="onSideChange"
/>
<view class="tpl-right">
<!-- 模板2:三级分类标签横滑 (置于右栏顶部) -->
<sub-tag-bar
v-if="template === 2 && l3List.length"
:list="l3List"
:current-id="currentL3 && currentL3.id"
@change="onL3Change"
/>
<!-- 模板4:右上二级分类文字横滑(起点为当前一级名称,作为"全部"入口) -->
<category-scroller
v-if="template === 4"
:list="l2Items"
:current-id="topCurrentId"
mode="text"
@change="onL2Change"
/>
<sort-bar :sort="sort" :order="order" @change="onSortChange" />
<scroll-view scroll-y class="goods-scroll" @scrolltolower="loadMore">
<m-goods-list
v-if="goodsList.length"
:res="goodsList"
type="oneColumns"
:show-fields="setting.showFields"
:tab-bar-gap="false"
:store-name="false"
@add-cart="onAddCart"
/>
<view v-else-if="!loading" class="empty-state">
<u-empty
:text="failed ? '加载失败,请重试' : '暂无相关商品'"
mode="data"
icon="http://cdn.uviewui.com/uview/empty/data.png"
margin-top="100"
>
<view v-if="failed" class="retry" @click="loadGoods(true)">重试</view>
</u-empty>
</view>
<uni-load-more
v-if="showLoadMore"
:status="loading ? 'loading' : hasMore ? 'more' : 'noMore'"
:color="'#bfbfbf'"
:content-text="loadMoreText"
></uni-load-more>
</scroll-view>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { ref, computed, watch } from 'vue'
import { getGoodsList } from '@/api/goods.js'
import CategoryScroller from './category-scroller.vue'
import CategorySideList from './category-side-list.vue'
import SubTagBar from './sub-tag-bar.vue'
import SortBar from './sort-bar.vue'
import MGoodsList from '@/components/m-goods-list/list.vue'
defineOptions({
options: {
virtualHost: true,
addGlobalClass: true,
},
})
const props = withDefaults(defineProps<{
categoryList?: any[]
setting?: any
template?: number
}>(), {
categoryList: () => [],
setting: () => ({ template: 1, showFields: {} }),
template: 2
})
const currentL1 = ref<any>(null)
const currentL2 = ref<any>(null)
const currentL3 = ref<any>(null)
const sort = ref('releaseTime')
const order = ref('desc')
const goodsList = ref<any[]>([])
const pageNumber = ref(1)
const hasMore = ref(true)
const loading = ref(false)
const failed = ref(false)
const loadMoreText = {
contentdown: '上拉加载更多',
contentrefresh: '正在加载...',
contentnomore: '—— 到底啦 ——',
}
// 仅在正在加载、或者有下一页、或者商品总数达到 6 件以上触底时才展示底线,避免少量商品(如1~2件)时在空白区域突兀展示
const showLoadMore = computed(() => {
if (!goodsList.value.length) return false
if (loading.value) return true
if (hasMore.value) return true
return goodsList.value.length >= 6
})
// 模板2/3:左侧为当前一级的二级分类;模板4:左侧为一级分类
const sideList = computed(() =>
props.template === 4
? props.categoryList
: (currentL1.value && currentL1.value.children) || []
)
const sideCurrentId = computed(() =>
props.template === 4
? currentL1.value && currentL1.value.id
: currentL2.value && currentL2.value.id
)
// 模板2 的三级标签
const l3List = computed(() =>
(currentL2.value && currentL2.value.children) || []
)
// 模板4 顶部:当前一级名称(作为"全部") + 其二级分类
const l2Items = computed(() => {
if (!currentL1.value) return []
return [currentL1.value, ...((currentL1.value.children) || [])]
})
const topCurrentId = computed(() =>
(currentL2.value && currentL2.value.id) || (currentL1.value && currentL1.value.id)
)
const queryCategoryId = computed(() =>
(currentL3.value && currentL3.value.id) ||
(currentL2.value && currentL2.value.id) ||
(currentL1.value && currentL1.value.id)
)
watch(
() => props.categoryList,
(list) => {
if (list && list.length && !currentL1.value) {
currentL1.value = list[0]
currentL2.value = props.template === 4 ? null : (list[0].children && list[0].children[0]) || null
currentL3.value = (currentL2.value && currentL2.value.children && currentL2.value.children[0]) || null
loadGoods(true)
}
},
{ immediate: true }
)
function onL1Change(item: any) {
if (currentL1.value && item.id === currentL1.value.id) return
currentL1.value = item
currentL2.value = props.template === 4 ? null : (item.children && item.children[0]) || null
currentL3.value = (currentL2.value && currentL2.value.children && currentL2.value.children[0]) || null
resetSort()
loadGoods(true)
}
function onSideChange(item: any) {
if (props.template === 4) {
onL1Change(item)
return
}
if (currentL2.value && item.id === currentL2.value.id) return
currentL2.value = item
currentL3.value = (item.children && item.children[0]) || null
loadGoods(true)
}
function onL3Change(item: any) {
if (currentL3.value && item.id === currentL3.value.id) return
currentL3.value = item
loadGoods(true)
}
function onL2Change(item: any) {
// 选中一级名称项 = 全部(L2 置空)
if (currentL1.value && item.id === currentL1.value.id) {
currentL2.value = null
} else {
currentL2.value = item
}
loadGoods(true)
}
function onSortChange(payload: { sort: string; order: string }) {
sort.value = payload.sort
order.value = payload.order
loadGoods(true)
}
function resetSort() {
sort.value = 'releaseTime'
order.value = 'desc'
}
async function loadGoods(reset = false) {
if (loading.value || !queryCategoryId.value) return
if (reset) {
pageNumber.value = 1
goodsList.value = []
hasMore.value = true
}
loading.value = true
failed.value = false
try {
const res = await getGoodsList({
categoryId: queryCategoryId.value,
sort: sort.value,
order: order.value,
pageNumber: pageNumber.value,
pageSize: 10,
})
const records = (res.data && res.data.result && res.data.result.records) || []
goodsList.value.push(...records)
hasMore.value = records.length >= 10
} catch (e) {
failed.value = true
uni.showToast({ title: '加载失败,请重试', icon: 'none' })
} finally {
loading.value = false
}
}
function loadMore() {
if (!hasMore.value || loading.value) return
pageNumber.value += 1
loadGoods(false)
}
function onAddCart(item: any) {
uni.navigateTo({
url: '/pages/product/goods?id=' + item.id + '&goodsId=' + item.goodsId,
})
}
</script>
<style lang="scss" scoped>
.tpl-goods {
flex: 1;
min-height: 0;
height: 100%;
display: flex;
flex-direction: column;
background: #ffffff;
overflow: hidden;
}
.tpl-main {
flex: 1;
min-height: 0;
height: 0;
display: flex;
overflow: hidden;
}
.tpl-right {
flex: 1;
min-width: 0;
height: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
background: #ffffff;
}
.goods-scroll {
flex: 1;
min-height: 0;
height: 0;
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 60rpx 0 100rpx;
}
.retry {
margin-top: 24rpx;
padding: 12rpx 50rpx;
border: 1rpx solid $light-color;
color: $light-color;
border-radius: 36rpx;
font-size: 24rpx;
font-weight: 500;
}
</style>

View File

@@ -10,40 +10,30 @@
</view> </view>
</template> </template>
<script> <script setup lang="ts">
export default { import { ref, onMounted } from 'vue'
props: {
// 购物车 cart 消息 msg 订单 order 查询 search const props = withDefaults(defineProps<{
type: { type?: string
type: String, isBtn?: boolean
default: 'search' title?: string
}, }>(), {
isBtn:{ type: 'search',
type: Boolean, isBtn: false,
default: false title: '没有相关内容'
}, })
title:{
type: String, const src = ref('')
default: '没有相关内容'
} onMounted(() => {
}, src.value = `/static/default/default_${props.type}.png`
})
data() {
return { const toHome = () => {
src:'' uni.switchTab({
}; url: '/pages/home/home'
}, })
mounted() { }
this.src ='/static/default/default_'+ this.type + '.png';
},
methods: {
toHome() {
uni.switchTab({
url: '/pages/home/home'
});
}
}
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@@ -0,0 +1,459 @@
<template>
<view class="share-panel" :style="themeStyle">
<view class="tabs">
<view
class="tab-item"
:class="{ active: activeTab === 'text' }"
@click="activeTab = 'text'"
>
<text>推广图文</text>
<view v-if="activeTab === 'text'" class="tab-line"></view>
</view>
<view
class="tab-item"
:class="{ active: activeTab === 'poster' }"
@click="activeTab = 'poster'"
>
<text>生成海报</text>
<view v-if="activeTab === 'poster'" class="tab-line"></view>
</view>
</view>
<view v-if="loading" class="loading-wrap">
<text class="loading-text">加载中...</text>
</view>
<view v-else-if="activeTab === 'text'" class="content">
<view class="text-card">
<text v-if="shareContext.defaultShareText" class="share-text" :user-select="true">
{{ shareContext.defaultShareText }}
</text>
<view class="share-divider"></view>
<text class="share-text" :user-select="true">{{ shareBodyText }}</text>
<view class="share-divider"></view>
</view>
<view class="media-section">
<scroll-view scroll-x class="image-scroll" v-if="images.length">
<view class="image-list">
<image
v-for="(img, index) in images"
:key="index"
class="goods-image"
:src="img"
mode="aspectFill"
@click="previewImage(index)"
/>
</view>
</scroll-view>
<view class="save-btn-wrap">
<view class="save-btn" @click="saveShareContent">保存图文</view>
</view>
</view>
</view>
<view v-else class="content">
<poster-panel
:images="images"
:goods-name="shareContext.goodsName"
:goods-desc="posterGoodsDesc"
:price="shareContext.price"
:sku-id="skuId"
:goods-id="goodsId"
:distribution-id="distributionId"
:active="activeTab === 'poster'"
/>
</view>
</view>
</template>
<script setup lang="ts">
import { ref, computed, watch } from 'vue'
import { useStore } from '@/store'
import config from '@/config/config'
import { getThemeStyle } from '@/utils/theme'
import { getDistributionGoodsShareContext } from '@/api/distribution'
import { unitPrice, parseGoodsImageUrl } from '@/utils/filters.js'
import PosterPanel from './poster-panel.vue'
// #ifdef H5
import { h5Copy } from '@/js_sdk/h5-copy/h5-copy.js'
// #endif
const props = defineProps<{
skuId?: string
goodsId?: string
distributionId?: string
}>()
const store = useStore()
const themeStyle = computed(() => getThemeStyle(store.state.theme))
const activeTab = ref<'text' | 'poster'>('text')
const loading = ref(true)
const shareContext = ref<Record<string, any>>({})
const posterGoodsDesc = computed(() => {
const ctx = shareContext.value
return ctx.goodsSellingPoint || ctx.defaultShareText || ''
})
const images = computed(() => {
const raw: string[] = []
const list = shareContext.value.images
if (Array.isArray(list) && list.length) {
raw.push(...list)
} else if (shareContext.value.thumbnail) {
raw.push(shareContext.value.thumbnail)
}
const parsed = raw
.map((item) => parseGoodsImageUrl(item))
.filter((url) => !!url)
return [...new Set(parsed)]
})
const shareLink = computed(() => {
const link = shareContext.value.miniProgramLink || shareContext.value.sharePath || ''
if (!link) return ''
if (link.startsWith('http')) return link
const base = (config.shareLink || '').replace(/\/$/, '')
return base + link
})
const SHARE_DIVIDER = '- '.repeat(36).trim()
const shareBodyText = computed(() => {
const ctx = shareContext.value
const lines: string[] = []
if (ctx.goodsName) {
lines.push(`🔴 ${ctx.goodsName}`)
}
if (ctx.price !== null && ctx.price !== undefined) {
lines.push(`【到手价】💰 ${unitPrice(ctx.price, '¥')}元`)
}
if (shareLink.value) {
lines.push(`点击立即参与:${shareLink.value}`)
}
return lines.join('\n')
})
const shareText = computed(() => {
const ctx = shareContext.value
const lines: string[] = []
if (ctx.defaultShareText) {
lines.push(ctx.defaultShareText)
lines.push('')
}
lines.push(SHARE_DIVIDER)
if (shareBodyText.value) {
lines.push(shareBodyText.value)
}
lines.push(SHARE_DIVIDER)
return lines.join('\n')
})
watch(
() => [props.skuId, props.goodsId, props.distributionId],
() => {
loadShareContext()
},
{ immediate: true }
)
function loadShareContext() {
const { skuId, goodsId, distributionId } = props
if (!skuId || !goodsId || !distributionId) {
loading.value = false
shareContext.value = {}
return
}
loading.value = true
getDistributionGoodsShareContext({ skuId, goodsId, distributionId })
.then((res) => {
if (res.data?.success) {
shareContext.value = res.data.result || {}
} else {
uni.showToast({ title: res.data?.message || '加载失败', icon: 'none' })
}
})
.catch(() => {
uni.showToast({ title: '加载分享内容失败', icon: 'none' })
})
.finally(() => {
loading.value = false
})
}
function previewImage(index: number) {
if (!images.value.length) return
uni.previewImage({
current: images.value[index],
urls: images.value,
})
}
function isClipboardBlocked(errMsg = '') {
return (
errMsg.includes('privacy agreement') ||
errMsg.includes('no permission') ||
errMsg.includes('auth deny')
)
}
function saveShareContent() {
const text = shareText.value
if (!text.trim()) {
uni.showToast({ title: '暂无可保存内容', icon: 'none' })
return
}
// #ifdef H5
if (h5Copy(text) === false) {
uni.showToast({ title: '复制失败,请重试', icon: 'none' })
return
}
continueAfterCopy()
// #endif
// #ifndef H5
const runCopy = () => {
uni.setClipboardData({
data: text,
showToast: false,
success: () => continueAfterCopy(),
fail: (err: any) => {
console.error('setClipboardData fail', err)
const errMsg = err?.errMsg || ''
if (isClipboardBlocked(errMsg)) {
continueAfterCopy()
return
}
uni.showToast({ title: '复制失败,请重试', icon: 'none' })
},
})
}
// #ifdef MP-WEIXIN
const wxApi = (globalThis as any).wx
if (wxApi?.requirePrivacyAuthorize) {
wxApi.requirePrivacyAuthorize({
success: () => runCopy(),
fail: () => continueAfterCopy(),
})
return
}
// #endif
runCopy()
// #endif
}
function continueAfterCopy() {
const imageUrls = images.value
if (!imageUrls.length) {
uni.showToast({ title: '内容已复制', icon: 'none' })
return
}
uni.showLoading({ title: '保存中', mask: true })
saveImages(imageUrls)
.then(() => {
uni.hideLoading()
uni.showToast({ title: '内容已复制', icon: 'none' })
})
.catch((error) => {
uni.hideLoading()
uni.showToast({ title: '图片保存失败', icon: 'none' })
console.error('save images failed', error)
})
}
function saveToAlbum(filePath: string): Promise<void> {
return new Promise((resolve, reject) => {
uni.saveImageToPhotosAlbum({
filePath,
success: () => resolve(),
fail: (err: any) => {
const errMsg = err?.errMsg || ''
const needAuth =
errMsg.includes('auth deny') ||
errMsg.includes('authorize') ||
errMsg.includes('permission')
// #ifdef MP-WEIXIN
if (!needAuth) {
reject(new Error('save failed'))
return
}
uni.showModal({
title: '提示',
content: '需要您授权保存图片到相册',
confirmText: '去设置',
success: (modalRes) => {
if (!modalRes.confirm) {
reject(new Error('auth denied'))
return
}
uni.openSetting({
success: (settingRes) => {
if (settingRes.authSetting['scope.writePhotosAlbum']) {
saveToAlbum(filePath).then(resolve).catch(reject)
} else {
reject(new Error('auth denied'))
}
},
fail: () => reject(new Error('auth denied')),
})
},
fail: () => reject(new Error('auth denied')),
})
// #endif
// #ifndef MP-WEIXIN
reject(new Error('save failed'))
// #endif
},
})
})
}
function saveImages(urls: string[]) {
return urls.reduce<Promise<void>>((chain, url) => {
return chain.then(() => downloadAndSaveImage(url))
}, Promise.resolve())
}
function downloadAndSaveImage(url: string) {
if (!url || !/^https?:\/\//.test(url)) {
return Promise.reject(new Error('invalid url'))
}
return new Promise<void>((resolve, reject) => {
uni.downloadFile({
url,
success: (res) => {
if (res.statusCode !== 200 || !res.tempFilePath) {
reject(new Error('download failed'))
return
}
saveToAlbum(res.tempFilePath).then(resolve).catch(reject)
},
fail: () => reject(new Error('download failed')),
})
})
}
</script>
<style lang="scss" scoped>
.share-panel {
min-height: 100%;
background: #fff;
}
.tabs {
display: flex;
align-items: center;
justify-content: center;
padding: 24rpx 32rpx 0;
border-bottom: 1rpx solid #f0f0f0;
}
.tab-item {
position: relative;
flex: 1;
text-align: center;
padding-bottom: 20rpx;
font-size: 30rpx;
color: #999;
&.active {
color: #333;
font-weight: 600;
}
}
.tab-line {
position: absolute;
left: 50%;
bottom: 0;
transform: translateX(-50%);
width: 56rpx;
height: 6rpx;
border-radius: 6rpx;
background: #ff8f3f;
}
.loading-wrap {
padding: 120rpx 0;
text-align: center;
}
.loading-text {
color: #999;
font-size: 28rpx;
}
.content {
padding: 24rpx 24rpx 48rpx;
}
.text-card {
background: #f7f7f7;
border-radius: 16rpx;
padding: 28rpx;
}
.share-divider {
width: 100%;
height: 0;
margin: 20rpx 0;
border-top: 2rpx dashed #c8c8c8;
}
.share-text {
font-size: 28rpx;
line-height: 1.7;
color: #333;
white-space: pre-wrap;
word-break: break-all;
user-select: text;
-webkit-user-select: text;
}
.media-section {
margin-top: 24rpx;
}
.image-scroll {
width: 100%;
}
.image-list {
display: flex;
flex-direction: row;
white-space: nowrap;
}
.goods-image {
width: 200rpx;
height: 200rpx;
border-radius: 12rpx;
margin-right: 16rpx;
flex-shrink: 0;
background: #f5f5f5;
}
.save-btn-wrap {
display: flex;
justify-content: flex-end;
margin-top: 24rpx;
}
.save-btn {
min-width: 140rpx;
height: 60rpx;
line-height: 60rpx;
text-align: center;
padding: 0 20rpx;
border-radius: 30rpx;
background: linear-gradient(90deg, #ff9f3f, #ff6b35);
color: #fff;
font-size: 26rpx;
font-weight: 400;
box-shadow: 0 6rpx 16rpx rgba(255, 107, 53, 0.2);
}
</style>

View File

@@ -0,0 +1,556 @@
<template>
<view class="poster-panel">
<view v-if="posterList.length" class="poster-hint">点击海报预览后可保存到相册</view>
<view v-if="loading" class="loading-wrap">
<text class="loading-text">海报生成中...</text>
</view>
<view v-else-if="loadError" class="loading-wrap">
<text class="loading-text">{{ loadError }}</text>
<view class="retry-btn" @click="generatePosters">重新生成</view>
</view>
<view v-else-if="!images.length" class="loading-wrap">
<text class="loading-text">暂无商品图片</text>
</view>
<template v-else-if="posterList.length">
<view class="poster-content">
<swiper
class="poster-swiper"
:current="current"
circular
@change="onSwiperChange"
>
<swiper-item v-for="(item, index) in posterList" :key="index">
<view class="poster-card-wrap" @click="previewPoster(index)">
<image class="poster-image" :src="item" mode="widthFix" />
</view>
</swiper-item>
</swiper>
<view v-if="posterList.length > 1" class="poster-dots">
<view
v-for="(_, index) in posterList"
:key="index"
:class="['dot', current === index && 'active']"
/>
</view>
<view class="save-btn-wrap">
<view class="save-btn" @click="saveCurrentPoster">保存海报</view>
</view>
</view>
</template>
<view class="canvas-hide">
<!-- #ifdef MP-WEIXIN -->
<canvas id="distributionPosterCanvas" type="2d" style="width: 600px; height: 840px" />
<!-- #endif -->
<!-- #ifndef MP-WEIXIN -->
<canvas
canvas-id="distributionPosterCanvas"
id="distributionPosterCanvas"
style="width: 600px; height: 840px"
/>
<!-- #endif -->
</view>
</view>
</template>
<script setup lang="ts">
import { ref, watch, getCurrentInstance, nextTick } from 'vue'
import DrawPoster from '@/js_sdk/u-draw-poster'
import { getDistributionGoodsPosterContext } from '@/api/distribution'
import { unitPrice } from '@/utils/filters.js'
const CANVAS_SELECTOR = 'distributionPosterCanvas'
const POSTER_WIDTH = 600
const IMAGE_HEIGHT = POSTER_WIDTH
const BOTTOM_HEIGHT = 240
const POSTER_HEIGHT = IMAGE_HEIGHT + BOTTOM_HEIGHT
const QR_SIZE = 120
const QR_MARGIN_RIGHT = 28
const QR_MARGIN_BOTTOM = 28
const GENERATE_TIMEOUT = 45000
const props = defineProps<{
images?: string[]
goodsName?: string
goodsDesc?: string
price?: number | null
skuId?: string
goodsId?: string
distributionId?: string
active?: boolean
}>()
const instance = getCurrentInstance()
const posterList = ref<string[]>([])
const current = ref(0)
const loading = ref(false)
const loadError = ref('')
const hasGenerated = ref(false)
let dp: any = null
// #ifdef MP-WEIXIN
const st2 = (size: number) => size * 2
// #endif
// #ifndef MP-WEIXIN
const st2 = (size: number) => size
// #endif
watch(
() => [props.images?.length, props.skuId, props.goodsId, props.distributionId],
() => {
resetPosters()
if (props.active && props.images?.length) {
generatePosters()
}
}
)
watch(
() => props.active,
(active) => {
if (active && !hasGenerated.value && props.images?.length && !loading.value) {
generatePosters()
}
},
{ immediate: true }
)
function resetPosters() {
hasGenerated.value = false
posterList.value = []
loadError.value = ''
clearDrawPosterCache()
}
function clearDrawPosterCache() {
const pages = getCurrentPages()
const page = pages[pages.length - 1] as any
if (!page) return
delete page[`#${CANVAS_SELECTOR}__dp`]
delete page[`${CANVAS_SELECTOR}__dp`]
}
function onSwiperChange(e: any) {
current.value = e.detail?.current ?? 0
}
function previewPoster(index: number) {
if (!posterList.value.length) return
uni.previewImage({
current: posterList.value[index],
urls: posterList.value,
})
}
function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms))
}
function withTimeout<T>(promise: Promise<T>, ms: number, message: string) {
return Promise.race([
promise,
new Promise<T>((_, reject) => {
setTimeout(() => reject(new Error(message)), ms)
}),
])
}
function getComponentThis() {
return instance?.proxy || instance
}
async function waitCanvasReady() {
await nextTick()
await sleep(150)
}
async function resolveImagePath(url: string) {
if (!url) {
throw new Error('商品图片地址无效')
}
if (
url.startsWith('data:') ||
url.startsWith('wxfile://') ||
url.startsWith('http://tmp/') ||
url.startsWith('https://tmp/')
) {
return url
}
const res = await uni.downloadFile({ url })
if (res.statusCode === 200 && res.tempFilePath) {
return res.tempFilePath
}
throw new Error('商品图片下载失败,请检查图片域名配置')
}
function getImageInfo(src: string): Promise<{ width: number; height: number }> {
return new Promise((resolve, reject) => {
uni.getImageInfo({
src,
success: (res) => resolve({ width: res.width, height: res.height }),
fail: reject,
})
})
}
function calcContainBox(
imgW: number,
imgH: number,
boxX: number,
boxY: number,
boxW: number,
boxH: number
) {
const scale = Math.min(boxW / imgW, boxH / imgH)
const width = imgW * scale
const height = imgH * scale
return {
x: boxX + (boxW - width) / 2,
y: boxY + (boxH - height) / 2,
width,
height,
}
}
async function generatePosters() {
const { skuId, goodsId, distributionId, images } = props
if (!skuId || !goodsId || !distributionId || !images?.length) {
return
}
if (loading.value) {
return
}
// #ifndef MP-WEIXIN
{
loadError.value = '请在微信小程序中生成海报'
return
}
// #endif
loading.value = true
loadError.value = ''
posterList.value = []
clearDrawPosterCache()
try {
await withTimeout(runGeneratePosters(images, skuId, goodsId, distributionId), GENERATE_TIMEOUT, '海报生成超时,请重试')
hasGenerated.value = true
} catch (error: any) {
console.error('generate posters failed', error)
loadError.value = error?.message || '海报生成失败,请稍后重试'
clearDrawPosterCache()
} finally {
loading.value = false
}
}
async function runGeneratePosters(
images: string[],
skuId: string,
goodsId: string,
distributionId: string
) {
const posterRes = await getDistributionGoodsPosterContext({ skuId, goodsId, distributionId })
if (!posterRes.data?.success || !posterRes.data?.result?.qrCode) {
throw new Error(posterRes.data?.message || '葵花码生成失败')
}
const qrCode = `data:image/png;base64,${posterRes.data.result.qrCode}`
await waitCanvasReady()
dp = await DrawPoster.build({
selector: CANVAS_SELECTOR,
componentThis: getComponentThis(),
loading: false,
debugging: false,
})
if (!dp?.canvas || !dp?.ctx) {
throw new Error('画布初始化失败,请重试')
}
// #ifdef MP-WEIXIN
dp.canvas.width = st2(POSTER_WIDTH)
dp.canvas.height = st2(POSTER_HEIGHT)
// #endif
const results: string[] = []
for (const image of images) {
const localImage = await resolveImagePath(image)
results.push(await drawPoster(dp, localImage, qrCode))
}
posterList.value = results
}
async function drawPoster(dpInst: any, productImg: string, qrCode: string) {
const goodsName = props.goodsName || '商品推荐'
const goodsDesc = resolveGoodsDesc()
const priceText =
props.price !== null && props.price !== undefined ? unitPrice(props.price, '¥') : ''
await dpInst.draw((ctx: any) => {
ctx.clearRect(st2(0), st2(0), st2(POSTER_WIDTH), st2(POSTER_HEIGHT))
ctx.fillStyle = '#ffffff'
ctx.fillRoundRect(st2(0), st2(0), st2(POSTER_WIDTH), st2(POSTER_HEIGHT), st2(20))
ctx.clip()
})
await dpInst.draw(async (ctx: any) => {
ctx.fillStyle = '#f7f7f7'
ctx.fillRect(st2(0), st2(0), st2(POSTER_WIDTH), st2(IMAGE_HEIGHT))
const { width: imgW, height: imgH } = await getImageInfo(productImg)
const fit = calcContainBox(imgW, imgH, 0, 0, POSTER_WIDTH, IMAGE_HEIGHT)
await ctx.drawImage(
productImg,
st2(fit.x),
st2(fit.y),
st2(fit.width),
st2(fit.height)
)
})
await dpInst.draw(async (ctx: any) => {
ctx.fillStyle = '#ffffff'
ctx.fillRect(st2(0), st2(IMAGE_HEIGHT), st2(POSTER_WIDTH), st2(POSTER_HEIGHT - IMAGE_HEIGHT))
const qrX = POSTER_WIDTH - QR_SIZE - QR_MARGIN_RIGHT
const qrY = POSTER_HEIGHT - QR_SIZE - QR_MARGIN_BOTTOM
ctx.save()
ctx.beginPath()
ctx.arc(
st2(qrX + QR_SIZE / 2),
st2(qrY + QR_SIZE / 2),
st2(QR_SIZE / 2),
0,
Math.PI * 2
)
ctx.clip()
await ctx.drawImage(qrCode, st2(qrX), st2(qrY), st2(QR_SIZE), st2(QR_SIZE))
ctx.restore()
})
await dpInst.draw((ctx: any) => {
const textLeft = 24
const textMaxWidth = POSTER_WIDTH - QR_SIZE - QR_MARGIN_RIGHT - textLeft - 20
const bottomTop = IMAGE_HEIGHT
const bottomBottom = POSTER_HEIGHT - 16
const qrY = POSTER_HEIGHT - QR_SIZE - QR_MARGIN_BOTTOM
const nameLineHeight = 36
const descLineHeight = 28
const priceLineHeight = 36
const textGap = 16
const nameLineCount = Math.min(2, Math.max(1, Math.ceil(goodsName.length / 16)))
const descLineCount = goodsDesc ? Math.min(2, Math.max(1, Math.ceil(goodsDesc.length / 14))) : 0
let textBlockHeight = nameLineCount * nameLineHeight
if (goodsDesc) {
textBlockHeight += textGap + descLineCount * descLineHeight
}
if (priceText) {
textBlockHeight += textGap + priceLineHeight
}
const maxTextHeight = bottomBottom - bottomTop - 12
if (textBlockHeight > maxTextHeight) {
textBlockHeight = maxTextHeight
}
let textY = qrY + (QR_SIZE - textBlockHeight) / 2
textY = Math.max(bottomTop + 12, textY)
if (textY + textBlockHeight > bottomBottom) {
textY = bottomBottom - textBlockHeight
}
ctx.textAlign = 'left'
ctx.textBaseline = 'top'
ctx.fillStyle = '#333333'
ctx.font = `${st2(28)}px PingFang SC`
ctx.fillWarpText({
text: goodsName,
maxWidth: st2(textMaxWidth),
x: st2(textLeft),
y: st2(textY),
layer: 2,
lineHeight: st2(nameLineHeight),
})
textY += nameLineCount * nameLineHeight
if (goodsDesc) {
textY += textGap
ctx.fillStyle = '#999999'
ctx.font = `${st2(22)}px PingFang SC`
ctx.fillWarpText({
text: goodsDesc,
maxWidth: st2(textMaxWidth),
x: st2(textLeft),
y: st2(textY),
layer: 2,
lineHeight: st2(descLineHeight),
})
textY += descLineCount * descLineHeight
}
if (priceText) {
textY += textGap
const priceY = Math.min(textY, bottomBottom - priceLineHeight)
ctx.fillStyle = '#ff3c2a'
ctx.font = `bold ${st2(36)}px PingFang SC`
ctx.fillText(priceText, st2(textLeft), st2(priceY))
}
})
const path = await dpInst.createImagePath()
if (!path || path === '---stop createImagePath---') {
throw new Error('海报图片导出失败')
}
return path
}
function resolveGoodsDesc() {
const desc = (props.goodsDesc || '').trim()
const name = (props.goodsName || '').trim()
if (!desc || desc === name) return ''
return desc.length > 28 ? `${desc.slice(0, 28)}...` : desc
}
function saveCurrentPoster() {
const filePath = posterList.value[current.value]
if (!filePath) return
uni.saveImageToPhotosAlbum({
filePath,
success: () => {
uni.showToast({ title: '已保存到相册', icon: 'none' })
},
fail: (err: any) => {
const errMsg = err?.errMsg || ''
if (errMsg.includes('auth deny') || errMsg.includes('authorize')) {
uni.showModal({
title: '提示',
content: '需要您授权保存图片到相册',
confirmText: '去设置',
success: (modalRes) => {
if (modalRes.confirm) {
uni.openSetting({})
}
},
})
return
}
uni.showToast({ title: '保存失败', icon: 'none' })
},
})
}
</script>
<style lang="scss" scoped>
.poster-panel {
padding: 8rpx 0 48rpx;
}
.poster-hint {
text-align: center;
font-size: 26rpx;
color: #b3b3b3;
margin-bottom: 40rpx;
}
.poster-content {
margin-top: 8rpx;
}
.loading-wrap {
display: flex;
flex-direction: column;
align-items: center;
padding: 80rpx 48rpx;
box-sizing: border-box;
}
.loading-text {
display: block;
width: 100%;
color: #999;
font-size: 28rpx;
line-height: 1.6;
text-align: center;
}
.retry-btn {
margin-top: 32rpx;
}
.retry-btn,
.save-btn {
display: inline-flex;
align-items: center;
justify-content: center;
height: 64rpx;
padding: 0 40rpx;
border-radius: 32rpx;
background: linear-gradient(90deg, #ff9f3f, #ff6b35);
color: #fff;
font-size: 26rpx;
white-space: nowrap;
}
.poster-swiper {
height: 1000rpx;
}
.poster-card-wrap {
display: flex;
justify-content: center;
align-items: flex-start;
padding: 0 48rpx;
}
.poster-image {
width: 100%;
max-width: 620rpx;
border-radius: 20rpx;
box-shadow: 0 12rpx 40rpx rgba(0, 0, 0, 0.08);
}
.poster-dots {
display: flex;
justify-content: center;
align-items: center;
gap: 12rpx;
margin-top: 24rpx;
}
.dot {
width: 12rpx;
height: 12rpx;
border-radius: 50%;
background: #e0e0e0;
&.active {
width: 24rpx;
border-radius: 8rpx;
background: #ff8f3f;
}
}
.save-btn-wrap {
display: flex;
justify-content: center;
margin-top: 28rpx;
}
.canvas-hide {
position: fixed;
left: -9999px;
top: 0;
width: 600px;
height: 840px;
opacity: 0;
pointer-events: none;
}
</style>

View File

@@ -13,71 +13,62 @@
</view> </view>
</template> </template>
<script> <script setup lang="ts">
import config from "@/config/config"; import { ref, onMounted } from 'vue'
export default { import config from "@/config/config"
data() { import logoImg from "@/icon.png"
return {
config, // 设置工具类 const weChat = ref(false)
weChat: false, // 是否微信浏览器,该项为true时不显示 当前整个页面 const logo = logoImg
logo: require("@/icon.png"), //显示的圆形logo
}; onMounted(() => {
}, // #ifdef H5
mounted() { // 判断是否是微信浏览器
// #ifdef H5 var ua = navigator.userAgent.toLowerCase();
// 判断是否是微信浏览器 var isWeixin = ua.indexOf("micromessenger") != -1;
var ua = navigator.userAgent.toLowerCase(); weChat.value = isWeixin ? true : false
var isWeixin = ua.indexOf("micromessenger") != -1; // #endif
if (isWeixin) { })
this.weChat = true;
/**
* 跳转到下载app页面
*/
const downloadApp = () => {
setTimeout(function () {
window.location.href = config.downloadLink;
}, 2000);
}
/**
* 打开app 仅在h5生效 使用ifream唤醒app
*/
const openApp = () => {
let src: string = ''
if (location.href) {
src = location.href.split("/pages")[1];
}
let t = `${config.schemeLink}pages${src}`
try {
var e = navigator.userAgent.toLowerCase(),
n = e.match(/cpu iphone os (.*?) like mac os/);
if (
((n = null !== n ? n[1].replace(/_/g, ".") : 0), parseInt(n) >= 9)
) {
window.location.href = t
downloadApp()
} else { } else {
this.weChat = false; var r = document.createElement("iframe");
(r.src = t), (r.style.display = "none"), document.body.appendChild(r)
downloadApp()
} }
// #endif } catch (e) {
}, window.location.href = t
methods: { downloadApp()
}
/** }
* 跳转到下载app页面
*/
downloadApp() {
setTimeout(function () {
window.location.href = config.downloadLink;
}, 2000);
},
/**
* 打开app 仅在h5生效 使用ifream唤醒app
*/
openApp() {
let src;
if (location.href) {
src = location.href.split("/pages")[1];
}
let t = `${config.schemeLink}pages${src}`;
try {
var e = navigator.userAgent.toLowerCase(),
n = e.match(/cpu iphone os (.*?) like mac os/);
if (
((n = null !== n ? n[1].replace(/_/g, ".") : 0), parseInt(n) >= 9)
) {
window.location.href = t;
this.downloadApp();
} else {
var r = document.createElement("iframe");
(r.src = t), (r.style.display = "none"), document.body.appendChild(r);
this.downloadApp();
}
} catch (e) {
window.location.href = t;
this.downloadApp();
}
},
},
};
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@@ -1,6 +1,6 @@
<template> <template>
<div class="wrapper"> <div class="wrapper">
<u-popup class="popup" v-model="buyMask" :height="setup.height" closeable :mode="setup.mode" :border-radius="setup.radius" @close="closeMask()"> <u-popup class="popup" :show="buyMask" :height="setup.height" closeable :mode="setup.mode" :border-radius="setup.radius" @close="closeMask()">
<!-- 商品 --> <!-- 商品 -->
<view class="goods-box bottom"> <view class="goods-box bottom">
<view class="goods-header"> <view class="goods-header">
@@ -12,8 +12,8 @@
<view class="goods-price" v-if="goodsDetail.promotionPrice && ((isGroup && buyType === 'PINTUAN') || !isGroup)"> <view class="goods-price" v-if="goodsDetail.promotionPrice && ((isGroup && buyType === 'PINTUAN') || !isGroup)">
<span v-if="goodsDetail.promotionPrice && !pointDetail"> <span v-if="goodsDetail.promotionPrice && !pointDetail">
¥ ¥
<span class="goods-price-promotionShow goods-price-bigshow">{{ $options.filters.goodsFormatPrice(goodsDetail.promotionPrice)[0] }}</span> <span class="goods-price-promotionShow goods-price-bigshow">{{ goodsFormatPrice(goodsDetail.promotionPrice)[0] }}</span>
.{{ $options.filters.goodsFormatPrice(goodsDetail.promotionPrice)[1] }} .{{ goodsFormatPrice(goodsDetail.promotionPrice)[1] }}
</span> </span>
<span v-if="pointDetail.points"> <span v-if="pointDetail.points">
<span class="goods-price-promotionShow goods-price-bigshow">{{ pointDetail.points }}</span> <span class="goods-price-promotionShow goods-price-bigshow">{{ pointDetail.points }}</span>
@@ -21,28 +21,17 @@
</span> </span>
<div class="promotion-box"> <div class="promotion-box">
¥ ¥
<span class="goods-price-bigshow">{{ $options.filters.goodsFormatPrice(goodsDetail.price)[0] }}</span> <span class="goods-price-bigshow">{{ goodsFormatPrice(goodsDetail.price)[0] }}</span>
.{{ $options.filters.goodsFormatPrice(goodsDetail.price)[1] }} .{{ goodsFormatPrice(goodsDetail.price)[1] }}
</div> </div>
</view> </view>
<!-- 正常商品的价格 --> <!-- 正常商品的价格 -->
<view v-else> <view v-else>
<!-- 批发价格 --> <div class="goods-price">
<div class="price-row flex" v-if="goodsDetail.salesModel === 'WHOLESALE'">
<div class="goods-price" v-for="(item, index) in wholesaleList" :key="index">
<span>
¥
<span class="goods-price-bigshow">{{ $options.filters.goodsFormatPrice(item.price)[0] }}</span>
.{{ $options.filters.goodsFormatPrice(item.price)[1] }}
</span>
<span class="wholesale-item">{{ item.num }}{{ goodsDetail.goodsUnit }}</span>
</div>
</div>
<div class="goods-price" v-else>
<span> <span>
¥ ¥
<span class="goods-price-bigshow">{{ $options.filters.goodsFormatPrice(goodsDetail.price)[0] }}</span> <span class="goods-price-bigshow">{{ goodsFormatPrice(goodsDetail.price)[0] }}</span>
.{{ $options.filters.goodsFormatPrice(goodsDetail.price)[1] }} .{{ goodsFormatPrice(goodsDetail.price)[1] }}
</span> </span>
</div> </div>
</view> </view>
@@ -53,10 +42,14 @@
<span>,{{ num }}个</span> <span>,{{ num }}个</span>
</span> </span>
</view> </view>
<view class="goods-check-skus"> <view class="goods-check-skus" v-if="isAppointmentGoods(goodsDetail?.goodsType)">
可预约
<span class="goods-check-skus-name">按时段选择</span>
</view>
<view class="goods-check-skus" v-else>
库存 库存
<span class="goods-check-skus-name"> <span class="goods-check-skus-name">
<span>{{ goodsDetail.quantity }}</span> <span>{{ availableStock }}</span>
</span> </span>
</view> </view>
</view> </view>
@@ -81,345 +74,365 @@
</view> </view>
<!-- 拼团购买,仅筛选出当前拼团类型商品 --> <!-- 拼团购买,仅筛选出当前拼团类型商品 -->
<view <template v-for="(spec_val, spec_index) in spec.values" :key="spec_index">
v-if="parentOrder && spec_val.skuId == goodsDetail.id" <view
:class="{ active: spec_val.value == currentSelected[specIndex] }" v-if="parentOrder && spec_val.skuId == goodsDetail.id"
class="skus-view-item" :class="{ active: spec_val.value == currentSelected[specIndex] }"
v-for="(spec_val, spec_index) in spec.values" class="skus-view-item"
:key="spec_index" @click="handleClickSpec(spec, specIndex, spec_val)"
@click="handleClickSpec(spec, specIndex, spec_val)" >
> {{ spec_val.value }}
{{ spec_val.value }} </view>
</view> </template>
</view> </view>
</view> </view>
<div class="soldout" v-if="goodsDetail.quantity === 0"> <div class="soldout" v-if="availableStock === 0">
<u-alert-tips type="warning" title="商品已售罄" description="当前商品库存为0"></u-alert-tips> <u-alert type="warning" title="商品已售罄" :description="'当前商品库存为0'"></u-alert>
</div> </div>
<!-- 数量 --> <!-- 数量 -->
<view v-if="goodsDetail.quantity !== 0" class="goods-skus-number flex flex-a-c flex-j-sb"> <view v-if="availableStock !== 0" class="goods-skus-number flex flex-a-c flex-j-sb">
<view class="view-class-title">数量</view> <view class="view-class-title">数量</view>
<uni-number-box class="uNumber" :min="1" :max="999" :disabled="goodsDetail.quantity === 0" v-model="num"></uni-number-box> <uni-number-box class="uNumber" :min="1" :max="maxBuyNum" :disabled="availableStock === 0" v-model="num"></uni-number-box>
</view> </view>
</scroll-view> </scroll-view>
<!-- 按钮 --> <!-- 按钮 -->
<view class="btns" v-if="goodsDetail.quantity !== 0"> <view class="btns" v-if="availableStock !== 0">
<view class="box-btn card" v-if="buyType != 'PINTUAN' && goodsDetail.goodsType != 'VIRTUAL_GOODS'" @click="addToCartOrBuy('cart')">加入购物车</view> <view class="box-btn card" v-if="showAddToCart" @click="addToCartOrBuy('cart')">加入购物车</view>
<view class="box-btn buy" @click="addToCartOrBuy('buy')">立即购买</view> <view class="box-btn buy" @click="addToCartOrBuy('buy')">
{{ isAppointmentGoods(goodsDetail?.goodsType) ? '立即预约' : '立即购买' }}
</view>
</view> </view>
</view> </view>
</u-popup> </u-popup>
</div> </div>
</template> </template>
<script>
import * as API_trade from '@/api/trade.js';
import setup from './popup';
import uniNumberBox from '@/components/uni-number-box'
export default {
components: {
uniNumberBox
},
data() {
return {
setup,
num: this.wholesaleList && this.wholesaleList.length > 0 ? this.wholesaleList[0].num : 1,
selectName: '', //选中商品的昵称 <script setup lang="ts">
selectSkuList: '', //选中商铺sku, import { ref, computed, watch, onMounted } from 'vue'
selectedSpecImg: '', //选中的图片路径 import * as API_trade from '@/api/trade.js'
buyType: '', //用于存储促销,拼团等活动类型 import setup from './popup.js'
parentOrder: '', //父级拼团活动的数据 - 如果是团员则有数据 import uniNumberBox from '@/components/uni-number-box.vue'
formatList: [], import { goodsFormatPrice } from '@/utils/filters.js'
currentSelected: [], import {
skuList: '', isECoupon,
isClose: false //是否可以点击遮罩关闭 isVirtualGoods,
}; isAppointmentGoods,
}, getECouponStock,
props: { getECouponMaxBuyNum,
wholesaleList: { getAppointmentStock,
type: null, getAppointmentMaxBuyNum,
default: false } from '@/utils/goodsType.js'
},
buyMask: {
type: Boolean,
default: false
},
isGroup: {
type: Boolean,
default: false
},
goodsDetail: {
default: '',
type: null
},
selectedSku: {
default: '',
type: null
},
goodsSpec: {
default: '',
type: null
},
addr: {
default: '',
type: null
},
pointDetail: {
default: '',
type: null
}
},
computed: {
wholesalePrice(key) {
return this.wholesaleList.length
? this.wholesaleList.map(item => {
return item.price;
})
: [];
},
wholesaleNum(key) {
return this.wholesaleList.length
? this.wholesaleList.map(item => {
return item.num;
})
: [];
}
},
watch: {
num(val) {
val == 0 ? this.num = 1 : ''
if (val) {
//超过库存后修改回库存
if (val > this.goodsDetail.quantity) {
this.$nextTick(function() {
this.num = this.goodsDetail.quantity;
});
}
}
},
buyType: {
handler(val) {
if (val) {
this.buyType = val;
}
},
immediate: true
},
selectSkuList: {
handler(val, oldval) {
this.$emit('changed', val);
},
deep: true
},
'goodsDetail.quantity': {
handler(val) {
if (val == 0) {
uni.showToast({
title: '商品已售罄',
duration: 2000,
icon: 'none'
})
this.num = 1;
}
}
}
},
methods: { const props = withDefaults(defineProps<{
numCheck(val) { buyMask?: boolean
if (this.wholesaleList && this.wholesaleList.length > 0) { isGroup?: boolean
if (this.num <= this.wholesaleList[0].num) { goodsDetail?: any
uni.showToast({ selectedSku?: any | null
title: '批发商品购买数量不能小于起批数量!', goodsSpec?: any | null
duration: 2000, addr?: any | null
icon: 'none' pointDetail?: any | null
}); }>(), {
this.num = this.wholesaleList[0].num; buyMask: false,
} isGroup: false,
} goodsDetail: () => ({}),
}, selectedSku: '',
closeMask() { goodsSpec: '',
this.$emit('closeBuy', false); addr: '',
}, pointDetail: ''
})
/**点击规格 */
handleClickSpec(val, index, specValue) {
this.currentSelected[index] = specValue.value;
let selectedSkuId = this.goodsSpec.find(i => {
let matched = true;
let specValues = i.specValues.filter(j => j.specName !== 'images');
for (let n = 0; n < specValues.length; n++) {
if (specValues[n].specValue !== this.currentSelected[n]) {
matched = false;
return;
}
}
if (matched) {
return i;
}
});
if (selectedSkuId?.skuId) {
this.$set(this.currentSelected, index, specValue.value);
this.selectSkuList = {
spec: {
specName: val.name,
specValue: specValue.value
},
data: this.goodsDetail
};
this.selectName = specValue.value;
this.$emit('handleClickSku', { const emit = defineEmits(['closeBuy', 'changed', 'handleClickSku', 'queryCart'])
skuId: selectedSkuId.skuId,
goodsId: this.goodsDetail.goodsId
});
} else {
uni.showToast({
title: '暂无该商品!',
duration: 2000,
icon: 'none'
});
}
},
/** const num = ref(1)
* 直接购买
*/
buy(data) {
API_trade.addToCart(data).then(res => {
if (res.data.success) {
uni.navigateTo({
url: `/pages/order/fillorder?way=${data.cartType}&addr=${''}&parentOrder=${encodeURIComponent(JSON.stringify(this.parentOrder))}`
});
}
});
},
/** const selectName = ref('')
* 添加到购物车或购买 const selectSkuList = ref<any>('')
*/ const selectedSpecImg = ref('')
addToCartOrBuy(val) { const buyType = ref('')
if (!this.selectSkuList) { const parentOrder = ref<any>('')
uni.showToast({ const formatList = ref<any[]>([])
title: '请选择规格商品', const currentSelected = ref<string[]>([])
icon: 'none' const skuList = ref('')
});
return;
}
let data = {
skuId: this.goodsDetail.id,
num: this.num
};
if (val == 'cart') { // E_COUPON 读 SKU quantity;预约商品 quantity 固定 0,库存走时段
API_trade.addToCart(data).then(res => { const availableStock = computed(() => {
if (res.data.code == 200) { if (isECoupon(props.goodsDetail?.goodsType)) {
uni.showToast({ return getECouponStock(props.goodsDetail)
title: '商品已添加到购物车',
icon: 'none'
});
this.$emit('queryCart');
this.closeMask();
}
});
} else {
// 判断是否拼团商品
if (this.buyType) {
data.cartType = 'PINTUAN';
} else if (this.goodsDetail.goodsType == 'VIRTUAL_GOODS') {
data.cartType = 'VIRTUAL';
} else {
data.cartType = 'BUY_NOW';
}
API_trade.addToCart(data).then(res => {
if (res.data.code == 200) {
uni.navigateTo({
url: `/pages/order/fillorder?way=${data.cartType}&addr=${this.addr.id || ''}&parentOrder=${encodeURIComponent(JSON.stringify(this.parentOrder))}`
});
}
});
}
},
formatSku(list) {
// 格式化数据
let arr = [{}];
if (!Array.isArray(list)) {
return false;
}
list.forEach((item, index) => {
item.specValues.forEach((spec, specIndex) => {
let name = spec.specName;
let values = {
value: spec.specValue,
quantity: item.quantity,
skuId: item.skuId
};
if (name === 'images') {
return;
}
arr.forEach((arrItem, arrIndex) => {
if (
arrItem.name == name &&
arrItem.values &&
!arrItem.values.find(i => {
return i.value === values.value;
})
) {
arrItem.values.push(values);
}
let keys = arr.map(key => {
return key.name;
});
if (!keys.includes(name)) {
arr.push({
name: name,
values: [values]
});
}
});
});
});
arr.shift();
this.formatList = arr;
list.forEach(item => {
// 默认选中
if (item.skuId === this.goodsDetail.id) {
item.specValues
.filter(i => i.specName !== 'images')
.forEach((value, _index) => {
this.currentSelected[_index] = value.specValue;
this.selectName = value.specValue;
this.selectSkuList = {
spec: value,
data: this.goodsDetail
};
});
}
});
this.skuList = list;
// console.log(" this.skuList", this.skuList)
}
},
mounted() {
this.formatSku(this.goodsSpec);
console.log("goodsDetail",this.goodsDetail)
} }
}; if (isAppointmentGoods(props.goodsDetail?.goodsType)) {
return getAppointmentStock(props.goodsDetail)
}
return Number(props.goodsDetail?.quantity) || 0
})
const maxBuyNum = computed(() => {
if (isECoupon(props.goodsDetail?.goodsType)) {
return getECouponMaxBuyNum(props.goodsDetail)
}
if (isAppointmentGoods(props.goodsDetail?.goodsType)) {
return getAppointmentMaxBuyNum(props.goodsDetail)
}
return 999
})
// 电子卡券/预约商品禁止加购
const showAddToCart = computed(() => {
return (
buyType.value != 'PINTUAN' &&
!isVirtualGoods(props.goodsDetail?.goodsType) &&
!isECoupon(props.goodsDetail?.goodsType) &&
!isAppointmentGoods(props.goodsDetail?.goodsType)
)
})
watch(num, (val) => {
val == 0 ? num.value = 1 : ''
if (val && val > maxBuyNum.value) {
num.value = maxBuyNum.value
}
})
watch(() => props.isGroup, (val) => {
if (val) {
buyType.value = 'PINTUAN'
}
}, { immediate: true })
watch(selectSkuList, (_val) => {
emit('changed', selectSkuList.value)
}, { deep: true })
watch(
() => availableStock.value,
(val) => {
if (val == 0) {
uni.showToast({
title: '商品已售罄',
duration: 2000,
icon: 'none',
})
num.value = 1
} else if (num.value > maxBuyNum.value) {
num.value = maxBuyNum.value
}
}
)
const closeMask = () => {
emit('closeBuy', false)
}
/**点击规格 */
const handleClickSpec = (val: any, index: number, specValue: any) => {
currentSelected.value[index] = specValue.value
let selectedSkuId = props.goodsSpec.find((i: any) => {
let matched = true
let specValues = i.specValues.filter((j: any) => j.specName !== 'images')
for (let n = 0; n < specValues.length; n++) {
if (specValues[n].specValue !== currentSelected.value[n]) {
matched = false
return
}
}
if (matched) {
return i
}
})
if (selectedSkuId?.skuId) {
currentSelected.value[index] = specValue.value
selectSkuList.value = {
spec: {
specName: val.name,
specValue: specValue.value
},
data: props.goodsDetail
}
selectName.value = specValue.value
emit('handleClickSku', {
skuId: selectedSkuId.skuId,
goodsId: props.goodsDetail.goodsId
})
} else {
uni.showToast({
title: '暂无该商品!',
duration: 2000,
icon: 'none'
})
}
}
/**
* 活动页/父组件直接调用购买(POINTS / KANJIA 等显式 cartType)
*/
const buy = (data: any) => {
uni.hideLoading()
API_trade.addToCart(data).then((res) => {
if (res.data.success) {
const way = data.cartType || 'BUY_NOW'
uni.navigateTo({
url: `/pages/order/fillorder?way=${way}&addr=${''}&parentOrder=${encodeURIComponent(JSON.stringify(parentOrder.value || ''))}`,
})
} else {
uni.showToast({
title: res.data.message || '购买失败',
icon: 'none',
})
}
}).finally(() => {
uni.hideLoading()
})
}
/** 解析 cartType:拼团 PINTUAN;核销 VIRTUAL;其余含 E_COUPON 为 BUY_NOW */
function resolveCartType() {
if (buyType.value === 'PINTUAN') {
return 'PINTUAN'
}
if (isVirtualGoods(props.goodsDetail?.goodsType)) {
return 'VIRTUAL'
}
return 'BUY_NOW'
}
/**
* 添加到购物车或购买
*/
const addToCartOrBuy = (val: string) => {
if (!selectSkuList.value) {
uni.showToast({
title: '请选择规格商品',
icon: 'none',
})
return
}
const data: Record<string, any> = {
skuId: props.goodsDetail.id,
num: num.value,
}
if (val == 'cart') {
API_trade.addToCart(data).then((res) => {
if (res.data.success) {
uni.showToast({
title: '商品已添加到购物车',
icon: 'none',
})
emit('queryCart')
closeMask()
} else {
uni.showToast({
title: res.data.message || '加购失败',
icon: 'none',
})
}
})
} else {
if (isAppointmentGoods(props.goodsDetail?.goodsType)) {
const goodsId = props.goodsDetail.goodsId || ''
uni.navigateTo({
url: `/pages/order/appointment/appointmentCheckout?skuId=${props.goodsDetail.id}&goodsId=${goodsId}&num=${num.value}`,
})
closeMask()
return
}
data.cartType = resolveCartType()
API_trade.addToCart(data).then((res) => {
if (res.data.success) {
uni.navigateTo({
url: `/pages/order/fillorder?way=${data.cartType}&addr=${props.addr?.id || ''}&parentOrder=${encodeURIComponent(JSON.stringify(parentOrder.value || ''))}`,
})
} else {
uni.showToast({
title: res.data.message || '购买失败',
icon: 'none',
})
}
})
}
}
const formatSku = (list: any[]) => {
// 格式化数据
let arr: any[] = [{}]
if (!Array.isArray(list)) {
return false
}
list.forEach((_item, _index) => {
let item = list[_index]
item.specValues.forEach((spec: any, specIndex: number) => {
let name = spec.specName
let values = {
value: spec.specValue,
quantity: item.quantity,
skuId: item.skuId
}
if (name === 'images') {
return
}
arr.forEach((arrItem, arrIndex) => {
if (
arrItem.name == name &&
arrItem.values &&
!arrItem.values.find((i: any) => {
return i.value === values.value
})
) {
arrItem.values.push(values)
}
let keys = arr.map(key => {
return key.name
})
if (!keys.includes(name)) {
arr.push({
name: name,
values: [values]
})
}
})
})
})
arr.shift()
formatList.value = arr
list.forEach(item => {
// 默认选中
if (item.skuId === props.goodsDetail.id) {
item.specValues
.filter(i => i.specName !== 'images')
.forEach((value, _index) => {
currentSelected.value[_index] = value.specValue
selectName.value = value.specValue
selectSkuList.value = {
spec: value,
data: props.goodsDetail
}
})
}
})
skuList.value = list
}
onMounted(() => {
formatSku(props.goodsSpec)
})
defineExpose({
buy,
buyType,
parentOrder,
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import './popup.scss'; @import './popup.scss';
@@ -428,18 +441,18 @@ export default {
} }
.buy { .buy {
background-image: linear-gradient(135deg, #ffba0d, #ffc30d 69%, #ffcf0d); background-image: linear-gradient(135deg, $main-color, $light-color);
box-shadow: 0 2px 6px 0 rgba(255, 65, 66, 0.2); box-shadow: 0 2px 6px 0 rgba(255, 65, 66, 0.2);
} }
.card { .card {
background-image: linear-gradient(135deg, #f2140c, #f2270c 70%, #f24d0c); background-image: linear-gradient(91deg, $light-color 1%, $aider-light-color 99%);
box-shadow: 0 2px 6px 0 rgba(255, 65, 66, 0.2); box-shadow: 0 2px 6px 0 rgba(255, 65, 66, 0.2);
} }
/deep/.u-icon-plus, ::v-deep .u-icon-plus,
.u-icon-minus, ::v-deep .u-icon-minus,
.u-icon-disabled { ::v-deep .u-icon-disabled {
height: 30rpx !important; height: 30rpx !important;
background: #fff !important; background: #fff !important;
} }
@@ -457,7 +470,7 @@ export default {
} }
} }
/deep/ .uni-scroll-view { ::v-deep .uni-scroll-view {
overflow: hidden !important; overflow: hidden !important;
} }
@@ -504,13 +517,6 @@ export default {
} }
} }
.wholesale-item {
color: #999 !important;
font-size: 24rpx;
margin: 0 20rpx;
display: flex;
justify-content: center;
}
.goods-header { .goods-header {
height: 200rpx; height: 200rpx;
@@ -531,11 +537,6 @@ export default {
color: $price-color; color: $price-color;
line-height: 80rpx; line-height: 80rpx;
margin-right: 20rpx; margin-right: 20rpx;
> * {
color: $price-color;
line-height: 80rpx;
}
} }
.promotion-box { .promotion-box {
@@ -546,7 +547,7 @@ export default {
color: #999; color: #999;
margin-left: 10rpx; margin-left: 10rpx;
/deep/ span { .goods-price-bigshow {
font-size: 30rpx; font-size: 30rpx;
} }
} }
@@ -565,9 +566,6 @@ export default {
> .goods-check-skus-name { > .goods-check-skus-name {
margin-left: 4rpx; margin-left: 4rpx;
}
> span {
color: #333; color: #333;
} }
} }

View File

@@ -1 +0,0 @@
### 说明 https://ext.dcloud.net.cn/plugin?id=3237

View File

@@ -1,211 +0,0 @@
<template>
<div class="index">
<u-modal v-model="show" :show-title="false" :show-confirm-button="false" mask-close-able>
<view class="slot-content">
<image @click="downLoad()" class="img" :src="imgUrl" />
<div class="canvas-hide">
<!-- #ifdef MP-WEIXIN -->
<canvas id="canvas" type="2d" style="width: 600px; height: 960px" />
<!-- #endif -->
<!-- #ifndef MP-WEIXIN -->
<canvas canvas-id="canvas" id="canvas" style="width: 600px; height: 960px" />
<!-- #endif -->
</div>
</view>
</u-modal>
</div>
</template>
<script>
// 引入绘制插件
import DrawPoster from "@/js_sdk/u-draw-poster";
export default {
data: () => ({
imgUrl: "", //绘制出来的图片路径
show: false, //是否展示模态框
dp: {}, //绘制的dp对象,用于存储绘制等一些方法。
logo: require("@/pages/passport/static/logo-title.png"), //本地logo地址
}),
props: {
/**
* 父级传参的数据
*/
res: {
type: null,
default: "",
},
},
onUnload() {},
methods: {
/**
* 解决微信小程序中图片模糊问题
*/
// #ifdef MP-WEIXIN
st2: (size) => size * 2,
// #endif
// #ifndef MP-WEIXIN
st2: (size) => size,
// #endif
/**
* 保存图片
*/
downLoad() {
uni.saveImageToPhotosAlbum({
filePath: this.imgUrl,
success: function () {
uni.showToast({
title: "保存成功!",
icon: "none",
});
},
fail: function () {
uni.showToast({
title: "保存失败,请稍后重试!",
icon: "none",
});
},
});
},
/**
* 创建canvas
*/
async init() {
this.show = true;
this.dp = await DrawPoster.build({
selector: "canvas",
componentThis: this,
loading: true,
debugging: true,
});
let dp = this.dp;
// #ifdef MP-WEIXIN
// 用于微信小程序中画布错乱问题
dp.canvas.width = this.st2(600);
dp.canvas.height = this.st2(960);
// #endif
this.draw(dp);
},
async draw(dp) {
const { width, height, background, title } = this.res.container;
const { code, img, price } = this.res.bottom;
// /** 绘制背景 */
await dp.draw((ctx) => {
ctx.fillStyle = background;
ctx.fillRoundRect(
this.st2(0),
this.st2(0),
this.st2(width),
this.st2(height),
this.st2(12)
);
ctx.clip();
});
/** 绘制图片 */
dp.draw(async (ctx) => {
await Promise.all([
// 绘制Logo
ctx.drawImage(
this.logo,
this.st2(175),
this.st2(0),
this.st2(256),
this.st2(144)
),
// 中间图片
ctx.drawImage(
img,
this.st2(100),
this.st2(150),
this.st2(400),
this.st2(400)
),
// 二维码
ctx.drawImage(
code,
this.st2(39),
this.st2(750),
this.st2(150),
this.st2(150)
),
]);
});
/** 绘制中间文字*/
await dp.draw((ctx) => {
ctx.fillStyle = "#333";
ctx.font = `bold ${this.st2(24)}px PingFang SC`;
ctx.textAlign = "center";
ctx.fillWarpText({
text: title,
maxWidth: this.st2(500),
x: this.st2(300),
y: this.st2(600),
layer: 1,
});
ctx.fillStyle = "#ff3c2a";
ctx.font = `${this.st2(38)}px PingFang SC`;
ctx.textAlign = "center";
ctx.fillText(price, this.st2(300), this.st2(680));
});
// /** 绘制底部文字 */
await dp.draw((ctx) => {
ctx.fillStyle = "#666";
ctx.font = `${this.st2(24)}px PingFang SC`;
ctx.fillText("长按图片,识别二维码", this.st2(200), this.st2(866));
ctx.fillStyle = "#666";
ctx.font = `${this.st2(24)}px PingFang SC`;
ctx.fillText("查看商品详情", this.st2(200), this.st2(900));
});
this.imgUrl = await dp.createImagePath();
// console.log(posterImgUrl)
},
},
async mounted() {
this.init();
},
};
</script>
<style lang="scss" scoped>
page,
.index {
height: 100%;
}
.canvas-hide {
/* 1 */
position: fixed;
right: 100vw;
bottom: 100vh;
/* 2 */
z-index: -9999;
/* 3 */
opacity: 0;
}
.index {
position: relative;
text-align: center;
background: rgba($color: grey, $alpha: 0.2);
}
image {
display: block;
}
.img {
width: 600rpx;
height: 960rpx;
}
</style>

View File

@@ -79,182 +79,182 @@
</view> </view>
</template> </template>
<script> <script setup lang="ts">
import { ref, getCurrentInstance } from 'vue'
import { getRegionsById } from "@/api/common.js"
const instance = getCurrentInstance()
let windowWidth = 0 let windowWidth = 0
import { getRegionsById } from "@/api/common.js";
export default { const props = withDefaults(defineProps<{
name: "UniCityNvue", headTitle?: string
props: { pickerSize?: string | string[]
headTitle: { provinceData?: any[]
//标题 }>(), {
type: String, headTitle: "区域选择",
default: "区域选择", pickerSize: "1",
}, provinceData: () => [],
pickerSize: { })
// 使用多少个tab
type: [String, String], const emit = defineEmits(['funcValue'])
default: "1",
}, const clearRightIcon = ref(true)
provinceData: { const scrollLeft = ref(500)
// 默认的省市区id,如果不使用id的情况下则为[]; const scrollTop = ref(0)
type: Array, const enableScroll = ref(true)
default: function () { const tabCurrentIndex = ref(0)
return []; const tabbars = ref<any[]>(props.provinceData)
const pickersize = ref(props.pickerSize)
const showPicker = ref(false)
/**
* 显示选择器
*/
const show = () => {
showPicker.value = true
if (tabbars.value[0].children.length == 0) {
getRegionsById(0).then((res: any) => {
tabbars.value[0].children = res.data.result
})
}
windowWidth = uni.getSystemInfoSync().windowWidth
}
/**
* 关闭选择器
*/
const hide = () => {
showPicker.value = false
}
/**
* tab切换
*/
const changeTab = (e: number) => {
let index = e
setScroll(index)
//延迟300ms,等待swiper动画结束再修改tabbar
tabCurrentIndex.value = index
setTimeout(() => {
getScroll("show" + index)
}, 10)
}
/**
* 获得元素的大小
*/
const getElSize = (id: string): Promise<any> => {
return new Promise((res) => {
let el = uni
.createSelectorQuery()
.in(instance!.proxy)
.select("#" + id)
el.fields(
{
size: true,
scrollOffset: true,
rect: true,
}, },
}, (data: any) => {
}, res(data)
data() {
return {
clearRightIcon: true, //是否显示右侧关闭icon
scrollLeft: 500, //顶部选项卡左滑距离
scrollTop: 0, //默认滚动顶部为0
enableScroll: true, //是否启用滚动
tabCurrentIndex: 0, //当前选项卡索引
tabbars: this.provinceData, //默认的省市区id
pickersize: this.pickerSize, //多少个tab 推荐为4级
showPicker: false, //显示选取器
};
},
methods: {
/**
* 显示选择器
*/
show() {
this.showPicker = true;
if (this.tabbars[0].children.length == 0) {
getRegionsById(0).then((res) => {
this.tabbars[0].children = res.data.result;
});
} }
).exec()
})
}
windowWidth = uni.getSystemInfoSync().windowWidth; /**
}, * 点击城市后回调
*/
/** const changCity = async (index: number, item: any) => {
* 关闭选择器 if (tabbars.value[index].id != item.id) {
*/ tabbars.value[index].localName = item.name
hide() { tabbars.value[index].id = item.id
this.showPicker = false; tabbars.value[index].center = item.center
}, if (index < tabbars.value.length - 1) {
tabbars.value.splice(index + 1, tabbars.value.length - index - 1)
/** }
* tab切换 if (tabbars.value.length < pickersize.value as number) {
*/ uni.showLoading({
changeTab(e) { title: "加载中",
let index = e; mask: true
this.setScroll(index); })
//延迟300ms,等待swiper动画结束再修改tabbar try {
this.tabCurrentIndex = index; let data = await getRegionsById(item.id)
setTimeout(() => { uni.hideLoading()
this.getScroll("show" + index); // 当前选项级为最后一级时回调,将选中的数据返回
}, 10); if (data.data.result.length == 0) {
}, emit("funcValue", tabbars.value)
hide()
/**
* 获得元素的大小
*/
getElSize(id) {
return new Promise((res, rej) => {
let el = uni
.createSelectorQuery()
.in(this)
.select("#" + id);
el.fields(
{
size: true,
scrollOffset: true,
rect: true,
},
(data) => {
res(data);
}
).exec();
});
},
/**
* 点击城市后回调
*/
async changCity(index, item) {
if (this.tabbars[index].id != item.id) {
this.tabbars[index].localName = item.name;
this.tabbars[index].id = item.id;
this.tabbars[index].center = item.center
if (index < this.tabbars.length - 1) {
this.tabbars.splice(index + 1, this.tabbars.length - index - 1);
}
if (this.tabbars.length < this.pickersize) {
let data = await getRegionsById(item.id);
// 当前选项级为最后一级时回调,将选中的数据返回
if (data.data.result.length == 0) {
this.$emit("funcValue", this.tabbars);
this.hide();
} else {
// 将新的数据填充进下一级
var current = {
localName: "请选择",
id: "",
children: data.data.result,
};
this.tabbars.push(current);
this.tabCurrentIndex++;
// 当前距离重新为最上面
this.$set(this,'scrollTop',0)
}
} else { } else {
this.$emit("funcValue", this.tabbars); // 将新的数据填充进下一级
this.hide(); var current = {
} localName: "请选择",
} id: "",
}, children: data.data.result,
}
tabbars.value.push(current)
tabCurrentIndex.value++
/** // 当前距离重新为最上面
* 获取当前tab中滚动的距离 scrollTop.value = 0
*/
async setScroll(index) {
let width = 0;
let nowWidth = 0;
for (let i = 0; i <= index; i++) {
let result = await this.getElSize("tab" + i);
width += result.width;
if (i === index) {
nowWidth = result.width;
} }
} catch (error) {
uni.hideLoading()
} }
if (width + nowWidth > windowWidth) { } else {
this.scrollLeft = width + nowWidth; emit("funcValue", tabbars.value)
} else { hide()
this.scrollLeft = 0; }
} }
}, }
/** /**
* 计算当前的滚动距离 * 获取当前tab中滚动的距离
*/ */
getScroll(id) { const setScroll = async (index: number) => {
let width = 0
let nowWidth = 0
for (let i = 0; i <= index; i++) {
let result = await getElSize("tab" + i)
width += result.width
if (i === index) {
nowWidth = result.width
}
}
if (width + nowWidth > windowWidth) {
scrollLeft.value = width + nowWidth
} else {
scrollLeft.value = 0
}
}
/**
* 计算当前的滚动距离
*/
const getScroll = (id: string) => {
uni
.createSelectorQuery()
.in(instance!.proxy)
.select(".panel-scroll-box")
.boundingClientRect((data: any) => {
uni uni
.createSelectorQuery() .createSelectorQuery()
.in(this) .in(instance!.proxy)
.select(".panel-scroll-box") .select("#" + id)
.boundingClientRect((data) => { .boundingClientRect((res: any) => {
uni if (res != undefined && res != null && res != "") {
.createSelectorQuery() scrollTop.value = res.top - data.top
.in(this) }
.select("#" + id)
.boundingClientRect((res) => {
if (res != undefined && res != null && res != "") {
this.scrollTop = res.top - data.top;
}
})
.exec();
}) })
.exec(); .exec()
}, })
}, .exec()
}; }
// 暴露方法给父组件调用
defineExpose({ show, hide })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@@ -381,12 +381,10 @@ export default {
flex-direction: column; flex-direction: column;
/* #endif */ /* #endif */
margin-right: 5px; margin-right: 5px;
margin-left: 40rpx;
vertical-align: middle; vertical-align: middle;
} }
.color { .color {
color: $light-color; color: $light-color;
} }
icon {
margin-left: 40rpx;
}
</style> </style>

View File

@@ -8,4 +8,11 @@
| `type` | 商品展示类型 oneColumns twoColumns ,默认展示一行两列商品 | String | 否 | | `type` | 商品展示类型 oneColumns twoColumns ,默认展示一行两列商品 | String | 否 |
| `storeName` | 是否展示店铺名称,默认展示 | Boolean | 否 | | `storeName` | 是否展示店铺名称,默认展示 | Boolean | 否 |
| `keywords` | 高亮展示搜索内容 | String | 否 | | `keywords` | 高亮展示搜索内容 | String | 否 |
| `showFields` | 商品卡片字段开关(Object,null=现状渲染全量字段)。键:`subTitle` 副标题、`spec` 规格摘要(取 attrList 前 2 项)、`tags` 促销标签、`selfTag` 自营、`price` 价格、`linePrice` 划线价(仅 marketPrice>price 时显示)、`sales` 已售/评论、`cart` 购物车按钮。新增字段(副标题/规格/划线价/购物车)仅在 showFields 提供时才会渲染;目前仅 oneColumns 布局支持开关 | Object | 否 |
### EVENTS 事件说明
| 事件名 | 说明 | 回调参数 |
| ------ | ---- | -------- |
| `addCart` | 点击购物车按钮(showFields.cart 开启时渲染) | 当前商品对象 |

View File

@@ -1,5 +1,5 @@
<template> <template>
<div> <view>
<!-- 一行两列商品展示 --> <!-- 一行两列商品展示 -->
<view class="goods-list" v-if="type == 'twoColumns'"> <view class="goods-list" v-if="type == 'twoColumns'">
<view v-for="(item, index) in res" :key="index" class="goods-item"> <view v-for="(item, index) in res" :key="index" class="goods-item">
@@ -10,7 +10,7 @@
height="330rpx" height="330rpx"
mode="aspectFit" mode="aspectFit"
> >
<u-loading slot="loading"></u-loading> <template #loading><u-loading-icon></u-loading-icon></template>
</u-image> </u-image>
</view> </view>
<view class="goods-detail"> <view class="goods-detail">
@@ -23,9 +23,9 @@
<div class="price" v-if="item.price != undefined"> <div class="price" v-if="item.price != undefined">
¥<span ¥<span
>{{ >{{
$options.filters.goodsFormatPrice(item.price)[0] goodsFormatPrice(item.price)[0]
}} </span }} </span
>.{{ $options.filters.goodsFormatPrice(item.price)[1] }} >.{{ goodsFormatPrice(item.price)[1] }}
</div> </div>
</view> </view>
<div class="count-config" @click="navigateToDetailPage(item)"> <div class="count-config" @click="navigateToDetailPage(item)">
@@ -57,7 +57,7 @@
</view> </view>
<!-- 一行一列商品展示 --> <!-- 一行一列商品展示 -->
<div v-if="type == 'oneColumns'"> <div v-if="type == 'oneColumns'">
<div v-for="(item, index) in res" :key="index" class="goods-row"> div v-for="(item, index) in res" :key="index" class="goods-row">
<div class="flex goods-col"> <div class="flex goods-col">
<div class="goods-img" @click="navigateToDetailPage(item)"> <div class="goods-img" @click="navigateToDetailPage(item)">
<u-image <u-image
@@ -67,7 +67,7 @@
mode="aspectFit" mode="aspectFit"
:src="item.goodsImage || item.thumbnail" :src="item.goodsImage || item.thumbnail"
> >
<u-loading slot="loading"></u-loading> <template #loading><u-loading-icon></u-loading-icon></template>
</u-image> </u-image>
</div> </div>
<div class="goods-detail"> <div class="goods-detail">
@@ -77,14 +77,11 @@
<view class="price-box" @click="navigateToDetailPage(item)"> <view class="price-box" @click="navigateToDetailPage(item)">
<div class="price" v-if="item.price != undefined"> <div class="price" v-if="item.price != undefined">
¥<span ¥<span
>{{ $options.filters.goodsFormatPrice(item.price)[0] }} </span >{{ goodsFormatPrice(item.price)[0] }} </span
>.{{ $options.filters.goodsFormatPrice(item.price)[1] }} >.{{ goodsFormatPrice(item.price)[1] }}
</div> </div>
</view> </view>
<div class="promotion" @click="navigateToDetailPage(item)"> <div class="promotion" @click="navigateToDetailPage(item)">
<div v-if="item.salesModel == 'WHOLESALE'">
<span>批</span>
</div>
<div <div
v-for="(promotionItem, promotionIndex) in getPromotion(item)" v-for="(promotionItem, promotionIndex) in getPromotion(item)"
:key="promotionIndex" :key="promotionIndex"
@@ -112,41 +109,26 @@
</div> </div>
</div> </div>
</div> </div>
</div> </view>
</template> </template>
<script> <script setup lang="ts">
import commonTpl from "@/components/m-goods-list/common"; import { useGoodsListCommon } from './common'
export default { import { goodsFormatPrice } from '@/utils/filters.js'
data() {
return { const { lightSearchStr, getPromotion, navigateToDetailPage, navigateToStoreDetailPage } = useGoodsListCommon()
lightColor: this.$mainColor,
}; const props = withDefaults(defineProps<{
}, type?: string
mixins: [commonTpl], res?: any[]
props: { storeName?: boolean
// 展示的类型 keyword?: string | null
type:{ }>(), {
type:String, type: 'oneColumns',
default:"oneColumns" res: () => [],
}, storeName: true,
// 遍历的数据 keyword: ''
res: { })
type: Array,
default: () => {
return [];
},
},
},
methods: {
// 跳转到商品详情
navigateToDetailPage(item) {
uni.navigateTo({
url: `/pages/product/goods?id=${item.id}&goodsId=${item.goodsId}`,
});
},
},
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@@ -268,7 +250,7 @@ export default {
color: $main-color; color: $main-color;
font-weight: bold; font-weight: bold;
/deep/ span:nth-of-type(1) { ::v-deep span:nth-of-type(1) {
font-size: 38rpx; font-size: 38rpx;
} }
} }

View File

@@ -0,0 +1,90 @@
import { useStore } from '@/store'
/**
* 商品列表公共逻辑(原 common.vue mixin)
* 提供高亮搜索、unicode 转换、促销标签、导航跳转等通用方法
*/
export function useGoodsListCommon() {
const store = useStore()
const lightColor = store.getters.lightColor
/**
* 高亮显示搜索内容
*/
const lightSearchStr = (keyword: string, str: string) => {
if (!keyword) {
return str
} else {
let unicodes = ''
for (let i of Array.from(keyword)) {
unicodes += unicode(i) + "|"
}
const rule = '(' + unicodes + ')'
const reg = new RegExp(rule, 'gi')
return str ? str.replace(reg, (matchValue) =>
`<span style="color:${lightColor}">${matchValue}</span>`
) : ''
}
}
/**
* 转换为 unicode
*/
const unicode = (str: string) => {
var value = ''
for (var i = 0; i < str.length; i++) {
value += '\\u' + leftZero4(parseInt(str.charCodeAt(i).toString(16)))
}
return value
}
const leftZero4 = (str: string) => {
if (str != null && str != '' && str != 'undefined') {
if (str.length == 2) {
return '00' + str
}
}
return str
}
/**
* 数据去重 只显示一次 减免 劵等
*/
const getPromotion = (item: any) => {
if (item.promotionMap) {
let array: string[] = []
Object.keys(item.promotionMap).forEach((child) => {
if (!array.includes(child.split("-")[0])) {
array.push(child.split("-")[0])
}
})
return array
}
}
/**
* 跳转到商品详情
*/
const navigateToDetailPage = (item: any) => {
uni.navigateTo({
url: `/pages/product/goods?id=${item.id}&goodsId=${item.goodsId}`,
})
}
/**
* 跳转到店铺详情
*/
const navigateToStoreDetailPage = (item: any) => {
uni.navigateTo({
url: `/pages/product/shopPage?id=${item.storeId}`,
})
}
return {
lightSearchStr,
getPromotion,
navigateToDetailPage,
navigateToStoreDetailPage,
}
}

View File

@@ -1,69 +0,0 @@
<template>
</template>
<script>
export default {
methods: {
// 高亮显示搜索内容
lightSearchStr(keyword, str) {
if (!keyword) {
return str
} else {
let unicodes = '';
for (let i of Array.from(keyword)) {
unicodes += this.unicode(i) + "|"
}
const rule = '(' + unicodes + ')'
const reg = new RegExp(rule, 'gi');
return str ? str.replace(reg, matchValue =>
`<span style="color:${this.lightColor}">${matchValue}</span>`
) : ''
}
},
// 转换为unicode
unicode(str) {
var value = '';
for (var i = 0; i < str.length; i++) {
value += '\\u' + this.left_zero_4(parseInt(str.charCodeAt(i)).toString(16));
}
return value;
},
left_zero_4(str) {
if (str != null && str != '' && str != 'undefined') {
if (str.length == 2) {
return '00' + str;
}
}
return str;
},
// 数据去重一下 只显示一次 减免 劵 什么的
getPromotion(item) {
if (item.promotionMap) {
let array = [];
Object.keys(item.promotionMap).forEach((child) => {
if (!array.includes(child.split("-")[0])) {
array.push(child.split("-")[0]);
}
});
return array;
}
},
// 跳转到商品详情
navigateToDetailPage(item) {
uni.navigateTo({
url: `/pages/product/goods?id=${item.id}&goodsId=${item.goodsId}`,
});
},
// 跳转地址
navigateToStoreDetailPage(item) {
uni.navigateTo({
url: `/pages/product/shopPage?id=${item.storeId}`,
});
},
},
}
</script>
<style lang='scss' scoped>
</style>

View File

@@ -1,11 +1,11 @@
<template> <template>
<view> <view>
<!-- 一行两列商品展示 --> <!-- 一行两列商品展示 -->
<view class="goods-list" v-if="type == 'twoColumns'"> <view class="goods-list" :class="{ 'goods-list--embedded': !tabBarGap }" v-if="type == 'twoColumns'">
<view v-for="(item, index) in res" :key="index" class="goods-item"> <view v-for="(item, index) in res" :key="index" class="goods-item">
<view class="image-wrapper" @click="navigateToDetailPage(item)"> <view class="image-wrapper" @click="navigateToDetailPage(item)">
<u-image :src="item.thumbnail" width="100%" height='330rpx' mode="aspectFit"> <u-image :src="item.thumbnail" width="100%" height='330rpx' mode="aspectFit">
<u-loading slot="loading"></u-loading> <template #loading><u-loading-icon></u-loading-icon></template>
</u-image> </u-image>
</view> </view>
<view class="goods-detail"> <view class="goods-detail">
@@ -15,19 +15,17 @@
</div> </div>
<view class="price-box" @click="navigateToDetailPage(item)"> <view class="price-box" @click="navigateToDetailPage(item)">
<div class="price" v-if="item.price!=undefined"> <div class="price" v-if="item.price!=undefined">
¥<span>{{ $options.filters.goodsFormatPrice(item.price )[0] }} </span>.{{ ¥<span class="price-int">{{ goodsFormatPrice(item.price )[0] }} </span>.{{
$options.filters.goodsFormatPrice(item.price )[1] goodsFormatPrice(item.price )[1]
}} }}
</div> </div>
</view> </view>
<PaidMemberPrice :quote="paidQuotes[item.id]" />
<div class="promotion" @click="navigateToDetailPage(item)"> <div class="promotion" @click="navigateToDetailPage(item)">
<div v-if="item.salesModel == 'WHOLESALE'">
<span>批</span>
</div>
<div v-for="(promotionItem,promotionIndex) in getPromotion(item)" :key="promotionIndex"> <div v-for="(promotionItem,promotionIndex) in getPromotion(item)" :key="promotionIndex">
<span v-if="promotionItem.indexOf('COUPON') != -1">劵</span> <span class="promotion-tag" v-if="promotionItem.indexOf('COUPON') != -1">劵</span>
<span v-if="promotionItem.indexOf('FULL_DISCOUNT') != -1">满减</span> <span class="promotion-tag" v-if="promotionItem.indexOf('FULL_DISCOUNT') != -1">满减</span>
<span v-if="promotionItem.indexOf('SECKILL') != -1">秒杀</span> <span class="promotion-tag" v-if="promotionItem.indexOf('SECKILL') != -1">秒杀</span>
</div> </div>
</div> </div>
<div class="count-config" @click="navigateToDetailPage(item)"> <div class="count-config" @click="navigateToDetailPage(item)">
@@ -35,175 +33,134 @@
<span>{{ item.commentNum || "0" }}条评论</span> <span>{{ item.commentNum || "0" }}条评论</span>
</div> </div>
<div class="store-seller-name" v-if="storeName" @click="navigateToStoreDetailPage(item)"> <div class="store-seller-name" v-if="storeName" @click="navigateToStoreDetailPage(item)">
<div class="text-hidden"> <view class="store-name-row">
<u-tag style="margin-right: 10rpx" size="mini" mode="dark" v-if="item.selfOperated" <text class="self-tag" v-if="item.selfOperated">自营</text>
text="自营" type="error" /> <text class="store-name-text">{{ item.storeName || "暂无" }}</text>
<span>{{ item.storeName || "暂无" }}</span> <text class="to-store">进店</text>
</div> </view>
<span> <u-icon name="arrow-right" size="12" color="#c5c5c5"></u-icon>
<u-icon name="arrow-right"></u-icon>
</span>
</div> </div>
</view> </view>
</view> </view>
</view> </view>
<!-- 一行一列商品展示 --> <!-- 一行一列商品展示 -->
<div v-if="type == 'oneColumns'" class="goods-one-row"> <div v-if="type == 'oneColumns'" class="goods-one-row" :class="{ 'goods-one-row--embedded': !tabBarGap }">
<div v-for="(item, index) in res" :key="index" class="goods-row"> <div v-for="(item, index) in res" :key="index" class="goods-row">
<div class="flex goods-col"> <div class="flex goods-col">
<div class="goods-img" @click="navigateToDetailPage(item)"> <div class="goods-img" @click="navigateToDetailPage(item)">
<u-image width="230rpx" mode="aspectFit" border-radius='16' height="230rpx" :src="item.thumbnail"> <u-image :width="!tabBarGap ? '170rpx' : '230rpx'" mode="aspectFit" :border-radius="!tabBarGap ? '12' : '16'" :height="!tabBarGap ? '170rpx' : '230rpx'" :src="item.thumbnail">
<u-loading slot="loading"></u-loading> <template #loading><u-loading-icon></u-loading-icon></template>
</u-image> </u-image>
</div> </div>
<div class="goods-detail"> <div class="goods-detail">
<div class="title clamp3" @click="navigateToDetailPage(item)">{{ item.goodsName }}</div> <div class="title clamp2" @click="navigateToDetailPage(item)">
<text class="self-tag" v-if="(!storeName || flag('selfTag')) && item.selfOperated">自营</text>
{{ item.goodsName }}
</div>
<div class="selling-point" v-if="extra('subTitle') && item.sellingPoint">{{ item.sellingPoint }}</div>
<div class="spec-summary" v-if="extra('spec') && specSummary(item)">{{ specSummary(item) }}</div>
<div class="promotion" v-if="flag('tags')" @click="navigateToDetailPage(item)">
<div v-for="(promotionItem,promotionIndex) in getPromotion(item)" :key="promotionIndex">
<span class="promotion-tag" v-if="promotionItem.indexOf('COUPON') != -1">劵</span>
<span class="promotion-tag" v-if="promotionItem.indexOf('FULL_DISCOUNT') != -1">满减</span>
<span class="promotion-tag" v-if="promotionItem.indexOf('SECKILL') != -1">秒杀</span>
</div>
</div>
<div style="overflow: hidden" v-if="flag('sales')" @click="navigateToDetailPage(item)" class="count-config">
<span style="float: left; font-size: 22rpx">已售 {{ item.buyCount || '0' }}</span>
<span style="float: right; font-size: 22rpx" v-if="item.commentNum">{{ item.commentNum }}条评论</span>
</div>
<view class="price-box" @click="navigateToDetailPage(item)"> <view class="price-box" @click="navigateToDetailPage(item)">
<div class="price" v-if="item.price!=undefined"> <div class="price" v-if="flag('price') && item.price!=undefined">
¥<span>{{ $options.filters.goodsFormatPrice(item.price )[0] }} </span>.{{ ¥<span class="price-int">{{ goodsFormatPrice(item.price )[0] }} </span>.{{
$options.filters.goodsFormatPrice(item.price )[1] goodsFormatPrice(item.price )[1]
}} }}
</div> </div>
<div class="market-price" v-if="extra('linePrice') && hasMarketPrice(item)">¥{{ item.marketPrice }}</div>
<div class="cart-btn" v-if="extra('cart')" @click.stop="emit('addCart', item)">
<u-icon name="shopping-cart" size="16" :color="mainColor"></u-icon>
</div>
</view> </view>
<div class="promotion" @click="navigateToDetailPage(item)"> <PaidMemberPrice v-if="flag('price')" :quote="paidQuotes[item.id]" />
<div v-if="item.salesModel == 'WHOLESALE'"> <div class="store-seller-name" v-if="storeName" @click="navigateToStoreDetailPage(item)">
<span>批</span> <view class="store-name-row">
</div> <text class="self-tag" v-if="item.selfOperated && flag('selfTag')">自营</text>
<div v-for="(promotionItem,promotionIndex) in getPromotion(item)" :key="promotionIndex"> <text class="store-name-text">{{ item.storeName }}</text>
<span v-if="promotionItem.indexOf('COUPON') != -1">劵</span> <text class="to-store">进店</text>
<span v-if="promotionItem.indexOf('FULL_DISCOUNT') != -1">满减</span> </view>
<span v-if="promotionItem.indexOf('SECKILL') != -1">秒杀</span> <u-icon name="arrow-right" size="12" color="#c5c5c5"></u-icon>
</div>
</div>
<div style="overflow: hidden" @click="navigateToDetailPage(item)" class="count-config">
<span style="float: left; font-size: 22rpx">已售 {{ item.buyCount || '0' }}</span>
<span style="float: right; font-size: 22rpx">{{ item.commentNum || '0' }}条评论</span>
</div>
<div style="overflow: hidden" @click="navigateToStoreDetailPage(item)" class="count-config">
<div class="text-hidden" v-if="storeName">
<u-tag style="margin-right: 10rpx" size="mini" mode="dark" v-if="item.selfOperated"
text="自营" type="error" />
<span class="line1-store-name">{{ item.storeName }}</span>
<span class="to-store">进店<u-icon size="24" name="arrow-right" color="#666"></u-icon>
</span>
</div>
<span>
<u-icon name="arrow-right" color="#c5c5c5"></u-icon>
</span>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</view> </view>
</template> </template>
<script> <script setup lang="ts">
import commonTpl from '@/components/m-goods-list/common' import { computed, watch, ref } from 'vue'
export default { import { onShow } from '@dcloudio/uni-app'
data() { import PaidMemberPrice from '@/components/paid-member-price/index.vue'
return { import { getPaidMemberQuotes } from '@/api/paid-member'
lightColor: this.$mainColor import { isLogin } from '@/utils/filters'
} import { useStore } from '@/store'
}, import { useGoodsListCommon } from './common'
mixins: [commonTpl], import { goodsFormatPrice } from '@/utils/filters.js'
props: {
// 遍历的数据
res: {
type: Array,
default: () => {
return []
}
},
// 一行两列还是一行一列显示
type: {
type: String,
default: 'twoColumns',
validator() {
return ['twoColumns', 'oneColumns']
}
},
storeName: {
type: Boolean,
default: true
},
keyword: {
type: null,
default: ''
}
}, const store = useStore()
watch: { const mainColor = computed(() => (store && store.getters && store.getters.mainColor) || '#ff3c2a')
keyword(val) {
if (val) {
this.lightSearchStr(val)
}
}
},
methods: {
// 高亮显示搜索内容 const { lightSearchStr, getPromotion, navigateToDetailPage, navigateToStoreDetailPage } = useGoodsListCommon()
lightSearchStr(keyword, str) {
if (!keyword) { const props = withDefaults(defineProps<{
return str res?: any[]
} else { type?: string
let unicodes = ''; storeName?: boolean
for (let i of Array.from(keyword)) { tabBarGap?: boolean
unicodes += this.unicode(i) + "|" keyword?: string | null
} showFields?: Record<string, boolean> | null
const rule = '(' + unicodes + ')' }>(), {
const reg = new RegExp(rule, 'gi'); res: () => [],
return str ? str.replace(reg, matchValue => type: 'twoColumns',
`<span style="color:${this.lightColor}">${matchValue}</span>` storeName: true,
) : '' tabBarGap: true,
} keyword: '',
}, showFields: null
// 转换为unicode })
unicode(str) {
var value = ''; const emit = defineEmits(['addCart'])
for (var i = 0; i < str.length; i++) { const paidQuotes = ref<Record<string, any>>({})
value += '\\u' + this.left_zero_4(parseInt(str.charCodeAt(i)).toString(16)); let paidRequest = 0
} async function loadPaidQuotes() {
return value; const request = ++paidRequest, memberId = String(isLogin()?.id || '')
}, paidQuotes.value = {}
left_zero_4(str) { if (!memberId) return
if (str != null && str != '' && str != 'undefined') { const ids = [...new Set((props.res || []).map(item => String(item.id || '')).filter(Boolean))]
if (str.length == 2) { try {
return '00' + str; const results = await Promise.all(Array.from({length:Math.ceil(ids.length/100)},(_,i)=>getPaidMemberQuotes(ids.slice(i*100,i*100+100))))
} if (request !== paidRequest || String(isLogin()?.id || '') !== memberId) return
} paidQuotes.value = Object.assign({}, ...results.filter(res=>res.data?.success).map(res=>res.data.result || {}))
return str; } catch {}
}, }
// 数据去重一下 只显示一次 减免 劵 什么的 watch(() => [(props.res || []).map(item=>item.id).join(','), store.state.userInfo?.id, store.state.hasLogin], loadPaidQuotes, {immediate:true})
getPromotion(item) { onShow(loadPaidQuotes)
if (item ? item.promotionMap : item.promotionMap) {
const fieldList = item ? item.promotionMap : item.promotionMap // 存量字段(促销/销量/自营/价格):showFields 为 null 时维持现状渲染
let array = []; const flag = (key: string) => props.showFields == null || props.showFields[key] !== false
Object.keys(fieldList).forEach((child) => { // 新增字段(副标题/规格/划线价/购物车按钮):仅 showFields 提供时可渲染
if (!array.includes(child.split("-")[0])) { const extra = (key: string) => props.showFields != null && props.showFields[key] !== false
array.push(child.split("-")[0]); const hasMarketPrice = (item: any) =>
} item.marketPrice != null && item.price != null && item.marketPrice > item.price
}); const specSummary = (item: any) =>
return array; Array.isArray(item.attrList)
} ? item.attrList.slice(0, 2).map((a: any) => `${a.name}: ${a.value}`).join(' · ')
}, : ''
// 跳转到商品详情
navigateToDetailPage(item) { watch(() => props.keyword, (val) => {
uni.navigateTo({ if (val) {
url: `/pages/product/goods?id=${item.id}&goodsId=${item.goodsId}`, lightSearchStr(val as string, '')
});
},
// 跳转地址
navigateToStoreDetailPage(item) {
uni.navigateTo({
url: `/pages/product/shopPage?id=${item.storeId}`,
});
},
}
} }
})
</script> </script>
<style lang='scss' scoped> <style lang='scss' scoped>
@@ -214,23 +171,25 @@
.goods-list { .goods-list {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: space-between;
margin: 10rpx 20rpx 284rpx; margin: 10rpx 20rpx 284rpx;
width: 100%; width: calc(100% - 40rpx);
box-sizing: border-box;
&.goods-list--embedded {
margin-bottom: 20rpx;
}
>.goods-item { >.goods-item {
background-color: #ffffff; background-color: #ffffff;
display: flex; display: flex;
border-radius: 16rpx; border-radius: 16rpx;
flex-direction: column; flex-direction: column;
width: calc(50% - 30rpx); width: calc(50% - 10rpx);
margin-bottom: 20rpx; margin-bottom: 20rpx;
padding-bottom: 20rpx; padding-bottom: 20rpx;
&:nth-child(2n + 1) {
margin-right: 20rpx;
}
.image-wrapper { .image-wrapper {
width: 100%; width: 100%;
height: 330rpx; height: 330rpx;
@@ -239,41 +198,209 @@
padding: 0; padding: 0;
} }
} }
.count-config, .count-config,
.store-seller-name { .store-seller-name {
font-size: $font-sm; font-size: $font-sm;
} }
.text-hidden { .store-seller-name {
color: #666;
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 4rpx;
font-size: 24rpx;
}
.store-name-row {
flex: 1;
min-width: 0;
display: flex;
align-items: center;
overflow: hidden;
}
.store-name-text {
flex: 1;
min-width: 0;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
font-size: 24rpx;
color: #999;
}
.to-store {
flex-shrink: 0;
font-size: 24rpx;
color: #333;
margin-left: 8rpx;
}
.self-tag {
flex-shrink: 0;
margin-right: 8rpx;
padding: 2rpx 10rpx;
border-radius: 8rpx;
background: $main-color;
color: #fff;
font-size: 20rpx;
line-height: 1.4;
}
.count-config {
padding: 5rpx 0;
color: #666;
display: flex;
font-size: 24rpx;
justify-content: space-between;
} }
} }
.goods-one-row--embedded {
.goods-row {
padding: 20rpx 16rpx;
border-bottom: 1rpx solid #f6f6f6;
background: #ffffff;
>.goods-col {
display: flex;
align-items: stretch;
>.goods-img {
flex: 0 0 170rpx;
width: 170rpx;
height: 170rpx;
border-radius: 12rpx;
overflow: hidden;
background: #f8f8f8;
}
>.goods-detail {
flex: 1;
min-width: 0;
margin: 0 0 0 16rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
>.title {
font-size: 26rpx;
color: #222;
line-height: 1.4;
max-height: 74rpx;
padding: 0;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
text-overflow: ellipsis;
.self-tag {
display: inline-block;
margin-right: 8rpx;
padding: 1rpx 8rpx;
border-radius: 6rpx;
background: $main-color;
color: #fff;
font-size: 20rpx;
line-height: 1.4;
vertical-align: middle;
}
}
.selling-point {
font-size: 22rpx;
color: #999;
line-height: 1.3;
margin-top: 4rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.spec-summary {
font-size: 22rpx;
color: #999;
line-height: 1.3;
margin-top: 2rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.count-config {
font-size: 22rpx;
color: #999;
margin-top: 4rpx;
}
.price-box {
display: flex;
align-items: flex-end;
justify-content: space-between;
margin-top: auto;
padding-top: 8rpx;
.price {
font-size: 22rpx;
color: $main-color;
font-weight: 500;
line-height: 1;
.price-int {
font-size: 34rpx;
font-weight: bold;
}
}
.market-price {
font-size: 22rpx;
color: #bbb;
text-decoration: line-through;
margin-left: 8rpx;
}
.cart-btn {
width: 48rpx;
height: 48rpx;
border-radius: 50%;
background: #ffffff;
border: 2rpx solid $main-color;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
box-shadow: 0 2rpx 8rpx rgba(255, 60, 42, 0.12);
}
}
}
}
}
}
.goods-row { .goods-row {
background: #fff; background: #fff;
padding: 16rpx; padding: 16rpx;
>.goods-col { >.goods-col {
display: flex; display: flex;
>.goods-img { >.goods-img {
overflow: hidden; overflow: hidden;
flex: 4; flex: 4;
} }
>.goods-detail { >.goods-detail {
flex: 7; flex: 7;
} }
} }
} }
.goods-detail { .goods-detail {
margin: 0 20rpx; margin: 0 20rpx;
>.title { >.title {
font-size: $font-base; font-size: $font-base;
color: $font-color-dark; color: $font-color-dark;
@@ -285,29 +412,106 @@
-webkit-line-clamp: 2; -webkit-line-clamp: 2;
overflow: hidden; overflow: hidden;
} }
.promotion { .selling-point {
font-size: 22rpx;
color: #999;
line-height: 1.4;
margin-top: 4rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.spec-summary {
font-size: 22rpx;
color: #999;
line-height: 1.4;
margin-top: 4rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.market-price {
font-size: 22rpx;
color: #999;
text-decoration: line-through;
margin-left: 8rpx;
}
.cart-btn {
width: 48rpx;
height: 48rpx;
border-radius: 50%;
background: #ffffff;
border: 2rpx solid $main-color;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
box-sizing: border-box;
box-shadow: 0 2rpx 8rpx rgba(255, 60, 42, 0.12);
}
.promotion {
margin-top: 4rpx; margin-top: 4rpx;
display: flex; display: flex;
div { .promotion-tag {
span { font-size: 24rpx;
font-size: 24rpx; color: $light-color;
color: $light-color; margin-right: 10rpx;
margin-right: 10rpx; padding: 0 4rpx;
padding: 0 4rpx; border-radius: 2px;
border-radius: 2rpx;
}
} }
} }
.store-seller-name { .store-seller-name {
color: #666; color: #666;
overflow: hidden;
display: flex; display: flex;
align-items: center;
justify-content: space-between; justify-content: space-between;
margin-top: 4rpx;
font-size: 24rpx;
} }
.store-name-row {
flex: 1;
min-width: 0;
display: flex;
align-items: center;
overflow: hidden;
}
.store-name-text {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 24rpx;
color: #999;
}
.to-store {
flex-shrink: 0;
font-size: 24rpx;
color: #333;
margin-left: 8rpx;
}
.self-tag {
flex-shrink: 0;
margin-right: 8rpx;
padding: 2rpx 10rpx;
border-radius: 8rpx;
background: $main-color;
color: #fff;
font-size: 20rpx;
line-height: 1.4;
}
.count-config { .count-config {
padding: 5rpx 0; padding: 5rpx 0;
color: #666; color: #666;
@@ -315,7 +519,7 @@
font-size: 24rpx; font-size: 24rpx;
justify-content: space-between; justify-content: space-between;
} }
>.price-box { >.price-box {
margin-top: 10rpx; margin-top: 10rpx;
display: flex; display: flex;
@@ -324,18 +528,17 @@
padding-right: 10rpx; padding-right: 10rpx;
font-size: 24rpx; font-size: 24rpx;
color: $font-color-light; color: $font-color-light;
>.price { >.price {
font-size: 26rpx; font-size: 26rpx;
line-height: 1; line-height: 1;
color: $main-color; color: $main-color;
font-weight: bold; font-weight: bold;
/deep/ span:nth-of-type(1) { .price-int {
font-size: 38rpx; font-size: 38rpx;
} }
} }
} }
} }
</style> </style>

View File

@@ -1,170 +1,145 @@
<template> <template>
<div> <div>
<div v-for="(item, index) in res" :key="index" class="goods-row" @click="navigateToDetailPage(item)"> <div v-for="(item, index) in res" :key="index" class="goods-row" @click="onItemClick(item)">
<div class="flex goods-col"> <div class="flex goods-col">
<div class="goods-img"> <div class="goods-img">
<u-image width="230rpx" mode="aspectFit" border-radius='16' height="230rpx" :src="item.goodsImage || item.thumbnail"> <u-image width="230rpx" mode="aspectFit" border-radius='16' height="230rpx" :src="item.goodsImage || item.thumbnail">
<u-loading slot="loading"></u-loading> <template #loading><u-loading-icon></u-loading-icon></template>
</u-image> </u-image>
</div> </div>
<div class="goods-detail"> <div class="goods-detail">
<div class="title clamp3">{{ item.goodsName }}</div> <div class="title clamp3">{{ item.goodsName }}</div>
<div class='flex flex-a-c flex-j-sb'> <div class='flex flex-a-c flex-j-sb'>
<view class="price-box"> <view class="price-box">
<!-- 秒杀 / 拼团 --> <!-- 秒杀 / 拼团 -->
<div class="price" v-if="!type && item.price!=undefined"> <div class="price" v-if="!type && item.price!=undefined">
¥<span>{{ $options.filters.goodsFormatPrice(item.price )[0] }} </span>.{{ ¥<span class="price-int">{{ goodsFormatPrice(item.price )[0] }} </span>.{{
$options.filters.goodsFormatPrice(item.price )[1] goodsFormatPrice(item.price )[1]
}} }}
</div> </div>
<!-- 砍价 --> <!-- 砍价 -->
<div class="price" v-if="type && item.purchasePrice!=undefined"> <div class="price" v-if="type && item.purchasePrice!=undefined">
最低: 最低:
¥<span>{{ $options.filters.goodsFormatPrice(item.purchasePrice )[0] }} </span>.{{ ¥<span class="price-int">{{ goodsFormatPrice(item.purchasePrice )[0] }} </span>.{{
$options.filters.goodsFormatPrice(item.purchasePrice )[1] goodsFormatPrice(item.purchasePrice )[1]
}} }}
</div> </div>
<!-- 兜底策略如果金额是0 --> <!-- 兜底策略如果金额是0 -->
<div class="price" v-if="!item.price && !type"> <div class="price" v-if="!item.price && !type">
¥<span>0 </span>.00 ¥<span class="price-int">0 </span>.00
</div> </div>
</view> </view>
<div> <div>
<image class='buy' :src="buy"></image> <image class="buy" src="/static/buy.png"></image>
</div> </div>
</div> </div>
<div class='count-config' v-if="!type"> <div class='count-config' v-if="!type">
<span>即将恢复{{ item.originalPrice}}元</span> <text class="count-config-text">即将恢复{{ item.originalPrice}}元</text>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script> <script setup lang="ts">
import commonTpl from '@/components/m-goods-list/common' import { goodsFormatPrice } from '@/utils/filters.js'
export default {
data() { const props = withDefaults(defineProps<{
return { res?: any[]
lightColor: this.$mainColor, type?: string | null
buy: require('@/static/buy.png') }>(), {
} res: () => [],
}, type: ''
mixins: [commonTpl], })
props: {
// 遍历的数据 // 促销列表跳转:拼团/秒杀 PromotionGoods 用 skuId;砍价走活动详情
res: { function onItemClick(item: any) {
type: Array, if (props.type == 'kanJia') {
default: () => { uni.navigateTo({
return [] url: `/pages/promotion/bargain/detail?id=${item.id}`,
} })
}, return
type:{ }
type:null, const skuId = item.skuId || item.id
default:"" uni.navigateTo({
} url: `/pages/product/goods?id=${skuId}&goodsId=${item.goodsId}`,
}, })
methods: { }
// 跳转到商品详情 </script>
navigateToDetailPage(item) {
if(this.type == 'kanJia'){ <style lang='scss' scoped>
uni.navigateTo({ .buy {
url: `/pages/promotion/bargain/detail?id=${item.id}`, width: 152rpx;
}); height: 108rpx;
return }
} .flex-j-sb {
uni.navigateTo({ width: 100%;
url: `/pages/product/goods?id=${item.skuId}&goodsId=${item.goodsId}`, }
}); .goods-row {
}, background: #fff;
} padding: 16rpx;
} >.goods-col {
</script> display: flex;
>.goods-img {
<style lang='scss' scoped> overflow: hidden;
.buy { flex: 4;
width: 152rpx; }
height: 108rpx; >.goods-detail {
} flex: 7;
.flex-j-sb { }
width: 100%; }
} }
.goods-row { .goods-detail {
background: #fff; margin: 0 20rpx;
padding: 16rpx; >.title {
>.goods-col { font-size: $font-base;
display: flex; color: $font-color-dark;
>.goods-img { line-height: 1.5;
overflow: hidden; height: 86rpx;
flex: 4; padding: 10rpx 0 0;
} display: -webkit-box;
>.goods-detail { -webkit-box-orient: vertical;
flex: 7; -webkit-line-clamp: 2;
} overflow: hidden;
} }
}
.goods-detail { .count-config {
margin: 0 20rpx; padding: 5rpx 0;
>.title { color: #666;
font-size: $font-base; display: flex;
color: $font-color-dark; font-size: 24rpx;
line-height: 1.5; letter-spacing:2rpx;
height: 86rpx; padding-left: 10rpx;
padding: 10rpx 0 0;
display: -webkit-box; .count-config-text {
-webkit-box-orient: vertical; font-size: 24rpx;
-webkit-line-clamp: 2; }
overflow: hidden; }
}
.promotion {
margin-top: 4rpx; }
display: flex;
.price-box {
div { margin-top: 10rpx;
span { display: flex;
font-size: 24rpx; align-items: center;
color: $light-color; justify-content: space-between;
margin-right: 10rpx; padding-right: 10rpx;
padding: 0 4rpx; font-size: 24rpx;
border-radius: 2rpx; color: $font-color-light;
}
} >.price {
} font-size: 26rpx;
line-height: 1;
.count-config { color: $main-color;
padding: 5rpx 0; font-weight: bold;
color: #666;
display: flex; .price-int {
font-size: 24rpx; font-size: 48rpx;
letter-spacing:2rpx; }
padding-left: 10rpx; }
} }
</style>
}
.price-box {
margin-top: 10rpx;
display: flex;
align-items: center;
justify-content: space-between;
padding-right: 10rpx;
font-size: 24rpx;
color: $font-color-light;
>.price {
font-size: 26rpx;
line-height: 1;
color: $main-color;
font-weight: bold;
/deep/ span:nth-of-type(1) {
font-size: 48rpx;
}
}
}
</style>

View File

@@ -1,73 +1,63 @@
<template> <template>
<div> <view>
<div class="goods-recommend">{{title ? `--${title}-- `:''}}</div> <view class="goods-recommend">{{title ? `--${title}-- `:''}}</view>
<goodsTemplate :res='goodsList' /> <goodsTemplate :res='goodsList' />
</div> </view>
</template> </template>
<script> <script setup lang="ts">
import goodsTemplate from '@/components/m-goods-list/list' import { ref, onMounted } from 'vue'
import { getGoodsList } from "@/api/goods.js"; import goodsTemplate from '@/components/m-goods-list/list.vue'
export default { import { getGoodsList } from "@/api/goods.js"
data() {
return {
goodsList: [],
params: {
pageNumber: 1,
},
};
},
props: {
title: {
type: String,
default: "",
},
pageSize: {
type: null,
default: 12,
},
categoryId: {
type: null,
default: "",
},
storeId: {
type: null,
default: "",
},
},
components:{goodsTemplate},
mounted() {
this.initGoods();
},
methods: {
/**
* 初始化商品
*/
async initGoods() {
let submit = JSON.parse(
JSON.stringify(
Object.assign(this.params, {
pageSize: this.pageSize,
categoryId: this.categoryId,
storeId: this.storeId,
})
)
);
Object.keys(submit).map((key) => { const props = withDefaults(defineProps<{
if (!submit[key] || submit[key].length == 0) { title?: string
delete submit[key]; pageSize?: number | null
} categoryId?: string | null
}); storeId?: string | null
let goodsList = await getGoodsList(submit); }>(), {
this.goodsList.push(...goodsList.data.result.records); title: '',
}, pageSize: 12,
handleClick(item) { categoryId: '',
uni.navigateTo({ storeId: ''
url: `/pages/product/goods?id=${item.id}&goodsId=${item.goodsId}`, })
});
}, const goodsList = ref<any[]>([])
}, const params = ref({
}; pageNumber: 1,
})
onMounted(() => {
initGoods()
})
/**
* 初始化商品
*/
const initGoods = async () => {
let submit = JSON.parse(
JSON.stringify(
Object.assign(params.value, {
pageSize: props.pageSize,
categoryId: props.categoryId,
storeId: props.storeId,
})
)
)
Object.keys(submit).map((key) => {
if (!submit[key] || (submit[key] as any).length == 0) {
delete submit[key]
}
})
let res = await getGoodsList(submit)
goodsList.value.push(...(res.data.result.records as any[]))
}
const handleClick = (item: any) => {
uni.navigateTo({
url: `/pages/product/goods?id=${item.id}&goodsId=${item.goodsId}`,
})
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@@ -100,10 +90,6 @@ $w_94: 94%;
border-top-left-radius: 20rpx; border-top-left-radius: 20rpx;
border-top-right-radius: 20rpx; border-top-right-radius: 20rpx;
overflow: hidden; overflow: hidden;
> img {
width: 100%;
height: 100%;
}
} }
.goods-desc { .goods-desc {
border-bottom-left-radius: 20rpx; border-bottom-left-radius: 20rpx;
@@ -134,4 +120,4 @@ $w_94: 94%;
} }
} }
} }
</style> </style>

View File

@@ -1,17 +1,23 @@
<template> <template>
<view class="serach"> <view class="serach">
<view class="left-box" @tap="onClickLeft"> <view class="left-box" @tap="onClickLeft">
<u-icon name="arrow-left" size="40" color="#666"></u-icon> <u-icon name="arrow-left" size="28rpx" color="#606266"></u-icon>
</view> </view>
<view class="content" :style="{ 'border-radius': radius + 'px' }"> <view class="content" :style="{ 'border-radius': radius + 'px' }">
<!-- HM修改 增加进入输入状态的点击范围 --> <!-- HM修改 增加进入输入状态的点击范围 -->
<view class="content-box" :class="{ center: mode === 2 }"> <view class="content-box" :class="{ center: mode === 2 }">
<u-icon name="search" size="32" style="padding:0 15rpx;"></u-icon> <u-icon name="search" size="30rpx" color="#909399" style="padding:0 14rpx;"></u-icon>
<!-- HM修改 增加placeholder input confirm-type confirm--> <!-- HM修改 增加placeholder input confirm-type confirm-->
<input style="width:100%; " :placeholder="placeholder" placeholder-class="placeholder-color" <input style="width:100%; " :placeholder="placeholder" placeholder-class="placeholder-color"
@input="inputChange" confirm-type="search" @confirm="triggerConfirm" class="input" @input="inputChange" confirm-type="search" @confirm="triggerConfirm" class="input"
:class="{ center: !active && mode === 2 }" :focus="isFocus" v-model="inputVal" @focus="focus" @blur="blur" /> :class="{ center: !active && mode === 2 }" :focus="isFocus" v-model="inputVal" @focus="focus" @blur="blur" />
<u-icon name="close" v-if="isDelShow" style="padding:0 30rpx;" @click="clear"></u-icon> <view
class="clear-icon"
v-if="showClear && isDelShow"
@tap.stop.prevent="clear"
>
<u-icon name="close" size="28rpx" color="#909399"></u-icon>
</view>
</view> </view>
</view> </view>
@@ -21,204 +27,214 @@
</view> </view>
<view v-else class="button-item"> <view v-else class="button-item">
<u-icon name="grid-fill" size="50" @click="handelListClass()" v-if="!switchLayout"></u-icon> <u-icon name="grid-fill" size="32rpx" color="var(--theme-light, #ff6b35)" @click="handelListClass()" v-if="!switchLayout"></u-icon>
<u-icon v-else @click="handelListClass()" name="list-dot" size="50"></u-icon> <u-icon v-else @click="handelListClass()" name="list-dot" size="32rpx" color="var(--theme-light, #ff6b35)"></u-icon>
</view> </view>
</view> </view>
</view> </view>
</template> </template>
<script> <script setup lang="ts">
export default { import { ref, watch, onMounted } from 'vue'
props: {
mode: {
value: Number,
default: 1,
},
//HM修改 定义默认搜索关键词(水印文字)
placeholder: {
value: String,
default: "请输入搜索内容",
},
value: {
type: String,
default: "",
},
// 默认半径为60
radius: {
value: String,
default: 60,
},
// 是否获取焦点
isFocusVal: {
value: Boolean,
default: true,
},
},
data() {
return {
isShowSeachGoods: false, //是否显示查询的商品
active: false, //是否选中
inputVal: "", //Input中内容
isDelShow: false, //是否显示右侧删除icon
isFocus: false, //是否获取焦点
switchLayout: true, //切换当前商品的布局,默认为两列
};
},
mounted() {
this.isFocus = this.isFocusVal;
},
methods: {
//
out() {
uni.reLaunch({
url: "/pages/tabbar/home/index",
});
},
// 切换排列顺序
handelListClass() {
this.switchLayout = !this.switchLayout;
this.$emit("SwitchType");
},
//HM修改 触发组件confirm事件
triggerConfirm() {
this.$emit("confirm", false);
uni.hideKeyboard();
},
//HM修改 触发组件input事件
inputChange(event) {
var keyword = event.detail.value;
this.$emit("input", keyword);
if (this.inputVal) {
this.isDelShow = true;
}
},
focus() {
this.active = true;
//HM修改 增加获取焦点判断
if (this.inputVal) {
this.isDelShow = true;
}
},
blur() {
this.isFocus = false;
if (!this.inputVal) {
this.active = false;
}
},
clear() {
//HM修改 收起键盘
uni.hideKeyboard();
this.isFocus = false;
this.inputVal = "";
this.active = false;
//HM修改 清空内容时候触发组件input
this.$emit("input", "");
//this.$emit('search', '');//HM修改 清空内容时候不进行搜索
},
/** const props = withDefaults(defineProps<{
* 回退到上一级 mode?: number
*/ placeholder?: string
onClickLeft() { modelValue?: string
const paths = getCurrentPages(); value?: string
console.log(paths) radius?: string
if(paths.length > 1){ isFocusVal?: boolean
uni.navigateBack(); showClear?: boolean
}else{ }>(), {
uni.switchTab({ mode: 1,
url:"/pages/tabbar/home/index" placeholder: "请输入搜索内容",
}) modelValue: "",
} value: "",
}, radius: "60",
isFocusVal: true,
showClear: true,
})
/** const emit = defineEmits(['confirm', 'input', 'update:modelValue', 'search', 'SwitchType'])
* 内容为空时,输入默认关键字
*/ const isShowSeachGoods = ref(false)
search() { const active = ref(false)
if (!this.inputVal) { const inputVal = ref("")
if (this.searchName == "取消") { const isDelShow = ref(false)
uni.hideKeyboard(); const isFocus = ref(false)
this.isFocus = false; const switchLayout = ref(true)
this.active = false;
return; onMounted(() => {
} isFocus.value = props.isFocusVal
} inputVal.value = props.modelValue || props.value || ''
this.$emit("search", this.inputVal ? this.inputVal : this.placeholder); })
},
}, //
watch: { const out = () => {
/** uni.reLaunch({
* 监听当前是否有值 是否显示清除图标 url: "/pages/tabbar/home/index",
*/ })
inputVal(newVal) { }
newVal ? (this.isDelShow = true) : (this.isDelShow = false); // 切换排列顺序
}, const handelListClass = () => {
}, switchLayout.value = !switchLayout.value
}; emit("SwitchType")
}
//HM修改 触发组件confirm事件
const triggerConfirm = () => {
emit("confirm", false)
uni.hideKeyboard()
}
//HM修改 触发组件input事件
const inputChange = (event: any) => {
var keyword = event.detail.value
emit("input", keyword)
emit("update:modelValue", keyword)
if (inputVal.value) {
isDelShow.value = true
}
}
const focus = () => {
active.value = true
//HM修改 增加获取焦点判断
if (inputVal.value) {
isDelShow.value = true
}
}
const blur = () => {
isFocus.value = false
if (!inputVal.value) {
active.value = false
}
}
const clear = () => {
//HM修改 收起键盘
uni.hideKeyboard()
isFocus.value = false
inputVal.value = ""
active.value = false
isDelShow.value = false
//HM修改 清空内容时候触发组件input
emit("input", "")
emit("update:modelValue", "")
//this.$emit('search', '');//HM修改 清空内容时候不进行搜索
}
const setInputValue = (value: string) => {
inputVal.value = value || ''
emit("input", inputVal.value)
emit("update:modelValue", inputVal.value)
}
/**
* 回退到上一级
*/
const onClickLeft = () => {
const paths = getCurrentPages()
console.log(paths)
if(paths.length > 1){
uni.navigateBack()
}else{
uni.switchTab({
url:"/pages/tabbar/home/index"
})
}
}
/**
* 内容为空时,输入默认关键字
*/
const search = () => {
if (!inputVal.value) {
if (false) { // searchName == "取消" - 兼容旧逻辑
uni.hideKeyboard()
isFocus.value = false
active.value = false
return
}
}
emit("search", inputVal.value ? inputVal.value : props.placeholder)
}
/**
* 监听当前是否有值 是否显示清除图标
*/
watch(inputVal, (newVal) => {
newVal ? (isDelShow.value = true) : (isDelShow.value = false)
})
watch(() => props.modelValue, (newVal) => {
if (newVal !== inputVal.value) {
inputVal.value = newVal || ''
}
})
defineExpose({
isShowSeachGoods,
inputVal,
clear,
setInputValue,
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.serach { .serach {
display: flex; display: flex;
width: 100%; width: 100%;
//border-bottom: 1px #f5f5f5 solid; //HM修改 去掉边框 align-items: center;
box-sizing: border-box; box-sizing: border-box;
font-size: $uni-font-size-base; font-size: 24rpx;
.left-box { .left-box {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
width: 15%; flex-shrink: 0;
/* #ifndef APP-NVUE */ width: auto;
text-align: center; padding: 0 8rpx;
// display: flex;
// /* #endif */
} }
.content { .content {
display: flex; display: flex;
align-items: center; align-items: center;
width: 100%; flex: 1;
min-width: 0;
height: 70rpx; height: 70rpx;
color: #999; color: #999;
background: #eee; background: #eee;
overflow: hidden; overflow: hidden;
transition: all 0.2s linear; transition: all 0.2s linear;
border-radius: 1000rpx;
.content-box { .content-box {
width: 100%; width: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
&.center { &.center {
justify-content: center; justify-content: flex-start;
}
.icon {
padding: 0 15rpx;
&.icon-serach:before {
content: "\e61c";
}
} }
.input { .input {
width: 100%; flex: 1;
max-width: 100%; min-width: 0;
width: auto;
line-height: 60rpx; line-height: 60rpx;
height: 60rpx; height: 60rpx;
transition: all 0.2s linear; transition: all 0.2s linear;
&.center { &.center {
width: 200rpx;
}
&.sub {
// position: absolute;
width: auto; width: auto;
color: grey;
} }
} }
.clear-icon {
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
width: 72rpx;
height: 70rpx;
}
} }
} }
@@ -226,16 +242,16 @@ export default {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
position: relative;
flex-shrink: 0; flex-shrink: 0;
width: 0; width: 0;
overflow: hidden;
transition: all 0.2s linear; transition: all 0.2s linear;
white-space: nowrap; white-space: nowrap;
overflow: hidden;
&.active { &.active {
padding-left: 15rpx; padding-left: 12rpx;
width: 100rpx; width: auto;
min-width: 80rpx;
} }
} }
} }

View File

@@ -1,6 +1,6 @@
<template> <template>
<!-- 遮罩层 --> <!-- 遮罩层 -->
<u-popup @close="close" v-model="show" mode="bottom" border-radius="30" height="260rpx"> <u-popup @close="close" v-model:show="show" mode="bottom" border-radius="30" height="260rpx">
<view class="share-title"> <view class="share-title">
<span>分享至</span> <span>分享至</span>
@@ -15,130 +15,138 @@
<!-- #endif --> <!-- #endif -->
<!-- #ifdef APP-PLUS --> <!-- #ifdef APP-PLUS -->
<view class="share-item" @click="handleShare(item)" v-for="(item, index) in list" :key="index"> <view class="share-item" @click="handleShare(item)" v-for="(item, index) in list" :key="index">
<u-icon :color="item.color" size="80" :name="item.icon"></u-icon> <u-icon class="share-icon" :color="item.color" size="80" :name="item.icon"></u-icon>
<view>{{ item.title }}</view> <view class="share-label">{{ item.title }}</view>
</view> </view>
<!-- #endif --> <!-- #endif -->
<!-- #ifdef H5 --> <!-- #ifdef H5 -->
<view class="share-item" @click="copyLink()"> <view class="share-item" @click="copyLink()">
<u-icon color="#b4aee8" size="80" name="share-fill"></u-icon> <u-icon class="share-icon" color="#b4aee8" size="80" name="share-fill"></u-icon>
<view>{{ '复制链接' }}</view> <view class="share-label">{{ '复制链接' }}</view>
</view> </view>
<!-- #endif --> <!-- #endif -->
</view> </view>
</u-popup> </u-popup>
</template> </template>
<script>
import { h5Copy } from "@/js_sdk/h5-copy/h5-copy.js";
import configs from "@/config/config";
import mpShare from "uview-ui/libs/mixin/mpShare.js";
export default { <script setup lang="ts">
mixins: [mpShare], import { ref } from 'vue'
data() { import configs from "@/config/config"
return { import mpShare from "@/utils/mpShare.js"
configs, import { setClipboard } from "@/utils/filters.js"
show: true,
list: [ // mixin 处理:mpShare 提供小程序分享能力
{ mpShare
color: "#04BE02",
title: "微信好友", const props = defineProps<{
icon: "weixin-fill", thumbnail?: string
type: 0, goodsName?: string
}, type?: string
{ goodsId?: string | number
color: "#04BE02", link?: string
title: "朋友圈", }>()
icon: "weixin-circle-fill",
type: 1, const emit = defineEmits(['close'])
},
], const show = ref(true)
}; const config = configs
const list = ref([
{
color: "#04BE02",
title: "微信好友",
icon: "weixin-fill",
type: 0,
}, },
// 图片缩略图、 商品名称 、 type(goods,shop,pintuan) 拼团商品分享以及店铺分享 {
color: "#04BE02",
props: ["thumbnail", "goodsName", "type", "goodsId", "link"], title: "朋友圈",
methods: { icon: "weixin-circle-fill",
close() { type: 1,
this.$emit("close");
},
weChatShare(){
this.$u.mpShare = {
title: this.shareTitle(), // 默认为小程序名称,可自定义
path: '', // 默认为当前页面路径,一般无需修改,QQ小程序不支持
// 分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径。
// 支持PNG及JPG,默认为当前页面的截图
imageUrl: this.thumbnail ||''
}
},
// h5复制链接
// #ifdef H5
copyLink() {
let content;
if (this.link) {
content = this.configs.shareLink + this.link;
} else {
content =
this.configs.shareLink +
getCurrentPages()[getCurrentPages().length - 1].__page__.fullPath;
}
this.$options.filters.setClipboard(content)
},
// #endif
shareTitle() {
let shareTitle;
if (this.type == "goods") {
shareTitle = `[好友推荐]${this.goodsName}快来跟我一起看看吧`;
} else if (this.type == "shops") {
shareTitle = `[好友发现]${this.goodsName}快来跟我一起看看吧`;
} else if (this.type == "pintuan") {
shareTitle = `[好友邀请]${this.goodsName}快来跟我一起抢购吧!`;
} else if (this.type == "kanjia") {
shareTitle = `[好友邀请]请快来帮我砍一刀${this.goodsName}`;
}
return shareTitle;
},
// #ifdef APP-PLUS
handleShare(val) {
console.log("12312312")
if (val.type <= 1) {
let scene; // "WXSenceTimeline 朋友圈 WXSceneSession 微信好友"
val.type == 1
? (scene = "WXSenceTimeline")
: (scene = "WXSceneSession");
uni.share({
provider: "weixin",
scene: scene,
href: configs.shareLink + this.link,
imageUrl: this.thumbnail,
type: 0,
summary: this.goodsName,
title: this.shareTitle(),
success: function (res) {
uni.showToast({
title: "分享成功!",
duration: 2000,
icon: "none",
});
this.$emit("close");
},
fail: function (err) {
uni.showToast({
title: "分享失败!",
duration: 2000,
icon: "none",
});
this.$emit("close");
},
});
}
},
// #endif
}, },
}; ])
const close = () => {
emit("close")
}
const weChatShare = () => {
// @ts-ignore
const proxy = getCurrentInstance()?.proxy
if (proxy) {
// @ts-ignore
proxy.$u.mpShare = {
title: shareTitle(),
path: '',
imageUrl: props.thumbnail || ''
}
}
}
// h5复制链接
// #ifdef H5
const copyLink = () => {
let content: string
if (props.link) {
content = config.shareLink + props.link
} else {
content =
config.shareLink +
getCurrentPages()[getCurrentPages().length - 1].__page__.fullPath
}
setClipboard(content)
}
// #endif
const shareTitle = (): string => {
let shareTitle: string = ''
if (props.type == "goods") {
shareTitle = `[好友推荐]${props.goodsName}快来跟我一起看看吧`
} else if (props.type == "shops") {
shareTitle = `[好友发现]${props.goodsName}快来跟我一起看看吧`
} else if (props.type == "pintuan") {
shareTitle = `[好友邀请]${props.goodsName}快来跟我一起抢购吧!`
} else if (props.type == "kanjia") {
shareTitle = `[好友邀请]请快来帮我砍一刀${props.goodsName}`
}
return shareTitle
}
// #ifdef APP-PLUS
const handleShare = (val: any) => {
console.log("12312312")
if (val.type <= 1) {
let scene: string // "WXSenceTimeline 朋友圈 WXSceneSession 微信好友"
val.type == 1
? (scene = "WXSenceTimeline")
: (scene = "WXSceneSession")
uni.share({
provider: "weixin",
scene: scene,
href: config.shareLink + props.link,
imageUrl: props.thumbnail,
type: 0,
summary: props.goodsName,
title: shareTitle(),
success: function () {
uni.showToast({
title: "分享成功!",
duration: 2000,
icon: "none",
})
emit("close")
},
fail: function () {
uni.showToast({
title: "分享失败!",
duration: 2000,
icon: "none",
})
emit("close")
},
})
}
}
// #endif
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import "./mp-share.scss"; @import "./mp-share.scss";
@@ -155,7 +163,7 @@ export default {
top: 30rpx; top: 30rpx;
} }
} }
button:after { .share-btn:after {
border: none; border: none;
} }
@@ -168,9 +176,10 @@ button:after {
width: 25%; width: 25%;
font-size: 24rpx; font-size: 24rpx;
color: #666; color: #666;
> * { > .share-icon,
> .share-label {
margin: 8rpx 0; margin: 8rpx 0;
} }
} }
} }
</style> </style>

View File

@@ -1,27 +1,21 @@
<template> <template>
<div> <view>
<u-popup v-model="show" mode="bottom" height="800rpx" border-radius="14"> <u-popup v-model:show="show" mode="bottom" height="800rpx" border-radius="14">
<div class="wrapper"> <view class="wrapper">
<view class="down-goods-tips">该商品已下架</view> <view class="down-goods-tips">该商品已下架</view>
<scroll-view scroll-y="true" style="height: 670rpx"> <scroll-view scroll-y="true" style="height: 670rpx">
<goodsRecommend title="其他商品" /> <goodsRecommend title="其他商品" />
</scroll-view> </scroll-view>
</div> </view>
</u-popup> </u-popup>
</div> </view>
</template> </template>
<script> <script setup lang="ts">
import goodsRecommend from "@/components/m-goods-recommend/index.vue"; import { ref } from 'vue'
import goodsRecommend from "@/components/m-goods-recommend/index.vue"
export default { const show = ref(true)
data() {
return {
show: true, // 是否显示
};
},
components: { goodsRecommend },
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@@ -0,0 +1,6 @@
<template><view v-if="quote" class="paid-price" @click.stop="open"><image v-if="quote.label" :src="quote.label" mode="aspectFit" /><text>会员价 ¥{{ Number(quote.price).toFixed(2) }}</text><text v-if="!quote.eligible" class="open">开通享 ›</text></view></template>
<script setup>
defineProps({quote:{type:Object,default:null}})
function open(){uni.navigateTo({url:'/pages/mine/paidMember'})}
</script>
<style scoped>.paid-price{display:flex;align-items:center;flex-wrap:wrap;gap:6rpx;margin-top:8rpx;color:#a77c3e;font-size:22rpx;line-height:1.6}.paid-price image{width:28rpx;height:28rpx}.open{font-size:20rpx;opacity:.8}</style>

View File

@@ -1,343 +0,0 @@
<template>
<view class="shadow" :class="!show?'':'shadow-show'" :style="{backgroundColor:show?maskBg:'rgba(0,0,0,0)'}" @tap="tapMask">
<view class="popups" :class="[theme]" :style="{top: popupsTop ,left: popupsLeft,flexDirection:direction}">
<text :class="dynPlace" :style="{width:'0px',height:'0px'}" v-if="triangle"></text>
<view v-for="(item,index) in popData" :key="index" @tap.stop="tapItem(item)" class="itemChild view" :class="[direction=='row'?'solid-right':'solid-bottom',item.disabled?'disabledColor':'']">
<u-icon size="35" :name="item.icon" v-if="item.icon"></u-icon><span class="title">{{item.title}}</span>
</view>
<slot></slot>
</view>
</view>
</template>
<script>
export default {
props: {
maskBg: {
type: String,
default: "rgba(0,0,0,0)",
},
placement: {
type: String,
default: "default", //default top-start top-end bottom-start bottom-end
},
direction: {
type: String,
default: "column", //column row
},
x: {
type: Number,
default: 0,
},
y: {
type: Number,
default: 0,
},
value: {
type: Boolean,
default: false,
},
popData: {
type: Array,
default: () => [],
},
theme: {
type: String,
default: "light", //light dark
},
dynamic: {
type: Boolean,
default: false,
},
gap: {
type: Number,
default: 20,
},
triangle: {
type: Boolean,
default: true,
},
},
data() {
return {
popupsTop: "0rpx",
popupsLeft: "0rpx",
show: false,
dynPlace: "",
};
},
mounted() {
this.popupsPosition();
},
methods: {
tapMask() {
this.$emit("input", !this.value);
},
tapItem(item) {
if (item.disabled) return;
this.$emit("tapPopup", item);
this.$emit("input", !this.value);
},
getStatusBar() {
let promise = new Promise((resolve, reject) => {
uni.getSystemInfo({
success: function (e) {
let customBar;
// #ifdef H5
customBar = e.statusBarHeight + e.windowTop;
// #endif
resolve(customBar);
},
});
});
return promise;
},
async popupsPosition() {
let statusBar = await this.getStatusBar();
let promise = new Promise((resolve, reject) => {
let popupsDom = uni.createSelectorQuery().in(this).select(".popups");
popupsDom
.fields(
{
size: true,
},
(data) => {
let width = data.width;
let height = data.height;
let y = this.dynamic
? this.dynamicGetY(this.y, this.gap)
: this.transformRpx(this.y);
let x = this.dynamic
? this.dynamicGetX(this.x, this.gap)
: this.transformRpx(this.x);
// #ifdef H5
y = this.dynamic
? this.y + statusBar
: this.transformRpx(this.y + statusBar);
// #endif
this.dynPlace =
this.placement == "default"
? this.getPlacement(x, y)
: this.placement;
switch (this.dynPlace) {
case "top-start":
this.popupsTop = `${y + 9}rpx`;
this.popupsLeft = `${x - 15}rpx`;
break;
case "top-end":
this.popupsTop = `${y + 9}rpx`;
this.popupsLeft = `${x + 15 - width}rpx`;
break;
case "bottom-start":
this.popupsTop = `${y - 18 - height}rpx`;
this.popupsLeft = `${x - 15}rpx`;
break;
case "bottom-end":
this.popupsTop = `${y - 9 - height}rpx`;
this.popupsLeft = `${x + 15 - width}rpx`;
break;
}
resolve();
}
)
.exec();
});
return promise;
},
getPlacement(x, y) {
let width = uni.getSystemInfoSync().windowWidth;
let height = uni.getSystemInfoSync().windowHeight;
if (x > width / 2 && y > height / 2) {
return "bottom-end";
} else if (x < width / 2 && y < height / 2) {
return "top-start";
} else if (x > width / 2 && y < height / 2) {
return "top-end";
} else if (x < width / 2 && y > height / 2) {
return "bottom-start";
} else if (x > width / 2) {
return "top-end";
} else {
return "top-start";
}
},
dynamicGetY(y, gap) {
let height = uni.getSystemInfoSync().windowHeight;
y = y < gap ? gap : y;
y = height - y < gap ? height - gap : y;
return y;
},
dynamicGetX(x, gap) {
let width = uni.getSystemInfoSync().windowWidth;
x = x < gap ? gap : x;
x = width - x < gap ? width - gap : x;
return x;
},
transformRpx(params) {
return (params * uni.getSystemInfoSync().screenWidth) / 375;
},
},
watch: {
value: {
immediate: true,
handler: async function (newVal, oldVal) {
if (newVal) await this.popupsPosition();
this.show = newVal;
},
},
placement: {
immediate: true,
handler(newVal, oldVal) {
this.dynPlace = newVal;
},
},
},
};
</script>
<style lang="scss" scoped>
.title {
margin-left: 20rpx;
}
.shadow {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
height: 100%;
z-index: 9999;
transition: background 0.3s ease-in-out;
visibility: hidden;
&.shadow-show {
visibility: visible;
}
}
.popups {
position: absolute;
padding: 20rpx;
border-radius: 5px;
display: flex;
.view {
display: flex;
align-items: center;
padding: 15rpx 10rpx;
font-size: 25rpx;
}
.image {
display: inline-block;
vertical-align: middle;
width: 40rpx;
height: 40rpx;
margin-right: 20rpx;
}
}
.dark {
background-color: #4c4c4c;
color: #fff;
.top-start:after {
content: "";
position: absolute;
top: -18rpx;
left: 10rpx;
border-width: 0 20rpx 20rpx;
border-style: solid;
border-color: transparent transparent #4c4c4c;
}
.top-end:after {
content: "";
position: absolute;
top: -18rpx;
right: 10rpx;
border-width: 0 20rpx 20rpx;
border-style: solid;
border-color: transparent transparent #4c4c4c;
}
.bottom-start:after {
content: "";
position: absolute;
bottom: -18rpx;
left: 10rpx;
border-width: 20rpx 20rpx 0;
border-style: solid;
border-color: #4c4c4c transparent transparent;
}
.bottom-end:after {
content: "";
position: absolute;
bottom: -18rpx;
right: 10rpx;
border-width: 20rpx 20rpx 0;
border-style: solid;
border-color: #4c4c4c transparent transparent;
}
.disabledColor {
color: #c5c8ce;
}
}
.light {
color: #515a6e;
box-shadow: 0upx 0upx 30upx rgba(0, 0, 0, 0.2);
background: #fff;
.top-start:after {
content: "";
position: absolute;
top: -18rpx;
left: 10rpx;
border-width: 0 20rpx 20rpx;
border-style: solid;
border-color: transparent transparent #fff;
}
.top-end:after {
content: "";
position: absolute;
top: -18rpx;
right: 10rpx;
border-width: 0 20rpx 20rpx;
border-style: solid;
border-color: transparent transparent #fff;
}
.bottom-start:after {
content: "";
position: absolute;
bottom: -18rpx;
left: 10rpx;
border-width: 20rpx 20rpx 0;
border-style: solid;
border-color: #fff transparent transparent;
}
.bottom-end:after {
content: "";
position: absolute;
bottom: -18rpx;
right: 10rpx;
border-width: 20rpx 20rpx 0;
border-style: solid;
border-color: #fff transparent transparent;
}
.disabledColor {
color: #c5c8ce;
}
}
.solid-bottom {
border-bottom: 1px solid #f3f5f7;
}
.solid-right {
border-right: 1px solid #ccc;
}
.popups .itemChild:last-child {
border: none;
}
</style>

View File

@@ -0,0 +1,78 @@
<template>
<view class="u-time-line-item">
<view class="u-time-line-item__node" :style="nodeStyle">
<slot name="node">
<view class="u-time-line-item__dot" :style="{ backgroundColor: bgColor }"></view>
</slot>
</view>
<view class="u-time-line-item__content">
<slot name="content" />
</view>
</view>
</template>
<script setup lang="ts">
import { computed } from 'vue'
const props = defineProps<{
nodeTop?: string | number
bgColor?: string
}>()
const nodeStyle = computed(() => {
if (props.nodeTop === '' || props.nodeTop === null || props.nodeTop === undefined) {
return {}
}
const top = typeof props.nodeTop === 'number' ? `${props.nodeTop}rpx` : props.nodeTop
return { top }
})
</script>
<style lang="scss" scoped>
.u-time-line-item {
display: flex;
flex-direction: row;
position: relative;
padding-bottom: 32rpx;
&:last-child {
padding-bottom: 0;
}
&__node {
position: relative;
width: 32rpx;
display: flex;
justify-content: center;
flex-shrink: 0;
z-index: 1;
}
&__dot {
width: 16rpx;
height: 16rpx;
border-radius: 50%;
background-color: #ddd;
}
&__content {
flex: 1;
padding-left: 12rpx;
}
&::before {
content: '';
position: absolute;
left: 15rpx;
top: 0;
bottom: 0;
width: 1px;
background-color: #ddd;
}
&:last-child::before {
bottom: auto;
height: 16rpx;
}
}
</style>

View File

@@ -0,0 +1,16 @@
<template>
<view class="u-time-line">
<slot />
</view>
</template>
<script setup lang="ts">
// UTimeLine 组件
</script>
<style lang="scss" scoped>
.u-time-line {
display: flex;
flex-direction: column;
}
</style>

View File

@@ -2,22 +2,22 @@
<view class="uni-load-more"> <view class="uni-load-more">
<view class="uni-load-more__img" v-show="status === 'loading' && showIcon"> <view class="uni-load-more__img" v-show="status === 'loading' && showIcon">
<view class="load1"> <view class="load1">
<view :style="{ background: color }"></view> <view class="load-item" :style="{ background: color }"></view>
<view :style="{ background: color }"></view> <view class="load-item" :style="{ background: color }"></view>
<view :style="{ background: color }"></view> <view class="load-item" :style="{ background: color }"></view>
<view :style="{ background: color }"></view> <view class="load-item" :style="{ background: color }"></view>
</view> </view>
<view class="load2"> <view class="load2">
<view :style="{ background: color }"></view> <view class="load-item" :style="{ background: color }"></view>
<view :style="{ background: color }"></view> <view class="load-item" :style="{ background: color }"></view>
<view :style="{ background: color }"></view> <view class="load-item" :style="{ background: color }"></view>
<view :style="{ background: color }"></view> <view class="load-item" :style="{ background: color }"></view>
</view> </view>
<view class="load3"> <view class="load3">
<view :style="{ background: color }"></view> <view class="load-item" :style="{ background: color }"></view>
<view :style="{ background: color }"></view> <view class="load-item" :style="{ background: color }"></view>
<view :style="{ background: color }"></view> <view class="load-item" :style="{ background: color }"></view>
<view :style="{ background: color }"></view> <view class="load-item" :style="{ background: color }"></view>
</view> </view>
</view> </view>
<text class="uni-load-more__text" :style="{ color: color }" v-if="showText"> <text class="uni-load-more__text" :style="{ color: color }" v-if="showText">
@@ -26,42 +26,28 @@
</view> </view>
</template> </template>
<script> <script setup lang="ts">
export default { withDefaults(defineProps<{
name: 'uni-load-more', status?: string
props: { showIcon?: boolean
status: { showText?: boolean
//上拉的状态:more-loading前;loading-loading中;noMore-没有更多了 color?: string
type: String, contentText?: {
default: 'more' contentdown: string
}, contentrefresh: string
showIcon: { contentnomore: string
type: Boolean,
default: true
},
showText: {
type: Boolean,
default: true
},
color: {
type: String,
default: '#777777'
},
contentText: {
type: Object,
default() {
return {
contentdown: '上拉显示更多',
contentrefresh: '正在加载...',
contentnomore: '没有更多数据了'
};
}
}
},
data() {
return {};
} }
}; }>(), {
status: 'more',
showIcon: true,
showText: true,
color: '#777777',
contentText: () => ({
contentdown: '上拉显示更多',
contentrefresh: '正在加载...',
contentnomore: '没有更多数据了',
}),
})
</script> </script>
<style> <style>
@@ -86,11 +72,13 @@ export default {
margin-right: 10px; margin-right: 10px;
} }
.uni-load-more__img > view { .load1,
.load2,
.load3 {
position: absolute; position: absolute;
} }
.uni-load-more__img > view view { .load-item {
width: 6px; width: 6px;
height: 2px; height: 2px;
border-top-left-radius: 1px; border-top-left-radius: 1px;
@@ -102,25 +90,25 @@ export default {
animation: load 1.56s ease infinite; animation: load 1.56s ease infinite;
} }
.uni-load-more__img > view view:nth-child(1) { .load-item:nth-child(1) {
transform: rotate(90deg); transform: rotate(90deg);
top: 2px; top: 2px;
left: 9px; left: 9px;
} }
.uni-load-more__img > view view:nth-child(2) { .load-item:nth-child(2) {
transform: rotate(180deg); transform: rotate(180deg);
top: 11px; top: 11px;
right: 0; right: 0;
} }
.uni-load-more__img > view view:nth-child(3) { .load-item:nth-child(3) {
transform: rotate(270deg); transform: rotate(270deg);
bottom: 2px; bottom: 2px;
left: 9px; left: 9px;
} }
.uni-load-more__img > view view:nth-child(4) { .load-item:nth-child(4) {
top: 11px; top: 11px;
left: 0; left: 0;
} }
@@ -140,51 +128,51 @@ export default {
transform: rotate(60deg); transform: rotate(60deg);
} }
.load1 view:nth-child(1) { .load1 .load-item:nth-child(1) {
animation-delay: 0s; animation-delay: 0s;
} }
.load2 view:nth-child(1) { .load2 .load-item:nth-child(1) {
animation-delay: 0.13s; animation-delay: 0.13s;
} }
.load3 view:nth-child(1) { .load3 .load-item:nth-child(1) {
animation-delay: 0.26s; animation-delay: 0.26s;
} }
.load1 view:nth-child(2) { .load1 .load-item:nth-child(2) {
animation-delay: 0.39s; animation-delay: 0.39s;
} }
.load2 view:nth-child(2) { .load2 .load-item:nth-child(2) {
animation-delay: 0.52s; animation-delay: 0.52s;
} }
.load3 view:nth-child(2) { .load3 .load-item:nth-child(2) {
animation-delay: 0.65s; animation-delay: 0.65s;
} }
.load1 view:nth-child(3) { .load1 .load-item:nth-child(3) {
animation-delay: 0.78s; animation-delay: 0.78s;
} }
.load2 view:nth-child(3) { .load2 .load-item:nth-child(3) {
animation-delay: 0.91s; animation-delay: 0.91s;
} }
.load3 view:nth-child(3) { .load3 .load-item:nth-child(3) {
animation-delay: 1.04s; animation-delay: 1.04s;
} }
.load1 view:nth-child(4) { .load1 .load-item:nth-child(4) {
animation-delay: 1.17s; animation-delay: 1.17s;
} }
.load2 view:nth-child(4) { .load2 .load-item:nth-child(4) {
animation-delay: 1.3s; animation-delay: 1.3s;
} }
.load3 view:nth-child(4) { .load3 .load-item:nth-child(4) {
animation-delay: 1.43s; animation-delay: 1.43s;
} }

View File

@@ -10,211 +10,183 @@
</view> </view>
</view> </view>
</template> </template>
<script>
/**
* NumberBox 数字输入框
* @description 带加减按钮的数字输入框
* @tutorial https://ext.dcloud.net.cn/plugin?id=31
* @property {Number} value 输入框当前值
* @property {Number} min 最小值
* @property {Number} max 最大值
* @property {Number} step 每次点击改变的间隔大小
* @property {String} background 背景色
* @property {String} color 字体颜色(前景色)
* @property {Boolean} disabled = [true|false] 是否为禁用状态
* @event {Function} change 输入框值改变时触发的事件,参数为输入框当前的 value
* @event {Function} focus 输入框聚焦时触发的事件,参数为 event 对象
* @event {Function} blur 输入框失焦时触发的事件,参数为 event 对象
*/
export default { <script setup lang="ts">
name: "UniNumberBox", import { ref, watch } from 'vue'
emits: ['change', 'input', 'update:modelValue', 'blur', 'focus'],
props: {
value: {
type: [Number, String],
default: 1
},
modelValue: {
type: [Number, String],
default: 1
},
min: {
type: Number,
default: 0
},
max: {
type: Number,
default: 100
},
step: {
type: Number,
default: 1
},
background: {
type: String,
default: '#f5f5f5'
},
color: {
type: String,
default: '#333'
},
disabled: {
type: Boolean,
default: false
}
},
data() {
return {
inputValue: 0
};
},
watch: {
value(val) {
this.inputValue = +val;
},
modelValue(val) {
this.inputValue = +val;
}
},
created() {
if (this.value === 1) {
this.inputValue = +this.modelValue;
}
if (this.modelValue === 1) {
this.inputValue = +this.value;
}
},
methods: {
_calcValue(type) {
if (this.disabled) {
return;
}
const scale = this._getDecimalScale();
let value = this.inputValue * scale;
let step = this.step * scale;
if (type === "minus") {
value -= step;
if (value < (this.min * scale)) {
return;
}
if (value > (this.max * scale)) {
value = this.max * scale
}
}
if (type === "plus") { const props = withDefaults(defineProps<{
value += step; value?: number | string
if (value > (this.max * scale)) { modelValue?: number | string
return; min?: number
} max?: number
if (value < (this.min * scale)) { step?: number
value = this.min * scale background?: string
} color?: string
} disabled?: boolean
}>(), {
value: 1,
modelValue: 1,
min: 0,
max: 100,
step: 1,
background: '#f5f5f5',
color: '#333',
disabled: false,
})
this.inputValue = (value / scale).toFixed(String(scale).length - 1); const emit = defineEmits<{
this.$emit("change", +this.inputValue); change: [value: number]
// TODO vue2 兼容 input: [value: number]
this.$emit("input", +this.inputValue); 'update:modelValue': [value: number]
// TODO vue3 兼容 blur: [event: Event]
this.$emit("update:modelValue", +this.inputValue); focus: [event: Event]
}, }>()
_getDecimalScale() {
let scale = 1; const inputValue = ref(0)
// 浮点型
if (~~this.step !== this.step) { watch(() => props.value, (val) => {
scale = Math.pow(10, String(this.step).split(".")[1].length); inputValue.value = +val
} })
return scale;
}, watch(() => props.modelValue, (val) => {
_onBlur(event) { inputValue.value = +val
this.$emit('blur', event) })
let value = event.detail.value;
if (!value) { if (props.value === 1) {
// this.inputValue = 0; inputValue.value = +props.modelValue
return; }
} if (props.modelValue === 1) {
value = +value; inputValue.value = +props.value
if (value > this.max) { }
value = this.max;
} else if (value < this.min) { function _getDecimalScale() {
value = this.min; let scale = 1
} if (~~props.step !== props.step) {
const scale = this._getDecimalScale(); scale = Math.pow(10, String(props.step).split('.')[1].length)
this.inputValue = value.toFixed(String(scale).length - 1); }
this.$emit("change", +this.inputValue); return scale
this.$emit("input", +this.inputValue); }
},
_onFocus(event) { function _emitValue() {
this.$emit('focus', event) const val = +inputValue.value
} emit('change', val)
emit('input', val)
emit('update:modelValue', val)
}
function _calcValue(type: 'minus' | 'plus') {
if (props.disabled) {
return
}
const scale = _getDecimalScale()
let value = inputValue.value * scale
const step = props.step * scale
if (type === 'minus') {
value -= step
if (value < props.min * scale) {
return
} }
}; if (value > props.max * scale) {
value = props.max * scale
}
}
if (type === 'plus') {
value += step
if (value > props.max * scale) {
return
}
if (value < props.min * scale) {
value = props.min * scale
}
}
inputValue.value = Number((value / scale).toFixed(String(scale).length - 1))
_emitValue()
}
function _onBlur(event: any) {
emit('blur', event)
let value = event.detail.value
if (!value) {
return
}
value = +value
if (value > props.max) {
value = props.max
} else if (value < props.min) {
value = props.min
}
const scale = _getDecimalScale()
inputValue.value = Number(value.toFixed(String(scale).length - 1))
_emitValue()
}
function _onFocus(event: Event) {
emit('focus', event)
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
$box-height: 48rpx; $box-height: 48rpx;
$bg: #f5f5f5; $bg: #f5f5f5;
$br: 4rpx; $br: 4rpx;
$color: #333; $color: #333;
.uni-numbox { .uni-numbox {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
/* #endif */ /* #endif */
flex-direction: row; flex-direction: row;
} }
.uni-numbox-btns { .uni-numbox-btns {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
/* #endif */ /* #endif */
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
padding: 0 8px; padding: 0 8px;
background-color: $bg; background-color: $bg;
/* #ifdef H5 */ /* #ifdef H5 */
cursor: pointer; cursor: pointer;
/* #endif */ /* #endif */
} }
.uni-numbox__value { .uni-numbox__value {
margin: 0 4rpx; margin: 0 4rpx;
background-color: $bg; background-color: $bg;
width: 70rpx; width: 70rpx;
height: $box-height; height: $box-height;
text-align: center; text-align: center;
font-size: 24rpx; font-size: 24rpx;
border-left-width: 0; border-left-width: 0;
border-right-width: 0; border-right-width: 0;
color: $color; color: $color;
} }
.uni-numbox__minus { .uni-numbox__minus {
border-top-left-radius: $br; border-top-left-radius: $br;
border-bottom-left-radius: $br; border-bottom-left-radius: $br;
} }
.uni-numbox__plus { .uni-numbox__plus {
border-top-right-radius: $br; border-top-right-radius: $br;
border-bottom-right-radius: $br; border-bottom-right-radius: $br;
} }
.uni-numbox--text { .uni-numbox--text {
// fix nvue line-height: 40rpx;
line-height: 40rpx; font-size: 40rpx;
font-weight: 300;
color: $color;
}
font-size: 40rpx; .uni-numbox .uni-numbox--disabled {
font-weight: 300; color: #c0c0c0 !important;
color: $color; /* #ifdef H5 */
} cursor: not-allowed;
/* #endif */
.uni-numbox .uni-numbox--disabled { }
color: #c0c0c0 !important;
/* #ifdef H5 */
cursor: not-allowed;
/* #endif */
}
</style> </style>

View File

@@ -1,111 +1,99 @@
<template></template> <template></template>
<script>
import { getAddressCode } from "@/api/address"; <script setup lang="ts">
import { onMounted } from 'vue'
import { getAddressCode } from '@/api/address'
import config from '@/config/config' import config from '@/config/config'
export default {
data() {
return {
config
};
},
mounted() {
this.init();
},
methods: {
// 初始化地图并且调用
initMap() {
let that = this;
uni.chooseLocation({
success: function (res) {
/**获取地址详情地址 */
that.posToCity(res.latitude, res.longitude).then((val) => {
/**获取地址code */
getAddressCode(
val.regeocode.addressComponent.citycode,
val.regeocode.addressComponent.township
).then((code) => {
that.$emit("callback", { ...val, ...res, ...code });
that.$emit("close");
});
});
},
fail(e) {
console.log(e)
that.$emit("close");
},
});
},
// 根据当前客户端判断展示不同类型数据 const emit = defineEmits<{
init() { callback: [payload: Record<string, any>]
// #ifdef MP-WEIXIN close: []
this.wechatMap(); }>()
// #endif
// #ifndef MP-WEIXIN
this.initMap();
// #endif
},
// 如果是微信小程序单独走微信小程序授权模式 onMounted(() => {
wechatMap() { init()
let that = this; })
uni.authorize({
scope: "scope.userLocation", function initMap() {
success() { uni.chooseLocation({
// 允许授权 success(res) {
that.initMap(); posToCity(res.latitude, res.longitude).then((val) => {
}, getAddressCode(
fail() { val.regeocode.addressComponent.citycode,
//拒绝授权 val.regeocode.addressComponent.township,
uni.showModal({ ).then((code) => {
content: "检测到您没打开获取地址功能权限,是否去设置打开?", emit('callback', { ...val, ...res, ...code })
confirmText: "确认", emit('close')
cancelText: "取消", })
success: (res) => { })
if (res.confirm) { },
// 打开设置好后重新刷新地图 fail(e) {
uni.openSetting({ console.log(e)
success: (res) => { emit('close')
that.initMap(); },
}, })
}); }
} else {
// 取消后关闭 function init() {
that.$emit("close"); // #ifdef MP-WEIXIN
return false; wechatMap()
} // #endif
}, // #ifndef MP-WEIXIN
}); initMap()
return false; // #endif
}, }
});
}, function wechatMap() {
// 获取城市的数据 uni.authorize({
posToCity(latitude, longitude) { scope: 'scope.userLocation',
return new Promise((resolve, reject) => { success() {
uni.request({ initMap()
url: `https://restapi.amap.com/v3/geocode/regeo`, },
method: "GET", fail() {
data: { uni.showModal({
key: config.aMapKey, //web服务的key content: '检测到您没打开获取地址功能权限,是否去设置打开?',
location: `${longitude},${latitude}`, confirmText: '确认',
}, cancelText: '取消',
success: ({ data }) => { success: (res) => {
const { status, info } = data; if (res.confirm) {
if (status === "1") { uni.openSetting({
resolve(data); success: () => {
} else { initMap()
reject(info); },
} })
}, } else {
fail: (err) => { emit('close')
reject(err); }
}, },
}); })
}); },
}, })
}, }
};
function posToCity(latitude: number, longitude: number) {
return new Promise<any>((resolve, reject) => {
uni.request({
url: 'https://restapi.amap.com/v3/geocode/regeo',
method: 'GET',
data: {
key: config.aMapKey,
location: `${longitude},${latitude}`,
},
success: ({ data }: any) => {
const { status, info } = data
if (status === '1') {
resolve(data)
} else {
reject(info)
}
},
fail: (err) => {
reject(err)
},
})
})
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
</style> </style>

View File

@@ -1,284 +1,356 @@
<template> <template>
<view> <view>
<view <view
v-if="!hid" v-if="!state.hid"
class="flex-row-center" class="flex-row-center"
:style="{ top: scHight }" :style="{ top: state.scHight }"
style="width: 750rpx; position: fixed; z-index: 100; left: 0" style="width: 750rpx; position: fixed; z-index: 100; left: 0; background-color: #ffffff; padding: 40rpx 0"
> >
<view <view class="flex-column-center">
class="flex-column-center"
style="background-color: #fcfcfc; padding: 30rpx; border-radius: 10rpx"
>
<movable-area <movable-area
class="flex" class="flex"
style="width: 100%" style="width: 100%"
animation="false" animation="false"
:style="{ height: originalHeight }" :style="{ height: state.originalHeight }"
> >
<movable-view <movable-view
scale-value="1" scale-value="1"
animation="false" animation="false"
damping="5000" damping="5000"
:x="moveX" :x="state.moveX"
:style="{ :style="{
height: sliderHeight, height: state.sliderHeight,
width: sliderWidth, width: state.sliderWidth,
'z-index': 101, 'z-index': 101,
}" }"
direction="horizontal" direction="horizontal"
> >
<image <image
:src="imgbk" :src="state.imgbk"
class="image" class="image"
mode="aspectFit" mode="aspectFit"
:style="{ :style="{
height: sliderHeight, height: state.sliderHeight,
width: sliderWidth, width: state.sliderWidth,
'margin-top': imgbKH, 'margin-top': state.imgbKH,
}" }"
></image> ></image>
</movable-view> </movable-view>
<image <image
:src="img" :src="state.img"
mode="aspectFit" mode="aspectFit"
:style="{ height: originalHeight, width: originalWidth }" :style="{ height: state.originalHeight, width: state.originalWidth }"
style="border-radius: 10rpx" style="border-radius: 24rpx"
></image> ></image>
</movable-area> </movable-area>
<movable-area <movable-area class="v-track" animation="false">
class="flex-row-start" <view class="v-fill" :style="{ width: fillWidth }"></view>
style=" <text class="v-track-text" :style="{ color: state.col }">{{
width: 100%; state.hasImg
background-color: #efefef; }}</text>
height: 80rpx;
border-radius: 40rpx;
margin-top: 30rpx;
"
>
<movable-view <movable-view
scale-value="1" scale-value="1"
animation="false" animation="false"
damping="50" damping="50"
:x="movePv" :x="state.movePv"
class="flex-row-center" class="v-handle"
style=" :style="handleStyle"
border-radius: 50%;
height: 100rpx;
width: 100rpx;
background-color: #ffffff;
border: 2rpx solid #e3e3e3;
margin-top: -13rpx;
"
direction="horizontal" direction="horizontal"
@change="moveChange" @change="moveChange"
@touchend="end" @touchend="end"
> >
<u-icon <u-icon
:color="mainColor" color="#ffffff"
size="40" size="38"
v-if="endLoad" v-if="state.endLoad"
name="arrow-right" name="arrow-right"
></u-icon> ></u-icon>
<u-icon :color="mainColor" size="40" v-else name="reload"></u-icon> <u-icon color="#ffffff" size="38" v-else name="reload"></u-icon>
</movable-view> </movable-view>
<text style="padding-left: 140rpx" :style="{ color: col }">{{
hasImg
}}</text>
</movable-area> </movable-area>
<view class="flex-row-around padding-top" style="width: 100%">
<u-icon
@click="hide"
:color="mainColor"
size="40"
name="close"
></u-icon>
<text class="cu-tag round" @click="getCode">刷新拼图</text> <view class="v-foot">
<text class="my-neirong-sm cuIcon-safe" style="color: #c1c1c1" <view class="v-icon-btn" @click="getCode">
>Lili-FRAMEWORK</text <u-icon color="#888888" size="32" name="reload"></u-icon>
> </view>
<view class="v-icon-btn" @click="hide">
<u-icon color="#888888" size="30" name="close"></u-icon>
</view>
</view>
<view class="v-mark">
<text class="cuIcon-safe v-mark-icon"></text>
<text>Lili-FRAMEWORK 安全验证</text>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</template> </template>
<script> <script setup lang="ts">
import api from "@/config/api.js"; import { reactive, computed } from 'vue'
import storage from "@/utils/storage.js"; import { useStore } from '@/store'
import uuid from "@/utils/uuid.modified.js"; import api from '@/config/api.js'
const phone = uni.getSystemInfoSync(); import storage from '@/utils/storage.js'
const l = phone.screenWidth / 750; import uuid from '@/utils/uuid.modified.js'
export default {
name: "verification", const emit = defineEmits(['send'])
created() { const props = withDefaults(defineProps<{
// 可自行调整 height?: string
this.scHight = phone.screenHeight / 2 - 200 + "px"; width?: string
this.getCode(); left?: string
}, top?: string
props: { business?: string
height: { apiType?: string
type: String, }>(), {
default: "80rpx", height: '80rpx',
width: '350rpx',
left: '180rpx',
top: '30rpx',
business: 'LOGIN',
apiType: 'buyer'
})
const sliderBaseUrl = computed(() => {
return props.apiType === 'store' ? api.store : api.buyer
})
const store = useStore()
const phone = uni.getSystemInfoSync()
const l = phone.screenWidth / 750
const mainColor = computed(() => store.getters.mainColor)
const fillWidth = computed(() => `${state.moveX + 42 * l}px`)
const handleStyle = computed(() => {
const glow = /^#[0-9a-fA-F]{6}$/.test(mainColor.value)
? mainColor.value + '59'
: 'rgba(0, 0, 0, 0.18)'
return { background: mainColor.value, boxShadow: `0 6rpx 20rpx ${glow}` }
})
const state = reactive({
flage: false,
key: '', // key
vsrtx: '点击进行验证', // 按钮提示语
vsr: false,
hid: true,
col: '#838383',
movePv: 0,
hasImg: '拖动滑块已完成拼图',
spcode: '',
tl: 0,
moveCode: 0,
// X轴移动距离
moveX: 0,
// 模版高度
originalHeight: '',
// 模版宽度
originalWidth: '',
// 拼图高度
sliderHeight: '',
// 平涂宽度
sliderWidth: '',
scHight: 0,
// 原图
img: '',
// 拼图
imgbk: '',
endLoad: true,
imgbKH: ''
})
// 可自行调整
state.scHight = phone.screenHeight / 2 - 200 + 'px'
getCode()
function show() {
state.hid = false
}
function hide() {
if (!state.vsr) {
// vsr判断是否验证成功,成功隐藏验证框
state.hid = !state.hid
}
}
function error() {
state.vsr = false
state.hid = false
state.moveX = 0
state.moveCode = 0
}
// 获取验证图片
function getCode() {
state.col = '#b3afae'
state.hasImg = '图片加载中...'
if (!storage.getUuid()) {
storage.setUuid(uuid.v1())
}
uni.request({
url: sliderBaseUrl.value + '/common/slider/' + props.business,
header: {
uuid: storage.getUuid()
}, },
width: { success: (res: any) => {
type: String, state.col = '#838383'
default: "350rpx", state.hasImg = '拖动滑块以完成拼图'
const data = res.data.result
// base64的图片
state.img = data.backImage
state.imgbk = data.slidingImage
// 根据参数动态适应验证图片的高宽
state.imgbKH = data.randomY * 1.8 + 'rpx'
state.originalHeight = data.originalHeight * 1.8 + 'rpx'
state.originalWidth = data.originalWidth * 1.8 + 'rpx'
state.sliderHeight = data.sliderHeight * 1.8 + 'rpx'
state.sliderWidth = data.sliderWidth * 1.8 + 'rpx'
// 适应比率,用来适应滑动距离
state.tl = 1 / (1.8 * l)
// 无用信息
state.spcode = data.capcode
// 验证令牌
state.key = data.key
store.state.verificationKey = data.key
}
})
}
function end() {
state.endLoad = false
// 验证拼图位置是否正确
uni.request({
method: 'POST',
url:
sliderBaseUrl.value +
'/common/slider/' +
props.business +
'?xPos=' +
parseInt(String(state.moveCode * state.tl)),
header: {
uuid: storage.getUuid()
}, },
left: { success: (res: any) => {
type: String, state.endLoad = true
default: "180rpx", if (res.data.result == false) {
}, res.data.result = false
top: { } else {
type: String, res.data.result = true
default: "30rpx", }
},
business: { if (res.data && res.data.result) {
type: String, // 验证成功后把key发送出去,后端会把验证信息存在缓存里
default: "LOGIN", emit('send', state.key)
}, hide()
}, state.vsr = true
data() { state.vsrtx = '已通过验证'
return { } else {
mainColor: this.$mainColor, getCode() // 让滑块回到起始位置
flage: false, if (state.movePv == 1) {
key: "", //key state.movePv = 0
vsrtx: "点击进行验证", //按钮提示语 } else {
vsr: false, // state.movePv = 1
hid: true, }
col: "#838383",
movePv: 0,
hasImg: "拖动滑块已完成拼图",
spcode: "",
tl: 0,
moveCode: 0,
//X轴移动距离
moveX: 0,
//模版高度
originalHeight: "",
//模版宽度
originalWidth: "",
//拼图高度
sliderHeight: "",
//平涂宽度
sliderWidth: "",
scHight: 0,
//原图
img: "",
//拼图
imgbk: "",
endLoad: true,
imgbKH: "",
};
},
methods: {
show() {
this.hid = false;
},
hide() {
if (!this.vsr) {
// vsr判断是否验证成功,成功隐藏验证框
this.hid = !this.hid;
} }
}, },
error() { fail: () => {
this.vsr = false; uni.showToast({ title: '连接服务器失败', icon: 'none' })
this.hid = false; }
this.moveX = 0; })
this.moveCode = 0; }
},
// 获取验证图片
getCode() {
this.col = "#b3afae";
this.hasImg = "图片加载中...";
if (!storage.getUuid()) {
storage.setUuid(uuid.v1());
}
uni.request({
url: api.common + "/common/slider/" + this.business,
header: {
uuid: storage.getUuid(),
},
success: (res) => {
this.col = "#838383";
this.hasImg = "拖动滑块以完成拼图";
var data = res.data.result;
// base64的图片 // 绑定拼图位置
this.img = data.backImage; function moveChange(e: any) {
this.imgbk = data.slidingImage; state.moveX = e.detail.x
// 根据参数动态适应验证图片的高宽 state.moveCode = e.detail.x
this.imgbKH = data.randomY * 1.8 + "rpx"; }
this.originalHeight = data.originalHeight * 1.8 + "rpx";
this.originalWidth = data.originalWidth * 1.8 + "rpx";
this.sliderHeight = data.sliderHeight * 1.8 + "rpx";
this.sliderWidth = data.sliderWidth * 1.8 + "rpx";
// 适应比率,用来适应滑动距离
this.tl = 1 / (1.8 * l);
// 无用信息
this.spcode = data.capcode;
// 验证令牌
this.key = data.key;
this.$store.state.verificationKey = data.key;
},
});
},
end(e) {
this.endLoad = false;
// 验证拼图位置是否正确
uni.request({
method: "POST",
url:
api.common +
"/common/slider/" +
this.business +
"?xPos=" +
parseInt(this.moveCode * this.tl),
header: {
uuid: storage.getUuid(),
},
success: (res) => {
this.endLoad = true;
res.data.result == false
? (res.data.result = false)
: (res.data.result = true);
if (res.data && res.data.result) { defineExpose({
//验证成功后把key发送出去,后端会把验证信息存在缓存里 show,
this.$emit("send", this.key); hide,
this.hide(); error,
this.vsr = true; getCode,
this.vsrtx = "已通过验证"; })
} else {
this.getCode(); // 让滑块回到起始位置
if (this.movePv == 1) {
this.movePv = 0;
} else {
this.movePv = 1;
}
}
},
fail: (res) => {
this.$msg("连接服务器失败");
},
});
},
// 绑定拼图位置
moveChange(e) {
this.moveX = e.detail.x;
this.moveCode = e.detail.x;
},
},
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import "./animation.css"; @import "./animation.css";
@import "./icon.css"; @import "./icon.css";
// @import './main.css'; // @import './main.css';
.v-track {
position: relative;
width: 100%;
height: 84rpx;
margin-top: 36rpx;
background-color: #f7f7f8;
border-radius: 42rpx;
}
.v-fill {
position: absolute;
left: 0;
top: 0;
bottom: 0;
background-color: #ffe9e5;
border-radius: 42rpx;
}
.v-track-text {
position: absolute;
left: 0;
right: 0;
top: 0;
line-height: 84rpx;
text-align: center;
font-size: 26rpx;
letter-spacing: 2rpx;
}
.v-handle {
width: 84rpx;
height: 84rpx;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
}
.v-foot {
display: flex;
flex-direction: row;
justify-content: flex-end;
width: 100%;
margin-top: 28rpx;
}
.v-icon-btn {
width: 68rpx;
height: 68rpx;
border-radius: 50%;
background-color: #f4f4f5;
display: flex;
align-items: center;
justify-content: center;
margin-left: 24rpx;
}
.v-mark {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
margin-top: 32rpx;
font-size: 22rpx;
color: #d2d2d2;
}
.v-mark-icon {
margin-right: 8rpx;
font-size: 22rpx;
color: #d9d9d9;
}
.dh-wt { .dh-wt {
animation: at 1.1s ease; animation: at 1.1s ease;
animation-iteration-count: infinite; animation-iteration-count: infinite;

View File

@@ -2,14 +2,15 @@
<view class="xt__verify-code"> <view class="xt__verify-code">
<!-- 输入框 --> <!-- 输入框 -->
<input <input
ref="codeInput"
id="xt__input" id="xt__input"
:value="code" :value="code"
class="xt__input" class="xt__input"
:focus="isFocus" :focus="focused"
:password="isPassword" :password="isPassword"
:type="inputType" :type="inputType"
:maxlength="size" :maxlength="size"
@input="input" @input="handleInput"
@focus="inputFocus" @focus="inputFocus"
@blur="inputBlur" @blur="inputBlur"
/> />
@@ -23,21 +24,20 @@
></view> ></view>
<!-- 输入框 - 组 --> <!-- 输入框 - 组 -->
<view id="xt__input-ground" class="xt__input-ground"> <view id="xt__input-ground" class="xt__input-ground" @click="focusInput">
<template v-for="(item, index) in size"> <template v-for="(item, index) in size" :key="index">
<view <view
:key="index"
:style="{ borderColor: code.length === index && cursorVisible ? boxActiveColor : boxNormalColor }" :style="{ borderColor: code.length === index && cursorVisible ? boxActiveColor : boxNormalColor }"
:class="['xt__box', `xt__box-${type + ''}`, `xt__box::after`]" :class="['xt__box', `xt__box-${type + ''}`, `xt__box::after`]"
> >
<view :style="{ borderColor: boxActiveColor }" class="xt__middle-line" v-if="type === 'middle' && !code[index]"></view> <view :style="{ borderColor: boxActiveColor }" class="xt__middle-line" v-if="type === 'middle' && !code[index]"></view>
<text class="xt__code-text">{{ code[index] | codeFormat(isPassword) }}</text> <text class="xt__code-text">{{ codeFormat(code[index], isPassword) }}</text>
</view> </view>
</template> </template>
</view> </view>
</view> </view>
</template> </template>
<script> <script setup lang="ts">
/** /**
* @description 输入验证码组件 * @description 输入验证码组件
* @property {string} type = [box|middle|bottom] - 显示类型 默认:box -eg:bottom * @property {string} type = [box|middle|bottom] - 显示类型 默认:box -eg:bottom
@@ -50,151 +50,156 @@
* @property {string} boxActiveColor - 光标聚焦到的框的颜色 默认:#000000 * @property {string} boxActiveColor - 光标聚焦到的框的颜色 默认:#000000
* @event {Function(data)} confirm - 输入完成 * @event {Function(data)} confirm - 输入完成
*/ */
export default { import { ref, watch, onMounted, nextTick, getCurrentInstance } from 'vue'
name: 'xt-verify-code',
props: {
value: {
type: String,
default: () => ''
},
type: {
type: String,
default: () => 'box'
},
inputType: {
type: String,
default: () => 'number'
},
size: {
type: Number,
default: () => 6
},
isFocus: {
type: Boolean,
default: () => true
},
isPassword: {
type: Boolean,
default: () => false
},
cursorColor: {
type: String,
default: () => '#cccccc'
},
boxNormalColor: {
type: String,
default: () => '#cccccc'
},
boxActiveColor: {
type: String,
default: () => '#000000'
}
},
model: {
prop: 'value',
event: 'input'
},
data() {
return {
cursorVisible: false,
cursorHeight: 35,
code: '', // 输入的验证码
codeCursorLeft: [] // 向左移动的距离数组
};
},
created() {
this.cursorVisible = this.isFocus;
},
mounted() {
this.init();
},
methods: {
/**
* @description 初始化
*/
init() {
this.getCodeCursorLeft();
this.setCursorHeight();
},
/**
* @description 获取元素节点
* @param {string} elm - 节点的id、class 相当于 document.querySelect的参数 -eg: #id
* @param {string} type = [single|array] - 单个元素获取多个元素 默认是单个元素
* @param {Function} callback - 回调函数
*/
getElement(elm, type = 'single', callback) {
uni
.createSelectorQuery()
.in(this)
[type === 'array' ? 'selectAll' : 'select'](elm)
.boundingClientRect()
.exec(data => {
callback(data[0]);
});
},
/**
* @description 计算光标的高度
*/
setCursorHeight() {
this.getElement('.xt__box', 'single', boxElm => {
this.cursorHeight = boxElm.height * 0.6;
});
},
/**
* @description 获取光标在每一个box的left位置
*/
getCodeCursorLeft() {
// 获取父级框的位置信息
this.getElement('#xt__input-ground', 'single', parentElm => {
const parentLeft = parentElm.left;
// 获取各个box信息
this.getElement('.xt__box', 'array', elms => {
this.codeCursorLeft = [];
elms.forEach(elm => {
this.codeCursorLeft.push(elm.left - parentLeft + elm.width / 2);
});
});
});
},
// 输入框输入变化的回调 const emit = defineEmits(['update:modelValue', 'input', 'confirm'])
input(e) { const props = withDefaults(defineProps<{
const value = e.detail.value; modelValue?: string
this.cursorVisible = value.length !== this.size; value?: string
this.$emit('input', value); type?: string
this.inputSuccess(value); inputType?: string
}, size?: number
isFocus?: boolean
isPassword?: boolean
cursorColor?: string
boxNormalColor?: string
boxActiveColor?: string
}>(), {
modelValue: '',
value: '',
type: 'box',
inputType: 'number',
size: 6,
isFocus: true,
isPassword: false,
cursorColor: '#cccccc',
boxNormalColor: '#cccccc',
boxActiveColor: '#000000'
})
// 输入完成回调 const instance = getCurrentInstance()
inputSuccess(value) { const codeInput = ref<any>(null)
if (value.length === this.size) { const focused = ref(false)
this.$emit('confirm', value); const cursorVisible = ref(false)
} const cursorHeight = ref(35)
}, const code = ref('') // 输入的验证码
// 输入聚焦 const codeCursorLeft = ref<number[]>([]) // 向左移动的距离数组
inputFocus() {
this.cursorVisible = this.code.length !== this.size; // 初始化
}, watch([() => props.modelValue, () => props.value], ([modelVal, val]) => {
// 输入失去焦点 code.value = modelVal || val || ''
inputBlur() { }, { immediate: true })
this.cursorVisible = false;
} onMounted(() => {
}, focused.value = props.isFocus
watch: { cursorVisible.value = props.isFocus
value(val) { init()
this.code = val; if (props.isFocus) {
} nextTick(() => {
}, focusInput()
filters: { })
codeFormat(val, isPassword) {
let value = '';
if (val) {
value = isPassword ? '*' : val;
}
return value;
}
} }
}; })
function focusInput() {
focused.value = false
nextTick(() => {
focused.value = true
// #ifdef H5
const inputEl = codeInput.value
if (inputEl && typeof inputEl.focus === 'function') {
inputEl.focus()
}
// #endif
})
}
/**
* @description 初始化
*/
function init() {
getCodeCursorLeft()
setCursorHeight()
}
/**
* @description 获取元素节点
* @param {string} elm - 节点的id、class 相当于 document.querySelect的参数 -eg: #id
* @param {string} type = [single|array] - 单个元素获取多个元素 默认是单个元素
* @param {Function} callback - 回调函数
*/
function getElement(elm: string, type: string = 'single', callback: Function) {
uni
.createSelectorQuery()
.in(instance?.proxy)
[type === 'array' ? 'selectAll' : 'select'](elm)
.boundingClientRect()
.exec((data: any) => {
callback(data[0])
})
}
/**
* @description 计算光标的高度
*/
function setCursorHeight() {
getElement('.xt__box', 'single', (boxElm: any) => {
cursorHeight.value = boxElm.height * 0.6
})
}
/**
* @description 获取光标在每一个box的left位置
*/
function getCodeCursorLeft() {
// 获取父级框的位置信息
getElement('#xt__input-ground', 'single', (parentElm: any) => {
const parentLeft = parentElm.left
// 获取各个box信息
getElement('.xt__box', 'array', (elms: any) => {
codeCursorLeft.value = []
elms.forEach((elm: any) => {
codeCursorLeft.value.push(elm.left - parentLeft + elm.width / 2)
})
})
})
}
// 输入框输入变化的回调
function handleInput(e: any) {
const inputValue = e?.detail?.value ?? e?.target?.value ?? ''
const value = String(inputValue).replace(/\D/g, '').slice(0, props.size)
code.value = value
cursorVisible.value = value.length !== props.size
emit('update:modelValue', value)
emit('input', value)
inputSuccess(value)
}
// 输入完成回调
function inputSuccess(value: string) {
if (value.length === props.size) {
emit('confirm', value)
}
}
// 输入聚焦
function inputFocus() {
cursorVisible.value = code.value.length !== props.size
}
// 输入失去焦点
function inputBlur() {
cursorVisible.value = false
}
function codeFormat(val: string | undefined, isPassword: boolean): string {
let value = ''
if (val) {
value = isPassword ? '*' : val
}
return value
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.xt__verify-code { .xt__verify-code {
@@ -203,11 +208,13 @@ export default {
box-sizing: border-box; box-sizing: border-box;
.xt__input { .xt__input {
height: 100%;
width: 200%;
position: absolute; position: absolute;
left: -100%; top: 0;
z-index: 1; left: 0;
height: 100%;
width: 100%;
opacity: 0;
z-index: 2;
} }
.xt__cursor { .xt__cursor {
position: absolute; position: absolute;
@@ -215,6 +222,8 @@ export default {
transform: translateY(-50%); transform: translateY(-50%);
display: inline-block; display: inline-block;
width: 2px; width: 2px;
z-index: 1;
pointer-events: none;
animation-name: cursor; animation-name: cursor;
animation-duration: 0.8s; animation-duration: 0.8s;
animation-iteration-count: infinite; animation-iteration-count: infinite;
@@ -226,11 +235,14 @@ export default {
align-items: center; align-items: center;
width: 100%; width: 100%;
box-sizing: border-box; box-sizing: border-box;
position: relative;
z-index: 1;
.xt__box { .xt__box {
position: relative; position: relative;
display: inline-block; display: inline-block;
width: 76rpx; width: 76rpx;
height: 112rpx; height: 112rpx;
pointer-events: none;
&-bottom { &-bottom {
border-bottom-width: 2px; border-bottom-width: 2px;
border-bottom-style: solid; border-bottom-style: solid;
@@ -259,13 +271,40 @@ export default {
position: absolute; position: absolute;
top: 50%; top: 50%;
left: 50%; left: 50%;
font-size:52rpx; z-index: 1;
color: #333;
font-size: 52rpx;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
} }
} }
} }
} }
/* #ifdef APP-PLUS */
/*
* App 的原生 input 如果覆盖在验证码格上,部分 Android 设备会出现
* 原生光标/输入绘制层与自绘数字冲突。沿用 u-code-input 的隐藏输入方式,
* 将输入内容和原生光标移出可视区域,验证码格只负责展示响应式状态。
*/
.xt__verify-code {
overflow: hidden;
}
.xt__input {
left: -750rpx;
width: 1500rpx;
z-index: 1;
}
.xt__input-ground {
z-index: 2;
}
.xt__cursor {
z-index: 3;
}
/* #endif */
@keyframes cursor { @keyframes cursor {
0% { 0% {
opacity: 1; opacity: 1;

View File

@@ -1,39 +1,41 @@
/** /**
* base : 基础业务API * buyer : 买家 API(baseURL 为 buyer + /buyer)
* buyer : 买家API * store : 商家 API(baseURL 为 store + /store)
*/ */
// 开发环境 // 开发环境
const dev = { const dev = {
im: "https://im-api.pickmall.cn", buyer: "https://buyer-api.pickmall.cn",
common: "https://common-api.pickmall.cn", store: "https://admin-api.pickmall.cn",
buyer: "https://buyer-api.pickmall.cn", im: "https://im-api.pickmall.cn",
// common: "http://192.168.0.113:8890", mqtt: "wss://lilishop-mqtt-pull.dllll.xyz/mqtt",
// buyer: "http://192.168.0.113:8888", };
// im: "http://192.168.0.113:8885", // 生产环境
}; const prod = {
// 生产环境 buyer: "https://buyer-api.pickmall.cn",
const prod = { store: "https://admin-api.pickmall.cn",
im: "https://im-api.pickmall.cn", im: "https://im-api.pickmall.cn",
common: "https://common-api.pickmall.cn", mqtt: "wss://lilishop-mqtt-pull.dllll.xyz/mqtt",
buyer: "https://buyer-api.pickmall.cn", };
};
let api = dev;
//默认生产环境 if (process.env.NODE_ENV == "development") {
let api = dev; api = dev;
//如果是开发环境 } else {
if (process.env.NODE_ENV == "development") { api = prod;
api = dev; }
} else { // 微信小程序、App 打包使用生产环境配置
api = prod; // #ifdef MP-WEIXIN || APP-PLUS
} api = prod;
//微信小程序,app的打包方式建议为生产环境,所以这块直接条件编译赋值 // #endif
// #ifdef MP-WEIXIN || APP-PLUS
api = prod; const buyerHost = api.buyer;
// #endif const storeHost = api.store;
api.buyer = buyerHost + "/buyer";
api.buyer += "/buyer"; api.store = storeHost + "/store";
api.common += "/common"; api.im = api.im + "/im";
api.im += "/im";
export default { export default {
...api, ...api,
}; buyerHost,
storeHost,
};

View File

@@ -15,7 +15,7 @@ export default {
imWebSrc: "https://im.pickmall.cn", //IM地址 imWebSrc: "https://im.pickmall.cn", //IM地址
baseWsUrl: "wss://im-api.pickmall.cn/lili/webSocket", // IM WS 地址 baseWsUrl: "wss://im-api.pickmall.cn/lili/webSocket", // IM WS 地址
enableGetClipboard: false, //是否启用粘贴板获取 scanAuthNavigation 中的链接,如果匹配则会跳转到对应页面 enableGetClipboard: false, //是否启用粘贴板获取 scanAuthNavigation 中的链接,如果匹配则会跳转到对应页面
enableMiniBarStartUpApp: true, //是否在h5中右侧浮空按钮点击启动app enableMiniBarStartUpApp: false, //是否在h5中右侧浮空按钮点击启动app
/** /**
* 如需更换主题请修改此处以及uni.scss中的全局颜色 * 如需更换主题请修改此处以及uni.scss中的全局颜色
*/ */

23
index.html Normal file
View File

@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
/>
<title></title>
<!-- H5 构建会把 process.env 替换成空对象,但运行时仍会读取 process,浏览器中不存在该变量 -->
<script>
if (typeof process === "undefined") {
window.process = { env: {} };
}
</script>
<!--preload-links-->
<!--app-context-->
</head>
<body>
<div id="app"><!--app-html--></div>
<script type="module" src="/main.js"></script>
</body>
</html>

View File

@@ -2,18 +2,105 @@
* 微信小程序支付 * 微信小程序支付
* 此处针对于微信小程序开发的支付插件 * 此处针对于微信小程序开发的支付插件
* 第一次支付成功后会跳出订阅的消息 如果用户拒绝或同意都会跳转到支付成功页面 * 第一次支付成功后会跳出订阅的消息 如果用户拒绝或同意都会跳转到支付成功页面
* 如果点击订阅 会将状态写进缓存 之后不再提醒。 *
* * @param {sn,price,orderPromotionType}
* @param {sn,price}
*/ */
import { getWeChatMpMessage } from "@/api/message.js"; import { getWeChatMpMessage } from "@/api/message.js";
import { initiatePay } from "@/api/trade"; import { initiatePay } from "@/api/trade";
const SCENE_NAME_MAP = {
ORDER_DELIVER: ["订单发货提醒", "订单发货通知"],
ORDER_COMPLETE: ["订单已完成提醒", "订单完成通知"],
PINTUAN_SUCCESS: ["拼团成功通知"],
AFTER_SALE_AUDIT: ["售后申请审核通知", "售后审核通知"],
POINT_CHANGE: ["积分变更提醒", "积分变更通知"],
WALLET_CHANGE: ["账户余额变动通知", "余额账户变更通知"],
WALLET_WITHDRAWAL_AUDIT_ERROR: ["提现结果通知", "提现申请审核通知"],
};
let cachedMpMessageList = null;
export function prefetchMpMessageTemplates() {
return getWeChatMpMessage()
.then((res) => {
if (res && res.data && Array.isArray(res.data.result)) {
cachedMpMessageList = res.data.result;
}
return cachedMpMessageList || [];
})
.catch(() => cachedMpMessageList || []);
}
function extractTmplIdsByScenes(list, targetScenes) {
const tmplIds = [];
(targetScenes || []).forEach((scene) => {
const aliasNames = SCENE_NAME_MAP[scene] || [];
const matched = (list || []).find(
(item) =>
item &&
item.enable !== false &&
item.code &&
(item.sceneCode === scene || aliasNames.includes(item.name))
);
if (matched && matched.code && !tmplIds.includes(matched.code)) {
tmplIds.push(matched.code);
}
});
return tmplIds.slice(0, 3);
}
export function subscribeMpMessageByScenes(sceneCodes, onComplete) {
const done = typeof onComplete === "function" ? onComplete : () => {};
const targetScenes = Array.isArray(sceneCodes) ? sceneCodes : [];
if (!targetScenes.length) {
done();
return;
}
if (Array.isArray(cachedMpMessageList) && cachedMpMessageList.length) {
const finalTmplIds = extractTmplIdsByScenes(cachedMpMessageList, targetScenes);
if (!finalTmplIds.length) {
done();
return;
}
console.log("[微信订阅消息] 请求订阅 tmplIds:", finalTmplIds);
uni.requestSubscribeMessage({
tmplIds: finalTmplIds,
complete: (res) => {
console.log("[微信订阅消息] 授权返回结果:", res);
done();
},
});
return;
}
prefetchMpMessageTemplates()
.then((list) => {
const finalTmplIds = extractTmplIdsByScenes(list, targetScenes);
if (!finalTmplIds.length) {
done();
return;
}
uni.requestSubscribeMessage({
tmplIds: finalTmplIds,
complete: () => done(),
});
})
.catch(() => done());
}
export function subscribePayMessageThen(onComplete, options = {}) {
const isPintuan =
options &&
String(options.orderPromotionType || "").toUpperCase() === "PINTUAN";
const scenes = isPintuan
? ["ORDER_DELIVER", "ORDER_COMPLETE", "PINTUAN_SUCCESS"]
: ["ORDER_DELIVER", "ORDER_COMPLETE"];
subscribeMpMessageByScenes(scenes, onComplete);
}
class LiLiWXPay { class LiLiWXPay {
constructor(...payList) { constructor(...payList) {
this.data = payList[0]; this.data = payList[0];
console.log(payList);
// 调用支付
this.pay = () => { this.pay = () => {
uni.showLoading({ uni.showLoading({
title: "加载中", title: "加载中",
@@ -26,7 +113,6 @@ class LiLiWXPay {
}; };
const paymentMethod = "WECHAT"; const paymentMethod = "WECHAT";
const paymentClient = "MP"; const paymentClient = "MP";
// 调用支付
initiatePay(paymentMethod, paymentClient, submitData).then((res) => { initiatePay(paymentMethod, paymentClient, submitData).then((res) => {
let response = res.data.result; let response = res.data.result;
uni.hideLoading(); uni.hideLoading();
@@ -38,16 +124,25 @@ class LiLiWXPay {
package: response.package, package: response.package,
signType: response.signType, signType: response.signType,
paySign: response.paySign, paySign: response.paySign,
success: (e) => { success: () => {
uni.showToast({ uni.showToast({
icon: "none", icon: "none",
title: "支付成功!", title: "支付成功!",
}); });
sendMessage(payList[0].price); subscribePayMessageThen(
() => {
uni.redirectTo({
url:
"/pages/cart/payment/success?paymentMethod=WECHAT" +
"&payPrice=" +
payList[0].price,
});
},
{ orderPromotionType: this.data.orderPromotionType }
);
}, },
fail: (e) => { fail: (e) => {
this.exception = e; this.exception = e;
// 支付异常或支付失败之后跳转到订单页面
uni.showModal({ uni.showModal({
content: "支付失败,如果您已支付,请勿反复支付", content: "支付失败,如果您已支付,请勿反复支付",
showCancel: false, showCancel: false,
@@ -64,41 +159,4 @@ class LiLiWXPay {
} }
} }
function sendMessage(price) {
//订阅消息
getWeChatMpMessage().then((res) => {
var message = res.data.result;
var templateid = message.map((item) => item.code);
uni.requestSubscribeMessage({
tmplIds: templateid,
success: (res) => {
},
fail: (res) => {
console.log('fail', res)
uni.showToast({
icon: "none",
title: "订阅消息失败",
})
},
complete: (res) => {
console.log('complete', res)
/**
* 已经支付成功
*/
uni.redirectTo({
url:
"/pages/cart/payment/success?paymentMethod=WECHAT" +
"&payPrice=" +
price,
});
},
});
});
}
export default LiLiWXPay; export default LiLiWXPay;

View File

@@ -1,8 +1,7 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/; var b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
exports.weBtoa = function (string) { export function weBtoa(string) {
string = String(string); string = String(string);
var bitmap, a, b, c, result = "", i = 0, rest = string.length % 3; var bitmap, a, b, c, result = "", i = 0, rest = string.length % 3;
for (; i < string.length;) { for (; i < string.length;) {
@@ -15,8 +14,8 @@ exports.weBtoa = function (string) {
b64.charAt(bitmap >> 6 & 63) + b64.charAt(bitmap & 63); b64.charAt(bitmap >> 6 & 63) + b64.charAt(bitmap & 63);
} }
return rest ? result.slice(0, rest - 3) + "===".substring(rest) : result; return rest ? result.slice(0, rest - 3) + "===".substring(rest) : result;
}; }
exports.weAtob = function (string) { export function weAtob(string) {
string = String(string).replace(/[\t\n\f\r ]+/g, ""); string = String(string).replace(/[\t\n\f\r ]+/g, "");
if (!b64re.test(string)) if (!b64re.test(string))
throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded."); throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");
@@ -30,9 +29,9 @@ exports.weAtob = function (string) {
String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255); String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255);
} }
return result; return result;
}; }
function b64DecodeUnicode(str) { function b64DecodeUnicode(str) {
return decodeURIComponent(exports.weAtob(str).replace(/(.)/g, function (p) { return decodeURIComponent(weAtob(str).replace(/(.)/g, function (p) {
var code = p.charCodeAt(0).toString(16).toUpperCase(); var code = p.charCodeAt(0).toString(16).toUpperCase();
if (code.length < 2) { if (code.length < 2) {
code = "0" + code; code = "0" + code;
@@ -58,7 +57,7 @@ function base64_url_decode(str) {
return b64DecodeUnicode(output); return b64DecodeUnicode(output);
} }
catch (err) { catch (err) {
return exports.weAtob(output); return weAtob(output);
} }
} }
function weappJwtDecode(token, options) { function weappJwtDecode(token, options) {
@@ -74,4 +73,4 @@ function weappJwtDecode(token, options) {
throw ("Invalid token specified: " + e.message); throw ("Invalid token specified: " + e.message);
} }
} }
exports.default = weappJwtDecode; export default weappJwtDecode;

View File

@@ -1,5 +1,20 @@
var _a; var _a;
export const PLATFORM = typeof process !== 'undefined' ? (_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.VUE_APP_PLATFORM : undefined; function detectPlatform() {
if (typeof process !== 'undefined' && (_a = process === null || process === void 0 ? void 0 : process.env) !== null && _a !== void 0 && _a.VUE_APP_PLATFORM) {
return process.env.VUE_APP_PLATFORM;
}
if (typeof wx !== 'undefined' && typeof wx.getSystemInfoSync === 'function') {
return 'mp-weixin';
}
if (typeof uni !== 'undefined' && typeof uni.getSystemInfoSync === 'function') {
const info = uni.getSystemInfoSync();
if (info && info.uniPlatform === 'mp-weixin') {
return 'mp-weixin';
}
}
return undefined;
}
export const PLATFORM = detectPlatform();
/** 全局对象 */ /** 全局对象 */
const _uni = (function () { const _uni = (function () {
if (typeof uni != "undefined") if (typeof uni != "undefined")

View File

@@ -37,7 +37,9 @@ export const handleBuildOpts = (options) => {
} }
const oldSelector = defaultOpts.selector; const oldSelector = defaultOpts.selector;
if (PLATFORM === 'mp-weixin' && defaultOpts.type2d) { if (PLATFORM === 'mp-weixin' && defaultOpts.type2d) {
defaultOpts.selector = '#' + defaultOpts.selector; defaultOpts.selector = oldSelector.startsWith('#')
? oldSelector
: '#' + oldSelector;
} }
if (!PLATFORM) { if (!PLATFORM) {
console.error('注意! draw-poster未开启uni条件编译! 当环境是微信小程序将不会动态切换为type2d模式'); console.error('注意! draw-poster未开启uni条件编译! 当环境是微信小程序将不会动态切换为type2d模式');

View File

@@ -265,7 +265,7 @@ function checkSystemEnableLocation() {
} }
} }
module.exports = { export default {
judgeIosPermission: judgeIosPermission, judgeIosPermission: judgeIosPermission,
requestAndroidPermission: requestAndroidPermission, requestAndroidPermission: requestAndroidPermission,
checkSystemEnableLocation: checkSystemEnableLocation, checkSystemEnableLocation: checkSystemEnableLocation,

146
main.js
View File

@@ -1,59 +1,87 @@
import Vue from "vue"; import { createSSRApp, computed } from 'vue'
import App from "./App"; import App from './App'
import * as filters from "./utils/filters.js"; // global filter import uviewPlus, { setConfig } from 'uview-plus'
import uView from "uview-ui"; import store from './store'
import store from "./store"; import config from '@/config/config'
import config from '@/config/config'; // #ifdef H5
import airBtn from "@/components/m-airbtn/index.vue"; import airBtn from '@/components/m-airbtn/index.vue'
import socketIO from './pages/mine/im/socket'; // #endif
/** import mpShare from '@/utils/mpShare.js'
* 仅在h5中显示唤醒app功能 import * as filterUtils from './utils/filters.js'
* 在h5页面手动挂载 import { getThemeStyle } from '@/utils/theme'
*
*/ export function createApp() {
// #ifdef H5 const app = createSSRApp(App)
if (config.enableMiniBarStartUpApp) {
let btn = Vue.component("airBtn", airBtn); //全局注册 // uview-plus 内部会触发 Vue3 开发态告警(枚举组件实例 keys),不影响运行
document.body.appendChild(new btn().$mount().$el); app.config.warnHandler = (msg, _instance, trace) => {
} if (
// #endif typeof msg === 'string' &&
msg.includes('enumerating keys on a component instance')
// 引入uView对小程序分享的mixin封装 ) {
let mpShare = require('uview-ui/libs/mixin/mpShare.js'); return
Vue.mixin(mpShare) }
try {
/** console.warn(`[Vue warn]: ${msg}${trace || ''}`)
* 全局filters } catch (e) {
*/ // #ifdef MP-WEIXIN
// 微信开发者工具部分版本在输出 Vue warn 时会触发
Object.keys(filters).forEach((key) => { // TypeError: Cannot read property '__global' of null
Vue.filter(key, filters[key]); // #endif
}); }
}
// 引入Vuex
Vue.prototype.$store = store; app.use(store)
// Vue.prototype.socketIo = new socketIO(); app.use(uviewPlus)
Vue.use(uView);
Vue.config.productionTip = false; // uview-plus 的图标字体默认每个 u-icon 实例都会触发 uni.loadFontFace,
// 导致进入页面时同一字体被反复请求。开启 loadFontOnce 后全局只加载一次。
setConfig({
/** config: {
* 注意! loadFontOnce: true,
* 此处将常用的颜色嵌入到原型链上面 iconUrl: 'https://lilishop-uniapp.oss-cn-beijing.aliyuncs.com/font_2225171_8kdcwk4po24.ttf',
* 颜色使用驼峰命名对应 uni.scss中全局颜色变量名 },
* 如需更换主题请修改此处以及uni.scss中的全局颜色 props: {
*/ form: {
// 主题色 labelWidth: '180rpx',
Vue.prototype.$mainColor = config.mainColor; labelPosition: 'left',
// 高亮主题色 },
Vue.prototype.$lightColor = config.lightColor; },
// 辅助高亮颜色 })
Vue.prototype.$aiderLightColor = config.aiderLightColor;
app.config.globalProperties.$store = store
app.config.globalProperties.$mainColor = computed(() => store.getters.mainColor)
App.mpType = "app"; app.config.globalProperties.$lightColor = computed(() => store.getters.lightColor)
app.config.globalProperties.$aiderLightColor = computed(
const app = new Vue({ () => store.getters.aiderLightColor
...App, )
});
app.$mount(); const filterMethods = {}
Object.keys(filterUtils).forEach((key) => {
if (typeof filterUtils[key] === 'function') {
filterMethods[key] = filterUtils[key]
}
})
app.mixin({
methods: filterMethods,
computed: {
themeStyle() {
return getThemeStyle(this.$store.state.theme)
},
},
})
app.mixin(mpShare)
// #ifdef H5
if (config.enableMiniBarStartUpApp) {
const mountPoint = document.createElement('div')
document.body.appendChild(mountPoint)
createSSRApp(airBtn).mount(mountPoint)
}
// #endif
return {
app
}
}

View File

@@ -1,9 +1,10 @@
{ {
"vueVersion" : "3",
"name" : "lilishop", "name" : "lilishop",
"appid" : "__UNI__ED807EA", "appid" : "__UNI__ED807EA",
"description" : "", "description" : "",
"versionName" : "4.5.3", "versionName" : "5.0.4",
"versionCode" : 4000503, "versionCode" : 503,
"transformPx" : false, "transformPx" : false,
"app-plus" : { "app-plus" : {
"compatible" : { "compatible" : {
@@ -191,6 +192,7 @@
"mp-weixin" : { "mp-weixin" : {
/* 小程序特有相关 */ /* 小程序特有相关 */
"usingComponents" : true, "usingComponents" : true,
"lazyCodeLoading" : "requiredComponents",
"appid" : "wx6f10f29075dc1b0b", "appid" : "wx6f10f29075dc1b0b",
"optimization" : { "optimization" : {
"subPackages" : true "subPackages" : true
@@ -198,8 +200,9 @@
"setting" : { "setting" : {
"urlCheck" : false, "urlCheck" : false,
"minified" : true, "minified" : true,
"postcss" : false, "postcss" : true,
"es6" : true "es6" : true,
"enhance" : true
}, },
"permission" : { "permission" : {
"scope.userLocation" : { "scope.userLocation" : {
@@ -207,12 +210,9 @@
} }
}, },
"plugins" : {}, "plugins" : {},
// 直播插件注释 "libVersion" : "3.5.8",
// "live-player-plugin" : { "__usePrivacyCheck__" : false,
// "version" : "1.3.0", "requiredPrivateInfos" : [ "chooseLocation", "getLocation", "chooseAddress" ]
// "provider" : "wx2b03c6e691cd7370"
// }
"requiredPrivateInfos" : [ "chooseLocation", "getLocation" ]
}, },
"h5" : { "h5" : {
"devServer" : { "devServer" : {

3027
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

27
package.json Normal file
View File

@@ -0,0 +1,27 @@
{
"name": "lilishop-uniapp",
"version": "4.5.3",
"description": "Lilishop uni-app mobile client (Vue 3)",
"main": "main.js",
"scripts": {
"postinstall": "patch-package && node scripts/patch-mqtt-abort.js",
"test:mqtt-app-runtime": "node scripts/test-mqtt-app-runtime.js"
},
"repository": {
"type": "git",
"url": "https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp"
},
"license": "Apache-2.0",
"dependencies": {
"@tencentcloud/chat": "^3.5.5",
"hls.js": "^1.6.16",
"mqtt": "5.15.1",
"sass": "^1.89.2",
"uview-plus": "3.8.42",
"vuex": "^4.1.0"
},
"devDependencies": {
"patch-package": "^8.0.1",
"postinstall-postinstall": "^2.1.0"
}
}

View File

@@ -0,0 +1,26 @@
import { storeHttp } from "../utils/storeRequest.js";
/**
* 分页获取客户评价列表
* @param {Object} params { grade, goodsName, replyStatus, pageNumber, pageSize }
*/
export function getStoreEvaluationList(params) {
return storeHttp.request({
url: "/member/evaluation",
method: "GET",
params,
});
}
/**
* 回复客户评价
* @param {String} id 评价ID
* @param {String} reply 回复文字
* @param {String} replyImage 可选回复图片
*/
export function replyStoreEvaluation(id, reply, replyImage = "") {
return storeHttp.request({
url: `/member/evaluation/reply/${id}?reply=${encodeURIComponent(reply)}&replyImage=${encodeURIComponent(replyImage)}`,
method: "PUT",
});
}

View File

@@ -0,0 +1,70 @@
import { storeHttp } from "../utils/storeRequest.js";
/**
* 获取商家商品列表
* @param {Object} params { goodsName, marketEnable, authFlag, pageNumber, pageSize }
*/
export function getStoreGoodsList(params) {
return storeHttp.request({
url: "/goods/goods/list",
method: "GET",
params,
});
}
/**
* 获取商家商品详情
* @param {String} id 商品ID
*/
export function getStoreGoodsDetail(id) {
return storeHttp.request({
url: `/goods/goods/get/${id}`,
method: "GET",
});
}
/**
* 获取商品关联的 SKU 列表
* @param {String} goodsId 商品ID
*/
export function getStoreGoodsSkuList(goodsId) {
return storeHttp.request({
url: `/goods/goods/sku/${goodsId}/list`,
method: "GET",
});
}
/**
* 上架商品
* @param {String|Array} goodsId
*/
export function upGoods(goodsId) {
const ids = Array.isArray(goodsId) ? goodsId.join(",") : goodsId;
return storeHttp.request({
url: `/goods/goods/up?goodsId=${ids}`,
method: "PUT",
});
}
/**
* 下架商品
* @param {String|Array} goodsId
*/
export function downGoods(goodsId) {
const ids = Array.isArray(goodsId) ? goodsId.join(",") : goodsId;
return storeHttp.request({
url: `/goods/goods/under?goodsId=${ids}`,
method: "PUT",
});
}
/**
* 获取商品统计数量(出售中、已下架等)
*/
export function getStoreGoodsNumber(params) {
return storeHttp.request({
url: "/goods/goods/goodsNumber",
method: "GET",
params,
});
}

View File

@@ -0,0 +1,104 @@
import { storeHttp } from "../utils/storeRequest.js";
/**
* 商家订单列表
* @param {Object} params { orderStatus, orderType, keywords, pageNumber, pageSize }
*/
export function getStoreOrderList(params) {
return storeHttp.request({
url: "/order/order",
method: "GET",
params,
});
}
/**
* 商家订单详情
* @param {String} sn
*/
export function getStoreOrderDetail(sn) {
return storeHttp.request({
url: `/order/order/${sn}`,
method: "GET",
});
}
/**
* 自提 / 虚拟商品单码核销
* @param {String} sn
* @param {String} verificationCode
*/
export function storeOrderTake(sn, verificationCode) {
return storeHttp.request({
url: `/order/order/take/${sn}/${verificationCode}`,
method: "PUT",
});
}
/**
* 通用核销预检(按核销码查询)
* @param {String} code
*/
export function previewStoreVerification(code) {
return storeHttp.request({
url: "/order/order/verification/preview",
method: "GET",
params: { code },
});
}
/**
* 通用确认核销
* @param {String} code
*/
export function confirmStoreVerification(code) {
return storeHttp.request({
url: "/order/order/verification/confirm",
method: "POST",
data: { code },
});
}
/**
* 预约服务 — 根据核销码查询预约订单详情
* @param {String} code
*/
export function getAppointmentOrderByCode(code) {
return storeHttp.request({
url: `/appointment/verification/order/${code}`,
method: "GET",
});
}
/**
* 预约服务 — 执行核销
* @param {Object} params { orderSn, code, serviceStaffId }
*/
export function verifyAppointmentCode(params) {
return storeHttp.request({
url: "/appointment/verification/verify",
method: "POST",
data: params,
});
}
/**
* 预约服务 — 获取已启用的服务人员列表(供核销时指派/确认)
*/
export function getEnabledServiceStaff() {
return storeHttp.request({
url: "/appointment/service-staff/enabled",
method: "GET",
});
}
/**
* 预约服务 — 根据订单号获取预约单核销状态
* @param {String} orderSn
*/
export function getAppointmentVerificationByOrderSn(orderSn) {
return storeHttp.request({
url: `/appointment/verification/order-by-sn/${orderSn}`,
method: "GET",
});
}

View File

@@ -0,0 +1,94 @@
import { storeHttp } from "../utils/storeRequest.js";
/**
* 账号密码登录(支持店主与店员账号)
* @param {Object} params { username, password }
*/
export function userLogin(params) {
return storeHttp.request({
url: "/passport/login/userLogin",
method: "POST",
params,
header: {
"content-type": "application/x-www-form-urlencoded",
},
});
}
/**
* 短信验证码登录(支持店主与店员手机号)
* @param {Object} params { mobile, code }
*/
export function smsLogin(params) {
return storeHttp.request({
url: "/passport/login/smsLogin",
method: "POST",
params,
header: {
"content-type": "application/x-www-form-urlencoded",
},
});
}
/**
* 发送登录短信
* @param {String} mobile
* @param {String} verificationEnums (LOGIN)
*/
export function sendStoreSms(mobile, verificationEnums = "LOGIN") {
return storeHttp.request({
url: `/common/sms/${verificationEnums}/${mobile}`,
method: "GET",
});
}
/**
* 获取滑块验证码
* @param {String} verificationEnums (LOGIN)
*/
export function getStoreSlider(verificationEnums = "LOGIN") {
return storeHttp.request({
url: `/common/slider/${verificationEnums}`,
method: "GET",
});
}
/**
* 登出
*/
export function storeLogout() {
return storeHttp.request({
url: "/passport/login/logout",
method: "POST",
});
}
/**
* 获取店铺基本配置与信息
*/
export function getStoreSettings() {
return storeHttp.request({
url: "/settings/storeSettings",
method: "GET",
});
}
/**
* 获取当前登录人员(店主 / 店员)个人信息
*/
export function getStoreUserInfo() {
return storeHttp.request({
url: "/member/user/info",
method: "GET",
});
}
/**
* 获取当前登录所属店铺详情
*/
export function getStoreDetail() {
return storeHttp.request({
url: "/member/user",
method: "GET",
});
}

View File

@@ -0,0 +1,650 @@
<template>
<view class="merchant-evaluation-page">
<!-- 顶部 Tab 过滤 -->
<view class="sticky-header">
<view class="tab-scroll-wrap">
<view
class="tab-item"
v-for="item in tabList"
:key="item.key"
:class="{ active: currentTab === item.key }"
@click="switchTab(item.key)"
>
<text class="tab-label">{{ item.label }}</text>
<view class="indicator" v-if="currentTab === item.key"></view>
</view>
</view>
</view>
<!-- 评价列表主体 -->
<view class="eval-list-body">
<view
class="eval-card"
v-for="item in evalList"
:key="item.id"
>
<!-- 头部:买家信息与星级 -->
<view class="eval-header">
<view class="user-box">
<image
class="user-avatar"
:src="item.memberProfile || '/static/tabbar/home.png'"
mode="aspectFill"
></image>
<view class="user-meta">
<text class="user-name">{{ maskName(item.memberName) }}</text>
<text class="eval-time">{{ item.createTime || '--' }}</text>
</view>
</view>
<!-- 评分 -->
<view class="rating-stars">
<u-icon
v-for="star in 5"
:key="star"
name="star-fill"
size="14"
:color="star <= (item.descriptionScore || 5) ? '#f59e0b' : '#e5e7eb'"
></u-icon>
</view>
</view>
<!-- 评价文字内容 -->
<view class="eval-content">
<text class="content-text">{{ item.content || '用户未填写文字评价' }}</text>
</view>
<!-- 买家晒图 -->
<view class="eval-images" v-if="getImages(item.images).length > 0">
<image
class="eval-pic"
v-for="(img, idx) in getImages(item.images)"
:key="idx"
:src="img"
mode="aspectFill"
@click="previewImages(getImages(item.images), idx)"
></image>
</view>
<!-- 关联商品简要信息 -->
<view class="goods-snippet" v-if="item.goodsName">
<image
class="goods-snippet-img"
:src="item.goodsImage || '/static/tabbar/home.png'"
mode="aspectFill"
></image>
<text class="goods-snippet-title">{{ item.goodsName }}</text>
</view>
<!-- 商家已回复内容 -->
<view class="seller-reply-box" v-if="item.reply">
<view class="reply-title-row">
<text class="reply-tag">掌柜回复:</text>
<text class="reply-time" v-if="item.replyTime">{{ item.replyTime }}</text>
</view>
<text class="reply-text">{{ item.reply }}</text>
</view>
<!-- 回复动作条 -->
<view class="eval-footer">
<view
class="reply-trigger-btn"
@click="openReplyModal(item)"
>
<u-icon name="chat" size="14" :color="item.reply ? '#6b7280' : '#ffffff'"></u-icon>
<text :class="{ 'is-replied': item.reply }">
{{ item.reply ? '修改回复' : '立即回复' }}
</text>
</view>
</view>
</view>
<!-- 空状态 -->
<view class="empty-state" v-if="!loading && evalList.length === 0">
<u-icon name="chat" size="56" color="#d1d5db"></u-icon>
<text class="empty-text">暂无相关评价数据</text>
</view>
<!-- 加载提示 -->
<view class="loading-more" v-if="loading">
<text>正在加载评价数据...</text>
</view>
<view class="no-more" v-else-if="finished && evalList.length > 0">
<text>没有更多了</text>
</view>
</view>
<!-- 回复弹窗 -->
<view class="reply-modal-mask" v-if="showReplyModal" @click.self="closeReplyModal">
<view class="reply-modal-card">
<view class="modal-header">
<text class="modal-title">回复买家评价</text>
<view class="close-btn" @click="closeReplyModal">
<u-icon name="close" size="18" color="#9ca3af"></u-icon>
</view>
</view>
<view class="modal-body">
<textarea
class="reply-textarea"
v-model="replyText"
placeholder="请输入真诚的掌柜回复内容,让买家感受到热情与专业..."
placeholder-class="placeholder"
maxlength="300"
></textarea>
<view class="char-count">
<text>{{ replyText.length }}/300</text>
</view>
</view>
<view class="modal-footer">
<view class="modal-btn cancel" @click="closeReplyModal">取消</view>
<view
class="modal-btn confirm"
:class="{ loading: submittingReply }"
@click="submitReply"
>
{{ submittingReply ? '提交中...' : '提交回复' }}
</view>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref } from 'vue'
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { getStoreEvaluationList, replyStoreEvaluation } from '../../api/evaluation.js'
const currentTab = ref('ALL')
const loading = ref(false)
const finished = ref(false)
const pageNumber = ref(1)
const pageSize = ref(10)
const evalList = ref([])
const showReplyModal = ref(false)
const currentEval = ref(null)
const replyText = ref('')
const submittingReply = ref(false)
const tabList = [
{ key: 'ALL', label: '全部' },
{ key: 'GOOD', label: '好评' },
{ key: 'POOR', label: '中差评' },
{ key: 'UNREPLIED', label: '待回复' },
]
onLoad(() => {
fetchEvaluations(true)
})
onPullDownRefresh(async () => {
await fetchEvaluations(true)
uni.stopPullDownRefresh()
})
onReachBottom(() => {
if (!finished.value && !loading.value) {
pageNumber.value++
fetchEvaluations(false)
}
})
const fetchEvaluations = async (reset = false) => {
if (reset) {
pageNumber.value = 1
evalList.value = []
finished.value = false
}
loading.value = true
const params = {
pageNumber: pageNumber.value,
pageSize: pageSize.value,
}
if (currentTab.value === 'GOOD') {
params.grade = 'GOOD'
} else if (currentTab.value === 'POOR') {
params.grade = 'POOR'
} else if (currentTab.value === 'UNREPLIED') {
params.replyStatus = false
}
try {
const res = await getStoreEvaluationList(params)
loading.value = false
if (res.data && res.data.success && res.data.result) {
const records = res.data.result.records || []
if (reset) {
evalList.value = records
} else {
evalList.value = [...evalList.value, ...records]
}
if (records.length < pageSize.value) {
finished.value = true
}
} else {
finished.value = true
}
} catch (e) {
loading.value = false
finished.value = true
}
}
const switchTab = (tabKey) => {
if (currentTab.value === tabKey) return
currentTab.value = tabKey
fetchEvaluations(true)
}
const maskName = (name) => {
if (!name) return '匿名买家'
if (name.length <= 2) return name[0] + '*'
return name[0] + '***' + name[name.length - 1]
}
const getImages = (imgs) => {
if (!imgs) return []
if (Array.isArray(imgs)) return imgs
if (typeof imgs === 'string') {
try {
const parsed = JSON.parse(imgs)
if (Array.isArray(parsed)) return parsed
} catch (e) {
return imgs.split(',').filter(Boolean)
}
}
return []
}
const previewImages = (urls, current) => {
uni.previewImage({
urls,
current,
})
}
// 打开回复弹窗
const openReplyModal = (item) => {
currentEval.value = item
replyText.value = item.reply || ''
showReplyModal.value = true
}
const closeReplyModal = () => {
showReplyModal.value = false
currentEval.value = null
replyText.value = ''
}
// 提交回复
const submitReply = async () => {
if (!replyText.value.trim()) {
uni.showToast({ title: '请输入回复内容', icon: 'none' })
return
}
if (submittingReply.value) return
submittingReply.value = true
uni.showLoading({ title: '提交中...' })
try {
const res = await replyStoreEvaluation(currentEval.value.id, replyText.value.trim())
uni.hideLoading()
submittingReply.value = false
if (res.data && res.data.success) {
uni.showToast({ title: '回复成功', icon: 'success' })
closeReplyModal()
fetchEvaluations(true)
} else {
uni.showToast({
title: res.data?.message || '回复失败',
icon: 'none',
})
}
} catch (e) {
uni.hideLoading()
submittingReply.value = false
uni.showToast({ title: '网络异常,请重试', icon: 'none' })
}
}
</script>
<style lang="scss" scoped>
.merchant-evaluation-page {
min-height: 100vh;
background-color: #f3f4f6;
padding-bottom: 40rpx;
}
.sticky-header {
position: sticky;
top: 0;
z-index: 100;
background: #ffffff;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.04);
.tab-scroll-wrap {
display: flex;
border-bottom: 1rpx solid #f0f0f0;
padding: 0 16rpx;
.tab-item {
flex: 1;
text-align: center;
padding: 24rpx 0;
position: relative;
.tab-label {
font-size: 28rpx;
color: #6b7280;
font-weight: 500;
}
&.active {
.tab-label {
color: #111827;
font-weight: 700;
}
.indicator {
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 40rpx;
height: 6rpx;
background: #111827;
border-radius: 3rpx;
}
}
}
}
}
.eval-list-body {
padding: 24rpx 28rpx;
.eval-card {
background: #ffffff;
border-radius: 20rpx;
padding: 28rpx;
margin-bottom: 24rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.03);
.eval-header {
display: flex;
justify-content: space-between;
align-items: center;
.user-box {
display: flex;
align-items: center;
.user-avatar {
width: 72rpx;
height: 72rpx;
border-radius: 36rpx;
background: #f3f4f6;
}
.user-meta {
margin-left: 16rpx;
.user-name {
font-size: 26rpx;
font-weight: 600;
color: #111827;
display: block;
}
.eval-time {
font-size: 20rpx;
color: #9ca3af;
margin-top: 4rpx;
display: block;
}
}
}
.rating-stars {
display: flex;
gap: 4rpx;
}
}
.eval-content {
margin-top: 20rpx;
.content-text {
font-size: 28rpx;
color: #1f2937;
line-height: 1.5;
word-break: break-all;
}
}
.eval-images {
display: flex;
flex-wrap: wrap;
gap: 16rpx;
margin-top: 16rpx;
.eval-pic {
width: 150rpx;
height: 150rpx;
border-radius: 12rpx;
background: #f3f4f6;
}
}
.goods-snippet {
display: flex;
align-items: center;
background: #f9fafb;
border-radius: 12rpx;
padding: 14rpx;
margin-top: 20rpx;
.goods-snippet-img {
width: 64rpx;
height: 64rpx;
border-radius: 8rpx;
background: #e5e7eb;
flex-shrink: 0;
}
.goods-snippet-title {
font-size: 22rpx;
color: #4b5563;
margin-left: 14rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.seller-reply-box {
margin-top: 20rpx;
background: #f3f4f6;
border-left: 6rpx solid #111827;
border-radius: 8rpx;
padding: 16rpx 20rpx;
.reply-title-row {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 8rpx;
.reply-tag {
font-size: 24rpx;
font-weight: 700;
color: #111827;
}
.reply-time {
font-size: 20rpx;
color: #9ca3af;
}
}
.reply-text {
font-size: 26rpx;
color: #4b5563;
line-height: 1.4;
}
}
.eval-footer {
display: flex;
justify-content: flex-end;
margin-top: 24rpx;
padding-top: 20rpx;
border-top: 1rpx solid #f9fafb;
.reply-trigger-btn {
display: flex;
align-items: center;
gap: 8rpx;
padding: 10rpx 28rpx;
border-radius: 12rpx;
background: #111827;
color: #ffffff;
font-size: 24rpx;
font-weight: 600;
.is-replied {
color: #4b5563;
}
&:has(.is-replied) {
background: #f3f4f6;
border: 1rpx solid #e5e7eb;
}
}
}
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
padding: 120rpx 0;
.empty-text {
font-size: 26rpx;
color: #9ca3af;
margin-top: 20rpx;
}
}
.loading-more,
.no-more {
text-align: center;
padding: 24rpx 0;
font-size: 22rpx;
color: #9ca3af;
}
}
/* 回复弹窗 */
.reply-modal-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.6);
z-index: 999;
display: flex;
align-items: center;
justify-content: center;
padding: 40rpx;
.reply-modal-card {
background: #ffffff;
width: 100%;
max-width: 640rpx;
border-radius: 28rpx;
padding: 36rpx;
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 24rpx;
.modal-title {
font-size: 32rpx;
font-weight: 700;
color: #111827;
}
}
.modal-body {
position: relative;
.reply-textarea {
width: 100%;
height: 240rpx;
background: #f9fafb;
border: 1rpx solid #e5e7eb;
border-radius: 16rpx;
padding: 20rpx;
font-size: 28rpx;
color: #111827;
box-sizing: border-box;
}
.placeholder {
color: #9ca3af;
font-size: 26rpx;
}
.char-count {
position: absolute;
right: 16rpx;
bottom: 16rpx;
font-size: 20rpx;
color: #9ca3af;
}
}
.modal-footer {
display: flex;
gap: 20rpx;
margin-top: 28rpx;
.modal-btn {
flex: 1;
height: 84rpx;
border-radius: 16rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 30rpx;
font-weight: 600;
&.cancel {
background: #f3f4f6;
color: #4b5563;
}
&.confirm {
background: #111827;
color: #ffffff;
&.loading {
opacity: 0.7;
}
}
}
}
}
}
</style>

View File

@@ -0,0 +1,737 @@
<template>
<view class="merchant-goods-detail" v-if="goodsDetail">
<!-- 顶部主图轮播 -->
<view class="gallery-wrapper">
<swiper
class="gallery-swiper"
:indicator-dots="false"
:autoplay="false"
@change="onSwiperChange"
>
<swiper-item
v-for="(img, idx) in galleryImages"
:key="idx"
@click="previewGallery(idx)"
>
<image class="swiper-img" :src="img" mode="aspectFill"></image>
</swiper-item>
</swiper>
<view class="swiper-indicator" v-if="galleryImages.length > 1">
<text>{{ currentSwiperIndex + 1 }} / {{ galleryImages.length }}</text>
</view>
</view>
<!-- 核心信息卡片 -->
<view class="info-card core-card">
<view class="price-row">
<view class="main-price">
<text class="symbol">¥</text>
<text class="num">{{ goodsDetail.price || '0.00' }}</text>
</view>
<view class="sub-price" v-if="goodsDetail.cost">
<text>成本价 ¥{{ goodsDetail.cost }}</text>
</view>
<view class="status-tags">
<view
class="badge market"
:class="goodsDetail.marketEnable === 'UPPER' ? 'on-sale' : 'off-sale'"
>
{{ goodsDetail.marketEnable === 'UPPER' ? '出售中' : '已下架' }}
</view>
<view
class="badge auth"
:class="goodsDetail.authFlag === 'PASS' ? 'auth-pass' : 'auth-pending'"
>
{{ getAuthText(goodsDetail.authFlag) }}
</view>
</view>
</view>
<view class="title-row">
<text class="goods-title">{{ goodsDetail.goodsName }}</text>
</view>
<view class="meta-stats-grid">
<view class="stat-col">
<text class="stat-num">{{ goodsDetail.quantity ?? 0 }}</text>
<text class="stat-label">总库存</text>
</view>
<view class="stat-sep"></view>
<view class="stat-col">
<text class="stat-num">{{ goodsDetail.buyCount ?? 0 }}</text>
<text class="stat-label">累计销量</text>
</view>
<view class="stat-sep"></view>
<view class="stat-col">
<text class="stat-num">{{ goodsDetail.sn || '--' }}</text>
<text class="stat-label">商品货号</text>
</view>
</view>
</view>
<!-- 规格与多 SKU 列表 -->
<view class="info-card" v-if="skuList && skuList.length > 0">
<view class="card-head">
<view class="head-left">
<text class="card-title">规格与 SKU 明细</text>
<text class="sku-count-pill">共 {{ skuList.length }} 种规格</text>
</view>
</view>
<view class="sku-list">
<view
class="sku-item"
v-for="(sku, index) in skuList"
:key="sku.id || sku.sn || index"
>
<image
class="sku-thumb"
:src="getSkuThumb(sku)"
mode="aspectFill"
></image>
<view class="sku-info">
<text class="sku-spec">{{ formatSpecs(sku, index) }}</text>
<text class="sku-sn" v-if="sku.sn">SKU编码:{{ sku.sn }}</text>
<view class="sku-nums">
<text class="sku-price">售价:<text class="val">¥{{ sku.price || '0.00' }}</text></text>
<text class="sku-stock">库存:<text class="val">{{ sku.quantity ?? sku.stock ?? sku.enableQuantity ?? 0 }}</text></text>
</view>
</view>
</view>
</view>
</view>
<!-- 基本属性卡片(优化分类展示) -->
<view class="info-card">
<view class="card-head">
<text class="card-title">基本属性</text>
</view>
<view class="prop-row" v-if="goodsDetail.categoryName">
<text class="prop-label">所属分类</text>
<text class="prop-val cat-val">{{ formatCategoryName(goodsDetail.categoryName) }}</text>
</view>
<view class="prop-row" v-if="goodsDetail.brandName">
<text class="prop-label">商品品牌</text>
<text class="prop-val">{{ goodsDetail.brandName }}</text>
</view>
<view class="prop-row" v-if="goodsDetail.goodsUnit">
<text class="prop-label">计量单位</text>
<text class="prop-val">{{ goodsDetail.goodsUnit }}</text>
</view>
<view class="prop-row" v-if="goodsDetail.releaseTime">
<text class="prop-label">发布时间</text>
<text class="prop-val">{{ goodsDetail.releaseTime }}</text>
</view>
</view>
<!-- 图文详情 -->
<view class="info-card intro-card" v-if="goodsDetail.intro || goodsDetail.mobileIntro">
<view class="card-head">
<text class="card-title">商品图文详情</text>
</view>
<view class="intro-html">
<rich-text :nodes="formatRichText(goodsDetail.mobileIntro || goodsDetail.intro)"></rich-text>
</view>
</view>
<!-- 底部固定悬浮操作栏(带安全底间距,防止遮挡内容) -->
<view class="bottom-action-bar">
<view class="preview-btn" @click="previewInMall">
<u-icon name="eye" size="20" color="#4b5563"></u-icon>
<text>买家预览</text>
</view>
<view
class="market-action-btn off"
v-if="goodsDetail.marketEnable === 'UPPER'"
@click="handleToggleMarket('DOWN')"
>
<text>下架商品</text>
</view>
<view
class="market-action-btn on"
v-else
@click="handleToggleMarket('UPPER')"
>
<text>立即上架</text>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getStoreGoodsDetail, getStoreGoodsSkuList, upGoods, downGoods } from '../../api/goods.js'
import { parseGoodsImageUrl } from '@/utils/filters.js'
const getSkuThumb = (sku: any) => {
const img = sku.thumbnail || sku.original
if (img) {
const parsed = parseGoodsImageUrl(img)
if (parsed) return parsed
}
const rawSpec = sku.simpleSpecs || sku.specs
if (rawSpec && typeof rawSpec === 'string') {
const match = rawSpec.match(/https?:\/\/[^\s"'\\}]+\.(jpeg|jpg|png|webp|gif)/i)
if (match) return match[0]
}
return galleryImages.value[0] || '/static/tabbar/home.png'
}
const goodsId = ref('')
const goodsDetail = ref<any>(null)
const skuList = ref<any[]>([])
const currentSwiperIndex = ref(0)
onLoad((options: any) => {
if (options?.id) {
goodsId.value = options.id
fetchGoodsDetail()
}
})
const galleryImages = computed(() => {
if (!goodsDetail.value) return []
if (Array.isArray(goodsDetail.value.goodsGalleryList) && goodsDetail.value.goodsGalleryList.length > 0) {
return goodsDetail.value.goodsGalleryList
}
const defaultImg = goodsDetail.value.original || goodsDetail.value.thumbnail
return defaultImg ? [defaultImg] : ['/static/tabbar/home.png']
})
const fetchGoodsDetail = async () => {
uni.showLoading({ title: '加载中...' })
try {
const res: any = await getStoreGoodsDetail(goodsId.value)
uni.hideLoading()
if (res?.data && res.data.success && res.data.result) {
goodsDetail.value = res.data.result
skuList.value = res.data.result.skuList || []
if (skuList.value.length === 0) {
fetchSkuList()
}
} else {
uni.showToast({ title: '获取商品详情失败', icon: 'none' })
}
} catch (e) {
uni.hideLoading()
uni.showToast({ title: '网络连接异常', icon: 'none' })
}
}
const fetchSkuList = async () => {
try {
const skuRes: any = await getStoreGoodsSkuList(goodsId.value)
if (skuRes?.data && skuRes.data.success && Array.isArray(skuRes.data.result)) {
skuList.value = skuRes.data.result
}
} catch (e) {}
}
const onSwiperChange = (e: any) => {
currentSwiperIndex.value = e.detail.current
}
const previewGallery = (current: number) => {
uni.previewImage({
urls: galleryImages.value,
current,
})
}
// 智能清洗并优雅格式化规格文本(过滤 images 等系统 JSON 冗余)
const formatSpecs = (sku: any, index: number) => {
// 1. 优先使用规范的 specList 数组
if (sku.specList && Array.isArray(sku.specList) && sku.specList.length > 0) {
const listStr = sku.specList
.map((s: any) => {
if (s.specName && s.specValue) return `${s.specName}: ${s.specValue}`
return s.specValue || s.specName
})
.filter(Boolean)
.join(' / ')
if (listStr) return listStr
}
// 2. 深度清洗 simpleSpecs 或 specs 中的复杂复合 JSON
const rawSpec = sku.simpleSpecs || sku.specs
if (rawSpec && typeof rawSpec === 'string') {
const trimmed = rawSpec.trim()
if (trimmed.startsWith('{') || trimmed.startsWith('[')) {
try {
const obj = JSON.parse(trimmed)
const ignoreKeys = ['images', 'code', 'message', 'result', 'success', 'showProgress', 'url', 'status', 'specImage', 'specType']
const pairs: string[] = []
for (const [k, v] of Object.entries(obj)) {
if (!ignoreKeys.includes(k) && typeof v === 'string' && !v.startsWith('http') && v.length < 50) {
pairs.push(`${k}: ${v}`)
}
}
if (pairs.length > 0) return pairs.join(' / ')
} catch (e) {}
// JSON 解析失败时正则提取真实的规格键值对
const matches = [...trimmed.matchAll(/"([^"]{1,20})"\s*:\s*"([^"]{1,30})"/g)]
const ignoreKeys = ['code', 'message', 'success', 'url', 'result', 'showProgress', 'status', 'name']
const pairs: string[] = []
for (const m of matches) {
const k = m[1]
const v = m[2]
if (!ignoreKeys.includes(k) && !v.startsWith('http')) {
pairs.push(`${k}: ${v}`)
}
}
if (pairs.length > 0) return pairs.join(' / ')
} else {
// 纯文本规格
return trimmed
}
}
// 3. 提取不同于 SPU 主标题的商品名称差异
if (sku.goodsName && sku.goodsName !== goodsDetail.value?.goodsName) {
return sku.goodsName
}
// 4. 最终兜底
return skuList.value.length > 1 ? `规格 ${index + 1}` : '统一规格'
}
// 格式化分类展示:将原始 JSON 数组 [ "数码办公", "手机通讯", "手机" ] 转为层级面包屑 "数码办公 > 手机通讯 > 手机"
const formatCategoryName = (cat: any) => {
if (!cat) return '--'
if (Array.isArray(cat)) {
return cat.filter(Boolean).join(' > ')
}
if (typeof cat === 'string') {
try {
const parsed = JSON.parse(cat)
if (Array.isArray(parsed)) {
return parsed.filter(Boolean).join(' > ')
}
} catch (e) {}
// 处理带引号或逗号的非标准字符串
return cat.replace(/[\[\]"']/g, '').split(',').map((s: string) => s.trim()).filter(Boolean).join(' > ')
}
return String(cat)
}
const getAuthText = (flag: string) => {
const map: Record<string, string> = {
PASS: '审核通过',
AUDIT: '待审核',
REFUSE: '审核驳回',
}
return map[flag] || flag || '已通过'
}
const formatRichText = (html: string) => {
if (!html) return ''
return html
.replace(/<img[^>]*>/gi, (match) => {
return match
.replace(/style="[^"]*"/gi, '')
.replace(/width="[^"]*"/gi, '')
.replace(/height="[^"]*"/gi, '')
})
.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;border-radius:12rpx;margin:16rpx 0;"')
}
// 上下架切换
const handleToggleMarket = (targetStatus: string) => {
const isUp = targetStatus === 'UPPER'
const actionText = isUp ? '上架' : '下架'
uni.showModal({
title: `${actionText}商品`,
content: `确定要${actionText}当前商品?`,
success: async (res) => {
if (res.confirm) {
uni.showLoading({ title: `正在${actionText}...` })
try {
const apiCall = isUp ? upGoods(goodsId.value) : downGoods(goodsId.value)
const resp: any = await apiCall
uni.hideLoading()
if (resp?.data && resp.data.success) {
uni.showToast({ title: `${actionText}成功`, icon: 'success' })
fetchGoodsDetail()
} else {
uni.showToast({
title: resp?.data?.message || `${actionText}失败`,
icon: 'none',
})
}
} catch (e) {
uni.hideLoading()
uni.showToast({ title: '网络异常,请稍后重试', icon: 'none' })
}
}
},
})
}
// 前往买家端预览
const previewInMall = () => {
uni.navigateTo({
url: `/pages/product/goods?id=${goodsId.value}`,
})
}
</script>
<style lang="scss" scoped>
.merchant-goods-detail {
min-height: 100vh;
background-color: #f4f5f7;
/* 预留出底部固定操作栏的高以及全面屏安全区,彻底解决内容被底部遮挡 */
padding-bottom: calc(160rpx + env(safe-area-inset-bottom));
}
.gallery-wrapper {
position: relative;
width: 100%;
height: 680rpx;
background: #ffffff;
.gallery-swiper {
width: 100%;
height: 100%;
.swiper-img {
width: 100%;
height: 100%;
}
}
.swiper-indicator {
position: absolute;
right: 28rpx;
bottom: 44rpx;
background: rgba(0, 0, 0, 0.55);
color: #ffffff;
font-size: 22rpx;
font-weight: 500;
padding: 6rpx 20rpx;
border-radius: 20rpx;
backdrop-filter: blur(4px);
}
}
.info-card {
margin: 20rpx 28rpx;
background: #ffffff;
border-radius: 24rpx;
padding: 30rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.03);
.card-head {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 24rpx;
padding-bottom: 16rpx;
border-bottom: 1rpx solid #f9fafb;
.head-left {
display: flex;
align-items: center;
gap: 16rpx;
}
.card-title {
font-size: 30rpx;
font-weight: 700;
color: #111827;
}
.sku-count-pill {
font-size: 22rpx;
color: #6b7280;
background: #f3f4f6;
padding: 4rpx 14rpx;
border-radius: 12rpx;
}
}
&.core-card {
margin-top: -30rpx;
position: relative;
z-index: 10;
.price-row {
display: flex;
align-items: baseline;
justify-content: space-between;
.main-price {
color: #ef4444;
display: flex;
align-items: baseline;
.symbol {
font-size: 28rpx;
font-weight: 700;
}
.num {
font-size: 48rpx;
font-weight: 700;
margin-left: 4rpx;
}
}
.sub-price {
font-size: 24rpx;
color: #9ca3af;
margin-left: 16rpx;
flex: 1;
}
.status-tags {
display: flex;
gap: 12rpx;
.badge {
font-size: 22rpx;
padding: 6rpx 16rpx;
border-radius: 10rpx;
font-weight: 600;
&.on-sale {
background: #ecfdf5;
color: #059669;
}
&.off-sale {
background: #f3f4f6;
color: #9ca3af;
}
&.auth-pass {
background: #eff6ff;
color: #2563eb;
}
&.auth-pending {
background: #fffbeb;
color: #d97706;
}
}
}
}
.title-row {
margin-top: 20rpx;
.goods-title {
font-size: 32rpx;
font-weight: 700;
color: #111827;
line-height: 1.45;
}
}
.meta-stats-grid {
display: flex;
align-items: center;
background: #f9fafb;
border-radius: 16rpx;
padding: 22rpx 0;
margin-top: 26rpx;
.stat-col {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
.stat-num {
font-size: 28rpx;
font-weight: 700;
color: #111827;
}
.stat-label {
font-size: 22rpx;
color: #9ca3af;
margin-top: 4rpx;
}
}
.stat-sep {
width: 1rpx;
height: 38rpx;
background: #e5e7eb;
}
}
}
.sku-list {
.sku-item {
display: flex;
align-items: center;
padding: 20rpx 0;
border-bottom: 1rpx solid #f3f4f6;
&:last-child {
border-bottom: none;
}
.sku-thumb {
width: 104rpx;
height: 104rpx;
border-radius: 14rpx;
background: #f9fafb;
border: 1rpx solid #f3f4f6;
flex-shrink: 0;
}
.sku-info {
flex: 1;
margin-left: 22rpx;
display: flex;
flex-direction: column;
.sku-spec {
font-size: 28rpx;
font-weight: 600;
color: #111827;
line-height: 1.35;
}
.sku-sn {
font-size: 22rpx;
color: #9ca3af;
margin-top: 6rpx;
}
.sku-nums {
display: flex;
justify-content: space-between;
align-items: baseline;
margin-top: 10rpx;
.sku-price {
font-size: 24rpx;
color: #6b7280;
.val {
font-size: 28rpx;
font-weight: 700;
color: #ef4444;
}
}
.sku-stock {
font-size: 24rpx;
color: #6b7280;
.val {
font-weight: 600;
color: #111827;
}
}
}
}
}
}
.prop-row {
display: flex;
align-items: flex-start;
justify-content: space-between;
padding: 18rpx 0;
border-bottom: 1rpx solid #f9fafb;
&:last-child {
border-bottom: none;
}
.prop-label {
font-size: 26rpx;
color: #6b7280;
width: 160rpx;
flex-shrink: 0;
}
.prop-val {
flex: 1;
text-align: right;
font-size: 26rpx;
color: #111827;
font-weight: 500;
line-height: 1.45;
&.cat-val {
color: #2563eb;
background: #eff6ff;
display: inline-block;
padding: 6rpx 16rpx;
border-radius: 8rpx;
font-size: 24rpx;
font-weight: 500;
}
}
}
&.intro-card {
.intro-html {
margin-top: 16rpx;
font-size: 28rpx;
color: #374151;
line-height: 1.6;
word-break: break-all;
}
}
}
.bottom-action-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: #ffffff;
display: flex;
align-items: center;
padding: 16rpx 28rpx calc(16rpx + env(safe-area-inset-bottom)) 28rpx;
box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.06);
z-index: 100;
gap: 20rpx;
.preview-btn {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 0 20rpx;
text {
font-size: 20rpx;
color: #4b5563;
margin-top: 4rpx;
}
}
.market-action-btn {
flex: 1;
height: 84rpx;
border-radius: 16rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 28rpx;
font-weight: 600;
&.off {
background: #fef2f2;
color: #dc2626;
border: 1rpx solid #fecaca;
}
&.on {
background: #111827;
color: #ffffff;
}
}
}
</style>

View File

@@ -0,0 +1,472 @@
<template>
<view class="merchant-goods-page">
<!-- 顶部吸顶搜索栏与 Tab -->
<view class="sticky-header">
<view class="search-bar">
<u-icon name="search" size="18" color="#9ca3af"></u-icon>
<input
class="search-input"
type="text"
v-model="keywords"
placeholder="搜索商品名称"
placeholder-class="placeholder"
@confirm="onSearch"
/>
<view class="clear-btn" v-if="keywords" @click="clearSearch">
<u-icon name="close-circle-fill" size="16" color="#d1d5db"></u-icon>
</view>
</view>
<view class="tab-scroll-wrap">
<view
class="tab-item"
v-for="item in tabList"
:key="item.key"
:class="{ active: currentTab === item.key }"
@click="switchTab(item.key)"
>
<text class="tab-label">{{ item.label }}</text>
<view class="indicator" v-if="currentTab === item.key"></view>
</view>
</view>
</view>
<!-- 商品列表主体 -->
<view class="goods-list-body">
<view
class="goods-card"
v-for="goods in goodsList"
:key="goods.id"
@click="goToDetail(goods.id)"
>
<view class="card-main">
<image
class="goods-img"
:src="goods.thumbnail || goods.original || '/static/tabbar/home.png'"
mode="aspectFill"
></image>
<view class="goods-meta">
<view class="title-row">
<text class="goods-title">{{ goods.goodsName }}</text>
</view>
<view class="stock-sales-row">
<text class="meta-tag">库存: {{ goods.quantity ?? 0 }}</text>
<text class="meta-tag">销量: {{ goods.buyCount ?? 0 }}</text>
</view>
<view class="price-status-row">
<view class="price-box">
<text class="symbol">¥</text>
<text class="price-num">{{ goods.price || goods.sellingPrice || '0.00' }}</text>
</view>
<view class="status-badge" :class="goods.marketEnable === 'UPPER' ? 'on-sale' : 'off-sale'">
{{ goods.marketEnable === 'UPPER' ? '出售中' : '已下架' }}
</view>
</view>
</view>
</view>
<!-- 底部快捷操作条 -->
<view class="card-footer">
<text class="goods-sn" v-if="goods.sn">商品货号:{{ goods.sn }}</text>
<view class="actions-group">
<view
class="action-btn off"
v-if="goods.marketEnable === 'UPPER'"
@click.stop="toggleMarket(goods, 'DOWN')"
>
<text>下架商品</text>
</view>
<view
class="action-btn on"
v-else
@click.stop="toggleMarket(goods, 'UPPER')"
>
<text>立即上架</text>
</view>
</view>
</view>
</view>
<!-- 空状态 -->
<view class="empty-state" v-if="!loading && goodsList.length === 0">
<u-icon name="bag" size="56" color="#d1d5db"></u-icon>
<text class="empty-text">暂无相关商品</text>
</view>
<!-- 加载提示 -->
<view class="loading-more" v-if="loading">
<text>正在加载商品列表...</text>
</view>
<view class="no-more" v-else-if="finished && goodsList.length > 0">
<text>没有更多了</text>
</view>
</view>
</view>
</template>
<script setup>
import { ref } from 'vue'
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { getStoreGoodsList, upGoods, downGoods } from '../../api/goods.js'
const keywords = ref('')
const currentTab = ref('ALL')
const loading = ref(false)
const finished = ref(false)
const pageNumber = ref(1)
const pageSize = ref(10)
const goodsList = ref([])
const tabList = [
{ key: 'ALL', label: '全部' },
{ key: 'UPPER', label: '出售中' },
{ key: 'DOWN', label: '已下架' },
]
onLoad((options) => {
if (options?.tab) {
currentTab.value = options.tab
}
fetchGoods(true)
})
onPullDownRefresh(async () => {
await fetchGoods(true)
uni.stopPullDownRefresh()
})
onReachBottom(() => {
if (!finished.value && !loading.value) {
pageNumber.value++
fetchGoods(false)
}
})
const fetchGoods = async (reset = false) => {
if (reset) {
pageNumber.value = 1
goodsList.value = []
finished.value = false
}
loading.value = true
const params = {
pageNumber: pageNumber.value,
pageSize: pageSize.value,
}
if (keywords.value.trim()) {
params.goodsName = keywords.value.trim()
}
if (currentTab.value !== 'ALL') {
params.marketEnable = currentTab.value
}
try {
const res = await getStoreGoodsList(params)
loading.value = false
if (res.data && res.data.success && res.data.result) {
const records = res.data.result.records || []
if (reset) {
goodsList.value = records
} else {
goodsList.value = [...goodsList.value, ...records]
}
if (records.length < pageSize.value) {
finished.value = true
}
} else {
finished.value = true
}
} catch (e) {
loading.value = false
finished.value = true
}
}
const switchTab = (tabKey) => {
if (currentTab.value === tabKey) return
currentTab.value = tabKey
fetchGoods(true)
}
const onSearch = () => {
fetchGoods(true)
}
const clearSearch = () => {
keywords.value = ''
fetchGoods(true)
}
const goToDetail = (id) => {
uni.navigateTo({
url: `/pages-sub/merchant/pages/goods/detail?id=${id}`,
})
}
// 快捷上下架切换
const toggleMarket = (goods, targetStatus) => {
const isUp = targetStatus === 'UPPER'
const actionText = isUp ? '上架' : '下架'
uni.showModal({
title: `${actionText}提示`,
content: `确定要${actionText}商品「${goods.goodsName}」吗?`,
success: async (res) => {
if (res.confirm) {
uni.showLoading({ title: `正在${actionText}...` })
try {
const apiCall = isUp ? upGoods(goods.id) : downGoods(goods.id)
const resp = await apiCall
uni.hideLoading()
if (resp.data && resp.data.success) {
uni.showToast({ title: `${actionText}成功`, icon: 'success' })
fetchGoods(true)
} else {
uni.showToast({
title: resp.data?.message || `${actionText}失败`,
icon: 'none',
})
}
} catch (e) {
uni.hideLoading()
uni.showToast({ title: '网络连接异常', icon: 'none' })
}
}
},
})
}
</script>
<style lang="scss" scoped>
.merchant-goods-page {
min-height: 100vh;
background-color: #f3f4f6;
padding-bottom: 40rpx;
}
.sticky-header {
position: sticky;
top: 0;
z-index: 100;
background: #ffffff;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.04);
.search-bar {
display: flex;
align-items: center;
background: #f3f4f6;
margin: 20rpx 28rpx;
padding: 16rpx 24rpx;
border-radius: 16rpx;
.search-input {
flex: 1;
margin-left: 16rpx;
font-size: 26rpx;
color: #111827;
}
.placeholder {
color: #9ca3af;
font-size: 26rpx;
}
}
.tab-scroll-wrap {
display: flex;
border-bottom: 1rpx solid #f0f0f0;
padding: 0 16rpx;
.tab-item {
flex: 1;
text-align: center;
padding: 20rpx 0;
position: relative;
.tab-label {
font-size: 28rpx;
color: #6b7280;
font-weight: 500;
}
&.active {
.tab-label {
color: #111827;
font-weight: 700;
}
.indicator {
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 40rpx;
height: 6rpx;
background: #111827;
border-radius: 3rpx;
}
}
}
}
}
.goods-list-body {
padding: 24rpx 28rpx;
.goods-card {
background: #ffffff;
border-radius: 20rpx;
padding: 24rpx;
margin-bottom: 24rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.03);
.card-main {
display: flex;
.goods-img {
width: 170rpx;
height: 170rpx;
border-radius: 16rpx;
background: #f3f4f6;
}
.goods-meta {
flex: 1;
margin-left: 20rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
.title-row {
.goods-title {
font-size: 28rpx;
font-weight: 600;
color: #111827;
line-height: 1.4;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
}
.stock-sales-row {
display: flex;
gap: 16rpx;
margin-top: 8rpx;
.meta-tag {
font-size: 22rpx;
color: #6b7280;
background: #f3f4f6;
padding: 4rpx 12rpx;
border-radius: 8rpx;
}
}
.price-status-row {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 12rpx;
.price-box {
display: flex;
align-items: baseline;
color: #ff3c2a;
.symbol {
font-size: 22rpx;
font-weight: 700;
}
.price-num {
font-size: 34rpx;
font-weight: 700;
margin-left: 4rpx;
}
}
.status-badge {
font-size: 22rpx;
padding: 4rpx 14rpx;
border-radius: 8rpx;
font-weight: 500;
&.on-sale {
background: #ecfdf5;
color: #059669;
}
&.off-sale {
background: #f3f4f6;
color: #9ca3af;
}
}
}
}
}
.card-footer {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 20rpx;
padding-top: 20rpx;
border-top: 1rpx solid #f9fafb;
.goods-sn {
font-size: 22rpx;
color: #9ca3af;
}
.actions-group {
display: flex;
gap: 16rpx;
.action-btn {
padding: 10rpx 28rpx;
border-radius: 12rpx;
font-size: 24rpx;
font-weight: 600;
&.off {
background: #fef2f2;
color: #dc2626;
border: 1rpx solid #fecaca;
}
&.on {
background: #111827;
color: #ffffff;
}
}
}
}
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
padding: 120rpx 0;
.empty-text {
font-size: 26rpx;
color: #9ca3af;
margin-top: 20rpx;
}
}
.loading-more,
.no-more {
text-align: center;
padding: 24rpx 0;
font-size: 22rpx;
color: #9ca3af;
}
}
</style>

View File

@@ -0,0 +1,812 @@
<template>
<view class="workbench-page">
<!-- 顶部商家信息栏 -->
<view class="store-hero">
<view class="store-info-row">
<view class="store-avatar">
<image
class="avatar-img"
:src="storeInfo.settings?.storeLogo || '/static/tabbar/home.png'"
mode="aspectFill"
></image>
</view>
<view class="store-meta">
<view class="name-row">
<text class="store-name">{{ storeInfo.settings?.storeName || storeInfo.store?.storeName || '商家移动工作台' }}</text>
<view class="badge" :class="isClerk ? 'clerk-badge' : 'owner-badge'">
{{ isClerk ? '店员' : '店主' }}
</view>
</view>
<text class="clerk-name">当前操作员:{{ operatorName }}</text>
</view>
<view class="logout-btn" @click="handleLogout">
<text>退出</text>
</view>
</view>
</view>
<!-- 核心操作区(快速核销) -->
<view class="core-actions-card">
<view class="card-header">
<text class="card-title">快速核销</text>
<text class="card-subtitle">支持预约单、自提单与虚拟卡密</text>
</view>
<!-- 扫码主按钮 -->
<view class="scan-hero-btn" @click="handleScanCode">
<view class="scan-icon-circle">
<u-icon name="scan" size="38" color="#ffffff"></u-icon>
</view>
<view class="scan-text-box">
<text class="main-text">扫码快速核销</text>
<text class="sub-text">扫描顾客出示的核销码/订单码</text>
</view>
<u-icon name="arrow-right" size="18" color="rgba(255,255,255,0.6)"></u-icon>
</view>
<!-- 手动输码 -->
<view class="manual-input-box">
<view class="input-wrap">
<u-icon name="edit-pen" size="20" color="#9ca3af"></u-icon>
<input
class="code-input"
type="number"
maxlength="12"
v-model="manualCode"
placeholder="输入8位数字核销码"
placeholder-class="placeholder"
@confirm="handleManualVerify"
/>
<view class="clear-icon" v-if="manualCode" @click="clearManualCode">
<u-icon name="close-circle-fill" size="16" color="#d1d5db"></u-icon>
</view>
</view>
<view
class="verify-btn"
:class="{ active: manualCode.trim().length >= 6 }"
@click="handleManualVerify"
>
<text>核销</text>
</view>
</view>
</view>
<!-- 核心业务四大板块 -->
<view class="business-grid-card">
<view class="grid-card-header">
<text class="grid-card-title">经营管理</text>
</view>
<view class="business-grid">
<!-- 订单管理 -->
<view class="biz-item" @click="navigateTo('/pages-sub/merchant/pages/order/list?tab=ALL')">
<view class="biz-icon-box bg-blue">
<u-icon name="order" size="26" color="#2563eb"></u-icon>
</view>
<text class="biz-title">订单管理</text>
</view>
<!-- 商品管理 -->
<view class="biz-item" @click="navigateTo('/pages-sub/merchant/pages/goods/list')">
<view class="biz-icon-box bg-emerald">
<u-icon name="bag" size="26" color="#059669"></u-icon>
</view>
<text class="biz-title">商品管理</text>
</view>
<!-- 评价管理 -->
<view class="biz-item" @click="navigateTo('/pages-sub/merchant/pages/evaluation/list')">
<view class="biz-icon-box bg-amber">
<u-icon name="chat" size="26" color="#d97706"></u-icon>
</view>
<text class="biz-title">评价管理</text>
</view>
<!-- 待核销专区 -->
<view class="biz-item" @click="navigateTo('/pages-sub/merchant/pages/order/list?tab=TAKE')">
<view class="biz-icon-box bg-orange">
<u-icon name="checkmark-circle" size="26" color="#ea580c"></u-icon>
</view>
<text class="biz-title">待核销单</text>
</view>
</view>
</view>
<!-- 核销确认弹窗 -->
<view class="modal-mask" v-if="showModal" @click.self="closeModal">
<view class="modal-card">
<view class="modal-header">
<text class="modal-title">核销信息确认</text>
<view class="close-btn" @click="closeModal">
<u-icon name="close" size="18" color="#9ca3af"></u-icon>
</view>
</view>
<!-- 订单概览 -->
<view class="order-summary" v-if="verifyingOrder">
<view class="summary-row">
<text class="label">核销码:</text>
<text class="value highlight-code">{{ currentCode }}</text>
</view>
<view class="summary-row">
<text class="label">订单编号:</text>
<text class="value">{{ verifyingOrder.sn || verifyingOrder.orderSn || '--' }}</text>
</view>
<view class="summary-row" v-if="verifyingOrder.consigneeMobile || verifyingOrder.memberPhone">
<text class="label">顾客电话:</text>
<text class="value">{{ maskPhone(verifyingOrder.consigneeMobile || verifyingOrder.memberPhone) }}</text>
</view>
<view class="summary-row" v-if="verifyingOrder.goodsName || verifyingOrder.orderItems?.[0]?.goodsName">
<text class="label">商品名称:</text>
<text class="value goods-text">
{{ verifyingOrder.goodsName || verifyingOrder.orderItems?.[0]?.goodsName }}
</text>
</view>
<view class="summary-row" v-if="verifyingOrder.num">
<text class="label">购买数量:</text>
<text class="value">{{ verifyingOrder.num }} 件</text>
</view>
<!-- 预约服务专属选项:选择服务人员 -->
<view class="staff-picker-box" v-if="isAppointmentOrder">
<text class="staff-label">指派/核销服务人员:</text>
<picker
class="picker-ctrl"
mode="selector"
:range="staffList"
range-key="name"
:value="selectedStaffIndex"
@change="onStaffChange"
>
<view class="picker-display">
<text>{{ currentStaffName }}</text>
<u-icon name="arrow-down" size="14" color="#6b7280"></u-icon>
</view>
</picker>
</view>
</view>
<!-- 弹窗操作 -->
<view class="modal-footer">
<view class="modal-btn cancel" @click="closeModal">取消</view>
<view
class="modal-btn confirm"
:class="{ loading: confirming }"
@click="submitConfirmVerification"
>
{{ confirming ? '核销中...' : '确认核销' }}
</view>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import storage from '@/utils/storage.js'
import {
previewStoreVerification,
storeOrderTake,
confirmStoreVerification,
getAppointmentOrderByCode,
verifyAppointmentCode,
getEnabledServiceStaff,
} from '../../api/order.js'
import { storeLogout } from '../../api/passport.js'
const storeInfo = ref({})
const operatorName = computed(() => {
const u = storeInfo.value?.user
return u?.nickName || u?.username || '当前操作员'
})
const isClerk = computed(() => {
const u = storeInfo.value?.user
if (u && (u.isSuper === false || u.shopkeeper === false)) return true
return false
})
const manualCode = ref('')
const showModal = ref(false)
const confirming = ref(false)
const currentCode = ref('')
const verifyingOrder = ref(null)
const isAppointmentOrder = ref(false)
const staffList = ref([])
const selectedStaffIndex = ref(0)
const currentStaffName = computed(() => {
if (staffList.value.length > 0 && staffList.value[selectedStaffIndex.value]) {
return staffList.value[selectedStaffIndex.value].name
}
return '未指派 / 默认'
})
onMounted(() => {
const token = storage.getStoreAccessToken()
if (!token) {
uni.redirectTo({ url: '/pages-sub/merchant/pages/login/index' })
return
}
storeInfo.value = storage.getStoreInfo() || {}
loadStaffList()
})
const loadStaffList = async () => {
try {
const res = await getEnabledServiceStaff()
if (res.data && res.data.success && Array.isArray(res.data.result)) {
staffList.value = res.data.result
}
} catch (e) {
// 忽略加载异常
}
}
const maskPhone = (phone) => {
if (!phone || phone.length < 7) return phone || ''
return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
}
// 扫码快速核销
const handleScanCode = () => {
uni.scanCode({
onlyFromCamera: true,
scanType: ['qrCode', 'barCode'],
success: (res) => {
let code = res.result || ''
if (code.includes('code=')) {
const match = code.match(/code=([a-zA-Z0-9]+)/)
if (match && match[1]) {
code = match[1]
}
}
if (code) {
queryAndShowVerify(code.trim())
} else {
uni.showToast({ title: '未能识别核销码', icon: 'none' })
}
},
fail: () => {},
})
}
// 手动输码核销
const clearManualCode = () => {
manualCode.value = ''
}
const handleManualVerify = () => {
const code = manualCode.value.trim()
if (!code || code.length < 6) {
uni.showToast({ title: '请输入有效的核销码', icon: 'none' })
return
}
queryAndShowVerify(code)
}
// 预检核销码并展示弹窗
const queryAndShowVerify = async (code) => {
currentCode.value = code
uni.showLoading({ title: '正在查询订单...' })
try {
let isAppoint = false
let orderData = null
try {
const appointRes = await getAppointmentOrderByCode(code)
if (appointRes.data && appointRes.data.success && appointRes.data.result) {
isAppoint = true
orderData = appointRes.data.result
}
} catch (e) {}
if (!orderData) {
const previewRes = await previewStoreVerification(code)
if (previewRes.data && previewRes.data.success && previewRes.data.result) {
orderData = previewRes.data.result
}
}
uni.hideLoading()
if (orderData) {
verifyingOrder.value = orderData
isAppointmentOrder.value = isAppoint
showModal.value = true
} else {
verifyingOrder.value = { sn: '以提交核销为准' }
isAppointmentOrder.value = false
showModal.value = true
}
} catch (err) {
uni.hideLoading()
verifyingOrder.value = { sn: '以提交核销为准' }
isAppointmentOrder.value = false
showModal.value = true
}
}
const onStaffChange = (e) => {
selectedStaffIndex.value = e.detail.value
}
const closeModal = () => {
showModal.value = false
verifyingOrder.value = null
manualCode.value = ''
}
// 确认核销提交
const submitConfirmVerification = async () => {
if (confirming.value) return
confirming.value = true
uni.showLoading({ title: '核销中...' })
try {
let success = false
let message = ''
if (isAppointmentOrder.value) {
const staff = staffList.value[selectedStaffIndex.value]
const params = {
orderSn: verifyingOrder.value?.orderSn || verifyingOrder.value?.sn,
code: currentCode.value,
serviceStaffId: staff ? staff.id : undefined,
}
const res = await verifyAppointmentCode(params)
success = res.data && res.data.success
message = res.data?.message
} else {
const sn = verifyingOrder.value?.orderSn || verifyingOrder.value?.sn
if (sn && sn !== '以提交核销为准') {
const res = await storeOrderTake(sn, currentCode.value)
success = res.data && res.data.success
message = res.data?.message
} else {
const res = await confirmStoreVerification(currentCode.value)
success = res.data && res.data.success
message = res.data?.message
}
}
uni.hideLoading()
confirming.value = false
if (success) {
try {
uni.vibrateShort()
} catch (e) {}
uni.showToast({ title: '核销成功!', icon: 'success' })
closeModal()
} else {
uni.showToast({
title: message || '核销失败,请核对核销码',
icon: 'none',
})
}
} catch (e) {
uni.hideLoading()
confirming.value = false
uni.showToast({ title: '请求失败,请稍后重试', icon: 'none' })
}
}
// 退出登录
const handleLogout = () => {
uni.showModal({
title: '退出商家工作台',
content: '退出后将清除本店登录凭证,确认退出?',
success: async (res) => {
if (res.confirm) {
try {
await storeLogout()
} catch (e) {}
storage.clearStoreAuth()
uni.redirectTo({
url: '/pages-sub/merchant/pages/login/index',
})
}
},
})
}
const navigateTo = (url) => {
uni.navigateTo({ url })
}
</script>
<style lang="scss" scoped>
.workbench-page {
min-height: 100vh;
background-color: #f3f4f6;
padding-bottom: 60rpx;
}
.store-hero {
background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
padding: 60rpx 36rpx 100rpx 36rpx;
color: #ffffff;
.store-info-row {
display: flex;
align-items: center;
.store-avatar {
width: 96rpx;
height: 96rpx;
border-radius: 20rpx;
overflow: hidden;
background: #ffffff;
border: 2rpx solid rgba(255, 255, 255, 0.2);
.avatar-img {
width: 100%;
height: 100%;
}
}
.store-meta {
flex: 1;
margin-left: 24rpx;
.name-row {
display: flex;
align-items: center;
gap: 12rpx;
.store-name {
font-size: 34rpx;
font-weight: 700;
color: #ffffff;
}
.badge {
font-size: 20rpx;
padding: 4rpx 14rpx;
border-radius: 8rpx;
font-weight: 500;
&.owner-badge {
background: rgba(255, 255, 255, 0.2);
color: #ffffff;
}
&.clerk-badge {
background: #ecfdf5;
color: #059669;
}
}
}
.clerk-name {
display: block;
font-size: 24rpx;
color: rgba(255, 255, 255, 0.65);
margin-top: 8rpx;
}
}
.logout-btn {
padding: 10rpx 24rpx;
background: rgba(255, 255, 255, 0.12);
border-radius: 12rpx;
font-size: 24rpx;
color: rgba(255, 255, 255, 0.85);
}
}
}
.core-actions-card {
margin: -60rpx 32rpx 28rpx 32rpx;
background: #ffffff;
border-radius: 28rpx;
padding: 36rpx;
box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.06);
.card-header {
margin-bottom: 28rpx;
.card-title {
font-size: 32rpx;
font-weight: 700;
color: #111827;
display: block;
}
.card-subtitle {
font-size: 22rpx;
color: #9ca3af;
margin-top: 6rpx;
display: block;
}
}
.scan-hero-btn {
background: linear-gradient(135deg, #10b981 0%, #059669 100%);
border-radius: 22rpx;
padding: 32rpx 28rpx;
display: flex;
align-items: center;
box-shadow: 0 10rpx 24rpx rgba(16, 185, 129, 0.3);
.scan-icon-circle {
width: 80rpx;
height: 80rpx;
border-radius: 40rpx;
background: rgba(255, 255, 255, 0.2);
display: flex;
align-items: center;
justify-content: center;
}
.scan-text-box {
flex: 1;
margin-left: 24rpx;
.main-text {
font-size: 34rpx;
font-weight: 700;
color: #ffffff;
display: block;
}
.sub-text {
font-size: 22rpx;
color: rgba(255, 255, 255, 0.8);
margin-top: 6rpx;
display: block;
}
}
}
.manual-input-box {
display: flex;
align-items: center;
margin-top: 28rpx;
gap: 16rpx;
.input-wrap {
flex: 1;
display: flex;
align-items: center;
background: #f9fafb;
border: 1rpx solid #e5e7eb;
border-radius: 16rpx;
padding: 18rpx 24rpx;
.code-input {
flex: 1;
margin-left: 16rpx;
font-size: 28rpx;
color: #111827;
}
.placeholder {
color: #9ca3af;
font-size: 26rpx;
}
}
.verify-btn {
padding: 20rpx 36rpx;
background: #e5e7eb;
color: #9ca3af;
border-radius: 16rpx;
font-size: 28rpx;
font-weight: 600;
&.active {
background: #111827;
color: #ffffff;
}
}
}
}
.business-grid-card {
margin: 0 32rpx 24rpx 32rpx;
background: #ffffff;
border-radius: 28rpx;
padding: 32rpx 24rpx;
box-shadow: 0 6rpx 20rpx rgba(0, 0, 0, 0.04);
.grid-card-header {
margin-bottom: 24rpx;
padding-left: 8rpx;
.grid-card-title {
font-size: 30rpx;
font-weight: 700;
color: #111827;
}
}
.business-grid {
display: flex;
flex-wrap: wrap;
.biz-item {
width: 50%;
box-sizing: border-box;
padding: 20rpx;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
.biz-icon-box {
width: 96rpx;
height: 96rpx;
border-radius: 24rpx;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 16rpx;
&.bg-blue {
background: #eff6ff;
}
&.bg-emerald {
background: #ecfdf5;
}
&.bg-amber {
background: #fffbeb;
}
&.bg-orange {
background: #fff7ed;
}
}
.biz-title {
font-size: 28rpx;
font-weight: 700;
color: #1f2937;
}
.biz-sub {
font-size: 22rpx;
color: #9ca3af;
margin-top: 4rpx;
}
}
}
}
/* 弹窗遮罩 */
.modal-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.6);
z-index: 999;
display: flex;
align-items: center;
justify-content: center;
padding: 40rpx;
.modal-card {
background: #ffffff;
width: 100%;
max-width: 620rpx;
border-radius: 28rpx;
padding: 36rpx;
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 28rpx;
.modal-title {
font-size: 32rpx;
font-weight: 700;
color: #111827;
}
}
.order-summary {
background: #f9fafb;
border-radius: 16rpx;
padding: 24rpx;
margin-bottom: 32rpx;
.summary-row {
display: flex;
font-size: 26rpx;
margin-bottom: 14rpx;
&:last-child {
margin-bottom: 0;
}
.label {
color: #6b7280;
width: 150rpx;
}
.value {
color: #111827;
flex: 1;
&.highlight-code {
font-size: 32rpx;
font-weight: 700;
color: #10b981;
}
&.goods-text {
word-break: break-all;
}
}
}
.staff-picker-box {
margin-top: 20rpx;
padding-top: 20rpx;
border-top: 1rpx dashed #e5e7eb;
.staff-label {
font-size: 24rpx;
color: #6b7280;
display: block;
margin-bottom: 12rpx;
}
.picker-display {
display: flex;
align-items: center;
justify-content: space-between;
background: #ffffff;
border: 1rpx solid #d1d5db;
border-radius: 12rpx;
padding: 16rpx 20rpx;
font-size: 26rpx;
color: #111827;
}
}
}
.modal-footer {
display: flex;
gap: 20rpx;
.modal-btn {
flex: 1;
height: 84rpx;
border-radius: 16rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 30rpx;
font-weight: 600;
&.cancel {
background: #f3f4f6;
color: #4b5563;
}
&.confirm {
background: #111827;
color: #ffffff;
&.loading {
opacity: 0.7;
}
}
}
}
}
}
</style>

View File

@@ -0,0 +1,550 @@
<template>
<view class="merchant-login-page">
<!-- 顶部状态栏沉浸背景 -->
<view class="header-bg">
<view class="brand-box">
<view class="badge-icon">
<u-icon name="bag" size="32" color="#ffffff"></u-icon>
</view>
<text class="brand-title">商家管理工作台</text>
<text class="brand-desc">随时随地 · 快捷扫码核销与订单管理</text>
</view>
</view>
<!-- 登录卡片 -->
<view class="login-card">
<!-- 模式切换 Tab -->
<view class="tab-header">
<view
class="tab-item"
:class="{ active: loginType === 'account' }"
@click="switchTab('account')"
>
<text>账号密码登录</text>
<view class="active-indicator" v-if="loginType === 'account'"></view>
</view>
<view
class="tab-item"
:class="{ active: loginType === 'sms' }"
@click="switchTab('sms')"
>
<text>短信验证码登录</text>
<view class="active-indicator" v-if="loginType === 'sms'"></view>
</view>
</view>
<!-- 账号密码表单 -->
<view class="form-container" v-if="loginType === 'account'">
<view class="input-item">
<u-input
v-model="accountForm.username"
placeholder="请输入商家账号/手机号"
border="surround"
prefixIcon="account"
:prefixIconStyle="{ color: '#8c8c8c', fontSize: '36rpx', marginRight: '16rpx' }"
:customStyle="customInputStyle"
clearable
/>
</view>
<view class="input-item">
<u-input
v-model="accountForm.password"
placeholder="请输入登录密码"
type="password"
border="surround"
prefixIcon="lock"
:prefixIconStyle="{ color: '#8c8c8c', fontSize: '36rpx', marginRight: '16rpx' }"
:customStyle="customInputStyle"
clearable
/>
</view>
</view>
<!-- 短信验证码表单 -->
<view class="form-container" v-else>
<view class="input-item">
<u-input
v-model="smsForm.mobile"
placeholder="请输入店主手机号"
type="number"
maxlength="11"
border="surround"
prefixIcon="phone"
:prefixIconStyle="{ color: '#8c8c8c', fontSize: '36rpx', marginRight: '16rpx' }"
:customStyle="customInputStyle"
clearable
/>
</view>
<view class="input-item">
<u-input
v-model="smsForm.code"
placeholder="请输入 6 位短信验证码"
type="number"
maxlength="6"
border="surround"
prefixIcon="email"
:prefixIconStyle="{ color: '#8c8c8c', fontSize: '36rpx', marginRight: '16rpx' }"
:customStyle="customInputStyle"
clearable
>
<template #suffix>
<view
class="send-btn"
:class="{ disabled: smsCount > 0 || !smsForm.mobile }"
@click="handleSendSms"
>
<text>{{ smsCount > 0 ? `${smsCount}s后重试` : '获取验证码' }}</text>
</view>
</template>
</u-input>
</view>
</view>
<!-- 登录提交按钮 -->
<view class="action-btn" :class="{ loading: submitting }" @click="handleLogin">
<text class="btn-text">{{ submitting ? '正在登录...' : '立即进入工作台' }}</text>
</view>
<view class="notice-tip">
<u-icon name="info-circle" size="14" color="#8c8c8c"></u-icon>
<text class="notice-text">仅限已入驻商城的店主/店员账号登录</text>
</view>
</view>
<!-- 安全滑块拼图验证码弹窗 -->
<myVerification
v-if="codeFlag"
ref="verificationRef"
apiType="store"
business="LOGIN"
@send="handleVerificationSuccess"
/>
</view>
</template>
<script setup lang="ts">
import { ref, reactive, onBeforeUnmount, nextTick } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import storage from '@/utils/storage.js'
import myVerification from '@/components/verification/verification.vue'
import {
userLogin,
smsLogin,
sendStoreSms,
getStoreSettings,
getStoreUserInfo,
getStoreDetail,
} from '../../api/passport.js'
const loginType = ref<'account' | 'sms'>('account')
const submitting = ref(false)
const smsCount = ref(0)
let timer: any = null
// 滑块验证码相关控制
const codeFlag = ref(false)
const verificationRef = ref<any>(null)
const verifyAction = ref<'login' | 'sms'>('login')
const customInputStyle = {
backgroundColor: '#f9fafb',
borderRadius: '16rpx',
height: '84rpx',
paddingLeft: '16rpx',
fontSize: '28rpx',
}
const accountForm = reactive({
username: '',
password: '',
})
const smsForm = reactive({
mobile: '',
code: '',
})
onLoad(() => {
// 如果已存在商家 token,直接进入工作台
if (storage.getStoreAccessToken()) {
uni.redirectTo({
url: '/pages-sub/merchant/pages/index/index',
})
}
})
onBeforeUnmount(() => {
if (timer) {
clearInterval(timer)
timer = null
}
})
function switchTab(type: 'account' | 'sms') {
loginType.value = type
}
// 弹出滑块拼图验证码
function openVerification(action: 'login' | 'sms') {
verifyAction.value = action
codeFlag.value = true
nextTick(() => {
verificationRef.value?.show()
verificationRef.value?.getCode()
})
}
// 点击获取短信验证码
const handleSendSms = () => {
if (smsCount.value > 0) return
if (!/^1[3-9]\d{9}$/.test(smsForm.mobile)) {
uni.showToast({ title: '请输入正确的11位手机号', icon: 'none' })
return
}
// 发送短信验证码前先通过滑块拼图验证
openVerification('sms')
}
// 点击“立即进入工作台”按钮
const handleLogin = () => {
if (submitting.value) return
if (loginType.value === 'account') {
if (!accountForm.username.trim()) {
uni.showToast({ title: '请输入商家账号', icon: 'none' })
return
}
if (!accountForm.password) {
uni.showToast({ title: '请输入登录密码', icon: 'none' })
return
}
// 账号密码登录:必须先通过安全滑块拼图验证
openVerification('login')
} else {
// 短信验证码登录
if (!/^1[3-9]\d{9}$/.test(smsForm.mobile)) {
uni.showToast({ title: '请输入有效的手机号', icon: 'none' })
return
}
if (!smsForm.code.trim()) {
uni.showToast({ title: '请输入验证码', icon: 'none' })
return
}
// 短信验证码登录直接提交
doSmsLogin()
}
}
// 滑块验证码成功回调
const handleVerificationSuccess = () => {
if (verifyAction.value === 'login') {
doAccountLogin()
} else if (verifyAction.value === 'sms') {
doSendSms()
}
}
// 执行账号密码登录
const doAccountLogin = async () => {
submitting.value = true
uni.showLoading({ title: '正在登录...' })
try {
const res: any = await userLogin({
username: accountForm.username.trim(),
password: accountForm.password,
})
uni.hideLoading()
submitting.value = false
if (res?.data && res.data.success && res.data.result) {
codeFlag.value = false
const { accessToken, refreshToken } = res.data.result
storage.setStoreAccessToken(accessToken)
if (refreshToken) {
storage.setStoreRefreshToken(refreshToken)
}
// 获取店铺与店员信息
try {
const [settingsRes, userRes, storeRes] = (await Promise.all([
getStoreSettings().catch(() => null),
getStoreUserInfo().catch(() => null),
getStoreDetail().catch(() => null),
])) || []
const storeInfo = {
settings: settingsRes?.data?.result || {},
user: userRes?.data?.result || {},
store: storeRes?.data?.result || {},
}
storage.setStoreInfo(storeInfo)
} catch (e) {
console.warn('获取店铺额外信息失败', e)
}
uni.showToast({ title: '登录成功', icon: 'success' })
setTimeout(() => {
uni.redirectTo({
url: '/pages-sub/merchant/pages/index/index',
})
}, 500)
} else {
uni.showToast({
title: res?.data?.message || '登录失败,请检查账号密码',
icon: 'none',
})
verificationRef.value?.getCode()
}
} catch (err: any) {
uni.hideLoading()
submitting.value = false
verificationRef.value?.getCode()
uni.showToast({
title: err?.data?.message || '网络连接异常或账号密码错误',
icon: 'none',
})
}
}
// 执行发送短信验证码
const doSendSms = async () => {
try {
uni.showLoading({ title: '发送中...' })
const res = await sendStoreSms(smsForm.mobile, 'LOGIN')
uni.hideLoading()
if (res?.data && res.data.success) {
codeFlag.value = false
uni.showToast({ title: '验证码已发送', icon: 'success' })
smsCount.value = 60
timer = setInterval(() => {
smsCount.value--
if (smsCount.value <= 0) {
clearInterval(timer)
timer = null
}
}, 1000)
} else {
verificationRef.value?.getCode()
uni.showToast({
title: res?.data?.message || '发送失败,请稍后重试',
icon: 'none',
})
}
} catch (e: any) {
uni.hideLoading()
verificationRef.value?.getCode()
uni.showToast({ title: e?.data?.message || '网络异常,发送失败', icon: 'none' })
}
}
// 执行短信登录
const doSmsLogin = async () => {
submitting.value = true
uni.showLoading({ title: '正在登录...' })
try {
const res: any = await smsLogin({
mobile: smsForm.mobile.trim(),
code: smsForm.code.trim(),
})
uni.hideLoading()
submitting.value = false
if (res?.data && res.data.success && res.data.result) {
const { accessToken, refreshToken } = res.data.result
storage.setStoreAccessToken(accessToken)
if (refreshToken) {
storage.setStoreRefreshToken(refreshToken)
}
try {
const [settingsRes, userRes, storeRes] = (await Promise.all([
getStoreSettings().catch(() => null),
getStoreUserInfo().catch(() => null),
getStoreDetail().catch(() => null),
])) || []
const storeInfo = {
settings: settingsRes?.data?.result || {},
user: userRes?.data?.result || {},
store: storeRes?.data?.result || {},
}
storage.setStoreInfo(storeInfo)
} catch (e) {
console.warn('获取店铺额外信息失败', e)
}
uni.showToast({ title: '登录成功', icon: 'success' })
setTimeout(() => {
uni.redirectTo({
url: '/pages-sub/merchant/pages/index/index',
})
}, 500)
} else {
uni.showToast({
title: res?.data?.message || '登录失败,请检查验证码',
icon: 'none',
})
}
} catch (err: any) {
uni.hideLoading()
submitting.value = false
uni.showToast({ title: err?.data?.message || '网络连接异常', icon: 'none' })
}
}
</script>
<style lang="scss" scoped>
.merchant-login-page {
min-height: 100vh;
background-color: #f7f8fa;
display: flex;
flex-direction: column;
}
.header-bg {
background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
padding: 100rpx 40rpx 140rpx 40rpx;
color: #ffffff;
display: flex;
justify-content: center;
align-items: center;
.brand-box {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
.badge-icon {
width: 100rpx;
height: 100rpx;
border-radius: 24rpx;
background: rgba(255, 255, 255, 0.12);
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 24rpx;
}
.brand-title {
font-size: 38rpx;
font-weight: 700;
letter-spacing: 2rpx;
margin-bottom: 12rpx;
}
.brand-desc {
font-size: 24rpx;
color: rgba(255, 255, 255, 0.65);
}
}
}
.login-card {
margin: -80rpx 32rpx 40rpx 32rpx;
background: #ffffff;
border-radius: 28rpx;
padding: 40rpx 36rpx;
box-shadow: 0 12rpx 36rpx rgba(0, 0, 0, 0.06);
.tab-header {
display: flex;
border-bottom: 1rpx solid #f0f0f0;
margin-bottom: 36rpx;
.tab-item {
flex: 1;
text-align: center;
padding-bottom: 24rpx;
font-size: 30rpx;
color: #8c8c8c;
font-weight: 500;
position: relative;
&.active {
color: #111827;
font-weight: 700;
}
.active-indicator {
position: absolute;
bottom: -1rpx;
left: 50%;
transform: translateX(-50%);
width: 48rpx;
height: 6rpx;
background: #111827;
border-radius: 3rpx;
}
}
}
.form-container {
.input-item {
margin-bottom: 28rpx;
.send-btn {
padding: 10rpx 20rpx;
background: #111827;
color: #ffffff;
border-radius: 10rpx;
font-size: 24rpx;
white-space: nowrap;
&.disabled {
background: #d1d5db;
color: #9ca3af;
}
}
}
}
.action-btn {
background: #111827;
border-radius: 18rpx;
height: 92rpx;
display: flex;
align-items: center;
justify-content: center;
margin-top: 32rpx;
box-shadow: 0 8rpx 20rpx rgba(17, 24, 39, 0.2);
.btn-text {
color: #ffffff;
font-size: 32rpx;
font-weight: 600;
}
&.loading {
opacity: 0.7;
}
}
.notice-tip {
display: flex;
align-items: center;
justify-content: center;
margin-top: 28rpx;
gap: 8rpx;
.notice-text {
font-size: 22rpx;
color: #9ca3af;
}
}
}
</style>

View File

@@ -0,0 +1,586 @@
<template>
<view class="merchant-order-detail">
<!-- 状态头部 -->
<view class="status-banner" :class="getStatusClass(orderDetail?.order?.orderStatus)">
<view class="status-icon">
<u-icon :name="getStatusIcon(orderDetail?.order?.orderStatus)" size="28" color="#ffffff"></u-icon>
</view>
<view class="status-text-box">
<text class="status-title">{{ getStatusText(orderDetail?.order?.orderStatus) }}</text>
<view class="sn-row" @click="copySn(orderSn)">
<text class="status-sub">订单编号:{{ orderSn }}</text>
<u-icon name="file-text" size="13" color="rgba(255,255,255,0.8)"></u-icon>
</view>
</view>
</view>
<!-- 核销码专属卡片 -->
<view class="verify-code-card" v-if="orderDetail?.order?.verificationCode || isAppointment">
<view class="card-title-row">
<text class="card-title">核销凭证</text>
<view class="code-badge">
{{ isAppointment ? '预约核销' : '自提核销' }}
</view>
</view>
<view class="code-box">
<text class="code-number">{{ orderDetail?.order?.verificationCode || '--' }}</text>
<view
class="verify-now-btn"
v-if="orderDetail?.order?.orderStatus === 'TAKE'"
@click="handleDirectVerify"
>
立即核销
</view>
</view>
</view>
<!-- 买家 / 收货信息 -->
<view class="info-card">
<view class="card-title-row">
<text class="card-title">买家信息</text>
</view>
<view class="info-row">
<text class="info-label">收货人/自提人:</text>
<text class="info-value">{{ orderDetail?.order?.consigneeName || '匿名买家' }}</text>
</view>
<view class="info-row">
<text class="info-label">联系电话:</text>
<text class="info-value">{{ maskPhone(orderDetail?.order?.consigneeMobile) }}</text>
</view>
<view class="info-row" v-if="orderDetail?.order?.consigneeAddressPath">
<text class="info-label">地址:</text>
<text class="info-value">{{ orderDetail?.order?.consigneeAddressPath }} {{ orderDetail?.order?.consigneeDetail || '' }}</text>
</view>
</view>
<!-- 商品清单(干净规范,拒绝裸露 JSON) -->
<view class="info-card">
<view class="card-title-row">
<text class="card-title">商品清单</text>
</view>
<view
class="goods-row"
v-for="(item, idx) in (orderDetail?.orderItems || [])"
:key="item.id || item.goodsId || idx"
>
<image class="goods-img" :src="getGoodsImage(item)" mode="aspectFill"></image>
<view class="goods-detail">
<text class="goods-title">{{ getGoodsTitle(item) }}</text>
<view class="sku-tag" v-if="getCleanSpecs(item)">
<text>{{ getCleanSpecs(item) }}</text>
</view>
<view class="goods-bottom">
<text class="price">¥{{ item.unitPrice || item.goodsPrice || '0.00' }}</text>
<text class="qty">x{{ item.num || 1 }}</text>
</view>
</view>
</view>
</view>
<!-- 订单财务明细 -->
<view class="info-card">
<view class="card-title-row">
<text class="card-title">费用明细</text>
</view>
<view class="fee-row">
<text class="fee-label">商品总价</text>
<text class="fee-val">¥{{ orderDetail?.order?.goodsPrice || '0.00' }}</text>
</view>
<view class="fee-row" v-if="orderDetail?.order?.discountPrice">
<text class="fee-label">优惠金额</text>
<text class="fee-val discount">-¥{{ orderDetail?.order?.discountPrice }}</text>
</view>
<view class="fee-row" v-if="orderDetail?.order?.freightPrice">
<text class="fee-label">运费</text>
<text class="fee-val">+¥{{ orderDetail?.order?.freightPrice }}</text>
</view>
<view class="fee-divider"></view>
<view class="fee-row total">
<text class="fee-label">实收金额</text>
<text class="fee-val total-price">¥{{ orderDetail?.order?.flowPrice || '0.00' }}</text>
</view>
</view>
<!-- 订单参数(支付方式中文人性化映射) -->
<view class="info-card">
<view class="info-row">
<text class="info-label">下单时间:</text>
<text class="info-value">{{ orderDetail?.order?.createTime || '--' }}</text>
</view>
<view class="info-row" v-if="orderDetail?.order?.paymentTime">
<text class="info-label">支付时间:</text>
<text class="info-value">{{ orderDetail?.order?.paymentTime }}</text>
</view>
<view class="info-row" v-if="orderDetail?.order?.paymentMethod">
<text class="info-label">支付方式:</text>
<text class="info-value pay-method-val">{{ formatPaymentMethod(orderDetail?.order?.paymentMethod) }}</text>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getStoreOrderDetail, storeOrderTake } from '../../api/order.js'
import { parseGoodsImageUrl } from '@/utils/filters.js'
const orderSn = ref('')
const orderDetail = ref<any>(null)
const isAppointment = computed(() => {
return orderDetail.value?.order?.orderType === 'APPOINTMENT_GOODS'
})
onLoad((options: any) => {
if (options?.sn) {
orderSn.value = options.sn
fetchDetail()
}
})
const fetchDetail = async () => {
uni.showLoading({ title: '加载中...' })
try {
const res: any = await getStoreOrderDetail(orderSn.value)
uni.hideLoading()
if (res?.data && res.data.success && res.data.result) {
orderDetail.value = res.data.result
} else {
uni.showToast({ title: '获取订单详情失败', icon: 'none' })
}
} catch (e) {
uni.hideLoading()
uni.showToast({ title: '网络连接异常', icon: 'none' })
}
}
// 复制单号
const copySn = (sn: string) => {
if (!sn) return
uni.setClipboardData({
data: sn,
success: () => {
uni.showToast({ title: '单号已复制', icon: 'none' })
},
})
}
// 提取商品标题
const getGoodsTitle = (item: any) => {
if (item.goodsName && item.goodsName.trim()) return item.goodsName
if (item.name && item.name.trim()) return item.name
if (orderDetail.value?.order?.orderName) return orderDetail.value.order.orderName
return '精选商品'
}
// 智能提取商品图片,过滤并兼顾富文本/JSON 结构
const getGoodsImage = (item: any) => {
if (item.image) {
const parsed = parseGoodsImageUrl(item.image)
if (parsed) return parsed
}
// 若 image 为空,尝试从 specs JSON 里抓取合法的图片 url
if (item.specs && typeof item.specs === 'string') {
const match = item.specs.match(/https?:\/\/[^\s"'\\}]+\.(jpeg|jpg|png|webp|gif)/i)
if (match) return match[0]
}
return '/static/tabbar/home.png'
}
// 智能提炼清洁规格,绝不裸露冗长的原始 JSON
const getCleanSpecs = (item: any) => {
const specs = item.specs
if (!specs || !String(specs).trim()) return ''
const trimmed = String(specs).trim()
// 若为 JSON 格式
if (trimmed.startsWith('{') || trimmed.startsWith('[')) {
try {
const obj = JSON.parse(trimmed)
const ignoreKeys = ['images', 'code', 'message', 'result', 'success', 'showProgress', 'url', 'status']
const pairs: string[] = []
for (const [k, v] of Object.entries(obj)) {
if (!ignoreKeys.includes(k) && typeof v === 'string' && !v.startsWith('http') && v.length < 50) {
pairs.push(`${k}: ${v}`)
}
}
if (pairs.length > 0) return pairs.join(' / ')
} catch (e) {}
// 解析失败正则提取业务键值对
const matches = [...trimmed.matchAll(/"([^"]{1,20})"\s*:\s*"([^"]{1,30})"/g)]
const ignoreKeys = ['code', 'message', 'success', 'url', 'result', 'showProgress', 'status', 'name']
const pairs: string[] = []
for (const m of matches) {
const k = m[1]
const v = m[2]
if (!ignoreKeys.includes(k) && !v.startsWith('http')) {
pairs.push(`${k}: ${v}`)
}
}
if (pairs.length > 0) return pairs.join(' / ')
return ''
}
// 纯文本规格
return trimmed
}
// 支付方式中文映射
const formatPaymentMethod = (method: string) => {
if (!method) return '--'
const map: Record<string, string> = {
WALLET: '余额支付',
ALIPAY: '支付宝支付',
ALIPAY_PC: '支付宝支付',
ALIPAY_WAP: '支付宝支付',
ALIPAY_APP: '支付宝支付',
WECHAT: '微信支付',
WEIXIN: '微信支付',
WECHAT_MP: '微信支付',
WEIXIN_MP: '微信支付',
WX_JSAPI: '微信支付',
WX_APP: '微信支付',
WX_NATIVE: '微信支付',
WX_H5: '微信支付',
BANK_TRANSFER: '银行转账',
POINT: '积分兑换',
CASH: '现金支付',
OFFLINE: '线下支付',
FREE: '免费免付',
}
const key = String(method).toUpperCase().trim()
return map[key] || method
}
const maskPhone = (phone: string) => {
if (!phone || phone.length < 7) return phone || ''
return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
}
const getStatusText = (status: string) => {
const map: Record<string, string> = {
UNPAID: '待付款',
PAID: '已付款',
UNDELIVERED: '待发货',
DELIVERED: '待收货',
COMPLETED: '已完成',
CANCELLED: '已取消',
TAKE: '待核销',
}
return map[status] || status || '处理中'
}
const getStatusClass = (status: string) => {
if (status === 'TAKE') return 'bg-take'
if (status === 'COMPLETED') return 'bg-done'
if (status === 'CANCELLED') return 'bg-cancel'
return 'bg-normal'
}
const getStatusIcon = (status: string) => {
if (status === 'TAKE') return 'checkmark-circle-fill'
if (status === 'COMPLETED') return 'checkmark'
if (status === 'CANCELLED') return 'close'
return 'clock'
}
// 直接在详情页核销
const handleDirectVerify = async () => {
const code = orderDetail.value?.order?.verificationCode
if (!code) {
uni.showToast({ title: '该订单暂无可核销码', icon: 'none' })
return
}
uni.showModal({
title: '确认核销',
content: `确认核销此单?核销码:${code}`,
success: async (res) => {
if (res.confirm) {
uni.showLoading({ title: '正在核销...' })
try {
const takeRes: any = await storeOrderTake(orderSn.value, code)
uni.hideLoading()
if (takeRes?.data && takeRes.data.success) {
uni.showToast({ title: '核销成功', icon: 'success' })
fetchDetail()
} else {
uni.showToast({
title: takeRes?.data?.message || '核销失败',
icon: 'none',
})
}
} catch (e) {
uni.hideLoading()
uni.showToast({ title: '核销异常,请稍后重试', icon: 'none' })
}
}
},
})
}
</script>
<style lang="scss" scoped>
.merchant-order-detail {
min-height: 100vh;
background-color: #f4f5f7;
padding-bottom: calc(50rpx + env(safe-area-inset-bottom));
}
.status-banner {
padding: 44rpx 36rpx;
color: #ffffff;
display: flex;
align-items: center;
&.bg-take {
background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}
&.bg-normal {
background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
}
&.bg-done {
background: #6b7280;
}
&.bg-cancel {
background: #9ca3af;
}
.status-icon {
width: 68rpx;
height: 68rpx;
border-radius: 34rpx;
background: rgba(255, 255, 255, 0.2);
display: flex;
align-items: center;
justify-content: center;
margin-right: 20rpx;
}
.status-text-box {
display: flex;
flex-direction: column;
.status-title {
font-size: 36rpx;
font-weight: 700;
}
.sn-row {
display: flex;
align-items: center;
gap: 8rpx;
margin-top: 8rpx;
.status-sub {
font-size: 24rpx;
color: rgba(255, 255, 255, 0.85);
}
}
}
}
.verify-code-card {
margin: -24rpx 28rpx 24rpx 28rpx;
background: #ffffff;
border-radius: 24rpx;
padding: 28rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.05);
.card-title-row {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20rpx;
.card-title {
font-size: 28rpx;
font-weight: 700;
color: #111827;
}
.code-badge {
font-size: 22rpx;
font-weight: 500;
color: #059669;
background: #ecfdf5;
padding: 4rpx 14rpx;
border-radius: 8rpx;
}
}
.code-box {
display: flex;
justify-content: space-between;
align-items: center;
background: #f9fafb;
border-radius: 16rpx;
padding: 20rpx 28rpx;
.code-number {
font-size: 44rpx;
font-weight: 700;
color: #10b981;
letter-spacing: 4rpx;
}
.verify-now-btn {
background: #111827;
color: #ffffff;
padding: 14rpx 32rpx;
border-radius: 14rpx;
font-size: 26rpx;
font-weight: 600;
box-shadow: 0 4rpx 12rpx rgba(17, 24, 39, 0.2);
}
}
}
.info-card {
margin: 0 28rpx 24rpx 28rpx;
background: #ffffff;
border-radius: 24rpx;
padding: 28rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.02);
.card-title-row {
margin-bottom: 20rpx;
padding-bottom: 14rpx;
border-bottom: 1rpx solid #f9fafb;
.card-title {
font-size: 28rpx;
font-weight: 700;
color: #111827;
}
}
.info-row {
display: flex;
align-items: flex-start;
font-size: 26rpx;
margin-bottom: 16rpx;
&:last-child {
margin-bottom: 0;
}
.info-label {
color: #6b7280;
width: 180rpx;
flex-shrink: 0;
}
.info-value {
color: #111827;
flex: 1;
font-weight: 500;
line-height: 1.4;
&.pay-method-val {
color: #2563eb;
font-weight: 600;
}
}
}
.goods-row {
display: flex;
padding: 18rpx 0;
border-bottom: 1rpx solid #f9fafb;
&:last-child {
border-bottom: none;
}
.goods-img {
width: 140rpx;
height: 140rpx;
border-radius: 14rpx;
background: #f9fafb;
border: 1rpx solid #f3f4f6;
flex-shrink: 0;
}
.goods-detail {
flex: 1;
margin-left: 20rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
.goods-title {
font-size: 28rpx;
color: #111827;
font-weight: 600;
line-height: 1.4;
}
.sku-tag {
margin-top: 6rpx;
text {
font-size: 22rpx;
color: #6b7280;
background: #f3f4f6;
padding: 4rpx 12rpx;
border-radius: 6rpx;
}
}
.goods-bottom {
display: flex;
justify-content: space-between;
align-items: baseline;
margin-top: 10rpx;
.price {
font-size: 30rpx;
font-weight: 700;
color: #111827;
}
.qty {
font-size: 22rpx;
color: #9ca3af;
}
}
}
}
.fee-row {
display: flex;
justify-content: space-between;
font-size: 26rpx;
margin-bottom: 14rpx;
color: #6b7280;
.discount {
color: #10b981;
}
&.total {
margin-top: 16rpx;
margin-bottom: 0;
font-size: 28rpx;
font-weight: 700;
color: #111827;
.total-price {
font-size: 36rpx;
font-weight: 700;
color: #ef4444;
}
}
}
.fee-divider {
height: 1rpx;
background: #f3f4f6;
margin: 16rpx 0;
}
}
</style>

View File

@@ -0,0 +1,653 @@
<template>
<view class="merchant-order-page">
<!-- 顶部吸顶搜索栏与 Tab -->
<view class="sticky-header">
<!-- 搜索栏 -->
<view class="search-box">
<view class="search-input-wrap">
<u-icon name="search" size="18" color="#9ca3af"></u-icon>
<input
class="search-input"
type="text"
v-model="keywords"
placeholder="搜索订单号 / 买家手机号"
placeholder-class="placeholder"
confirm-type="search"
@confirm="onSearch"
/>
<view class="clear-btn" v-if="keywords" @click="clearSearch">
<u-icon name="close-circle-fill" size="16" color="#d1d5db"></u-icon>
</view>
</view>
<view class="search-action-btn" v-if="keywords" @click="onSearch">
<text>搜索</text>
</view>
</view>
<!-- 状态横向滑动 Tab 栏(绝不折行) -->
<scroll-view class="tab-scroll" scroll-x :show-scrollbar="false" :scroll-with-animation="true">
<view class="tab-inner">
<view
class="tab-item"
v-for="item in tabList"
:key="item.key"
:class="{ active: currentTab === item.key }"
@click="switchTab(item.key)"
>
<text class="tab-label">{{ item.label }}</text>
<view class="indicator" v-if="currentTab === item.key"></view>
</view>
</view>
</scroll-view>
</view>
<!-- 订单列表主体 -->
<view class="order-list-body">
<!-- 列表数据 -->
<view
class="order-card"
v-for="order in orderList"
:key="order.sn"
@click="goToDetail(order.sn)"
>
<!-- 头部:单号与状态 -->
<view class="card-head">
<view class="sn-box" @click.stop="copySn(order.sn)">
<text class="order-sn">单号:{{ order.sn }}</text>
<u-icon name="file-text" size="14" color="#9ca3af"></u-icon>
</view>
<view class="status-badge" :class="getStatusClass(order.orderStatus)">
{{ getStatusText(order.orderStatus) }}
</view>
</view>
<!-- 商品信息 -->
<view class="goods-container">
<view
class="goods-item"
v-for="goods in (order.orderItems || [])"
:key="goods.id || goods.goodsId"
>
<image class="goods-thumb" :src="goods.image || '/static/tabbar/home.png'" mode="aspectFill"></image>
<view class="goods-info">
<text class="goods-name">{{ getGoodsName(goods, order) }}</text>
<view class="spec-pill" v-if="getSpecText(goods)">
<text>{{ getSpecText(goods) }}</text>
</view>
<view class="price-qty-row">
<text class="goods-price">¥{{ goods.unitPrice || goods.goodsPrice || '0.00' }}</text>
<text class="goods-qty">x{{ goods.num || 1 }}</text>
</view>
</view>
</view>
</view>
<!-- 订单金额与买家信息 -->
<view class="card-foot">
<view class="buyer-info" v-if="order.consigneeMobile || order.memberPhone">
<u-icon name="account" size="14" color="#9ca3af"></u-icon>
<text class="buyer-tel">{{ maskPhone(order.consigneeMobile || order.memberPhone) }}</text>
</view>
<view class="buyer-info" v-else>
<text class="order-type-tag" v-if="order.orderType === 'APPOINTMENT_GOODS'">预约商品单</text>
<text class="order-type-tag" v-else-if="order.verificationCode">自提单</text>
</view>
<view class="total-bar">
<text class="total-label">实付:</text>
<text class="total-symbol">¥</text>
<text class="total-price">{{ order.flowPrice || '0.00' }}</text>
</view>
</view>
<!-- 核销专属快捷动作 -->
<view class="card-actions" v-if="order.verificationCode || order.orderType === 'APPOINTMENT_GOODS' || order.orderStatus === 'TAKE'">
<view class="action-btn verify" @click.stop="quickVerify(order)">
<u-icon name="scan" size="15" color="#ffffff"></u-icon>
<text class="btn-lbl">扫码/输码核销</text>
</view>
</view>
</view>
<!-- 空状态 -->
<view class="empty-state" v-if="!loading && orderList.length === 0">
<u-icon name="order" size="64" color="#d1d5db"></u-icon>
<text class="empty-text">暂无相关订单记录</text>
</view>
<!-- 加载提示 -->
<view class="loading-more" v-if="loading">
<text>正在加载订单数据...</text>
</view>
<view class="no-more" v-else-if="finished && orderList.length > 0">
<text>— 没有更多了 —</text>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { getStoreOrderList } from '../../api/order.js'
const keywords = ref('')
const currentTab = ref('ALL')
const loading = ref(false)
const finished = ref(false)
const pageNumber = ref(1)
const pageSize = ref(10)
const orderList = ref<any[]>([])
// 优化 Tab 标题,保持精练统一、绝不换行
const tabList = [
{ key: 'ALL', label: '全部' },
{ key: 'TAKE', label: '待核销' },
{ key: 'UNDELIVERED', label: '待发货' },
{ key: 'DELIVERED', label: '待收货' },
{ key: 'COMPLETED', label: '已完成' },
]
onLoad((options: any) => {
if (options?.tab) {
currentTab.value = options.tab
}
fetchOrders(true)
})
onPullDownRefresh(async () => {
await fetchOrders(true)
uni.stopPullDownRefresh()
})
onReachBottom(() => {
if (!finished.value && !loading.value) {
pageNumber.value++
fetchOrders(false)
}
})
const fetchOrders = async (reset = false) => {
if (reset) {
pageNumber.value = 1
orderList.value = []
finished.value = false
}
loading.value = true
const params: any = {
pageNumber: pageNumber.value,
pageSize: pageSize.value,
keywords: keywords.value.trim() || undefined,
}
if (currentTab.value !== 'ALL') {
params.orderStatus = currentTab.value
}
try {
const res: any = await getStoreOrderList(params)
loading.value = false
if (res?.data && res.data.success) {
const records = res.data.result?.records || []
if (reset) {
orderList.value = records
} else {
orderList.value = [...orderList.value, ...records]
}
if (records.length < pageSize.value) {
finished.value = true
}
} else {
uni.showToast({
title: res?.data?.message || '获取订单列表失败',
icon: 'none',
})
}
} catch (e) {
loading.value = false
uni.showToast({ title: '网络连接异常', icon: 'none' })
}
}
const switchTab = (key: string) => {
if (currentTab.value === key) return
currentTab.value = key
fetchOrders(true)
}
const onSearch = () => {
fetchOrders(true)
}
const clearSearch = () => {
keywords.value = ''
fetchOrders(true)
}
const goToDetail = (sn: string) => {
uni.navigateTo({
url: `/pages-sub/merchant/pages/order/detail?sn=${sn}`,
})
}
// 快捷核销
const quickVerify = (order: any) => {
uni.navigateTo({
url: `/pages-sub/merchant/pages/order/detail?sn=${order.sn}&autoVerify=1`,
})
}
// 复制单号
const copySn = (sn: string) => {
if (!sn) return
uni.setClipboardData({
data: sn,
success: () => {
uni.showToast({ title: '单号已复制', icon: 'none' })
},
})
}
// 提取商品名(容错兜底)
const getGoodsName = (goods: any, order: any) => {
if (goods.goodsName && goods.goodsName.trim()) return goods.goodsName
if (goods.name && goods.name.trim()) return goods.name
if (order.orderName && order.orderName.trim()) return order.orderName
if (goods.specs && goods.specs.trim()) return goods.specs
return '精选商品'
}
// 提取规格文本(智能剔除多余字段)
const getSpecText = (goods: any) => {
const specs = goods.specs
if (!specs || !String(specs).trim()) return ''
if (specs === goods.goodsName) return ''
// 处理 JSON 字符串形式
if (typeof specs === 'string' && (specs.startsWith('{') || specs.startsWith('['))) {
try {
const obj = JSON.parse(specs)
if (typeof obj === 'object') {
const values = Object.values(obj).filter(Boolean)
if (values.length) return values.join(' / ')
}
} catch (e) {}
}
return String(specs)
}
// 手机号脱敏
const maskPhone = (phone: string) => {
if (!phone) return ''
const str = String(phone).trim()
if (str.length === 11) {
return str.substring(0, 3) + '****' + str.substring(7)
}
return str
}
// 状态文字映射
const getStatusText = (status: string) => {
const map: Record<string, string> = {
UNPAID: '待付款',
PAID: '已付款',
UNDELIVERED: '待发货',
DELIVERED: '待收货',
COMPLETED: '已完成',
CANCELLED: '已取消',
TAKE: '待核销',
}
return map[status] || status || '处理中'
}
// 状态样式类
const getStatusClass = (status: string) => {
switch (status) {
case 'TAKE':
return 'status-take'
case 'COMPLETED':
return 'status-done'
case 'CANCELLED':
return 'status-cancel'
default:
return 'status-normal'
}
}
</script>
<style lang="scss" scoped>
.merchant-order-page {
min-height: 100vh;
background-color: #f4f5f7;
padding-bottom: calc(40rpx + env(safe-area-inset-bottom));
}
.sticky-header {
position: sticky;
top: 0;
z-index: 50;
background: #ffffff;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
.search-box {
padding: 16rpx 28rpx 10rpx 28rpx;
display: flex;
align-items: center;
gap: 16rpx;
.search-input-wrap {
flex: 1;
height: 72rpx;
background: #f3f4f6;
border-radius: 36rpx;
display: flex;
align-items: center;
padding: 0 24rpx;
.search-input {
flex: 1;
margin-left: 12rpx;
font-size: 26rpx;
color: #111827;
}
.placeholder {
color: #9ca3af;
font-size: 26rpx;
}
.clear-btn {
padding: 6rpx;
}
}
.search-action-btn {
font-size: 28rpx;
color: #2563eb;
font-weight: 600;
padding: 0 8rpx;
}
}
.tab-scroll {
width: 100%;
white-space: nowrap;
.tab-inner {
display: flex;
align-items: center;
padding: 0 16rpx;
min-width: 100%;
box-sizing: border-box;
.tab-item {
flex: 1;
min-width: 130rpx;
text-align: center;
padding: 22rpx 12rpx;
position: relative;
white-space: nowrap;
.tab-label {
font-size: 28rpx;
color: #6b7280;
font-weight: 500;
transition: all 0.2s ease;
}
&.active {
.tab-label {
color: #111827;
font-weight: 700;
font-size: 30rpx;
}
.indicator {
position: absolute;
bottom: 4rpx;
left: 50%;
transform: translateX(-50%);
width: 44rpx;
height: 6rpx;
background: #111827;
border-radius: 3rpx;
}
}
}
}
}
}
.order-list-body {
padding: 24rpx 28rpx;
.order-card {
background: #ffffff;
border-radius: 24rpx;
padding: 28rpx;
margin-bottom: 24rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.03);
.card-head {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 20rpx;
border-bottom: 1rpx solid #f3f4f6;
.sn-box {
display: flex;
align-items: center;
gap: 8rpx;
.order-sn {
font-size: 24rpx;
color: #6b7280;
font-weight: 500;
}
}
.status-badge {
font-size: 22rpx;
font-weight: 600;
padding: 6rpx 16rpx;
border-radius: 10rpx;
&.status-take {
background: #ecfdf5;
color: #059669;
}
&.status-done {
background: #f3f4f6;
color: #6b7280;
}
&.status-cancel {
background: #f9fafb;
color: #9ca3af;
}
&.status-normal {
background: #fff7ed;
color: #ea580c;
}
}
}
.goods-container {
padding: 10rpx 0;
.goods-item {
display: flex;
padding: 16rpx 0;
border-bottom: 1rpx solid #fafafa;
&:last-child {
border-bottom: none;
}
.goods-thumb {
width: 140rpx;
height: 140rpx;
border-radius: 14rpx;
background: #f9fafb;
border: 1rpx solid #f3f4f6;
flex-shrink: 0;
}
.goods-info {
flex: 1;
margin-left: 20rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
.goods-name {
font-size: 28rpx;
font-weight: 600;
color: #111827;
line-height: 1.4;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.spec-pill {
margin-top: 6rpx;
text {
font-size: 22rpx;
color: #6b7280;
background: #f3f4f6;
padding: 4rpx 12rpx;
border-radius: 6rpx;
}
}
.price-qty-row {
display: flex;
justify-content: space-between;
align-items: baseline;
margin-top: 10rpx;
.goods-price {
font-size: 28rpx;
font-weight: 700;
color: #111827;
}
.goods-qty {
font-size: 22rpx;
color: #9ca3af;
}
}
}
}
}
.card-foot {
display: flex;
justify-content: space-between;
align-items: center;
padding-top: 20rpx;
border-top: 1rpx solid #f9fafb;
.buyer-info {
display: flex;
align-items: center;
gap: 8rpx;
.buyer-tel {
font-size: 24rpx;
color: #6b7280;
font-weight: 500;
}
.order-type-tag {
font-size: 20rpx;
color: #2563eb;
background: #eff6ff;
padding: 4rpx 12rpx;
border-radius: 6rpx;
}
}
.total-bar {
display: flex;
align-items: baseline;
.total-label {
font-size: 24rpx;
color: #6b7280;
}
.total-symbol {
font-size: 24rpx;
font-weight: 700;
color: #ef4444;
}
.total-price {
font-size: 34rpx;
font-weight: 700;
color: #ef4444;
margin-left: 2rpx;
}
}
}
.card-actions {
display: flex;
justify-content: flex-end;
padding-top: 20rpx;
margin-top: 16rpx;
border-top: 1rpx dashed #e5e7eb;
.action-btn {
display: flex;
align-items: center;
gap: 8rpx;
padding: 14rpx 28rpx;
border-radius: 36rpx;
font-size: 26rpx;
font-weight: 600;
&.verify {
background: #111827;
color: #ffffff;
box-shadow: 0 4rpx 12rpx rgba(17, 24, 39, 0.15);
.btn-lbl {
font-size: 24rpx;
}
}
}
}
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 120rpx 0;
.empty-text {
font-size: 28rpx;
color: #9ca3af;
margin-top: 24rpx;
}
}
.loading-more,
.no-more {
text-align: center;
padding: 30rpx 0;
font-size: 24rpx;
color: #9ca3af;
}
}
</style>

View File

@@ -0,0 +1,155 @@
import api from "@/config/api.js";
import Request from "@/lib/request/index.js";
import Foundation from "@/utils/Foundation.js";
import { md5 } from "@/utils/md5.js";
import storage from "@/utils/storage.js";
import uuid from "@/utils/uuid.modified.js";
let isStoreNavigateTo = false;
function cleanStoreAuth() {
uni.showToast({
title: "商家登录状态已过期,请重新登录",
icon: "none",
duration: 1800,
});
storage.clearStoreAuth();
if (!isStoreNavigateTo) {
isStoreNavigateTo = true;
setTimeout(() => {
isStoreNavigateTo = false;
uni.reLaunch({
url: "/pages-sub/merchant/pages/login/index",
});
}, 1200);
}
}
const storeHttp = new Request();
const ensureUuid = () => {
if (!storage.getUuid()) {
storage.setUuid(uuid.v1());
}
};
storeHttp.setConfig((config) => {
ensureUuid();
config.baseURL = api.store;
config.header = {
...config.header,
};
config.validateStatus = () => true;
return config;
});
storeHttp.interceptors.request.use(
(config) => {
ensureUuid();
const token = storage.getStoreAccessToken();
if (token) {
const nonce = Foundation.randomString(6);
const timestamp = parseInt(new Date().getTime() / 1000);
const sign = md5(nonce + timestamp + token);
const _params = { nonce, timestamp, sign };
config.params = { ...(config.params || {}), ..._params };
config.header.accessToken = token;
}
config.header = {
...config.header,
uuid: storage.getUuid(),
};
return config;
},
(config) => Promise.reject(config)
);
let isStoreRefreshing = false;
let storeRequests = [];
function refreshTokenApi(refreshToken) {
return uni.request({
url: `${api.store}/passport/login/refresh/${refreshToken}`,
method: "GET",
header: {
uuid: storage.getUuid(),
},
});
}
storeHttp.interceptors.response.use(
async (response) => {
isStoreNavigateTo = false;
try {
uni.hideLoading();
} catch (e) {}
const token = storage.getStoreAccessToken();
const refreshToken = storage.getStoreRefreshToken();
// 403 / 401 并且有 refreshToken,尝试刷新
if (
token &&
refreshToken &&
(response.statusCode === 403 || response.statusCode === 401 || response.data?.code === 403)
) {
if (!isStoreRefreshing) {
isStoreRefreshing = true;
storage.removeStoreAccessToken();
try {
const [err, res] = await refreshTokenApi(refreshToken);
const data = res?.data || err?.data;
if (data && data.success && data.result) {
const { accessToken: newAccessToken, refreshToken: newRefreshToken } = data.result;
storage.setStoreAccessToken(newAccessToken);
if (newRefreshToken) {
storage.setStoreRefreshToken(newRefreshToken);
}
response.header = response.header || {};
response.header.accessToken = `${newAccessToken}`;
storeRequests.forEach((cb) => cb(newAccessToken));
storeRequests = [];
return storeHttp.request(response.config);
} else {
cleanStoreAuth();
return Promise.reject(data);
}
} catch (e) {
cleanStoreAuth();
return Promise.reject(e);
} finally {
isStoreRefreshing = false;
}
} else {
return new Promise((resolve) => {
storeRequests.push((newToken) => {
response.header = response.header || {};
response.header.accessToken = `${newToken}`;
resolve(storeHttp.request(response.config));
});
});
}
} else if (
(!token && (response.statusCode === 403 || response.statusCode === 401)) ||
response.data?.code === 403 ||
response.data?.code === 401
) {
cleanStoreAuth();
} else if ((response.statusCode === 200 && response.data && !response.data.success) || response.statusCode === 400) {
if (response.data?.message) {
uni.showToast({
title: response.data.message,
icon: "none",
duration: 2000,
});
}
}
return response;
},
(error) => error
);
export { storeHttp };
export default storeHttp;

1971
pages.json

File diff suppressed because it is too large Load Diff

View File

@@ -1,302 +1,262 @@
<template> <template>
<view class="coupon-center"> <view class="coupon-center">
<div class="swiper-box"> <view class="coupon-list">
<div class="swiper-item"> <u-empty mode="coupon" style='margin-top: 20%;' text="没有优惠券了" v-if="whetherEmpty"></u-empty>
<div class="scroll-v" enableBackToTop="true" scroll-y> <view v-else class="coupon-card" v-for="(item, index) in couponList" :key="index">
<u-empty mode="coupon" style='margin-top: 20%;' text="没有优惠券了" v-if="whetherEmpty"></u-empty> <view class="coupon-card-left">
<view v-else class="coupon-item" v-for="(item, index) in couponList" :key="index"> <text class="coupon-price-symbol">¥</text>
<view class="left"> <text class="coupon-price-value">{{ item.couponType == 'DISCOUNT' ? item.couponDiscount + '折' : unitPrice(item.price) }}</text>
<view class="wave-line"> </view>
<view class="wave" v-for="(item, index) in 12" :key="index"></view> <view class="coupon-divider"></view>
</view> <view class="coupon-card-right">
<view class="message"> <view class="coupon-info">
<view> <text class="coupon-card-name">{{ item.storeName == 'platform' ? '全平台' : item.storeName + '店铺' }}使用</text>
<!--判断当前优惠券类型 couponType PRICE || DISCOUNT --> <text class="coupon-card-desc">{{ item.consumeThreshold > 0 ? '满' + unitPrice(item.consumeThreshold) + '元可用' : '无门槛使用' }}</text>
<span v-if="item.couponType == 'DISCOUNT'">{{ item.couponDiscount }}折</span> <text class="coupon-card-time" v-if="item.endTime">有效期至:{{ item.endTime.split(" ")[0] }}</text>
<span v-else>{{ item.price }}元</span>
</view>
<view>满{{ item.consumeThreshold | unitPrice }}元可用</view>
</view>
<view class="circle circle-top"></view>
<view class="circle circle-bottom"></view>
</view>
<view class="right">
<view>
<!-- 根据scopeType 判断是否是 平台、品类或店铺 -->
<view class="coupon-title wes-3" v-if="item.scopeType">
<span v-if="item.scopeType == 'ALL' && item.storeId == '0'">全平台</span>
<span v-if="item.scopeType == 'PORTION_GOODS_CATEGORY'">仅限品类</span>
<view v-else>{{ item.storeName == 'platform' ? '全平台' :item.storeName+'店铺' }}使用
</view>
</view>
<view v-if="item.endTime">有效期至:{{ item.endTime.split(" ")[0] }}</view>
</view>
<view class="receive" @click="receive(item)">
<text>点击</text><br />
<text>领取</text>
</view>
<view class="bg-quan"> 券 </view>
</view>
</view> </view>
<view class="coupon-claim-btn" @click="receive(item)">
</div> 领取
</div> </view>
</div> </view>
</view>
</view>
</view> </view>
</template> </template>
<script> <script setup lang="ts">
import { import { receiveCoupons } from '@/api/members.js'
receiveCoupons import { getAllCoupons } from '@/api/promotions.js'
} from "@/api/members.js"; import { useStore } from '@/store'
import { import { unitPrice } from '@/utils/filters.js'
getAllCoupons import {
} from "@/api/promotions.js"; onLoad,
export default { onNavigationBarButtonTap,
data() { onPullDownRefresh,
return { onReachBottom,
loadStatus: "more", //下拉状态 } from '@dcloudio/uni-app'
whetherEmpty: false, //是否为空 import { getCurrentInstance, ref } from 'vue'
couponList: [], // 优惠券列表
params: {
pageNumber: 1,
pageSize: 10,
},
storeId: "", //店铺 id,
couponData: ""
};
},
onLoad(option) {
this.storeId = option.storeId;
this.getCoupon();
},
onReachBottom() {
this.loadMore() const store = useStore()
}, const { proxy } = getCurrentInstance()!
onPullDownRefresh() {
//下拉刷新
this.params.pageNumber = 1;
this.couponList = [];
this.getCoupon();
},
methods: {
/**
* 获取当前优惠券
*/
getCoupon() {
uni.showLoading({
title: "加载中",
});
let submitData = {
...this.params
};
// 判断当前是否有店铺
this.storeId ? (submitData = {
...this.params,
storeId: this.storeId
}) : "",
getAllCoupons(submitData)
.then((res) => {
if (this.$store.state.isShowToast){ uni.hideLoading() };
uni.stopPullDownRefresh();
if (res.data.code == 200) {
// 如果请求成功,展示数据并进行展示
this.couponData = res.data.result
if (this.couponData.total == 0) {
// 当本次请求数据为空展示空信息
this.whetherEmpty = true;
} else {
this.couponList.push(...this.couponData.records);
this.loadStatus = "noMore";
}
}
})
.catch((err) => {
if (this.$store.state.isShowToast){ uni.hideLoading() };
});
},
/**
* 领取优惠券
*/
receive(val) {
this.$u.throttle(()=>{
this.fetchCoupon(val)
}, 1500)
},
fetchCoupon(val){ const loadStatus = ref('more')
receiveCoupons(val.id).then((res) => { const whetherEmpty = ref(false)
if (res.data.code == 200) { const couponList = ref<any[]>([])
uni.showToast({ const params = ref({
title: "领取成功", pageNumber: 1,
icon: "none", pageSize: 10,
}); })
} else { const storeId = ref('')
uni.showToast({ const couponData = ref<any>(null)
title: res.data.message,
icon: "none",
});
}
});
},
/** onLoad((option) => {
* 加载更多 storeId.value = option.storeId || ''
*/ getCoupon()
loadMore() { })
if (this.couponData.total > this.params.pageNumber * this.params.pageSize) {
this.params.pageNumber++; onReachBottom(() => {
this.getCoupon(); loadMore()
} })
},
}, onPullDownRefresh(() => {
onNavigationBarButtonTap(e) { params.value.pageNumber = 1
uni.navigateTo({ couponList.value = []
url: "/pages/cart/coupon/couponIntro", getCoupon()
}); })
},
}; onNavigationBarButtonTap(() => {
uni.navigateTo({
url: '/pages/cart/coupon/couponIntro',
})
})
function hideLoadingIfNeeded() {
if (store.state.isShowToast) uni.hideLoading()
}
function getCoupon() {
uni.showLoading({ title: '加载中' })
const submitData = storeId.value
? { ...params.value, storeId: storeId.value }
: { ...params.value }
getAllCoupons(submitData)
.then((res) => {
hideLoadingIfNeeded()
uni.stopPullDownRefresh()
if (res.data.code == 200) {
couponData.value = res.data.result
if (couponData.value.total == 0) {
whetherEmpty.value = true
} else {
couponList.value.push(...couponData.value.records)
loadStatus.value = 'noMore'
}
}
})
.catch(() => {
hideLoadingIfNeeded()
})
}
function receive(val: any) {
proxy.$u.throttle(() => {
fetchCoupon(val)
}, 1500)
}
function fetchCoupon(val: any) {
receiveCoupons(val.id).then((res) => {
if (res.data.code == 200) {
uni.showToast({ title: '领取成功', icon: 'none' })
} else {
uni.showToast({ title: res.data.message, icon: 'none' })
}
})
}
function loadMore() {
if (couponData.value?.total > params.value.pageNumber * params.value.pageSize) {
params.value.pageNumber++
getCoupon()
}
}
</script> </script>
<style>
page {
height: 100%;
}
</style>
<style lang="scss" scoped> <style lang="scss" scoped>
.coupon-center { .coupon-center {
height: 100%; min-height: 100vh;
background: #f7f8fa;
}
.swiper-box { .coupon-list {
.coupon-item { padding: 24rpx;
display: flex; }
align-items: center;
height: 220rpx;
margin: 20rpx;
.left { .coupon-card {
height: 100%; display: flex;
width: 260rpx; align-items: stretch;
background-color: $light-color; background: #fff;
position: relative; border-radius: 24rpx;
margin-bottom: 24rpx;
position: relative;
box-shadow: none;
border: 1rpx solid #f0f1f5;
overflow: hidden;
transition: transform 0.2s ease, box-shadow 0.2s ease;
.message { &:active {
color: $font-color-white; transform: scale(0.98);
display: flex; }
justify-content: center;
align-items: center;
flex-direction: column;
margin-top: 40rpx;
view:nth-child(1) { &::before,
font-weight: bold; &::after {
font-size: 60rpx; content: "";
} position: absolute;
width: 32rpx;
height: 32rpx;
background: #f7f8fa;
border-radius: 50%;
left: 204rpx;
z-index: 2;
box-shadow: inset 0 0 0 1rpx #eceef2;
}
view:nth-child(2) { &::before {
font-size: $font-sm; top: -16rpx;
} }
}
.wave-line { &::after {
height: 220rpx; bottom: -16rpx;
width: 8rpx; }
position: absolute; }
top: 0;
left: 0;
background-color: $light-color;
overflow: hidden;
.wave { .coupon-card-left {
width: 8rpx; width: 220rpx;
height: 16rpx; min-height: 180rpx;
background-color: #ffffff; display: flex;
border-radius: 0 16rpx 16rpx 0; align-items: center;
margin-top: 4rpx; justify-content: center;
} flex-shrink: 0;
} color: #ff3b30;
position: relative;
background: linear-gradient(135deg, #fff5f5 0%, #ffecec 100%);
}
.circle { .coupon-price-symbol {
width: 40rpx; font-size: 32rpx;
height: 40rpx; font-weight: 700;
background-color: $bg-color; margin-right: 4rpx;
position: absolute; }
border-radius: 50%;
z-index: 111;
}
.circle-top { .coupon-price-value {
top: -20rpx; font-size: 56rpx;
right: -20rpx; font-weight: 900;
} line-height: 1;
letter-spacing: -1rpx;
}
.circle-bottom { .coupon-divider {
bottom: -20rpx; position: absolute;
right: -20rpx; left: 220rpx;
} top: 24rpx;
} bottom: 24rpx;
width: 0;
border-left: 2rpx dashed #eceef2;
}
.right { .coupon-card-right {
display: flex; flex: 1;
justify-content: space-between; padding: 32rpx 32rpx 32rpx 40rpx;
align-items: center; display: flex;
width: 450rpx; align-items: center;
font-size: $font-sm; justify-content: space-between;
height: 100%; gap: 20rpx;
background-color: #ffffff; background: #fff;
overflow: hidden; }
position: relative;
>view:nth-child(1) { .coupon-info {
color: #666666; display: flex;
margin-left: 20rpx; flex-direction: column;
display: flex; gap: 12rpx;
height: 100%; flex: 1;
flex-direction: column; min-width: 0;
justify-content: space-around; }
>view:nth-child(1) { .coupon-card-name {
color: #ff6262; font-size: 30rpx;
font-size: 30rpx; color: #111;
} font-weight: 700;
} line-height: 1.3;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.receive { .coupon-card-desc {
color: #ffffff; font-size: 24rpx;
background-color: $main-color; color: #8a8f99;
border-radius: 50%; font-weight: 500;
width: 86rpx; }
height: 86rpx;
text-align: center;
margin-right: 30rpx;
vertical-align: middle;
padding-top: 8rpx;
position: relative;
z-index: 2;
}
.bg-quan { .coupon-card-time {
width: 244rpx; font-size: 22rpx;
height: 244rpx; color: #b0b3bf;
border: 6rpx solid $main-color; }
border-radius: 50%;
opacity: 0.1;
color: $main-color;
text-align: center;
padding-top: 30rpx;
font-size: 130rpx;
position: absolute;
right: -54rpx;
bottom: -60rpx;
}
}
}
}
}
.coupon-title { .coupon-claim-btn {
width: 260rpx; flex-shrink: 0;
padding: 16rpx 32rpx;
border-radius: 40rpx;
font-size: 26rpx;
font-weight: 700;
color: #fff;
background: linear-gradient(135deg, #ff6b35, #ff4b2b);
box-shadow: 0 8rpx 16rpx rgba(255, 75, 43, 0.25);
} &:active {
opacity: 0.9;
}
}
</style> </style>

View File

@@ -1,53 +1,51 @@
<template> <template>
<view class="content"> <view :style="themeStyle" class="content">
<view class="body"> <view class="body">
<view class="top-view"> <view class="top-view">
<view class="title">{{coupon.title}}</view> <view class="title">{{ coupon.title }}</view>
<view class="price" v-if="coupon.couponType =='PRICE'"><text>¥</text>{{coupon.price | unitPrice}}</view> <view class="price" v-if="coupon.couponType == 'PRICE'"><text>¥</text>{{ unitPrice(coupon.price) }}</view>
<view class="price" v-if="coupon.couponType =='DISCOUNT'">{{coupon.discount}}折</view> <view class="price" v-if="coupon.couponType == 'DISCOUNT'">{{ coupon.discount }}折</view>
<view class="text">满{{coupon.consumeThreshold}}元可用</view> <view class="text">{{ coupon.consumeThreshold > 0 ? '满' + coupon.consumeThreshold + '元可用' : '无门槛使用' }}</view>
<view class="bg-quan"> <view class="bg-quan">券</view>
券 <view class="jiao-1" :class="{ 'used-color': coupon.used_status != 0 }">
</view> <text class="text-1">{{ coupon.used_status == 0 ? '新到' : coupon.used_status_text }}</text>
<view class="jiao-1" :class="{'used-color':coupon.used_status!=0}">
<text class="text-1">{{coupon.used_status == 0?'新到':coupon.used_status_text}}</text>
</view> </view>
</view> </view>
<view class="bottom-view"> <view class="bottom-view">
<view class="text">• 使用范围:{{ <view class="text">• 使用范围:{{
coupon.scopeType == 'ALL' && coupon.storeId == '0' coupon.scopeType == 'ALL' && coupon.storeId == '0'
? "全平台" ? '全平台'
: coupon.scopeType == "PORTION_GOODS" : coupon.scopeType == 'PORTION_GOODS'
? "部分商品" ? '部分商品'
: coupon.scopeType == "PORTION_GOODS_CATEGORY" : coupon.scopeType == 'PORTION_GOODS_CATEGORY'
? "部分分类商品" ? '部分分类商品'
: coupon.storeName == 'platform' ? '全平台' :coupon.storeName+'' : coupon.storeName == 'platform' ? '全平台' : coupon.storeName + ''
}}使用</view> }}使用</view>
<view class="text">• 有效期至:{{coupon.endTime}}</view> <view class="text">• 有效期至:{{ coupon.endTime }}</view>
</view> </view>
</view> </view>
</view> </view>
</template> </template>
<script> <script setup lang="ts">
export default { import { ref, computed } from 'vue'
data() { import { onLoad } from '@dcloudio/uni-app'
return { import { unitPrice } from '@/utils/filters.js'
coupon: {}, //优惠券数据 import { useStore } from '@/store'
}; import { getThemeStyle } from '@/utils/theme'
}, const store = useStore()
onLoad(option) { const themeStyle = computed(() => getThemeStyle(store.state.theme))
this.coupon = JSON.parse(decodeURIComponent(option.item));
}, const coupon = ref<Record<string, any>>({})
};
onLoad((option) => {
coupon.value = JSON.parse(decodeURIComponent(option.item))
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
page, page,
.content { .content {
// background: $main-color;
height: 100%; height: 100%;
} }
.body { .body {

View File

@@ -1,292 +1,323 @@
<template> <template>
<div class="wrapper"> <view class="b-content" :style="themeStyle">
<u-tabs <view class="coupon-tabs">
:list="list" <u-tabs
:is-scroll="false" :list="list"
:active-color="lightColor" :scrollable="false"
:current="current" :inactiveStyle="{ color: '#333' }"
@change=" v-model:current="current"
(i) => { :lineColor="lightColor"
current = i; :activeStyle="{ color: lightColor }"
} ></u-tabs>
"
>
</u-tabs>
<div class="empty" v-if="couponsList.length <= 0">
<u-empty text="暂无优惠券" mode="coupon"></u-empty>
</div>
<view class="coupon-item" v-for="(item, index) in couponsList" :key="index">
<view class="left">
<view class="wave-line">
<view class="wave" v-for="(item, index) in 12" :key="index"></view>
</view>
<view class="message">
<view>
<span v-if="item.couponType == 'DISCOUNT'">{{ item.discount }}折</span>
<span v-else>{{ item.price }}元</span>
</view>
<view>满{{ item.consumeThreshold | unitPrice }}元可用</view>
</view>
<view class="circle circle-top"></view>
<view class="circle circle-bottom"></view>
</view>
<view class="right">
<view class="desc">
<view v-if="item.scopeType">
<span v-if="item.scopeType == 'ALL' && item.storeId == '0'">全平台</span>
<span v-if="item.scopeType == 'PORTION_GOODS_CATEGORY'">仅限品类</span>
<view v-else
>{{
item.storeName == "platform" ? "全平台" : item.storeName + "店铺"
}}使用</view
>
</view>
<view class="reason" v-if="item.reason">{{ item.reason }}</view>
<view class="end-time">有效期至:{{ item.endTime }}</view>
</view>
<view
class="receive"
v-if="current == 0 && !routerVal.selectedCoupon.includes(item.id)"
@click="clickWay(item)"
>
<text>立即</text><br />
<text>使用</text>
</view>
<view class="used" v-if="current == 0 && routerVal.selectedCoupon.includes(item.id)" @click="clickWay(item)">
<text>取消</text><br />
<text>使用</text>
</view>
<view class="bg-quan">券</view>
</view>
</view> </view>
</div>
<scroll-view class="list-scroll-content" scroll-y>
<u-empty
mode="coupon"
text="暂无优惠券"
v-if="couponsList.length <= 0"
></u-empty>
<view
class="coupon-card"
:class="{ 'coupon-used': current != 0 }"
v-for="(item, index) in couponsList"
:key="item.id || index"
>
<view class="coupon-card-left">
<text class="coupon-price-symbol" v-if="item.couponType != 'DISCOUNT'">¥</text>
<text class="coupon-price-value">
{{ item.couponType == 'DISCOUNT' ? item.discount + '折' : unitPrice(item.price) }}
</text>
</view>
<view class="coupon-divider"></view>
<view class="coupon-card-right">
<view class="coupon-info">
<text class="coupon-card-name">
<template v-if="item.scopeType == 'ALL' && item.storeId == '0'">全平台</template>
<template v-else-if="item.scopeType == 'PORTION_GOODS_CATEGORY'">仅限品类</template>
<template v-else>
{{ item.storeName == 'platform' ? '全平台' : (item.storeName || '') + '店铺' }}
</template>
使用
</text>
<text class="coupon-card-desc">{{ item.consumeThreshold > 0 ? '满' + unitPrice(item.consumeThreshold) + '元可用' : '无门槛使用' }}</text>
<text class="coupon-card-time" v-if="item.reason">{{ item.reason }}</text>
<text class="coupon-card-time" v-if="item.endTime">有效期至:{{ item.endTime }}</text>
</view>
<view
class="coupon-status-btn"
v-if="current == 0 && !isSelected(item)"
@click="clickWay(item)"
>
立即使用
</view>
<view
class="coupon-status-btn cancel"
v-else-if="current == 0 && isSelected(item)"
@click="clickWay(item)"
>
取消使用
</view>
<view class="coupon-status-btn disabled" v-else>
不可用
</view>
</view>
</view>
</scroll-view>
</view>
</template> </template>
<script>
import { useCoupon } from "@/api/trade.js";
export default { <script setup lang="ts">
data() { import { ref, computed, watch, onMounted } from 'vue'
return { import { onLoad } from '@dcloudio/uni-app'
lightColor: this.$lightColor, import { useStore } from '@/store'
current: 0, import { useCoupon } from '@/api/trade.js'
list: [ import { unitPrice } from '@/utils/filters.js'
{ import { getThemeStyle } from '@/utils/theme'
name: "可用优惠券",
},
{
name: "不可用优惠券",
},
],
couponsList: [], //优惠券集合
params: {
//传参
memberCouponStatus: "NEW", //优惠券状态
pageNumber: 1,
pageSize: 10,
scopeId: "", //商品skuid
storeId: "", //店铺id
totalPrice: "", //价格
},
routerVal: "", //上级传参
};
},
onLoad(options) {
this.routerVal = options;
},
watch: {
current(val) {
console.log(this.$store.state.cantUseCoupons);
val == 0
? (this.couponsList = this.$store.state.canUseCoupons)
: (this.couponsList = this.$store.state.cantUseCoupons);
},
},
mounted() { const store = useStore()
this.init();
console.log(this.routerVal);
},
methods: { const lightColor = computed(() => store.getters.lightColor)
/** const themeStyle = computed(() => getThemeStyle(store.state.theme))
* 从vuex中拿取优惠券信息 const current = ref(0)
*/ const list = [
init() { { name: '可用优惠券' },
this.couponsList = this.$store.state.canUseCoupons; { name: '不可用优惠券' },
}, ]
/** const couponsList = ref<any[]>([])
* 领取优惠券 const routerVal = ref<Record<string, any>>({
*/ selectedCoupon: [],
clickWay(coupon) { way: '',
useCoupon({ })
memberCouponId: coupon.id,
used: !this.routerVal.selectedCoupon.includes(coupon.id), onLoad((options) => {
way: this.routerVal.way, const selectedCoupon = options?.selectedCoupon
}).then((res) => { let selected: string[] = []
if (res.data.success) { if (Array.isArray(selectedCoupon)) {
uni.navigateBack(); selected = selectedCoupon
} else { } else if (typeof selectedCoupon === 'string' && selectedCoupon) {
uni.showToast({ selected = selectedCoupon.split(',')
title: res.data.message, }
duration: 2000, routerVal.value = {
icon: "none", ...(options || {}),
}); selectedCoupon: selected,
} }
}); })
},
}, watch(current, (val) => {
}; couponsList.value = val == 0
? store.state.canUseCoupons
: store.state.cantUseCoupons
})
onMounted(() => {
couponsList.value = store.state.canUseCoupons || []
})
function isSelected(coupon: any) {
return (routerVal.value.selectedCoupon || []).includes(coupon.id)
}
function clickWay(coupon: any) {
useCoupon({
memberCouponId: coupon.id,
used: !isSelected(coupon),
way: routerVal.value.way,
}).then((res) => {
if (res.data.success) {
uni.navigateBack()
} else {
uni.showToast({
title: res.data.message,
duration: 2000,
icon: 'none',
})
}
})
}
</script> </script>
<style scoped lang="scss">
.desc { <style lang="scss" scoped>
height: 220rpx; .b-content {
flex: 2; background: #f7f8fa;
min-height: 100vh;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: space-around;
}
.end-time,
.reason {
color: #999;
line-height: 1.5;
font-size: 24rpx;
} }
.empty { .coupon-tabs {
margin-top: 20px; background: #fff;
text-align: center; height: 88rpx;
box-shadow: 0 1rpx 8rpx rgba(0, 0, 0, 0.04);
position: relative;
z-index: 2;
flex-shrink: 0;
} }
.wrapper {
background: #f9f9f9; :deep(.u-tabs),
overflow: hidden; :deep(.u-tabs__wrapper),
:deep(.u-tabs__wrapper__scroll-view-wrapper),
:deep(.u-tabs__wrapper__scroll-view),
:deep(.u-tabs__wrapper__nav) {
background: #fff;
height: 88rpx;
} }
.coupon-item {
:deep(.u-tabs__wrapper__nav__item) {
min-height: 88rpx;
}
:deep(.u-tabs__wrapper__nav__item__text) {
color: #333;
font-size: 28rpx;
}
.list-scroll-content {
flex: 1;
height: 0;
width: 100%;
padding: 24rpx;
box-sizing: border-box;
}
.coupon-card {
display: flex; display: flex;
align-items: center; align-items: stretch;
height: 220rpx; background: #fff;
margin: 20rpx; border-radius: 24rpx;
margin-bottom: 24rpx;
position: relative;
border: 1rpx solid #f0f1f5;
overflow: hidden;
.left { &:active {
height: 100%; transform: scale(0.98);
width: 260rpx;
background-color: $light-color;
position: relative;
.message {
color: $font-color-white;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
margin-top: 40rpx;
view:nth-child(1) {
font-weight: bold;
font-size: 60rpx;
}
view:nth-child(2) {
font-size: $font-sm;
}
}
.wave-line {
height: 220rpx;
width: 8rpx;
position: absolute;
top: 0;
left: 0;
background-color: $light-color;
overflow: hidden;
.wave {
width: 8rpx;
height: 16rpx;
background-color: #ffffff;
border-radius: 0 16rpx 16rpx 0;
margin-top: 4rpx;
}
}
.circle {
width: 40rpx;
height: 40rpx;
background-color: $bg-color;
position: absolute;
border-radius: 50%;
z-index: 111;
}
.circle-top {
top: -20rpx;
right: -20rpx;
}
.circle-bottom {
bottom: -20rpx;
right: -20rpx;
}
} }
.right { &::before,
display: flex; &::after {
justify-content: space-between; content: '';
align-items: center; position: absolute;
width: 450rpx; width: 32rpx;
font-size: $font-sm; height: 32rpx;
height: 220rpx; background: #f7f8fa;
background-color: #ffffff; border-radius: 50%;
overflow: hidden; left: 204rpx;
position: relative; z-index: 2;
> view:nth-child(1) { box-shadow: inset 0 0 0 1rpx #eceef2;
color: #666666; }
margin-left: 20rpx;
> view:nth-child(1) { &::before {
color: #ff6262; top: -16rpx;
font-size: 30rpx; }
}
}
.receive { &::after {
color: #ffffff; bottom: -16rpx;
background-color: $main-color; }
border-radius: 50%;
width: 86rpx;
height: 86rpx;
text-align: center;
margin-right: 30rpx;
vertical-align: middle;
padding-top: 8rpx;
position: relative;
z-index: 2;
}
.used { &.coupon-used {
color: #ffffff; .coupon-card-left {
background-color: black; background: linear-gradient(135deg, #f5f5f5 0%, #eeeeee 100%);
border-radius: 50%; color: #999;
width: 86rpx;
height: 86rpx;
text-align: center;
margin-right: 30rpx;
vertical-align: middle;
padding-top: 8rpx;
position: relative;
z-index: 2;
} }
}
}
.bg-quan { .coupon-card-left {
width: 244rpx; width: 220rpx;
height: 244rpx; min-height: 180rpx;
border: 6rpx solid $main-color; display: flex;
border-radius: 50%; align-items: center;
opacity: 0.1; justify-content: center;
color: $main-color; flex-shrink: 0;
text-align: center; color: #ff3b30;
padding-top: 30rpx; position: relative;
font-size: 130rpx; background: linear-gradient(135deg, #fff5f5 0%, #ffecec 100%);
position: absolute; }
right: -54rpx;
bottom: -60rpx; .coupon-price-symbol {
} font-size: 32rpx;
font-weight: 700;
margin-right: 4rpx;
}
.coupon-price-value {
font-size: 56rpx;
font-weight: 900;
line-height: 1;
letter-spacing: -1rpx;
}
.coupon-divider {
position: absolute;
left: 220rpx;
top: 24rpx;
bottom: 24rpx;
width: 0;
border-left: 2rpx dashed #eceef2;
}
.coupon-card-right {
flex: 1;
padding: 32rpx 32rpx 32rpx 40rpx;
display: flex;
align-items: center;
justify-content: space-between;
gap: 20rpx;
background: #fff;
}
.coupon-info {
display: flex;
flex-direction: column;
gap: 12rpx;
flex: 1;
min-width: 0;
}
.coupon-card-name {
font-size: 30rpx;
color: #111;
font-weight: 700;
line-height: 1.3;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.coupon-card-desc {
font-size: 24rpx;
color: #8a8f99;
font-weight: 500;
}
.coupon-card-time {
font-size: 22rpx;
color: #b0b3bf;
}
.coupon-status-btn {
flex-shrink: 0;
padding: 16rpx 28rpx;
border-radius: 40rpx;
font-size: 26rpx;
font-weight: 700;
color: #fff;
background: linear-gradient(135deg, var(--theme-light, #ff6b35), var(--theme-primary, #ff4b2b));
&:active {
opacity: 0.9;
}
&.cancel {
background: #333;
}
&.disabled {
background: #ccc;
} }
} }
</style> </style>

View File

@@ -1,472 +1,394 @@
<template> <template>
<view class="b-content"> <view class="b-content">
<view class="navbar"> <view class="coupon-tabs">
<!-- 循环出头部tab栏 --> <u-tabs
<view :list="navList"
v-for="(item, index) in navList" keyName="text"
:key="index" :scrollable="false"
class="nav-item" :inactiveStyle="{ color: '#333' }"
@click="handleTabClick(index)" v-model:current="tabCurrentIndex"
><text :class="{ current: tabCurrentIndex === index }">{{ :lineColor="lightColor"
item.text :activeStyle="{ color: lightColor }"
}}</text></view ></u-tabs>
> </view>
</view> <swiper
<swiper :current="tabCurrentIndex"
:current="tabCurrentIndex" class="swiper-box"
class="swiper-box" duration="300"
duration="300" @change="changeTab"
@change="changeTab" >
> <swiper-item
<swiper-item class="tab-content"
class="tab-content" v-for="(navItem, navIndex) in navList"
v-for="(navItem, navIndex) in navList" :key="navIndex"
:key="navIndex" >
> <scroll-view
<scroll-view class="list-scroll-content"
class="list-scroll-content" scroll-y
scroll-y @scrolltolower="loadData"
@scrolltolower="loadData" >
> <u-empty
<!-- 空白页 --> mode="coupon"
<u-empty text="暂无优惠券了"
mode="coupon" v-if="navItem.whetherEmpty"
text="暂无优惠券了" ></u-empty>
v-if="navItem.whetherEmpty"
></u-empty> <view
class="coupon-card"
<!-- 数据 --> :class="{ 'coupon-used': navIndex != 0, 'coupon-expired': navIndex == 2 }"
<view v-for="(coupon, index) in navItem.dataList"
v-if="navItem.dataList && coupon" :key="index"
class="coupon-item" >
:class="{ 'coupon-used': navIndex != 0 }" <view class="coupon-card-left">
v-for="(coupon, index) in navItem.dataList" <text class="coupon-price-symbol" v-if="coupon.couponType != 'DISCOUNT'">¥</text>
:key="index" <text class="coupon-price-value">{{ coupon.couponType == 'DISCOUNT' ? coupon.discount + '折' : unitPrice(coupon.price) }}</text>
> </view>
<view class="left"> <view class="coupon-divider"></view>
<view class="wave-line"> <view class="coupon-card-right">
<view <view class="coupon-info">
class="wave" <text class="coupon-card-name">{{ coupon.title }}</text>
v-for="(item, index) in 12" <text class="coupon-card-desc">{{ coupon.consumeThreshold > 0 ? '满' + unitPrice(coupon.consumeThreshold) + '元可用' : '无门槛使用' }}</text>
:key="index" <text class="coupon-card-desc">使用范围:{{
></view> coupon.scopeType == "ALL" && coupon.storeId == "0"
</view> ? "全平台"
<view class="message"> : coupon.scopeType == "PORTION_GOODS"
<view class="price" v-if="coupon.couponType == 'DISCOUNT'" ? "部分商品"
>{{ coupon.discount }}折</view : coupon.scopeType == "PORTION_GOODS_CATEGORY"
> ? "部分分类商品"
<view class="price" v-else>{{ coupon.price }}元</view> : coupon.storeName == "platform"
<view class="sub-price" ? "全平台"
>满{{ coupon.consumeThreshold | unitPrice }}可用</view : coupon.storeName + ""
> }}使用</text>
</view> <text class="coupon-card-time" v-if="coupon.endTime">{{ coupon.endTime }}</text>
<view class="circle circle-top"></view> </view>
<view class="circle circle-bottom"></view> <view class="coupon-status-btn" v-if="navIndex == 0" @click="useItNow(coupon)">
</view> 立即使用
<view class="right" v-if="coupon"> </view>
<view class="content"> <view class="coupon-status-btn disabled" v-else-if="navIndex == 1">
<view class="title-1">{{ coupon.title }}</view> 已使用
<view class="title-2" </view>
>使用范围:{{ <view class="coupon-status-btn disabled" v-else>
coupon.scopeType == "ALL" && coupon.storeId == "0" 已过期
? "全平台" </view>
: coupon.scopeType == "PORTION_GOODS" </view>
? "部分商品" </view>
: coupon.scopeType == "PORTION_GOODS_CATEGORY" <uni-load-more :status="navItem.loadStatus"></uni-load-more>
? "部分分类商品" </scroll-view>
: coupon.storeName == "platform" </swiper-item>
? "全平台" </swiper>
: coupon.storeName + "" </view>
}}使用</view </template>
>
<view v-if="coupon.endTime">{{ coupon.endTime }}</view> <script setup lang="ts">
<view @click="couponDetail(coupon)" import { getMemberCoupons } from '@/api/members.js'
>详细说明 import { useStore } from '@/store'
<u-icon import { unitPrice } from '@/utils/filters.js'
style="float: right; margin-top: 10rpx" import { onShow } from '@dcloudio/uni-app'
name="arrow-right" import { computed, ref, watch } from 'vue'
></u-icon>
</view> const store = useStore()
</view>
<view class="jiao-1" v-if="navIndex == 0"> const lightColor = computed(() => store.getters.lightColor)
<text class="text-1">新到</text> const tabCurrentIndex = ref(0)
<text class="text-2" v-if="coupon.used_status == 1" const navList = ref([
>将过期</text {
> text: '未使用',
</view> loadStatus: 'more',
<image dataList: [] as any[],
class="no-icon" params: {
v-if="navIndex == 1" memberCouponStatus: 'NEW',
src="@/static/img/used.png" pageNumber: 1,
></image> pageSize: 10,
<image status: 1,
class="no-icon" },
v-if="navIndex == 2" whetherEmpty: false,
src="@/static/img/overdue.png" },
></image> {
<view text: '已使用',
class="receive" loadStatus: 'more',
v-if="navIndex == 0" dataList: [] as any[],
@click="useItNow(coupon)" params: {
> memberCouponStatus: 'USED',
<text>立即</text><br /> pageNumber: 1,
<text>使用</text> pageSize: 10,
</view> status: 2,
<view class="bg-quan"> 券 </view> },
</view> whetherEmpty: false,
</view> },
<uni-load-more :status="navItem.loadStatus"></uni-load-more> {
</scroll-view> text: '已过期',
</swiper-item> loadStatus: 'more',
</swiper> dataList: [] as any[],
</view> params: {
</template> memberCouponStatus: 'EXPIRE',
pageNumber: 1,
<script> pageSize: 10,
import { getMemberCoupons } from "@/api/members.js"; status: 3,
},
export default { whetherEmpty: false,
data() { },
return { ])
tabCurrentIndex: 0, //tab栏下标默认为0 未使用
navList: [ onShow(() => {
//每个tab存储的信息 navList.value[tabCurrentIndex.value].params.pageNumber = 1
{ navList.value[tabCurrentIndex.value].dataList = []
text: "未使用", getData()
loadStatus: "more", })
dataList: [],
params: { watch(tabCurrentIndex, (val) => {
memberCouponStatus: "NEW", if (navList.value[val].dataList.length == 0) getData()
pageNumber: 1, })
pageSize: 10,
status: 1, function hideLoadingIfNeeded() {
}, if (store.state.isShowToast) uni.hideLoading()
whetherEmpty: false, }
},
{ function handleTabClick(index: number) {
text: "已使用", tabCurrentIndex.value = index
loadStatus: "more", }
dataList: [],
params: { function getData() {
memberCouponStatus: "USED", uni.showLoading({ title: '加载中' })
pageNumber: 1, const index = tabCurrentIndex.value
pageSize: 10, getMemberCoupons(navList.value[index].params).then((res) => {
status: 2, uni.stopPullDownRefresh()
}, if (res.data.success) {
whetherEmpty: false, const data = res.data.result.records
}, if (data.length == 0) {
{ if (res.data.pageNumber == 1) {
text: "已过期", navList.value[index].whetherEmpty = true
loadStatus: "more", } else {
dataList: [], navList.value[index].loadStatus = 'noMore'
params: { }
memberCouponStatus: "EXPIRE", } else if (data.length < 10) {
pageNumber: 1, navList.value[index].loadStatus = 'noMore'
pageSize: 10, navList.value[index].dataList.push(...data)
status: 3, } else {
}, navList.value[index].dataList.push(...data)
whetherEmpty: false, }
}, }
], hideLoadingIfNeeded()
couponList: [], //优惠券列表 })
}; }
},
function changeTab(e: any) {
onShow() { tabCurrentIndex.value = e.detail.current
this.navList[this.tabCurrentIndex].params.pageNumber = 1; }
this.navList[this.tabCurrentIndex].dataList = [];
this.getData(); function loadData() {
}, const index = tabCurrentIndex.value
if (navList.value[index].loadStatus != 'noMore') {
watch: { navList.value[index].params.pageNumber++
/** getData()
* 监听切换顶部tab栏实现刷新数据 }
*/ }
tabCurrentIndex(val) {
if (this.navList[val].dataList.length == 0) this.getData(); function useItNow(item: any) {
}, uni.navigateTo({
}, url: `/pages/navigation/search/searchPage?promotionsId=${item.couponId}&promotionType=COUPON`,
methods: { })
/** }
* 顶部tab点击
*/ function couponDetail(item: any) {
handleTabClick(index) { uni.navigateTo({
this.tabCurrentIndex = index; url: '/pages/cart/coupon/couponDetail?item=' + encodeURIComponent(JSON.stringify(item)),
}, })
}
/** </script>
* 读取优惠券
*/ <style lang="scss" scoped>
getData() { .b-content {
uni.showLoading({ background: #f7f8fa;
title: "加载中", min-height: 100vh;
}); }
let index = this.tabCurrentIndex;
getMemberCoupons(this.navList[index].params).then((res) => { .coupon-tabs {
uni.stopPullDownRefresh(); background: #fff;
if (res.data.success) { height: 88rpx;
let data = res.data.result.records; box-shadow: 0 1rpx 8rpx rgba(0, 0, 0, 0.04);
if (data.length == 0) { position: relative;
if (res.data.pageNumber == 1) { z-index: 2;
this.navList[index].whetherEmpty = true; }
} else {
this.navList[index].loadStatus = "noMore"; :deep(.u-tabs),
} :deep(.u-tabs__wrapper),
} else if (data.length < 10) { :deep(.u-tabs__wrapper__scroll-view-wrapper),
this.navList[index].loadStatus = "noMore"; :deep(.u-tabs__wrapper__scroll-view),
this.navList[index].dataList.push(...data); :deep(.u-tabs__wrapper__nav) {
} else { background: #fff;
this.navList[index].dataList.push(...data); height: 88rpx;
} }
}
if (this.$store.state.isShowToast){ uni.hideLoading() }; :deep(.u-tabs__wrapper__nav__item) {
}); min-height: 88rpx;
}, }
/** :deep(.u-tabs__wrapper__nav__item__text) {
* 切换tab color: #333;
*/ font-size: 28rpx;
changeTab(e) { }
this.tabCurrentIndex = e.target.current;
}, .swiper-box {
height: calc(100vh - 88rpx - var(--status-bar-height));
/** }
* 加载数据
*/ .list-scroll-content {
loadData() { height: 100%;
let index = this.tabCurrentIndex; width: 100%;
if (this.navList[index].loadStatus != "noMore") { padding: 24rpx;
this.navList[index].params.pageNumber++; box-sizing: border-box;
this.getData(); }
}
}, .coupon-card {
display: flex;
/** align-items: stretch;
* 立即使用优惠券 background: #fff;
*/ border-radius: 24rpx;
useItNow(item) { margin-bottom: 24rpx;
uni.navigateTo({ position: relative;
url: `/pages/navigation/search/searchPage?promotionsId=${item.couponId}&promotionType=COUPON`, box-shadow: none;
}); border: 1rpx solid #f0f1f5;
}, overflow: hidden;
transition: transform 0.2s ease, box-shadow 0.2s ease;
/**
* 优惠券详情 &:active {
*/ transform: scale(0.98);
couponDetail(item) { }
uni.navigateTo({
url: &::before,
"/pages/cart/coupon/couponDetail?item=" + &::after {
encodeURIComponent(JSON.stringify(item)), content: "";
}); position: absolute;
}, width: 32rpx;
}, height: 32rpx;
}; background: #f7f8fa;
</script> border-radius: 50%;
left: 204rpx;
<style lang="scss" scoped> z-index: 2;
page { box-shadow: inset 0 0 0 1rpx #eceef2;
height: 100%; }
}
$item-color: #fff; &::before {
top: -16rpx;
.b-content { }
background: $page-color-base;
height: 100%; &::after {
} bottom: -16rpx;
}
.swiper-box {
height: calc(100vh - 40px); &.coupon-used {
} .coupon-card-left {
background: linear-gradient(135deg, #f5f5f5 0%, #eeeeee 100%);
.list-scroll-content { color: #999;
height: 100%; }
width: 100%; .coupon-status-btn {
background: #ccc;
.coupon-item { box-shadow: none;
display: flex; }
align-items: center; }
height: 220rpx;
margin: 20rpx; &.coupon-expired {
.coupon-card-left {
.left { background: linear-gradient(135deg, #f5f5f5 0%, #eeeeee 100%);
height: 100%; color: #999;
width: 260rpx; }
background-color: $light-color; .coupon-status-btn {
position: relative; background: #ccc;
box-shadow: none;
.message { }
color: $font-color-white; }
display: flex; }
justify-content: center;
align-items: center; .coupon-card-left {
flex-direction: column; width: 220rpx;
margin-top: 40rpx; min-height: 180rpx;
display: flex;
view:nth-child(1) { align-items: center;
font-weight: bold; justify-content: center;
font-size: 60rpx; flex-shrink: 0;
} color: #ff3b30;
position: relative;
view:nth-child(2) { background: linear-gradient(135deg, #fff5f5 0%, #ffecec 100%);
font-size: $font-sm; }
}
} .coupon-price-symbol {
font-size: 32rpx;
.wave-line { font-weight: 700;
height: 220rpx; margin-right: 4rpx;
width: 8rpx; }
position: absolute;
top: 0; .coupon-price-value {
left: 0; font-size: 56rpx;
background-color: $light-color; font-weight: 900;
overflow: hidden; line-height: 1;
letter-spacing: -1rpx;
.wave { }
width: 8rpx;
height: 16rpx; .coupon-divider {
background-color: #ffffff; position: absolute;
border-radius: 0 16rpx 16rpx 0; left: 220rpx;
margin-top: 4rpx; top: 24rpx;
} bottom: 24rpx;
} width: 0;
border-left: 2rpx dashed #eceef2;
.circle { }
width: 40rpx;
height: 40rpx; .coupon-card-right {
background-color: $bg-color; flex: 1;
position: absolute; padding: 32rpx 32rpx 32rpx 40rpx;
border-radius: 50%; display: flex;
z-index: 111; align-items: center;
} justify-content: space-between;
gap: 20rpx;
.circle-top { background: #fff;
top: -20rpx; }
right: -20rpx;
} .coupon-info {
display: flex;
.circle-bottom { flex-direction: column;
bottom: -20rpx; gap: 12rpx;
right: -20rpx; flex: 1;
} min-width: 0;
} }
.right { .coupon-card-name {
display: flex; font-size: 30rpx;
justify-content: space-between; color: #111;
align-items: center; font-weight: 700;
width: 450rpx; line-height: 1.3;
font-size: $font-sm; display: -webkit-box;
height: 100%; -webkit-line-clamp: 2;
background-color: #ffffff; -webkit-box-orient: vertical;
overflow: hidden; overflow: hidden;
position: relative; }
.content { .coupon-card-desc {
color: #666666; font-size: 24rpx;
margin-left: 20rpx; color: #8a8f99;
line-height: 2em; font-weight: 500;
> view:nth-child(1) { }
color: #ff6262;
font-size: 30rpx; .coupon-card-time {
} font-size: 22rpx;
color: #b0b3bf;
.title-1, }
.title-2,
.title-3 { .coupon-status-btn {
font-size: 25rpx; flex-shrink: 0;
} padding: 16rpx 32rpx;
} border-radius: 40rpx;
.receive { font-size: 26rpx;
color: #ffffff; font-weight: 700;
background-color: $main-color; color: #fff;
border-radius: 50%; background: linear-gradient(135deg, #ff6b35, #ff4b2b);
width: 86rpx;
height: 86rpx; &:active {
text-align: center; opacity: 0.9;
margin-right: 48rpx; }
vertical-align: middle;
padding-top: 8rpx; &.disabled {
position: relative; background: #ccc;
z-index: 2; box-shadow: none;
} }
}
.jiao-1 { </style>
background-color: #ffc71c;
width: 400rpx;
transform: rotate(45deg);
text-align: center;
position: absolute;
color: #ffffff;
right: -130rpx;
top: 0;
.text-1 {
margin-left: 68rpx;
font-size: 28rpx;
}
.text-2 {
margin-left: 68rpx;
font-size: 28rpx;
}
}
.no-icon {
border-radius: 50%;
width: 86rpx;
height: 86rpx;
margin-right: 48rpx;
position: relative;
z-index: 2;
}
.bg-quan {
width: 244rpx;
height: 244rpx;
border: 6rpx solid $main-color;
border-radius: 50%;
opacity: 0.1;
color: $main-color;
text-align: center;
padding-top: 30rpx;
font-size: 130rpx;
position: absolute;
right: -54rpx;
bottom: -60rpx;
}
}
}
}
.navbar {
display: flex;
height: 80rpx;
padding: 0 5px;
background: #fff;
color: $light-color;
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
position: relative;
z-index: 10;
.nav-item {
flex: 1;
height: 100%;
font-size: 26rpx;
color: $light-color;
position: relative;
text-align: center;
text {
line-height: 80rpx;
}
.current {
font-weight: bold;
font-size: 28rpx;
&:after {
content: "";
position: absolute;
bottom: 10rpx;
left: 108rpx;
width: 30rpx;
border-bottom: 2px solid $light-color;
}
}
}
}
</style>

View File

@@ -0,0 +1,209 @@
<template>
<view class="b-content" :style="themeStyle">
<scroll-view class="list-scroll-content" scroll-y>
<u-empty
mode="coupon"
text="暂无可用礼品卡"
v-if="!cardList.length"
></u-empty>
<view class="coupon-card" v-for="item in cardList" :key="item.id">
<view class="coupon-card-left">
<view class="price-row">
<text class="coupon-price-symbol">¥</text>
<text class="coupon-price-value">{{ unitPrice(item.balance) }}</text>
</view>
</view>
<view class="coupon-divider"></view>
<view class="coupon-card-right">
<text class="coupon-card-name">{{ item.giftCardName || '礼品卡' }}</text>
<view class="coupon-card-foot">
<view
class="coupon-status-btn"
:class="{ cancel: item.selected }"
@click="clickWay(item)"
>
{{ item.selected ? '取消使用' : '立即使用' }}
</view>
</view>
</view>
</view>
<view class="notice" v-if="cardList.length">{{ GIFT_CARD_PAY_NOTICE }}</view>
</scroll-view>
</view>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { useStore } from '@/store'
import { selectGiftCard } from '@/api/trade.js'
import { unitPrice } from '@/utils/filters.js'
import { decorateGiftCard, GIFT_CARD_PAY_NOTICE } from '@/utils/giftCard.js'
import { getThemeStyle } from '@/utils/theme'
const store = useStore()
const themeStyle = computed(() => getThemeStyle(store.state.theme))
const way = ref('')
const cardList = ref<any[]>([])
onLoad((options) => {
way.value = options?.way || ''
})
onShow(() => {
const selectedIds = (store.state as any).selectedGiftCardIds || []
const cards = (store.state as any).canUseGiftCards || []
cardList.value = cards.map((item: any) => decorateGiftCard(item, selectedIds))
})
function clickWay(item: any) {
if (!item?.id) return
selectGiftCard({
way: way.value,
credentialId: String(item.id),
used: !item.selected,
}).then((res) => {
if (res.data.success) {
uni.navigateBack()
} else {
uni.showToast({
title: res.data.message || '礼品卡选择失败',
icon: 'none',
duration: 2000,
})
}
})
}
</script>
<style lang="scss" scoped>
.b-content {
background: #f7f8fa;
min-height: 100vh;
display: flex;
flex-direction: column;
}
.list-scroll-content {
flex: 1;
height: 100vh;
width: 100%;
padding: 24rpx 24rpx calc(24rpx + env(safe-area-inset-bottom));
box-sizing: border-box;
}
.coupon-card {
display: flex;
align-items: stretch;
background: #fff;
border-radius: 24rpx;
margin-bottom: 24rpx;
position: relative;
border: 1rpx solid #f0f1f5;
overflow: hidden;
}
.coupon-card-left {
width: 200rpx;
min-height: 148rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
flex-shrink: 0;
color: #ff3b30;
background: linear-gradient(135deg, #fff5f5 0%, #ffecec 100%);
}
.price-row {
display: flex;
align-items: baseline;
justify-content: center;
}
.coupon-price-symbol {
font-size: 26rpx;
font-weight: 700;
margin-right: 2rpx;
}
.coupon-price-value {
font-size: 44rpx;
font-weight: 900;
line-height: 1;
}
.coupon-price-label {
margin-top: 8rpx;
font-size: 22rpx;
color: #ff8a80;
}
.coupon-divider {
position: absolute;
left: 200rpx;
top: 24rpx;
bottom: 24rpx;
width: 0;
border-left: 2rpx dashed #f0d6d6;
}
.coupon-card-right {
flex: 1;
min-width: 0;
padding: 24rpx 24rpx 20rpx 28rpx;
display: flex;
flex-direction: column;
background: #fff;
}
.coupon-card-name {
font-size: 28rpx;
color: #111;
font-weight: 700;
line-height: 1.4;
}
.coupon-card-desc,
.coupon-card-time {
margin-top: 8rpx;
font-size: 22rpx;
color: #8a8f99;
line-height: 1.4;
}
.coupon-card-time {
word-break: break-all;
}
.coupon-card-foot {
display: flex;
align-items: center;
justify-content: flex-end;
margin-top: 16rpx;
}
.coupon-status-btn {
flex-shrink: 0;
padding: 12rpx 24rpx;
border-radius: 40rpx;
font-size: 24rpx;
font-weight: 700;
line-height: 1.2;
color: #fff;
background: linear-gradient(135deg, var(--theme-light, #ff6b35), var(--theme-primary, #ff4b2b));
&.cancel {
background: #333;
}
}
.notice {
margin-top: 8rpx;
font-size: 22rpx;
color: #999;
line-height: 1.6;
}
</style>

View File

@@ -0,0 +1,433 @@
<template>
<view class="page">
<view class="bind-section">
<view class="section-title">兑换礼品卡</view>
<view class="bind-row">
<text class="bind-label">卡号</text>
<u-input
v-model="bindForm.cardNo"
border="none"
maxlength="64"
placeholder="请输入卡号"
clearable
/>
</view>
<view class="bind-row">
<text class="bind-label">兑换码</text>
<u-input
v-model="bindForm.cardSecret"
border="none"
maxlength="128"
placeholder="请输入兑换码(卡密)"
clearable
/>
</view>
<view class="bind-btn" :class="{ disabled: bindSubmitting }" @click="submitBind">
{{ bindSubmitting ? '兑换中...' : '兑换' }}
</view>
</view>
<view class="tabs-wrap">
<u-tabs
:list="tabList"
keyName="text"
:scrollable="false"
:inactiveStyle="{ color: '#333' }"
v-model:current="tabCurrentIndex"
:lineColor="lightColor"
:activeStyle="{ color: lightColor }"
/>
</view>
<scroll-view class="list-scroll" scroll-y @scrolltolower="loadMore">
<u-empty v-if="!loading && !list.length" mode="coupon" text="暂无礼品卡" />
<view
class="gcc-card"
:class="{ 'is-disabled': statusTab === 'UNAVAILABLE' }"
v-for="item in list"
:key="item.id || item.cardNo"
>
<view class="gcc-header">
<view class="gcc-header-pattern" />
<view class="gcc-header-inner">
<view class="gcc-header-left">
<view class="gcc-title">{{ item.giftCardName || '礼品卡' }}</view>
<view class="gcc-face">{{ item.cardType === 'PICKUP' ? '兑换 ' + item.pickupCount + ' 种商品' : '面值' + item.faceText + '元' }}</view>
<view class="gcc-cardno">{{ item.cardNo }}</view>
</view>
<view class="gcc-header-right">
<view class="gcc-type">{{ item.cardType === 'PICKUP' ? '提货卡' : '现金卡' }}</view>
<view class="gcc-expire">{{ item.expireText }}</view>
</view>
</view>
</view>
<view class="gcc-body">
<view v-if="item.cardType === 'PICKUP'" class="gcc-row">每种一件 · 一次兑完 · 免邮</view>
<view v-else class="gcc-row">
当前余额:
<text class="gcc-strong" v-if="item.balance != null">¥{{ unitPrice(item.balance) }}</text>
<text class="gcc-strong" v-else>—</text>
</view>
<view
class="gcc-action"
:class="{ 'is-disabled': actionDisabled || isActivating(item) }"
@click="onCardPrimaryAction(item)"
>
<text v-if="isActivating(item)">提交中...</text>
<text v-else>{{ actionLabel }}</text>
</view>
</view>
</view>
<view class="load-more" v-if="list.length">{{ loadStatusText }}</view>
<view class="notice">{{ useNotice }}</view>
</scroll-view>
</view>
</template>
<script setup lang="ts">
import {
activateGiftCardCashMemberCard,
bindGiftCardCashMemberCard,
getGiftCardCashMemberCardPage,
} from '@/api/promotions.js'
import { unitPrice } from '@/utils/filters.js'
import {
decorateGiftCard,
GIFT_CARD_STATUS,
GIFT_CARD_USE_NOTICE,
giftCardActionLabel,
resolveMemberCardId,
} from '@/utils/giftCard.js'
import { useStore } from '@/store'
import { onShow } from '@dcloudio/uni-app'
import { computed, ref, watch } from 'vue'
const store = useStore()
const lightColor = computed(() => store.getters.lightColor)
const useNotice = GIFT_CARD_USE_NOTICE
const tabList = [
{ text: '可用', status: GIFT_CARD_STATUS.AVAILABLE },
{ text: '不可用', status: GIFT_CARD_STATUS.UNAVAILABLE },
{ text: '待激活', status: GIFT_CARD_STATUS.PENDING_ACTIVATION },
]
const tabCurrentIndex = ref(0)
const statusTab = computed(() => tabList[tabCurrentIndex.value].status)
const actionLabel = computed(() => giftCardActionLabel(statusTab.value))
const actionDisabled = computed(() => statusTab.value === GIFT_CARD_STATUS.UNAVAILABLE)
const bindForm = ref({ cardNo: '', cardSecret: '' })
const bindSubmitting = ref(false)
const loading = ref(false)
const list = ref<any[]>([])
const pageNumber = ref(1)
const loadStatus = ref('more')
const activatingId = ref('')
const loadStatusText = computed(() => (loadStatus.value === 'noMore' ? '没有更多了' : ''))
onShow(() => {
resetAndLoad()
})
watch(tabCurrentIndex, () => {
resetAndLoad()
})
function resetAndLoad() {
pageNumber.value = 1
list.value = []
loadStatus.value = 'more'
getList()
}
function getList() {
if (loadStatus.value === 'noMore' && pageNumber.value > 1) return
loading.value = true
getGiftCardCashMemberCardPage({
pageNumber: pageNumber.value,
pageSize: 10,
sort: 'createTime',
order: 'desc',
memberCardStatus: statusTab.value,
}).then((res) => {
loading.value = false
if (!res.data.success) return
const records = ((res.data.result && res.data.result.records) || []).map((item: any) =>
decorateGiftCard(item)
)
if (pageNumber.value === 1) {
list.value = records
} else {
list.value = list.value.concat(records)
}
loadStatus.value = records.length < 10 ? 'noMore' : 'more'
}).catch(() => {
loading.value = false
})
}
function loadMore() {
if (loadStatus.value === 'noMore' || loading.value) return
pageNumber.value += 1
getList()
}
function submitBind() {
const cardNo = String(bindForm.value.cardNo || '').trim()
const cardSecret = String(bindForm.value.cardSecret || '').trim()
if (!cardNo) {
uni.showToast({ title: '请输入卡号', icon: 'none' })
return
}
if (!cardSecret) {
uni.showToast({ title: '请输入兑换码', icon: 'none' })
return
}
if (bindSubmitting.value) return
bindSubmitting.value = true
bindGiftCardCashMemberCard({ cardNo, cardSecret })
.then((res) => {
bindSubmitting.value = false
if (!res.data.success) return
uni.showToast({ title: res.data.message || '兑换成功', icon: 'none' })
bindForm.value = { cardNo: '', cardSecret: '' }
const pendingIndex = tabList.findIndex((item) => item.status === GIFT_CARD_STATUS.PENDING_ACTIVATION)
if (pendingIndex >= 0 && tabCurrentIndex.value !== pendingIndex) {
tabCurrentIndex.value = pendingIndex
return
}
resetAndLoad()
})
.catch(() => {
bindSubmitting.value = false
})
}
function isActivating(item: any) {
const id = resolveMemberCardId(item)
return !!activatingId.value && activatingId.value === id
}
function onCardPrimaryAction(item: any) {
if (actionDisabled.value) return
if (statusTab.value === GIFT_CARD_STATUS.PENDING_ACTIVATION) {
const memberCardId = resolveMemberCardId(item)
if (!memberCardId) {
uni.showToast({ title: '卡片信息异常,无法激活', icon: 'none' })
return
}
if (activatingId.value) return
activatingId.value = memberCardId
activateGiftCardCashMemberCard(memberCardId)
.then((res) => {
if (res.data.success) {
uni.showToast({ title: res.data.message || '激活成功', icon: 'none' })
const availableIndex = tabList.findIndex((item) => item.status === GIFT_CARD_STATUS.AVAILABLE)
if (availableIndex >= 0 && tabCurrentIndex.value !== availableIndex) {
tabCurrentIndex.value = availableIndex
return
}
resetAndLoad()
}
})
.finally(() => {
activatingId.value = ''
})
return
}
if (statusTab.value === GIFT_CARD_STATUS.AVAILABLE) {
if (item.cardType === 'PICKUP') uni.navigateTo({ url: '/pages/cart/gift-card/pickupCard?id=' + encodeURIComponent(resolveMemberCardId(item)) })
else uni.switchTab({ url: '/pages/tabbar/home/index' })
}
}
</script>
<style lang="scss" scoped>
.page {
height: 100vh;
background: #f7f8fa;
display: flex;
flex-direction: column;
box-sizing: border-box;
}
.bind-section {
margin: 24rpx;
padding: 28rpx 24rpx 24rpx;
background: #fff;
border-radius: 16rpx;
}
.section-title {
font-size: 30rpx;
font-weight: 600;
color: #333;
margin-bottom: 8rpx;
}
.bind-row {
display: flex;
align-items: center;
min-height: 88rpx;
border-bottom: 1rpx solid #f0f1f5;
}
.bind-label {
width: 110rpx;
flex-shrink: 0;
font-size: 28rpx;
color: #333;
}
.bind-btn {
margin-top: 24rpx;
height: 80rpx;
line-height: 80rpx;
text-align: center;
border-radius: 40rpx;
color: #fff;
font-size: 30rpx;
font-weight: 600;
background: linear-gradient(135deg, #ff6b35, #ff4b2b);
&.disabled {
opacity: 0.6;
}
}
.tabs-wrap {
background: #fff;
}
.list-scroll {
flex: 1;
height: 0;
padding: 24rpx;
box-sizing: border-box;
}
.gcc-card {
border-radius: 20rpx;
overflow: hidden;
background: #fff;
margin-bottom: 24rpx;
box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.06);
&.is-disabled {
opacity: 0.72;
}
}
.gcc-header {
position: relative;
min-height: 180rpx;
background: linear-gradient(125deg, #ff9a4a 0%, #ff7729 42%, #ff8f3d 100%);
}
.gcc-header-pattern {
position: absolute;
inset: 0;
opacity: 0.22;
pointer-events: none;
background-image: repeating-linear-gradient(
-36deg,
transparent,
transparent 10rpx,
rgba(255, 255, 255, 0.45) 10rpx,
rgba(255, 255, 255, 0.45) 12rpx
);
}
.gcc-header-inner {
position: relative;
z-index: 1;
display: flex;
justify-content: space-between;
padding: 28rpx 24rpx 24rpx;
color: #fff;
}
.gcc-header-left {
flex: 1;
min-width: 0;
padding-right: 16rpx;
}
.gcc-title {
font-size: 32rpx;
font-weight: 700;
}
.gcc-face {
margin-top: 12rpx;
font-size: 24rpx;
opacity: 0.95;
}
.gcc-cardno {
margin-top: 28rpx;
font-size: 22rpx;
opacity: 0.75;
word-break: break-all;
}
.gcc-header-right {
text-align: right;
flex-shrink: 0;
}
.gcc-type {
font-size: 32rpx;
font-weight: 700;
}
.gcc-expire {
margin-top: 16rpx;
font-size: 22rpx;
opacity: 0.9;
}
.gcc-body {
padding: 24rpx;
}
.gcc-row {
font-size: 26rpx;
color: #333;
}
.gcc-strong {
color: #ff6b22;
font-weight: 600;
}
.gcc-action {
margin-top: 24rpx;
height: 72rpx;
line-height: 72rpx;
text-align: center;
border-radius: 999rpx;
font-size: 28rpx;
font-weight: 500;
color: #e95b6c;
background: #faf4f5;
&.is-disabled {
color: #c5c8ce;
background: #f7f7f7;
}
}
.load-more,
.notice {
font-size: 24rpx;
color: #999;
line-height: 1.6;
padding: 8rpx 8rpx 40rpx;
}
.notice {
padding-bottom: calc(40rpx + env(safe-area-inset-bottom));
}
</style>

View File

@@ -0,0 +1,118 @@
<!--
提货卡选品及确认兑换,兼容 H5、App 和微信小程序。
@author Bulbasaur
@since 2026-11-05
-->
<template>
<view class="pickup-page">
<view class="notice">每张卡一次兑完,每种一件,免邮。兑换成功后取消不退权益,不支持退款或退货。</view>
<view v-if="loading" class="state">加载中...</view>
<view v-else-if="error" class="state" @click="load">{{ error }},点击重试</view>
<template v-else-if="detail.credentialId">
<view class="title">{{ detail.giftCardName }}</view>
<view v-if="completed || detail.tradeSn" class="state">该提货卡已兑换<button @click="viewOrders">查看订单</button></view>
<template v-else>
<view class="rule">{{ detail.pickupMode === 'ALL' ? '兑换以下全部商品' : '任选 ' + detail.pickupCount + ' 种商品' }} · 已选 {{ selected.length }} 种</view>
<view v-for="goods in detail.goods" :key="goods.id" class="goods" :class="{ selected: selected.includes(goods.id), disabled: !goods.available }" @click="toggle(goods)">
<image :src="goods.thumbnail" mode="aspectFill" />
<view class="goods-info"><view>{{ goods.goodsName }}</view><view class="muted">{{ specsText(goods.specs) }}</view><view class="muted">{{ goods.storeName }} · 1 件</view><text v-if="!goods.available">暂不可兑换</text></view>
<text>{{ selected.includes(goods.id) ? '●' : '○' }}</text>
</view>
<view class="address">
<view class="title">收货地址</view>
<picker :range="addresses" :range-key="'label'" :value="addressIndex" :disabled="busy" @change="chooseAddress"><view>{{ addresses[addressIndex]?.label || '请选择收货地址' }} ›</view></picker>
<view class="links"><text @click="manageAddress">管理收货地址</text><text @click="loadAddresses">刷新地址</text></view>
</view>
<button class="submit" :loading="busy" :disabled="!canSubmit || busy" @click="submit">确认兑换 · 实付 ¥0</button>
</template>
</template>
</view>
</template>
<script setup>
import { computed, ref } from 'vue'
import { onLoad, onShow, onUnload } from '@dcloudio/uni-app'
import { getAddressList } from '@/api/address.js'
import { getPickupCard, previewPickupCard, redeemPickupCard } from '@/api/pickupCard.js'
import storage from '@/utils/storage.js'
const detail = ref({}), selected = ref([]), addresses = ref([]), addressIndex = ref(0)
const loading = ref(false), busy = ref(false), error = ref(''), completed = ref(false)
let cardId = '', active = true, version = 0, owner = ''
const canSubmit = computed(() => selected.value.length === detail.value.pickupCount && !!addresses.value[addressIndex.value] && !detail.value.goods?.some(g => selected.value.includes(g.id) && !g.available))
/** 隔离账号切换和离页后的异步响应。 */
function sameOwner() { return active && owner === String(storage.getUserInfo()?.id || '') }
/** 将既有 SKU 规格转成可读文字。 */
function specsText(value) { try { const specs = JSON.parse(value || '[]'); return Array.isArray(specs) ? specs.filter(s => s.specName !== 'images').map(s => s.specValue).join(' / ') : '' } catch { return value || '' } }
/** 非全选模式可增减选项,数量仍由后端再次校验。 */
function toggle(goods) {
if (busy.value || !goods.available || detail.value.pickupMode === 'ALL') return
if (selected.value.includes(goods.id)) selected.value = selected.value.filter(id => id !== goods.id)
else if (detail.value.pickupCount === 1) selected.value = [goods.id]
else if (selected.value.length < detail.value.pickupCount) selected.value = [...selected.value, goods.id]
else uni.showToast({ title: '已达到可兑换种数', icon: 'none' })
}
/** 读取当前会员地址并保留有效选项。 */
async function loadAddresses() {
const previous = addresses.value[addressIndex.value]?.id
const response = await getAddressList(1, 100)
if (!sameOwner()) return
if (!response.data.success) throw new Error(response.data.message || '地址加载失败')
addresses.value = (response.data.result?.records || []).map(a => ({ ...a, label: `${a.name} ${a.mobile} ${a.consigneeAddressPath || ''} ${a.detail || ''}` }))
const index = addresses.value.findIndex(a => a.id === previous)
addressIndex.value = index >= 0 ? index : Math.max(0, addresses.value.findIndex(a => a.isDefault))
}
/** 刷新卡可用性;返回页面重新校验已选商品。 */
async function load() {
const request = ++version
loading.value = true; error.value = ''
try {
const response = await getPickupCard(cardId)
if (!sameOwner() || request !== version) return
if (!response.data.success) throw new Error(response.data.message || '卡片加载失败')
detail.value = response.data.result
selected.value = detail.value.pickupMode === 'ALL' ? detail.value.goods.map(g => g.id) : selected.value.filter(id => detail.value.goods.some(g => g.id === id && g.available))
await loadAddresses()
} catch (e) { if (sameOwner() && request === version) error.value = e.message || '加载失败' }
finally { if (sameOwner() && request === version) loading.value = false }
}
/** 提交前服务端试算;确认后核销,网络错误允许幂等重试。 */
async function submit() {
if (busy.value || !canSubmit.value || !sameOwner()) return
busy.value = true
const payload = { credentialId: cardId, skuIds: [...selected.value], addressId: addresses.value[addressIndex.value].id }
try {
const preview = await previewPickupCard(payload)
if (!sameOwner()) return
if (!preview.data.success) throw new Error(preview.data.message || '兑换校验失败')
const confirmed = await new Promise(resolve => uni.showModal({ title: '确认兑换', content: '每种一件,免邮且实付为零。兑换后取消不退权益,不支持退款或退货。', confirmText: '确认兑换', success: result => resolve(result.confirm), fail: () => resolve(false) }))
if (!confirmed || !sameOwner()) return
const response = await redeemPickupCard(payload)
if (!sameOwner()) return
if (!response.data.success) throw new Error(response.data.message || '兑换失败')
completed.value = true
} catch (e) {
if (sameOwner()) {
try { const status = await getPickupCard(cardId); if (sameOwner() && status.data.success && status.data.result?.tradeSn) { detail.value = status.data.result; completed.value = true; return } } catch { /* 保留选项以便重试 */ }
uni.showToast({ title: e.message || '结果待确认,请重试或查看订单', icon: 'none' })
}
}
finally { if (sameOwner()) busy.value = false }
}
/** 地址选择仅改变本页状态,不修改地址本身。 */
function chooseAddress(event) { addressIndex.value = Number(event.detail.value) }
/** 复用现有地址管理,返回时刷新。 */
function manageAddress() { if (!busy.value) uni.navigateTo({ url: '/pages/mine/address/addressManage' }) }
/** 兑换订单沿用普通订单列表与物流详情。 */
function viewOrders() { uni.navigateTo({ url: '/pages/order/myOrder?status=0' }) }
onLoad(options => { cardId = options.id || ''; owner = String(storage.getUserInfo()?.id || '') })
onShow(() => {
if (owner !== String(storage.getUserInfo()?.id || '')) { detail.value = {}; selected.value = []; addresses.value = []; error.value = '账号已变更,请返回我的礼品卡'; return }
load()
})
onUnload(() => { active = false; version++ })
</script>
<style scoped>
.pickup-page{min-height:100vh;background:#f6f7f9;padding:24rpx;box-sizing:border-box;padding-bottom:calc(40rpx + env(safe-area-inset-bottom))}.notice{background:#fff5e8;color:#965b24;padding:24rpx;border-radius:16rpx;font-size:26rpx;line-height:1.7}.title{font-weight:600;font-size:32rpx;margin:28rpx 0 20rpx}.rule,.muted{color:#777;font-size:24rpx;margin:12rpx 0}.goods{display:flex;align-items:center;gap:20rpx;background:#fff;border:2rpx solid transparent;border-radius:16rpx;padding:24rpx;margin:16rpx 0}.goods.selected{border-color:#f56c36}.goods.disabled{opacity:.5}.goods image{width:130rpx;height:130rpx;border-radius:12rpx;flex-shrink:0}.goods-info{flex:1;font-size:28rpx}.address{background:#fff;padding:4rpx 24rpx 24rpx;border-radius:16rpx;font-size:26rpx}.links{display:flex;justify-content:space-between;color:#e75d31;margin-top:24rpx}.submit{background:#e75d31;color:#fff;margin-top:32rpx;border-radius:48rpx;font-size:30rpx}.state{text-align:center;padding:60rpx 20rpx}
</style>

View File

@@ -0,0 +1,87 @@
<template>
<view class="error-page">
<u-navbar title="支付失败" :border="false" :fixed="true" :placeholder="true" :auto-back="true"></u-navbar>
<view class="error-content">
<u-icon name="close-circle-fill" color="#f56c6c" size="120"></u-icon>
<text class="error-title">支付失败</text>
<text class="error-desc">{{ errorMessage || '支付过程中出现错误,请重试' }}</text>
<view class="btn-group">
<u-button type="primary" text="返回订单" @click="goBack"></u-button>
<u-button type="warning" text="去支付" @click="rePay"></u-button>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
const errorMessage = ref('')
const orderSn = ref('')
onLoad((options: any) => {
if (options) {
errorMessage.value = options.message || ''
orderSn.value = options.orderSn || ''
}
})
function goBack() {
uni.navigateBack({
fail: () => {
uni.switchTab({ url: '/pages/tabbar/user/my' })
}
})
}
function rePay() {
if (orderSn.value) {
uni.navigateTo({
url: `/pages/cart/payment/payOrder?orderSn=${orderSn.value}`
})
} else {
goBack()
}
}
</script>
<style lang="scss" scoped>
.error-page {
min-height: 100vh;
background: #fff;
}
.error-content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 200rpx 40rpx;
}
.error-title {
font-size: 36rpx;
font-weight: bold;
color: #333;
margin-top: 40rpx;
}
.error-desc {
font-size: 28rpx;
color: #999;
margin-top: 20rpx;
text-align: center;
}
.btn-group {
display: flex;
gap: 24rpx;
margin-top: 60rpx;
width: 100%;
:deep(.u-button) {
flex: 1;
}
}
</style>

View File

@@ -1,496 +1,455 @@
<template> <template>
<div class="wrapper"> <div :style="themeStyle" class="wrapper">
<div class="box"> <div class="box">
<div class="block block-1"> <div class="block block-1">
<image class="img" src="@/pages/cart/static/pay.png" /> <image class="img" src="@/pages/cart/static/pay.png" />
<p class="ptips">收银台</p> <p class="ptips">收银台</p>
<p class="ptips">剩余支付时间: <view class="ptips ptips-countdown">
<u-count-down :show-days="false" :show-border="true" font-size="28" color="#008ffa" border-color="#008ffa" ref="uCountDown" :timestamp="autoCancel"></u-count-down> 剩余支付时间:
</p> <u-count-down
<p class="ptips"> v-if="autoCancelTime > 0"
:time="autoCancelTime"
format="HH:mm:ss"
@finish="onPayTimeout"
>
<template #default="{ hours, minutes, seconds }">
<view class="countdown-box">
<text class="countdown-num">{{ padTime(hours) }}</text>
<text class="countdown-colon">:</text>
<text class="countdown-num">{{ padTime(minutes) }}</text>
<text class="countdown-colon">:</text>
<text class="countdown-num">{{ padTime(seconds) }}</text>
</view>
</template>
</u-count-down>
<view v-else class="countdown-box">
<text class="countdown-num">00</text>
<text class="countdown-colon">:</text>
<text class="countdown-num">00</text>
<text class="countdown-colon">:</text>
<text class="countdown-num">00</text>
</view>
</view>
<view class="ptips ptips-price">
支付金额 支付金额
<span>¥{{ cashierParams.price | unitPrice }}</span> <text class="price-text">¥{{ unitPrice(cashierParams.price) }}</text>
</p> </view>
</div> </div>
</div> </div>
<div class="__pay_form__"> <div class="__pay_form__">
</div> </div>
<div class="block-4" v-if="cashierParams.price > 0"> <div class="block-4" v-if="cashierParams.price > 0">
<div class="payItem">支付方式</div> <div class="payItem payItem-title">支付方式</div>
<div class="payItem" v-for="(item, index) in payList" :key="index"> <div
<u-row class="row"> class="payItem payItem-method"
<div class="col1" @click="awaitPay(item, index)" size="100" style="text-align:left;"> v-for="(item, index) in payList"
<div v-if="item == 'ALIPAY'"> :key="index"
<u-icon class="method_icon" name="zhifubao-circle-fill" color="#008ffa" size="80"></u-icon> @click="awaitPay(item, index)"
<span class="method_name">支付宝</span> >
</div> <view class="method-left">
<div v-if="item == 'WECHAT'"> <template v-if="item == 'ALIPAY'">
<u-icon class="method_icon" name="weixin-circle-fill" color="#00c98b" size="80"></u-icon> <u-icon class="method_icon" name="zhifubao-circle-fill" color="#008ffa" size="44"></u-icon>
<span class="method_name">微信</span> <text class="method_name">支付宝</text>
</div> </template>
<div v-if="item == 'WALLET'"> <template v-if="item == 'WECHAT'">
<u-icon class="method_icon" name="red-packet-fill" color="#dd6161" size="80"></u-icon> <u-icon class="method_icon" name="weixin-circle-fill" color="#00c98b" size="44"></u-icon>
<span class="method_name">余额支付(当前余额:¥{{ walletValue | unitPrice }})</span> <text class="method_name">微信</text>
</div> </template>
</div> <template v-if="item == 'WALLET'">
<div class="col3" @click="awaitPay(item)" textAlign="right"> <u-icon class="method_icon" name="red-packet-fill" color="#dd6161" size="44"></u-icon>
<u-icon size="26" color="#b1b1b1" name="arrow-right"></u-icon> <text class="method_name">余额支付(当前余额:¥{{ unitPrice(walletValue) }})</text>
</div> </template>
</u-row> </view>
<u-icon size="28" color="#b1b1b1" name="arrow-right"></u-icon>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script> <script setup lang="ts">
import * as API_Trade from "@/api/trade"; import { ref, getCurrentInstance, onMounted, computed } from 'vue'
import {payCallback} from '@/api/members' import { onLoad, onBackPress, onUnload } from '@dcloudio/uni-app'
export default { import { useStore } from '@/store'
data() { import * as API_Trade from '@/api/trade'
return { import { payCallback } from '@/api/members'
//路径传参 import { unitPrice } from '@/utils/filters.js'
routerVal: "", import { getThemeStyle } from '@/utils/theme'
//收银台参数
cashierParams: "",
//支付方式集合
payList: "",
//支付sn
sn: "",
//订单类型
orderType: "",
//支付异常
exception: {},
//支付表单
payForm: {},
//支付类型 APP/WECHAT_MP/H5/NATIVE app/微信小程序/h5/二维码
paymentType: "",
// 支付客户端 APP/NATIVE/JSAPI/H5
paymentClient: "",
//余额
walletValue: 0.0,
// 支付倒计时
autoCancel: 0,
};
},
onLoad(val) {
this.routerVal = val;
//初始化参数 const store = useStore()
// #ifdef APP-PLUS const themeStyle = computed(() => getThemeStyle(store.state.theme))
this.paymentType = "APP"; const { proxy } = getCurrentInstance()!
this.paymentClient = "APP";
//#endif
// #ifdef MP-WEIXIN
this.paymentType = "WECHAT_MP";
this.paymentClient = "MP";
//#endif
// #ifdef H5
this.paymentType = "H5";
//如果是微信浏览器,则使用公众号支付,否则使用h5,
// 区别是:h5是通过浏览器外部调用微信app进行支付,而JSAPI则是 在微信浏览器内部,或者小程序 调用微信支付
this.paymentClient = this.isWeiXin() ? "JSAPI" : "H5";
//#endif
const routerVal = ref<Record<string, string>>({})
const cashierParams = ref<Record<string, any>>({ price: 0 })
const payList = ref<string[]>([])
const sn = ref('')
const orderType = ref('')
const paymentType = ref('')
const paymentClient = ref('')
const walletValue = ref(0)
const autoCancelTime = ref(0)
let h5PollTimer: ReturnType<typeof setInterval> | undefined
onUnload(() => { if (h5PollTimer) clearInterval(h5PollTimer) })
onLoad((val) => {
routerVal.value = val || {}
// #ifdef APP-PLUS
paymentType.value = 'APP'
paymentClient.value = 'APP'
// #endif
// #ifdef MP-WEIXIN
paymentType.value = 'WECHAT_MP'
paymentClient.value = 'MP'
// #endif
// #ifdef H5
paymentType.value = 'H5'
paymentClient.value = isWeiXin() ? 'JSAPI' : 'H5'
// #endif
})
// onBackPress((e) => {
}, if (e.from == 'backbutton') {
onBackPress(e) { if (routerVal.value.paid_member_sn) {
if (e.from == "backbutton") { uni.redirectTo({ url: '/pages/mine/paidMemberRecords' })
if(this.routerVal.recharge_sn){ } else if (routerVal.value.recharge_sn) {
uni.switchTab({ uni.switchTab({ url: '/pages/tabbar/user/my' })
url: '/pages/tabbar/user/my' } else {
}); uni.navigateTo({ url: '/pages/order/myOrder?status=0' })
} }
else{ return true
uni.navigateTo({ }
url: "/pages/order/myOrder?status=0", return false
}); })
}
return true; //阻止默认返回行为
}
},
mounted() {
this.cashierData();
},
methods: {
/** onMounted(() => {
* 支付成功后跳转 cashierData()
*/ })
callback(paymentMethod){
uni.navigateTo({
url: "/pages/cart/payment/success?paymentMethod=" +
paymentMethod +
"&payPrice=" +
this.cashierParams.price+
"&orderType="+this.orderType
});
},
/**
* 获取收银详情
*/
cashierData() {
let parms = {};
if (this.routerVal.recharge_sn) { function hideLoadingIfNeeded() {
// 判断当前是否是充值 if (store.state.isShowToast) uni.hideLoading()
this.sn = this.routerVal.recharge_sn; }
this.orderType = "RECHARGE";
} else if (this.routerVal.trade_sn) {
this.sn = this.routerVal.trade_sn;
this.orderType = "TRADE";
} else {
this.sn = this.routerVal.order_sn;
this.orderType = "ORDER";
}
parms.sn = this.sn;
parms.orderType = this.orderType;
parms.clientType = this.paymentType;
API_Trade.getCashierData(parms).then((res) => { function callback(paymentMethod: string) {
if (orderType.value === 'PAID_MEMBER') {
if(res.data.success){ uni.redirectTo({ url: '/pages/mine/paidMember?payment_sn=' + encodeURIComponent(sn.value) })
this.cashierParams = res.data.result; return
}
const goSuccess = () => {
uni.redirectTo({
url:
'/pages/cart/payment/success?paymentMethod=' +
paymentMethod +
'&payPrice=' +
cashierParams.value.price +
'&orderType=' +
orderType.value +
'&orderPromotionType=' +
(cashierParams.value.orderPromotionType || ''),
})
}
goSuccess()
}
// #ifdef MP-WEIXIN function cashierData() {
this.payList = res.data.result.support.filter((item) => { const parms: Record<string, string> = {}
return item != "ALIPAY";
});
// #endif
if (routerVal.value.paid_member_sn) {
if(this.routerVal.recharge_sn){ sn.value = routerVal.value.paid_member_sn
this.payList = res.data.result.support.filter((item) => { orderType.value = 'PAID_MEMBER'
return item != "WALLET"; } else if (routerVal.value.recharge_sn) {
}) sn.value = routerVal.value.recharge_sn
} orderType.value = 'RECHARGE'
else{ } else if (routerVal.value.trade_sn) {
this.payList = res.data.result.support; sn.value = routerVal.value.trade_sn
} orderType.value = 'TRADE'
// #ifdef H5 } else {
//判断是否微信浏览器 sn.value = routerVal.value.order_sn
var ua = window.navigator.userAgent.toLowerCase(); orderType.value = 'ORDER'
if (ua.match(/MicroMessenger/i) == 'micromessenger') { }
parms.sn = sn.value
this.payList = res.data.result.support.filter((item) => { parms.orderType = orderType.value
return item != "ALIPAY"; parms.clientType = paymentType.value
});
// 充值的话仅保留微信支付
if(this.orderType == "RECHARGE"){
this.payList = res.data.result.support.filter((item) => {
return item == "WECHAT";
});
}
}
// #endif
this.walletValue = res.data.result.walletValue; API_Trade.getCashierData(parms).then((res) => {
this.autoCancel = if (res.data.success) {
(res.data.result.autoCancel - new Date().getTime()) / 1000; cashierParams.value = res.data.result
}
else if(res.data.code == 32000){
setTimeout(()=>{
uni.redirectTo({
url: `/pages/order/myOrder?status=0`
});
},500)
}
});
},
// #ifdef MP-WEIXIN
payList.value = res.data.result.support.filter((item: string) => item != 'ALIPAY')
// #endif
awaitPay(payment){ if (routerVal.value.recharge_sn) {
this.$u.throttle(()=>{ payList.value = res.data.result.support.filter((item: string) => item != 'WALLET')
this.pay(payment) } else {
}, 2000) payList.value = res.data.result.support
}, }
//订单支付 // #ifdef H5
async pay(payment) { const ua = window.navigator.userAgent.toLowerCase()
if (ua.match(/MicroMessenger/i) == 'micromessenger') {
// 支付编号 payList.value = res.data.result.support.filter((item: string) => item != 'ALIPAY')
const sn = this.sn; if (orderType.value == 'RECHARGE') {
// 交易类型【交易号|订单号】 payList.value = res.data.result.support.filter((item: string) => item == 'WECHAT')
const orderType = this.orderType; }
}
// #endif
const clientType = this.paymentType; walletValue.value = res.data.result.walletValue
let params = { const cancelAt = Number(res.data.result.autoCancel)
sn, autoCancelTime.value = cancelAt > 0 ? Math.max(cancelAt - Date.now(), 0) : 0
orderType, } else if (res.data.code == 32000) {
clientType, setTimeout(() => {
}; uni.redirectTo({ url: '/pages/order/myOrder?status=0' })
}, 500)
}
})
}
//支付方式 WECHAT/ALIPAY function awaitPay(payment: string) {
const paymentMethod = payment; proxy.$u.throttle(() => {
// 客户端类型 APP/NATIVE/JSAPI/H5 pay(payment)
const paymentClient = this.paymentClient; }, 2000)
}
uni.showLoading({
title: "正在唤起支付...",
mask:true
});
// #ifdef APP-PLUS
//APP pay
// 初始化支付签名
await API_Trade.initiatePay(paymentMethod, paymentClient, params).then(
(signXml) => {
if (this.$store.state.isShowToast){ uni.hideLoading() };
//如果支付异常
if (!signXml.data.success) {
uni.showToast({
title: signXml.data.message,
duration: 2000
});
return;
}
let payForm = signXml.data.result;
let paymentType = paymentMethod === "WECHAT" ? "wxpay" : "alipay";
if(paymentMethod === "WALLET"){
uni.showToast({
icon: "none",
title: "支付成功!",
});
this.callback(paymentMethod)
}
else{
uni.requestPayment({
provider: paymentType,
orderInfo: payForm || '',
success: (e) => {
uni.showToast({
icon: "none",
title: "支付成功!",
});
this.callback(paymentMethod)
},
fail: (e) => {
console.log(this);
this.exception = e;
uni.showModal({
content: "支付失败,如果您已支付,请勿反复支付",
showCancel: false,
});
},
});
}
}
);
//APP pay
// #endif
//#ifdef H5 function padTime(val: number) {
//H5 pay return String(val != null ? val : 0).padStart(2, '0')
await API_Trade.initiatePay(paymentMethod, paymentClient, params).then( }
(res) => {
let response = res.data;
//如果非支付宝支付才需要进行判定,因为支付宝h5支付是直接输出的,没有返回所谓的消息状态
if(paymentMethod !== "ALIPAY"){
//如果支付异常
if (!response.success) {
uni.showToast({
title: response.message,
duration: 2000,
icon:"none"
});
return;
}
}
if (paymentMethod === "ALIPAY") {
document.write(response);
} else if (paymentMethod === "WECHAT") {
if (this.isWeiXin()) {
//微信公众号支付
WeixinJSBridge.invoke(
"getBrandWCPayRequest",
response.result,
(res) => {
if (res.err_msg == "get_brand_wcpay_request:ok") {
// 使用以上方式判断前端返回,微信团队郑重提示:
//res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
uni.showToast({
icon: "none",
title: "支付成功!",
});
this.callback(paymentMethod)
} else {
uni.showModal({
content: "支付失败,如果您已支付,请勿反复支付",
showCancel: false,
});
}
}
);
if (this.$store.state.isShowToast){ uni.hideLoading() };
} else {
window.location.href = JSON.parse(response.result).h5_url;
const searchParams = {
...params,
price:this.cashierParams,
}
const timer = setInterval(()=>{
payCallback(searchParams).then(res=>{
if(res.data.result){
clearTimeout(timer);
uni.navigateTo({
url:"/pages/order/myOrder"
})
}
})
},3000)
if (this.$store.state.isShowToast){ uni.hideLoading() };
}
} else if (paymentMethod === "WALLET") {
uni.showToast({
title: response.message,
icon: "none",
});
if (response.success) {
this.callback(paymentMethod)
}
}
}
);
//H5pay
// #endif
//#ifdef MP-WEIXIN function onPayTimeout() {
//微信小程序 uni.showToast({ title: '支付超时,请重新下单', icon: 'none' })
await API_Trade.initiatePay(paymentMethod, paymentClient, params).then( setTimeout(() => {
(res) => { uni.redirectTo({ url: '/pages/order/myOrder?status=0' })
let response = res.data.result; }, 1500)
//如果支付异常 }
if (!res.data.success) {
uni.showModal({ function goPayError(message = '支付失败,如果您已支付,请勿反复支付') {
content: res.data.message, if (orderType.value === 'PAID_MEMBER') {
showCancel: false, uni.showToast({ title: '支付未完成,请在购买记录中查看结果', icon: 'none' })
}) uni.redirectTo({ url: '/pages/mine/paidMemberRecords' })
return; return
} }
if (paymentMethod === "WECHAT") { const query = [`orderSn=${encodeURIComponent(sn.value)}`, `message=${encodeURIComponent(message)}`]
uni.requestPayment({ uni.navigateTo({ url: `/pages/cart/payment/error?${query.join('&')}` })
provider: "wxpay", }
appid: response.appid,
timeStamp: response.timeStamp, async function pay(payment: string) {
nonceStr: response.nonceStr, const params = {
package: response.package, sn: sn.value,
signType: response.signType, orderType: orderType.value,
paySign: response.paySign, clientType: paymentType.value,
success: (e) => { }
console.log(e); const paymentMethod = payment
uni.showToast({ const client = paymentClient.value
icon: "none",
title: "支付成功!", uni.showLoading({ title: '正在唤起支付...', mask: true })
});
this.callback(paymentMethod) // #ifdef APP-PLUS
await API_Trade.initiatePay(paymentMethod, client, params).then((signXml) => {
}, hideLoadingIfNeeded()
fail: (e) => { if (!signXml.data.success) {
console.log(e); uni.showToast({ title: signXml.data.message, duration: 2000 })
this.exception = e; return
uni.showModal({ }
content: "支付失败,如果您已支付,请勿反复支付", const payForm = signXml.data.result
showCancel: false, const provider = paymentMethod === 'WECHAT' ? 'wxpay' : 'alipay'
}); if (paymentMethod === 'WALLET') {
}, uni.showToast({ icon: 'none', title: '支付成功!' })
}); callback(paymentMethod)
} else { } else {
uni.showToast({ uni.requestPayment({
icon: "none", provider,
title: "支付成功!", orderInfo: payForm || '',
}); success: () => {
this.callback(paymentMethod) uni.showToast({ icon: 'none', title: '支付成功!' })
callback(paymentMethod)
} },
} fail: () => {
); goPayError()
// #endif },
}, })
isWeiXin() { }
var ua = window.navigator.userAgent.toLowerCase(); })
if (ua.match(/MicroMessenger/i) == "micromessenger") { // #endif
return true;
} else { // #ifdef H5
return false; await API_Trade.initiatePay(paymentMethod, client, params).then((res) => {
} const response = res.data
}, if (paymentMethod !== 'ALIPAY' && !response.success) {
}, uni.showToast({ title: response.message, duration: 2000, icon: 'none' })
}; return
}
if (paymentMethod === 'ALIPAY') {
document.write(response)
} else if (paymentMethod === 'WECHAT') {
if (isWeiXin()) {
WeixinJSBridge.invoke('getBrandWCPayRequest', response.result, (payRes: any) => {
if (payRes.err_msg == 'get_brand_wcpay_request:ok') {
uni.showToast({ icon: 'none', title: '支付成功!' })
callback(paymentMethod)
} else {
goPayError()
}
})
hideLoadingIfNeeded()
} else {
const paymentUrl = typeof response.result === 'string' && response.result.startsWith('http')
? response.result : JSON.parse(response.result).h5_url
const returnUrl = orderType.value === 'PAID_MEMBER'
? window.location.href.split('#')[0] + '#/pages/mine/paidMember?payment_sn=' + encodeURIComponent(sn.value)
: window.location.href
window.location.href = paymentUrl + (paymentUrl.includes('?') ? '&' : '?') + 'redirect_url=' + encodeURIComponent(returnUrl)
const searchParams = { ...params, price: cashierParams.value }
let attempts = 0
if (h5PollTimer) clearInterval(h5PollTimer)
h5PollTimer = setInterval(() => {
if (++attempts > 100) { clearInterval(h5PollTimer); return }
payCallback(searchParams).then((cbRes) => {
if (cbRes.data.result) {
clearInterval(h5PollTimer)
if (orderType.value === 'PAID_MEMBER') callback(paymentMethod)
else uni.navigateTo({ url: '/pages/order/myOrder' })
}
}).catch(() => {})
}, 3000)
hideLoadingIfNeeded()
}
} else if (paymentMethod === 'WALLET') {
uni.showToast({ title: response.message, icon: 'none' })
if (response.success) callback(paymentMethod)
}
})
// #endif
// #ifdef MP-WEIXIN
await API_Trade.initiatePay(paymentMethod, client, params).then((res) => {
const response = res.data.result
if (!res.data.success) {
uni.showModal({ content: res.data.message, showCancel: false })
return
}
if (paymentMethod === 'WECHAT') {
uni.requestPayment({
provider: 'wxpay',
appid: response.appid,
timeStamp: response.timeStamp,
nonceStr: response.nonceStr,
package: response.package,
signType: response.signType,
paySign: response.paySign,
success: () => {
uni.showToast({ icon: 'none', title: '支付成功!' })
callback(paymentMethod)
},
fail: () => {
goPayError()
},
})
} else {
uni.showToast({ icon: 'none', title: '支付成功!' })
callback(paymentMethod)
}
})
// #endif
}
function isWeiXin() {
const ua = window.navigator.userAgent.toLowerCase()
return ua.match(/MicroMessenger/i) == 'micromessenger'
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.method_icon { .method_icon {
vertical-align: middle; flex-shrink: 0;
}
.method-left {
display: flex;
align-items: center;
flex: 1;
min-width: 0;
} }
.method_name { .method_name {
font-size: 28rpx; font-size: 28rpx;
color: #999; color: #333;
padding-left: 24rpx; padding-left: 20rpx;
}
.row {
display: flex;
width: 100%;
}
/deep/ .u-row {
width: 100% !important;
display: flex;
justify-content: space-between !important;
}
.method_name,
.col1 {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
} }
.col1 {
text-align: center;
flex: 99;
}
.col3 {
text-align: right;
flex: 1;
}
.payItem { .payItem {
padding: 13px 25rpx; padding: 0 30rpx;
border-top: 1px solid #f9f9f9; border-top: 1px solid #f5f5f5;
line-height: 100rpx;
font-size: 36rpx;
color: #333; color: #333;
} }
.payItem-title {
font-size: 28rpx;
color: #999;
padding-top: 24rpx;
padding-bottom: 16rpx;
border-top: none;
}
.payItem-method {
display: flex;
align-items: center;
justify-content: space-between;
min-height: 100rpx;
padding-top: 24rpx;
padding-bottom: 24rpx;
}
.ptips { .ptips {
font-size: 32rpx; font-size: 32rpx;
margin: 20rpx 0; margin: 20rpx 0;
color: #333; color: #333;
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
}
> span { .ptips-countdown {
gap: 8rpx;
}
.ptips-price {
.price-text {
font-size: 40rpx; font-size: 40rpx;
color: #df5a52; color: $main-color;
font-weight: 600;
margin-left: 10rpx; margin-left: 10rpx;
} }
} }
.countdown-box {
display: inline-flex;
align-items: center;
}
.countdown-num {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 44rpx;
height: 44rpx;
padding: 0 8rpx;
font-size: 28rpx;
color: #008ffa;
border: 1rpx solid #008ffa;
border-radius: 8rpx;
box-sizing: border-box;
}
.countdown-colon {
margin: 0 6rpx;
font-size: 28rpx;
color: #008ffa;
font-weight: 600;
}
.img { .img {
width: 392rpx !important; width: 392rpx !important;
height: 296rpx !important; height: 296rpx !important;

View File

@@ -1,9 +1,9 @@
<template> <template>
<view class="wrapper" v-if="flag"> <view :style="themeStyle" class="wrapper" v-if="flag">
<div class='goods' v-if="selectedGoods"> <div class='goods' v-if="selectedGoods">
<image class="goods-image" :src="selectedGoods.thumbnail" alt=""> <image class="goods-image" :src="selectedGoods.thumbnail" alt="" />
<p class="goodsName">{{selectedGoods.goodsName}}</p> <p class="goodsName">{{selectedGoods.goodsName}}</p>
<div class="goodsPrice">{{(selectedGoods.promotionPrice || selectedGoods.price ) | unitPrice('¥')}}</div> <div class="goodsPrice">{{ unitPrice(selectedGoods.promotionPrice || selectedGoods.price, '¥') }}</div>
</div> </div>
<div> <div>
<div class="tips"> <div class="tips">
@@ -14,6 +14,9 @@
<span v-if="isBuy &&!master.toBeGroupedNum >0"> <span v-if="isBuy &&!master.toBeGroupedNum >0">
已成功拼团 已成功拼团
</span> </span>
<span v-if="!master.toBeGroupedNum >0">
拼团已结束
</span>
</div> </div>
<div v-if="isMaster && !isOver"> <div v-if="isMaster && !isOver">
@@ -24,7 +27,7 @@
去首页逛逛 去首页逛逛
</div> </div>
</div> </div>
<div v-if="!isMaster && !isOver && !isBuy"> <div v-if="!isMaster && !isOver && !isBuy && master.toBeGroupedNum">
<div class="share-user" @click="toBuy"> <div class="share-user" @click="toBuy">
参与拼团 参与拼团
</div> </div>
@@ -45,184 +48,203 @@
</div> </div>
<!-- 倒计时 --> <!-- 倒计时 -->
<div class="count-down" v-if="!isOver"> <div class="count-down" v-if="!isOver && master.toBeGroupedNum">
<u-count-down bg-color="#ededed" :hide-zero-day="true" @end="isOver" :timestamp="timeStamp"></u-count-down> <u-count-down
v-if="timeStamp > 0"
bgColor="#ededed"
:time="timeStamp * 1000"
format="HH:mm:ss"
@finish="onCountDownEnd"
></u-count-down>
</div> </div>
<div class="user-list" v-if="data.pintuanMemberVOS"> <div class="user-list" v-if="data.pintuanMemberVOS">
<div class="user-item" v-for="(item,index) in data.pintuanMemberVOS" :key="index"> <div class="user-item" v-for="(item,index) in data.pintuanMemberVOS" :key="index">
<span class="master" v-if="item.orderSn == ''">团长</span> <span class="master" v-if="item.orderSn == ''">团长</span>
<image class="img" :src="item.face" alt=""> <image class="img" :src="item.face" alt="" />
</div> </div>
</div> </div>
<popupGoods :addr="addr" ref="popupGoods" :buyMask="maskFlag" @closeBuy="closePopupBuy" :goodsDetail="goodsDetail" :goodsSpec="goodsSpec" v-if="goodsDetail.id " @handleClickSku="getGoodsDetail" /> <popupGoods
<shares @close="closeShare" :link="'/pages/cart/payment/shareOrderGoods?sn='+this.routers.sn+'&sku='+this.routers.sku+'&goodsId='+this.routers.goodsId" type="pintuan" :addr="addr"
:thumbnail="data.promotionGoods.thumbnail" :goodsName="data.promotionGoods.goodsName" v-if="shareFlag " /> ref="popupGoodsRef"
:buyMask="maskFlag"
@closeBuy="closePopupBuy"
:goodsDetail="goodsDetail"
:goodsSpec="goodsSpec"
v-if="goodsDetail.id"
@handleClickSku="getGoodsDetail"
/>
<shares
@close="closeShare"
:link="shareLink"
type="pintuan"
:thumbnail="data.promotionGoods.thumbnail"
:goodsName="data.promotionGoods.goodsName"
v-if="shareFlag"
/>
</view> </view>
</template> </template>
<script> <script setup lang="ts">
import { getGoods } from "@/api/goods.js"; import { ref, computed, watch, onMounted } from 'vue'
import { getPinTuanShare } from "@/api/order"; import { onLoad } from '@dcloudio/uni-app'
import shares from "@/components/m-share/index"; import { useStore } from '@/store'
import storage from "@/utils/storage.js"; import { getGoods } from '@/api/goods.js'
import popupGoods from "@/components/m-buy/goods"; //购物车商品的模块 import { getPinTuanShare } from '@/api/order'
import shares from '@/components/m-share/index'
import storage from '@/utils/storage.js'
import popupGoods from '@/components/m-buy/goods'
import { unitPrice } from '@/utils/filters.js'
import { getThemeStyle } from '@/utils/theme'
export default { const store = useStore()
data() { const themeStyle = computed(() => getThemeStyle(store.state.theme))
return {
flag: false, //判断接口是否正常请求 const popupGoodsRef = ref<any>(null)
addr: { const flag = ref(false)
id: "", const addr = ref({ id: '' })
}, const maskFlag = ref(false)
maskFlag: false, //商品弹框 const timeStamp = ref(0)
timeStamp: 0, const shareFlag = ref(false)
shareFlag: false, const data = ref<any>(null)
data: "", const isMaster = ref(true)
isMaster: true, const selectedGoods = ref<any>(null)
selectedGoods: "", //选择的商品规格昵称 const routers = ref<Record<string, string>>({})
routers: "", //传参数据 const goodsDetail = ref<any>({})
goodsDetail: "", //商品详情 const goodsSpec = ref<any>(null)
goodsSpec: "", const master = ref<any>(null)
master: "", // 团长 const PromotionList = ref<any>(null)
PromotionList: "", //优惠集合 const isGroup = ref(false)
isGroup: false, //是否拼团 const isOver = ref(false)
isOver: false, //是否结束活动 const isBuy = ref(false)
isBuy: false, //当前用户是是否购买
}; const shareLink = computed(() => {
}, const { sn, sku, goodsId } = routers.value
components: { return `/pages/cart/payment/shareOrderGoods?sn=${sn}&sku=${sku}&goodsId=${goodsId}`
shares, })
popupGoods,
}, watch(isGroup, (val) => {
watch: { if (val) {
isGroup(val) { const timer = setInterval(() => {
if (val) { if (popupGoodsRef.value) {
let timer = setInterval(() => { popupGoodsRef.value.buyType = 'PINTUAN'
this.$refs.popupGoods.buyType = "PINTUAN";
clearInterval(timer);
}, 100);
} else {
this.$refs.popupGoods.buyType = "";
} }
}, clearInterval(timer)
}, }, 100)
onLoad(options) { } else if (popupGoodsRef.value) {
this.routers = options; popupGoodsRef.value.buyType = ''
}, }
mounted() { })
this.init(this.routers.sn, this.routers.sku);
},
methods: {
closeShare() {
this.shareFlag = false;
},
// 这里的话得先跳到商品详情才能购买商品
toBuy() {
this.maskFlag = true;
this.$refs.popupGoods.parentOrder = {
...this.master,
orderSn: this.routers.sn,
};
this.$refs.popupGoods.isMask = true;
this.$refs.popupGoods.isClose = true;
this.$refs.popupGoods.buyType = "PINTUAN";
},
// 分享
share() {
this.shareFlag = true;
},
closePopupBuy(val) {
this.maskFlag = false;
},
// 实例化本页面
async init(sn, sku) {
let res = await getPinTuanShare(sn, sku);
if (res.data.success && res.data.result.promotionGoods) {
this.flag = true;
this.data = res.data.result;
this.selectedGoods = res.data.result.promotionGoods;
let endTime = Date.parse(
res.data.result.promotionGoods.endTime.replace(/-/g, "/")
);
// 获取当前剩余的拼团商品时间
let timeStamp = Date.parse(new Date(endTime)) / 1000;
// 获取当前时间时间戳 onLoad((options) => {
let dateTime = Date.parse(new Date()) / 1000; routers.value = options || {}
})
this.timeStamp = parseInt(timeStamp - dateTime); onMounted(() => {
init(routers.value.sn, routers.value.sku)
})
this.timeStamp <= 0 ? (this.isOver = true) : (this.isOver = false); function hideLoadingIfNeeded() {
if (store.state.isShowToast) uni.hideLoading()
}
// 获取剩余拼团人数 function closeShare() {
this.master = shareFlag.value = false
res.data.result.pintuanMemberVOS.length != 0 && }
res.data.result.pintuanMemberVOS.filter((item) => {
return item.orderSn == "";
})[0];
// 获取当前是否是拼团本人 function onCountDownEnd() {
if ( isOver.value = true
storage.getUserInfo(this.routers.sku, this.routers.goodsId).id == }
this.master.memberId
) { function toBuy() {
this.isMaster = true; maskFlag.value = true
} else { if (!popupGoodsRef.value) return
this.isMaster = false; popupGoodsRef.value.parentOrder = {
// 获取商品详情 ...master.value,
this.getGoodsDetail({ orderSn: routers.value.sn,
id: this.routers.sku, }
goodsId: this.routers.goodsId, popupGoodsRef.value.isMask = true
}); popupGoodsRef.value.isClose = true
popupGoodsRef.value.buyType = 'PINTUAN'
}
function share() {
shareFlag.value = true
}
function closePopupBuy() {
maskFlag.value = false
}
async function init(sn: string, sku: string) {
const res = await getPinTuanShare(sn, sku)
if (res.data.success && res.data.result.promotionGoods) {
flag.value = true
data.value = res.data.result
selectedGoods.value = res.data.result.promotionGoods
const endTime = Date.parse(
res.data.result.promotionGoods.endTime.replace(/-/g, '/')
)
const endTimestamp = Date.parse(new Date(endTime) as any) / 1000
const dateTime = Date.parse(new Date() as any) / 1000
timeStamp.value = parseInt(String(endTimestamp - dateTime))
isOver.value = timeStamp.value <= 0
master.value =
res.data.result.pintuanMemberVOS.length != 0 &&
res.data.result.pintuanMemberVOS.filter((item: any) => item.orderSn == '')[0]
if (
storage.getUserInfo(routers.value.sku, routers.value.goodsId).id ==
master.value.memberId
) {
isMaster.value = true
} else {
isMaster.value = false
getGoodsDetail({
id: routers.value.sku,
goodsId: routers.value.goodsId,
})
}
if (storage.getUserInfo().id) {
const bought = res.data.result.pintuanMemberVOS.filter(
(item: any) => item.memberId == storage.getUserInfo().id
)
isBuy.value = bought.length != 0
}
} else {
uni.showToast({
title: '当前拼团单有误!请联系管理员重试',
duration: 2000,
icon: 'none',
})
}
}
function getGoodsDetail(val: { id: string; goodsId: string }) {
const { id, goodsId } = val
uni.showLoading({ title: '加载中', mask: true })
getGoods(id, goodsId).then((response) => {
goodsDetail.value = response.data.result.data
selectedGoods.value = response.data.result.data
goodsSpec.value = response.data.result.specs
hideLoadingIfNeeded()
PromotionList.value = response.data.result.promotionMap
if (PromotionList.value) {
Object.keys(PromotionList.value).forEach((item) => {
if (item.indexOf('PINTUAN') == 0) {
isGroup.value = true
} }
})
}
})
}
// 获取当前商品是否已经购买 function handleClickHome() {
if (storage.getUserInfo().id) { uni.switchTab({ url: '/pages/tabbar/home/index' })
let isBuy = res.data.result.pintuanMemberVOS.filter((item) => { }
return item.memberId == storage.getUserInfo().id;
});
isBuy.length != 0 ? (this.isBuy = true) : (this.isBuy = false);
}
} else {
uni.showToast({
title: "当前拼团单有误!请联系管理员重试",
duration: 2000,
icon: "none",
});
}
},
// 获取商品详情
getGoodsDetail(val) {
let { id, goodsId } = val;
uni.showLoading({
title: "加载中",
mask: true,
});
getGoods(id, goodsId).then((response) => {
this.goodsDetail = response.data.result.data;
this.selectedGoods = response.data.result.data;
this.goodsSpec = response.data.result.specs;
if (this.$store.state.isShowToast){ uni.hideLoading() };
this.PromotionList = response.data.result.promotionMap;
// 判断是否拼团活动 如果有则显示拼团活动信息
this.PromotionList &&
Object.keys(this.PromotionList).forEach((item) => {
if (item.indexOf("PINTUAN") == 0) {
this.isGroup = true;
}
});
});
},
handleClickHome() {
uni.switchTab({
url: "/pages/tabbar/home/index",
});
},
},
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@@ -318,7 +340,7 @@ page {
background: $main-color; background: $main-color;
} }
.disabled { .disabled {
background: rgba($main-color, $alpha: 0.2); background: var(--theme-primary-20, rgba(255, 60, 42, 0.2));
} }
.home { .home {
color: $main-color; color: $main-color;

View File

@@ -1,168 +1,188 @@
<template> <template>
<div class="wrapper"> <div :style="themeStyle" class="wrapper">
<div class="pay-wrapper"> <div class="pay-wrapper">
<div class="pay-money"> <div class="pay-money">
¥{{ Number(payPrice) | unitPrice }} ¥{{ unitPrice(Number(payPrice)) }}
</div> </div>
<div class="pay-btns"> <div class="pay-btns">
<div v-show="!from" @click="checkOrder">查看{{ this.orderType == "RECHARGE" ? '余额' : '订单' }}</div> <div v-show="!from" @click="checkOrder">查看{{ orderType == "RECHARGE" ? '余额' : '订单' }}</div>
<div @click="navigateTo('/pages/tabbar/home/index', 'switch')">回到首页</div> <div @click="navigateTo('/pages/tabbar/home/index', 'switch')">回到首页</div>
</div> </div>
</div> </div>
<div class="pay-box"> <div class="pay-box">
<div class="pay-tag-box"> <div class="pay-tag-box">
<h2>订单支付成功!</h2> <h2>订单支付成功!</h2>
<div class="pay-item"> <div class="pay-item">
<div> <div>
支付方式: 支付方式:
</div> </div>
<div>{{ paymentMethod | paymentTypeFilter }}</div> <div>{{ paymentTypeFilter(paymentMethod) }}</div>
</div> </div>
</div> </div>
</div> </div>
<goodsRecommend /> <goodsRecommend />
</div> </div>
</template>
</template> <script setup lang="ts">
<script> import { ref, computed } from 'vue'
import goodsRecommend from "@/components/m-goods-recommend"; import { onLoad } from '@dcloudio/uni-app'
export default { import goodsRecommend from '@/components/m-goods-recommend'
data() { import { unitPrice } from '@/utils/filters.js'
return { import { useStore } from '@/store'
checked: false, import { getThemeStyle } from '@/utils/theme'
paymentMethod: "", import {
prefetchMpMessageTemplates,
from: "", subscribePayMessageThen,
payPrice: 0, } from '@/js_sdk/lili-pay/wx-pay.js'
goodsList: [],
activeColor: this.$mainColor, const store = useStore()
}; const themeStyle = computed(() => getThemeStyle(store.state.theme))
},
components: { const paymentMethod = ref('')
goodsRecommend, const from = ref('')
}, const payPrice = ref<number | string>(0)
filters: { const orderType = ref('')
paymentTypeFilter(val) { const orderPromotionType = ref('')
switch (val) {
case "WECHAT": onLoad((options) => {
return "微信"; paymentMethod.value = options.paymentMethod || ''
case "ALIPAY": from.value = options.from || ''
return "支付宝"; payPrice.value = options.payPrice || 0
case "WALLET": orderType.value = options.orderType || ''
return "余额支付"; orderPromotionType.value = options.orderPromotionType || ''
default: // #ifdef MP-WEIXIN
return ""; prefetchMpMessageTemplates()
} // #endif
}, })
},
onLoad(options) { function paymentTypeFilter(val: string) {
this.paymentMethod = options.paymentMethod || ""; switch (val) {
this.from = options.from || ""; case 'WECHAT':
this.payPrice = options.payPrice || 0; return '微信'
this.orderType = options.orderType; case 'ALIPAY':
return '支付宝'
}, case 'WALLET':
methods: { return '余额支付'
checkOrder() { default:
/** return ''
* 查看订单 }
* 1.充值跳转到明细里面 }
* 2.支付跳转到订单详情
*/ function checkOrder() {
if (this.orderType == "RECHARGE") { if (orderType.value == 'RECHARGE') {
uni.reLaunch({ uni.reLaunch({
url: `/pages/mine/deposit/operation`, url: '/pages/mine/deposit/operation',
}); })
} else { return
this.navigateTo("/pages/order/myOrder?status=0"); }
} const doGoOrder = () => {
}, uni.reLaunch({
url: '/pages/order/myOrder?status=0',
navigateTo(url, type) { })
if (type === "switch") { }
uni.switchTab({ // #ifdef MP-WEIXIN
url, subscribePayMessageThen(doGoOrder, {
}); orderPromotionType: orderPromotionType.value,
} else { })
uni.redirectTo({ // #endif
url, // #ifndef MP-WEIXIN
}); doGoOrder()
} // #endif
}, }
},
}; function navigateTo(url: string, type?: string) {
</script> const doNavigate = () => {
<style scoped lang="scss"> if (type === 'switch') {
.subscribe { uni.switchTab({ url })
justify-content: space-between; } else {
align-items: center; uni.redirectTo({ url })
margin: 0 auto 40rpx auto; }
padding: 0 20rpx 20rpx; }
width: 80%; if (orderType.value == 'RECHARGE') {
} doNavigate()
return
.pay-btns { }
display: flex; // #ifdef MP-WEIXIN
width: 50%; subscribePayMessageThen(doNavigate, {
justify-content: space-between; orderPromotionType: orderPromotionType.value,
margin: 0 auto; })
color: #fff; // #endif
// #ifndef MP-WEIXIN
>div { doNavigate()
padding: 6px 12px; // #endif
border: 1px solid #fff; }
border-radius: 100px; </script>
} <style scoped lang="scss">
} .subscribe {
justify-content: space-between;
.pay-money { align-items: center;
line-height: 1; margin: 0 auto 40rpx auto;
font-size: 50rpx; padding: 0 20rpx 20rpx;
color: #fff; width: 80%;
margin-bottom: 100rpx; }
}
.pay-btns {
.pay-item { display: flex;
font-weight: bold; width: 50%;
margin: 32rpx 0; justify-content: space-between;
display: flex; margin: 0 auto;
justify-content: space-between; color: #fff;
font-size: 24rpx;
color: rgba($color: $main-color, $alpha: 0.8); >div {
} padding: 6px 12px;
border: 1px solid #fff;
.pay-box { border-radius: 100px;
overflow: hidden; }
} }
.pay-tag-box { .pay-money {
width: 80%; line-height: 1;
margin: 80rpx auto 40rpx auto; font-size: 50rpx;
padding: 20rpx; color: #fff;
border-radius: 20rpx; margin-bottom: 100rpx;
background: rgba($color: $main-color, $alpha: 0.2); }
>h2 { .pay-item {
margin-top: 20rpx; font-weight: bold;
font-size: 40rpx; margin: 32rpx 0;
color: $main-color; display: flex;
} justify-content: space-between;
} font-size: 24rpx;
color: var(--theme-primary-70, rgba(255, 60, 42, 0.7));
.pay-wrapper { }
background-image: linear-gradient(90deg, #fa123b, #ff6b35, #ff9f28, #ffcc03);
height: 480rpx; .pay-box {
position: relative; overflow: hidden;
display: flex; }
align-items: center;
justify-content: center; .pay-tag-box {
flex-direction: column; width: 80%;
} margin: 80rpx auto 40rpx auto;
padding: 20rpx;
.pay-box { border-radius: 20rpx;
transform: translateY(-100rpx); background: var(--theme-primary-20, rgba(255, 60, 42, 0.2));
width: 100%;
background: #fff; >h2 {
border-top-right-radius: 100rpx; margin-top: 20rpx;
} font-size: 40rpx;
</style> color: $main-color;
}
}
.pay-wrapper {
background-image: linear-gradient(90deg, $main-color, $light-color, $aider-light-color);
height: 480rpx;
position: relative;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.pay-box {
transform: translateY(-100rpx);
width: 100%;
background: #fff;
border-top-right-radius: 100rpx;
}
</style>

View File

@@ -2,21 +2,16 @@
<default-page v-if="type" :type="type" title="您的设备已断网" :isBtn="false" /> <default-page v-if="type" :type="type" title="您的设备已断网" :isBtn="false" />
</template> </template>
<script> <script setup lang="ts">
import defaultPage from '@/components/default-page/default-page.vue'; import { ref } from 'vue'
export default { import { onLoad } from '@dcloudio/uni-app'
components: { import defaultPage from '@/components/default-page/default-page.vue'
defaultPage
}, const type = ref<string>()
data() {
return { onLoad(() => {
type: undefined type.value = 'msg'
} })
},
onLoad(options) {
}
}
</script> </script>
<style> <style>

View File

@@ -1,356 +1,433 @@
<template> <template>
<view class="add-address"> <view :style="themeStyle" class="address-page add-address">
<div class="uForm"> <!-- #ifdef MP-WEIXIN -->
<u-form :border-bottom="false" :model="form" ref="uForm" :error-type="['toast']" :rule="rules"> <view class="wechat-import">
<!-- #ifndef H5 --> <button class="wechat-import-button" :disabled="importing" @click="importWechatAddress">
<view class="selectAddress" @click="clickUniMap"> <view class="wechat-icon"><u-icon name="weixin-fill" color="#07b75b" size="26" /></view>
选择收货地址 <view class="wechat-copy">
</view> <text class="wechat-title">{{ importing ? '正在导入微信地址…' : '导入微信收货地址' }}</text>
<!-- #endif --> </view>
<u-form-item class="border" label="收货人" label-width="130" prop="name"> <u-icon name="arrow-right" color="#77a38a" size="14" />
<u-input v-model="form.name" clearable placeholder="请输入收货人姓名" /> </button>
</u-form-item> </view>
<!-- #endif -->
<u-form-item label="手机号码" label-width="130" prop="mobile"> <view v-if="importNotice" class="import-notice">{{ importNotice }}</view>
<u-input v-model="form.mobile" type="number" maxlength="11" placeholder="请输入收货人手机号码" /> <view class="section-heading">收货信息</view>
</u-form-item> <view class="address-card form-card">
<u-form-item label="所在区域" label-width="130" prop="___path"> <up-form
<div @click="showPicker" > :model="form"
{{ form.___path || '请选择所在地区' }} ref="uForm"
</div> error-type="toast"
</u-form-item> :rules="rules"
<u-form-item class="detailAddress" label="详细地址" label-width="130" prop="detail"> label-position="left"
<u-input type="textarea" v-model="form.detail" maxlength="100" height="150" placeholder="街道楼牌号等" /> label-width="180rpx"
</u-form-item> :label-style="{ color: '#5b606b', fontSize: '28rpx' }"
<u-form-item label="地址别名" label-width="130"> >
<u-input v-model="form.alias" placeholder="请输入地址别名" /> <up-form-item label="收货人" label-width="160rpx" prop="name" :border-bottom="true" :custom-style="fieldStyle">
</u-form-item> <u-input
<u-checkbox-group shape="circle" size="30"> v-model="form.name"
<u-checkbox :active-color="lightColor" v-model="form.isDefault">设为默认地址</u-checkbox> border="none"
</u-checkbox-group> input-align="left"
clearable
<div class="saveBtn" @click="save">保存</div> placeholder="姓名"
</u-form> />
</up-form-item>
<m-city :provinceData="list" headTitle="区域选择" ref="cityPicker" @funcValue="getpickerParentValue" pickerSize="4">
</m-city> <up-form-item label="手机号码" label-width="160rpx" prop="mobile" :border-bottom="true" :custom-style="fieldStyle">
<u-input
<uniMap v-if="mapFlag" @close="closeMap" @callback="callBackAddress" /> v-model="form.mobile"
</div> type="number"
</view> maxlength="11"
</template> border="none"
<script> input-align="left"
import { addAddress, editAddress, getAddressDetail } from "@/api/address.js"; placeholder="收货人的手机号码"
import city from "@/components/m-city/m-city.vue"; />
import uniMap from "@/components/uniMap"; </up-form-item>
import permision from "@/js_sdk/wa-permission/permission.js";
export default { <up-form-item label="所在地区" label-width="160rpx" prop="___path" :border-bottom="true" :custom-style="fieldStyle" @click="showPicker">
components: { <view class="form-value" :class="{ 'is-placeholder': !form.___path }">
"m-city": city, {{ form.___path || '请选择所在地区' }}
uniMap, </view>
}, <template #right>
onShow() { <u-icon name="arrow-right" color="#ccc" size="16"></u-icon>
// 判断当前系统权限定位是否开启 </template>
}, </up-form-item>
methods: {
// 关闭地图 <up-form-item label="详细地址" label-width="160rpx" prop="detail" :border-bottom="true" :custom-style="{ ...fieldStyle, alignItems: 'flex-start' }">
closeMap() { <textarea
this.mapFlag = false; class="address-textarea"
}, v-model="form.detail"
// 打开地图并访问权限 maxlength="100"
clickUniMap() { :auto-height="true"
// #ifdef APP-PLUS placeholder="街道、门牌号等详细信息"
if (plus.os.name == "iOS") { placeholder-style="color: #b1b5bd; font-size: 28rpx;"
// ios系统 />
permision.judgeIosPermission("location") </up-form-item>
? (this.mapFlag = true)
: this.refuseMap(); <up-form-item label="地址标签" label-width="160rpx" :border-bottom="false" :custom-style="fieldStyle">
} else { <u-input
// 安卓 v-model="form.alias"
this.requestAndroidPermission( border="none"
"android.permission.ACCESS_FINE_LOCATION" input-align="left"
); placeholder="如:家、公司(选填)"
} />
// #endif </up-form-item>
// #ifndef APP-PLUS </up-form>
this.mapFlag = true; </view>
// #endif <view class="address-card default-row">
}, <view>
<text class="default-title">设为默认地址</text>
// 如果拒绝权限 提示区设置 <text class="default-hint">下单时优先使用这个地址</text>
refuseMap() { </view>
uni.showModal({ <switch :checked="!!form.isDefault" :color="mainColor" @change="form.isDefault = $event.detail.value" />
title: "温馨提示", </view>
content: "您已拒绝定位,请开启", <view class="address-footer">
confirmText: "去设置", <button class="address-primary-button" :disabled="importing" @click="save">保存收货地址</button>
success(res) { </view>
if (res.confirm) {
//打开授权设置 <m-city
// #ifndef MP-WEIXIN :provinceData="list"
uni.getSystemInfo({ headTitle="区域选择"
success(res) { ref="cityPicker"
if (res.platform == "ios") { @funcValue="getpickerParentValue"
//IOS pickerSize="4"
plus.runtime.openURL("app-settings://"); ></m-city>
} else if (res.platform == "android") {
//安卓 <uniMap v-if="mapFlag" @close="closeMap" @callback="callBackAddress" />
let main = plus.android.runtimeMainActivity(); </view>
let Intent = plus.android.importClass( </template>
"android.content.Intent" <script setup lang="ts">
); import { ref, reactive, computed, getCurrentInstance } from 'vue'
let mIntent = new Intent("android.settings.ACTION_SETTINGS"); import { onLoad, onShow, onReady } from '@dcloudio/uni-app'
main.startActivity(mIntent); import { useStore } from '@/store'
} import { addAddress as addAddressApi, editAddress, getAddressDetail } from '@/api/address.js'
}, import MCity from '@/components/m-city/m-city.vue'
}); import uniMap from '@/components/uniMap'
// #endif import permision from '@/js_sdk/wa-permission/permission.js'
} import { getThemeStyle } from '@/utils/theme'
}, import { getRegionsById } from '@/api/common.js'
}); import { resolveWechatRegion, getWechatAddressErrorType } from '@/utils/wechatAddress.js'
},
const store = useStore()
// 获取安卓是否拥有地址权限 const themeStyle = computed(() => getThemeStyle(store.state.theme))
async requestAndroidPermission(permisionID) { const { proxy } = getCurrentInstance()!
var result = await permision.requestAndroidPermission(permisionID);
const mainColor = computed(() => store.getters.mainColor)
if (result == 1) { const fieldStyle = { padding: '28rpx 0', minHeight: '100rpx', boxSizing: 'border-box', alignItems: 'center' }
this.mapFlag = true; const mapFlag = ref(false)
} else { const routerVal = ref<Record<string, string>>({})
this.refuseMap(); const uForm = ref<any>(null)
} const cityPicker = ref<any>(null)
}, const importing = ref(false)
const importNotice = ref('')
// 选择地址后数据的回调
callBackAddress(val) { // #ifdef MP-WEIXIN
console.log(val) function importWechatAddress() {
uni.showLoading({ if (importing.value) return
title: "加载中", importing.value = true
}); uni.chooseAddress({
success: async (address: any) => {
if (val.regeocode && val) { uni.showLoading({ title: '正在匹配地区', mask: true })
let address = val.regeocode; // Clear the old region and coordinates, including when editing an existing address.
this.form.detail = address.formatted_address; //地址详情 Object.assign(form, {
this.form.___path = val.data.result.name; name: address.userName || '',
this.form.consigneeAddressIdPath = val.data.result.id; // 地址id分割 mobile: address.telNumber || '',
this.form.consigneeAddressPath = val.data.result.name; //地址名称, ','分割 detail: address.detailInfoNew || address.detailInfo || '',
this.form.lat = val.latitude; //纬度 consigneeAddressIdPath: [],
this.form.lon = val.longitude; //经度 consigneeAddressPath: [],
uni.hideLoading(); ___path: '',
} lat: '',
lon: '',
this.mapFlag = !this.mapFlag; //关闭地图 })
}, importNotice.value = ''
try {
// 保存当前 地址 const regions = await resolveWechatRegion(address, getRegionsById)
save() { if (regions) {
this.$refs.uForm.validate((valid) => { if (regions.length < 4 && address.streetName) {
if (valid) { form.detail = address.detailInfo || [address.streetName, address.detailInfoNew].filter(Boolean).join('')
let pages = getCurrentPages(); //获取页面栈 }
let beforePage = pages[pages.length - 2]; //上个页面 const names = regions.map((item: any) => item.name || item.localName)
form.consigneeAddressIdPath = regions.map((item: any) => item.id)
// 如果没有id则为新增地址 form.consigneeAddressPath = names
if (!this.form.id) { form.___path = names.join('')
// 删除没有的数据 const center = String(regions[regions.length - 1].center || '').split(',')
delete this.form.___path; if (center.length === 2) [form.lon, form.lat] = center
addAddress(this.form).then((res) => { importNotice.value = '已导入微信地址,请核对后保存'
if (res.data.success) { } else {
uni.navigateBack(); showImportedRegionHint(address)
} }
}); } catch {
} else { showImportedRegionHint(address)
// 修改地址 } finally {
delete this.form.___path; importing.value = false
delete this.form.updateBy; uni.hideLoading()
delete this.form.updateTime; uForm.value?.clearValidate()
editAddress(this.form).then((res) => { }
if (res.data.success) { },
uni.navigateBack(); fail: (error: any) => {
} importing.value = false
}); const type = getWechatAddressErrorType(error)
} if (type === 'cancel') return
} let platform = ''
}); try { platform = (globalThis as any).wx?.getDeviceInfo?.()?.platform || '' } catch {}
}, // Log diagnostics only, never the selected address or other personal information.
console.warn('[微信地址导入失败]', {
// 三级地址联动回调 errMsg: String(error?.errMsg || error?.message || ''),
getpickerParentValue(e) { errCode: error?.errCode ?? error?.errno ?? '',
// 将需要绑定的地址设置为空,并赋值 type,
this.form.consigneeAddressIdPath = []; platform,
this.form.consigneeAddressPath = []; })
let name = ""; if (type === 'auth') {
uni.showModal({
e.forEach((item, index) => { title: '开启收货地址授权',
if (item.id) { content: '需要允许使用微信收货地址才能导入,也可以继续手动填写。',
// 遍历数据 confirmText: '去设置',
this.form.consigneeAddressIdPath.push(item.id); success: (result) => { if (result.confirm) uni.openSetting({}) },
this.form.consigneeAddressPath.push(item.localName); })
name += item.localName; return
this.form.___path = name; }
} if (type === 'privacy') {
if (index == e.length - 1) { console.warn('[微信地址导入] 请核对小程序后台的用户隐私保护指引是否声明收货地址,以及用户隐私授权状态。')
//如果是最后一个 }
let _town = item.children.filter((_child) => { if (type === 'configuration') {
return _child.id == item.id; console.warn('[微信地址导入] manifest.json 的 mp-weixin.requiredPrivateInfos 必须包含 chooseAddress,修改后需重新编译小程序。')
}); }
const content = type === 'configuration'
this.form.lat = _town[0].center.split(",")[1]; ? '收货地址导入暂未配置完成,请稍后再试,也可以手动填写。'
this.form.lon = _town[0].center.split(",")[0]; : type === 'privacy'
} ? '暂时无法获取微信收货地址,请稍后重试,也可以手动填写。'
}); : platform === 'devtools'
}, ? '当前开发工具中未能打开微信地址簿,请使用手机微信扫码预览测试,也可以手动填写。'
: type === 'unsupported'
// 显示三级地址联动 ? '当前微信环境不支持导入收货地址,请更新微信后重试,也可以手动填写。'
showPicker() { : '暂时无法打开微信地址簿,请稍后重试,也可以手动填写。'
this.$refs.cityPicker.show(); uni.showModal({ title: '微信地址未导入', content, showCancel: false })
}, },
}, })
mounted() {}, }
data() {
return { function showImportedRegionHint(address: any) {
lightColor: this.$lightColor, //高亮颜色 const region = [address.provinceName, address.cityName, address.countyName, address.streetName].filter(Boolean).join('')
mapFlag: false, // 地图选择开 // Preserve the street if the user has to select it manually and the new detail field omits it.
routerVal: "", form.detail = address.detailInfo || [address.streetName, address.detailInfoNew].filter(Boolean).join('')
form: { importNotice.value = `已导入姓名、电话和详细地址,请补选所在地区${region ? '(微信地址:' + region + ')' : ''}`
detail: "", //地址详情 }
name: "", //收货人姓名 // #endif
mobile: "", //手机号码
consigneeAddressIdPath: [], //地址id const form = reactive<Record<string, any>>({
consigneeAddressPath: [], //地址名字 detail: '',
___path: "", //所在区域 name: '',
isDefault: false, //是否默认地址 mobile: '',
}, consigneeAddressIdPath: [],
// 表单提交校验规则 consigneeAddressPath: [],
rules: { ___path: '',
name: [ isDefault: false,
{ })
required: true,
message: "收货人姓名不能为空", const list = ref([
trigger: ["blur", "change"], {
}, id: '',
], localName: '请选择',
mobile: [ children: [],
{ },
required: true, ])
message: "手机号码不能为空",
trigger: ["blur", "change"], const rules = {
}, name: [
{ {
validator: (rule, value, callback) => { required: true,
return this.$u.test.mobile(value); message: '收货人姓名不能为空',
}, trigger: ['blur', 'change'],
message: "手机号码不正确", },
trigger: ["change", "blur"], ],
}, mobile: [
], {
___path: [ required: true,
{ message: '手机号码不能为空',
required: true, trigger: ['blur', 'change'],
message: "请选择所在区域", },
trigger: ["change"], {
}, validator: (_rule: unknown, value: string) => proxy.$u.test.mobile(value),
], message: '手机号码不正确',
detail: [ trigger: ['change', 'blur'],
{ },
required: true, ],
message: "请填写详细地址", ___path: [
trigger: ["blur", "change"], {
}, required: true,
], message: '请选择所在区域',
}, trigger: ['change'],
list: [ },
{ ],
id: "", detail: [
localName: "请选择", {
children: [], required: true,
}, message: '请填写详细地址',
], trigger: ['blur', 'change'],
}; },
}, ],
onLoad(option) { }
uni.showLoading({
title: "加载中", onShow(() => {})
});
this.routerVal = option; onLoad(async (option) => {
// 如果当前是编辑地址,则需要查询出地址详情信息 routerVal.value = option || {}
if (option.id) { uni.setNavigationBarTitle({ title: option?.id ? '编辑收货地址' : '新增收货地址' })
getAddressDetail(option.id).then((res) => { if (!option?.id) return
const params = res.data.result; uni.showLoading({ title: '加载中' })
params.___path = params.consigneeAddressPath; try {
this.$set(this, "form", params); const res = await getAddressDetail(option.id)
const params = res.data?.result
if (this.$store.state.isShowToast){ uni.hideLoading() }; if (!res.data?.success || !params) {
}); uni.showToast({ title: '地址加载失败,请重试', icon: 'none' })
} return
uni.hideLoading(); }
}, Object.assign(form, params, { ___path: params.consigneeAddressPath || '' })
// 初始化rules必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕 } catch {
onReady() { uni.showToast({ title: '地址加载失败,请重试', icon: 'none' })
this.$refs.uForm.setRules(this.rules); } finally {
}, uni.hideLoading()
}; }
</script> })
<style scoped lang="scss">
.detailAddress { onReady(() => {
/deep/ .u-form-item--left { uForm.value?.setRules(rules)
display: flex; })
align-items: flex-start;
} function closeMap() {
} mapFlag.value = false
.saveBtn, }
.selectAddress {
height: 70rpx; function refuseMap() {
uni.showModal({
line-height: 70rpx; title: '温馨提示',
text-align: center; content: '您已拒绝定位,请开启',
font-size: 30rpx; confirmText: '去设置',
background: $aider-light-color; success(res) {
color: #fff; if (res.confirm) {
width: 70%; // #ifndef MP-WEIXIN
margin: 40rpx auto 0 auto; uni.getSystemInfo({
border-radius: 20rpx; success(sysRes) {
} if (sysRes.platform == 'ios') {
.selectAddress { plus.runtime.openURL('app-settings://')
margin-top: 40rpx; } else if (sysRes.platform == 'android') {
background: #fff; const main = plus.android.runtimeMainActivity()
const Intent = plus.android.importClass('android.content.Intent')
color: $aider-light-color; const mIntent = new Intent('android.settings.ACTION_SETTINGS')
border: 2rpx solid $aider-light-color; main.startActivity(mIntent)
} }
},
.uForm { })
width: 94%; // #endif
overflow: hidden; }
left: 3%; },
position: relative; })
top: 2%; }
background: #fff;
border-radius: 20rpx; async function requestAndroidPermission(permisionID: string) {
padding: 0 0 40rpx 0; const result = await permision.requestAndroidPermission(permisionID)
} if (result == 1) {
.add-address { mapFlag.value = true
width: 100%; } else {
padding-top: 3%; refuseMap()
}
/deep/ .u-form-item { }
background-color: #fff;
padding: 24rpx 30rpx; function callBackAddress(val: any) {
} uni.showLoading({ title: '加载中' })
.u-btn { if (val.regeocode && val) {
margin: 30rpx 30rpx 0 30rpx; const address = val.regeocode
background-color: $main-color; form.detail = address.formatted_address
} form.___path = val.data.result.name
form.consigneeAddressIdPath = val.data.result.id
/deep/.u-checkbox { form.consigneeAddressPath = val.data.result.name
margin: 30rpx 30rpx 0 30rpx; form.lat = val.latitude
form.lon = val.longitude
.u-label-class.u-checkbox__label { uni.hideLoading()
color: $font-color-light; }
font-size: $font-sm; mapFlag.value = !mapFlag.value
} }
}
} function save() {
/deep/ .u-checkbox__label { if (importing.value) return
font-size: 28rpx; uForm.value?.validate().then(() => {
} const params = { ...form }
</style> delete params.___path
if (Array.isArray(params.consigneeAddressIdPath)) {
params.consigneeAddressIdPath = params.consigneeAddressIdPath.join(',')
}
if (Array.isArray(params.consigneeAddressPath)) {
params.consigneeAddressPath = params.consigneeAddressPath.join(',')
}
if (!params.id) {
addAddressApi(params).then((res) => {
if (res.data.success) {
uni.navigateBack()
} else {
uni.showToast({ title: res.data.message || '保存失败', icon: 'none' })
}
})
} else {
delete params.updateBy
delete params.updateTime
editAddress(params).then((res) => {
if (res.data.success) {
uni.navigateBack()
} else {
uni.showToast({ title: res.data.message || '保存失败', icon: 'none' })
}
})
}
}).catch(() => {})
}
function getpickerParentValue(e: any[]) {
form.consigneeAddressIdPath = []
form.consigneeAddressPath = []
let name = ''
e.forEach((item, index) => {
if (item.id) {
form.consigneeAddressIdPath.push(item.id)
form.consigneeAddressPath.push(item.localName)
name += item.localName
form.___path = name
}
if (index == e.length - 1) {
const center = String(item.center || item.children?.find((_child: any) => _child.id == item.id)?.center || '').split(',')
form.lat = center.length === 2 ? center[1] : ''
form.lon = center.length === 2 ? center[0] : ''
}
})
importNotice.value = ''
}
function showPicker() {
cityPicker.value?.show()
}
</script>
<style scoped lang="scss">
@import "./address-page.scss";
.wechat-import { margin-bottom: 28rpx; }
.wechat-import-button {
display: flex; align-items: center; padding: 28rpx; margin: 0; width: 100%; text-align: left;
background: #eef9f2; border-radius: 24rpx; line-height: 1.5;
&::after { border: 1rpx solid #dcefe3; border-radius: 24rpx; }
&[disabled] { background: #eef9f2; opacity: .65; }
}
.wechat-icon { width: 76rpx; height: 76rpx; border-radius: 20rpx; background: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-right: 22rpx; }
.wechat-copy { flex: 1; min-width: 0; }
.wechat-title { display: block; color: #253e30; font-size: 30rpx; font-weight: 600; }
.import-notice { margin-bottom: 24rpx; padding: 20rpx 24rpx; border-radius: 16rpx; background: #fff5e5; color: #a47a3b; font-size: 24rpx; line-height: 1.6; }
.section-heading { padding: 0 8rpx 20rpx; font-size: 26rpx; color: #858b96; }
.form-card { padding: 0 28rpx; }
.form-value { width: 100%; line-height: 1.6; font-size: 28rpx; color: #303744; overflow-wrap: anywhere; }
.is-placeholder { color: #b1b5bd; }
.address-textarea { width: 100%; min-height: 88rpx; font-size: 28rpx; color: #303744; line-height: 1.6; padding: 0; }
.default-row { display: flex; justify-content: space-between; align-items: center; margin-top: 24rpx; padding: 28rpx; }
.default-title { display: block; font-size: 28rpx; color: #353b47; }
.default-hint { display: block; font-size: 23rpx; color: #a0a5af; margin-top: 8rpx; }
.default-row switch { transform: scale(.8); transform-origin: right center; }
</style>

View File

@@ -0,0 +1,43 @@
.address-page {
min-height: 100vh;
box-sizing: border-box;
background: #f6f7f9;
padding: 28rpx 24rpx calc(180rpx + env(safe-area-inset-bottom));
}
.address-card {
background: #fff;
border-radius: 24rpx;
overflow: hidden;
}
.address-footer {
position: fixed;
left: 0;
right: 0;
bottom: 0;
z-index: 90;
box-sizing: border-box;
padding: 20rpx 32rpx calc(20rpx + env(safe-area-inset-bottom));
background: #fff;
border-top: 1rpx solid #f0f1f4;
}
.address-primary-button {
display: flex;
align-items: center;
justify-content: center;
gap: 14rpx;
width: 100%;
height: 88rpx;
margin: 0;
padding: 0 24rpx;
border-radius: 44rpx;
background: var(--theme-primary);
color: #fff;
font-size: 30rpx;
font-weight: 500;
line-height: 1;
&::after { border: none; }
&[disabled] { opacity: .5; background: var(--theme-primary); color: #fff; }
}

View File

@@ -20,6 +20,9 @@
padding: 2rpx 20rpx; padding: 2rpx 20rpx;
} }
.list { .list {
padding-bottom: calc(140rpx + constant(safe-area-inset-bottom));
padding-bottom: calc(140rpx + env(safe-area-inset-bottom));
.item:hover { .item:hover {
background: #ededed; background: #ededed;
} }
@@ -115,18 +118,33 @@
} }
} }
.btn-bar {
position: fixed;
left: 0;
right: 0;
bottom: 0;
z-index: 99;
padding: 20rpx 30rpx calc(20rpx + constant(safe-area-inset-bottom));
padding: 20rpx 30rpx calc(20rpx + env(safe-area-inset-bottom));
background: $page-color-base;
box-sizing: border-box;
}
.btn { .btn {
background: $light-color; background: $light-color;
position: fixed; width: 100%;
width: 690rpx;
bottom: 60rpx;
height: 80rpx; height: 80rpx;
left: 30rpx;
font-size: 30rpx; font-size: 30rpx;
line-height: 80rpx; color: #fff;
border-radius: 40rpx;
.u-icon { display: flex;
margin-right: 10rpx; align-items: center;
justify-content: center;
overflow: hidden;
.btn-text {
margin-left: 12rpx;
line-height: 1;
} }
} }
} }

View File

@@ -1,169 +1,135 @@
<template> <template>
<view class="address"> <view class="address">
<u-empty class="empty" v-if="addressList.length == 0" text="暂无收货地址" mode="address"></u-empty> <u-empty class="empty" v-if="addressList.length == 0" text="暂无收货地址" mode="address"></u-empty>
<view class="list" v-else> <view class="list" v-else>
<view class="item c-content" v-for="(item, index) in addressList" :key="index"> <view class="item c-content" v-for="(item, index) in addressList" :key="index">
<view class="basic" @click="selectAddressData(item)"> <view class="basic" @click="selectAddressData(item)">
<text>{{ item.name }}</text> <text>{{ item.name }}</text>
<text>{{ item.mobile }}</text> <text>{{ item.mobile }}</text>
<text class="default" v-show="item.isDefault">默认</text> <text class="default" v-show="item.isDefault">默认</text>
<view> <view>
<div class="region"> <div class="region">
<span v-if="item.consigneeAddressPath[0]">{{item.consigneeAddressPath[0]}}</span> <span v-if="item.consigneeAddressPath[0]">{{item.consigneeAddressPath[0]}}</span>
<span v-if="item.consigneeAddressPath[1]">{{item.consigneeAddressPath[1]}}</span> <span v-if="item.consigneeAddressPath[1]">{{item.consigneeAddressPath[1]}}</span>
<span v-if="item.consigneeAddressPath[2]">{{item.consigneeAddressPath[2]}}</span> <span v-if="item.consigneeAddressPath[2]">{{item.consigneeAddressPath[2]}}</span>
<span v-if="item.consigneeAddressPath[3]">{{item.consigneeAddressPath[3]}}</span> <span v-if="item.consigneeAddressPath[3]">{{item.consigneeAddressPath[3]}}</span>
<span>{{ item.detail }}</span> <span>{{ item.detail }}</span>
</div> </div>
</view> </view>
</view> </view>
<view class="edit"> <view class="edit">
<view class="relative" @click="setDefault(item)"> <view class="relative" @click="setDefault(item)">
<view v-if="item.isDefault" class="alifont icon-xuanzhong"></view> <view v-if="item.isDefault" class="alifont icon-xuanzhong"></view>
<text v-else class="unchecked"></text> <text v-else class="unchecked"></text>
<text>{{ item.isDefault ? "默认地址" : "设为默认" }}</text> <text>{{ item.isDefault ? "默认地址" : "设为默认" }}</text>
</view> </view>
<view class="relative"> <view class="relative">
<view class="alifont icon-bianji-copy"></view> <view class="alifont icon-bianji-copy"></view>
<text class="mr-40" @click="addAddress(item.id)">编辑</text> <text class="mr-40" @click="addAddress(item.id)">编辑</text>
<view class="alifont icon-lajitong"></view> <view class="alifont icon-lajitong" @click.stop="removeAddress(item.id)"></view>
<text @click="removeAddress(item.id)">删除</text> <text @click.stop="removeAddress(item.id)">删除</text>
</view> </view>
</view> </view>
</view> </view>
<view style="height: 100px"></view> <view style="height: 100px"></view>
</view> </view>
<button type="default" class="btn" @click="addAddress('')"> <view class="btn" @click="addAddress('')">
<u-icon name="plus-circle"></u-icon> <u-icon name="plus-circle" color="#ffffff" size="18"></u-icon>
添加新收货人 <text class="btn-text">添加新收货人</text>
</button> </view>
<u-action-sheet :list="removeList" :tips="tips" v-model="showAction" @click="deleteAddressMessage"></u-action-sheet> </view>
</view> </template>
</template>
<script setup lang="ts">
<script> import { ref } from 'vue'
import * as API_Trade from "@/api/trade"; import { onLoad, onShow, onPullDownRefresh } from '@dcloudio/uni-app'
import * as API_Address from "@/api/address.js"; import { useStore } from '@/store'
export default { import * as API_Trade from '@/api/trade'
data() { import * as API_Address from '@/api/address.js'
return {
addressList: [], //地址列表 const store = useStore()
showAction: false, //是否显示下栏框
removeList: [ const addressList = ref<any[]>([])
{ const routerVal = ref<Record<string, string>>({})
text: "确定", const params = { pageNumber: 1, pageSize: 1000 }
},
], onPullDownRefresh(() => {
tips: { addressList.value = []
text: "确定要删除该收货人信息吗?", getAddressList()
}, })
removeId: "", //删除的地址id
routerVal: "", onLoad((val) => {
params: { routerVal.value = val || {}
pageNumber: 1, })
pageSize: 1000,
}, onShow(() => {
}; addressList.value = []
}, getAddressList()
onPullDownRefresh() { })
//下拉刷新
this.addressList = []; function hideLoadingIfNeeded() {
this.getAddressList(); if (store.state.isShowToast) uni.hideLoading()
}, }
onLoad: function (val) {
this.routerVal = val; async function selectAddressData(val: any) {
}, await API_Trade.setAddressId(val.id, routerVal.value.way)
onShow() { uni.navigateBack({ delta: 1 })
this.addressList = []; }
this.getAddressList();
}, function getAddressList() {
onHide() {}, uni.showLoading()
methods: { API_Address.getAddressList(params.pageNumber, params.pageSize).then((res) => {
async selectAddressData(val) { res.data.result.records.forEach((item: any) => {
await API_Trade.setAddressId(val.id, this.routerVal.way); item.consigneeAddressPath = item.consigneeAddressPath.split(',')
})
uni.navigateBack({ addressList.value = res.data.result.records
delta: 1, hideLoadingIfNeeded()
}); })
}, }
//获取地址列表
getAddressList() { function removeAddress(id: string) {
uni.showLoading(); uni.showModal({
title: '提示',
API_Address.getAddressList( content: '确定要删除该收货人信息吗?',
this.params.pageNumber, success: (res) => {
this.params.pageSize if (!res.confirm) return
).then((res) => { API_Address.deleteAddress(id).then((result) => {
res.data.result.records.forEach((item) => { if (result.statusCode == 200) {
item.consigneeAddressPath = item.consigneeAddressPath.split(","); uni.showToast({ icon: 'none', title: '删除成功' })
}); getAddressList()
this.addressList = res.data.result.records; } else {
console.log(this.addressList); uni.showToast({ icon: 'none', title: result.data.message, duration: 2000 })
}
if (this.$store.state.isShowToast){ uni.hideLoading() }; })
}); },
}, })
//删除地址 }
removeAddress(id) {
this.removeId = id; function addAddress(id: string) {
this.showAction = true; if (id) {
}, uni.navigateTo({
deleteAddressMessage() { url: `/pages/mine/address/add?id=${id}&way=${routerVal.value.way}&type=order`,
API_Address.deleteAddress(this.removeId).then((res) => { })
if (res.statusCode == 200) { } else {
uni.showToast({ uni.navigateTo({
icon: "none", url: `/pages/mine/address/add?way=${routerVal.value.way}&type=order`,
title: "删除成功", })
}); }
this.getAddressList(); }
} else {
uni.showToast({ function setDefault(item: any) {
icon: "none", delete item.updateBy
title: res.data.message, delete item.updateTime
duration: 2000, delete item.deleteFlag
}); if (!item.isDefault) item.isDefault = true
} API_Address.editAddress(item).then(() => {
}); uni.showToast({ title: '设置默认地址成功', icon: 'none' })
}, getAddressList()
//新建。编辑地址 })
addAddress(id) { }
if (id) { </script>
uni.navigateTo({
url: <style lang="scss" scoped>
"/pages/mine/address/add?id=" + @import "./address.scss";
id + </style>
"&way=" +
this.routerVal.way +
"&type=order",
});
} else {
uni.navigateTo({
url:
"/pages/mine/address/add?way=" + this.routerVal.way + "&type=order",
});
}
},
//设为默认地址
setDefault(item) {
delete item.updateBy;
delete item.updateTime;
delete item.deleteFlag;
item.isDefault ? "" : (item.isDefault = !item.isDefault);
API_Address.editAddress(item).then((res) => {
uni.showToast({
title: "设置默认地址成功",
icon: "none",
});
this.getAddressList();
});
},
},
};
</script>
<style lang="scss" scoped>
@import "./address.scss";
</style>

View File

@@ -1,160 +1,171 @@
<template> <template>
<view class="address"> <view class="address-page address-manage" :style="themeStyle">
<u-empty class="empty" v-if="this.addressList.length === 0" text="暂无收货地址" mode="address"></u-empty> <view v-if="!loading && addressList.length === 0" class="empty-state">
<view class="list" > <view class="empty-icon"><u-icon name="map" size="42" color="#c4c8d1" /></view>
<view class="item c-content" v-for="(item, index) in addressList" :key="index"> <text class="empty-title">还没有收货地址</text>
<view class="basic"> <text class="empty-description">添加常用地址,下次购物更方便</text>
<text>{{ item.name }}</text> </view>
<text>{{ item.mobile }}</text> <view v-if="addressList.length" class="list-heading">
<text class="default" v-show="item.isDefault">默认</text> <text>我的收货地址</text>
<view> <text class="address-count">共 {{ addressList.length }} 个</text>
<div class="region"> </view>
<span v-if="item.consigneeAddressPath[0]">{{item.consigneeAddressPath[0]}}</span> <view class="address-list">
<span v-if="item.consigneeAddressPath[1]">{{item.consigneeAddressPath[1]}}</span> <view class="address-card address-item" v-for="item in addressList" :key="item.id">
<span v-if="item.consigneeAddressPath[2]">{{item.consigneeAddressPath[2]}}</span> <view class="recipient-line">
<span v-if="item.consigneeAddressPath[3]">{{item.consigneeAddressPath[3]}}</span> <text class="recipient-name">{{ item.name }}</text>
<span>{{ item.detail }}</span> <text class="recipient-mobile">{{ item.mobile }}</text>
</div>
</view>
</view> </view>
<view class="edit"> <view class="address-region">{{ item.consigneeAddressPath.join(' ') }}</view>
<view class="relative" @click="setDefault(item)"> <text class="address-detail">{{ item.detail }}</text>
<view v-if="item.isDefault" class="alifont icon-xuanzhong"></view> <view class="address-tags" v-if="item.isDefault || item.alias">
<text v-else class="unchecked"></text> <text v-if="item.isDefault" class="address-tag default-tag">默认地址</text>
<text>{{ item.isDefault ? "默认地址" : "设为默认" }}</text> <text v-if="item.alias" class="address-tag">{{ item.alias }}</text>
</view>
<view class="card-actions">
<view class="default-action" @click="setDefault(item)">
<view class="default-check" :class="{ 'is-checked': item.isDefault }">
<u-icon v-if="item.isDefault" name="checkmark" size="11" color="#fff" />
</view>
<text>{{ item.isDefault ? '已设为默认' : '设为默认' }}</text>
</view> </view>
<view class="relative"> <view class="edit-actions">
<view class="alifont icon-bianji-copy"></view> <view class="text-action" @click="addAddress(item.id)">
<text class="mr-40" @click="addAddress(item.id)">编辑</text> <u-icon name="edit-pen" size="16" color="#6c7280" /><text>编辑</text>
<view class="alifont icon-lajitong"></view> </view>
<text @click="removeAddress(item.id)">删除</text> <view class="action-divider"></view>
<view class="text-action" @click="removeAddress(item.id)">
<u-icon name="trash" size="16" color="#9297a1" /><text>删除</text>
</view>
</view> </view>
</view> </view>
</view> </view>
<view style="height: 100px"></view>
</view> </view>
<view class="address-footer">
<button type="default" class="btn" @click="addAddress('')"> <button class="address-primary-button" @click="addAddress('')">
<u-icon name="plus-circle"></u-icon> <u-icon name="plus" color="#fff" size="17" /><text>新增收货地址</text>
添加新收货人 </button>
</button> </view>
<u-action-sheet :list="removeList" :tips="tips" v-model="showAction" @click="deleteAddressMessage"></u-action-sheet>
</view> </view>
</template> </template>
<script> <script setup lang="ts">
import * as API_Address from "@/api/address.js"; import { ref, computed } from 'vue'
export default { import { onLoad, onShow, onPullDownRefresh, onBackPress } from '@dcloudio/uni-app'
data() { import { useStore } from '@/store'
return { import { tipsToLogin } from '@/utils/filters.js'
addressList: [], //地址列表 import * as API_Address from '@/api/address.js'
showAction: false, //是否显示下栏框 import { getThemeStyle } from '@/utils/theme'
removeList: [ const store = useStore()
{ const themeStyle = computed(() => getThemeStyle(store.state.theme))
text: "确定", const loading = ref(true)
},
],
tips: {
text: "确定要删除该收货人信息吗?",
},
removeId: "", //删除的地址id
routerVal: "",
params: {
pageNumber: 1,
pageSize: 1000,
},
};
},
// 返回上一级
onBackPress(e) {
uni.switchTab({
url: "/pages/tabbar/user/my",
});
return true;
},
onLoad: function (val) {
this.routerVal = val;
},
onPullDownRefresh() {
//下拉刷新
this.addressList = [];
this.getAddressList();
},
/**
* 进入页面检测当前账户是否登录
*/
onShow() {
if (this.$options.filters.tipsToLogin()) {
this.getAddressList();
}
},
methods: {
//获取地址列表
getAddressList() {
uni.showLoading();
API_Address.getAddressList(
this.params.pageNumber,
this.params.pageSize
).then((res) => {
res.data.result.records.forEach((item) => {
item.consigneeAddressPath = item.consigneeAddressPath.split(",");
});
this.addressList = res.data.result.records;
if (this.$store.state.isShowToast){ uni.hideLoading() }; const addressList = ref<any[]>([])
}); const routerVal = ref<Record<string, string>>({})
}, const params = { pageNumber: 1, pageSize: 1000 }
//删除地址
removeAddress(id) { onBackPress(() => {
this.removeId = id; uni.switchTab({ url: '/pages/tabbar/user/my' })
this.showAction = true; return true
}, })
// 删除地址
deleteAddressMessage() { onLoad((val) => {
API_Address.deleteAddress(this.removeId).then((res) => { routerVal.value = val || {}
if (res.statusCode == 200) { })
uni.showToast({
icon: "none", onPullDownRefresh(() => {
title: "删除成功", getAddressList()
}); })
this.getAddressList();
onShow(() => {
if (tipsToLogin()) {
getAddressList()
}
})
async function getAddressList() {
loading.value = true
try {
const res = await API_Address.getAddressList(params.pageNumber, params.pageSize)
if (!res.data?.success || !Array.isArray(res.data.result?.records)) throw new Error('地址加载失败')
addressList.value = res.data.result.records.map((item: any) => ({
...item,
consigneeAddressPath: Array.isArray(item.consigneeAddressPath)
? item.consigneeAddressPath
: String(item.consigneeAddressPath || '').split(',').filter(Boolean),
}))
} catch {
uni.showToast({ title: '地址加载失败,请下拉重试', icon: 'none' })
} finally {
loading.value = false
uni.stopPullDownRefresh()
}
}
function removeAddress(id: string) {
uni.showModal({
title: '提示',
content: '确定要删除该收货人信息吗?',
success: (res) => {
if (!res.confirm) return
API_Address.deleteAddress(id).then((result) => {
if (result.data?.success) {
uni.showToast({ icon: 'none', title: '删除成功' })
getAddressList()
} else { } else {
uni.showToast({ uni.showToast({ icon: 'none', title: result.data.message, duration: 2000 })
icon: "none",
title: res.data.message,
duration: 2000,
});
} }
}); })
}, },
//新建。编辑地址 })
addAddress(id) { }
uni.navigateTo({
url: `/pages/mine/address/add${id ? "?id=" + id : ""}`,
});
},
//设为默认地址
setDefault(item) {
delete item.updateBy;
delete item.updateTime;
delete item.deleteFlag;
item.isDefault ? "" : (item.isDefault = !item.isDefault); function addAddress(id?: string) {
uni.navigateTo({
url: `/pages/mine/address/add${id ? '?id=' + id : ''}`,
})
}
API_Address.editAddress(item).then(() => { function setDefault(item: any) {
uni.showToast({ if (item.isDefault) return
title: "设置默认地址成功", const data = { ...item, isDefault: true, consigneeAddressPath: item.consigneeAddressPath.join(',') }
icon: "none", delete data.updateBy
}); delete data.updateTime
this.getAddressList(); delete data.deleteFlag
}); API_Address.editAddress(data).then((res) => {
}, if (res.data?.success) {
}, uni.showToast({ title: '已设为默认地址', icon: 'none' })
}; getAddressList()
} else {
uni.showToast({ title: res.data?.message || '设置失败,请重试', icon: 'none' })
}
}).catch(() => uni.showToast({ title: '设置失败,请重试', icon: 'none' }))
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import "./address.scss"; @import "./address-page.scss";
.list-heading { display: flex; justify-content: space-between; padding: 8rpx 8rpx 24rpx; font-size: 26rpx; color: #6c7280; }
.address-count { color: #a0a5af; font-size: 24rpx; }
.address-item { padding: 32rpx 32rpx 0; margin-bottom: 24rpx; }
.recipient-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: 20rpx; margin-bottom: 18rpx; }
.recipient-name { font-size: 34rpx; font-weight: 600; color: #222732; overflow-wrap: anywhere; }
.recipient-mobile { color: #636a77; font-size: 28rpx; }
.address-region { color: #9399a4; font-size: 25rpx; line-height: 1.7; }
.address-detail { display: block; color: #343b48; font-size: 29rpx; line-height: 1.7; overflow-wrap: anywhere; }
.address-tags { display: flex; flex-wrap: wrap; gap: 12rpx; padding-top: 20rpx; }
.address-tag { max-width: 100%; overflow-wrap: anywhere; padding: 4rpx 14rpx; background: #f3f4f6; border-radius: 8rpx; color: #7f8591; font-size: 22rpx; }
.default-tag { color: var(--theme-primary); background: var(--theme-primary-10); }
.card-actions { margin-top: 26rpx; border-top: 1rpx solid #f0f1f4; min-height: 92rpx; display: flex; justify-content: space-between; align-items: center; }
.default-action, .text-action, .edit-actions { display: flex; align-items: center; }
.default-action { gap: 12rpx; min-height: 80rpx; color: #858b96; font-size: 24rpx; }
.default-check { width: 30rpx; height: 30rpx; box-sizing: border-box; border: 2rpx solid #dce0e6; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.is-checked { background: var(--theme-primary); border-color: var(--theme-primary); }
.text-action { gap: 8rpx; min-height: 80rpx; color: #6c7280; font-size: 24rpx; padding: 0 8rpx; }
.action-divider { width: 1rpx; height: 22rpx; background: #e9ebef; margin: 0 16rpx; }
.empty-state { display: flex; flex-direction: column; align-items: center; padding: 160rpx 0 80rpx; }
.empty-icon { width: 148rpx; height: 148rpx; display: flex; align-items: center; justify-content: center; background: #eaecef; border-radius: 50%; margin-bottom: 36rpx; }
.empty-title { color: #454c59; font-size: 32rpx; font-weight: 500; }
.empty-description { color: #a0a5af; font-size: 26rpx; margin-top: 16rpx; }
</style> </style>

View File

@@ -16,71 +16,67 @@
</view> </view>
<view style="height: 100px"></view> <view style="height: 100px"></view>
</view> </view>
<u-action-sheet :list="removeList" :tips="tips" v-model="showAction" @click="deleteAddressMessage"></u-action-sheet> <u-action-sheet
:actions="removeList"
:description="tips.text"
cancel-text="取消"
v-model:show="showAction"
@select="deleteAddressMessage"
></u-action-sheet>
</view> </view>
</template> </template>
<script> <script setup lang="ts">
import * as API_Trade from "@/api/trade"; import { ref } from 'vue'
import * as API_Store from "@/api/store.js"; import { onLoad, onShow, onPullDownRefresh } from '@dcloudio/uni-app'
export default { import { useStore } from '@/store'
data() { import * as API_Trade from '@/api/trade'
return { import * as API_Store from '@/api/store.js'
storeAddressList: [], //地址列表
showAction: false, //是否显示下栏框
removeList: [
{
text: "确定",
},
],
tips: {
text: "确定要删除该收货人信息吗?",
},
removeId: "", //删除的地址id
routerVal: "",
params: {
pageNumber: 1,
pageSize: 1000,
},
};
},
onPullDownRefresh() {
//下拉刷新
this.storeAddressList = [];
this.getAddressList();
},
onLoad: function (val) {
this.routerVal = val;
},
onShow() {
this.storeAddressList = [];
this.getAddressList();
},
onHide() {},
methods: {
async selectAddressData(val) {
await API_Trade.setStoreAddressId(val.id, this.routerVal.way);
uni.navigateBack({ const store = useStore()
delta: 1,
});
},
//获取地址列表
getAddressList() {
uni.showLoading();
API_Store.getStoreAddress( const storeAddressList = ref<any[]>([])
this.routerVal.storeId, const showAction = ref(false)
this.params const removeList = [{ name: '确定' }]
).then((res) => { const tips = { text: '确定要删除该收货人信息吗?' }
this.storeAddressList = res.data.result.records; const removeId = ref('')
console.log(this.storeAddressList); const routerVal = ref<Record<string, string>>({})
const params = { pageNumber: 1, pageSize: 1000 }
if (this.$store.state.isShowToast){ uni.hideLoading() }; onPullDownRefresh(() => {
}); storeAddressList.value = []
}, getAddressList()
}, })
};
onLoad((val) => {
routerVal.value = val || {}
})
onShow(() => {
storeAddressList.value = []
getAddressList()
})
function hideLoadingIfNeeded() {
if (store.state.isShowToast) uni.hideLoading()
}
async function selectAddressData(val: any) {
await API_Trade.setStoreAddressId(val.id, routerVal.value.way)
uni.navigateBack({ delta: 1 })
}
function getAddressList() {
uni.showLoading()
API_Store.getStoreAddress(routerVal.value.storeId, params).then((res) => {
storeAddressList.value = res.data.result.records
hideLoadingIfNeeded()
})
}
function deleteAddressMessage() {
// 保留 action-sheet 回调占位,当前页面无删除入口
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@@ -0,0 +1,37 @@
<template>
<view class="member-card" :style="{ color: cardColor }">
<image v-if="grade.gradeBackground && !backgroundFailed" :key="grade.gradeBackground" class="card-background" :src="grade.gradeBackground"
mode="aspectFill" @load="backgroundLoaded = true" @error="backgroundFailed = true" />
<view class="member-card-content">
<view class="card-status">{{ isCurrent ? '当前等级' : '等级预览' }}</view>
<view class="grade-heading">
<image v-if="grade.gradeImage && !iconFailed" :key="grade.gradeImage" class="grade-icon" :src="grade.gradeImage" mode="aspectFit" @error="iconFailed = true" />
<u-icon v-else name="level" size="30" :color="cardColor" /><text class="grade-title">{{ grade.gradeName }}</text>
</view>
<text class="card-subtitle">{{ benefitCount }} 项专属权益 · {{ thresholdText }}</text>
</view>
</view>
</template>
<script setup>
import { computed, ref, watch } from 'vue'
const props = defineProps({ grade: { type: Object, required: true }, benefitCount: { type: Number, default: 0 }, isCurrent: { type: Boolean, default: false } })
const backgroundLoaded = ref(false), backgroundFailed = ref(false), iconFailed = ref(false)
const cardColor = computed(() => {
if (!backgroundLoaded.value || backgroundFailed.value) return '#fff5df'
const color = props.grade.gradeFontColor
return /^#[0-9a-f]{6}$/i.test(color || '') ? color : '#333333'
})
const thresholdText = computed(() => props.grade.isDefault ? '默认等级' : `${Math.max(0, Number(props.grade.requiredExperience) || 0).toLocaleString('en-US')} 经验值可达`)
watch(() => props.grade.gradeBackground, () => { backgroundLoaded.value = false; backgroundFailed.value = false }, { flush: 'sync' })
watch(() => props.grade.gradeImage, () => { iconFailed.value = false }, { flush: 'sync' })
</script>
<style scoped lang="scss">
.member-card { position: relative; overflow: hidden; width: 100%; height: 100%; border-radius: 24rpx; background: linear-gradient(115deg, #51443b, #8e7351); }
.card-background { position: absolute; width: 100%; height: 100%; top: 0; left: 0; }
.member-card-content { position: relative; height: 100%; padding: 30rpx 32rpx; box-sizing: border-box; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; }
.card-status { border: 1rpx solid currentColor; opacity: .8; font-size: 20rpx; padding: 4rpx 14rpx; border-radius: 20rpx; }
.grade-heading { display: flex; align-items: center; gap: 14rpx; margin: 18rpx 0 12rpx; max-width: 100%; }
.grade-icon { width: 68rpx; height: 68rpx; flex-shrink: 0; }
.grade-title { font-size: 38rpx; line-height: 1.4; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-subtitle { font-size: 23rpx; opacity: .85; }
</style>

View File

@@ -1,219 +1,484 @@
<template> <template>
<view class="wap"> <view :style="themeStyle" class="deposit-log-page">
<u-navbar title="预存款列表"> <u-navbar
</u-navbar> title="预存款明细"
<view class="wrapper-show-money"> :fixed="true"
<view class="money-view"> :placeholder="true"
<h3>预存款金额 </h3> :border="false"
<view class="money">¥{{walletNum | unitPrice }}</view> :auto-back="true"
></u-navbar>
</view>
</view> <!-- 顶部余额概览卡片 -->
<view class="wrapper-tabs"> <view class="header-wrap">
<view class="balance-hero">
<swiper class="swiper-box" :current="swiperCurrent"> <view class="hero-glow hero-glow-1"></view>
<swiper-item class="swiper-item" v-for="index in list.length" :key="index"> <view class="hero-glow hero-glow-2"></view>
<scroll-view class="scroll-v view-wrapper" enableBackToTop="true" scroll-with-animation scroll-y @scrolltolower="loadMore"> <view class="hero-top">
<view v-if="depositData.length!=0" class="view-item" v-for="(logItem, logIndex) in depositData" :key="logIndex"> <text class="money-label">当前预存款余额 (元)</text>
<view class="view-item-detail"> </view>
<view class="-title">{{logItem.detail}}</view> <view class="money-row">
<!-- <view class="-number">{{logItem.detail}}</view> --> <text class="money-symbol">¥</text>
</view> <text class="money-value">{{ unitPrice(walletNum) }}</text>
<view class="view-item-change"> </view>
<view class="-money green" v-if="logItem.serviceType == 'WALLET_PAY' || logItem.serviceType == 'WALLET_WITHDRAWAL'"> {{logItem.money | unitPrice}} </view> </view>
<view class="-money" v-if="logItem.serviceType == 'WALLET_REFUND' || logItem.serviceType == 'WALLET_RECHARGE' || logItem.serviceType == 'WALLET_COMMISSION' ">
+{{logItem.money | unitPrice}} </view> <!-- 收支筛选栏 -->
<view class="-time">{{logItem.createTime}}</view> <view class="filter-bar">
</view> <view
</view> v-for="(tab, idx) in filterTabs"
:key="tab.key"
<u-empty v-if="depositData.length==0" mode="history" text="暂无记录" /> class="filter-pill"
:class="{ active: activeFilter === idx }"
</scroll-view> @click="activeFilter = idx"
>
</swiper-item> {{ tab.name }}
</view>
</swiper> </view>
</view> </view>
</view>
</template> <!-- 明细列表区 -->
<view class="list-container">
<script> <view v-if="filteredData.length > 0" class="list-card">
import { getUserRecharge, getWalletLog } from "@/api/members"; <view
import { getUserWallet } from "@/api/members"; class="log-item"
export default { v-for="(item, logIndex) in filteredData"
data() { :key="logIndex"
return { >
walletNum: 0, <!-- 第一行:类型标签 + 标题 | 变动金额 -->
current: 0, <view class="log-row-main">
swiperCurrent: 0, <view class="log-title-wrap">
userInfo: "", //用户详情信息 <text class="type-tag" :class="item.parsed.tagClass">{{ item.parsed.tagText }}</text>
params: { <text class="log-title">{{ item.parsed.title }}</text>
pageNumber: 1, </view>
pageSize: 10, <text class="log-amount" :class="item.parsed.moneyClass">
order: "desc", {{ item.parsed.formattedMoney }}
}, </text>
depositData: [], //遍历的数据集合 </view>
rechargeList: "", //充值明细列表
walletLogList: "", //钱包变动列表 <!-- 第二行:提取出的单号或备注说明 -->
list: [ <view v-if="item.parsed.metaList.length > 0" class="log-meta-box">
// { <view
// name: "充值明细", class="log-meta-line"
// }, v-for="(meta, mIdx) in item.parsed.metaList"
{ :key="mIdx"
name: "预存款变动明细", >
}, <text class="meta-label">{{ meta.label }}:</text>
], <text class="meta-val">{{ meta.value }}</text>
}; </view>
}, </view>
watch: {
swiperCurrent(index) { <!-- 第三行:变动时间 -->
this.swiperCurrent = index; <view class="log-row-foot">
}, <text class="log-time">{{ item.createTime }}</text>
}, </view>
async mounted() { </view>
this.getWallet(); </view>
let result = await getUserWallet(); //预存款
<view v-else-if="loaded" class="empty-box">
this.walletNum = result.data.result.memberWallet; <u-empty mode="history" text="暂无预存款变动记录" />
}, </view>
methods: { </view>
</view>
/**分页获取预存款充值记录 */ </template>
getRecharge() {
getUserRecharge(this.params).then((res) => { <script setup lang="ts">
if (res.data.success) { import { ref, onMounted, computed } from 'vue'
if (res.data.result.records.length != 0) { import { onReachBottom } from '@dcloudio/uni-app'
this.depositData.push(...res.data.result.records); import { getWalletLog, getUserWallet } from '@/api/members'
} import { unitPrice } from '@/utils/filters.js'
} import { useStore } from '@/store'
}); import { getThemeStyle } from '@/utils/theme'
},
const store = useStore()
getWallet() { const themeStyle = computed(() => getThemeStyle(store.state.theme))
getWalletLog(this.params).then((res) => { const walletNum = ref(0)
if (res.data.success) { const loaded = ref(false)
if (res.data.result.records.length != 0) { const hasMore = ref(true)
this.depositData.push(...res.data.result.records); const activeFilter = ref(0)
} const filterTabs = [
} { key: 'ALL', name: '全部明细' },
}); { key: 'IN', name: '收入 / 退款' },
}, { key: 'OUT', name: '支出 / 提现' },
]
changed(index) { const params = ref({
this.depositData = []; pageNumber: 1,
this.swiperCurrent = index; pageSize: 10,
this.params.pageNumber = 1; order: 'desc',
if (index == 0) { })
// this.getRecharge(); const depositData = ref<any[]>([])
this.getWallet();
} else { onMounted(async () => {
this.getWallet(); getWallet()
} const result = await getUserWallet()
}, walletNum.value = result.data?.result?.memberWallet ?? 0
})
loadMore() {
this.params.pageNumber++; onReachBottom(() => {
this.getWallet(); if (!hasMore.value) return
}, loadMore()
}, })
};
</script> function isOutgoing(logItem: any) {
const money = Number(logItem?.money) || 0
<style lang="scss" scoped> if (money < 0) return true
.green { const serviceType = logItem?.serviceType
color: $aider-color-green !important; return serviceType === 'WALLET_PAY' || serviceType === 'WALLET_WITHDRAWAL'
} }
.view-item {
padding: 32rpx; function isIncoming(logItem: any) {
display: flex; const money = Number(logItem?.money) || 0
justify-content: space-between; if (money > 0) return true
align-items: center; const serviceType = logItem?.serviceType
} return (
.view-item-change { serviceType === 'WALLET_REFUND' ||
text-align: right; serviceType === 'WALLET_RECHARGE' ||
> .-money { serviceType === 'WALLET_COMMISSION'
font-size: 36rpx; )
color: $main-color; }
font-weight: bold;
} function parseLogDetail(logItem: any) {
> .-time { const raw = String(logItem?.detail || '').trim()
font-size: 22rpx; const serviceType = logItem?.serviceType || ''
color: #999; const out = isOutgoing(logItem)
} const inc = isIncoming(logItem)
}
.view-item-detail { const absAmount = unitPrice(Math.abs(Number(logItem?.money) || 0))
line-height: 1.75; const formattedMoney = out ? `-${absAmount}` : inc ? `+${absAmount}` : absAmount
> .-title { const moneyClass = out ? 'out' : inc ? 'in' : ''
font-size: 28rpx;
} let title = '余额变动'
> .-number { let tagText = '变动'
font-size: 22rpx; let tagClass = 'tag-default'
color: #999;
} const orderMatch = raw.match(/订单\[([^\]]+)\]/)
} const afterSaleMatch = raw.match(/售后单\[([^\]]+)\]/)
.submit-btn { const rechargeMatch = raw.match(/充值单号为[::]\s*([A-Za-z0-9_-]+)/)
line-height: 90rpx;
text-align: center; if (afterSaleMatch && afterSaleMatch[1] === 'ORDER_CANCEL') {
title = '订单取消退回'
color: #fff; tagText = '退款'
background: $main-color; tagClass = 'tag-in'
} else if (serviceType === 'WALLET_REFUND' || raw.includes('退还') || raw.includes('返还')) {
margin: 0 auto; title = '售后退款入账'
height: 90rpx; tagText = '退款'
} tagClass = 'tag-in'
} else if (serviceType === 'WALLET_PAY' || raw.includes('支付金额')) {
.operation { title = '订单余额支付'
font-size: 32rpx; tagText = '消费'
margin-right: 24rpx; tagClass = 'tag-out'
color: rgb(96, 98, 102); } else if (serviceType === 'WALLET_RECHARGE') {
} title = raw.includes('后台') ? '平台余额充值' : '预存款充值'
.money { tagText = '充值'
font-size: 40rpx; tagClass = 'tag-in'
font-weight: bold; } else if (serviceType === 'WALLET_WITHDRAWAL') {
} title = out ? '余额提现申请' : '提现退回解冻'
tagText = '提现'
.money-view { tagClass = out ? 'tag-out' : 'tag-in'
height: 100%; } else if (serviceType === 'WALLET_COMMISSION') {
width: 100%; title = '分销佣金入账'
padding: 0 32rpx; tagText = '佣金'
display: flex; tagClass = 'tag-in'
align-items: flex-end; }
justify-content: center;
flex-direction: column; const metaList: Array<{ label: string; value: string }> = []
color: #fff; if (orderMatch && orderMatch[1]) {
background-image: linear-gradient( metaList.push({ label: '订单编号', value: orderMatch[1] })
25deg, }
$main-color, if (afterSaleMatch && afterSaleMatch[1] && afterSaleMatch[1] !== 'ORDER_CANCEL') {
$light-color, metaList.push({ label: '售后单号', value: afterSaleMatch[1] })
$aider-light-color }
); if (rechargeMatch && rechargeMatch[1]) {
} metaList.push({ label: '充值单号', value: rechargeMatch[1] })
}
.swiper-item,
.scroll-v { if (metaList.length === 0 && raw && !raw.includes('???')) {
height: 100%; const cleaned = raw
} .replace(/[,,]?\s*(支付金额|退还金额|余额返还)\[[^\]]+\]/g, '')
.replace(/:\s*\d+(\.\d+)?$/, '')
.swiper-box { .trim()
/* #ifndef H5 */ if (cleaned && cleaned !== title) {
height: calc(100vh - 200rpx); metaList.push({ label: '变动说明', value: cleaned })
/* #endif */ }
}
/* #ifdef H5 */
height: calc(100vh - 288rpx); return {
/* #endif */ title,
} tagText,
tagClass,
.wap { formattedMoney,
width: 100%; moneyClass,
height: calc(100vh - 44px); isOut: out,
} isIn: inc,
metaList,
.wrapper-show-money { }
height: 200rpx; }
// background-image: url('/static/img/main-bg.jpg');
} const decoratedList = computed(() =>
</style> depositData.value.map((item) => ({
...item,
parsed: parseLogDetail(item),
}))
)
const filteredData = computed(() => {
if (activeFilter.value === 1) {
return decoratedList.value.filter((item) => item.parsed.isIn)
}
if (activeFilter.value === 2) {
return decoratedList.value.filter((item) => item.parsed.isOut)
}
return decoratedList.value
})
function getWallet() {
getWalletLog(params.value).then((res) => {
loaded.value = true
const records = (res.data?.success && res.data?.result?.records) || []
if (records.length) {
depositData.value.push(...records)
}
if (records.length < params.value.pageSize) {
hasMore.value = false
}
})
}
function loadMore() {
params.value.pageNumber++
getWallet()
}
</script>
<style lang="scss" scoped>
.deposit-log-page {
min-height: 100vh;
background: #f5f6fa;
padding-bottom: 48rpx;
box-sizing: border-box;
}
.header-wrap {
padding: 24rpx 24rpx 8rpx;
}
.balance-hero {
position: relative;
overflow: hidden;
border-radius: 24rpx;
padding: 36rpx 36rpx 34rpx;
color: #ffffff;
background: linear-gradient(135deg, $main-color 0%, $light-color 60%, $aider-light-color 100%);
box-shadow: 0 12rpx 28rpx rgba(229, 50, 56, 0.18);
}
.hero-glow {
position: absolute;
border-radius: 50%;
background: rgba(255, 255, 255, 0.12);
pointer-events: none;
}
.hero-glow-1 {
width: 220rpx;
height: 220rpx;
right: -60rpx;
top: -70rpx;
}
.hero-glow-2 {
width: 140rpx;
height: 140rpx;
right: 90rpx;
bottom: -60rpx;
background: rgba(255, 255, 255, 0.08);
}
.hero-top {
display: flex;
align-items: center;
justify-content: space-between;
}
.money-label {
font-size: 25rpx;
color: rgba(255, 255, 255, 0.88);
letter-spacing: 0.5rpx;
}
.money-row {
margin-top: 14rpx;
display: flex;
align-items: baseline;
}
.money-symbol {
font-size: 34rpx;
font-weight: 600;
margin-right: 8rpx;
}
.money-value {
font-size: 58rpx;
font-weight: 700;
line-height: 1.15;
letter-spacing: 1rpx;
font-variant-numeric: tabular-nums;
}
.filter-bar {
display: flex;
align-items: center;
gap: 16rpx;
margin-top: 24rpx;
}
.filter-pill {
padding: 12rpx 28rpx;
border-radius: 999rpx;
font-size: 25rpx;
color: #666666;
background: #ffffff;
font-weight: 500;
transition: all 0.2s;
&.active {
background: $main-color;
color: #ffffff;
font-weight: 600;
box-shadow: 0 4rpx 12rpx rgba(229, 50, 56, 0.2);
}
}
.list-container {
padding: 16rpx 24rpx 0;
}
.list-card {
display: flex;
flex-direction: column;
gap: 18rpx;
}
.log-item {
background: #ffffff;
border-radius: 20rpx;
padding: 28rpx 30rpx;
box-shadow: 0 2rpx 12rpx rgba(17, 30, 79, 0.03);
}
.log-row-main {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
}
.log-title-wrap {
display: flex;
align-items: center;
gap: 12rpx;
min-width: 0;
flex: 1;
}
.type-tag {
flex-shrink: 0;
font-size: 20rpx;
font-weight: 600;
padding: 4rpx 12rpx;
border-radius: 8rpx;
line-height: 1.3;
&.tag-in {
color: #00a870;
background: rgba(0, 168, 112, 0.1);
}
&.tag-out {
color: #ff4d4f;
background: rgba(255, 77, 79, 0.1);
}
&.tag-default {
color: #666666;
background: #f0f2f5;
}
}
.log-title {
font-size: 30rpx;
font-weight: 600;
color: #1d2129;
line-height: 1.35;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.log-amount {
flex-shrink: 0;
font-size: 34rpx;
font-weight: 700;
line-height: 1.2;
font-variant-numeric: tabular-nums;
color: #1d2129;
&.in {
color: #00a870;
}
&.out {
color: #ff4d4f;
}
}
.log-meta-box {
margin-top: 16rpx;
padding: 14rpx 18rpx;
background: #f8f9fb;
border-radius: 12rpx;
display: flex;
flex-direction: column;
gap: 6rpx;
}
.log-meta-line {
display: flex;
align-items: center;
font-size: 23rpx;
line-height: 1.45;
color: #4e5969;
}
.meta-label {
flex-shrink: 0;
color: #86909c;
}
.meta-val {
flex: 1;
min-width: 0;
color: #4e5969;
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
word-break: break-all;
}
.log-row-foot {
margin-top: 16rpx;
display: flex;
align-items: center;
justify-content: space-between;
}
.log-time {
font-size: 22rpx;
color: #999999;
line-height: 1.2;
}
.empty-box {
padding-top: 120rpx;
}
</style>

View File

@@ -1,19 +1,18 @@
<template> <template>
<view class="wrapper"> <view class="wrapper">
<u-cell-group> <u-cell-group>
<u-cell-item title="申请单号"></u-cell-item> <u-cell title="申请单号"></u-cell>
<u-cell-item title="提现金额" value="新版本"></u-cell-item> <u-cell title="提现金额" value="新版本"></u-cell>
<u-cell-item title="收款银行"></u-cell-item> <u-cell title="收款银行"></u-cell>
<u-cell-item title="收款账号" value="新版本"></u-cell-item> <u-cell title="收款账号" value="新版本"></u-cell>
<u-cell-item title="开户人姓名"></u-cell-item> <u-cell title="开户人姓名"></u-cell>
<u-cell-item title="创建时间" value="新版本"></u-cell-item> <u-cell title="创建时间" value="新版本"></u-cell>
<u-cell-item title="提现状态" value="新版本"></u-cell-item> <u-cell title="提现状态" value="新版本"></u-cell>
</u-cell-group> </u-cell-group>
</view> </view>
</template> </template>
<script> <script setup lang="ts">
export default {};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@@ -1,114 +1,168 @@
<template> <template>
<div class="wrapper"> <view :style="themeStyle" class="page">
<u-navbar :custom-back="back" title="余额"></u-navbar> <u-navbar
<div class="box"> title="余额"
<div class="deposit">预存款金额</div> :auto-back="false"
<div class="money">¥{{walletNum | unitPrice }}</div> :placeholder="true"
<div class="operation-btns"> :border="false"
<div class="operation-btn light" @click="navigateTo('/pages/mine/deposit/withdrawal')">提现</div> @leftClick="back"
<div class="operation-btn" @click="navigateTo('/pages/mine/deposit/recharge')">充值</div> ></u-navbar>
</div>
</div> <view class="page-body">
<div class="box list" @click="navigateTo('/pages/mine/deposit/index')"> <view class="balance-card">
<div class="list-left">预存款明细</div> <view class="deposit">预存款金额</view>
<div class="list-right"> <view class="money">¥{{ unitPrice(walletNum) }}</view>
<u-icon name="arrow-right"></u-icon> <view class="operation-btns">
</div> <view
</div> class="operation-btn light"
</div> @click="navigateTo('/pages/mine/deposit/withdrawal')"
>提现</view>
<view
class="operation-btn primary"
@click="navigateTo('/pages/mine/deposit/recharge')"
>充值</view>
</view>
</view>
<view class="menu-list">
<view class="list-item" @click="navigateTo('/pages/mine/deposit/index')">
<text class="list-label">预存款明细</text>
<u-icon name="arrow-right" color="#ccc" size="16"></u-icon>
</view>
<view class="list-item" @click="navigateTo('/pages/mine/deposit/withdrawApply')">
<text class="list-label">提现记录</text>
<u-icon name="arrow-right" color="#ccc" size="16"></u-icon>
</view>
</view>
</view>
</view>
</template> </template>
<script> <script setup lang="ts">
import { getUserWallet } from "@/api/members"; import { ref, computed } from 'vue'
export default { import { onShow } from '@dcloudio/uni-app'
data() { import { getUserWallet } from '@/api/members'
return { import { isLogin, navigateToLogin, unitPrice } from '@/utils/filters.js'
walletNum: 0, import { useStore } from '@/store'
}; import { getThemeStyle } from '@/utils/theme'
}, import {
async onShow() { prefetchMpMessageTemplates,
if (this.$options.filters.isLogin("auth")) { subscribeMpMessageByScenes,
let result = await getUserWallet(); //预存款 } from '@/js_sdk/lili-pay/wx-pay.js'
this.walletNum = result.data.result.memberWallet;
} else { const store = useStore()
this.$options.filters.navigateToLogin("redirectTo"); const themeStyle = computed(() => getThemeStyle(store.state.theme))
}
}, const walletNum = ref(0)
methods: {
back() { onShow(async () => {
uni.switchTab({ if (isLogin('auth')) {
url: "/pages/tabbar/user/my", // #ifdef MP-WEIXIN
}); prefetchMpMessageTemplates()
}, // #endif
/** const result = await getUserWallet()
* 跳转 walletNum.value = result.data.result.memberWallet
*/ } else {
navigateTo(url) { navigateToLogin('redirectTo')
uni.navigateTo({ }
url, })
});
}, function back() {
}, const doBack = () => {
}; uni.switchTab({ url: '/pages/tabbar/user/my' })
}
// #ifdef MP-WEIXIN
subscribeMpMessageByScenes(['WALLET_CHANGE'], doBack)
// #endif
// #ifndef MP-WEIXIN
doBack()
// #endif
}
function navigateTo(url: string) {
uni.navigateTo({ url })
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.list { .page {
display: flex; min-height: 100vh;
justify-content: center; background: #f5f5f5;
align-items: center;
} }
.list-left {
flex: 8;
}
.list-right {
flex: 2;
text-align: right;
}
.wrapper {
width: 94%;
margin: 0 3%;
}
.box {
margin: 20rpx 0;
background: #fff;
border-radius: 20rpx;
padding: 40rpx; .page-body {
padding: 24rpx;
} }
.balance-card {
background: #fff;
border-radius: 16rpx;
padding: 48rpx 32rpx 40rpx;
text-align: center;
}
.deposit {
font-size: 28rpx;
color: #999;
}
.money {
margin: 24rpx 0 40rpx;
font-size: 64rpx;
font-weight: 600;
color: #333;
letter-spacing: 2rpx;
}
.operation-btns { .operation-btns {
display: flex; display: flex;
justify-content: center; flex-direction: row;
align-items: center; align-items: center;
gap: 24rpx;
} }
.money {
text-align: center;
color: #333;
font-size: 50rpx;
margin: 20rpx 0 40rpx 0;
letter-spacing: 2rpx;
}
.deposit {
margin-top: 50rpx;
text-align: center;
color: #999;
font-size: 28rpx;
letter-spacing: 2rpx;
}
.operation-btn { .operation-btn {
background: #ee6d41; flex: 1;
color: #fff; height: 88rpx;
height: 90rpx; line-height: 88rpx;
width: 240rpx; border-radius: 12rpx;
margin: 0 20rpx; font-size: 30rpx;
border-radius: 10rpx;
text-align: center; text-align: center;
line-height: 90rpx;
font-size: 32rpx;
} }
.light { .light {
background: #fdf2ee; background: #fdf2ee;
color: #ee6d41; color: $light-color;
border: 1px solid rgba(238, 109, 65, 0.25);
} }
</style>
.primary {
background: $light-color;
color: #fff;
}
.menu-list {
margin-top: 24rpx;
background: #fff;
border-radius: 16rpx;
overflow: hidden;
}
.list-item {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding: 32rpx;
border-bottom: 1px solid #f5f5f5;
&:last-child {
border-bottom: none;
}
}
.list-label {
font-size: 30rpx;
color: #333;
}
</style>

Some files were not shown because too many files have changed in this diff Show More