Compare commits

..
179 Commits
Author SHA1 Message Date
15233722133 b090a3c070 init 2026-10-09 16:16:32 +08:00
15233722133 39100c71be feat: 兑换添加手动价格、添加撤单功能 2026-10-08 16:58:47 +08:00
15233722133 1c34e15f8a feat: 异常提示优化 2026-09-30 11:05:26 +08:00
15233722133 0cbbf4309d feat: 添加金种子包配置 2026-09-30 10:39:45 +08:00
15233722133 82f6737820 feat: 添加金种子兑换包模块 2026-09-29 13:01:47 +08:00
15233722133 4b0aab8a51 feat: 提现添加权限配置 2026-09-28 14:00:26 +08:00
15233722133 6d2f1c4fdb feat: 样式优化 2026-09-24 11:31:36 +08:00
15233722133 31c4aa36a5 feat: ai店铺订单添加修改配送功能 2026-09-24 11:20:36 +08:00
15233722133 8dee31e18c feat: 修改提交验证 2026-09-22 11:38:37 +08:00
15233722133 4e190b5879 feat: 添加华夏变现、添加三方权限配置 2026-09-22 10:09:04 +08:00
15233722133 2a25354ee4 feat: 商城订单添加删除按钮(已取消) 2026-09-16 09:54:35 +08:00
15233722133 9ade530194 feat: ai店铺支付完成返回选品广场 2026-09-08 16:07:17 +08:00
15233722133 34b2ac37b8 feat: 选品广场购买结算返回原位 2026-09-08 11:10:52 +08:00
15233722133 a573a61be7 feat: 添加已售罄标签 2026-08-26 10:40:18 +08:00
15233722133 677b18bca9 feat: 版本更新记录 2026-08-13 16:42:34 +08:00
15233722133 9a30b0efde feat: 添加催一催按钮、应用宝跳转配置 2026-08-12 13:15:50 +08:00
15233722133 6a1f4f66ac feat: 网店管理-按钮文案从「停用/启用」改为「休息/营业」 2026-08-11 14:00:56 +08:00
15233722133 5de2935c7d feat: 提货清单时间排序 2026-08-11 11:34:17 +08:00
15233722133 95a614e6ca feat: 查看物流兼容老数据 2026-08-11 11:01:51 +08:00
15233722133 acb5f1952b feat: 已收货也要展示物流 2026-08-11 10:32:36 +08:00
15233722133 f8f697f74b feat: 选择自提门店列展示状态 2026-08-10 17:24:49 +08:00
15233722133 14fa7b32c4 feat: 商户端无权限提出返回到用户端 2026-08-10 15:47:15 +08:00
15233722133 633977ce32 feat: 备货进度隐藏分拣时间进度条 2026-08-10 15:12:43 +08:00
15233722133 8979301a2e feat: 区分普通订单和ai订单的查看物流 2026-08-10 14:24:10 +08:00
15233722133 9c1e42fe48 feat: 普通商品售后订单隐藏、查看物流展示 2026-08-10 13:37:06 +08:00
15233722133 50c4a7168f feat: 隐藏网店管理进度条 2026-08-10 10:39:17 +08:00
15233722133 dca5f1d18e feat:售后展示 2026-08-08 17:18:02 +08:00
15233722133 92fdf2baac feat:售后类型参数传递问题修改 2026-08-08 15:57:05 +08:00
15233722133 531033c066 feat:参数类型调整 2026-08-08 15:17:03 +08:00
15233722133 74d3c6f382 feat: 调整参数结构 2026-08-08 15:03:16 +08:00
15233722133 2ee3fc14e2 feat:修改售后参数 2026-08-08 14:51:26 +08:00
15233722133 8932e4b748 feat: 售后页面多余接口调用问题 2026-08-08 13:48:24 +08:00
15233722133 1415846b0b feat:售后展示问题 2026-08-08 13:27:18 +08:00
15233722133 85f2e94c1c feat: 普通商品购买默认第一个规格 2026-08-07 16:37:40 +08:00
15233722133 b0eb441bfe feat: 立即发货、延迟发货、查看订单按钮展示调整 2026-08-07 16:26:03 +08:00
15233722133 50b8039ad6 feat: 删除商品标题旁边延迟tag 2026-08-07 15:38:42 +08:00
15233722133 5c71cba575 feat: 开通店铺商品详情、物流接口变更 2026-08-07 14:39:20 +08:00
15233722133 c635215e24 feat: 没有延迟商品不展示立即发货 2026-08-07 14:22:54 +08:00
15233722133 dde77fb6d7 feat:申请售后价格展示调整 2026-08-07 14:18:26 +08:00
15233722133 8ac4d594c0 feat: 新增店铺订单批量收货api 2026-08-07 10:23:10 +08:00
15233722133 57080382be feat: 解决延迟发货展示问题 2026-08-06 18:08:18 +08:00
15233722133 3d54e7ce31 feat: 待收货、待发货添加15(部分发货状态) 2026-08-06 17:57:52 +08:00
15233722133 01e6925ede feat: 变更物流查看方式 2026-08-06 17:49:37 +08:00
15233722133 811f87d385 feat: 单个物流查看 2026-08-06 17:24:19 +08:00
15233722133 5f6358cb07 feat: 弹窗展示优化 2026-08-06 16:27:23 +08:00
15233722133 63d699ca7b feat: 部分确认收货 2026-08-06 16:03:07 +08:00
15233722133 b8bcd46f1d feat: 查看物流展示 2026-08-06 15:39:41 +08:00
15233722133 497babbc3d feat: 立即发货按钮展示 2026-08-06 15:02:09 +08:00
15233722133 53f0736d29 feat: 延迟弹窗控制可选择数量 2026-08-06 14:52:56 +08:00
15233722133 79f3e63a90 Merge branch 'v2.2' into v1.8.1
* v2.2:
  feat:  延迟发货调试
  feat: 多规格延迟发货
  feat: 店铺订单多规格展示
  feat: 延迟发货api
2026-08-06 13:50:31 +08:00
15233722133 a37ea9cb8e feat: 延迟发货调试 2026-08-06 13:21:17 +08:00
15233722133 160a72b015 feat: 多规格延迟发货 2026-08-05 18:17:04 +08:00
15233722133 0964dae037 feat: 店铺订单多规格展示 2026-08-05 17:59:44 +08:00
HongRun Liu 1c2df80a79 feat: 我的订单合并现金待确认tab到待支付tab 2026-08-05 17:11:31 +08:00
15233722133 e8a4108b42 feat: 延迟发货api 2026-08-05 11:10:52 +08:00
HongRun Liu 25da673443 feat: 增加现金支付 2026-08-05 10:51:29 +08:00
15233722133 1daec0121b feat: 取消退款状态不展示退款按钮 2026-08-04 17:00:49 +08:00
15233722133 0a9067c61e feat: 三方服务展示、无双变现记录不跳转 2026-08-03 17:56:19 +08:00
15233722133 a585857f92 feat: 商品详情图片宽度兜底 2026-08-01 12:55:23 +08:00
15233722133 082667a8be feat: 隐藏三方服务 2026-07-31 17:57:27 +08:00
15233722133 cf6353759d feat: 修改api地址 2026-07-30 17:40:46 +08:00
15233722133 d168e38305 feat: 添加无双相关 2026-07-25 16:30:57 +08:00
15233722133 3569ff6b5a feat: 新增三方服务 2026-07-25 16:24:09 +08:00
15233722133 7705af52af feat: 自提状态下不展示延时发货 2026-07-23 10:59:54 +08:00
15233722133 8e8a76971e feat:添加刷新配置 2026-07-16 14:10:33 +08:00
15233722133 6e47575c0b feat: 添加页面刷新功能 2026-07-16 14:10:04 +08:00
15233722133 8f0e5fa1d5 feat: 备货进度商品展示 2026-07-16 09:56:13 +08:00
15233722133 4c5d0e53d7 feat: 新增订单api 2026-07-15 18:29:16 +08:00
15233722133 7c8352ed56 feat: 提货清单隐藏取货码 2026-07-15 16:21:40 +08:00
15233722133 60cc75ccc4 feat: 核销接口参数调整 2026-07-15 15:13:31 +08:00
15233722133 882292ec2c feat: 门店标点展示 2026-07-15 14:55:51 +08:00
15233722133 a88952db3a feat: 多网点展示 2026-07-15 14:15:14 +08:00
15233722133 ea5b1c2532 feat: 选品广场/会员优选添加自提模块 2026-07-15 13:41:16 +08:00
15233722133 26c8f721f7 feat:网点列表展示、启/停用api 2026-07-15 12:04:29 +08:00
15233722133 df0ae8143a feat: 核销api 2026-07-15 10:51:15 +08:00
15233722133 eb6aed3a86 feat: 标记分拣、取货门店展示 2026-07-15 10:31:51 +08:00
15233722133 042c19f4dc feat: 商户提货列传递门店id 2026-07-14 18:20:00 +08:00
15233722133 94f8297a01 feat: 核销码展示、备货进度静态 2026-07-14 16:44:57 +08:00
15233722133 585fd6fb7e style: 订单详情nav展示问题 2026-07-14 15:56:55 +08:00
15233722133 74a4f25ebd feat: 修改网点api地址以及回填内容 2026-07-14 14:22:03 +08:00
15233722133 f065197d75 Merge branch 'v1.6' into v1.8
* v1.6:
  feat: 添加商户端页面
2026-07-14 13:41:20 +08:00
15233722133 ac0d0c2a7f feat: 注册页面添加扫描邀请码 2026-07-13 13:51:48 +08:00
15233722133 f85a676742 feat: 选品广场放开多规格 2026-07-09 14:38:22 +08:00
15233722133 edf992bf3a feat: 银行卡参数明文 2026-07-09 13:59:13 +08:00
15233722133 948957d805 feat: 添加商户端页面 2026-07-07 10:42:09 +08:00
15233722133 baf82cec86 feat: 添加延迟发货提示语、提现参数变更 2026-07-06 14:05:14 +08:00
15233722133 79bd7adb8a feat: 提现参数调整 2026-07-06 10:39:34 +08:00
15233722133 93800a463d feat: 提现页面银行卡号回填 2026-07-03 16:27:59 +08:00
15233722133 39dd128df1 feat: 修改服务协议地址 2026-07-02 17:10:56 +08:00
15233722133 d4e9cdcb4a feat: 银行卡页面添加修改/解绑功能 2026-06-30 10:09:18 +08:00
15233722133 4e5858039a feat: 定时器改为10秒 2026-06-26 17:29:00 +08:00
15233722133 024f5dff19 fix: 一次调用两次分页问题 2026-06-26 17:24:23 +08:00
15233722133 3d18abf3aa feat:调整页数参数 2026-06-26 17:20:30 +08:00
15233722133 c07dd81eaa feat: 修改新增参数名称 2026-06-26 16:44:51 +08:00
15233722133 a881ddd959 feat: 收支明细收益下添加三个tab 2026-06-26 16:32:16 +08:00
15233722133 baacf1be41 feat: 修改收支明细列表加载问题 2026-06-26 15:30:49 +08:00
15233722133 1902549342 feat: 添加风云榜、七数商角标 2026-06-26 15:00:57 +08:00
15233722133 a2f39099d6 feat: 登录页面记录列表支持滚动条 2026-06-26 13:38:34 +08:00
15233722133 655eceafbc style: 风云榜样式调整 2026-06-26 13:33:38 +08:00
15233722133 2b54995709 feat: 添加风云榜api 2026-06-26 11:34:05 +08:00
15233722133 7d6ca9de83 feat: 解开金种子数据展示 2026-06-25 17:06:36 +08:00
15233722133 8f76387cc7 feat: 放开金种子接口 2026-06-25 16:14:35 +08:00
15233722133 a7f80af1de feat: ai店铺添加柱状图 2026-06-25 11:10:18 +08:00
15233722133 c8eb96b64c feat: 添加收支明细页面、修改我的店铺展示、ai店铺-列表记录添加分页 2026-06-24 16:40:38 +08:00
15233722133 ab8e8371cf feat:更新版本记录 2026-06-23 13:29:38 +08:00
15233722133 90fc557ac8 feat: 添加跳转链接、提现跳转实名认证 2026-06-22 16:10:17 +08:00
15233722133 5dc1823786 feat: 添加登录记录 2026-06-16 18:07:34 +08:00
15233722133 3d83be503a feat: 变现添加输入手机号 2026-06-16 16:49:07 +08:00
15233722133 5124f93433 feat: 选品广场详情添加购买按钮 2026-06-16 11:02:02 +08:00
15233722133 a811e42c92 fix: 申请售后展示问题 2026-06-15 18:07:55 +08:00
15233722133 980c5be89e feat: 更改时间来源、格式 2026-06-15 15:15:49 +08:00
15233722133 577c022ac0 feat: 添加修改头像入口、AI订单记录展示 状态 2026-06-15 13:20:41 +08:00
15233722133 f440b6c32b Merge branch 'v1.2_crop' into v1.3
* v1.2_crop:
  feat: 裁剪添加放大缩小
  feat: 优化为先选择图片再裁剪
  feat:裁剪头像
2026-06-15 11:20:13 +08:00
15233722133 a56e6c8a1c fix: 解决进度条+loading 同时出现问题 2026-06-15 11:19:32 +08:00
15233722133 5443d09cad feat: 放开左边提现入口 2026-06-15 11:11:19 +08:00
15233722133 104d63a73d feat: 裁剪添加放大缩小 2026-06-15 11:02:13 +08:00
15233722133 8ec0ad482b feat: 优化为先选择图片再裁剪 2026-06-15 10:28:55 +08:00
15233722133 2ca7bb9817 feat:裁剪头像 2026-06-15 10:24:15 +08:00
15233722133 cb8ddd34a1 style: ai店铺滑动回不来问题、钱包禁用数量点击去变现入口 2026-06-12 18:08:30 +08:00
15233722133 fd282413d8 feat: 版本更新、列表记录数量取值、 2026-06-12 17:08:16 +08:00
15233722133 795de5ff62 feat: 进度条百分比保留两位小数 2026-06-12 09:51:42 +08:00
15233722133 6dee56e17f style: 样式展示问题 2026-06-09 15:20:25 +08:00
15233722133 5551b08d5a feat: banner跳转ai店铺判断 2026-06-08 17:34:23 +08:00
15233722133 7752c4efa5 fest: 确认单页防抖处理 2026-06-08 15:32:47 +08:00
15233722133 65c229c37b feat:收银台区分标识返回页面 2026-06-08 13:20:45 +08:00
15233722133 84ffbdee47 feat: ai店铺订单详情按钮展示 2026-06-08 10:50:20 +08:00
15233722133 5a110a24c1 feat: 列表记录进度条数据来源变更 2026-06-08 10:33:26 +08:00
15233722133 eba95941e2 feat: ai店铺订单按钮展示 2026-06-08 10:29:25 +08:00
15233722133 2449d67e53 feat: 购物车为空时底部不显示“去结算” 2026-06-05 17:20:49 +08:00
15233722133 70cbccbb52 feat: “会员优选”商品卡片点击不再跳转到商品详情页 2026-06-05 16:37:01 +08:00
15233722133 e271764292 feat: 点底部 tab 的“AI店铺”时没开通就不跳转并提示 2026-06-05 16:30:30 +08:00
15233722133 a1c5dd5514 feat: 一键分享按钮展示调整 2026-06-05 16:16:13 +08:00
15233722133 07740f7746 feat: 选品广场结算返回到我的店铺页,粉色卡默认false所有页面统一调整 2026-06-05 15:59:52 +08:00
15233722133 f51892b9c5 feat:完善首页会员优选、我的社员ui重构 2026-06-05 15:21:02 +08:00
15233722133 311f380dbc feat: ’已开通不展示会员优选‘兜底 2026-06-05 14:14:17 +08:00
15233722133 3d795805e7 feat:添加店铺订单详情api 2026-06-05 13:21:40 +08:00
15233722133 620712828e feat:添加开通ai店铺订单接口、添加分类(店铺订单) 2026-06-05 12:32:40 +08:00
15233722133 e8f59cc6c5 feat: 添加首页会员优选列表 2026-06-05 10:49:52 +08:00
15233722133 7fd6871e3c feat: 进度条添加百分比展示 2026-06-05 10:26:19 +08:00
15233722133 d657df4ba3 feat: 我的店铺列表进度条数据变更 2026-06-05 09:46:13 +08:00
15233722133 9fa063f695 feat: 我的店铺进度条 2026-06-04 17:41:39 +08:00
15233722133 c305aa60b0 feat: 注册账号添加获取验证码 2026-06-04 15:59:35 +08:00
15233722133 9ad7d6791c feat:添加有这么登录 2026-06-04 14:56:52 +08:00
15233722133 880cb95bf9 style: 登录/注册页面ui换新 2026-06-04 14:53:47 +08:00
15233722133 e01295bbc2 style: 调整列表内容展示 2026-06-04 14:01:43 +08:00
15233722133 3e331bba3d feat: 列表记录商品名称取消兜底 2026-06-04 13:53:40 +08:00
15233722133 4d86ead906 feat: 修改店铺当即展示 2026-06-04 13:48:58 +08:00
15233722133 e1ac39de86 feat: skuid判空 2026-06-04 13:39:10 +08:00
15233722133 d487c20d49 feat: ai店铺列表记录数据展示 2026-06-04 13:37:43 +08:00
15233722133 1bd4efbf68 style: 已加购商品弹窗调整 2026-06-03 16:05:21 +08:00
15233722133 fd851bab83 feat: 添加我的店铺api 2026-06-03 15:18:09 +08:00
15233722133 5c7f7a9c4e style: 设置页面添加紫色背景 2026-06-03 13:44:40 +08:00
15233722133 55ce8b83eb feat: 版本更新优化非强制更新 2026-06-03 10:20:56 +08:00
15233722133 0be8c98710 fix: ai商品结算价格展示调整 2026-06-02 17:33:11 +08:00
15233722133 04fd017fb0 feat: 没有设置开屏页不展示跳过按钮直接展示首页 2026-06-02 15:49:43 +08:00
15233722133 fe1ca06827 style: 调整ai店铺商品布局、tabbar中心icon白边处理 2026-06-02 15:26:19 +08:00
15233722133 3f01c33bfb style: 调整ai店铺商品布局、tabbar中心icon白边处理 2026-06-02 15:21:43 +08:00
15233722133 85d797f34f feat: 添加优惠金额 2026-06-02 14:28:29 +08:00
15233722133 f83068a3fc style: 购物车、我的页面ui 2026-06-02 14:00:17 +08:00
15233722133 1fe0a6351c feat: 添加ai店铺-列表记录、金种子图表样式调整 2026-06-02 11:31:12 +08:00
15233722133 910212dcac style: 金种子页面ui 2026-06-02 10:15:26 +08:00
15233722133 79fab5929a style: ai店铺ui 2026-06-01 18:47:47 +08:00
15233722133 86e964c363 feat: 提现金额修改字段 2026-06-01 17:39:05 +08:00
15233722133 4c09e97178 feat:ai店铺添加滚动列表 2026-06-01 17:35:42 +08:00
15233722133 6e6d41a25c feat: 验证码 2026-06-01 17:26:13 +08:00
15233722133 4d16af0ad6 feat: 去变现添加 获取验证码 2026-06-01 16:49:05 +08:00
15233722133 0f2a64f3b2 feat: 金种子icon添加蓝色阴影 2026-06-01 16:25:36 +08:00
15233722133 d2f77335d1 feat: 添加去变现功能 2026-06-01 16:12:25 +08:00
15233722133 c2388e1396 feat: 全局更改tabbar、首页、分享页UI重构 2026-06-01 15:50:19 +08:00
15233722133 aa0a289f27 feat: 开屏页面优化 2026-06-01 11:14:28 +08:00
15233722133 34fbca57a3 fix: 开屏页跳转按钮覆盖问题 2026-05-29 15:02:40 +08:00
15233722133 41cd5339dd feat: 添加NativeObj模块 2026-05-28 16:17:40 +08:00
15233722133 864f9ce627 feat:开屏页视频播放优化 2026-05-28 14:39:00 +08:00
15233722133 7a75f8b4bf fix: app启动报错问题修复 2026-05-28 14:33:10 +08:00
15233722133 2eb5f30d74 feat: 添加ai店铺页面 2026-05-27 17:54:46 +08:00
15233722133 7f8cd06954 feat: 添加现金支付渠道、解决选择地址没有id问题 2026-05-27 15:08:46 +08:00
15233722133 cf20c568de feat: 添加银行卡入口 2026-05-26 16:46:07 +08:00
15233722133 85188d268a feat: 版本更新 2026-05-26 16:33:32 +08:00
15233722133 30fdac8a06 feat: 金种子、邀请页、启动页API、银行卡 2026-05-26 16:26:52 +08:00
174 changed files with 25780 additions and 2990 deletions
+8 -18
View File
@@ -1,29 +1,20 @@
# 版本号
SHOPRO_VERSION=v2.4.1
# 后端接口 - 正式环境(通过 process.env.NODE_ENV 非 development)
#SHOPRO_BASE_URL=http://8.136.55.200:48090
# 后端接口 - 测试环境(通过 process.env.NODE_ENV = development)
# 霍慧超
#SHOPRO_DEV_BASE_URL=http://192.168.101.7:48092
# 陈力
# SHOPRO_DEV_BASE_URL=http://192.168.101.57:48092
# 张吉生
#SHOPRO_DEV_BASE_URL=http://192.168.101.58:48090
SHOPRO_BASE_URL=https://kyj.api.suwizihe.org.cn
# 服务器
SHOPRO_DEV_BASE_URL=http://www.qflyqzy.net:48090
SHOPRO_DEV_BASE_URL=https://kyj.api.suwizihe.org.cn
#SHOPRO_DEV_BASE_URL=https://www.qflyqzy.net/yg-api
# 伟伟
# SHOPRO_DEV_BASE_URL=http://192.168.1.7:48080
# 测试环境
# SHOPRO_DEV_BASE_URL=https://yougoutest.api.riananyoumu.com
# 本地
#SHOPRO_DEV_BASE_URL=http://8.136.55.200:48090
# SHOPRO_DEV_BASE_URL=http://192.168.1.3:48080
### SHOPRO_DEV_BASE_URL=http://10.171.1.188:48090
### SHOPRO_DEV_BASE_URL = http://yunai.natapp1.cc
# 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持 S3 服务
SHOPRO_UPLOAD_TYPE=server
@@ -49,4 +40,3 @@ SHOPRO_MPLIVE_ON=0
# 租户ID 默认 1
SHOPRO_TENANT_ID=1
+1
View File
@@ -10,3 +10,4 @@ package-lock.json
*.keystore
pnpm-lock.yaml
.history
/AGENTS.md
+397 -156
View File
@@ -15,107 +15,220 @@
import {
ShoproInit
} from './sheep';
import {
gethotupdatelist
} from '@/sheep/api/index/index';
const SCHEME_TAG = '[Scheme]';
const HOME_PATH = '/pages/index/index';
const SCHEME_PROTOCOL = 'yougou://';
const schemeState = {
lastScheme: '',
lastHandleAt: 0,
launching: false,
schemeHandledInLaunch: false,
};
const isSameSchemeDebounce = (scheme) => {
const now = Date.now();
const same = schemeState.lastScheme === scheme && now - schemeState.lastHandleAt < 800;
schemeState.lastScheme = scheme;
schemeState.lastHandleAt = now;
return same;
};
const parseSchemeQuery = (query = {}) => {
try {
const result = {};
Object.keys(query || {}).forEach((k) => {
const v = query[k];
if (v === undefined || v === null) return;
if (typeof v === 'string' && v.length > 512) {
result[k] = v.slice(0, 512);
return;
}
result[k] = v;
});
return result;
} catch (e) {
console.warn(SCHEME_TAG, 'parseSchemeQuery error', e);
return {};
}
};
const resolveTargetPath = (scheme = '', query = {}) => {
try {
const url = String(scheme || '').trim();
if (!url) return { path: HOME_PATH, query: parseSchemeQuery(query) };
const withoutProtocol = url.replace(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//, '');
if (!withoutProtocol) return { path: HOME_PATH, query: parseSchemeQuery(query) };
const [pathRaw = '', queryRaw = ''] = withoutProtocol.split('?');
const cleanPath = pathRaw.replace(/^\/+/, '/').trim();
const path = cleanPath.startsWith('/pages/') ? cleanPath : HOME_PATH;
const merged = { ...parseSchemeQuery(query) };
if (queryRaw) {
queryRaw.split('&').forEach((pair) => {
const [k, v] = pair.split('=');
if (!k) return;
try { merged[decodeURIComponent(k)] = v === undefined ? '' : decodeURIComponent(v); } catch (_) {}
});
}
return { path, query: merged };
} catch (e) {
console.warn(SCHEME_TAG, 'resolveTargetPath error, fallback to home', e);
return { path: HOME_PATH, query: parseSchemeQuery(query) };
}
};
const buildUrl = (path, query) => {
try {
const q = query || {};
const keys = Object.keys(q).filter((k) => q[k] !== undefined && q[k] !== null && q[k] !== '');
if (!keys.length) return path;
const qs = keys
.map((k) => `${encodeURIComponent(k)}=${encodeURIComponent(String(q[k]))}`)
.join('&');
return `${path}${path.includes('?') ? '&' : '?'}${qs}`;
} catch (e) {
return path;
}
};
const safeReLaunch = (path, query, source) => {
const finalUrl = buildUrl(path, query);
console.log(SCHEME_TAG, `${source} → reLaunch`, finalUrl);
try {
uni.reLaunch({
url: finalUrl,
fail: (err) => {
console.warn(SCHEME_TAG, 'reLaunch fail, fallback to switchTab/home', err);
if (path === HOME_PATH) {
try {
uni.switchTab({
url: HOME_PATH,
fail: (err2) => {
console.warn(SCHEME_TAG, 'switchTab also fail', err2);
uni.navigateTo({ url: HOME_PATH, fail: () => {} });
},
});
} catch (e) {
console.warn(SCHEME_TAG, 'switchTab catch', e);
}
} else {
uni.navigateTo({ url: finalUrl, fail: () => uni.reLaunch({ url: HOME_PATH }) });
}
},
});
} catch (e) {
console.error(SCHEME_TAG, 'safeReLaunch catch error', e);
try { uni.reLaunch({ url: HOME_PATH }); } catch (_) {}
}
};
const isSchemeTrigger = (options) => {
if (!options) return false;
if (String(options?.path || '').toLowerCase() === 'scheme') return true;
const scheme = String(options?.scheme || options?.argv?.scheme || '');
if (scheme.startsWith(SCHEME_PROTOCOL)) return true;
const referrer = String(options?.referrer || '');
if (referrer.startsWith(SCHEME_PROTOCOL)) return true;
return false;
};
const handleSchemeByOptions = (options, source) => {
const scheme = String(options?.scheme || options?.argv?.scheme || options?.referrer || '');
if (isSameSchemeDebounce(scheme)) {
console.log(SCHEME_TAG, `${source} 防抖跳过`, scheme);
return;
}
console.log(SCHEME_TAG, `${source} 触发`, options);
const query = { ...(options?.query || {}), ...(options?.argv?.query || {}) };
const { path, query: resolvedQuery } = resolveTargetPath(scheme, query);
safeReLaunch(path, resolvedQuery, source);
};
let schemeEventListenerRegistered = false;
const registerSchemeEventListener = () => {
if (schemeEventListenerRegistered) return;
if (typeof plus === 'undefined' || !plus?.globalEvent) return;
try {
plus.globalEvent.addEventListener('newintent', (e) => {
const intent = e?.intent || e;
let scheme = '';
let query = {};
try {
if (typeof plus?.runtime?.arguments === 'function' || typeof plus?.runtime?.arguments !== 'undefined') {
const args = plus.runtime.arguments;
if (args && typeof args === 'object') {
scheme = String(args.scheme || args.url || args.action || '');
query = args.query || {};
} else if (typeof args === 'string') {
scheme = args;
}
}
if (!scheme && intent?.data) {
const data = String(intent.data || '');
scheme = data;
const i = data.indexOf('?');
if (i > -1) {
data.slice(i + 1).split('&').forEach((pair) => {
const [k, v] = pair.split('=');
if (!k) return;
try { query[decodeURIComponent(k)] = v === undefined ? '' : decodeURIComponent(v); } catch (_) {}
});
}
}
if (!scheme && intent?.extras) {
scheme = String(intent.extras.scheme || intent.extras.url || intent.extras['android.intent.extra.TEXT'] || '');
}
} catch (err) {
console.warn(SCHEME_TAG, 'newintent parse error', err);
}
if (!scheme) return;
if (isSameSchemeDebounce(scheme)) {
console.log(SCHEME_TAG, 'newintent 防抖跳过', scheme);
return;
}
console.log(SCHEME_TAG, 'newintent(plus.globalEvent) 触发', { scheme, query, intent });
const { path, query: resolvedQuery } = resolveTargetPath(scheme, query);
safeReLaunch(path, resolvedQuery, 'newintent后台唤起');
});
schemeEventListenerRegistered = true;
console.log(SCHEME_TAG, 'plus.globalEvent newintent 监听已注册');
} catch (e) {
console.warn(SCHEME_TAG, 'registerSchemeEventListener catch', e);
}
};
const registerSchemeRuntimeArguments = () => {
if (typeof plus === 'undefined' || !plus?.runtime) return;
try {
const args = plus.runtime.arguments;
let scheme = '';
let query = {};
if (args && typeof args === 'object') {
scheme = String(args.scheme || args.url || '');
query = args.query || {};
} else if (typeof args === 'string' && args) {
scheme = args;
}
if (!scheme) return;
if (isSameSchemeDebounce(scheme)) {
console.log(SCHEME_TAG, 'runtime.arguments 防抖跳过', scheme);
return;
}
console.log(SCHEME_TAG, 'plus.runtime.arguments 读取', { scheme, query });
const { path, query: resolvedQuery } = resolveTargetPath(scheme, query);
safeReLaunch(path, resolvedQuery, 'plus.runtime.arguments冷启动');
} catch (e) {
console.warn(SCHEME_TAG, 'registerSchemeRuntimeArguments catch', e);
}
};
let globalData = ref({
statusBarHeight: 0, // 状态导航栏高度
navHeight: 0, // 总体高度
navigationBarHeight: 0, // 导航栏高度(标题栏高度)
windowHeight: 0,
});
let filePath = ref();
const wgtUp = async () => {
// console.log(plus.runtime);
let res = await gethotupdatelist();
if (res.code !== 0) return;
filePath.value = res.data.filePath;
let localVersion = uni.getSystemInfoSync().appWgtVersion;
if (res.data.versionNumber != localVersion) {
if (res.data.type == 'min') {
if (res.data.isForceUpdate) {
// 强制更新
downloadFile();
} else {
uni.showModal({
title: '提示',
content: '发现新的版本,是否更新?',
confirmColor: '#FA7E31',
success: (res) => {
if (res.confirm) {
downloadFile();
} else if (res.cancel) {
if (res.data.isForceUpdate) {
plus.runtime.quit(); //退出应用
}
}
},
});
}
} else {
uni.showModal({
title: '提示',
content: '发现新的版本,请到立即更新到最新版本',
confirmText: '立即更新',
cancelText: res.data.isForceUpdate ? '关闭' : '取消',
confirmColor: '#FA7E31',
success: (res) => {
if (res.confirm) {
updateApp(filePath.value);
} else if (res.cancel) {
if (res.data.isForceUpdate) {
plus.runtime.quit(); //退出应用
}
}
},
});
}
}
};
const updateApp = (url) => {
uni.showLoading({
title: '下载中',
});
uni.downloadFile({
url: url, //下载地址
success: (res) => {
console.log(res, '下载成功');
if (res.statusCode === 200) {
console.log('下载成功');
uni.hideLoading();
uni.showToast({
title: '下载成功',
icon: 'success',
});
uni.saveFile({
tempFilePath: res.tempFilePath,
success: function(res) {
uni.openDocument({
filePath: res.savedFilePath,
success: function(res) {
console.log(res, '打开安装包');
},
});
},
fail: (err) => {
console.log(err, '打开安装包-失败');
},
});
}
},
fail(e) {
uni.hideLoading();
uni.showToast({
title: '下载失败,请检查网络',
icon: 'none',
});
console.log(e);
},
});
};
const socket = () => {
let url = 'ws://192.168.101.229:48080/aishop/ws';
let socketTask = uni.connectSocket({
@@ -138,6 +251,135 @@
console.log('WebSocket 错误!', res);
});
};
const parseTitleToProgress = (title) => {
const text = String(title || '');
const percentMatch = text.match(/(\d{1,3})%/);
const percent = percentMatch ? Number(percentMatch[1]) : null;
const cleanText = text.replace(/\s*\d{1,3}%\s*$/, '').trim() || text;
const normalizedPercent =
percent !== null && Number.isFinite(percent) ?
Math.max(0, Math.min(100, percent)) :
text.includes('安装') && !text.includes('下载') ? 100 : null;
return {
percent: normalizedPercent,
text: cleanText
};
};
const shouldUseUpdateOverlay = (title) => {
const text = String(title || '');
if (!text) return false;
if (/下载|安装|更新/.test(text) && (/%/.test(text) || /下载中|安装中|正在下载|正在安装|正在更新/.test(text))) {
return true;
}
return false;
};
const ensureLoadingPatched = () => {
if (!uni || uni.__updateLoadingPatched) return;
const originalShowLoading = uni.showLoading;
const originalHideLoading = uni.hideLoading;
if (typeof originalShowLoading !== 'function' || typeof originalHideLoading !== 'function') {
uni.__updateLoadingPatched = true;
return;
}
const HOT_UPDATE_PROGRESS_EVENT = '__hot_update_progress__';
const canEmit = () => typeof uni !== 'undefined' && typeof uni.$emit === 'function';
const emitProgress = (payload) => {
if (!canEmit()) return false;
uni.__hotUpdatePendingProgress = payload;
uni.$emit(HOT_UPDATE_PROGRESS_EVENT, payload);
return true;
};
if (!uni.__updateToastPatched && typeof uni.showToast === 'function') {
const originalShowToast = uni.showToast;
uni.showToast = (options = {}) => {
const title =
typeof options === 'string' ? options : (options?.title ?? '');
if ((uni.__hotUpdateInFlight || uni.__hotUpdatePendingProgress || uni.__updateProgressShown) && shouldUseUpdateOverlay(title)) {
return;
}
return originalShowToast.call(uni, options);
};
uni.__updateToastPatched = true;
}
uni.showLoading = (options = {}) => {
const title = options?.title ?? '';
if (shouldUseUpdateOverlay(title) && (uni.__hotUpdateInFlight || uni.__hotUpdatePendingProgress || canEmit())) {
const parsed = parseTitleToProgress(title);
if (!uni.__updateProgressShown && canEmit()) {
uni.__updateProgressShown = true;
emitProgress({
type: 'show',
text: parsed.text || '下载中...'
});
}
if (parsed.percent !== null && canEmit()) {
emitProgress({
type: 'set',
percent: parsed.percent,
text: parsed.text || ''
});
}
return;
}
return originalShowLoading.call(uni, options);
};
uni.hideLoading = () => {
if (uni.__updateProgressShown && canEmit()) {
uni.__updateProgressShown = false;
emitProgress({
type: 'hide'
});
return;
}
return originalHideLoading.call(uni);
};
uni.__updateLoadingPatched = true;
};
const waitForPlusRuntime = ({
timeoutMs = 5000,
intervalMs = 50
} = {}) =>
new Promise((resolve) => {
const ready = () => typeof plus !== 'undefined' && !!plus?.runtime;
if (ready()) {
resolve(true);
return;
}
const startedAt = Date.now();
const timer = setInterval(() => {
if (ready()) {
clearInterval(timer);
resolve(true);
return;
}
if (Date.now() - startedAt >= timeoutMs) {
clearInterval(timer);
resolve(false);
}
}, intervalMs);
});
const ensureGlobalHotUpdateChecked = async () => {
if (uni.__globalHotUpdateCheckedInApp) return;
uni.__globalHotUpdateCheckedInApp = true;
const ok = await waitForPlusRuntime();
if (!ok) return;
if (typeof uni.__globalHotUpdateCheck === 'function') {
await uni.__globalHotUpdateCheck({
force: true,
source: 'app'
});
}
};
onMounted(() => {
// #ifdef APP-PLUS
// plus.nativeUI.setUIStyle('dark');
@@ -156,59 +398,16 @@
globalData.value.statusBarHeight = uni.getSystemInfoSync()?.statusBarHeight;
globalData.value.windowHeight = uni.getSystemInfoSync()?.windowHeight;
// 热更新
// #ifdef APP-PLUS
wgtUp();
// #endif
ensureLoadingPatched();
ensureGlobalHotUpdateChecked();
// socket()
});
const downloadFile = () => {
let url = filePath.value;
uni.downloadFile({
url: url,
success: (downloadResult) => {
uni.showToast({
title: '更新中....',
icon: 'none',
});
if (downloadResult) {
if (downloadResult.statusCode === 200) {
plus.runtime.install(
downloadResult.tempFilePath, {
force: true,
},
function() {
uni.showModal({
title: '成功提示',
content: '热更新成功,请重启应用',
confirmColor: '#FA7E31',
showCancel: false,
success: function(res) {
if (res.confirm) {
plus.runtime.restart(); //自动重启软件
}
},
});
},
function(e) {
uni.showModal({
title: '失败提示',
content: e,
showCancel: false,
confirmColor: '#FA7E31',
});
},
);
}
}
},
});
};
onLaunch(() => {
// 隐藏原生导航栏 使用自定义底部导航
// uni.hideTabBar({
// fail: () => {},
// });
onLaunch((options = {}) => {
try {
uni.hideTabBar({
fail: () => {},
});
} catch (e) {}
// globalData.value.statusBarHeight = uni.getSystemInfoSync()?.statusBarHeight;
// globalData.value.windowHeight = uni.getSystemInfoSync()?.windowHeight;
// 获取微信胶囊的位置信息 width,height,top,right,left,bottom
@@ -228,25 +427,67 @@
uni.setStorageSync('globalData', globalData.value);
// 加载Shopro底层依赖
ShoproInit();
console.log(SCHEME_TAG, 'onLaunch', options);
schemeState.launching = true;
schemeState.schemeHandledInLaunch = false;
// #ifdef APP-PLUS
const boot = () => {
registerSchemeEventListener();
const optionsHit = isSchemeTrigger(options);
if (optionsHit) {
schemeState.schemeHandledInLaunch = true;
handleSchemeByOptions(options, 'onLaunch冷启动scheme');
} else {
registerSchemeRuntimeArguments();
}
};
if (typeof plus === 'undefined' || !plus?.runtime) {
const start = Date.now();
const t = setInterval(() => {
if (typeof plus !== 'undefined' && plus?.runtime) {
clearInterval(t);
boot();
} else if (Date.now() - start > 4000) {
clearInterval(t);
boot();
}
}, 50);
} else {
boot();
}
setTimeout(() => { schemeState.launching = false; }, 1500);
// #endif
});
onShow(() => {
onShow((options = {}) => {
try {
uni.hideTabBar({
fail: () => {},
});
} catch (e) {}
// #ifdef APP-PLUS
// 获取urlSchemes参数
const args = plus.runtime.arguments;
if (args) {}
if (
!schemeState.launching &&
!schemeState.schemeHandledInLaunch &&
isSchemeTrigger(options)
) {
handleSchemeByOptions(options, 'onShow兜底scheme');
}
schemeState.schemeHandledInLaunch = false;
// 获取剪贴板
uni.getClipboardData({
success: (res) => {},
});
// #endif
});
uni.onTabBarMidButtonTap(() => {
uni.navigateTo({
url: '/pages/home/seed',
if (typeof uni.onTabBarMidButtonTap === 'function') {
uni.onTabBarMidButtonTap(() => {
uni.navigateTo({
url: '/pages/home/seed',
});
});
});
}
</script>
<style lang="scss">
@@ -264,4 +505,4 @@
.uni-app--showtopwindow uni-page-head {
display: none;
}
</style>
</style>
+80
View File
@@ -0,0 +1,80 @@
# Changelog
所有版本改动记录在此文件中。
## [1.3.9] - 2026-06-05
### 新增
- 添加“会员优选”标签下列表api
- 我的订单添加`店铺订单`列
- 添加商城订单列type为5(开通ai店铺订单)详情接口api
- 首页`会员优选`分类兜底(已开通ai店铺不展示)
- 首页`会员优选`分类点击购买直接跳转到购买页、支付完成返回首页
- 我的社员、我的订单ui重构
- 粉色卡默认false所有页面统一调整
- 选品广场结算返回到我的店铺页
- 点底部 tab 的`AI店铺`时没开通就不跳转并提示
- `会员优选`商品卡片点击不再跳转到商品详情页
- 购物车为空时:底部不显示“去结算”
- 会员专区→买商品→支付→支付结果→返回首页「选品广场」;选品广场→买商品→支付→支付结果→返回首页「我的店铺」
## [1.4.1] - 2026-06-09
### 修改
- 我的页面蓝色背景不展示问题
- ai店铺页面nav下展示白色border问题
## [1.4.8] - 2026-06-16
### 新增
- 变现添加输入手机号
- 添加登录记录
- 添加头像修改入口
## [1.4.9] - 2026-06-22
### 新增
- 添加跳转江文数商链接
- 提现未实名跳转实名认证
## [1.5.0] - 2026-06-24
### 新增
- 添加收支明细页面
- 我的店铺文案展示当前用户名称
## [1.5.1] - 2026-06-24
### 新增
- 修改我的店铺展示
- ai店铺-列表记录添加分页
## [1.5.2] - 2026-06-26
### 新增
- 选品广场添加`风云榜`
- 选品广场商品列表添加`七数商角标`
- 收支明细收益下添加`店长收益、权益收益、代理收益`
### 修改
- 金种子`池体量增长动态`数量展示调整为分
- 邀请好友页面添加`安全顶部`
## [1.6.5] - 2026-07-31
### 新增
- 添加高德地图key
## [1.6.8] - 2026-08-3
### 新增
- 无双链接、商品详情展示兜底
-
## [1.6.9] - 2026-08-3
### 新增
- 无双变现记录禁用跳转
## [1.7.0] - 2026-08-6
### 新增
- 现金支付模块
## [1.7.1] - 2026-08-12
### 新增
- 我的订单-修改延迟/立即发货、查看物流、确认订单等功能
- 添加自提、待分拣/待取货状态(待分拣不展示取货码)
- 提货订单添加时间排序
- 选择网点列表营业中优先展示
- 多规格商品展示、延迟发货状态展示
+9
View File
@@ -0,0 +1,9 @@
### 项目打包配置
- 更改版本号
- 当前版本号`1.4.1`
- 包名:`uni.UNI8B187414/com.yougou.mall`
- 应用名称:`康源家园`
- appId:`__UNI__8B19741`
- api地址`.env`:
- 线上`https://www.qflyqzy.net/yg-api`
- 测试`https://yougoutest.api.riananyoumu.com`
+1 -1
View File
@@ -1,7 +1,7 @@
{
"prompt" : "template",
"title" : "用户协议和隐私政策",
"message" : "欢迎使用本应用,我们非常重视您的个人信息和隐私保护。在使用服务之前,请仔细阅读<a href='http://www.qflyqzy.net:5010/h5/#/user_agreement'>《用户协议》</a>和<a href='http://www.qflyqzy.net:5010/h5/#/privacy_agreement'>《隐私政策》</a>。我们将按照您同意的条款使用您的个人信息,以便为您提供服务。",
"message" : "欢迎使用本应用,我们非常重视您的个人信息和隐私保护。在使用服务之前,请仔细阅读<a href='http://yougou.h5.qflyqzy.net/pages/index/user_agreement'>《用户协议》</a>和<a href='http://yougou.h5.qflyqzy.net/pages/index/user_agreement'>《隐私政策》</a>。我们将按照您同意的条款使用您的个人信息,以便为您提供服务。",
"buttonAccept" : "同意并接受",
"buttonRefuse" : "退出应用",
"styles" : {
+205 -33
View File
@@ -4,6 +4,11 @@
class="image m-r-16 shrink"
:class="{ w_180: props.source === 3, h_180: props.source === 3 }"
>
<view class="corner-badge" v-if="props.source === 0 && cornerText">
<view class="corner-badge__bg"></view>
<view class="corner-badge__text">{{ cornerText }}</view>
</view>
<view v-if="showSoldOutTag" class="sold-out-tag">已售罄</view>
<image :src="props.data.picUrl" mode="scaleToFill" />
</view>
<view class="flex1 flex-column ju-between">
@@ -11,7 +16,7 @@
<view class="lineTwo size28 f500 m-b-14">
{{ props.source === 3 || props.source === 1 ? props.data.spuName : props.data.name }}
</view>
<view class="flex-center m-t-14 m-b-14" v-if="props.source === 0">
<view class="flex-center m-t-14 m-b-14" v-if="props.source === 0&&false">
<view class="flex1 m-r-28 progressCard card1">
<view class="progress"></view>
<view
@@ -33,25 +38,14 @@
</view>
<view class="stockText size24">存量:{{ props.data.stocks }}</view>
</view>
<view
class="flex-center ju-flex-start"
v-if="props.source === 0"
:style="{ opacity: show ? 0 : 1 }"
>
<view class="size24 m-r-10">
距离<span class="c15">本场{{ timeText }}</span
>仅剩
<view class="flex-row al-flex-end m-t-14" v-if="props.source === 0">
<view class="price-stock-row w100">
<view class="c13 size38 weight900">
<text class="size28">¥</text
>{{ fen2yuan(props.data.discountedPrice ? props.data.discountedPrice : props.data.price) }}
</view>
<!-- <text class="size20 c_999">存量:{{ props.data.stocks }}</text> -->
</view>
<uni-countdown
color="#FFFFFF"
background-color="#FF393A"
border-color="#FF393A"
:show-day="false"
:hour="hour"
:minute="minute"
:second="second"
@timeup="timeup"
></uni-countdown>
</view>
</view>
<view class="flex-center ju-flex-start">
@@ -83,11 +77,31 @@
</view>
</view>
</view>
<view class="flex-row ju-between">
<view class="flex-row al-flex-end">
<view class="flex-row ju-between footer-row">
<view
class="countdown-wrap"
v-if="props.source === 0"
:style="{ opacity: show ? 0 : 1 }"
>
<view class="size24 countdown-label">
距离<text>本场{{ timeText }}</text
>仅剩
</view>
<uni-countdown
color="#FFFFFF"
background-color="transparent"
border-color="transparent"
:show-day="false"
:hour="hour"
:minute="minute"
:second="second"
@timeup="timeup"
></uni-countdown>
</view>
<view class="flex-row al-flex-end" v-else>
<view class="c13 size28 weight900"
>¥
<span class="size38" v-if="props.source == 1">{{ fen2yuan(props.data.price) }}</span>
<text class="size38" v-if="props.source == 1">{{ fen2yuan(props.data.price) }}</text>
<span class="size38" v-else-if="props.source == 3">{{
fen2yuan(
props.data.discountedTotalPrice
@@ -116,10 +130,26 @@
}}</view
>
</view>
<view v-if="props.source === 0 && timeText !== '开始'">
<uni-badge :text="props.data.cartCount" absolute="rightTop" :offset="[8, 3]">
<view class="ai-button1 w_144" style="color: #fff" @click.stop="addCar">选规格</view>
<view v-if="props.source === 0 && timeText !== '开始'" class="spec-btn-wrap">
<uni-badge
v-if="!isSoldOut"
:text="props.data.cartCount"
absolute="rightTop"
:offset="[8, 3]"
>
<view
class="ai-button1 w_144"
:class="{ 'btn-soldout': isSoldOut }"
:style="isSoldOut ? 'color:#fff;' : 'color: #fff;'"
@click.stop="addCar"
>{{ isSoldOut ? '已售罄' : '选规格' }}</view>
</uni-badge>
<view
v-else
class="ai-button1 w_144 btn-soldout"
style="color:#fff"
@click.stop="addCar"
>已售罄</view>
</view>
</view>
<view v-if="props.source === 1" class="flex-center ju-flex-end m-t-12">
@@ -147,13 +177,13 @@
</view>
</template>
<script setup lang="ts">
<script setup>
import { fen2yuan } from '@/sheep/hooks/useGoods';
import { ref, onMounted, getCurrentInstance, defineProps, watch } from 'vue';
import { ref, getCurrentInstance, defineProps, watch, computed } from 'vue';
import { formatOrderStatus } from '@/sheep/hooks/useGoods';
import * as api from '@/sheep/api/ai/index';
const { proxy } = getCurrentInstance() as any;
const { proxy } = getCurrentInstance();
const props = defineProps({
data: {
@@ -172,6 +202,56 @@
default: 'id',
},
});
const cornerText = computed(() => {
const raw = String(props?.data?.shoppingPlazaName || '').trim();
if (raw !== '七数商') return '';
return raw;
});
const isSoldOut = computed(() => {
const d = props.data || {};
const stockNum = Number(
d.stock ?? d.stocks ?? d.pointStock ?? d.leftStock ?? -1,
);
if (stockNum !== -1 && !Number.isNaN(stockNum)) {
if (stockNum <= 0) return true;
}
if (Array.isArray(d.skuArr) && d.skuArr.length) {
const total = d.skuArr.reduce((s, sku) => {
const skuStock = Number(
(sku && (sku.stock ?? sku.stocks ?? sku.count ?? sku.leftStock)) ?? 0,
);
return s + (Number.isNaN(skuStock) ? 0 : skuStock);
}, 0);
if (total <= 0) return true;
}
if (Array.isArray(d.skus) && d.skus.length) {
const total = d.skus.reduce((s, sku) => {
const skuStock = Number(
(sku && (sku.stock ?? sku.stocks ?? sku.count ?? sku.leftStock)) ?? 0,
);
return s + (Number.isNaN(skuStock) ? 0 : skuStock);
}, 0);
if (total <= 0) return true;
}
if (Array.isArray(d.items1) && d.items1.length) {
const total = d.items1.reduce((s, sku) => {
const skuStock = Number(
(sku && (sku.stock ?? sku.stocks ?? sku.count ?? sku.leftStock)) ?? 0,
);
return s + (Number.isNaN(skuStock) ? 0 : skuStock);
}, 0);
if (total <= 0) return true;
}
return false;
});
const showSoldOutTag = computed(() => {
if (!isSoldOut.value) return false;
if (props.source === 0) return true;
return false;
});
let timeText = ref('结束');
let hour = ref(0);
let minute = ref(0);
@@ -272,6 +352,7 @@
}
}
const addCar = () => {
if (isSoldOut.value) return;
proxy.$emit('addCar', props.data);
};
const goInfo = () => {
@@ -311,13 +392,14 @@
</script>
<style scoped lang="scss">
.card {
background: #ffefe5;
background: #fff;
border-radius: 12rpx;
padding: 24rpx 20rpx;
box-sizing: border-box;
}
.image {
position: relative;
width: 248rpx;
height: 248rpx;
border-radius: 8rpx;
@@ -329,6 +411,42 @@
}
}
.corner-badge {
position: absolute;
left: 0;
top: 0;
width: 0;
height: 0;
z-index: 2;
}
.corner-badge__bg {
position: absolute;
left: 0;
top: 0;
width: 64rpx;
height: 64rpx;
background: linear-gradient(178deg, #ffcf70 0%, #ff8a00 100%);
clip-path: polygon(0 0, 100% 0, 0 100%);
opacity: 0.8;
}
.corner-badge__text {
position: absolute;
left: 6rpx;
top: 6rpx;
width: 35rpx;
max-height: 52rpx;
font-size: 14rpx;
line-height: 18rpx;
color: #ffffff;
font-weight: 700;
transform-origin: 0 0;
white-space: normal;
word-break: break-all;
overflow: hidden;
}
.stockText {
color: #000;
}
@@ -356,9 +474,6 @@
left: 14rpx;
}
.progress {
}
.progress1 {
width: 0%;
background: linear-gradient(90deg, #f7772e 0%, #ee0a24 98%),
@@ -375,14 +490,71 @@
width: 32rpx !important;
height: 32rpx !important;
line-height: 32rpx !important;
background: linear-gradient(
to bottom right,
var(--countdown-grad-start) 0%,
var(--countdown-grad-end) 100%
) !important;
border: 0 !important;
}
:deep(.uni-countdown__splitor) {
color: #ff393a !important;
color: var(--countdown-grad-end) !important;
}
.card {
border-radius: 16rpx;
overflow: hidden;
}
.footer-row {
align-items: center;
}
.countdown-wrap {
display: flex;
flex-direction: column;
align-items: flex-start;
}
.countdown-label {
line-height: 34rpx;
margin-bottom: 8rpx;
}
.spec-btn-wrap {
display: flex;
align-items: center;
}
.price-stock-row {
display: flex;
align-items: baseline;
justify-content: space-between;
}
.sold-out-tag {
position: absolute;
right: 0;
top: 0;
z-index: 3;
width: 108rpx;
height: 52rpx;
line-height: 52rpx;
text-align: center;
font-size: 24rpx;
font-weight: 600;
color: #ffffff;
background: rgba(0, 0, 0, 0.58);
border-radius: 0 0 0 12rpx;
backdrop-filter: blur(2px);
}
.btn-soldout {
background: #cccccc !important;
color: #ffffff !important;
filter: grayscale(100%);
cursor: not-allowed !important;
pointer-events: none !important;
}
</style>
@@ -0,0 +1,506 @@
<template>
<view class="avatar-cropper">
<view
ref="stageEl"
class="crop-stage"
@touchstart="onTouchStart"
@touchmove="onTouchMove"
@touchend="onTouchEnd"
@touchcancel="onTouchEnd"
@wheel.stop.prevent="onWheel"
@mousewheel.stop.prevent="onWheel"
>
<view class="crop-stage-inner">
<movable-area
v-if="imagePath"
class="stage-area"
:style="{ width: stageWidthPx + 'px', height: stageHeightPx + 'px' }"
>
<movable-view
class="stage-movable"
direction="all"
:out-of-bounds="true"
:x="posX"
:y="posY"
:style="{ width: drawWidthPx + 'px', height: drawHeightPx + 'px' }"
@change="onMoveChange"
>
<image class="stage-image" :src="imagePath" mode="scaleToFill" />
</movable-view>
</movable-area>
<view v-else class="empty-state flex-center" @click="chooseImage">
<view class="empty-btn">选择图片</view>
</view>
<view v-if="imagePath" class="mask-layer" :style="{ width: stageWidthPx + 'px', height: stageHeightPx + 'px' }">
<view class="mask-top" :style="{ height: cropTopPx + 'px' }"></view>
<view class="mask-middle" :style="{ height: cropSizePx + 'px' }">
<view class="mask-left" :style="{ width: cropLeftPx + 'px' }"></view>
<view class="mask-hole" :style="{ width: cropSizePx + 'px', height: cropSizePx + 'px' }"></view>
<view class="mask-right" :style="{ width: stageWidthPx - cropLeftPx - cropSizePx + 'px' }"></view>
</view>
<view class="mask-bottom" :style="{ height: stageHeightPx - cropTopPx - cropSizePx + 'px' }"></view>
<view class="crop-border" :style="{ left: cropLeftPx + 'px', top: cropTopPx + 'px', width: cropSizePx + 'px', height: cropSizePx + 'px' }"></view>
</view>
</view>
</view>
<view class="actions">
<view class="btn btn-ghost" @click="chooseImage">重新选择</view>
<view class="btn btn-primary" :class="{ disabled: !imagePath }" @click="confirmCrop">确认</view>
</view>
<canvas
canvas-id="avatarCropCanvas"
class="hidden-canvas"
:style="{ width: outputSizePx + 'px', height: outputSizePx + 'px' }"
/>
</view>
</template>
<script setup>
import { ref, computed, nextTick, getCurrentInstance, onMounted, onUnmounted, watch } from 'vue';
const props = defineProps({
src: {
type: String,
default: '',
},
outputSize: {
type: Number,
default: 600,
},
});
const emit = defineEmits(['confirm', 'error']);
const { proxy } = getCurrentInstance();
const outputSizePx = computed(() => Number(props.outputSize) || 600);
const stageEl = ref(null);
const stageDomEl = ref(null);
const cropSizePx = ref(0);
const stageWidthPx = ref(0);
const stageHeightPx = ref(0);
const imagePath = ref('');
const imgWidth = ref(0);
const imgHeight = ref(0);
const baseScale = ref(1);
const zoom = ref(1);
const minZoom = 1;
const maxZoom = 4;
const totalScale = computed(() => (baseScale.value || 1) * (zoom.value || 1));
const drawWidthPx = computed(() => Math.ceil(imgWidth.value * totalScale.value));
const drawHeightPx = computed(() => Math.ceil(imgHeight.value * totalScale.value));
const posX = ref(0);
const posY = ref(0);
const clamp = (val, min, max) => Math.min(max, Math.max(min, val));
const cropLeftPx = computed(() => Math.max(0, Math.round((stageWidthPx.value - cropSizePx.value) / 2)));
const cropTopPx = computed(() => Math.max(0, Math.round((stageHeightPx.value - cropSizePx.value) / 2)));
const calcBaseScale = () => {
if (!cropSizePx.value || !imgWidth.value || !imgHeight.value) return 1;
const sw = cropSizePx.value / imgWidth.value;
const sh = cropSizePx.value / imgHeight.value;
return Math.max(sw, sh);
};
const resetPosition = () => {
const w = drawWidthPx.value;
const h = drawHeightPx.value;
const left = cropLeftPx.value;
const top = cropTopPx.value;
const box = cropSizePx.value;
posX.value = Math.round(left + box / 2 - w / 2);
posY.value = Math.round(top + box / 2 - h / 2);
clampPosition();
};
const clampPosition = () => {
const w = drawWidthPx.value;
const h = drawHeightPx.value;
const left = cropLeftPx.value;
const top = cropTopPx.value;
const box = cropSizePx.value;
const minX = Math.round(left + box - w);
const maxX = Math.round(left);
const minY = Math.round(top + box - h);
const maxY = Math.round(top);
posX.value = clamp(posX.value, minX, maxX);
posY.value = clamp(posY.value, minY, maxY);
};
const measureStage = async () => {
const rect = await new Promise((resolve) => {
uni
.createSelectorQuery()
.in(proxy)
.select('.crop-stage-inner')
.boundingClientRect((r) => resolve(r))
.exec();
}).catch(() => null);
if (!rect) return;
stageWidthPx.value = Math.max(1, Math.round(Number(rect.width) || 0));
stageHeightPx.value = Math.max(1, Math.round(Number(rect.height) || 0));
};
const loadImage = async (src) => {
if (!src) return;
const info = await new Promise((resolve, reject) => {
uni.getImageInfo({
src,
success: resolve,
fail: reject,
});
}).catch(() => null);
if (!info) {
emit('error', 'getImageInfo_failed');
return;
}
imagePath.value = src;
imgWidth.value = Number(info.width) || 0;
imgHeight.value = Number(info.height) || 0;
zoom.value = 1;
baseScale.value = calcBaseScale();
await nextTick();
await measureStage();
resetPosition();
};
const chooseImage = () => {
uni.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
success: async (res) => {
const filePath = res?.tempFilePaths?.[0] || '';
if (!filePath) return;
await loadImage(filePath);
},
fail: () => {},
});
};
const onMoveChange = (e) => {
if (!e?.detail) return;
posX.value = Math.round(Number(e.detail.x) || 0);
posY.value = Math.round(Number(e.detail.y) || 0);
clampPosition();
};
const pinchState = ref({
active: false,
startDist: 0,
startZoom: 1,
});
const getTouchDist = (touches) => {
if (!touches || touches.length < 2) return 0;
const t1 = touches[0];
const t2 = touches[1];
const dx = Number(t2.clientX) - Number(t1.clientX);
const dy = Number(t2.clientY) - Number(t1.clientY);
return Math.sqrt(dx * dx + dy * dy);
};
const onTouchStart = (e) => {
const touches = e?.touches || [];
if (touches.length !== 2) return;
pinchState.value = {
active: true,
startDist: getTouchDist(touches),
startZoom: zoom.value,
};
};
const onTouchMove = (e) => {
const touches = e?.touches || [];
if (!pinchState.value.active || touches.length !== 2) return;
const dist = getTouchDist(touches);
if (!dist || !pinchState.value.startDist) return;
const nextZoom = clamp(pinchState.value.startZoom * (dist / pinchState.value.startDist), minZoom, maxZoom);
if (Math.abs(nextZoom - zoom.value) < 0.001) return;
applyZoom(nextZoom);
};
const onTouchEnd = () => {
pinchState.value.active = false;
};
const onWheel = (e) => {
if (!imagePath.value) return;
let dy = 0;
if (typeof e?.deltaY === 'number' && e.deltaY) {
dy = e.deltaY;
} else if (typeof e?.detail?.deltaY === 'number' && e.detail.deltaY) {
dy = e.detail.deltaY;
} else if (typeof e?.wheelDelta === 'number' && e.wheelDelta) {
dy = -e.wheelDelta;
} else if (typeof e?.detail?.wheelDelta === 'number' && e.detail.wheelDelta) {
dy = -e.detail.wheelDelta;
} else if (typeof e?.detail === 'number' && e.detail) {
dy = e.detail;
}
if (!dy) return;
const factor = dy > 0 ? 0.92 : 1.08;
applyZoom(clamp(zoom.value * factor, minZoom, maxZoom));
};
const applyZoom = (nextZoom) => {
if (!imagePath.value) return;
const prevScale = totalScale.value || 1;
const nextScale = (baseScale.value || 1) * (nextZoom || 1);
const left = cropLeftPx.value;
const top = cropTopPx.value;
const box = cropSizePx.value;
const centerX = left + box / 2;
const centerY = top + box / 2;
const imgX = (centerX - posX.value) / prevScale;
const imgY = (centerY - posY.value) / prevScale;
zoom.value = nextZoom;
posX.value = Math.round(centerX - imgX * nextScale);
posY.value = Math.round(centerY - imgY * nextScale);
nextTick(() => clampPosition());
};
const confirmCrop = async () => {
if (!imagePath.value) return;
clampPosition();
await nextTick();
const box = cropSizePx.value;
const left = cropLeftPx.value;
const top = cropTopPx.value;
const scale = totalScale.value || 1;
const sx = Math.max(0, Math.round(((left - posX.value) / scale) * 1000) / 1000);
const sy = Math.max(0, Math.round(((top - posY.value) / scale) * 1000) / 1000);
const sWidth = Math.min(imgWidth.value, Math.round((box / scale) * 1000) / 1000);
const sHeight = Math.min(imgHeight.value, Math.round((box / scale) * 1000) / 1000);
const ctx = uni.createCanvasContext('avatarCropCanvas', proxy);
ctx.clearRect(0, 0, outputSizePx.value, outputSizePx.value);
ctx.drawImage(imagePath.value, sx, sy, sWidth, sHeight, 0, 0, outputSizePx.value, outputSizePx.value);
ctx.draw(false, () => {
uni.canvasToTempFilePath(
{
canvasId: 'avatarCropCanvas',
width: outputSizePx.value,
height: outputSizePx.value,
destWidth: outputSizePx.value,
destHeight: outputSizePx.value,
fileType: 'jpg',
quality: 0.92,
success: (res) => {
const tempFilePath = res?.tempFilePath || '';
if (!tempFilePath) {
emit('error', 'canvasToTempFilePath_empty');
return;
}
emit('confirm', tempFilePath);
},
fail: () => emit('error', 'canvasToTempFilePath_failed'),
},
proxy,
);
});
};
onMounted(() => {
const sys = uni.getSystemInfoSync();
const w = Number(sys.windowWidth) || 375;
cropSizePx.value = Math.floor(w * 0.78);
if (cropSizePx.value < 220) cropSizePx.value = 220;
if (cropSizePx.value > 360) cropSizePx.value = 360;
nextTick(() => measureStage());
if (props.src) loadImage(props.src);
const el = stageEl.value?.$el || stageEl.value;
stageDomEl.value = el || null;
if (el && typeof el.addEventListener === 'function') {
const handler = (evt) => {
try {
evt.preventDefault && evt.preventDefault();
evt.stopPropagation && evt.stopPropagation();
} catch (e) {}
onWheel(evt);
};
el.__avatarCropWheelHandler = handler;
el.addEventListener('wheel', handler, { passive: false });
el.addEventListener('mousewheel', handler, { passive: false });
}
});
onUnmounted(() => {
const el = stageDomEl.value || stageEl.value?.$el || stageEl.value;
const handler = el && el.__avatarCropWheelHandler;
if (el && handler && typeof el.removeEventListener === 'function') {
el.removeEventListener('wheel', handler);
el.removeEventListener('mousewheel', handler);
try {
delete el.__avatarCropWheelHandler;
} catch (e) {}
}
});
watch(
() => cropSizePx.value,
() => {
if (!imagePath.value) return;
baseScale.value = calcBaseScale();
nextTick(() => {
measureStage();
resetPosition();
});
},
);
watch(
() => [stageWidthPx.value, stageHeightPx.value, zoom.value],
() => {
if (!imagePath.value) return;
nextTick(() => clampPosition());
},
);
</script>
<style lang="scss" scoped>
.avatar-cropper {
width: 100%;
height: 100%;
box-sizing: border-box;
padding: 30rpx 32rpx 40rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
}
.crop-stage {
width: 100%;
flex: 1;
display: flex;
align-items: center;
justify-content: center;
}
.crop-stage-inner {
width: 100%;
height: 100%;
position: relative;
border-radius: 18rpx;
overflow: hidden;
background: #000;
}
.stage-area {
position: relative;
background: #000;
}
.stage-movable {
position: absolute;
left: 0;
top: 0;
}
.stage-image {
width: 100%;
height: 100%;
}
.mask-layer {
position: absolute;
left: 0;
top: 0;
pointer-events: none;
}
.mask-top,
.mask-bottom {
width: 100%;
background: rgba(0, 0, 0, 0.45);
}
.mask-middle {
width: 100%;
display: flex;
flex-direction: row;
}
.mask-left,
.mask-right {
height: 100%;
background: rgba(0, 0, 0, 0.45);
}
.mask-hole {
background: transparent;
}
.crop-border {
position: absolute;
border: 2rpx solid rgba(255, 255, 255, 0.95);
box-sizing: border-box;
}
.empty-state {
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.65);
}
.empty-btn {
padding: 18rpx 28rpx;
border-radius: 999rpx;
background: rgba(255, 255, 255, 0.18);
color: #fff;
font-size: 28rpx;
}
.actions {
width: 100%;
display: flex;
gap: 24rpx;
margin-top: 28rpx;
}
.btn {
flex: 1;
height: 84rpx;
border-radius: 16rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 30rpx;
font-weight: 600;
box-sizing: border-box;
}
.btn-ghost {
background: transparent;
color: rgba(153, 153, 153, 1);
border: 2rpx solid rgba(220, 220, 220, 1);
}
.btn-primary {
background: #2556ec;
color: #ffffff;
}
.btn-primary.disabled {
opacity: 0.5;
}
.hidden-canvas {
position: absolute;
left: -9999px;
top: -9999px;
}
</style>
+21 -7
View File
@@ -1,14 +1,15 @@
<template>
<l-echart ref="chartRef"></l-echart>
<l-echart ref="chartRef" class="chart"></l-echart>
</template>
<script setup lang="ts">
<script setup>
import { onMounted, ref, onBeforeUnmount, nextTick, watch } from 'vue';
import * as echarts from 'echarts';
const chartRef = ref(null)
const myChart = ref(null)
let hasSetOption = false
const props = defineProps({
options: {
@@ -21,14 +22,19 @@
const initChart = async () => {
if (!chartRef.value) return
// 初始化echart
myChart.value = await chartRef.value.init(echarts)
if (!myChart.value) {
myChart.value = await chartRef.value.init(echarts)
}
// 默认获取容器尺寸
myChart.value.resize();
// 设置true清空echart缓存
myChart.value?.setOption(props.options, true);
if (!hasSetOption) {
myChart.value?.setOption(props.options, true);
hasSetOption = true
return
}
myChart.value?.setOption(props.options);
}
@@ -55,6 +61,14 @@
onBeforeUnmount(() => {
if (myChart.value) {
echarts.dispose(myChart.value);
myChart.value = null;
}
});
</script>
</script>
<style scoped>
.chart {
width: 100%;
height: 100%;
}
</style>
+7 -5
View File
@@ -101,6 +101,7 @@
mobile: '',
detailAddress: '',
defaultStatus: false,
areaId: null,
areaName: '',
},
rules: {},
@@ -119,7 +120,7 @@
errorMessage: '请输入手机号',
}, ],
},
areaName: {
areaId: {
rules: [{
required: true,
errorMessage: '请选择您的位置',
@@ -135,8 +136,10 @@
// 确认选择地区
const onRegionConfirm = (e) => {
state.model.areaName = `${e.province_name} ${e.city_name} ${e.district_name} ${e.street_name}`;
state.model.areaId = e.street_id;
state.model.areaName = [e.province_name, e.city_name, e.district_name, e.street_name]
.filter(Boolean)
.join(' ');
state.model.areaId = e.street_id ?? e.district_id ?? e.city_id ?? e.province_id ?? null;
state.showRegion = false;
};
@@ -263,7 +266,6 @@
onEdit,
});
const regionClick = (e) => {
console.log('111')
if (e.value == 'areaName') {
state.showRegion = true;
}
@@ -389,4 +391,4 @@
:deep(.is-disabled){
background-color: #ffffff !important;
}
</style>
</style>
+16 -6
View File
@@ -1,23 +1,26 @@
<template>
<view class="cardTitle p-x-20 cardBg" :style="{ height: statusBarHeight + 44 + 'px' }">
<view class="cardTitle p-x-20 cardBg" :style="[{ height: statusBarHeight + 44 + 'px' }, { backgroundColor: props.bg }]">
<view :style="{ height: statusBarHeight + 'px' }"></view>
<view class="flex-center ju-between h_88">
<view class="cardLeft" v-if="props.showLeftButton">
<view @tap="onClickLeft">
<view class="cardLeft" v-if="props.showLeftButton || $slots.left">
<view v-if="props.showLeftButton" @tap="onClickLeft">
<uni-icons type="left" :color="textColor" />
</view>
<slot name="left" />
</view>
<view class="title size36 flex1 center" :style="[{ color: textColor }]">{{
props.title
}}</view>
<view> </view>
<view class="cardRight" :style="{ color: textColor }">
<slot name="right" />
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { getCurrentInstance, defineProps, defineEmits, ref } from 'vue';
import { onPageScroll } from '@dcloudio/uni-app';
// import { onPageScroll } from '@dcloudio/uni-app';
import sheep from '@/sheep';
const { proxy } = getCurrentInstance() as any;
let props = defineProps({
@@ -91,7 +94,7 @@
}
.cardBg {
// 背景图片顶部显示, 超出部分隐藏, 宽等于100%
background-color: #ffffff;
background-color: transparent;
}
:deep(.uniui-left) {
font-size: 44rpx !important;
@@ -102,4 +105,11 @@
left: 20rpx;
transform: translateY(50%);
}
.cardRight {
position: absolute;
bottom: 44rpx;
right: 20rpx;
transform: translateY(50%);
}
</style>
+13 -2
View File
@@ -2,12 +2,16 @@
<view class="cardTitle p-x-20" :style="{ background: backgroundColor }">
<view :style="{height: statusBarHeight + 'px'}"></view>
<view class="flex-center ju-between h_88">
<view class="cardLeft" v-if="props.showLeftButton">
<view @tap="onClickLeft">
<view class="cardLeft" v-if="props.showLeftButton || $slots.left">
<view v-if="props.showLeftButton" @tap="onClickLeft">
<uni-icons type="left" :color="textColor" />
</view>
<slot name="left" />
</view>
<view class="title size36 flex1 center" :style="[{ color: textColor }]">{{ props.title }}</view>
<view class="cardRight" :style="{ color: textColor }">
<slot name="right" />
</view>
</view>
</view>
</template>
@@ -111,4 +115,11 @@
left: 20rpx;
transform: translateY(50%);
}
.cardRight {
position: absolute;
bottom: 44rpx;
right: 20rpx;
transform: translateY(50%);
}
</style>
+14 -3
View File
@@ -2,12 +2,16 @@
<view class="cardTitle p-x-20">
<view :style="{height: statusBarHeight + 'px'}"></view>
<view class="flex-center ju-between h_88">
<view class="cardLeft" v-if="props.showLeftButton">
<view @tap="onClickLeft">
<view class="cardLeft" v-if="props.showLeftButton || $slots.left">
<view v-if="props.showLeftButton" @tap="onClickLeft">
<uni-icons type="left" :color="textColor" />
</view>
<slot name="left" />
</view>
<view class="title size36 flex1 center" :style="[{ color: textColor }]">{{ props.title }}</view>
<view class="cardRight" :style="{ color: textColor }">
<slot name="right" />
</view>
</view>
</view>
</template>
@@ -123,4 +127,11 @@
left: 20rpx;
transform: translateY(50%);
}
</style>
.cardRight {
position: absolute;
bottom: 44rpx;
right: 20rpx;
transform: translateY(50%);
}
</style>
+385 -201
View File
@@ -1,213 +1,397 @@
<template>
<view class="flex-center" :class="{
<view
class="flex-center"
:class="{
'ju-flex-end': props.type == 2,
'ju-between': props.type != 2,
}">
<view class="more size24" v-if="props.type != 2"></view>
<view class="flex-center ju-flex-end">
<view v-for="(item, index) in btns" :key="index">
<view v-if="item.value.split(',').indexOf(String(props?.data?.status)) !== -1" class="btn size28 f500"
@click.stop="btnClick(item.id)"
:style="{ color: item.color, background: item.background, border: item.border }"
:class="{btn1: props.type == 2}">
{{ item.name }}
</view>
</view>
</view>
</view>
}"
>
<view class="more size24" v-if="props.type != 2"></view>
<view class="flex-center ju-flex-end">
<view
v-if="showRemind"
class="btn size28 f500 remind-btn"
@click.stop="btnClick(7)"
>
催一催
</view>
<view
v-if="showModifyDeliveryBtn"
class="btn size28 f500 modify-delivery-btn"
@click.stop="btnClick(13)"
>
修改配送
</view>
<view v-for="(item, index) in btns" :key="index">
<view
v-if="
shouldShowBtn(item)
"
class="btn size28 f500"
@click.stop="btnClick(item.id)"
:style="{ color: item.color, background: item.background, border: item.border }"
:class="{ btn1: props.type == 2 }"
>
{{ item.name }}
</view>
</view>
</view>
</view>
</template>
<script setup>
import {
ref,
getCurrentInstance,
defineProps,
defineEmits
} from 'vue';
import sheep from '@/sheep';
import OrderApi from '@/sheep/api/trade/order';
const {
proxy
} = getCurrentInstance();
import { computed } from 'vue';
import { ref, getCurrentInstance, defineProps, defineEmits } from 'vue';
import sheep from '@/sheep';
import OrderApi from '@/sheep/api/trade/order';
const { proxy } = getCurrentInstance();
let emit = defineEmits(['downData']);
const props = defineProps({
data: {
type: Object,
default () {
return {};
},
},
type: {
type: String,
default: '0', //0列表2订单详情
},
});
let btns = ref([{
id: 1,
name: '取消订单',
value: '0',
},
{
id: 2,
name: '去付款',
value: '0',
color: '#EE0A24',
background: 'rgba(238,10,36,0.2)',
border: 'none'
},
// { //在订单详情退货
// id: 3,
// name: '申请售后',
// value: '10,20',
// },
{
id: 4,
name: '确认收货',
value: '20,60',
color: '#EE0A24',
background: 'rgba(238,10,36,0.2)',
border: 'none'
},
// {
// id: 5,
// name: '再次购买',
// value: '30,50,40',
// color: '#FA9C31',
// },
{
id: 6,
name: '取消售后',
value: '60',
},
]);
const btnClick = (index) => {
let timestamp = new Date().getTime();
let payExpireTime = props.data.payExpireTime
if (timestamp > payExpireTime && props.data.status == 0 && index == 2) {
uni.showToast({
title: '订单已过期',
icon: 'none'
});
return;
}
let id = props.data?.id;
switch (index) {
case 1:
cancelOrder();
break;
case 2:
payOrder(id);
break;
case 3:
applyAfterSale();
break;
case 4:
confirmReceive();
break;
case 5:
buyAgain();
break;
case 6:
cancelAfterSale();
break;
}
};
// 取消订单
const cancelOrder = () => {
let orderId = props.data?.id;
uni.showModal({
title: '提示',
content: '确定要取消订单吗?',
confirmColor: '#FA7E31',
success: async function(res) {
if (!res.confirm) {
return;
}
let emit = defineEmits(['downData', 'remind']);
const props = defineProps({
data: {
type: Object,
default() {
return {};
},
},
type: {
type: String,
default: '0', //0列表2订单详情
},
});
upData();
const {
code
} = await OrderApi.cancelOrder(orderId);
if (code === 0) {
uni.showToast({
title: '订单已取消',
icon: 'none'
});
upData();
}
},
});
};
// 去付款
const payOrder = (id) => {
sheep.$router.go('/pages/pay/index', {
id: props.data.payOrderId,
});
};
// 申请售后
const applyAfterSale = () => {
sheep.$router.go('/pages/order/aftersale/apply', props.data);
};
// 确认收货
const confirmReceive = () => {
let change = false
if (props.data?.items.length) {
props.data.items.forEach(item => {
if (item.afterSaleStatus == 10) {
change = true
return
}
})
}
if (change) {
uni.showToast({
title: '有售后中的商品,请先处理完售后',
icon: 'none'
})
return
}
uni.showModal({
title: '提示',
content: '确认收货吗?',
confirmColor: '#FA7E31',
success: async function(res) {
if (!res.confirm) {
return;
}
// 正常的确认收货流程
const {
code
} = await OrderApi.receiveOrder(props.data?.id);
if (code === 0) {
upData();
}
},
});
};
// 再次购买
const buyAgain = () => {};
// 取消售后
const cancelAfterSale = () => {};
const upData = () => {
emit('downData');
};
// 订单级 refundStatus:0 未退款 / 10 部分退款 / 20 全部退款
// 用户需求:如果是 20(全部退款),就不要展示"申请售后"按钮了。
const refundStatus = computed(() => {
const v = props.data?.refundStatus === undefined ? props.data?.refund_status : props.data?.refundStatus;
return Number(v) || 0;
});
const isAllRefunded = computed(() => refundStatus.value === 20);
const isVerifyCompleted = computed(() => {
const info = props.data || {};
const status = Number(info?.status);
return Boolean(
info?.pickUpVerifyTime ||
info?.verifyTime ||
info?.completedTime ||
status === 30 ||
status === 3,
);
});
const resolveStage = () => {
const data = props.data || {};
const external = Number(data?.preparationStatus);
const rawStatus = Number.isFinite(external) ? external : Number(data?.preparationStatus ?? data?.status ?? 0);
if (isVerifyCompleted.value) return 'done';
if (rawStatus === 1 || rawStatus === 2) return 'wait';
if (
data?.deliveryTime ||
data?.arriveStoreTime ||
data?.deliveredTime ||
rawStatus === 20
) {
return 'delivered';
}
return 'sorting';
};
const isSorting = computed(() => resolveStage() === 'sorting');
const showRemind = computed(() => {
const info = props.data || {};
return (
Number(info?.deliveryType) === 2 &&
Boolean(info?.payStatus) &&
!isVerifyCompleted.value &&
isSorting.value
);
});
const isThirdPartyOrder = computed(() => {
const d = props.data || {};
if (d.thirdPartyOrder === true || d.thirdPartyOrder === 'true' || d.thirdPartyOrder === 1) {
return true;
}
const items = Array.isArray(d.items) ? d.items : [];
return items.some(
(it) => it.thirdPartyOrder === true || it.thirdPartyOrder === 'true' || it.thirdPartyOrder === 1,
);
});
const showModifyDeliveryBtn = computed(() => {
if (!isThirdPartyOrder.value) return false;
const d = props.data || {};
const canUpdate = d.canUpdateDeliveryType === true || d.canUpdateDeliveryType === 'true' || d.canUpdateDeliveryType === 1;
if (!canUpdate) return false;
return String(d?.status) === '10';
});
const shouldShowBtn = (item) => {
if (item.id !== 3 && item.value.split(',').indexOf(String(props?.data?.status)) === -1) {
return false;
}
if (item.id === 3 && Number(props?.data?.type) === 5) return false;
if (item.id === 3 && props?.data?.payChannelCode === 'cash_payment') return false;
if (item.id === 3 && isAllRefunded.value) return false;
if (Number(props.data?.deliveryType) === 2 && [4, 8, 11].includes(item.id)) {
return false;
}
return true;
};
let btns = ref([
{
id: 1,
name: '取消订单',
value: '0,70',
},
{
id: 2,
name: '去付款',
value: '0',
color: '#EE0A24',
background: 'rgba(238,10,36,0.2)',
border: 'none',
},
{
//在订单详情退货
id: 3,
name: '申请售后',
value: '10,20',
},
{
id: 4,
name: '确认收货',
value: '20,60',
color: '#EE0A24',
background: 'rgba(238,10,36,0.2)',
border: 'none',
},
{
id: 5,
name: '再次购买',
value: '30,50,40',
color: '#FA9C31',
},
{
id: 6,
name: '取消售后',
value: '60',
},
{
id: 8,
name: '删除订单',
value: '40',
},
]);
const btnClick = (index) => {
let timestamp = new Date().getTime();
let payExpireTime = props.data.payExpireTime;
if (timestamp > payExpireTime && props.data.status == 0 && index == 2) {
uni.showToast({
title: '订单已过期',
icon: 'none',
});
return;
}
if (index === 3 && Number(props?.data?.type) === 5) {
return;
}
// 全单已退款(refundStatus===20):保险层面禁止再次发起申请售后
if (index === 3 && isAllRefunded.value) {
uni.showToast({ title: '该订单已全部退款,无需再次申请售后', icon: 'none' });
return;
}
if (index === 3) {
return;
}
let id = props.data?.id;
switch (index) {
case 1:
cancelOrder();
break;
case 2:
payOrder(id);
break;
case 3:
applyAfterSale();
break;
case 4:
confirmReceive();
break;
case 5:
buyAgain();
break;
case 6:
cancelAfterSale();
break;
case 7:
remindStore();
break;
case 8:
deleteOrder();
break;
case 13:
goModifyDelivery();
break;
}
};
// 取消订单
const cancelOrder = () => {
let orderId = props.data?.id;
uni.showModal({
title: '提示',
content: '确定要取消订单吗?',
confirmColor: '#FA7E31',
success: async function (res) {
if (!res.confirm) {
return;
}
upData();
const { code } = await OrderApi.cancelOrder(orderId);
if (code === 0) {
uni.showToast({
title: '订单已取消',
icon: 'none',
});
upData();
}
},
});
};
const deleteOrder = () => {
const orderId = props.data?.id;
uni.showModal({
title: '提示',
content: '确定要删除订单吗?',
confirmColor: '#FA7E31',
success: async function (res) {
if (!res.confirm) {
return;
}
const { code } = await OrderApi.deleteOrder(orderId);
if (code === 0) {
uni.showToast({
title: '订单已删除',
icon: 'none',
});
upData();
}
},
});
};
// 去付款
const payOrder = (id) => {
sheep.$router.go('/pages/pay/index', {
id: props.data.payOrderId,
});
};
// 申请售后
const applyAfterSale = () => {
const __src = String(props?.data?.__source || props?.data?.source || '').trim();
const __ty = String(props?.data?.type || '').trim();
// 避免把整个订单对象里的同名字段 type/source/__source 直接展开污染 query(
// 否则普通商城订单也可能因为 data.type=5(或商城订单里的其他数字type)在 apply.vue 里误走 ai 接口)。
sheep.$router.go('/pages/order/aftersale/apply', {
id: props?.data?.id,
orderId: props?.data?.id,
no: props?.data?.no,
...(__src ? { source: __src } : {}),
...(__ty ? { openOrderType: __ty } : {}),
});
};
// 确认收货
const confirmReceive = () => {
let change = false;
if (props.data?.items.length) {
props.data.items.forEach((item) => {
if (item.afterSaleStatus == 10) {
change = true;
return;
}
});
}
if (change) {
uni.showToast({
title: '有售后中的商品,请先处理完售后',
icon: 'none',
});
return;
}
uni.showModal({
title: '提示',
content: '确认收货吗?',
confirmColor: '#FA7E31',
success: async function (res) {
if (!res.confirm) {
return;
}
// 正常的确认收货流程
const { code } = await OrderApi.receiveOrder(props.data?.id);
if (code === 0) {
upData();
}
},
});
};
// 再次购买
const buyAgain = () => {};
// 取消售后
const cancelAfterSale = () => {};
// 催一催
const remindStore = async () => {
emit('remind');
};
const upData = () => {
emit('downData');
};
const goModifyDelivery = () => {
const id = props.data?.orderId || props.data?.id;
if (!id) return;
const params = {
id,
orderTypeId: 1,
currentType: 0,
};
if (props.data?.type !== undefined && props.data?.type !== null) {
params.type = props.data.type;
}
if (props.data?.__source) {
params.source = props.data.__source;
}
sheep.$router.go('/pages/order/modifyDelivery', params);
};
</script>
<style scoped lang="scss">
.more {}
.more {
}
.btn {
line-height: 54rpx;
padding: 0 24rpx;
box-sizing: border-box;
border: 2rpx solid #999999;
border-radius: 94px 94px 94px 94px;
margin-left: 12rpx;
color: #999999;
}
.btn {
line-height: 24rpx;
padding: 10rpx 24rpx;
box-sizing: border-box;
border: 2rpx solid #999999;
border-radius: 10rpx;
margin-left: 12rpx;
color: #999999;
}
.btn1 {
line-height: 74rpx;
padding: 0 30rpx;
}
</style>
.btn1 {
// line-height: 74rpx;
// padding: 0 30rpx;
}
.remind-btn {
color: #2556ec;
background: rgba(37, 86, 236, 0.08);
border: 2rpx solid rgba(37, 86, 236, 0.28);
}
.modify-delivery-btn {
color: #1677FF;
background: rgba(22, 119, 255, 0.06);
border: 2rpx solid rgba(22, 119, 255, 0.28);
}
</style>
+7 -2
View File
@@ -123,12 +123,17 @@
*
* @param state 布尔值,表示 Mescroll 组件的状态,默认为 true
* @param num 数字,表示数据长度,默认为 0
* @param total 数字,表示总条数(可选)。传入后会使用 endBySize 精确判断是否还有下一页
*/
const getState = (state = true, num = 0) => {
const getState = (state = true, num = 0, total) => {
const mescroll = getMescroll();
if (state) {
mescroll.endSuccess(num);
if (Number.isFinite(Number(total))) {
mescroll.endBySize(num, Number(total));
} else {
mescroll.endSuccess(num);
}
} else {
mescroll.endErr();
}
+50 -19
View File
@@ -1,6 +1,10 @@
<template>
<view>
<view class="card_payment flex-center ju-between bg16 h_128 p-l-34 p-r-40">
<view
v-if="barVisible"
class="card_payment flex-center ju-between bg16 h_128 p-l-34 p-r-40"
:style="{ bottom: props.bottomOffset + 'px' }"
>
<view class="flex-center ju-flex-start flex1" @click="showPopup">
<uni-badge :text="num" absolute="rightTop" :offset="[13, 6]">
<view class="w_80 h_80 m-r-24">
@@ -12,7 +16,7 @@
</view>
<view class="ai-button1 h_80 line80 w_200" @click="go"> 去结算 </view>
</view>
<uni-popup ref="popupRef" type="bottom" border-radius="10px 10px 0 0">
<uni-popup ref="popupRef" type="bottom" border-radius="10px 10px 0 0" @change="onPopupChange">
<view class="p-x-32 p-y-40 bg17">
<view class="flex-center ju-between p-b-44">
<view>已加购商品</view>
@@ -71,6 +75,7 @@
</view>
<view class="ai-button1 h_80 line80 w_200" @click="go"> 去结算 </view>
</view>
<view class="popupSpacer" :style="{ height: popupSpacerHeight + 'px' }"></view>
</view>
</uni-popup>
@@ -81,7 +86,7 @@
</template>
<script setup lang="ts">
import { ref, getCurrentInstance, onMounted, defineProps, watch } from 'vue';
import { ref, computed, getCurrentInstance, onMounted, defineProps, watch } from 'vue';
import CartApi from '@/sheep/api/trade/cart.js';
import * as SpuApi from '@/sheep/api/ai/index';
import { onShow } from '@dcloudio/uni-app';
@@ -105,19 +110,23 @@
minSalesCountShow: {
type: Boolean,
default: false
},
bottomOffset: {
type: Number,
default: 0
}
});
const safeAreaBottom = Number(uni.getSystemInfoSync()?.safeAreaInsets?.bottom || 0);
const popupOpened = ref(false);
const popupBottomInsetPx = ref(0);
const popupSpacerHeight = computed(() => Math.max(0, Number(popupBottomInsetPx.value) || 0));
const cartList = ref([]);
let price = ref(0);
let num = ref(0);
let addShow1 = ref(false)
watch(() => props.addShow, () => {
addShow1.value = props.addShow
}, {
immediate: true,
deep: true
})
const getCartList = (val : any = true) => {
const barVisible = computed(() => Array.isArray(cartList.value) && cartList.value.length > 0);
const getCartList = () => {
num.value = 0;
price.value = 0;
SpuApi.getShopCartList({}).then((res) => {
@@ -136,14 +145,9 @@
});
price.value += e.discountedPrice;
});
addShow1.value = true
} else {
if (!val) {
addShow1.value = false
}
}
cartList.value = list;
proxy.$emit('updatePrice', addShow1.value);
proxy.$emit('updatePrice', list.length > 0);
});
};
@@ -151,15 +155,38 @@
getCartList();
});
let popupRef = ref(null);
const resolvePopupBottomInsetPx = () => {
return Math.max(0, (Number(props.bottomOffset) || 0) - safeAreaBottom);
};
const onPopupChange = (e: any) => {
popupOpened.value = !!e?.show;
if (popupOpened.value) {
popupBottomInsetPx.value = resolvePopupBottomInsetPx();
} else {
popupBottomInsetPx.value = 0;
}
};
const showPopup = () => {
if (!popupRef.value) return;
popupOpened.value = true;
popupBottomInsetPx.value = resolvePopupBottomInsetPx();
popupRef.value.open('bottom');
};
const hidePopup = () => {
popupOpened.value = false;
popupBottomInsetPx.value = 0;
popupRef.value.close();
};
onMounted(() => { });
watch(
() => cartList.value?.length,
(len) => {
if (popupOpened.value && (!len || len <= 0)) {
hidePopup();
}
},
);
//#region 选择规格弹窗
let showSelectSku = ref(false);
let goodsInfo = ref({});
@@ -242,7 +269,7 @@
// 删除接口
SpuApi.deleteShopCart({ id: v.id }).then((res) => {
if (res.code === 0) {
getCartList(false);
getCartList();
proxy.$emit('updataList');
}
});
@@ -331,4 +358,8 @@
.popupBottom {
box-shadow: 0px 0px 18px 0px rgba(0, 0, 0, 0.04);
}
</style>
.popupSpacer {
width: 100%;
}
</style>
+270 -38
View File
@@ -1,47 +1,279 @@
<template>
<view class="card_tabber">
</view>
<view class="tabbar-wrap">
<view class="tabbar safe-bottom">
<!-- :src="bgSrc" -->
<image class="tabbar-bg" mode="scaleToFill" />
<view class="tabbar-inner">
<view
v-for="item in items"
:key="item.pagePath"
class="tabbar-item flex1 flex-center flex-column"
:class="{ 'tabbar-item--mid': item.isMid }"
@click="onTap(item)"
>
<view :class="{ iconBox: item.isMid }">
<image
class="icon"
:class="{ iconMid: item.isMid }"
:src="getIconSrc(item)"
mode="aspectFit"
/>
</view>
<view v-if="item.text" class="s_20 text" :class="{ textActive: isActive(item) }">
{{ item.text }}
</view>
</view>
</view>
</view>
<view v-if="props.placeholder" class="tabbar-placeholder safe-bottom"></view>
</view>
</template>
<script setup>
import {ref} from 'vue'
import { computed, ref, watch } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import * as AiApi from '@/sheep/api/ai/index';
const tabber = ref({
items: [
{
text: '首页',
url: '/pages/index/index',
iconUrl: proxy.$url+'index/1.svg',
activeIconUrl: proxy.$url+'index/1_1.svg',
const props = defineProps({
path: {
type: String,
default: '',
},
placeholder: {
type: Boolean,
default: false,
},
});
const currentPath = ref('');
const normalizePath = (p) => {
if (!p) return '';
return p.startsWith('/') ? p : `/${p}`;
};
const updateCurrentPath = () => {
const pages = getCurrentPages?.() || [];
const current = pages[pages.length - 1];
const route = current?.route || '';
currentPath.value = normalizePath(route);
};
const hideNativeTabBar = () => {
try {
uni.hideTabBar({
fail: () => {},
});
} catch (e) {}
};
onShow(() => {
hideNativeTabBar();
updateCurrentPath();
});
watch(
() => props.path,
(val) => {
if (val) currentPath.value = normalizePath(val);
},
{ immediate: true },
);
const items = computed(() => [
{
pagePath: '/pages/index/index',
text: '首页',
iconPath: '/static/index/1.png',
selectedIconPath: '/static/index/blue_icon/1_1.png',
},
{
pagePath: '/pages/index/aiStore',//'/pages/AI/member',//
text: 'AI店铺',
iconPath: '/static/index/2.png',
selectedIconPath: '/static/index/blue_icon/2_1.png',
},
// {
// pagePath: '/pages/home/seed',
// text: '',
// iconPath: '/static/index/jinzhongzi.png',
// selectedIconPath: '/static/index/jinzhongzi.png',
// isMid: true,
// },
// {
// pagePath: '/pages/cart/cart',
// text: '购物车',
// iconPath: '/static/index/3.png',
// selectedIconPath: '/static/index/blue_icon/3_1.png',
// },
{
pagePath: '/pages/index/user',
text: '我的',
iconPath: '/static/index/4.png',
selectedIconPath: '/static/index/blue_icon/4_1.png',
},
]);
const isActive = (item) => {
return normalizePath(item.pagePath) === normalizePath(currentPath.value);
};
const getIconSrc = (item) => {
return isActive(item) ? item.selectedIconPath : item.iconPath;
};
const aiShopStatus = ref({
value: null,
checkedAt: 0,
});
const ensureAiShopOpened = async () => {
const now = Date.now();
if (aiShopStatus.value.value !== null && now - aiShopStatus.value.checkedAt < 60 * 1000) {
return Boolean(aiShopStatus.value.value);
}
const res = await AiApi.checkShopStatus({});
if (res?.code !== 0) {
throw new Error('checkShopStatus_failed');
}
const opened = Boolean(res?.data);
aiShopStatus.value = {
value: opened ? 1 : 0,
checkedAt: now,
};
return opened;
};
const onTap = async (item) => {
if (item.isMid) {
hideNativeTabBar();
uni.navigateTo({ url: item.pagePath });
return;
}
if (isActive(item)) return;
if (normalizePath(item.pagePath) === '/pages/index/aiStore') {
try {
const opened = await ensureAiShopOpened();
if (!opened) {
uni.showToast({
title: '您尚未开通AI店铺,无法查看购物车。请先开通AI店铺后再进行购买。',
icon: 'none',
duration: 2500,
});
return;
}
} catch (e) {
uni.showToast({
title: '系统繁忙,请稍后重试',
icon: 'none',
});
return;
}
}
hideNativeTabBar();
uni.switchTab({
url: item.pagePath,
fail: () => {
uni.reLaunch({ url: item.pagePath });
},
{
text: '分类',
url: '/pages/index/category',
iconUrl: proxy.$url+'index/2.svg',
activeIconUrl: proxy.$url+'index/2_1.svg',
},
{
text: '',
url: '/pages/home/seed',
iconUrl: proxy.$url+'index/6.svg',
activeIconUrl: proxy.$url+'index/6.svg',
},
{
text: '购物车',
url: '/pages/cart/cart',
iconUrl: proxy.$url+'index/3.svg',
activeIconUrl: proxy.$url+'index/3_1.svg',
},
{
text: '我的',
url: '/pages/index/user',
iconUrl: proxy.$url+'index/4.svg',
activeIconUrl: proxy.$url+'index/4_1.svg',
},
],
})
});
};
const bgSrc = computed(() => {
const svg = `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 750 150" preserveAspectRatio="none">
<path fill="#ffffff" d="M40 0 H295 Q316 0 316 21 A59 109 0 0 0 434 21 Q434 0 455 0 H710 Q750 0 750 40 V150 H0 V40 Q0 0 40 0 Z"/>
</svg>
`;
return `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;
});
</script>
<style>
<style lang="scss">
.tabbar-wrap {
width: 100%;
}
</style>
.tabbar {
position: fixed;
left: 0;
right: 0;
bottom: 0;
z-index: 80;
// background: var(--tabbar-bg, #ffffff);
overflow: visible;
}
.tabbar-bg {
position: absolute;
left: 0;
right: 0;
bottom: env(safe-area-inset-bottom);
width: 100%;
height: 100rpx;
background: #ffffff;
filter: drop-shadow(0 -6rpx 24rpx rgba(0, 0, 0, 0.12));
pointer-events: none;
}
.tabbar-inner {
height: 100rpx;
display: flex;
align-items: flex-end;
padding: 0 12rpx;
position: relative;
z-index: 1;
}
.tabbar-item {
min-width: 0;
padding-bottom: 10rpx;
}
.tabbar-item--mid {
padding-bottom: 0;
transform: translateY(-25rpx);
}
.icon {
width: 44rpx;
height: 44rpx;
}
.iconBox {
height: 150rpx;
display: flex;
align-items: flex-end;
justify-content: center;
}
.iconMid {
width: 100rpx;
height: 100rpx;
border-radius: 50%;
border-radius: 50%;
box-shadow: 0 10rpx 22rpx rgba(38, 107, 246, 0.8);
background: rgb(38, 107, 246);
}
.text {
margin-top: 6rpx;
font-size: 22rpx;
line-height: 1;
color: var(--tabbar-text, #979797);
}
.textActive {
color: #3b5efb;
}
.safe-bottom {
padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-placeholder {
height: 100rpx;
}
</style>
+105 -25
View File
@@ -1,55 +1,138 @@
<template>
<view>
<scroll-view scroll-x show-scrollbar="false" class="scroll-x-wrapper p-x-32">
<view class="navs flex-center ju-flex-start nowrap" style="width: auto;">
<view
class="navItem flex-center flex-column flex1 shrink nowrap"
:class="{ tabIndex: i == tabIndex, c34: i == tabIndex }"
v-for="(v, i) in props.list"
:key="i"
@click="navChange(i)"
>
<view class="navText"> {{ v.name }} </view>
<image src="/static/index/active.png" mode="scaleToFill" />
<su-sticky offsetTop="0" zIndex="20" bgColor="#F2F4F7">
<scroll-view scroll-x show-scrollbar="false" class="scroll-x-wrapper p-x-32">
<view class="navs flex-center ju-flex-start nowrap" style="width: auto;">
<view
class="navItem flex-center flex-column flex1 shrink nowrap"
:class="{ tabIndex: i == tabIndex, c34: i == tabIndex }"
v-for="(v, i) in displayList"
:key="i"
@click="navChange(i)"
>
<view class="navText"> {{ v.name }} </view>
<!-- <image src="/static/index/active.png" mode="scaleToFill" /> -->
</view>
</view>
</view>
</scroll-view>
</scroll-view>
</su-sticky>
<view class="goodsPages">
<goods-item
v-for="(tab, i) in props.list"
v-for="(tab, i) in displayList"
:key="tab.id || i"
:ref="(el) => mescrollItems[i] && (mescrollItems[i].value = el)"
:i="i"
:index="tabIndex"
:tabs="props.list"
:tabs="displayList"
></goods-item>
</view>
</view>
</template>
<script setup>
import { ref } from 'vue';
import { ref, watch } from 'vue';
import goodsItem from '../goodsItem/goodsItem.vue';
import { onPageScroll, onReachBottom, onShow } from '@dcloudio/uni-app';
import useMescrollMore from '@/uni_modules/mescroll-uni/hooks/useMescrollMore.js';
import UserApi from '@/sheep/api/member/user';
let props = defineProps({
list: {
type: Array,
default: () => [],
},
defaultTabName: {
type: String,
default: '',
},
});
const hasPurchasedShop = ref(null);
const displayList = ref([]);
const hasAppliedDefaultTab = ref(false);
const computeDisplayList = () => {
const list = Array.isArray(props.list) ? props.list : [];
const hasVip = list.some((v) => String(v?.name || '').trim() === '会员优选');
if (hasVip && Number(hasPurchasedShop.value) === 1) {
return list.filter((v) => String(v?.name || '').trim() !== '会员优选');
}
return list;
};
// 动态生成与 tabs 同步的 refs 数组,供 useMescrollMore 使用
const mescrollItems = props.list.map(() => ref(null));
const { tabIndex, getMescroll, scrollToLastY } = useMescrollMore(
const mescrollItems = [];
const syncMescrollItems = (list) => {
const n = Array.isArray(list) ? list.length : 0;
while (mescrollItems.length < n) mescrollItems.push(ref(null));
if (mescrollItems.length > n) mescrollItems.splice(n);
};
const { tabIndex } = useMescrollMore(
mescrollItems,
onPageScroll,
onReachBottom,
);
const applyDefaultTabIfNeeded = (list) => {
const target = String(props.defaultTabName || '').trim();
if (!target) return;
if (hasAppliedDefaultTab.value) return;
const index = (Array.isArray(list) ? list : []).findIndex(
(v) => String(v?.name || '').trim() === target,
);
if (index >= 0) {
tabIndex.value = index;
hasAppliedDefaultTab.value = true;
}
};
const refreshDisplay = () => {
const next = computeDisplayList();
displayList.value = next;
syncMescrollItems(next);
applyDefaultTabIfNeeded(next);
if (tabIndex.value >= next.length) tabIndex.value = 0;
};
const loadShopStatus = async () => {
const list = Array.isArray(props.list) ? props.list : [];
const hasVip = list.some((v) => String(v?.name || '').trim() === '会员优选');
if (!hasVip) return;
if (hasPurchasedShop.value !== null && hasPurchasedShop.value !== undefined) return;
const res = await UserApi.getUserInfo().catch(() => ({ code: -1 }));
if (res?.code === 0) {
hasPurchasedShop.value = Number(res?.data?.hasPurchasedShop) || 0;
refreshDisplay();
}
};
watch(
() => props.list,
() => {
refreshDisplay();
if (hasPurchasedShop.value === null || hasPurchasedShop.value === undefined) {
loadShopStatus();
}
},
{ immediate: true, deep: true },
);
watch(
() => props.defaultTabName,
() => {
hasAppliedDefaultTab.value = false;
applyDefaultTabIfNeeded(displayList.value);
},
{ immediate: true },
);
// let tabIndex = ref(0);
const navChange = (i) => {
// scrollToLastY()
tabIndex.value = i;
};
onShow(() => {
loadShopStatus();
});
</script>
<style lang="scss" scoped>
@@ -58,16 +141,11 @@
white-space: nowrap;
}
.navs {
// padding: 0 32rpx;
box-sizing: border-box;
height: 120rpx;
// padding-bottom: 10rpx;
.navItem {
color: #777777;
font-size: 32rpx;
// width: 20%;
// text-align: center;
// margin-right: 40rpx;
font-size: 28rpx;
white-space: nowrap;
flex-shrink: 0; // 防止被压缩
image {
@@ -79,8 +157,10 @@
}
.tabIndex {
color: #777777;
font-size: 36rpx;
font-weight: 500;
background: linear-gradient(135deg, #2C8CFA 0%, #3D5EFB 100%);
color: #ffffff !important;
border-radius: 12rpx;
image {
opacity: 1;
}
+110 -9
View File
@@ -9,20 +9,29 @@
>
<view
class="shrink"
@click="utils.go('/pages/goods/info', { id: props.data.id })"
@click="onCardClick"
:class="{
goodsImg1: props.type == 1,
goodsImg2: props.type == 2,
goodsImg3: props.type == 3,
}"
>
<view
v-if="isSoldOut"
class="sold-out-tag"
:class="{
sold1: props.type == 1,
sold2: props.type == 2,
sold3: props.type == 3,
}"
>已售罄</view>
<image
class=""
:src="props.data.picUrl ? sheep.$url.cdn(props.data.picUrl) : '/static/icon/null1.png'"
mode="aspectFill"
/>
</view>
<view class="goodItem" :class="{itemBg: props.type == 1}" @click="utils.go('/pages/goods/info', { id: props.data.id })">
<view class="goodItem" :class="{ itemBg: props.type == 1 }" @click="onCardClick">
<view class="wrap">
<view
class="title "
@@ -35,12 +44,12 @@
v-if="props.type == 1"
>
<view class="label" v-if="props.data.tagSaleName">{{ props.data.tagSaleName }}</view>
<view class="num">已售{{ props.data.salesCount }}</view>
<view class="num" v-if="!props.memberPreferred">已售{{ props.data.salesCount }}</view>
</view>
<view v-else-if="props.type == 2">
<view class="flex-center ju-between mt10 wrap">
<view class="num size26 m-r-4">{{ props.data.categoryText }}</view>
<view class="num">销量:{{ props.data.salesCount }}</view>
<view class="num" v-if="!props.memberPreferred">销量:{{ props.data.salesCount }}</view>
</view>
<view class="flex-row wrap" v-if="props.data.tagSaleName">
<view
@@ -66,13 +75,28 @@
> -->
</view>
<!-- -->
<uni-badge :text="props.data.cartCount" v-if="props.type == 2 && props.data.cartCount" absolute="rightTop" :customStyle="{background: '#FF0000'}">
<view class="shopIcon" :class="{ 'shopIcon1': props.type == 2 }" @click.stop="changeSelectSku">
<uni-badge
v-if="!isSoldOut && props.type == 2 && props.data.cartCount"
:text="props.data.cartCount"
absolute="rightTop"
:customStyle="{background: '#FF0000'}"
>
<view
class="shopIcon"
:class="{ 'shopIcon1': props.type == 2, 'shop-icon-soldout': isSoldOut }"
@click.stop="onShopIconClick"
>
<image src="/static/index/shop.png" mode="scaleToFill" />
</view>
</uni-badge>
<view class="shopIcon" :class="{ 'shopIcon1': props.type == 2 }" @click.stop="changeSelectSku" v-else>
<image src="/static/index/shop.png" mode="scaleToFill" />
<view
class="shopIcon"
:class="{ 'shopIcon1': props.type == 2, 'shop-icon-soldout': isSoldOut }"
@click.stop="onShopIconClick"
v-else
>
<image v-if="!isSoldOut" src="/static/index/shop.png" mode="scaleToFill" />
<view v-else class="shop-soldout-tip">售罄</view>
</view>
</view>
</view>
@@ -90,7 +114,7 @@
<script setup>
import sheep from '@/sheep';
import { ref, reactive, watch } from 'vue';
import { ref, reactive, watch, computed } from 'vue';
import SpuApi from '@/sheep/api/product/spu';
import { fen2yuan } from '@/sheep/hooks/useGoods';
@@ -101,6 +125,10 @@
return {};
},
},
memberPreferred: {
type: Boolean,
default: false,
},
type: {
//1:首页 2:分类 3:搜索
type: Number,
@@ -119,7 +147,33 @@
deep: true,
},
);
const isSoldOut = computed(() => {
return Number(props.data.stock || 0) <= 0;
});
let showSelectSku = ref(false);
const goDetail = () => {
sheep.$router.go('/pages/goods/info', { id: props.data.id });
};
const onCardClick = () => {
if (props.memberPreferred) return;
goDetail();
};
const buyMemberGoods = () => {
uni.navigateTo({
url: `/pages/AI/giftOrder?id=${props.data.id}`,
});
};
const onShopIconClick = () => {
if (isSoldOut.value) return;
if (props.memberPreferred) {
buyMemberGoods();
return;
}
changeSelectSku();
};
const changeSelectSku = async () => {
let res = await getData();
showSelectSku.value = true;
@@ -192,6 +246,37 @@
</script>
<style lang="scss" scoped>
.sold-out-tag {
position: absolute;
right: 0;
top: 0;
z-index: 3;
color: #ffffff;
font-weight: 600;
background: rgba(0, 0, 0, 0.58);
border-radius: 0 0 0 8rpx;
backdrop-filter: blur(2px);
text-align: center;
}
.sold-out-tag.sold1 {
width: 108rpx;
height: 52rpx;
line-height: 52rpx;
font-size: 24rpx;
}
.sold-out-tag.sold2 {
width: 96rpx;
height: 44rpx;
line-height: 44rpx;
font-size: 22rpx;
}
.sold-out-tag.sold3 {
width: 76rpx;
height: 36rpx;
line-height: 36rpx;
font-size: 18rpx;
}
.goodItem {
padding: 20rpx 24rpx;
box-sizing: border-box;
@@ -241,6 +326,22 @@
height: 100%;
}
}
.shop-icon-soldout {
background: #cccccc;
filter: grayscale(100%);
border-radius: 50%;
cursor: not-allowed;
display: flex;
align-items: center;
justify-content: center;
}
.shop-soldout-tip {
font-size: 18rpx;
color: #ffffff;
font-weight: 600;
text-align: center;
line-height: 1.2;
}
}
.shrink{
border-radius: 10rpx;
+40 -75
View File
@@ -1,45 +1,33 @@
<template>
<view class="goodsItem-container">
<view v-show="i === props.index">
<!-- top="120"下拉布局往下偏移,防止被悬浮菜单遮住 -->
<mescroll-uni
@init="mescrollInit"
top="0"
:down="downOption"
@down="downCallback"
:up="upOption"
@up="upCallback"
@emptyclick="emptyClick"
v-if="i === props.index"
:height="height + 'px'"
>
<!-- 数据列表 -->
<!-- <good-list :list="goods"></good-list> -->
<!-- <view v-for="(v,i) in goods" :key="i">
{{ v.picUrl }}
</view> -->
<view class="flex-row wrap w100" ref="cardRef">
<view class="cardItem" v-for="(v, i) in goods" :key="i">
<card_goods :data="v"></card_goods>
</view>
<view v-show="i === props.index">
<mescroll-body
@init="mescrollInit"
top="0"
:down="downOption"
@down="downCallback"
:up="upOption"
@up="upCallback"
@emptyclick="emptyClick"
v-if="i === props.index"
>
<view class="flex-row wrap w100">
<view class="cardItem" v-for="(v, i) in goods" :key="i">
<card_goods :data="v" :memberPreferred="isMemberPreferred"></card_goods>
</view>
</mescroll-uni>
</view>
</view>
</mescroll-body>
</view>
</template>
<script setup>
import { ref, watch, getCurrentInstance } from 'vue';
import { onPageScroll, onReachBottom } from '@dcloudio/uni-app';
import { ref, watch, computed } from 'vue';
import useMescroll from '@/uni_modules/mescroll-uni/hooks/useMescroll.js';
import SpuApi from '@/sheep/api/product/spu';
import { getAiProduct } from '@/sheep/api/ai';
import card_goods from './card_goods.vue';
const { proxy } = getCurrentInstance();
let goods = ref([]);
const column = ref(2);
const columnChange = ref(false);
const height = ref(0);
const props = defineProps({
i: Number, // 每个tab页的专属下标
index: {
@@ -77,7 +65,7 @@
},
);
const { mescrollInit, downCallback, getMescroll } = useMescroll(onPageScroll, onReachBottom); // 调用mescroll的hook
const { mescrollInit, downCallback, getMescroll } = useMescroll(); // 调用mescroll的hook
defineExpose({ getMescroll }); // 使父组件可以通过ref调用到getMescroll方法 (必须)
@@ -101,6 +89,8 @@
};
const isInit = ref(isAutoInit); // 当前tab是否已初始化
const tabName = computed(() => String(props.tabs?.[props.i]?.name || '').trim());
const isMemberPreferred = computed(() => tabName.value === '会员优选');
// 监听下标的变化
watch(
() => props.index,
@@ -121,28 +111,34 @@
}
}
};
let cardRef = ref(null);
// 是否有下一页
let hasMore = ref(true);
const upCallback = (mescroll) => {
if (isMemberPreferred.value) {
getAiProduct({
pageNo: mescroll.num,
pageSize: mescroll.size,
})
.then((res) => {
const list = res?.data?.list || [];
const next = Array.isArray(list) ? list : [];
if (mescroll.num == 1) goods.value = [];
goods.value = goods.value.concat(next);
mescroll.endSuccess(next.length);
})
.catch(() => {
mescroll.endErr();
});
return;
}
SpuApi.getSpuPage({
pageNo: mescroll.num,
pageSize: mescroll.size,
tagTypeId: props.tabs[props.i].id,
tagTypeId: props.tabs?.[props.i]?.id,
})
.then((res) => {
const list = res.data.list || []; // 当前页数据
// if(list.length){
// list.forEach(e=>{
// e.hide = true
// })
// }
if (mescroll.num == 1) goods.value = []; //如果是第一页需手动制空列表
goods.value = goods.value.concat(list); //追加新数据
hasMore.value = goods.value.length < res.data.total;
// 计算容器高度
getHeight(mescroll.num);
mescroll.endSuccess(list.length); // 请求成功, 结束加载
})
.catch(() => {
@@ -156,40 +152,9 @@
title: '点击了按钮,具体逻辑自行实现',
});
};
const getHeight = (num) => {
if (!goods.value.length) {
// 541
height.value = 10
return
}
// 相除向上取整
let cardHeight = Math.ceil(goods.value.length / 2) * (541)
let sysInfo = uni.getSystemInfoSync()
const windowHeight = sysInfo.windowHeight;
const value1 = windowHeight - sysInfo.statusBarHeight - uni.upx2px(88) - uni.upx2px(120)
let value2 = uni.upx2px(cardHeight) + 55 + uni.upx2px(12)
// if(hasMore){
// value2 = uni.upx2px(cardHeight) + uni.upx2px(12)
// }
const isGreater = value1 > value2;
if(isGreater){
height.value = value2
}else{
height.value = value1
}
// console.error(windowHeight)
// console.log("最大高"+value1)
// console.log("内容高"+value2)
// console.error(height.value)
};
</script>
<style lang="scss" scoped>
.goodsItem-container {
width: 100%;
height: 100%;
overflow: hidden;
}
.cardItem {
width: calc(50% - 8rpx);
margin-right: 16rpx;
@@ -0,0 +1,183 @@
<template>
<view class="tabbar-wrap">
<view class="tabbar safe-bottom">
<view class="tabbar-inner">
<view
v-for="item in items"
:key="item.pagePath"
class="tabbar-item flex1 flex-center flex-column"
:class="{ 'tabbar-item--mid': item.isMid }"
@tap.stop="onTap(item)"
>
<view class="iconBox" :class="{ iconBoxMid: item.isMid }">
<uni-icons
:type="item.icon"
:size="item.isMid ? 30 : 24"
:color="isActive(item) ? activeColor : normalColor"
/>
</view>
<view class="text" :class="{ textActive: isActive(item), textMid: item.isMid }">
{{ item.text }}
</view>
</view>
</view>
</view>
<view v-if="props.placeholder" class="tabbar-placeholder safe-bottom"></view>
</view>
</template>
<script setup>
import { computed, ref, watch } from 'vue';
import { onShow } from '@dcloudio/uni-app';
const props = defineProps({
path: {
type: String,
default: '',
},
placeholder: {
type: Boolean,
default: false,
},
});
const normalColor = '#666';
const activeColor = '#2556EC';
const currentPath = ref('');
const normalizePath = (p) => {
if (!p) return '';
return p.startsWith('/') ? p : `/${p}`;
};
const updateCurrentPath = () => {
const pages = getCurrentPages?.() || [];
const current = pages[pages.length - 1];
const route = current?.route || '';
currentPath.value = normalizePath(route);
};
const hideNativeTabBar = () => {
try {
uni.hideTabBar({
fail: () => {},
});
} catch (e) {}
};
onShow(() => {
hideNativeTabBar();
updateCurrentPath();
});
watch(
() => props.path,
(val) => {
if (val) currentPath.value = normalizePath(val);
},
{ immediate: true },
);
const items = computed(() => [
{
pagePath: '/pages/merchant/pickupList',
text: '提货清单',
icon: 'list',
},
{
pagePath: '/pages/merchant/scanVerify',
text: '扫码核销',
icon: 'scan',
isMid: true,
},
{
pagePath: '/pages/merchant/storeManage',
text: '网店管理',
icon: 'shop',
},
]);
const isActive = (item) => {
return normalizePath(item.pagePath) === normalizePath(currentPath.value);
};
const onTap = (item) => {
if (isActive(item)) return;
hideNativeTabBar();
uni.reLaunch({
url: item.pagePath,
fail: () => {
uni.navigateTo({ url: item.pagePath });
},
});
};
</script>
<style lang="scss">
.tabbar-wrap {
width: 100%;
}
.tabbar {
position: fixed;
left: 0;
right: 0;
bottom: 0;
padding: 14rpx 24rpx;
box-sizing: border-box;
z-index: 10;
}
.tabbar-inner {
width: 100%;
height: 110rpx;
border-radius: 30rpx;
background: rgba(255, 255, 255, 0.98);
display: flex;
align-items: center;
padding: 0 16rpx;
box-sizing: border-box;
box-shadow: 0 16rpx 40rpx rgba(0, 0, 0, 0.08);
}
.tabbar-item {
height: 110rpx;
justify-content: center;
}
.iconBox {
width: 56rpx;
height: 56rpx;
display: flex;
align-items: center;
justify-content: center;
}
.iconBoxMid {
width: 76rpx;
height: 76rpx;
border-radius: 22rpx;
background: rgba(37, 86, 236, 0.12);
}
.text {
margin-top: 6rpx;
font-size: 22rpx;
color: #666;
line-height: 1;
}
.textActive {
color: #2556ec;
font-weight: 600;
}
.textMid {
font-size: 20rpx;
}
.tabbar-placeholder {
height: calc(110rpx + 28rpx);
}
</style>
+71
View File
@@ -0,0 +1,71 @@
<template>
<view v-if="showSwitch" class="mode-switch" @tap.stop="open">
<view class="mode-switch__text">{{ label }}</view>
<uni-icons type="bottom" size="14" color="#333" />
</view>
</template>
<script setup>
import { computed, onMounted } from 'vue';
import sheep from '@/sheep';
const appStore = sheep.$store('app');
const userStore = sheep.$store('user');
const label = computed(() => (appStore.bizMode === 'merchant' ? '商户' : '用户'));
const hasStoreAccess = (value) => {
if (Array.isArray(value)) {
return value.some((item) => String(item ?? '').trim() !== '');
}
return String(value ?? '')
.split(',')
.some((item) => item.trim() !== '');
};
const showSwitch = computed(() => {
const info = userStore?.userInfo || {};
return hasStoreAccess(info.storeIds) || hasStoreAccess(info.storeId);
});
onMounted(() => {
if (!userStore?.isLogin) return;
if (showSwitch.value) return;
userStore.getInfo();
});
const setMode = (mode) => {
const next = mode === 'merchant' ? 'merchant' : 'user';
if (appStore.bizMode === next) return;
appStore.setBizMode(next);
const url = next === 'merchant' ? '/pages/merchant/pickupList' : '/pages/index/index';
uni.reLaunch({ url });
};
const open = () => {
uni.showActionSheet({
itemList: ['用户', '商户'],
success: ({ tapIndex }) => {
setMode(tapIndex === 1 ? 'merchant' : 'user');
},
fail: () => {},
});
};
</script>
<style scoped lang="scss">
.mode-switch {
display: flex;
align-items: center;
justify-content: flex-end;
padding: 10rpx 18rpx;
border-radius: 100rpx;
background: rgba(255, 255, 255, 0.9);
box-sizing: border-box;
}
.mode-switch__text {
font-size: 26rpx;
color: #333;
margin-right: 8rpx;
line-height: 1;
}
</style>
+242
View File
@@ -0,0 +1,242 @@
<template>
<view class="flex-center ju-flex-end w100">
<view
class="ai-button3 w_144 m-r-10 remind-ai-btn"
v-if="showRemind"
@tap.stop="emit('remind')"
>
催一催
</view>
<view
class="ai-button3 w_144 m-r-10 modify-delivery-btn"
v-if="showModifyDelivery"
@tap.stop="emit('modifyDelivery')"
>
修改配送
</view>
<view
class="ai-button3 w_144 m-r-10"
v-if="showDelay && !props.disableDelayShipment"
@tap.stop="emit('delay')"
>
延迟发货
</view>
<view
class="ai-button3 w_144 m-r-10"
v-if="showNow && !props.disableDelayShipment"
@tap.stop="emit('now')"
>
立即发货
</view>
<view
class="ai-button3 w_144 m-r-10"
v-if="hasExpress"
@tap.stop="emit('express')"
>
查看物流
</view>
<view
class="ai-button3 w_144"
v-if="props.showView && props.status !== 70"
@tap.stop="emit('view')"
>
{{ props.viewText }}
</view>
<view class="ai-button1 w_144 m-l-16" v-if="props.status === 20 || props.status === 15" @tap.stop="emit('confirm')">
确认收货
</view>
<view class="ai-button1 w_144 m-l-16" v-if="props.status === 0" @tap.stop="emit('pay')">
去支付
</view>
<view class="ai-button1 w_144 m-l-16" v-if="props.status === 70" @tap.stop="emit('cancel')">
取消订单
</view>
<view class="ai-button1 w_144 m-l-16" v-if="props.status === 70" @tap.stop="emit('pay')">
切换支付
</view>
</view>
</template>
<script setup>
import { computed } from 'vue';
const props = defineProps({
status: {
type: Number,
default: -1,
},
disableDelayShipment: {
type: Boolean,
default: false,
},
showView: {
type: Boolean,
default: false,
},
viewText: {
type: String,
default: '查看订单',
},
hasDelayedItems: {
type: Boolean,
default: false,
},
canDelayItems: {
type: Boolean,
default: false,
},
canShipItems: {
type: Boolean,
default: false,
},
logisticsId: {
type: [Number, String],
default: 0,
},
logisticsNo: {
type: String,
default: '',
},
deliveryTime: {
type: [Number, String],
default: '',
},
hasLogistics: {
type: Boolean,
default: false,
},
deliveryType: {
type: [Number, String],
default: 0,
},
payStatus: {
type: [Boolean, Number, String],
default: false,
},
preparationStatus: {
type: [Number, String],
default: null,
},
pickUpVerifyTime: {
type: [Number, String],
default: '',
},
verifyTime: {
type: [Number, String],
default: '',
},
completedTime: {
type: [Number, String],
default: '',
},
arriveStoreTime: {
type: [Number, String],
default: '',
},
deliveredTime: {
type: [Number, String],
default: '',
},
thirdPartyOrder: {
type: [Boolean, Number, String],
default: false,
},
canUpdateDeliveryType: {
type: [Boolean, Number, String],
default: false,
},
});
const isThirdPartyOrder = computed(() => {
const v = props.thirdPartyOrder;
if (v === true || v === 'true' || v === 1) return true;
return false;
});
const showModifyDelivery = computed(() => {
if (!isThirdPartyOrder.value) return false;
const v = props.canUpdateDeliveryType;
if (!(v === true || v === 'true' || v === 1)) return false;
const s = Number(props.status);
return s === 10;
});
// 延迟发货按钮:仅允许【待发货(10/伪50)、部分发货(15)】状态展示
// 伪状态 50 = 原生 status=10 + 有 status===1(延迟中)的商品,属于待发货分支
const showDelay = computed(() => {
const s = Number(props.status);
if (s === 20) return false; // 待收货:不展示
if (![10, 15, 50].includes(s)) return false;
return Boolean(props.canDelayItems);
});
// 立即发货按钮:仅允许【待发货(10/伪50)、部分发货(15)】状态,
// 且必须 delayRecords 里存在 status===1(延迟中)的商品(hasDelayedItems===true)
const showNow = computed(() => {
const s = Number(props.status);
if (s === 20) return false; // 待收货:不展示
if (![10, 15, 50].includes(s)) return false;
if (!Boolean(props.hasDelayedItems)) return false;
return Boolean(props.canShipItems);
});
const hasExpress = computed(() => {
if ([15, 20, 30].includes(props.status)) return true;
if (props.hasLogistics) return true;
if (Number(props.logisticsId) > 0) return true;
if (props.logisticsNo && String(props.logisticsNo).trim()) return true;
if (props.deliveryTime) return true;
return false;
});
const isVerifyCompleted = computed(() => {
const status = Number(props.status);
return Boolean(
props.pickUpVerifyTime ||
props.verifyTime ||
props.completedTime ||
status === 30 ||
status === 3,
);
});
const resolveStage = () => {
const external = Number(props.preparationStatus);
const rawStatus = Number.isFinite(external) ? external : Number(props.preparationStatus ?? props.status ?? 0);
if (isVerifyCompleted.value) return 'done';
if (rawStatus === 1 || rawStatus === 2) return 'wait';
if (
props.deliveryTime ||
props.arriveStoreTime ||
props.deliveredTime ||
rawStatus === 20
) {
return 'delivered';
}
return 'sorting';
};
const isSorting = computed(() => resolveStage() === 'sorting');
const showRemind = computed(() => {
return (
Number(props.deliveryType) === 2 &&
Boolean(props.payStatus) &&
!isVerifyCompleted.value &&
isSorting.value
);
});
const emit = defineEmits(['delay', 'now', 'view', 'confirm', 'pay', 'cancel', 'express', 'remind', 'modifyDelivery']);
</script>
<style scoped lang="scss">
.remind-ai-btn {
color: #2556ec !important;
background: rgba(37, 86, 236, 0.08);
border: 2rpx solid rgba(37, 86, 236, 0.28) !important;
}
.modify-delivery-btn {
color: #1677FF !important;
background: rgba(22, 119, 255, 0.06);
border: 2rpx solid rgba(22, 119, 255, 0.28) !important;
}
</style>
+848
View File
@@ -0,0 +1,848 @@
<template>
<uni-popup ref="popupRef" :type="popupType" background-color="transparent">
<view class="express-popup" :class="`express-popup--${popupType}`" @tap.stop>
<view class="express-popup__header">
<view>
<view class="express-popup__title">查看物流</view>
<view class="express-popup__order-no">订单号:{{ orderNo || '-' }}</view>
<view class="express-popup__tip">点击商品右侧按钮可展开/收起物流轨迹</view>
</view>
<view class="express-popup__close" @tap.stop="handleClose">×</view>
</view>
<view class="express-popup__scroll-wrap">
<scroll-view
scroll-y
scroll-with-animation
enhanced
:show-scrollbar="false"
class="express-popup__content"
>
<view v-if="renderItems.length === 0" class="express-popup__empty">
暂无物流信息
</view>
<view
v-else
class="express-popup__item"
:class="{ 'express-popup__item--expanded': item.expanded, 'express-popup__item--fallback': item.isFallback }"
v-for="(item, index) in renderItems"
:key="item.itemKey || index"
>
<view v-if="!item.isFallback" class="express-popup__item-top flex-row al-flex-start">
<image class="express-popup__item-image" :src="item.picUrl" mode="aspectFill" />
<view class="express-popup__item-main">
<view class="express-popup__item-name lineTwo">{{ item.spuName }}</view>
<view class="express-popup__item-sku">{{ item.skuText || '-' }}</view>
<view class="express-popup__item-info">
<text class="express-popup__item-count">数量:x{{ item.count }}</text>
<text
v-if="item.logisticsNo"
class="express-popup__item-logistics"
>运单号:{{ item.logisticsNo }}</text>
</view>
<view class="express-popup__item-action">
<view
class="express-popup__btn"
:class="item.expanded ? 'express-popup__btn--ghost' : 'express-popup__btn--primary'"
@tap.stop="handleToggleTrack(item)"
>
<text v-if="item.loading">加载中...</text>
<template v-else>
{{ item.expanded ? '收起物流' : '查看物流' }}
</template>
<text class="express-popup__btn-arrow" :class="{ rotated: item.expanded }">▾</text>
</view>
</view>
</view>
</view>
<view v-if="!item.isFallback ? item.expanded : true" class="express-popup__track" :class="{ 'express-popup__track--fallback': item.isFallback }">
<view v-if="item.loading" class="express-popup__track-loading">物流信息加载中...</view>
<view v-else-if="!Array.isArray(item.tracks) || item.tracks.length === 0" class="express-popup__track-empty">
暂无物流轨迹
</view>
<view v-else class="express-popup__track-list">
<view
class="express-popup__track-node"
:class="{ 'is-first': i === 0 }"
v-for="(node, i) in item.tracks"
:key="i"
>
<view class="express-popup__track-dot" />
<view class="express-popup__track-main">
<view class="express-popup__track-content">{{ node.content || node.desc || node.text || '-' }}</view>
<view class="express-popup__track-time">{{ node.time || node.ftime || node.createTime || '' }}</view>
</view>
</view>
</view>
</view>
</view>
</scroll-view>
</view>
</view>
</uni-popup>
</template>
<script setup>
import { computed, reactive, ref, watch } from 'vue';
import sheep from '@/sheep';
import { getAiOrderDelayRecords, getOpenOrderDetail, getOpenOrderExpressTrackList } from '@/sheep/api/ai';
import { getExpressTrackList } from '@/sheep/api/index/index';
const props = defineProps({
popupType: {
type: String,
default: 'bottom',
},
orderNo: {
type: String,
default: '',
},
orderData: {
type: Object,
default: () => ({}),
},
delayRecords: {
type: Array,
default: () => [],
},
orderId: {
type: [Number, String],
default: 0,
},
});
const emit = defineEmits(['close', 'view-express']);
const popupRef = ref();
const innerItems = ref([]);
const loadedRecords = ref([]);
const getFirstValidValue = (...values) =>
values.find((value) => value !== undefined && value !== null && String(value).trim() !== '') ?? '';
const hasValue = (value) => value !== undefined && value !== null && String(value).trim() !== '';
const formatSkuPropertyItem = (property) => {
const value = getFirstValidValue(
property?.valueName,
property?.value,
property?.specValue,
property?.attrValue,
property?.optionValue,
property?.propertyValue,
typeof property === 'string' ? property : '',
);
const name = getFirstValidValue(
property?.name,
property?.propertyName,
property?.specName,
property?.attrName,
property?.optionName,
property?.propertyKey,
'',
);
if (hasValue(name) && hasValue(value)) return `${name}:${value}`;
if (hasValue(value)) return String(value);
if (hasValue(name)) return String(name);
return '';
};
const formatSkuProperties = (properties) => {
if (!properties) return '';
if (typeof properties === 'string' && properties.trim()) return properties.trim();
if (Array.isArray(properties)) {
return properties.map(formatSkuPropertyItem).filter(Boolean).join(' ');
}
if (typeof properties === 'object') {
return Object.keys(properties)
.map((key) => {
const value = properties[key];
if (typeof value === 'object') return formatSkuPropertyItem(value);
return `${key}:${value}`;
})
.filter(Boolean)
.join(' ');
}
return '';
};
const resolveSpuItems = (data) => {
const items = Array.isArray(data?.items) ? data.items : [];
return items.flatMap((spu) => {
const subItems = Array.isArray(spu?.items) ? spu.items : [];
if (subItems.length > 0) {
return subItems.map((sub) => ({
...sub,
_spuName: getFirstValidValue(
spu?.spuName,
spu?.productName,
spu?.goodsName,
sub?.spuName,
sub?.productName,
sub?.goodsName,
),
_spuPic: getFirstValidValue(
spu?.picUrl,
spu?.imageUrl,
spu?.thumbUrl,
spu?.goodsPic,
sub?.picUrl,
sub?.imageUrl,
sub?.thumbUrl,
sub?.goodsPic,
),
_spuId: getFirstValidValue(spu?.spuId, spu?.productId, sub?.spuId, sub?.productId),
_skuText: getFirstValidValue(
sub?.skuProperties,
sub?.specInfo,
sub?.skuInfo,
sub?.skuText,
formatSkuProperties(sub?.skuProperties || sub?.specs || sub?.properties),
),
}));
}
return [
{
...spu,
_spuName: getFirstValidValue(spu?.spuName, spu?.productName, spu?.goodsName),
_spuPic: getFirstValidValue(
spu?.picUrl,
spu?.imageUrl,
spu?.thumbUrl,
spu?.goodsPic,
),
_spuId: getFirstValidValue(spu?.spuId, spu?.productId),
_skuText: getFirstValidValue(
spu?.skuProperties,
spu?.specInfo,
spu?.skuInfo,
spu?.skuText,
formatSkuProperties(spu?.skuProperties || spu?.specs || spu?.properties),
),
},
];
});
};
const resolveAllDelayRecords = () => {
if (Array.isArray(loadedRecords.value) && loadedRecords.value.length > 0) {
return loadedRecords.value.filter(Boolean);
}
const orderLevelRecords = Array.isArray(props.delayRecords)
? props.delayRecords
: Array.isArray(props.orderData?.delayRecords)
? props.orderData.delayRecords
: Array.isArray(props.orderData?.delayRecordList)
? props.orderData.delayRecordList
: [];
return orderLevelRecords.filter(Boolean);
};
const resolveCount = (record) =>
Number(
getFirstValidValue(
record?.count,
record?.num,
record?.quantity,
record?.number,
record?.totalCount,
1,
),
) || 1;
const resolveRecordOrderItemId = (record) =>
Number(
getFirstValidValue(
record?.orderItemId,
record?.orderItemVO?.id,
record?.orderItem?.id,
record?.itemId,
0,
),
) || 0;
const resolveRecordSkuText = (record) => {
const direct = getFirstValidValue(
record?.skuProperties,
record?.specInfo,
record?.skuText,
record?.skuInfo,
formatSkuProperties(record?.skuProperties || record?.specs || record?.properties),
);
if (direct) return direct;
const itemSpec = getFirstValidValue(
record?.orderItemVO?.skuProperties,
record?.orderItemVO?.specInfo,
record?.orderItem?.skuProperties,
record?.orderItem?.specInfo,
formatSkuProperties(record?.orderItemVO?.skuProperties || record?.orderItem?.specs),
);
return itemSpec;
};
const resolveRecordSpuName = (record) =>
getFirstValidValue(
record?.spuName,
record?.productName,
record?.goodsName,
record?.orderItemVO?.spuName,
record?.orderItem?.spuName,
record?.orderItemVO?.productName,
record?.orderItem?.productName,
);
const resolveRecordPicUrl = (record) =>
getFirstValidValue(
record?.picUrl,
record?.imageUrl,
record?.thumbUrl,
record?.goodsPic,
record?.orderItemVO?.picUrl,
record?.orderItem?.picUrl,
record?.orderItemVO?.imageUrl,
record?.orderItem?.imageUrl,
);
const resolveRecordLogisticsNo = (record) =>
getFirstValidValue(
record?.logisticsNo,
record?.waybillNo,
record?.trackingNo,
record?.expressNo,
record?.orderItemVO?.logisticsNo,
record?.orderItem?.logisticsNo,
);
const buildExpressItemList = () => {
const records = resolveAllDelayRecords();
const expressRecords = records.filter((record) => {
const status = Number(record?.status);
return status >= 3 && Number(record?.delayRecordId || record?.id) > 0;
});
if (expressRecords.length === 0) return [];
const spuItems = resolveSpuItems(props.orderData);
const findItemByOrderItemId = (id) =>
spuItems.find(
(sku) => Number(sku?.id || sku?.orderItemId || sku?.itemId || 0) === Number(id),
);
const findItemBySkuText = (text) =>
spuItems.find((sku) => {
const skuText = getFirstValidValue(
sku?.skuProperties,
sku?.specInfo,
sku?.skuInfo,
sku?.skuText,
formatSkuProperties(sku?.skuProperties || sku?.specs || sku?.properties),
);
return !!text && !!skuText && String(text).trim() === String(skuText).trim();
});
const singleSpu =
spuItems.length === 1
? spuItems[0]
: new Set(spuItems.map((s) => s?._spuId || s?._spuName)).size === 1
? spuItems[0]
: null;
return expressRecords.map((record, idx) => {
const orderItemId = resolveRecordOrderItemId(record);
const recordSku = resolveRecordSkuText(record);
let matched = orderItemId ? findItemByOrderItemId(orderItemId) : null;
if (!matched && recordSku) matched = findItemBySkuText(recordSku);
if (!matched && singleSpu) matched = singleSpu;
const count = resolveCount(record);
const spuName = matched
? getFirstValidValue(matched._spuName, matched?.spuName, matched?.productName)
: resolveRecordSpuName(record);
const picUrl = matched
? getFirstValidValue(matched._spuPic, matched?.picUrl, matched?.imageUrl)
: resolveRecordPicUrl(record);
const skuText = matched
? getFirstValidValue(
matched?._skuText,
matched?.skuProperties,
matched?.specInfo,
matched?.skuInfo,
matched?.skuText,
formatSkuProperties(matched?.skuProperties || matched?.specs || matched?.properties),
)
: recordSku;
const delayRecordId = Number(record?.delayRecordId || record?.id) || 0;
const logisticsNo = resolveRecordLogisticsNo(record);
return reactive({
itemKey: `${delayRecordId}-${idx}`,
delayRecordId,
spuName: spuName || '商品信息',
skuText: skuText || '单规格',
picUrl: picUrl || '',
count,
logisticsNo,
expanded: false,
loading: false,
tracks: null,
});
});
};
const renderItems = computed(() => innerItems.value || []);
const open = async () => {
loadedRecords.value = [];
const oid = props.orderId || props.orderData?.id || props.orderData?.orderId;
const isOpenOrder = Number(props.orderData?.type) === 5;
if (oid) {
try {
if (isOpenOrder) {
const { code, data } = await getOpenOrderDetail({ id: oid });
if (code === 0) {
if (data) {
loadedRecords.value = Array.isArray(data?.delayRecords)
? data.delayRecords
: Array.isArray(data?.delayRecordList)
? data.delayRecordList
: [];
props.orderData._openOrderDetailData = data;
}
}
} else {
const { code, data } = await getAiOrderDelayRecords({ orderId: oid });
if (code === 0 && Array.isArray(data)) {
loadedRecords.value = data;
}
}
} catch (e) {
loadedRecords.value = [];
}
}
const expressList = buildExpressItemList();
if (expressList.length === 0 && oid) {
const fallbackItem = reactive({
itemKey: 'fallback-order-express',
isFallback: true,
delayRecordId: 0,
spuName: '',
skuText: '',
picUrl: '',
count: 0,
logisticsNo: '',
expanded: true,
loading: true,
tracks: null,
});
expressList.push(fallbackItem);
innerItems.value = expressList;
popupRef.value?.open?.();
emit('view-express', {
id: oid,
code: 2,
});
const tracks = await loadTrackList(fallbackItem);
fallbackItem.tracks = tracks;
fallbackItem.loading = false;
return;
}
innerItems.value = expressList;
popupRef.value?.open?.();
};
const close = () => {
popupRef.value?.close?.();
};
const handleClose = () => {
emit('close');
close();
};
const loadTrackList = async (item) => {
const id = props.orderId || props.orderData?.id || props.orderData?.orderId;
if (!id) {
uni.showToast({
title: '物流信息异常',
icon: 'none',
});
return [];
}
const isFallback = !!item?.isFallback;
const delayRecordId = Number(item?.delayRecordId) || 0;
if (!isFallback && !delayRecordId) {
uni.showToast({
title: '物流信息异常',
icon: 'none',
});
return [];
}
const isOpenOrder = Number(props.orderData?.type) === 5;
const requestApi = isOpenOrder ? getOpenOrderExpressTrackList : getExpressTrackList;
const params = {
id,
code: 2,
delayRecordId: !isFallback ? delayRecordId : '',
};
try {
const { code, data } = await requestApi(params);
if (code === 0 && Array.isArray(data)) {
return data;
}
return [];
} catch (e) {
return [];
}
};
const handleToggleTrack = async (item) => {
if (!item) return;
if (item.loading) return;
if (item.isFallback) return;
if (!item.expanded) {
const id = props.orderId || props.orderData?.id || props.orderData?.orderId;
const delayRecordId = Number(item?.delayRecordId) || 0;
if (!id || !delayRecordId) {
uni.showToast({
title: '物流信息异常',
icon: 'none',
});
return;
}
emit('view-express', {
id,
delayRecordId,
code: 2,
});
if (!Array.isArray(item.tracks)) {
item.loading = true;
const data = await loadTrackList(item);
item.tracks = data;
item.loading = false;
}
item.expanded = true;
} else {
item.expanded = false;
}
};
defineExpose({ open, close });
</script>
<style lang="scss" scoped>
.express-popup {
background: #ffffff;
box-sizing: border-box;
display: flex;
flex-direction: column;
&--bottom {
width: 100%;
height: 82vh;
max-height: 82vh;
border-radius: 24rpx 24rpx 0 0;
padding: 32rpx 32rpx calc(24rpx + env(safe-area-inset-bottom)) 32rpx;
overflow: hidden;
box-sizing: border-box;
}
&--center {
width: 680rpx;
height: 78vh;
max-height: 78vh;
border-radius: 24rpx;
padding: 32rpx 32rpx 32rpx 32rpx;
margin: 0 auto;
overflow: hidden;
box-sizing: border-box;
}
&--center &__content {
padding-bottom: 0;
}
&--center &__btn {
min-width: 200rpx;
}
&__header {
display: flex;
justify-content: space-between;
align-items: flex-start;
padding-bottom: 24rpx;
border-bottom: 1rpx solid #f2f2f2;
flex-shrink: 0;
flex-grow: 0;
width: 100%;
box-sizing: border-box;
}
&__title {
font-size: 32rpx;
font-weight: 600;
color: #111827;
line-height: 44rpx;
}
&__order-no {
margin-top: 8rpx;
font-size: 24rpx;
color: #6b7280;
line-height: 32rpx;
}
&__tip {
margin-top: 8rpx;
font-size: 24rpx;
color: #f97316;
line-height: 32rpx;
}
&__close {
width: 48rpx;
height: 48rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 40rpx;
color: #9ca3af;
line-height: 1;
}
&__scroll-wrap {
flex: 1 1 auto;
min-height: 0;
width: 100%;
display: flex;
flex-direction: column;
margin-top: 20rpx;
box-sizing: border-box;
overflow: hidden;
}
&__content {
width: 100%;
flex: 1 1 auto;
height: auto;
min-height: 100%;
max-height: none;
margin: 0;
padding-bottom: 40rpx;
box-sizing: border-box;
}
&__empty {
padding: 80rpx 0;
text-align: center;
color: #9ca3af;
font-size: 26rpx;
}
&__item {
display: flex;
flex-direction: column;
padding: 20rpx 0;
border-bottom: 1rpx solid #f2f2f2;
}
&__item--expanded {
padding-bottom: 24rpx;
}
&__item-top {
width: 100%;
}
&__item-image {
flex-shrink: 0;
width: 140rpx;
height: 140rpx;
border-radius: 12rpx;
background: #f6f7fb;
margin-right: 20rpx;
}
&__item-main {
flex: 1;
min-width: 0;
padding-top: 4rpx;
display: flex;
flex-direction: column;
gap: 10rpx;
}
&__item-name {
font-size: 28rpx;
color: #111827;
line-height: 40rpx;
}
&__item-sku {
font-size: 24rpx;
color: #6b7280;
line-height: 32rpx;
background: #f6f7fb;
padding: 4rpx 12rpx;
border-radius: 8rpx;
align-self: flex-start;
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
&__item-info {
display: flex;
flex-direction: column;
gap: 4rpx;
}
&__item-count {
font-size: 26rpx;
color: #111827;
font-weight: 500;
}
&__item-logistics {
font-size: 22rpx;
color: #6b7280;
}
&__item-action {
margin-top: 10rpx;
display: flex;
justify-content: flex-end;
}
&__btn {
min-width: 200rpx;
height: 60rpx;
line-height: 60rpx;
text-align: center;
border-radius: 30rpx;
font-size: 26rpx;
font-weight: 500;
padding: 0 24rpx;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 6rpx;
}
&__btn-arrow {
font-size: 22rpx;
transition: transform .2s ease;
display: inline-block;
transform-origin: center;
}
&__btn-arrow.rotated {
transform: rotate(180deg);
}
&__btn--ghost {
border: 2rpx solid #e5e7eb;
color: #4b5563;
background: #ffffff;
}
&__btn--primary {
background: linear-gradient(135deg, #fa8735 0%, #fe3b48 100%);
color: #ffffff;
}
&__btn--disabled {
opacity: 0.6;
}
&__track {
margin-top: 20rpx;
margin-left: 160rpx;
padding: 20rpx 20rpx 10rpx 20rpx;
background: #f8fafc;
border-radius: 12rpx;
}
&__track--fallback {
margin-left: 0;
}
&__item--fallback &__item-action {
margin-top: 16rpx;
}
&__fallback-top {
display: flex;
flex-direction: column;
gap: 8rpx;
padding: 8rpx 0;
}
&__fallback-title {
font-size: 30rpx;
font-weight: 600;
color: #111827;
line-height: 42rpx;
}
&__fallback-desc {
font-size: 24rpx;
color: #6b7280;
line-height: 32rpx;
}
&__track-loading,
&__track-empty {
padding: 28rpx 0;
text-align: center;
font-size: 24rpx;
color: #9ca3af;
}
&__track-list {
position: relative;
padding: 8rpx 0 0 10rpx;
}
&__track-node {
position: relative;
padding-left: 24rpx;
padding-bottom: 20rpx;
&:last-child {
padding-bottom: 10rpx;
}
&:last-child::before {
display: none;
}
}
&__track-node::before {
content: '';
position: absolute;
left: 4rpx;
top: 20rpx;
bottom: 0;
width: 2rpx;
background: #e5e7eb;
}
&__track-dot {
position: absolute;
left: -4rpx;
top: 8rpx;
width: 14rpx;
height: 14rpx;
border-radius: 50%;
background: #d1d5db;
border: 2rpx solid #ffffff;
box-sizing: border-box;
box-shadow: 0 0 0 2rpx #e5e7eb;
}
&__track-node.is-first &__track-dot {
background: linear-gradient(135deg, #fa8735 0%, #fe3b48 100%);
box-shadow: 0 0 0 2rpx rgba(250,135,53,0.25);
width: 16rpx;
height: 16rpx;
left: -5rpx;
}
&__track-content {
font-size: 24rpx;
line-height: 34rpx;
color: #374151;
word-break: break-all;
}
&__track-node.is-first &__track-content {
color: #111827;
font-weight: 600;
font-size: 26rpx;
}
&__track-time {
margin-top: 6rpx;
font-size: 22rpx;
line-height: 30rpx;
color: #9ca3af;
}
}
::v-deep .uni-popup {
background: transparent !important;
}
::v-deep .uni-popup__wrapper {
background: transparent !important;
}
::v-deep .uni-popup__wrapper-box {
background: transparent !important;
}
::v-deep .uni-popup__content {
background: transparent !important;
}
.express-popup--bottom ::v-deep .uni-popup__content,
.express-popup--bottom ::v-deep .uni-popup__wrapper-box {
border-radius: 24rpx 24rpx 0 0 !important;
overflow: hidden !important;
}
.express-popup--center ::v-deep .uni-popup__content,
.express-popup--center ::v-deep .uni-popup__wrapper-box {
border-radius: 24rpx !important;
overflow: hidden !important;
background: transparent !important;
}
</style>
+639
View File
@@ -0,0 +1,639 @@
<template>
<uni-popup ref="popupRef" :type="popupType" background-color="transparent">
<view class="receive-popup" :class="`receive-popup--${popupType}`" @tap.stop>
<view class="receive-popup__header">
<view>
<view class="receive-popup__title">确认收货</view>
<view class="receive-popup__order-no">订单号:{{ orderNo || '-' }}</view>
<view class="receive-popup__tip">请选择已收到货物的商品</view>
</view>
<view class="receive-popup__close" @tap.stop="handleClose">×</view>
</view>
<scroll-view scroll-y class="receive-popup__content">
<view v-if="renderItems.length === 0" class="receive-popup__empty">
暂无可确认收货的商品
</view>
<view
v-else
class="receive-popup__item"
v-for="(item, index) in renderItems"
:key="item.itemKey || index"
@tap.stop="toggleItem(index)"
>
<view class="receive-popup__checkbox">
<view
class="receive-popup__checkbox-inner"
:class="{ 'receive-popup__checkbox-inner--on': !!item.__checked }"
>
<text v-if="item.__checked" class="receive-popup__checkbox-tick">✓</text>
</view>
</view>
<image class="receive-popup__item-image" :src="item.picUrl" mode="aspectFill" />
<view class="receive-popup__item-main">
<view class="receive-popup__item-name lineTwo">{{ item.spuName }}</view>
<view class="receive-popup__item-sku">{{ item.skuText || '-' }}</view>
<view class="receive-popup__item-count">数量:x{{ item.count }}</view>
</view>
</view>
</scroll-view>
<view class="receive-popup__actions">
<view
class="receive-popup__select-all"
@tap.stop="toggleAll"
>
<view
class="receive-popup__checkbox-inner receive-popup__checkbox-inner--sm"
:class="{ 'receive-popup__checkbox-inner--on': isAllChecked }"
>
<text v-if="isAllChecked" class="receive-popup__checkbox-tick receive-popup__checkbox-tick--sm">✓</text>
</view>
<text class="receive-popup__select-all-text">全选(已选 {{ checkedCount }} 项)</text>
</view>
<view class="receive-popup__action-bar">
<view class="receive-popup__btn receive-popup__btn--ghost" @tap.stop="handleClose">
取消
</view>
<view
class="receive-popup__btn receive-popup__btn--primary"
:class="{ 'receive-popup__btn--disabled': checkedCount === 0 }"
@tap.stop="handleSubmit"
>
确认收货({{ checkedCount }})
</view>
</view>
</view>
</view>
</uni-popup>
</template>
<script setup>
import { computed, ref, watch } from 'vue';
const props = defineProps({
popupType: {
type: String,
default: 'bottom',
},
orderNo: {
type: String,
default: '',
},
orderData: {
type: Object,
default: () => ({}),
},
delayRecords: {
type: Array,
default: () => [],
},
});
const emit = defineEmits(['close', 'submit']);
const popupRef = ref();
const innerItems = ref([]);
const getFirstValidValue = (...values) =>
values.find((value) => value !== undefined && value !== null && String(value).trim() !== '') ?? '';
const hasValue = (value) => value !== undefined && value !== null && String(value).trim() !== '';
const formatSkuPropertyItem = (property) => {
const value = getFirstValidValue(
property?.valueName,
property?.value,
property?.specValue,
property?.attrValue,
property?.optionValue,
property?.propertyValue,
typeof property === 'string' ? property : '',
);
const name = getFirstValidValue(
property?.name,
property?.propertyName,
property?.specName,
property?.attrName,
property?.optionName,
property?.propertyKey,
'',
);
if (hasValue(name) && hasValue(value)) return `${name}:${value}`;
if (hasValue(value)) return String(value);
if (hasValue(name)) return String(name);
return '';
};
const formatSkuProperties = (properties) => {
if (!properties) return '';
if (typeof properties === 'string' && properties.trim()) return properties.trim();
if (Array.isArray(properties)) {
return properties.map(formatSkuPropertyItem).filter(Boolean).join(' ');
}
if (typeof properties === 'object') {
return Object.keys(properties)
.map((key) => {
const value = properties[key];
if (typeof value === 'object') return formatSkuPropertyItem(value);
return `${key}:${value}`;
})
.filter(Boolean)
.join(' ');
}
return '';
};
const resolveSpuItems = (data) => {
const items = Array.isArray(data?.items) ? data.items : [];
return items.flatMap((spu) => {
const subItems = Array.isArray(spu?.items) ? spu.items : [];
if (subItems.length > 0) {
return subItems.map((sub) => ({
...sub,
_spuName: getFirstValidValue(
spu?.spuName,
spu?.productName,
spu?.goodsName,
sub?.spuName,
sub?.productName,
sub?.goodsName,
),
_spuPic: getFirstValidValue(
spu?.picUrl,
spu?.imageUrl,
spu?.thumbUrl,
spu?.goodsPic,
sub?.picUrl,
sub?.imageUrl,
sub?.thumbUrl,
sub?.goodsPic,
),
_spuId: getFirstValidValue(spu?.spuId, spu?.productId, sub?.spuId, sub?.productId),
_skuText: getFirstValidValue(
sub?.skuProperties,
sub?.specInfo,
sub?.skuInfo,
sub?.skuText,
formatSkuProperties(sub?.skuProperties || sub?.specs || sub?.properties),
),
}));
}
return [
{
...spu,
_spuName: getFirstValidValue(spu?.spuName, spu?.productName, spu?.goodsName),
_spuPic: getFirstValidValue(
spu?.picUrl,
spu?.imageUrl,
spu?.thumbUrl,
spu?.goodsPic,
),
_spuId: getFirstValidValue(spu?.spuId, spu?.productId),
_skuText: getFirstValidValue(
spu?.skuProperties,
spu?.specInfo,
spu?.skuInfo,
spu?.skuText,
formatSkuProperties(spu?.skuProperties || spu?.specs || spu?.properties),
),
},
];
});
};
const resolveAllDelayRecords = () => {
const orderLevelRecords = Array.isArray(props.delayRecords)
? props.delayRecords
: Array.isArray(props.orderData?.delayRecords)
? props.orderData.delayRecords
: Array.isArray(props.orderData?.delayRecordList)
? props.orderData.delayRecordList
: [];
return orderLevelRecords.filter(Boolean);
};
const resolveCount = (record) =>
Number(
getFirstValidValue(
record?.count,
record?.num,
record?.quantity,
record?.number,
record?.totalCount,
1,
),
) || 1;
const resolveRecordOrderItemId = (record) =>
Number(
getFirstValidValue(
record?.orderItemId,
record?.orderItemVO?.id,
record?.orderItem?.id,
record?.itemId,
0,
),
) || 0;
const resolveRecordSkuText = (record) => {
const direct = getFirstValidValue(
record?.skuProperties,
record?.specInfo,
record?.skuText,
record?.skuInfo,
formatSkuProperties(record?.skuProperties || record?.specs || record?.properties),
);
if (direct) return direct;
const itemSpec = getFirstValidValue(
record?.orderItemVO?.skuProperties,
record?.orderItemVO?.specInfo,
record?.orderItem?.skuProperties,
record?.orderItem?.specInfo,
formatSkuProperties(record?.orderItemVO?.skuProperties || record?.orderItem?.specs),
);
return itemSpec;
};
const resolveRecordSpuName = (record) =>
getFirstValidValue(
record?.spuName,
record?.productName,
record?.goodsName,
record?.orderItemVO?.spuName,
record?.orderItem?.spuName,
record?.orderItemVO?.productName,
record?.orderItem?.productName,
);
const resolveRecordPicUrl = (record) =>
getFirstValidValue(
record?.picUrl,
record?.imageUrl,
record?.thumbUrl,
record?.goodsPic,
record?.orderItemVO?.picUrl,
record?.orderItem?.picUrl,
record?.orderItemVO?.imageUrl,
record?.orderItem?.imageUrl,
);
const buildShippedItemList = () => {
const records = resolveAllDelayRecords();
const shippedRecords = records.filter(
(record) => Number(record?.status) === 3 && Number(record?.delayRecordId || record?.id) > 0,
);
if (shippedRecords.length === 0) return [];
const spuItems = resolveSpuItems(props.orderData);
const findItemByOrderItemId = (id) =>
spuItems.find(
(sku) => Number(sku?.id || sku?.orderItemId || sku?.itemId || 0) === Number(id),
);
const findItemBySkuText = (text) =>
spuItems.find((sku) => {
const skuText = getFirstValidValue(
sku?.skuProperties,
sku?.specInfo,
sku?.skuInfo,
sku?.skuText,
formatSkuProperties(sku?.skuProperties || sku?.specs || sku?.properties),
);
return !!text && !!skuText && String(text).trim() === String(skuText).trim();
});
const singleSpu =
spuItems.length === 1
? spuItems[0]
: new Set(spuItems.map((s) => s?._spuId || s?._spuName)).size === 1
? spuItems[0]
: null;
return shippedRecords.map((record, idx) => {
const orderItemId = resolveRecordOrderItemId(record);
const recordSku = resolveRecordSkuText(record);
let matched = orderItemId ? findItemByOrderItemId(orderItemId) : null;
if (!matched && recordSku) matched = findItemBySkuText(recordSku);
if (!matched && singleSpu) matched = singleSpu;
const count = resolveCount(record);
const spuName = matched
? getFirstValidValue(matched._spuName, matched?.spuName, matched?.productName)
: resolveRecordSpuName(record);
const picUrl = matched
? getFirstValidValue(matched._spuPic, matched?.picUrl, matched?.imageUrl)
: resolveRecordPicUrl(record);
const skuText = matched
? getFirstValidValue(
matched?._skuText,
matched?.skuProperties,
matched?.specInfo,
matched?.skuInfo,
matched?.skuText,
formatSkuProperties(matched?.skuProperties || matched?.specs || matched?.properties),
)
: recordSku;
const delayRecordId = Number(record?.delayRecordId || record?.id) || 0;
return {
itemKey: `${delayRecordId}-${idx}`,
delayRecordId,
spuName: spuName || '商品信息',
skuText: skuText || '单规格',
picUrl: picUrl || '',
count,
__checked: true,
};
});
};
const renderItems = computed(() => innerItems.value || []);
const isAllChecked = computed(() => {
const list = renderItems.value;
return list.length > 0 && list.every((item) => !!item.__checked);
});
const checkedCount = computed(
() => renderItems.value.filter((item) => !!item.__checked).length,
);
const open = () => {
innerItems.value = buildShippedItemList();
popupRef.value?.open?.();
};
const close = () => {
popupRef.value?.close?.();
};
const handleClose = () => {
emit('close');
close();
};
const toggleItem = (index) => {
if (!innerItems.value[index]) return;
innerItems.value[index].__checked = !innerItems.value[index].__checked;
};
const toggleAll = () => {
const target = !isAllChecked.value;
innerItems.value.forEach((item) => (item.__checked = target));
};
const handleSubmit = () => {
const checkedItems = renderItems.value
.filter((item) => !!item.__checked && Number(item.delayRecordId) > 0)
.map((item) => ({ delayRecordId: Number(item.delayRecordId) }));
if (checkedItems.length === 0) {
uni.showToast({
title: '请选择要确认收货的商品',
icon: 'none',
});
return;
}
emit('submit', { items: checkedItems });
};
defineExpose({ open, close });
</script>
<style lang="scss" scoped>
.receive-popup {
background: #ffffff;
box-sizing: border-box;
display: flex;
flex-direction: column;
&--bottom {
width: 100%;
max-height: 82vh;
border-radius: 24rpx 24rpx 0 0;
padding: 32rpx 32rpx calc(24rpx + env(safe-area-inset-bottom)) 32rpx;
overflow: hidden;
}
&--center {
width: 680rpx;
max-height: 78vh;
border-radius: 24rpx;
padding: 32rpx 32rpx 0 32rpx;
margin: 0 auto;
overflow: hidden;
}
&--center &__content {
max-height: 52vh;
}
&--center &__btn {
min-width: 160rpx;
}
&__header {
display: flex;
justify-content: space-between;
align-items: flex-start;
padding-bottom: 24rpx;
border-bottom: 1rpx solid #f2f2f2;
}
&__title {
font-size: 32rpx;
font-weight: 600;
color: #111827;
line-height: 44rpx;
}
&__order-no {
margin-top: 8rpx;
font-size: 24rpx;
color: #6b7280;
line-height: 32rpx;
}
&__tip {
margin-top: 8rpx;
font-size: 24rpx;
color: #f97316;
line-height: 32rpx;
}
&__close {
width: 48rpx;
height: 48rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 40rpx;
color: #9ca3af;
line-height: 1;
}
&__content {
flex: 1;
min-height: 0;
max-height: calc(82vh - 420rpx - env(safe-area-inset-bottom));
margin-top: 20rpx;
box-sizing: border-box;
}
&__empty {
padding: 80rpx 0;
text-align: center;
color: #9ca3af;
font-size: 26rpx;
}
&__item {
display: flex;
align-items: flex-start;
padding: 20rpx 0;
border-bottom: 1rpx solid #f2f2f2;
}
&__checkbox {
flex-shrink: 0;
width: 56rpx;
padding-top: 20rpx;
display: flex;
align-items: center;
justify-content: center;
}
&__checkbox-inner {
width: 40rpx;
height: 40rpx;
border: 2rpx solid #d1d5db;
border-radius: 50%;
background: #ffffff;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.15s;
box-sizing: border-box;
&--sm {
width: 32rpx;
height: 32rpx;
}
&--on {
background: #f97316;
border-color: #f97316;
}
}
&__checkbox-tick {
color: #ffffff;
font-size: 24rpx;
line-height: 1;
font-weight: 600;
&--sm {
font-size: 20rpx;
}
}
&__item-image {
flex-shrink: 0;
width: 140rpx;
height: 140rpx;
border-radius: 12rpx;
background: #f6f7fb;
margin-right: 20rpx;
}
&__item-main {
flex: 1;
min-width: 0;
padding-top: 4rpx;
display: flex;
flex-direction: column;
gap: 10rpx;
}
&__item-name {
font-size: 28rpx;
color: #111827;
line-height: 40rpx;
}
&__item-sku {
font-size: 24rpx;
color: #6b7280;
line-height: 32rpx;
background: #f6f7fb;
padding: 4rpx 12rpx;
border-radius: 8rpx;
align-self: flex-start;
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
&__item-count {
font-size: 26rpx;
color: #111827;
font-weight: 500;
}
&__actions {
padding: 16rpx 0 0 0;
background: #ffffff;
position: sticky;
bottom: 0;
left: 0;
right: 0;
z-index: 20;
box-shadow: 0 -8rpx 20rpx -10rpx rgba(0, 0, 0, 0.06);
padding-bottom: env(safe-area-inset-bottom);
margin-top: 20rpx;
}
&__select-all {
display: flex;
align-items: center;
padding: 8rpx 0 16rpx 0;
flex-shrink: 0;
}
&__select-all-text {
margin-left: 12rpx;
font-size: 26rpx;
color: #374151;
font-weight: 500;
}
&__action-bar {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 20rpx;
padding-bottom: 20rpx;
flex-shrink: 0;
}
&__btn {
min-width: 180rpx;
height: 72rpx;
line-height: 72rpx;
text-align: center;
border-radius: 36rpx;
font-size: 28rpx;
font-weight: 500;
padding: 0 28rpx;
}
&__btn--ghost {
border: 2rpx solid #e5e7eb;
color: #4b5563;
background: #ffffff;
}
&__btn--primary {
background: #f97316;
color: #ffffff;
}
&__btn--disabled {
opacity: 0.6;
}
}
::v-deep .uni-popup {
background: transparent !important;
}
::v-deep .uni-popup__wrapper {
background: transparent !important;
}
::v-deep .uni-popup__wrapper-box {
background: transparent !important;
}
::v-deep .uni-popup__content {
background: transparent !important;
}
.receive-popup--bottom ::v-deep .uni-popup__content,
.receive-popup--bottom ::v-deep .uni-popup__wrapper-box {
border-radius: 24rpx 24rpx 0 0 !important;
overflow: hidden !important;
}
.receive-popup--center ::v-deep .uni-popup__content,
.receive-popup--center ::v-deep .uni-popup__wrapper-box {
border-radius: 24rpx !important;
overflow: hidden !important;
background: transparent !important;
}
</style>
+863
View File
@@ -0,0 +1,863 @@
<template>
<uni-popup ref="popupRef" :type="popupType" background-color="transparent">
<view class="shipment-popup" :class="`shipment-popup--${popupType}`" @tap.stop>
<view class="shipment-popup__header">
<view>
<view class="shipment-popup__title">{{ titleText }}</view>
<view class="shipment-popup__order-no">订单号:{{ orderNo || '-' }}</view>
<view class="shipment-popup__order-time">下单时间:{{ orderTime || '-' }}</view>
</view>
<view class="shipment-popup__close" @tap.stop="handleClose">×</view>
</view>
<view class="shipment-popup__desc">{{ descText }}</view>
<scroll-view scroll-y class="shipment-popup__content">
<view v-if="renderItems.length === 0" class="shipment-popup__empty">
{{ emptyText }}
</view>
<view
v-else
class="shipment-popup__item"
v-for="(item, index) in renderItems"
:key="item.itemKey || index"
>
<image class="shipment-popup__item-image" :src="item.picUrl" mode="aspectFill" />
<view class="shipment-popup__item-main">
<view class="shipment-popup__item-name lineTwo">{{ item.spuName }}</view>
<view class="shipment-popup__item-sku">{{ item.skuText || '-' }}</view>
<view class="shipment-popup__item-footer flex-center ju-between">
<view class="shipment-popup__item-count">
<view class="shipment-popup__item-tags flex-wrap">
<text v-if="props.mode === 'delay' && Number(item.alreadyDelayed) > 0" class="shipment-popup__item-delayed">
已延迟 x{{ item.alreadyDelayed }}
</text>
<text v-if="props.mode === 'delay' && Number(item.shippedOrReceived) > 0" class="shipment-popup__item-shipped">
已出单 x{{ item.shippedOrReceived }}
</text>
</view>
<text class="shipment-popup__item-remain">最多可选 x{{ item.maxCount }}</text>
</view>
<su-number-box
v-model="item.selectedCount"
:min="0"
:max="item.maxCount"
:step="1"
background="#F6F7FB"
color="#333333"
@change="onCountChange(index, $event)"
/>
</view>
</view>
</view>
</scroll-view>
<view class="shipment-popup__actions">
<view class="shipment-popup__btn shipment-popup__btn--ghost" @tap.stop="handleClose">
取消
</view>
<view class="shipment-popup__btn shipment-popup__btn--primary" @tap.stop="handleSubmit">
{{ submitText }}
</view>
</view>
</view>
</uni-popup>
</template>
<script setup>
import { computed, ref } from 'vue';
const props = defineProps({
mode: {
type: String,
default: 'delay',
},
popupType: {
type: String,
default: 'bottom',
},
orderNo: {
type: String,
default: '',
},
orderTime: {
type: String,
default: '',
},
orderData: {
type: Object,
default: () => ({}),
},
delayRecords: {
type: Array,
default: () => [],
},
});
const emit = defineEmits(['close', 'submit']);
const popupRef = ref();
const innerItems = ref([]);
const titleText = computed(() => (props.mode === 'now' ? '立即发货' : '延迟发货'));
const submitText = computed(() => (props.mode === 'now' ? '确认立即发货' : '确认延迟发货'));
const descText = computed(() =>
props.mode === 'now' ? '请选择当前延迟商品及立即发货数量' : '请选择当前商品及延迟发货数量',
);
const emptyText = computed(() =>
props.mode === 'now' ? '暂无可立即发货的商品' : '暂无可延迟发货的商品',
);
const getFirstValidValue = (...values) =>
values.find((value) => value !== undefined && value !== null && String(value).trim() !== '') ?? '';
const hasValue = (value) => value !== undefined && value !== null && String(value).trim() !== '';
const formatSkuPropertyItem = (property) => {
const value = getFirstValidValue(
property?.valueName,
property?.value,
property?.specValue,
property?.attrValue,
property?.optionValue,
property?.propertyValue,
typeof property === 'string' ? property : '',
);
const name = getFirstValidValue(
property?.name,
property?.propertyName,
property?.specName,
property?.attrName,
property?.key,
property?.label,
);
if (name && value) {
return `${name} ${value}`;
}
return value || name || '';
};
const formatSkuProperties = (properties) => {
if (typeof properties === 'string' && properties.trim()) {
return properties.trim();
}
const list = Array.isArray(properties) ? properties : [];
if (!list.length) {
return '';
}
return list
.map((property) => formatSkuPropertyItem(property))
.filter(Boolean)
.join(' ');
};
const resolveOrderItemId = (item = {}) =>
getFirstValidValue(item?.orderItemId, item?.itemId, item?.orderGoodsId, item?.id);
const resolveRecordItemId = (record = {}) =>
getFirstValidValue(record?.orderItemId, record?.itemId, record?.orderGoodsId);
const resolveRecordUniqueId = (record = {}) =>
getFirstValidValue(record?.id, record?.delayRecordId, record?.recordId);
const resolveRecordCount = (record = {}) => {
const candidates = [
record?.count,
record?.delayCount,
record?.recordCount,
record?.remainingCount,
record?.availableCount,
record?.canCount,
record?.maxCount,
];
const matched = candidates
.map((value) => Number(value))
.find((value) => Number.isFinite(value) && value > 0);
return matched || 0;
};
const isSameSku = (skuItem = {}, record = {}) => {
const skuProps = Array.isArray(skuItem?.properties)
? skuItem.properties
: Array.isArray(skuItem?.skuProperties)
? skuItem.skuProperties
: Array.isArray(skuItem?.attrs)
? skuItem.attrs
: Array.isArray(skuItem?.specs)
? skuItem.specs
: Array.isArray(skuItem?.specifications)
? skuItem.specifications
: [];
const recordProps = Array.isArray(record?.properties)
? record.properties
: Array.isArray(record?.skuProperties)
? record.skuProperties
: Array.isArray(record?.attrs)
? record.attrs
: Array.isArray(record?.specs)
? record.specs
: Array.isArray(record?.specifications)
? record.specifications
: [];
if (skuProps.length && recordProps.length && skuProps.length === recordProps.length) {
const skuKey = skuProps
.map((p) => `${getFirstValidValue(p?.valueName, p?.value, p?.specValue, p?.attrValue, p?.optionValue, p?.propertyValue)}`)
.filter(Boolean)
.join('|');
const recKey = recordProps
.map((p) => `${getFirstValidValue(p?.valueName, p?.value, p?.specValue, p?.attrValue, p?.optionValue, p?.propertyValue)}`)
.filter(Boolean)
.join('|');
if (skuKey && recKey) return skuKey === recKey;
if (skuKey || recKey) return false;
} else if (skuProps.length || recordProps.length) {
return false;
}
const skuText = getFirstValidValue(
skuItem?.skuText,
skuItem?.specText,
skuItem?.propertiesText,
skuItem?.skuDesc,
skuItem?.specDesc,
skuItem?.specification,
formatSkuProperties(skuItem?.properties),
formatSkuProperties(skuItem?.skuProperties),
formatSkuProperties(skuItem?.attrs),
);
const recText = getFirstValidValue(
record?.skuText,
record?.specText,
record?.propertiesText,
formatSkuProperties(record?.properties),
formatSkuProperties(record?.skuProperties),
formatSkuProperties(record?.attrs),
formatSkuProperties(record?.specs),
formatSkuProperties(record?.specifications),
record?.skuDesc,
record?.specDesc,
record?.specification,
record?.propertiesValue,
record?.skuValue,
record?.sku,
record?.specInfo,
record?.attrText,
);
if (skuText && recText) return skuText === recText;
if (skuText || recText) return false;
return false;
};
const resolveDelayItemCount = (item = {}) => {
const candidates = [
item?.count,
item?.remainingCount,
item?.availableCount,
item?.canCount,
item?.maxCount,
item?.goodsCount,
item?.productCount,
item?.num,
item?.number,
item?.quantity,
];
const matched = candidates
.map((value) => Number(value))
.find((value) => Number.isFinite(value) && value > 0);
return matched || 0;
};
const buildAlreadyDelayedCountForSpu = (spuItem = {}, parentSpu = {}, delayRecordsInput) => {
const skuItems = Array.isArray(spuItem?.items) && spuItem.items.length > 0 ? spuItem.items : [spuItem];
const targetSpuId = getFirstValidValue(
spuItem?.spuId,
spuItem?.productId,
spuItem?.goodsId,
parentSpu?.spuId,
parentSpu?.productId,
parentSpu?.goodsId,
);
const targetSpuName = getFirstValidValue(
spuItem?.spuName,
spuItem?.name,
spuItem?.goodsName,
spuItem?.productName,
parentSpu?.spuName,
parentSpu?.name,
parentSpu?.goodsName,
parentSpu?.productName,
);
const matchSpuIdentity = (record) => {
const recordSpuId = getFirstValidValue(record?.spuId, record?.productId, record?.goodsId);
if (targetSpuId && recordSpuId) return String(targetSpuId) === String(recordSpuId);
const recordSpuName = getFirstValidValue(record?.spuName, record?.name, record?.goodsName, record?.productName);
if (targetSpuName && recordSpuName) return String(targetSpuName).trim() === String(recordSpuName).trim();
return false;
};
const buildEmptyMap = () => {
const empty = new Map();
skuItems.forEach((_, i) => empty.set(resolveOrderItemId(skuItems[i]) || `sku-${i}`, 0));
return empty;
};
const deductedMap = buildEmptyMap();
const delayedOnlyMap = buildEmptyMap();
const shippedReceivedMap = buildEmptyMap();
const allRecords = (Array.isArray(delayRecordsInput) && delayRecordsInput.length > 0 ? delayRecordsInput : []).filter((r) => {
if (!r) return false;
if (!matchSpuIdentity(r)) return false;
const c = resolveRecordCount(r);
return c > 0;
});
if (!allRecords.length || !skuItems.length) {
return {
deducted: deductedMap,
delayedOnly: delayedOnlyMap,
shippedAndReceived: shippedReceivedMap,
};
}
const DEDUCT_STATUS_SET = new Set([1, 3, 4]);
const DELAY_ONLY_SET = new Set([1]);
const SHIPPED_RECEIVED_SET = new Set([3, 4]);
const usedRecordKeys = new Set();
const addToMap = (targetMap, key, count) => {
if (!targetMap.has(key)) targetMap.set(key, 0);
targetMap.set(key, (Number(targetMap.get(key)) || 0) + count);
};
const addRecordCountToSku = (record, skuItem, skuIdx) => {
const rKey = resolveRecordUniqueId(record) || JSON.stringify(record);
if (usedRecordKeys.has(rKey)) return false;
const skuKey = resolveOrderItemId(skuItem) || `sku-${skuIdx}`;
const c = resolveRecordCount(record);
const status = Number(record?.status);
if (DEDUCT_STATUS_SET.has(status)) addToMap(deductedMap, skuKey, c);
if (DELAY_ONLY_SET.has(status)) addToMap(delayedOnlyMap, skuKey, c);
if (SHIPPED_RECEIVED_SET.has(status)) addToMap(shippedReceivedMap, skuKey, c);
usedRecordKeys.add(rKey);
return true;
};
allRecords.forEach((record) => {
const recordItemId = resolveRecordItemId(record);
if (!recordItemId) return;
const matchedIdx = skuItems.findIndex((skuItem) => {
const skuItemId = resolveOrderItemId(skuItem);
return skuItemId && String(skuItemId) === String(recordItemId);
});
if (matchedIdx >= 0) addRecordCountToSku(record, skuItems[matchedIdx], matchedIdx);
});
allRecords.forEach((record) => {
const rKey = resolveRecordUniqueId(record) || JSON.stringify(record);
if (usedRecordKeys.has(rKey)) return;
const matchedIdx = skuItems.findIndex((skuItem) => isSameSku(skuItem, record));
if (matchedIdx >= 0) addRecordCountToSku(record, skuItems[matchedIdx], matchedIdx);
});
allRecords.forEach((record) => {
const rKey = resolveRecordUniqueId(record) || JSON.stringify(record);
if (usedRecordKeys.has(rKey)) return;
if (skuItems.length === 1 && matchSpuIdentity(record)) {
addRecordCountToSku(record, skuItems[0], 0);
}
});
return {
deducted: deductedMap,
delayedOnly: delayedOnlyMap,
shippedAndReceived: shippedReceivedMap,
};
};
const getCountFromMap = (map, skuItem, skuIdx) => {
if (!map || map.size === 0) return 0;
const key = resolveOrderItemId(skuItem) || `sku-${skuIdx}`;
return Number(map.get(key)) || 0;
};
const getSkuAlreadyDelayedCount = (skuCountMap, skuItem, skuIdx) => {
if (!skuCountMap) return 0;
if (skuCountMap instanceof Map) {
return getCountFromMap(skuCountMap, skuItem, skuIdx);
}
const legacy = skuCountMap?.deducted ?? skuCountMap;
return getCountFromMap(legacy, skuItem, skuIdx);
};
const resolveDelayRecordId = (item = {}) =>
getFirstValidValue(item?.delayRecordId, item?.recordId, item?.id);
const resolveDelayRecordCount = (item = {}) => {
const candidates = [
item?.count,
item?.delayCount,
item?.recordCount,
item?.remainingCount,
item?.availableCount,
item?.canCount,
item?.maxCount,
];
const matched = candidates
.map((value) => Number(value))
.find((value) => Number.isFinite(value) && value > 0);
return matched || 0;
};
const createDelayShipmentItems = (data) => {
const sourceItems = Array.isArray(data?.items) ? data.items : [];
const delayRecordsInput = Array.isArray(props.delayRecords) ? props.delayRecords : [];
const results = [];
sourceItems.forEach((spuItem) => {
const hasNested = Array.isArray(spuItem?.items) && spuItem.items.length > 0;
const counter = buildAlreadyDelayedCountForSpu(spuItem, spuItem, delayRecordsInput);
const deductedMap = counter?.deducted;
const delayedOnlyMap = counter?.delayedOnly;
const shippedReceivedMap = counter?.shippedAndReceived;
if (hasNested) {
spuItem.items.forEach((skuItem, idx) => {
if (!skuItem) return;
const totalCount = resolveDelayItemCount(skuItem);
const deducted = getCountFromMap(deductedMap, skuItem, idx);
const delayedOnly = getCountFromMap(delayedOnlyMap, skuItem, idx);
const shippedReceived = getCountFromMap(shippedReceivedMap, skuItem, idx);
const remaining = Math.max(0, Number(totalCount) - Number(deducted));
const maxCount = remaining;
if (maxCount <= 0) return;
const orderItemId = resolveOrderItemId(skuItem);
const parentOrderItemId = resolveOrderItemId(spuItem);
const submitOrderItemId = getFirstValidValue(orderItemId, parentOrderItemId);
const skuText = getFirstValidValue(
formatSkuProperties(skuItem?.properties || spuItem?.properties),
formatSkuProperties(skuItem?.skuProperties || spuItem?.skuProperties),
formatSkuProperties(skuItem?.attrs || spuItem?.attrs),
formatSkuProperties(skuItem?.specs || spuItem?.specs),
formatSkuProperties(skuItem?.specifications || spuItem?.specifications),
getFirstValidValue(skuItem?.skuText, spuItem?.skuText),
getFirstValidValue(skuItem?.specText, spuItem?.specText),
getFirstValidValue(skuItem?.propertiesText, spuItem?.propertiesText),
getFirstValidValue(skuItem?.skuDesc, spuItem?.skuDesc),
getFirstValidValue(skuItem?.specDesc, spuItem?.specDesc),
);
results.push({
itemKey: getFirstValidValue(
submitOrderItemId,
`${skuItem?.spuName || skuItem?.name || spuItem?.spuName || spuItem?.name || ''}_${skuText}_${totalCount}_${deducted}`,
),
orderItemId,
parentOrderItemId,
submitOrderItemId,
picUrl: skuItem?.picUrl || spuItem?.picUrl || '',
spuName: skuItem?.spuName || skuItem?.name || spuItem?.spuName || spuItem?.name || '',
skuText,
totalCount,
deducted,
alreadyDelayed: delayedOnly,
shippedOrReceived: shippedReceived,
maxCount,
selectedCount: maxCount,
});
});
} else {
const totalCount = resolveDelayItemCount(spuItem);
const deducted = getCountFromMap(deductedMap, spuItem, 0);
const delayedOnly = getCountFromMap(delayedOnlyMap, spuItem, 0);
const shippedReceived = getCountFromMap(shippedReceivedMap, spuItem, 0);
const remaining = Math.max(0, Number(totalCount) - Number(deducted));
const maxCount = remaining;
if (maxCount <= 0) return;
const orderItemId = resolveOrderItemId(spuItem);
const submitOrderItemId = orderItemId;
const skuText = getFirstValidValue(
formatSkuProperties(spuItem?.properties),
formatSkuProperties(spuItem?.skuProperties),
formatSkuProperties(spuItem?.attrs),
formatSkuProperties(spuItem?.specs),
formatSkuProperties(spuItem?.specifications),
getFirstValidValue(spuItem?.skuText, spuItem?.specText, spuItem?.propertiesText),
getFirstValidValue(spuItem?.skuDesc, spuItem?.specDesc),
);
results.push({
itemKey: getFirstValidValue(
submitOrderItemId,
`${spuItem?.spuName || spuItem?.name || ''}_${skuText}_${totalCount}_${deducted}`,
),
orderItemId,
parentOrderItemId: orderItemId,
submitOrderItemId,
picUrl: spuItem?.picUrl || '',
spuName: spuItem?.spuName || spuItem?.name || '',
skuText,
totalCount,
deducted,
alreadyDelayed: delayedOnly,
shippedOrReceived: shippedReceived,
maxCount,
selectedCount: maxCount,
});
}
});
return results;
};
const createNowShipmentItem = (item) => {
const maxCount = resolveDelayRecordCount(item);
const delayRecordId = resolveDelayRecordId(item);
const skuText = getFirstValidValue(
formatSkuProperties(item?.properties),
formatSkuProperties(item?.skuProperties),
formatSkuProperties(item?.attrs),
formatSkuProperties(item?.specs),
formatSkuProperties(item?.specifications),
getFirstValidValue(item?.skuText, item?.specText, item?.propertiesText),
getFirstValidValue(item?.propertiesValue, item?.skuValue),
getFirstValidValue(item?.skuDesc, item?.specDesc, item?.specification),
getFirstValidValue(item?.sku, item?.specInfo, item?.attrText),
);
return {
itemKey: getFirstValidValue(
delayRecordId,
`${item?.spuName || item?.name || item?.title || ''}_${skuText}_${maxCount}`,
),
delayRecordId,
picUrl: getFirstValidValue(
item?.picUrl,
item?.image,
item?.imgUrl,
item?.thumbnail,
item?.pic,
item?.cover,
item?.spuImage,
item?.skuImage,
),
spuName: getFirstValidValue(
item?.spuName,
item?.name,
item?.title,
item?.goodsName,
item?.productName,
item?.spuTitle,
),
skuText,
maxCount,
selectedCount: maxCount,
};
};
const createNowShipmentItems = (data) => {
const rawExternal = Array.isArray(props.delayRecords) && props.delayRecords.length > 0
? props.delayRecords
: [];
const rawFromData = Array.isArray(data?.delayRecords)
? data.delayRecords
: Array.isArray(data?.delayRecordList)
? data.delayRecordList
: [];
const raw = rawExternal.length > 0 ? rawExternal : rawFromData;
return raw
.filter(Boolean)
.filter((item) => {
const status = Number(item?.status);
if (!status) return true;
return status === 1;
})
.map((item) => createNowShipmentItem(item))
.filter((item) => item.maxCount > 0);
};
const renderItems = computed(() => innerItems.value || []);
const open = () => {
const nextItems = props.mode === 'now' ? createNowShipmentItems(props.orderData) : createDelayShipmentItems(props.orderData);
innerItems.value = nextItems;
if (!popupRef.value || typeof popupRef.value.open !== 'function') {
uni.showToast({
title: '弹窗组件初始化失败,请重试',
icon: 'none',
});
return;
}
popupRef.value.open();
};
const close = () => {
if (popupRef.value && typeof popupRef.value.close === 'function') {
popupRef.value.close();
}
};
const handleClose = () => {
emit('close');
close();
};
const onCountChange = (index, value) => {
const current = innerItems.value[index];
if (!current) return;
const next = Number(value);
if (!Number.isFinite(next)) {
current.selectedCount = 0;
return;
}
current.selectedCount = Math.min(current.maxCount, Math.max(0, next));
};
const buildSubmitPayload = () => {
if (props.mode === 'now') {
const hasSelectedCount = innerItems.value.some((item) => Number(item.selectedCount) > 0);
const items = innerItems.value
.filter((item) => Number(item.selectedCount) > 0 && hasValue(item.delayRecordId))
.map((item) => ({
delayRecordId: item.delayRecordId,
count: Number(item.selectedCount),
}));
return {
hasSelectedCount,
items,
emptyTitle: hasSelectedCount ? '订单商品信息异常' : '请选择立即发货数量',
};
}
const hasSelectedCount = innerItems.value.some((item) => Number(item.selectedCount) > 0);
const items = innerItems.value
.filter((item) => Number(item.selectedCount) > 0 && hasValue(item.submitOrderItemId))
.map((item) => ({
orderItemId: item.submitOrderItemId,
count: Number(item.selectedCount),
}));
return {
hasSelectedCount,
items,
emptyTitle: hasSelectedCount ? '订单商品信息异常' : '请选择延迟发货数量',
};
};
const handleSubmit = () => {
const payload = buildSubmitPayload();
if (!payload.items.length) {
uni.showToast({
title: payload.emptyTitle,
icon: 'none',
});
return;
}
emit('submit', {
mode: props.mode,
items: payload.items,
close,
});
};
defineExpose({
open,
close,
});
</script>
<style lang="scss" scoped>
.shipment-popup {
background: #ffffff;
box-sizing: border-box;
display: flex;
flex-direction: column;
}
.shipment-popup--bottom {
width: 100%;
max-height: 82vh;
border-radius: 24rpx 24rpx 0 0;
padding: 32rpx 24rpx calc(48rpx + env(safe-area-inset-bottom));
overflow: hidden;
}
.shipment-popup--center {
width: 680rpx;
max-height: 82vh;
border-radius: 24rpx;
padding: 32rpx 24rpx 40rpx 24rpx;
overflow: hidden;
}
.shipment-popup__header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12rpx;
flex-shrink: 0;
}
.shipment-popup__title {
font-size: 34rpx;
font-weight: 600;
color: #333333;
}
.shipment-popup__order-no {
margin-top: 8rpx;
font-size: 22rpx;
line-height: 32rpx;
color: #999999;
word-break: break-all;
}
.shipment-popup__order-time {
margin-top: 4rpx;
font-size: 22rpx;
line-height: 32rpx;
color: #999999;
}
.shipment-popup__close {
width: 56rpx;
height: 56rpx;
border-radius: 50%;
background: #f3f4f6;
line-height: 56rpx;
text-align: center;
font-size: 36rpx;
color: #666666;
flex-shrink: 0;
}
.shipment-popup__desc {
font-size: 24rpx;
color: #999999;
margin-bottom: 24rpx;
flex-shrink: 0;
}
.shipment-popup__content {
flex: 1;
min-height: 0;
max-height: calc(82vh - 360rpx - env(safe-area-inset-bottom));
box-sizing: border-box;
}
.shipment-popup__item {
display: flex;
padding: 20rpx 0;
border-bottom: 1rpx solid #f2f2f2;
}
.shipment-popup__item-image {
width: 144rpx;
height: 144rpx;
border-radius: 12rpx;
flex-shrink: 0;
margin-right: 20rpx;
background: #f5f5f5;
}
.shipment-popup__item-main {
flex: 1;
min-width: 0;
}
.shipment-popup__item-name {
font-size: 28rpx;
line-height: 40rpx;
color: #333333;
}
.shipment-popup__item-sku {
margin-top: 10rpx;
font-size: 24rpx;
line-height: 34rpx;
color: #999999;
}
.shipment-popup__item-footer {
margin-top: 20rpx;
}
.shipment-popup__item-count {
font-size: 24rpx;
color: #666666;
display: flex;
flex-direction: column;
align-items: flex-start;
flex-wrap: wrap;
gap: 6rpx;
}
.shipment-popup__item-tags {
display: inline-flex;
align-items: center;
flex-wrap: wrap;
gap: 8rpx;
}
.shipment-popup__item-delayed {
color: #FA7E31;
background: #FFF4EC;
padding: 4rpx 12rpx;
border-radius: 8rpx;
}
.shipment-popup__item-shipped {
color: #1677FF;
background: #E8F1FF;
padding: 4rpx 12rpx;
border-radius: 8rpx;
}
.shipment-popup__item-remain {
color: #666666;
}
.shipment-popup__actions {
display: flex;
align-items: center;
gap: 20rpx;
margin-top: 24rpx;
flex-shrink: 0;
position: sticky;
bottom: 0;
left: 0;
right: 0;
z-index: 20;
background: #ffffff;
padding-top: 16rpx;
padding-bottom: env(safe-area-inset-bottom);
box-shadow: 0 -8rpx 20rpx -10rpx rgba(0, 0, 0, 0.06);
}
.shipment-popup__btn {
flex: 1;
height: 84rpx;
line-height: 84rpx;
text-align: center;
border-radius: 42rpx;
font-size: 28rpx;
font-weight: 500;
}
.shipment-popup__btn--ghost {
background: #f2f3f5;
color: #333333;
}
.shipment-popup__btn--primary {
background: linear-gradient(135deg, #fa8735 0%, #fe3b48 100%);
color: #ffffff;
}
.shipment-popup__empty {
padding: 40rpx 24rpx;
text-align: center;
font-size: 26rpx;
color: #999999;
}
::v-deep .uni-popup {
background: transparent !important;
}
::v-deep .uni-popup__wrapper {
background: transparent !important;
}
::v-deep .uni-popup__wrapper-box {
background: transparent !important;
}
::v-deep .uni-popup__content {
background: transparent !important;
}
.shipment-popup--bottom ::v-deep .uni-popup__content,
.shipment-popup--bottom ::v-deep .uni-popup__wrapper-box {
border-radius: 24rpx 24rpx 0 0 !important;
overflow: hidden !important;
}
.shipment-popup--center ::v-deep .uni-popup__content,
.shipment-popup--center ::v-deep .uni-popup__wrapper-box {
border-radius: 24rpx !important;
overflow: hidden !important;
background: transparent !important;
}
</style>
+813 -145
View File
@@ -1,163 +1,831 @@
<template>
<view class="order_con" :class="{ bg24: props.theme == 2 }">
<view class="order_con" :class="{ bg24: props.theme == 2 }">
<view class="flex-center ju-between m-b-28" v-if="(props.type == 2 || props.type == 4) && props.data.logisticsNo">
<view>{{ props.data.logisticsName }} {{ props.data.logisticsNo }}</view>
<view class="flex-center">
<view @click.stop="onCopy(props.data.logisticsNo)">复制</view>
<truckLine :data="props.data" :code="2" v-if="props.data.deliveryTime && props.data.logisticsNo" @openExpress="handleTruckLineOpenExpress"></truckLine>
</view>
</view>
<view class="flex-center ju-between m-b-28"
v-if="(props.type == 2 || props.type == 4) && props.data.logisticsNo">
<view>{{ props.data.logisticsName }} {{ props.data.logisticsNo }}</view>
<view class="flex-center">
<view @click.stop="onCopy(props.data.logisticsNo)">复制</view>
<truckLine :data="props.data" :code="2" v-if="props.data.deliveryTime && props.data.logisticsNo"></truckLine>
</view>
</view>
<view class="con_item flex-center ju-between" v-for="(v, i) in props.data.items" :key="i"
:class="{ 'al-flex-start': props.type == 3 || props.type == 4 }">
<view class="order_img shrink" :class="{ 'm-r-16': props.type == 3 }">
<image :src="`${v.picUrl}`" mode="aspectFill" />
</view>
<view class="flex1">
<view class="flex-row ju-between m-b-6">
<view class="size28 spuName lineTwo" :class="{ 'p-r-10': props.type == 3, c0: props.theme == 2 }">
{{ v.spuName }}
</view>
<view class="shrink price" v-if="props.type != 4"><span class="size24">¥</span><span class="size36"
style="font-weight: 600">{{ fen2yuan(v.price) }}</span></view>
</view>
<view v-if="props.type == 4">
<view class="m-b-12 size24 h_52" v-for="(item, i) in v.items" :key="i">
<view class="flex1 flex-center ju-between h_52 bg18 radius8 p-l-8 p-r-16">
<view class="lineOne c19">
{{item?.properties.length > 1? item?.properties.reduce((items2, items) => items2.valueName + ' ' + items.valueName,): item?.properties[0].valueName}}
</view>
<view class="flex-center">
<view class="c19">x{{ item.count }}</view>
<view class=" size28 m-l-12 weight900">¥<span class="">{{ fen2yuan(item.price) }}</span>
</view>
</view>
</view>
<view class="c13 size28 weight900">
¥<span class="size40">{{ fen2yuan(item.payPrice) }}</span>
</view>
</view>
</view>
<view class="flex-row ju-between" :class="{ 'm-t-8': props.type == 3 }" v-else>
<view class="valueName size28" :class="{ c19: props.theme == 2 }">{{
v.properties.map((property) => property.valueName).join(' ')
}}</view>
<view class="shrink size28 c_333" :class="{ c0: props.theme == 2 }">{{
`x${v.count}`
}}</view>
</view>
<view class="btn flex-row ju-flex-end" v-if="props.type == 2">
<button class="ss-reset-button btnItem btnItem1"
v-if="[10, 20].includes(props.data.status) && v.afterSaleStatus === 0" @tap.stop="
<view
class="con_item flex-center ju-between"
v-for="(v, i) in props.data.items"
:key="i"
:class="{ 'al-flex-start': props.type == 3 || props.type == 4 }"
>
<view class="order_img shrink" :class="{ 'm-r-16': props.type == 3 }">
<image :src="`${v.picUrl}`" mode="aspectFill" />
</view>
<view class="flex1">
<view class="flex-row ju-between m-b-6">
<view
class="size28 spuName lineTwo"
:class="{ 'p-r-10': props.type == 3, c0: props.theme == 2 }"
>
{{ v.spuName }}
</view>
<view class="shrink price" v-if="props.type != 4 && !showMultiSku(v)">
<span class="size24">¥</span>
<span class="size36" style="font-weight: 600">{{ fen2yuan(v.price) }}</span>
</view>
</view>
<view v-if="props.type == 4">
<view class="m-b-12" v-for="(item, i) in v.items" :key="i">
<view class="size24 flex1 flex-center ju-between h_52 bg18 radius8 p-l-8 p-r-16">
<view class="lineOne c19">
{{ formatSkuProperties(item?.properties) }}
</view>
<view class="flex-center">
<view class="c19">x{{ item.count }}</view>
<view class="size28 m-l-12 weight900">
¥<span class="">{{ fen2yuan(item.price) }}</span>
</view>
</view>
</view>
<view
class="delay-record-line"
:class="`delay-record-line--status-${resolveDelayStatus(record)}`"
v-for="(record, recordIndex) in getSkuDelayRecords(v, item)"
:key="recordIndex"
>
<view class="delay-record-line__dot" />
<view class="delay-record-line__text">
{{ getDelayRecordSkuText(record) }}
</view>
<view class="delay-record-line__meta">
<text class="delay-record-line__status">{{ getDelayStatusText(record) }}</text>
<text class="delay-record-line__count">x{{ getDelayRecordCount(record) }}</text>
</view>
</view>
<view class="c13 size28 weight900 m-t-4">
¥<span class="size40">{{ fen2yuan(item.payPrice) }}</span>
</view>
</view>
</view>
<view v-else-if="showMultiSku(v)" class="multi-sku-list">
<view class="multi-sku-item m-b-12" v-for="(item, itemIndex) in v.items" :key="item.id || itemIndex">
<view class="multi-sku-row flex1 flex-center ju-between bg18 radius8 p-l-8 p-r-16">
<view class="multi-sku-text lineOne c19">
{{ formatSkuProperties(item?.properties) }}
</view>
<view class="flex-center">
<view class="c19">x{{ item.count }}</view>
<view class="size28 m-l-12 weight900">
¥<span>{{ fen2yuan(item.payPrice || item.price) }}</span>
</view>
</view>
</view>
<view
class="delay-record-line delay-record-line--nested"
:class="`delay-record-line--status-${resolveDelayStatus(record)}`"
v-for="(record, recordIndex) in getSkuDelayRecords(v, item)"
:key="recordIndex"
>
<view class="delay-record-line__dot" />
<view class="delay-record-line__text">
{{ getDelayRecordSkuText(record) }}
</view>
<view class="delay-record-line__meta">
<text class="delay-record-line__status">{{ getDelayStatusText(record) }}</text>
<text class="delay-record-line__count">x{{ getDelayRecordCount(record) }}</text>
</view>
</view>
</view>
</view>
<view class="flex-row ju-between" :class="{ 'm-t-8': props.type == 3 }" v-else>
<view class="valueName size28" :class="{ c19: props.theme == 2 }">
{{ formatSkuProperties(v.properties) }}
</view>
<view class="shrink size28 c_333" :class="{ c0: props.theme == 2 }">
{{ `x${v.count}` }}
</view>
</view>
<view
v-if="!hasNestedSkuBlock(v)"
class="delay-record-line delay-record-line--single"
:class="`delay-record-line--status-${resolveDelayStatus(record)}`"
v-for="(record, recordIndex) in getSkuDelayRecords(v, v)"
:key="`single-${recordIndex}`"
>
<view class="delay-record-line__dot" />
<view class="delay-record-line__text">
{{ getDelayRecordSkuText(record) }}
</view>
<view class="delay-record-line__meta">
<text class="delay-record-line__status">{{ getDelayStatusText(record) }}</text>
<text class="delay-record-line__count">x{{ getDelayRecordCount(record) }}</text>
</view>
</view>
<view
class="btn flex-row ju-flex-end"
v-if="props.type == 2 && !props.hideItemAfterSale && !isAllRefunded"
>
<button
class="ss-reset-button btnItem btnItem1"
v-if="
[10, 20].includes(props.data.status) &&
v.afterSaleStatus === 0 &&
props.data.payChannelCode !== 'cash_payment'
"
@tap.stop="
sheep.$router.go('/pages/order/aftersale/apply', {
orderId: props.data.id,
itemId: v.id,
source: String(props.source || props.data?.__source || props.data?.source || '').trim(),
openOrderType: String(props.data?.type || ''),
})
">
申请售后
</button>
<view class="btnItem btnItem1" v-if="v.afterSaleStatus === 10" @click="cancelAfterSale(v)">
取消售后
</view>
<view class="btnItem" v-if="v.afterSaleStatus === 20"> 售后成功 </view>
</view>
</view>
</view>
</view>
"
>
申请售后
</button>
<view
class="btnItem btnItem1"
v-if="v.afterSaleStatus === 10"
@click="cancelAfterSale(v)"
>
取消售后
</view>
<view class="btnItem" v-if="v.afterSaleStatus === 20">售后成功</view>
</view>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { ref, reactive, getCurrentInstance, defineProps } from 'vue';
import { fen2yuan } from '@/sheep/hooks/useGoods';
import AfterSaleApi from '@/sheep/api/trade/afterSale';
import sheep from '@/sheep';
const { proxy } = getCurrentInstance() as any;
let emit = defineEmits(['getOrderDetail']);
const props = defineProps({
data: {
type: Object,
default() {
return {};
},
},
type: {
type: String,
default: '0', //0列表2订单详情 3订单列表 4ai订单详情
},
theme: {
type: String,
default: '2', //1浅色 2深色
},
});
const cancelAfterSale = (v) => {
uni.showModal({
title: '提示',
content: '确定要取消此申请吗?',
confirmColor: '#FA7E31',
success: async function (res) {
if (!res.confirm) {
return;
}
const { code } = await AfterSaleApi.cancelAfterSale(v.afterSaleId);
if (code === 0) {
getOrderDetail();
}
},
});
};
const getOrderDetail = () => {
emit('getOrderDetail');
};
const onCopy = (text) => {
sheep.$helper.copyText(text);
};
import { computed, defineProps } from 'vue';
import { fen2yuan, formatOrderStatus } from '@/sheep/hooks/useGoods';
import AfterSaleApi from '@/sheep/api/trade/afterSale';
import sheep from '@/sheep';
let emit = defineEmits(['getOrderDetail', 'openExpress']);
const formatSkuProperties = (properties: any) => {
const list = Array.isArray(properties) ? properties : [];
return list
.map((property) => property?.valueName)
.filter(Boolean)
.join(' ');
};
const showMultiSku = (item: any) => {
return (
['2', '3'].includes(props.type) &&
[String(props.source), String(props.data?.__source)].includes('aishop') &&
Array.isArray(item?.items) &&
item.items.length > 1
);
};
const hasNestedSkuBlock = (item: any) => {
if (props.type == 4) return true;
return showMultiSku(item);
};
const props = defineProps({
data: {
type: Object,
default() {
return {};
},
},
type: {
type: String,
default: '0',
},
source: {
type: String,
default: '',
},
theme: {
type: String,
default: '2',
},
delayRecords: {
type: Array,
default() {
return [];
},
},
hideItemAfterSale: {
type: Boolean,
default: false,
},
});
const isAiStoreOrder = computed(() =>
[String(props.source), String(props.data?.__source)].includes('aishop'),
);
const orderStatusText = computed(() => {
try {
return formatOrderStatus(props.data || {});
} catch (e) {
const status = Number(props.data?.status);
if (status === 30) return '已完成';
return '';
}
});
const isCompletedOrder = computed(() => orderStatusText.value === '已完成');
// 订单级 refundStatus:0 未退款 / 10 部分退款 / 20 全部退款
// 用户需求:refundStatus === 20(全部退款) 时,不要展示任何"申请售后"按钮(单品/整单都不展示)。
const refundStatus = computed(() => {
const v = props.data?.refundStatus === undefined ? props.data?.refund_status : props.data?.refundStatus;
return Number(v) || 0;
});
const isAllRefunded = computed(() => refundStatus.value === 20);
// 待收货状态(status=50):不再展示任何"已延迟 N 件"tab / 状态 + 数量的 SKU 延迟明细,
// 因为货已经发出,延迟发货的相关状态对用户无意义。
const isReceivingOrder = computed(() => {
const s = Number(props.data?.status);
return s === 50;
});
const hasDelayRecords = computed(() => {
if (isCompletedOrder.value) return false;
if (!isAiStoreOrder.value) return false;
if (Array.isArray(props.delayRecords) && props.delayRecords.length > 0) {
return true;
}
const records = Array.isArray(props.data?.delayRecords)
? props.data.delayRecords
: Array.isArray(props.data?.delayRecordList)
? props.data.delayRecordList
: [];
return records.length > 0;
});
const delayRecords = computed(() => {
if (!hasDelayRecords.value) return [];
if (Array.isArray(props.delayRecords) && props.delayRecords.length > 0) {
return props.delayRecords;
}
return Array.isArray(props.data?.delayRecords)
? props.data.delayRecords
: Array.isArray(props.data?.delayRecordList)
? props.data.delayRecordList
: [];
});
const DELAY_STATUS_MAP = {
1: { text: '延迟中', color: '#FA7E31' },
2: { text: '已激活(待发货)', color: '#1AAD19' },
3: { text: '已发货', color: '#1677FF' },
4: { text: '已收货', color: '#999999' },
};
const resolveDelayStatus = (record: any) => {
const status = Number(record?.status);
if ([1, 2, 3, 4].includes(status)) return status;
return 0;
};
const getDelayStatusText = (record: any) => {
const status = resolveDelayStatus(record);
const fallback = getFirstValidValue(record?.statusDesc, '');
if (DELAY_STATUS_MAP[status]) {
return DELAY_STATUS_MAP[status].text;
}
return fallback || '延迟中';
};
const getFirstValidValue = (...values: any[]) =>
values.find((value) => value !== undefined && value !== null && String(value).trim() !== '') ?? '';
const getNumber = (value: any) => {
const n = Number(value);
return Number.isFinite(n) ? n : 0;
};
const resolveItemId = (item: any) =>
getFirstValidValue(item?.orderItemId, item?.itemId, item?.orderGoodsId, item?.id);
const resolveRecordItemId = (record: any) =>
getFirstValidValue(record?.orderItemId, record?.itemId, record?.orderGoodsId);
const resolveRecordCount = (record: any) => {
const candidates = [
record?.count,
record?.delayCount,
record?.recordCount,
record?.remainingCount,
record?.availableCount,
record?.canCount,
record?.maxCount,
];
const matched = candidates.map((value) => getNumber(value)).find((value) => value > 0);
return matched || 0;
};
const isSameSku = (item: any, record: any) => {
const itemProps = Array.isArray(item?.properties)
? item.properties
: Array.isArray(item?.skuProperties)
? item.skuProperties
: Array.isArray(item?.attrs)
? item.attrs
: [];
const recordProps = Array.isArray(record?.properties)
? record.properties
: Array.isArray(record?.skuProperties)
? record.skuProperties
: Array.isArray(record?.attrs)
? record.attrs
: [];
if (itemProps.length && recordProps.length && itemProps.length === recordProps.length) {
const itemKey = itemProps
.map((p) => `${getFirstValidValue(p?.valueName, p?.value)}`)
.filter(Boolean)
.join('|');
const recordKey = recordProps
.map((p) => `${getFirstValidValue(p?.valueName, p?.value)}`)
.filter(Boolean)
.join('|');
if (itemKey && recordKey) {
return itemKey === recordKey;
}
if (itemKey || recordKey) {
return false;
}
} else if (itemProps.length || recordProps.length) {
return false;
}
const itemSkuText = getFirstValidValue(
item?.skuText,
item?.specText,
item?.propertiesText,
item?.skuDesc,
item?.specDesc,
);
const recordSkuText = getFirstValidValue(
record?.skuText,
record?.specText,
record?.propertiesText,
formatSkuProperties(record?.properties),
formatSkuProperties(record?.skuProperties),
formatSkuProperties(record?.attrs),
record?.skuDesc,
record?.specDesc,
);
if (itemSkuText && recordSkuText) {
return itemSkuText === recordSkuText;
}
if (itemSkuText || recordSkuText) {
return false;
}
return false;
};
const resolveRecordUniqueId = (record: any) =>
getFirstValidValue(record?.id, record?.delayRecordId, record?.recordId);
const uniqueByRecordId = (records: any[]) => {
const map = new Map();
(records || []).forEach((record) => {
const key = resolveRecordUniqueId(record) || JSON.stringify(record);
if (!map.has(key)) {
map.set(key, record);
}
});
return Array.from(map.values());
};
const buildSpuRecordAssignment = (spuItem: any) => {
if (!hasDelayRecords.value) {
return { spuRecords: [], skuMap: new Map() };
}
const skuItems = Array.isArray(spuItem?.items) && spuItem.items.length > 0 ? spuItem.items : [spuItem];
const targetSpuId = getFirstValidValue(spuItem?.spuId, spuItem?.productId, spuItem?.goodsId);
const targetSpuName = getFirstValidValue(
spuItem?.spuName,
spuItem?.name,
spuItem?.goodsName,
spuItem?.productName,
);
const matchSpuIdentity = (record: any) => {
const recordSpuId = getFirstValidValue(record?.spuId, record?.productId, record?.goodsId);
if (targetSpuId && recordSpuId) {
return String(targetSpuId) === String(recordSpuId);
}
const recordSpuName = getFirstValidValue(
record?.spuName,
record?.name,
record?.goodsName,
record?.productName,
);
if (targetSpuName && recordSpuName) {
return String(targetSpuName).trim() === String(recordSpuName).trim();
}
if (targetSpuId || recordSpuId) return false;
return false;
};
const spuRecordsRaw = delayRecords.value.filter((record) => {
if (!matchSpuIdentity(record)) return false;
const recordItemId = resolveRecordItemId(record);
const spuItemId = resolveItemId(spuItem);
if (recordItemId && spuItemId && String(recordItemId) === String(spuItemId)) {
return true;
}
const anySkuMatched = skuItems.some((skuItem) => {
const skuItemId = resolveItemId(skuItem);
if (recordItemId && skuItemId && String(recordItemId) === String(skuItemId)) {
return true;
}
return isSameSku(skuItem, record);
});
return anySkuMatched;
});
const spuRecords = uniqueByRecordId(spuRecordsRaw);
const skuMap = new Map();
skuItems.forEach((skuItem, idx) => {
const key = resolveItemId(skuItem) || `sku-${idx}`;
skuMap.set(key, []);
});
const usedRecordKeys = new Set();
const assignRecordToSku = (record: any, skuItem: any, skuIdx: number) => {
const key = resolveRecordUniqueId(record) || JSON.stringify(record);
if (usedRecordKeys.has(key)) return false;
const skuKey = resolveItemId(skuItem) || `sku-${skuIdx}`;
if (!skuMap.has(skuKey)) {
skuMap.set(skuKey, []);
}
skuMap.get(skuKey).push(record);
usedRecordKeys.add(key);
return true;
};
spuRecords.forEach((record) => {
const recordItemId = resolveRecordItemId(record);
if (!recordItemId) return;
const matchedIndex = skuItems.findIndex((skuItem) => {
const skuItemId = resolveItemId(skuItem);
return !!(skuItemId && String(recordItemId) === String(skuItemId));
});
if (matchedIndex >= 0) {
assignRecordToSku(record, skuItems[matchedIndex], matchedIndex);
}
});
spuRecords.forEach((record) => {
const key = resolveRecordUniqueId(record) || JSON.stringify(record);
if (usedRecordKeys.has(key)) return;
const matchedIndex = skuItems.findIndex((skuItem) => isSameSku(skuItem, record));
if (matchedIndex >= 0) {
assignRecordToSku(record, skuItems[matchedIndex], matchedIndex);
}
});
spuRecords.forEach((record) => {
const key = resolveRecordUniqueId(record) || JSON.stringify(record);
if (usedRecordKeys.has(key)) return;
if (skuItems.length === 1 && matchSpuIdentity(record)) {
assignRecordToSku(record, skuItems[0], 0);
}
});
return { spuRecords, skuMap };
};
const findMatchedRecords = (spuItem: any, skuItem?: any) => {
if (!hasDelayRecords.value) return [];
const target = skuItem || spuItem;
const { skuMap, spuRecords } = buildSpuRecordAssignment(spuItem);
const skuItems = Array.isArray(spuItem?.items) && spuItem.items.length > 0 ? spuItem.items : [spuItem];
const targetIndex = skuItems.findIndex((item) => item === target);
if (targetIndex >= 0) {
const skuKey = resolveItemId(target) || `sku-${targetIndex}`;
return uniqueByRecordId(skuMap.get(skuKey) || []);
}
return spuRecords;
};
const sumDelayCount = (records: any[]) =>
records.reduce((sum, record) => sum + resolveRecordCount(record), 0);
const getSpuDelayInfo = (spuItem: any) => {
if (!isAiStoreOrder.value || !hasDelayRecords.value) {
return { delayed: false, count: 0, text: '' };
}
const { spuRecords } = buildSpuRecordAssignment(spuItem);
const delayingRecords = spuRecords.filter(
(record) => resolveDelayStatus(record) === 1,
);
const count = sumDelayCount(delayingRecords);
if (!count) {
return { delayed: false, count: 0, text: '' };
}
return { delayed: true, count, text: `${count}件` };
};
const getSkuDelayRecords = (spuItem: any, skuItem: any) => {
if (!isAiStoreOrder.value || !hasDelayRecords.value || !skuItem) return [];
const skuItems = Array.isArray(spuItem?.items) && spuItem.items.length > 0 ? spuItem.items : [spuItem];
const targetIndex = skuItems.findIndex((item) => item === skuItem);
if (targetIndex < 0) {
if (skuItem === spuItem && skuItems.length === 1) {
return findMatchedRecords(spuItem, skuItem);
}
return [];
}
return findMatchedRecords(spuItem, skuItem);
};
const getDelayRecordCount = (record: any) => resolveRecordCount(record) || 0;
const getDelayRecordSkuText = (record: any) => {
const text = getFirstValidValue(
formatSkuProperties(record?.properties),
formatSkuProperties(record?.skuProperties),
formatSkuProperties(record?.attrs),
formatSkuProperties(record?.specs),
formatSkuProperties(record?.specifications),
getFirstValidValue(
record?.skuText,
record?.specText,
record?.propertiesText,
record?.propertiesValue,
record?.skuValue,
),
getFirstValidValue(record?.skuDesc, record?.specDesc, record?.specification),
getFirstValidValue(record?.sku, record?.specInfo, record?.attrText),
);
if (text && String(text).trim()) {
return text;
}
return getFirstValidValue(record?.spuName, record?.name, record?.goodsName, record?.productName);
};
const cancelAfterSale = (v: any) => {
uni.showModal({
title: '提示',
content: '确定要取消此申请吗?',
confirmColor: '#FA7E31',
success: async function (res: any) {
if (!res.confirm) {
return;
}
const { code } = await AfterSaleApi.cancelAfterSale(v.afterSaleId);
if (code === 0) {
getOrderDetail();
}
},
});
};
const getOrderDetail = () => {
emit('getOrderDetail');
};
const onCopy = (text: any) => {
sheep.$helper.copyText(text);
};
const handleTruckLineOpenExpress = (payload: any) => {
emit('openExpress', payload);
};
</script>
<style scoped lang="scss">
.order_con {
.con_item {
margin-bottom: 24rpx;
.order_con {
.con_item {
margin-bottom: 24rpx;
.order_img {
width: 160rpx;
height: 160rpx;
border-radius: 8rpx;
overflow: hidden;
margin-right: 12rpx;
.order_img {
width: 160rpx;
height: 160rpx;
border-radius: 8rpx;
overflow: hidden;
margin-right: 12rpx;
image {
width: 100%;
height: 100%;
}
}
image {
width: 100%;
height: 100%;
}
}
.spuName {
color: #333333;
}
.spuName {
color: #333333;
}
.valueName {
color: #777777;
}
}
}
.valueName {
color: #777777;
}
}
}
.price {
color: #ee0a24;
font-size: 24rpx;
}
.delay-tag {
display: inline-flex;
align-items: center;
padding: 2rpx 12rpx;
margin-left: 10rpx;
border-radius: 16rpx;
background: #FFF4EA;
color: #FA7E31;
font-size: 20rpx;
line-height: 30rpx;
white-space: nowrap;
vertical-align: middle;
}
.btnItem {
line-height: 50rpx;
padding: 0 20rpx;
box-sizing: border-box;
border-radius: 94px 94px 94px 94px;
margin-top: 12rpx;
font-size: 24rpx;
border: none;
}
.delay-tag--spu {
font-size: 22rpx;
line-height: 32rpx;
}
.btnItem1 {
background: #F2F2F2;
}
</style>
.delay-tag--sku {
font-size: 20rpx;
line-height: 28rpx;
}
.price {
color: #ee0a24;
font-size: 24rpx;
}
.multi-sku-list {
width: 100%;
}
.multi-sku-item:last-child {
margin-bottom: 0;
}
.multi-sku-row {
height: 52rpx;
}
.multi-sku-text {
flex: 1;
min-width: 0;
color: #777777;
font-size: 24rpx;
}
.delay-record-line {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10rpx 8rpx 10rpx 28rpx;
margin-top: 8rpx;
background: #FFF4EA;
border-radius: 8rpx;
position: relative;
}
.delay-record-line--status-1 {
background: #FFF4EA;
}
.delay-record-line--status-2 {
background: #E8F9E7;
}
.delay-record-line--status-3 {
background: #E8F1FF;
}
.delay-record-line--status-4 {
background: #F5F5F5;
}
.delay-record-line--status-0 {
background: #FFF4EA;
}
.delay-record-line--nested {
margin-left: 8rpx;
margin-right: 16rpx;
}
.delay-record-line--single {
margin-top: 12rpx;
}
.delay-record-line__dot {
position: absolute;
left: 12rpx;
top: 50%;
width: 8rpx;
height: 8rpx;
border-radius: 50%;
background: #FA7E31;
transform: translateY(-50%);
}
.delay-record-line--status-2 .delay-record-line__dot {
background: #1AAD19;
}
.delay-record-line--status-3 .delay-record-line__dot {
background: #1677FF;
}
.delay-record-line--status-4 .delay-record-line__dot {
background: #999999;
}
.delay-record-line--status-0 .delay-record-line__dot {
background: #FA7E31;
}
.delay-record-line__text {
flex: 1;
min-width: 0;
font-size: 22rpx;
line-height: 32rpx;
color: #FA7E31;
overflow: hidden;
word-break: break-all;
}
.delay-record-line--status-2 .delay-record-line__text {
color: #1AAD19;
}
.delay-record-line--status-3 .delay-record-line__text {
color: #1677FF;
}
.delay-record-line--status-4 .delay-record-line__text {
color: #999999;
}
.delay-record-line--status-0 .delay-record-line__text {
color: #FA7E31;
}
.delay-record-line__meta {
flex-shrink: 0;
display: inline-flex;
align-items: center;
margin-left: 12rpx;
gap: 12rpx;
}
.delay-record-line__status {
font-size: 20rpx;
line-height: 30rpx;
padding: 2rpx 12rpx;
border-radius: 16rpx;
background: rgba(250, 126, 49, 0.1);
color: #FA7E31;
white-space: nowrap;
}
.delay-record-line--status-2 .delay-record-line__status {
background: rgba(26, 173, 25, 0.1);
color: #1AAD19;
}
.delay-record-line--status-3 .delay-record-line__status {
background: rgba(22, 119, 255, 0.1);
color: #1677FF;
}
.delay-record-line--status-4 .delay-record-line__status {
background: rgba(153, 153, 153, 0.1);
color: #999999;
}
.delay-record-line--status-0 .delay-record-line__status {
background: rgba(250, 126, 49, 0.1);
color: #FA7E31;
}
.delay-record-line__count {
flex-shrink: 0;
font-size: 22rpx;
line-height: 32rpx;
font-weight: 600;
color: #FA7E31;
}
.delay-record-line--status-2 .delay-record-line__count {
color: #1AAD19;
}
.delay-record-line--status-3 .delay-record-line__count {
color: #1677FF;
}
.delay-record-line--status-4 .delay-record-line__count {
color: #999999;
}
.delay-record-line--status-0 .delay-record-line__count {
color: #FA7E31;
}
.price {
color: #ee0a24;
font-size: 24rpx;
}
.btnItem {
line-height: 50rpx;
padding: 0 20rpx;
box-sizing: border-box;
border-radius: 94px 94px 94px 94px;
margin-top: 12rpx;
font-size: 24rpx;
border: none;
}
.btnItem1 {
background: #f2f2f2;
}
</style>
+704 -36
View File
@@ -1,23 +1,25 @@
<template>
<view class="card_order bg24 size34" @click="
utils.go('/pages/order/detail', { id: props.index != 5 ? props.data.id : props.data.orderId })
utils.go('/pages/order/detail', { id: !props.isAfterSale ? props.data.id : props.data.orderId, type: props.data.type, source: props.data.__source })
">
<view class="flex-center ju-between createTime">
<view class="flex-center shrink">
<view class="size28">订单编号: {{ props.data.no }}</view>
<view class="copy flex-center" @tap.stop="onCopy(props.data.no)" style="margin-left: 10px">
<image :src="`${$url}goods/copy2.svg`" mode="scaleToFill" />
</view>
<view class="pickup-tag" v-if="Number(props.data?.deliveryType) === 2">自提</view>
</view>
<view class="stateText size28" style="margin-left: 10px" :class="formatOrderColor(props.data)"
v-if="props.index != 5">
v-if="!props.isAfterSale">
{{ formatOrderStatus(props.data) }}
</view>
<view class="stateText size28" v-else>
{{ formatAfterSaleStatus(props.data) }}
</view>
</view>
<card_order :data="props.data" v-if="props.index != 5" type="3"></card_order>
<card_order :data="props.data" :source="props.data.__source" :delay-records="state.delayRecords" v-if="!props.isAfterSale" type="3" @openExpress="goExpressLog"></card_order>
<view v-else class="con_item flex-center ju-between al-flex-start">
<view class="order_img shrink">
<image :src="`${props.data.picUrl}`" mode="aspectFill" />
@@ -37,18 +39,35 @@
<view class="shrink size24 c0">{{ `x${props.data.count}` }}</view>
</view>
<view class="btn flex-row ju-flex-end">
<button class="ss-reset-button btnItem btnItem1" @tap.stop="onApply"
v-if="statusChange(['10', '20', '30', '62', '63'], String(props.data.status))">取消售后</button>
<button class="ss-reset-button btnItem btnItem1" style="margin-left: 20rpx"
v-if="statusChange(['20'], String(props.data.status))" @tap.stop="
sheep.$router.go('/pages/order/aftersale/return-delivery', { id: props.data.id })
">
<button
class="ss-reset-button btnItem btnItem1"
@tap.stop="onApply"
v-if="statusChange(['10', '20', '30', '62', '63'], String(props.data.status))"
>取消售后</button
>
<button
class="ss-reset-button btnItem btnItem1"
style="margin-left: 20rpx"
v-if="statusChange(['20'], String(props.data.status))"
@tap.stop="
sheep.$router.go('/pages/order/aftersale/return-delivery', { id: props.data.id })
">
填写物流信息
</button>
</view>
</view>
</view>
<view class="flex-row ju-flex-end" v-if="props.index != 5">
<view class="discount-row flex-between" v-if="!props.isAfterSale">
<view v-if="isDelayedShipmentOrder()" class="delay-notice flex-center">
<view class="delay-notice__icon">!</view>
<view class="delay-notice__text">
延迟发货中,商品已为您锁定,配送需您手动恢复或点击立即发货。
</view>
</view>
<view class="size24 c_999">{{ formatCreateTime(props.data.createTime) }}</view>
<view class="size24 c32">已优惠¥{{ fen2yuan(props.data.randomDiscountPrice) }}</view>
</view>
<view class="flex-row ju-flex-end" v-if="!props.isAfterSale">
<view class="flex-center size24">{{ `共${props.data.productCount}件商品 合计: `
}}
<!-- <view class="price">¥{{ fen2yuan(props.data.payPrice) }}</view> -->
@@ -56,34 +75,109 @@
style="font-weight: 600;">{{ fen2yuan(props.data.payPrice) }}</span></view>
</view>
</view>
<view class="" style="margin-top: 32rpx" v-if="props.index != 5">
<view class="flex-center ju-flex-end m-t-12" v-if="!props.isAfterSale && isAiActionOrder">
<AiOrderActionBar
:status="currentStatus"
:disableDelayShipment="isPickUpOrder || !isAiStoreOrder"
:showView="false"
:hasDelayedItems="hasDelayedItems"
:canDelayItems="canDelayItems"
:canShipItems="canShipItems"
:logisticsId="props.data.logisticsId"
:logisticsNo="props.data.logisticsNo"
:deliveryTime="props.data.deliveryTime"
:hasLogistics="hasLogistics"
:thirdPartyOrder="resolveThirdPartyOrder()"
:canUpdateDeliveryType="props.data?.canUpdateDeliveryType"
@delay="onDelayShipment"
@now="onNowShipment"
@view="goAiOrderInfo"
@confirm="confirmReceiveOrder"
@pay="goPay"
@cancel="cancelAiOrder"
@express="goExpressLog"
@modifyDelivery="goModifyDelivery"
/>
</view>
<view class="" style="margin-top: 32rpx" v-else-if="!props.isAfterSale">
<card_orderBan :data="props.data" @downData="downData"></card_orderBan>
</view>
</view>
<ShipmentPopup
ref="nowShipmentPopupRef"
mode="now"
popup-type="bottom"
:order-no="props.data.no || ''"
:order-time="formatCreateTime(props.data.createTime) || ''"
:order-data="props.data"
:delay-records="state.delayRecords"
@close="closeNowShipmentPopup"
@submit="handleNowShipmentSubmit"
/>
<ShipmentPopup
ref="delayShipmentPopupRef"
mode="delay"
popup-type="bottom"
:order-no="props.data.no || ''"
:order-time="formatCreateTime(props.data.createTime) || ''"
:order-data="props.data"
:delay-records="state.delayRecords"
@close="closeDelayShipmentPopup"
@submit="handleDelayShipmentSubmit"
/>
<ReceiveItemPopup
ref="receiveItemPopupRef"
:order-no="props.data.no || ''"
:order-data="props.data"
:delay-records="state.delayRecords"
@close="closeReceiveItemPopup"
@submit="handleReceiveItemSubmit"
/>
<ExpressListPopup
ref="expressListPopupRef"
popup-type="bottom"
:order-no="props.data.no || ''"
:order-data="props.data"
:delay-records="state.delayRecords"
:order-id="resolveAiOrderId(props.data)"
@close="closeExpressListPopup"
/>
</template>
<script setup lang="ts">
<script setup>
import {
ref,
reactive,
onMounted,
onUnmounted,
getCurrentInstance,
watch,
nextTick,
defineProps,
defineEmits,
computed,
ref,
reactive,
watch,
onMounted,
} from 'vue';
import {
fen2yuan,
formatOrderColor,
formatOrderStatus,
handleOrderButtons,
formatAfterSaleStatus,
} from '@/sheep/hooks/useGoods';
import card_order from './card_order.vue';
import card_orderBan from '@/components/card_orderBan/card_orderBan.vue';
import AiOrderActionBar from '@/components/orderItem/AiOrderActionBar.vue';
import ShipmentPopup from '@/components/orderItem/ShipmentPopup.vue';
import ReceiveItemPopup from '@/components/orderItem/ReceiveItemPopup.vue';
import ExpressListPopup from '@/components/orderItem/ExpressListPopup.vue';
import AfterSaleApi from '@/sheep/api/trade/afterSale';
import sheep from '@/sheep/index';
import sheep from '@/sheep';
import {
aiDelayedShipment,
aiPendingShipment,
confirmReceive as aiConfirmReceive,
giftConfirmReceive,
cancelOrder as cancelAiOrderRequest,
cancelOpenOrder,
getAiOrderDelayRecords,
aiReceiveItem,
} from '@/sheep/api/ai';
let emit = defineEmits(['downData']);
let { proxy } = getCurrentInstance();
let props = defineProps({
@@ -97,25 +191,24 @@
type: Number,
default: 0,
},
isAfterSale: {
type: Boolean,
default: false,
},
});
let data = reactive({});
watch(
() => props.data,
(val) => {
data = val;
},
{
deep: true,
immediate: true,
},
);
const downData = () => {
emit('downData');
};
// 复制
const onCopy = (no) => {
proxy.$sheep.$helper.copyText(no);
};
const formatCreateTime = (value) => {
if (!value) return '';
const s = sheep?.$helper?.timeFormat
? sheep.$helper.timeFormat(value, 'yyyy-mm-dd hh:MM:ss')
: String(value);
return s || '';
};
const onApply = () => {
uni.showModal({
title: '提示',
@@ -135,6 +228,404 @@
const statusChange = (arr, status) => {
return arr.indexOf(status) != -1;
};
const isAiActionOrder =
String(props.data?.__source) === 'aishop' ||
Number(props.data?.type) === 4 ||
Number(props.data?.type) === 5;
const isAiStoreOrder = computed(() => String(props.data?.__source) === 'aishop');
const resolveThirdPartyOrder = () => {
const d = props.data || {};
if (d.thirdPartyOrder === true || d.thirdPartyOrder === 'true' || d.thirdPartyOrder === 1) {
return true;
}
const items = Array.isArray(d.items) ? d.items : [];
return items.some(
(it) => it.thirdPartyOrder === true || it.thirdPartyOrder === 'true' || it.thirdPartyOrder === 1,
);
};
const resolveOrderTypeForModify = () => {
const t = Number(props.data?.type ?? 0);
if (t === 4 || t === 5) return t;
// 只要能触发 AiOrderActionBar 的 modifyDelivery 按钮,就是 AI/店铺类订单
if (isAiActionOrder) return 4;
return 1;
};
const goModifyDelivery = () => {
const id = props.data?.id || props.data?.orderId;
if (!id) return;
const dataType = Number(props.data?.type ?? 0);
let finalType = dataType;
if (finalType !== 4 && finalType !== 5) {
finalType = isAiActionOrder ? 4 : 1;
}
const finalSource = props.data?.__source || (isAiActionOrder ? 'aishop' : '');
const currentType = isAiStoreOrder.value || isAiActionOrder ? 1 : 0;
const params = {
id,
orderTypeId: resolveOrderTypeForModify(),
type: finalType,
currentType,
};
if (finalSource) {
params.source = finalSource;
}
proxy.utils.go('/pages/order/modifyDelivery', params);
};
const isPickUpOrder = computed(() => {
if (Number(props.data?.deliveryType) === 2) return true;
return Boolean(
props.data?.pickUpStoreId ||
props.data?.pickUpStore ||
props.data?.pickUpStoreVO ||
props.data?.pickUpVerifyCode,
);
});
const currentStatus = ref(Number(props.data?.status));
watch(
() => props.data?.status,
(value) => {
currentStatus.value = Number(value);
},
{ immediate: true },
);
// 顶部提示条「延迟发货中...」仅在待付款/待发货/处理中这些发货流程前的状态展示,
// 待收货(status=50)已经发货完成,不应该再展示这条提醒。
const isDelayedShipmentOrder = () => {
const s = Number(currentStatus.value);
if (s === 50) return false; // 待收货:不再展示延迟发货提示
if (isPickUpOrder.value) return false;
// 其余状态(待付款/待发货/处理中)下,只要有延迟中(status===1)的商品就展示
return Boolean(
getCurrentDelayRecords().some(
(record) => Number(record?.status) === 1,
),
);
};
const hasDelayedItems = computed(() => {
if (!isAiStoreOrder.value) return false;
if (isPickUpOrder.value) return false;
const delayRecords = getCurrentDelayRecords();
return delayRecords.some((record) => Number(record?.status) === 1);
});
const canDelayItems = computed(() => {
if (!isAiStoreOrder.value) return false;
if (isPickUpOrder.value) return false;
const delayRecords = getCurrentDelayRecords();
const hasActivated = delayRecords.some((record) => Number(record?.status) === 2);
if (hasActivated) return true;
if (delayRecords.length === 0) {
const totalCount = Number(props.data?.productCount || props.data?.totalCount || 0) || 0;
if (totalCount > 0) return true;
}
return false;
});
const canShipItems = computed(() => {
if (!isAiStoreOrder.value) return false;
if (isPickUpOrder.value) return false;
const delayRecords = getCurrentDelayRecords();
if (delayRecords.length === 0) {
const totalCount = Number(props.data?.productCount || props.data?.totalCount || 0) || 0;
return totalCount > 0;
}
return delayRecords.some((record) => {
const status = Number(record?.status);
return status === 1 || status === 2;
});
});
const getCurrentDelayRecords = () => {
if (Array.isArray(state.delayRecords) && state.delayRecords.length > 0) return state.delayRecords;
const orderRecords = Array.isArray(props.data?.delayRecords)
? props.data.delayRecords
: Array.isArray(props.data?.delayRecordList)
? props.data.delayRecordList
: [];
return orderRecords.filter(Boolean);
};
const hasLogistics = computed(() => {
const data = props.data || {};
if (Number(data.logisticsId) > 0) return true;
if (data.logisticsNo && String(data.logisticsNo).trim()) return true;
if (data.deliveryTime) return true;
const items = Array.isArray(data.items) ? data.items : [];
for (const item of items) {
if (Number(item?.logisticsId) > 0) return true;
if (item?.logisticsNo && String(item.logisticsNo).trim()) return true;
if (item?.deliveryTime) return true;
const subItems = Array.isArray(item?.items) ? item.items : [];
for (const sub of subItems) {
if (Number(sub?.logisticsId) > 0) return true;
if (sub?.logisticsNo && String(sub.logisticsNo).trim()) return true;
if (sub?.deliveryTime) return true;
}
}
return false;
});
const state = reactive({
delayRecords: [],
delayRecordsLoaded: false,
});
const resolveAiOrderId = (data) => {
return data?.id || data?.orderId;
};
const loadDelayRecords = async (force = false) => {
if (props.isAfterSale) return;
if (!isAiStoreOrder.value) return;
const orderId = resolveAiOrderId(props.data);
if (!orderId) return;
if (state.delayRecordsLoaded && !force) return;
try {
const { code, data } = await getAiOrderDelayRecords({ orderId });
if (code === 0 && Array.isArray(data)) {
state.delayRecords = data;
} else {
state.delayRecords = [];
}
} catch (e) {
state.delayRecords = [];
} finally {
state.delayRecordsLoaded = true;
}
};
const nowShipmentPopupRef = ref();
const delayShipmentPopupRef = ref();
const receiveItemPopupRef = ref();
const expressListPopupRef = ref();
const closeNowShipmentPopup = () => {};
const closeDelayShipmentPopup = () => {};
const closeReceiveItemPopup = () => {};
const closeExpressListPopup = () => {};
const openDelayShipmentPopup = async (data) => {
const id = resolveAiOrderId(data);
if (!id) {
uni.showToast({
title: '订单信息异常',
icon: 'none',
});
return;
}
try {
await loadDelayRecords(true);
} catch (e) {
}
delayShipmentPopupRef.value?.open();
};
const openNowShipmentPopup = async (data) => {
const id = resolveAiOrderId(data);
if (!id) {
uni.showToast({
title: '订单信息异常',
icon: 'none',
});
return;
}
try {
await loadDelayRecords(true);
} catch (e) {
}
nowShipmentPopupRef.value?.open();
};
const handleDelayShipmentSubmit = async ({ items, close }) => {
const orderId = resolveAiOrderId(props.data);
if (!orderId || !Array.isArray(items) || items.length === 0) {
return;
}
const { code } = await aiDelayedShipment({
orderId,
items,
});
if (code === 0) {
close?.();
await loadDelayRecords(true);
const records = getCurrentDelayRecords();
const hasDelayed = records.some((r) => Number(r?.status) === 1);
if (hasDelayed && ![15, 20, 30].includes(Number(currentStatus.value))) {
currentStatus.value = 50;
} else if (!hasDelayed && Number(currentStatus.value) === 50) {
currentStatus.value = 10;
}
emit('downData');
}
};
const handleNowShipmentSubmit = async ({ items, close }) => {
const orderId = resolveAiOrderId(props.data);
if (!orderId || !Array.isArray(items) || items.length === 0) {
return;
}
const { code } = await aiPendingShipment({
orderId,
items,
});
if (code === 0) {
close?.();
await loadDelayRecords(true);
const records = getCurrentDelayRecords();
const hasDelayed = records.some((r) => Number(r?.status) === 1);
if (hasDelayed && ![15, 20, 30].includes(Number(currentStatus.value))) {
currentStatus.value = 50;
} else if (Number(currentStatus.value) === 50) {
currentStatus.value = 10;
}
emit('downData');
}
};
const onDelayShipment = () => {
delayShipment(props.data);
};
const onNowShipment = () => {
nowShipment(props.data);
};
function delayShipment(data) {
if (isPickUpOrder.value) {
uni.showToast({
title: '自提订单不支持延迟发货',
icon: 'none',
});
return;
}
if (!isAiStoreOrder.value) {
uni.showToast({
title: '当前订单不支持延迟发货',
icon: 'none',
});
return;
}
openDelayShipmentPopup(data);
}
function nowShipment(data) {
if (isPickUpOrder.value) {
uni.showToast({
title: '自提订单不支持立即发货',
icon: 'none',
});
return;
}
if (!isAiStoreOrder.value) {
uni.showToast({
title: '当前订单不支持立即发货',
icon: 'none',
});
return;
}
openNowShipmentPopup(data);
}
const goAiOrderInfo = () => {
if (Number(props.data?.type) === 5) {
const id = props.data?.id;
if (!id) return;
proxy.utils.go('/pages/order/detail', { id, type: props.data?.type });
return;
}
const id = resolveAiOrderId(props.data);
if (!id) return;
proxy.utils.go('/pages/AI/orderInfo', { id });
};
const goExpressLog = () => {
const id = resolveAiOrderId(props.data);
if (!id) {
uni.showToast({
title: '订单信息异常',
icon: 'none',
});
return;
}
// 店铺订单(source=aishop)、入店订单(type=4)、赠送店铺订单(type=5) 一律弹窗查看物流;只有普通商城订单走原生跳转
const orderType = Number(props.data?.type ?? 0);
const isStoreOrGiftOrInStore =
isAiStoreOrder.value || orderType === 4 || orderType === 5;
if (!isStoreOrGiftOrInStore) {
proxy.utils.go('/pages/order/express/log', { id });
return;
}
if (!isPickUpOrder.value) {
expressListPopupRef.value?.open?.();
return;
}
proxy.utils.go('/pages/order/express/log', { id });
};
const confirmReceiveOrder = async () => {
if (Number(currentStatus.value) === 15) {
const orderId = resolveAiOrderId(props.data);
if (orderId && !state.delayRecordsLoaded) {
await loadDelayRecords(true);
}
receiveItemPopupRef.value?.open?.();
return;
}
const id = resolveAiOrderId(props.data);
if (!id) return;
const req = Number(props.data?.type) === 5 ? giftConfirmReceive : aiConfirmReceive;
const { code } = await req({ id });
if (code === 0) {
emit('downData');
}
};
const handleReceiveItemSubmit = async ({ items }) => {
if (!Array.isArray(items) || items.length === 0) {
uni.showToast({
title: '请选择要确认收货的商品',
icon: 'none',
});
return;
}
const { code } = await aiReceiveItem({ items });
if (code === 0) {
receiveItemPopupRef.value?.close?.();
state.delayRecordsLoaded = false;
emit('downData');
}
};
const goPay = () => {
const id = resolveAiOrderId(props.data);
const payOrderId = props.data?.payOrderId;
if (!id || !payOrderId) {
uni.showToast({
title: '支付信息异常',
icon: 'none',
});
return;
}
proxy.utils.go('/pages/AI/cashierDesk', {
id,
payOrderId,
});
};
const cancelAiOrder = () => {
const id = resolveAiOrderId(props.data);
if (!id) return;
uni.showModal({
title: '提示',
content: '确定要取消订单吗?',
confirmColor: '#FA7E31',
success: async (res) => {
if (!res.confirm) return;
const request = Number(props.data?.type) === 5 ? cancelOpenOrder : cancelAiOrderRequest;
const result = await request({ id });
if (result.code === 0) emit('downData');
},
});
};
</script>
<style lang="scss" scoped>
.card_order {
@@ -143,12 +634,177 @@
border-radius: 8rpx;
}
.stateText {}
.createTime {
margin-bottom: 32rpx;
}
.discount-row {
margin-top: 8rpx;
flex-wrap: wrap;
row-gap: 12rpx;
}
.delay-notice {
width: 100%;
padding: 18rpx 20rpx;
box-sizing: border-box;
border-radius: 12rpx;
background: #fff4ea;
align-items: flex-start;
}
.delay-notice__icon {
width: 28rpx;
height: 28rpx;
line-height: 28rpx;
text-align: center;
border-radius: 50%;
border: 2rpx solid #fa7e31;
color: #fa7e31;
font-size: 20rpx;
flex-shrink: 0;
margin-right: 12rpx;
margin-top: 2rpx;
}
.delay-notice__text {
color: #fa7e31;
font-size: 24rpx;
line-height: 36rpx;
}
.delay-popup {
background: #ffffff;
border-radius: 24rpx 24rpx 0 0;
padding: 32rpx 24rpx calc(24rpx + env(safe-area-inset-bottom));
box-sizing: border-box;
}
.delay-popup__header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12rpx;
}
.delay-popup__title {
font-size: 34rpx;
font-weight: 600;
color: #333333;
}
.delay-popup__order-no {
margin-top: 8rpx;
font-size: 22rpx;
line-height: 32rpx;
color: #999999;
word-break: break-all;
}
.delay-popup__order-time {
margin-top: 4rpx;
font-size: 22rpx;
line-height: 32rpx;
color: #999999;
}
.delay-popup__close {
width: 56rpx;
height: 56rpx;
border-radius: 50%;
background: #f3f4f6;
line-height: 56rpx;
text-align: center;
font-size: 36rpx;
color: #666666;
}
.delay-popup__desc {
font-size: 24rpx;
color: #999999;
margin-bottom: 24rpx;
}
.delay-popup__content {
max-height: 720rpx;
}
.delay-popup__item {
display: flex;
padding: 20rpx 0;
border-bottom: 1rpx solid #f2f2f2;
}
.delay-popup__item-image {
width: 144rpx;
height: 144rpx;
border-radius: 12rpx;
flex-shrink: 0;
margin-right: 20rpx;
background: #f5f5f5;
}
.delay-popup__item-main {
flex: 1;
min-width: 0;
}
.delay-popup__item-name {
font-size: 28rpx;
line-height: 40rpx;
color: #333333;
}
.delay-popup__item-sku {
margin-top: 10rpx;
font-size: 24rpx;
line-height: 34rpx;
color: #999999;
}
.delay-popup__item-footer {
margin-top: 20rpx;
}
.delay-popup__item-count {
font-size: 24rpx;
color: #666666;
}
.delay-popup__actions {
display: flex;
align-items: center;
gap: 20rpx;
margin-top: 32rpx;
}
.delay-popup__btn {
flex: 1;
height: 84rpx;
line-height: 84rpx;
text-align: center;
border-radius: 42rpx;
font-size: 28rpx;
font-weight: 500;
}
.delay-popup__btn--ghost {
background: #f2f3f5;
color: #333333;
}
.delay-popup__btn--primary {
background: linear-gradient(135deg, #fa8735 0%, #fe3b48 100%);
color: #ffffff;
}
.now-shipment-empty {
padding: 40rpx 24rpx;
text-align: center;
font-size: 26rpx;
color: #999999;
}
.price {
color: #ee0a24;
font-size: 24rpx;
@@ -165,6 +821,18 @@
}
}
.pickup-tag {
margin-left: 10rpx;
padding: 2rpx 7rpx;
line-height: 1.6;
font-size: 22rpx;
color: #2556ec;
background: rgba(37, 86, 236, 0.08);
border: 2rpx solid rgba(37, 86, 236, 0.18);
border-radius: 8rpx;
flex-shrink: 0;
}
.con_item {
margin-bottom: 24rpx;
@@ -206,6 +874,6 @@
}
.btnItem1 {
background: #F2F2F2;
background: #f2f2f2;
}
</style>
</style>
+2 -3
View File
@@ -27,12 +27,11 @@
default: 1, //1:商城订单 2:AI店铺订单 3:AI店铺赠送订单
}
});
const emit = defineEmits(['openExpress']);
let show = ref(false);
let list = ref([]);
const logistics = () => {
// 获取物流信息并显示弹窗
getData();
show.value = true;
emit('openExpress', { data: props.data, code: props.code });
};
const close = () => {
show.value = false;
+29
View File
@@ -0,0 +1,29 @@
# Debug Session: app-map-markers-regression
- **Status**: [OPEN]
- **Created**: 2026-09-07
- **File Target**: pages/user/goods_details_store/index.vue
- **Symptom**: 打包的 App 端「选择自提门店」页,地图瓦片 + 门店标点(大头针+气泡)都不展示;H5/Dev 端正常。
## Hypotheses(可证伪)
| # | 假设 | 预测(插桩后要看到什么) | 关键观察点 |
|---|---|---|---|
| H1 | **Canvas 同时指定了 CSS 类 + inline style 双重定位,App 端 CSS `.marker-canvas` 的 `position:absolute;left:0;top:0;transform:scale(0)` 覆盖 inline `position:absolute;left:-9999px`,导致画布跑到地图左上角可视区 but `scale(0)` → **canvas 尺寸按 CSS 类变成 0×0(因为 CSS class 宽高没写)→ GPU 丢帧/ `canvasToTempFilePath` 返回空** → `commitMarkerResult` 写入 fallbackFinal 为 `_www/static/icon/map.png`(裸相对路径)→ `buildMarkers.filter(m=>!!icon)` OK 但 **plus.map BitmapFactory 解析 `_www/static/icon/map.png` 失败(之前是靠 copyTo 沙箱 `file://` 才成功)** → 所有 marker 静默丢弃。 | `DBG_CANVAS_POS`:模板 L93 同时有 class="marker-canvas" 和 inline style 重复 position → plus 渲染层 CSS 覆盖 inline,导致 canvas 实际尺寸 0。 | 模板 L93 冲突;renderMarkerIcon successCb `resultPath` 空,fallbackFinal=`_www/static/icon/map.png`,buildMarkers 后 markers 数组长度=N 但原生端 render 失败。 |
| H2 | **getFallbackStoreIcon 同步路径(L409-L426)所有分支都返回空**:冷启动 `plus.io.convertLocalFileSystemURL(MARKER_PIN_PNG_WWW)` 返回 undefined 或空串 → `_cachedFallbackStoreIcon` 永远空 → 异步 copyTo(L428+)是 Promise 但 renderMarkerIcon 同步就拿 fallbackIcon = '' → `fallbackFinal = getFinalFallback('') = MARKER_PIN_PNG_WWW = '_www/static/icon/map.png'` → 与 H1 同终点,BitmapFactory 不认。 | `DBG_FALLBACK_INIT`:getFallbackStoreIcon 同步返回 '' / MARKER_PIN_PNG_WWW,非 file:// 开头;copyTo 成功后 buildMarkers 二次触发后仍不生效(因为 tryFixIcon 把 file:// 路径再 normalize 一遍反而丢)。 | getFallbackStoreIcon() 返回值;copyTo 后 _cachedFallbackStoreIcon 的值;buildMarkers 最终 marker.iconPath 类型。 |
| H3 | **buildMarkers 末尾 filter 把所有 marker 都剔了**:L777-L780 `return !!icon`,但 `tryFixIcon` 在 `plus` 存在时把所有合法路径都当非法处理返回 `safeFallback = MARKER_PIN_PNG_WWW = '_www/static/icon/map.png'`(H1/H2),或者 `state.markerIconMap[getMarkerKey(id,false)]` 在 prepareMarkerIcons 3 并发下被 acquireCanvasLock 超时(4s)强制释放,renderMarkerIcon 抛异常走 `top exception` 分支写入空串,被 filter 踢。 | `DBG_BUILD_FILTERED`:buildMarkers 输入 filteredStoreList.value.length 输出 0;或输出 >0 但每一项 iconPath 都不是 file:// 前缀。 | buildMarkers 入口 list 长度;map 后中间数组里每项 iconPath 字符串;最终 newMarkers 长度。 |
| H4 | **`<map>` 标签 setting 驼峰没问题,但 plus 引擎在打包 release 构建时 `state.mapLatitude / state.mapLongitude` 初始值**(L134-L135 北京 39.9/116.4)被 tree-shaking 或 Vite 打包时 `reactive` 内数字丢失(非 0 但 NaN / Infinity)→ 原生地图中心错 + triggerMapRefresh 抖属性失败 → 瓦片白屏 + markers 数组存在但被挪到了无穷远。 | `DBG_MAP_COORDS`:onLoad 后 state.mapLatitude/state.mapLongitude/state.mapScale 的类型是 string 或 NaN,triggerMapRefresh `state.mapScale = 0` 后恢复失败。 | onLoad 时 state 初始值;triggerMapRefresh 两次 setTimeout 前后值;`Number.isNaN` / `typeof`。 |
| H5 | **`callout.display='BYCLICK'` 在打包 App 版旧 plus 引擎上不识别**(只认 'ALWAYS'/'NEVER'),L774 设置 `BYCLICK` → 整个 markers 数组被原生端静默整个丢弃(符合 project_memory 硬约束)。 | `DBG_CALLOUT`:改为 'ALWAYS' 或 'NEVER' 后 markers 立刻出。 | buildMarkers 数组有内容但原生端一个都不画;替换后正常。 |
## Instrumentation Plan(不改业务逻辑,仅加 console.warn 前缀 DBG_)
1. **模板 L93**:确认 canvas class + inline 重复(`.marker-canvas` 里 `position:absolute;left:0;top:0;transform:scale(0)` vs inline `position:absolute;left:-9999px`)→ **先静态验证 H1(模板里已经写了双重 position:absolute)**
2. **buildMarkers**(L748-L781):每 10 个店 `console.warn('[DBG_BUILD]', {inputLen:list.length, safeFallback, isStatic_safeFallback: isStaticRawPath(safeFallback), newMarkers_len: newMarkers.length, first_3_markers: newMarkers.slice(0,3).map(m=>({id:m.id, iconPathPrefix: (m.iconPath||'').slice(0,20), w:m.width, h:m.height, callout: m.callout?.display}))})`
3. **getFallbackStoreIcon**(L408-L492):同步出口 & copyTo 出口各打 1 条:`[DBG_FALLBACK_SYNC] return=${v?.slice?.(0,30)}; [DBG_FALLBACK_COPY] copied=${v?.slice?.(0,50)}`
4. **renderMarkerIcon** draw 结束:L627 successCb 和 L628 failCb 各 1 条:`[DBG_CANVAS_OK] key=${key} resultLen=${res?.tempFilePath?.length||0}, finalResultAfterResolve=${(resultPath||'').slice(0,40)}; [DBG_CANVAS_FAIL] key=${key}`
5. **onLoad 初始 state**:L924 try 开头加 `[DBG_MAP_INIT] {lat: state.mapLatitude, lon: state.mapLongitude, t_lat: typeof state.mapLatitude, t_lon: typeof state.mapLongitude, nan: Number.isNaN(state.mapLatitude)}`
## Reproduce Steps(对用户)
1. 打 release 包安装冷启动打开「选择自提门店」页;
2. 停留 10s 以上,确保 copyTo + prepareMarkerIcons 3 并发全部跑;
3. 连上 HBuilderX 控制台 / 或 Android Studio logcat 过滤 `[DBG_`,把日志贴给我。
+1 -1
View File
@@ -4,7 +4,7 @@
<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>
<title>康源家园</title>
<!--preload-links-->
<!--app-context-->
</head>
+30 -2
View File
@@ -14,13 +14,41 @@ import {
import {
debounce
} from '@/utils/common'
import { createHotUpdate, createEventProgress } from '@/utils/hotUpdate'
import { gethotupdatelist } from '@/sheep/api/index/index'
// import { setupVConsole } from '@/utils/vconsole.js'
export function createApp() {
// setupVConsole();
const hotUpdate = createHotUpdate({
progress: createEventProgress(),
apkMode: 'download',
getLatest: gethotupdatelist,
})
uni.__globalHotUpdateCheck = (options = {}) => {
const force = !!options?.force
if (!force && uni.__hotUpdateCheckedOnce) return
uni.__hotUpdateCheckedOnce = true
return hotUpdate.checkUpdate({ allowSkipPrompt: true })
}
const app = createSSRApp(App);
app.mixin({
onShow() {
if (typeof uni.__globalHotUpdateCheck === 'function') {
uni.__globalHotUpdateCheck({ force: true, source: 'pageShow' })
}
},
})
setTimeout(() => {
if (typeof uni.__globalHotUpdateCheck === 'function') uni.__globalHotUpdateCheck({ source: 'boot' })
}, 0)
setupPinia(app);
app.config.globalProperties.$url = 'https://sycbuck.oss-cn-hangzhou.aliyuncs.com/app/'
app.config.globalProperties.$ygUrl = 'https://swzhyg.oss-cn-hangzhou.aliyuncs.com/static/'
@@ -32,4 +60,4 @@ export function createApp() {
return {
app,
};
}
}
+17 -6
View File
@@ -1,9 +1,9 @@
{
"name" : "优购商城",
"name" : "康源家园",
"appid" : "__UNI__8B19741",
"description" : "",
"versionName" : "1.3.2",
"versionCode" : 132,
"versionName" : "1.0.0",
"versionCode" : 100,
"transformPx" : false,
"app-plus" : {
"privacy" : {
@@ -20,13 +20,16 @@
},
"modules" : {
"Camera" : {},
"NativeObj" : {},
"VideoPlayer" : {},
"Payment" : {},
"OAuth" : {},
"Share" : {}
"Share" : {},
"Maps" : {}
},
"distribute" : {
"android" : {
"schemes" : [ "weixin" ],
"schemes" : [ "yougou" ],
"permissions" : [
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
@@ -40,10 +43,11 @@
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.CALL_PHONE\"/>"
],
"abiFilters" : [ "arm64-v8a", "x86" ],
"abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ],
"minSdkVersion" : 21
},
"ios" : {
"schemes" : [ "yougou" ],
"privacyDescription" : {
"NSPhotoLibraryUsageDescription" : "需要同意访问您的相册选取图片才能完善该条目",
"NSPhotoLibraryAddUsageDescription" : ""
@@ -72,6 +76,13 @@
"appid" : "wx23b0c321b5d74d63",
"UniversalLinks" : ""
}
},
"maps" : {
"amap" : {
"name" : "amap_15382588177ANlLnvUge",
"appkey_ios" : "8694ccc22387dc97503979c38047519d",
"appkey_android" : "f4c7d5076af0e2d971233a984aabd042"
}
}
},
"icons" : {
+1
View File
@@ -103,6 +103,7 @@
},
"devDependencies": {
"prettier": "^2.8.7",
"sass": "^1.99.0",
"vconsole": "^3.15.0"
}
}
+134 -31
View File
@@ -32,6 +32,29 @@
"group": "商城"
}
},
{
"path": "pages/index/aiStore",
"style": {
"navigationBarTitleText": "AI店铺",
"navigationStyle": "custom"
},
"meta": {
"sync": true,
"title": "AI店铺",
"group": "商城"
}
},
{
"path": "pages/index/listRecord",
"style": {
"navigationBarTitleText": "列表记录"
},
"meta": {
"sync": true,
"title": "列表记录",
"group": "商城"
}
},
{
"path": "pages/index/user",
"style": {
@@ -78,6 +101,44 @@
"title": "购物车",
"group": "商城"
}
},
{
"path": "pages/merchant/pickupList",
"style": {
"navigationBarTitleText": "提货清单",
"navigationStyle": "custom",
"enablePullDownRefresh": true
},
"meta": {
"sync": true,
"title": "提货清单",
"group": "商户"
}
},
{
"path": "pages/merchant/storeManage",
"style": {
"navigationBarTitleText": "网店管理",
"navigationStyle": "custom",
"enablePullDownRefresh": true
},
"meta": {
"sync": true,
"title": "网店管理",
"group": "商户"
}
},
{
"path": "pages/merchant/scanVerify",
"style": {
"navigationBarTitleText": "扫码核销",
"navigationStyle": "custom"
},
"meta": {
"sync": true,
"title": "扫码核销",
"group": "商户"
}
}
],
"subPackages": [
@@ -174,6 +235,17 @@
"title": "订单详情"
}
},
{
"path": "stockProgress",
"style": {
"navigationBarTitleText": "备货进度",
"navigationStyle": "custom"
},
"meta": {
"auth": true,
"title": "备货进度"
}
},
{
"path": "confirm",
"style": {
@@ -225,6 +297,16 @@
"auth": true,
"title": "物流轨迹"
}
},
{
"path": "modifyDelivery",
"style": {
"navigationBarTitleText": "修改配送"
},
"meta": {
"auth": true,
"title": "修改配送"
}
}
]
},
@@ -444,6 +526,18 @@
"group": "通用"
}
},
{
"path": "avatarCrop",
"style": {
"navigationBarTitleText": "裁剪头像",
"navigationStyle": "custom"
},
"meta": {
"sync": true,
"title": "裁剪头像",
"group": "通用"
}
},
{
"path": "richtext",
"style": {
@@ -738,6 +832,13 @@
"enablePullDownRefresh": false
}
},
{
"path": "bankCard",
"style": {
"navigationBarTitleText": "银行卡",
"enablePullDownRefresh": false
}
},
{
"path": "phone",
"style": {
@@ -760,6 +861,13 @@
"enablePullDownRefresh": false
}
},
{
"path": "seedExchange",
"style": {
"navigationBarTitleText": "金种子兑换",
"enablePullDownRefresh": true
}
},
{
"path": "pointsDetail",
"style": {
@@ -813,12 +921,32 @@
"navigationBarTitleText": "待释放明细"
}
},
{
"path": "noReleaseAmount",
"style": {
"navigationBarTitleText": "收支明细"
}
},
{
"path" : "wallet",
"style" :
{
"navigationBarTitleText" : "钱包"
}
},
{
"path": "liquidation",
"style": {
"navigationBarTitleText": "去变现",
"enablePullDownRefresh": false
}
},
{
"path": "liquidationRecord",
"style": {
"navigationBarTitleText": "变现记录",
"enablePullDownRefresh": false
}
}
]
},
@@ -937,39 +1065,14 @@
"height": "50px",
"backgroundImage": "/static/index/6.png"
},
"list": [{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "static/index/1.png",
"selectedIconPath": "static/index/1_1.png"
},
{
"pagePath": "pages/index/category",
"text": "分类",
"iconPath": "static/index/2.png",
"selectedIconPath": "static/index/2_1.png"
},
{
"pagePath": "pages/cart/cart",
"text": "购物车",
"iconPath": "static/index/3.png",
"selectedIconPath": "static/index/3_1.png"
},
{
"pagePath": "pages/index/user",
"text": "我的",
"iconPath": "static/index/4.png",
"selectedIconPath": "static/index/4_1.png"
}
]
"list": []
},
"condition": {
//模式配置,仅开发期间生效
"current": 0, //当前激活的模式(list 的索引项)
"current": 0,
"list": [{
"name": "", //模式名称
"path": "", //启动页面,必选
"query": "" //启动参数,在页面的onLoad函数里面得到
"name": "",
"path": "",
"query": ""
}]
}
}
}
+363 -305
View File
@@ -1,332 +1,390 @@
<template>
<s-pages title="收银台" :goLeft="false" @onClickLeft="onClickLeft">
<view class="p-x-32">
<view class="center p-t-96 weight500 size100"><span class="size48">¥</span>
{{ fen2yuan(state.orderInfo.payPrice) }}
</view>
<view class="center m-t-20 m-b-66">{{ payDescText }}</view>
<view>
<radio-group @change="onTapPay">
<label class="" v-for="item in state.payMethods" :key="item.title">
<view class="flex-center ju-between m-b-40" :class="{ 'disabled-pay-item': item.disabled }">
<view class="flex-center">
<image class="h_64 w_64" v-if="item.disabled"
:src="sheep.$url.static('/static/img/shop/pay/cod_disabled.png')"
mode="aspectFit" />
<image class="h_64 w_64" v-else :src="sheep.$url.static(item.icon)" mode="aspectFit" />
<text class="pay-title m-l-12">{{ item.title }}</text>
</view>
<view class="check-box ss-flex ss-col-center ss-p-l-10">
<view class="userInfo-money ss-m-r-10" v-if="item.value === 'wallet'">
余额: {{ fen2yuan(totalRecharge) }}元
</view>
<view class="">
<radio :value="item.value" color="var(--ui-BG-Main)"
backgroundColor="rgba(255, 255, 255, 0)" :disabled="item.disabled"
:checked="state.payment === item.value" />
</view>
</view>
</view>
</label>
</radio-group>
</view>
<s-pages title="收银台" :pink_bg="true" :goLeft="false" @onClickLeft="onClickLeft">
<view class="p-x-32">
<view class="center p-t-96 weight500 size100"
><span class="size48">¥</span>
{{ fen2yuan(state.orderInfo.payPrice) }}
</view>
<view class="center size22 c_money">
已优惠{{ fen2yuan(state.orderInfo.randomDiscountPrice) }}元
</view>
<view class="center m-t-20 m-b-66">{{ payDescText }}</view>
<view>
<radio-group @change="onTapPay">
<label class="" v-for="item in state.payMethods" :key="item.title">
<view
class="flex-center ju-between m-b-40"
:class="{ 'disabled-pay-item': item.disabled }"
>
<view class="flex-center">
<image
class="h_64 w_64"
v-if="item.disabled"
:src="sheep.$url.static('/static/img/shop/pay/cod_disabled.png')"
mode="aspectFit"
/>
<image
class="h_64 w_64"
v-else
:src="sheep.$url.static(item.icon)"
mode="aspectFit"
/>
<text class="pay-title m-l-12">{{ item.title }}</text>
</view>
<view class="check-box ss-flex ss-col-center ss-p-l-10">
<view class="userInfo-money ss-m-r-10" v-if="item.value === 'wallet'">
余额: {{ fen2yuan(totalRecharge) }}元
</view>
<view class="">
<radio
:value="item.value"
color="var(--ui-BG-Main)"
backgroundColor="rgba(255, 255, 255, 0)"
:disabled="item.disabled"
:checked="state.payment === item.value"
/>
</view>
</view>
</view>
</label>
</radio-group>
</view>
<!-- 工具 -->
<view class="modal-footer ss-flex ss-row-center ss-col-center ss-m-t-80 ss-m-b-40">
<button v-if="state.payStatus === 0" class="ss-reset-button past-due-btn">
检测支付环境中
</button>
<button v-else-if="state.payStatus === -1" class="ss-reset-button past-due-btn" disabled>
支付已过期
</button>
<button v-else class="ai-button2" @tap="onPay" :disabled="state.payStatus !== 1"
:class="{ 'disabled-btn': state.payStatus !== 1 }">
立即支付
</button>
</view>
</view>
</s-pages>
<!-- 工具 -->
<view class="modal-footer ss-flex ss-row-center ss-col-center ss-m-t-80 ss-m-b-40">
<button v-if="state.payStatus === 0" class="ss-reset-button past-due-btn">
检测支付环境中
</button>
<button v-else-if="state.payStatus === -1" class="ss-reset-button past-due-btn" disabled>
支付已过期
</button>
<button v-else-if="state.payStatus === 3" class="ai-button2" @tap="onPay">
切换支付方式
</button>
<button
v-else
class="ai-button2"
@tap="onPay"
:disabled="state.payStatus !== 1"
:class="{ 'disabled-btn': state.payStatus !== 1 }"
>
立即支付
</button>
</view>
</view>
</s-pages>
</template>
<script setup lang="ts">
import {
ref,
reactive,
onMounted,
onUnmounted,
getCurrentInstance,
watch,
nextTick,
computed,
} from 'vue';
let { proxy } = getCurrentInstance();
import { onLoad, onShow } from '@dcloudio/uni-app';
import * as api from '@/sheep/api/ai/index';
import sheep from '@/sheep';
import PayChannelApi from '@/sheep/api/pay/channel';
import { fen2yuan, useDurationTime } from '@/sheep/hooks/useGoods';
import { getPayMethods, goPayResult } from '@/sheep/platform/pay';
import { SYSCONST } from '@/sheep/helper/const';
import { getWallet } from '@/sheep/api/home/pay';
let id = ref('');
let payOrderId = ref('');
let orderInfo = ref({});
const userWallet = ref();
import {
ref,
reactive,
onMounted,
onUnmounted,
getCurrentInstance,
watch,
nextTick,
computed,
} from 'vue';
let { proxy } = getCurrentInstance();
import { onLoad, onShow } from '@dcloudio/uni-app';
import * as api from '@/sheep/api/ai/index';
import sheep from '@/sheep';
import PayChannelApi from '@/sheep/api/pay/channel';
import PayOrderApi from '@/sheep/api/pay/order';
import { fen2yuan, useDurationTime } from '@/sheep/hooks/useGoods';
import { getPayMethods, goPayResult } from '@/sheep/platform/pay';
import { SYSCONST } from '@/sheep/helper/const';
import { getWallet } from '@/sheep/api/home/pay';
let id = ref('');
let payOrderId = ref('');
let orderInfo = ref({});
const userWallet = ref();
const returnTo = ref('');
let totalRecharge = ref();
// 检测支付环境
const state = reactive({
orderType: 'aiGoods', // 订单类型; goods - 商品订单, recharge - 充值订单 aiRecharge
orderInfo: {}, // 支付单信息
payStatus: 0, // 0=检测支付环境, -2=未查询到支付单信息, -1=支付已过期, 1=待支付,2=订单已支付
payMethods: [], // 可选的支付方式
payment: '', // 选中的支付方式
});
const getOrderDetail = async () => {
let { code, data } = await api.getOrderDetail({ id: id.value });
console.log('订单详情', code, data);
if (code !== 0 || !data) {
state.payStatus = -2;
return;
}
state.orderInfo = data || {};
// 设置支付状态
checkPayStatus();
// 获得支付方式
await setPayMethods();
};
let totalRecharge = ref();
// 检测支付环境
const state = reactive({
orderType: 'aiGoods', // 订单类型; goods - 商品订单, recharge - 充值订单 aiRecharge
orderInfo: {}, // 支付单信息
payStatus: 0, // 0=检测支付环境, -2=未查询到支付单信息, -1=支付已过期, 1=待支付,2=订单已支付,3=现金待确认
payMethods: [], // 可选的支付方式
payment: '', // 选中的支付方式
});
const getOrderDetail = async () => {
let { code, data } = await api.getOrderDetail({ id: id.value });
console.log('订单详情', code, data);
if (code !== 0 || !data) {
state.payStatus = -2;
return;
}
state.orderInfo = data || {};
// 设置支付状态
checkPayStatus();
// 获得支付方式
await setPayMethods();
};
// 获得支付方式
async function setPayMethods() {
const { data, code } = await PayChannelApi.getEnableChannelCodeList(state.orderInfo.appId || 1);
// console.log('支付方式', code, data);
if (code !== 0) {
return;
}
state.payMethods = getPayMethods(data);
console.log('支付方式', state.payMethods);
// 金额超出阈值,仅允许余额支付
if (state.orderInfo?.totalPrice >= SYSCONST.MAX_PRICE) {
state.payMethods = state.payMethods.map((item) => ({
...item,
disabled: item.value !== 'wallet' ? true : item.disabled,
}));
state.payment = 'wallet';
}
state.payMethods.find((item) => {
if (item.value && !item.disabled) {
state.payment = item.value;
return true;
}
});
}
// 支付文案提示
const payDescText = computed(() => {
if (state.payStatus === 2) {
return '该订单已支付';
}
if (state.payStatus === 1 && state.orderInfo?.payExpireTime) {
const time = useDurationTime(state.orderInfo.payExpireTime);
if (time?.ms <= 0) {
state.payStatus = -1;
return '';
}
return `剩余支付时间 ${time?.h}:${time?.m}:${time?.s} `;
}
if (state.payStatus === -2) {
return '未查询到支付单信息';
}
return '';
});
// 获得支付方式
async function setPayMethods() {
// 业务订单详情不含支付应用编号,拆分后需从支付单获取真实 appId,避免误用商城应用渠道
let appId = Number(state.orderInfo.appId);
if (!appId && payOrderId.value) {
const payOrderRes = await PayOrderApi.getOrder(payOrderId.value, false);
appId = Number(payOrderRes?.data?.appId);
}
if (!appId) {
sheep.$helper.toast('支付应用信息异常');
state.payMethods = [];
return;
}
const { data, code } = await PayChannelApi.getEnableChannelCodeList(appId);
// console.log('支付方式', code, data);
if (code !== 0) {
return;
}
// 现金待确认状态下去除现金渠道,仅展示可切换的线上渠道
state.payMethods = getPayMethods(data).filter(
(item) => item.value !== 'cash' || state.payStatus !== 3,
);
console.log('支付方式', state.payMethods);
// 金额超出阈值,仅允许余额支付
if (state.orderInfo?.totalPrice >= SYSCONST.MAX_PRICE) {
state.payMethods = state.payMethods.map((item) => ({
...item,
disabled: item.value !== 'wallet' ? true : item.disabled,
}));
state.payment = 'wallet';
}
state.payMethods.find((item) => {
if (item.value && !item.disabled) {
state.payment = item.value;
return true;
}
});
}
// 支付文案提示
const payDescText = computed(() => {
if (state.payStatus === 2) {
return '该订单已支付';
}
if (state.payStatus === 3) {
return '现金待确认';
}
if (state.payStatus === 1 && state.orderInfo?.payExpireTime) {
const time = useDurationTime(state.orderInfo.payExpireTime);
if (time?.ms <= 0) {
state.payStatus = -1;
return '';
}
return `剩余支付时间 ${time?.h}:${time?.m}:${time?.s} `;
}
if (state.payStatus === -2) {
return '未查询到支付单信息';
}
return '';
});
// 状态转换:payOrder.status => payStatus
function checkPayStatus() {
if (state.orderInfo.status === 10 || state.orderInfo.status === 20) {
// 支付成功
state.payStatus = 2;
// 跳转回支付成功页
uni.showModal({
title: '提示',
content: '订单已支付',
confirmColor: '#FA7E31',
showCancel: false,
success: function () {
goPayResult(state.orderInfo.id, state.orderType);
},
});
return;
}
if (state.orderInfo.status === 30) {
// 支付关闭
state.payStatus = -1;
return;
}
state.payStatus = 1; // 待支付
}
// 状态转换:payOrder.status => payStatus
function checkPayStatus() {
if (state.orderInfo.status === 10 || state.orderInfo.status === 20) {
// 支付成功
state.payStatus = 2;
// 跳转回支付成功页
uni.showModal({
title: '提示',
content: '订单已支付',
confirmColor: '#FA7E31',
showCancel: false,
success: function () {
goPayResult(state.orderInfo.id, state.orderType);
},
});
return;
}
if (state.orderInfo.status === 30) {
// 支付关闭
state.payStatus = -1;
return;
}
if (Number(state.orderInfo.status) === 70) {
state.payStatus = 3;
return;
}
state.payStatus = 1; // 待支付
}
// 切换支付方式
function onTapPay(e) {
state.payment = e.detail.value;
}
let type = ref(); //2充值
onLoad(async (options) => {
id.value = options.id || '';
payOrderId.value = options.payOrderId || '';
type.value = options.type || '';
// 切换支付方式
function onTapPay(e) {
state.payment = e.detail.value;
}
let type = ref(); //2充值
onLoad(async (options) => {
id.value = options.id || '';
payOrderId.value = options.payOrderId || '';
type.value = options.type || '';
returnTo.value = options.returnTo || '';
if (type.value == 2) {
state.orderType = 'aiRecharge';
state.orderInfo.totalPrice = options.price * 100;
// state.orderInfo.price = options.price || '';
if (type.value == 2) {
state.orderType = 'aiRecharge';
state.orderInfo.totalPrice = options.price * 100;
// state.orderInfo.price = options.price || '';
// 设置支付状态
checkPayStatus();
// 获得支付方式
await setPayMethods();
} else {
getOrderDetail();
}
});
onShow(() => {
getWallet().then((res) => {
if (res.code === 0) {
totalRecharge.value = res.data.totalRecharge;
}
});
});
const onPay = () => {
// console.log(userWallet.value.totalRecharge);
if (state.payment === '') {
sheep.$helper.toast('请选择支付方式');
return;
}
if (state.orderInfo.totalPrice >= SYSCONST.MAX_PRICE && state.payment !== 'wallet') {
sheep.$helper.toast('请选择余额支付');
return;
}
if (state.payment === 'wallet') {
uni.showModal({
title: '提示',
content: '确定要支付吗?',
confirmColor: '#FA7E31',
success: function (res) {
if (res.confirm) {
// sheep.$platform.pay(state.payment, state.orderType, payOrderId.value);
if (totalRecharge.value < state.orderInfo.totalPrice) {
uni.showToast({
title: '余额不足请充值',
icon: 'none',
});
setTimeout(() => {
uni.navigateTo({
url: '/pages/home/recharge',
});
}, 1000);
} else {
sheep.$platform.pay(state.payment, state.orderType, payOrderId.value);
}
}
},
});
} else {
sheep.$platform.pay(state.payment, state.orderType, payOrderId.value);
}
};
const onClickLeft = () => {
uni.navigateBack({
delta: 1,
});
};
// 设置支付状态
checkPayStatus();
// 获得支付方式
await setPayMethods();
} else {
getOrderDetail();
}
});
onShow(() => {
getWallet().then((res) => {
if (res.code === 0) {
totalRecharge.value = res.data.totalRecharge;
}
});
});
const onPay = () => {
// console.log(userWallet.value.totalRecharge);
if (state.payment === '') {
sheep.$helper.toast('请选择支付方式');
return;
}
if (state.orderInfo.totalPrice >= SYSCONST.MAX_PRICE && state.payment !== 'wallet') {
sheep.$helper.toast('请选择余额支付');
return;
}
if (returnTo.value) {
uni.setStorageSync('pay_return_to', returnTo.value);
} else if (String(type.value) === '2') {
uni.setStorageSync('pay_return_to', 'aiStore_plaza');
} else if (state.orderType === 'aiGoods') {
uni.setStorageSync('pay_return_to', 'aiStore_myshop');
}
if (state.payment === 'wallet') {
uni.showModal({
title: '提示',
content: '确定要支付吗?',
confirmColor: '#FA7E31',
success: function (res) {
if (res.confirm) {
// sheep.$platform.pay(state.payment, state.orderType, payOrderId.value);
if (totalRecharge.value < state.orderInfo.totalPrice) {
uni.showToast({
title: '余额不足请充值',
icon: 'none',
});
setTimeout(() => {
uni.navigateTo({
url: '/pages/home/recharge',
});
}, 1000);
} else {
sheep.$platform.pay(state.payment, state.orderType, payOrderId.value);
}
}
},
});
} else {
sheep.$platform.pay(state.payment, state.orderType, payOrderId.value);
}
};
const onClickLeft = () => {
uni.navigateBack({
delta: 1,
});
};
</script>
<style lang="scss" scoped>
.pay-icon {
width: 36rpx;
height: 36rpx;
margin-right: 26rpx;
}
.pay-icon {
width: 36rpx;
height: 36rpx;
margin-right: 26rpx;
}
.ss-modal-box {
// max-height: 1000rpx;
.ss-modal-box {
// max-height: 1000rpx;
.modal-header {
position: relative;
padding: 60rpx 20rpx 40rpx;
.modal-header {
position: relative;
padding: 60rpx 20rpx 40rpx;
.money-text {
color: $red;
font-size: 46rpx;
font-weight: bold;
font-family: OPPOSANS;
.money-text {
color: $red;
font-size: 46rpx;
font-weight: bold;
font-family: OPPOSANS;
&::before {
content: '¥';
font-size: 30rpx;
}
}
&::before {
content: '¥';
font-size: 30rpx;
}
}
.time-text {
font-size: 26rpx;
color: $gray-b;
}
.time-text {
font-size: 26rpx;
color: $gray-b;
}
.close-icon {
position: absolute;
top: 10rpx;
right: 20rpx;
font-size: 46rpx;
opacity: 0.2;
}
}
.close-icon {
position: absolute;
top: 10rpx;
right: 20rpx;
font-size: 46rpx;
opacity: 0.2;
}
}
.modal-content {
overflow-y: auto;
.modal-content {
overflow-y: auto;
.pay-title {
font-size: 26rpx;
font-weight: 500;
color: #333333;
}
.pay-title {
font-size: 26rpx;
font-weight: 500;
color: #333333;
}
.pay-tip {
font-size: 26rpx;
color: #bbbbbb;
}
.pay-tip {
font-size: 26rpx;
color: #bbbbbb;
}
.pay-item {
height: 86rpx;
}
.pay-item {
height: 86rpx;
}
.disabled-pay-item {
.pay-title {
color: #999999;
}
}
.disabled-pay-item {
.pay-title {
color: #999999;
}
}
.userInfo-money {
font-size: 26rpx;
color: #bbbbbb;
line-height: normal;
}
}
.userInfo-money {
font-size: 26rpx;
color: #bbbbbb;
line-height: normal;
}
}
.save-btn {
width: 710rpx;
height: 80rpx;
border-radius: 40rpx;
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
color: $white;
}
.save-btn {
width: 710rpx;
height: 80rpx;
border-radius: 40rpx;
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
color: $white;
}
.disabled-btn {
background: #e5e5e5;
color: #999999;
}
.disabled-btn {
background: #e5e5e5;
color: #999999;
}
.past-due-btn {
width: 710rpx;
height: 80rpx;
border-radius: 40rpx;
background-color: #999;
color: #fff;
}
}
</style>
.past-due-btn {
width: 710rpx;
height: 80rpx;
border-radius: 40rpx;
background-color: #999;
color: #fff;
}
}
</style>
+30 -3
View File
@@ -68,14 +68,21 @@
<detail-content-card class="detail-content-selector" :content="state.goodsInfo.description" />
</view>
</block>
<view class="theme-ai">
<card_payment ref="paymentRef" source="orderInfo" :actionStatus="timeText" @addCar="addCar" />
<view class="theme-ai" v-if="state.goodsInfo && state.goodsInfo.id">
<card_payment ref="paymentRef" source="orderInfo" :actionStatus="timeText" :bottomOffset="paymentBottomOffset"
@addCar="addCar" @updatePrice="updatePrice" />
</view>
<su-fixed bottom placeholder bg="bg24" :zIndex="1"
v-if="state.goodsInfo && state.goodsInfo.id && !hasCartItems">
<view class="buy-now-bar bg24">
<view class="ai-button1 buy-now-btn" @tap="addCar">立即购买</view>
</view>
</su-fixed>
</view>
</s-layout>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, onUnmounted, getCurrentInstance, watch, nextTick } from 'vue';
import { computed, ref, reactive, onMounted, onUnmounted, getCurrentInstance, watch, nextTick } from 'vue';
import { onLoad, onPageScroll } from '@dcloudio/uni-app';
import sheep from '@/sheep';
// import { onPageScroll} from '@dcloudio/uni-app';
@@ -114,6 +121,7 @@ const getInfo = async () => {
};
let id = ref();
let shoppingPlazaId = ref();
const hasCartItems = ref(false);
onLoad(async (options) => {
// 滚到顶部
uni.pageScrollTo({
@@ -130,6 +138,9 @@ function onSkuChange(e) {
const onAddCart = () => { };
const onBuy = () => { };
let paymentRef = ref(null);
const updatePrice = (val) => {
hasCartItems.value = !!val;
};
const addCar = () => {
paymentRef.value.addCar({ ...state.goodsInfo, shoppingPlazaId: shoppingPlazaId.value });
};
@@ -187,6 +198,9 @@ let sysInfo = uni.getSystemInfoSync();
const windowHeight = sysInfo.windowHeight;
let height = ref(0);
height.value = sysInfo.statusBarHeight + uni.upx2px(88);
const buyBarOffset =
uni.upx2px(120) + Number(sheep?.$platform?.device?.safeAreaInsets?.bottom || 0);
const paymentBottomOffset = computed(() => (hasCartItems.value ? 0 : buyBarOffset));
</script>
<style lang="scss" scoped>
.detail-card {
@@ -457,6 +471,19 @@ height.value = sysInfo.statusBarHeight + uni.upx2px(88);
left: 0;
}
.buy-now-bar {
height: 120rpx;
padding: 20rpx 32rpx;
box-sizing: border-box;
}
.buy-now-btn {
width: 100%;
height: 80rpx;
line-height: 80rpx;
text-align: center;
}
:deep(.uni-countdown__number) {
font-size: 24rpx !important;
width: 40rpx !important;
+37 -5
View File
@@ -1,10 +1,10 @@
<template>
<s-pages title="收银台" :goLeft="false" @onClickLeft="onClickLeft">
<s-pages title="收银台" :pink_bg="true" :goLeft="false" @onClickLeft="onClickLeft">
<view class="p-x-32">
<view class="center p-t-96 weight500 size100"
><span class="size48">¥</span>
<!-- {{ fen2yuan(state.orderInfo.totalPrice) }} -->
{{ fen2yuan(state.orderInfo.totalPrice) }}
{{ fen2yuan(state.orderInfo.payPrice) }}
</view>
<view class="center m-t-20 m-b-66">{{ payDescText }}</view>
<view>
@@ -60,6 +60,9 @@
<button v-else-if="state.payStatus === -1" class="ss-reset-button past-due-btn" disabled>
支付已过期
</button>
<button v-else-if="state.payStatus === 3" class="ai-button2" @tap="onPay">
切换支付方式
</button>
<button
v-else
class="ai-button2"
@@ -89,6 +92,7 @@
import * as api from '@/sheep/api/ai/index';
import sheep from '@/sheep';
import PayChannelApi from '@/sheep/api/pay/channel';
import PayOrderApi from '@/sheep/api/pay/order';
import { fen2yuan, useDurationTime } from '@/sheep/hooks/useGoods';
import { getPayMethods, goPayResult } from '@/sheep/platform/pay';
import { SYSCONST } from '@/sheep/helper/const';
@@ -97,13 +101,14 @@
let payOrderId = ref('');
let orderInfo = ref({});
const userWallet = ref();
const returnTo = ref('');
let totalRecharge = ref();
// 检测支付环境
const state = reactive({
orderType: 'aiGoods', // 订单类型; goods - 商品订单, recharge - 充值订单 aiRecharge
orderInfo: {}, // 支付单信息
payStatus: 0, // 0=检测支付环境, -2=未查询到支付单信息, -1=支付已过期, 1=待支付,2=订单已支付
payStatus: 0, // 0=检测支付环境, -2=未查询到支付单信息, -1=支付已过期, 1=待支付,2=订单已支付,3=现金待确认
payMethods: [], // 可选的支付方式
payment: '', // 选中的支付方式
});
@@ -122,11 +127,25 @@
// 获得支付方式
async function setPayMethods() {
const { data, code } = await PayChannelApi.getEnableChannelCodeList(state.orderInfo.appId || 1);
// 业务订单详情不含支付应用编号,拆分后需从支付单获取真实 appId,避免误用商城应用渠道
let appId = Number(state.orderInfo.appId);
if (!appId && payOrderId.value) {
const payOrderRes = await PayOrderApi.getOrder(payOrderId.value, false);
appId = Number(payOrderRes?.data?.appId);
}
if (!appId) {
sheep.$helper.toast('支付应用信息异常');
state.payMethods = [];
return;
}
const { data, code } = await PayChannelApi.getEnableChannelCodeList(appId);
if (code !== 0) {
return;
}
state.payMethods = getPayMethods(data);
// 现金待确认状态下去除现金渠道,仅展示可切换的线上渠道
state.payMethods = getPayMethods(data).filter(
(item) => item.value !== 'cash' || state.payStatus !== 3,
);
// 金额超出阈值,仅允许余额支付
if (state.orderInfo?.totalPrice >= SYSCONST.MAX_PRICE) {
state.payMethods = state.payMethods.map((item) => ({
@@ -147,6 +166,9 @@
if (state.payStatus === 2) {
return '该订单已支付';
}
if (state.payStatus === 3) {
return '现金待确认';
}
if (state.payStatus === 1 && state.orderInfo?.payExpireTime) {
const time = useDurationTime(state.orderInfo.payExpireTime);
if (time?.ms <= 0) {
@@ -183,6 +205,10 @@
state.payStatus = -1;
return;
}
if (Number(state.orderInfo.status) === 70) {
state.payStatus = 3;
return;
}
state.payStatus = 1; // 待支付
}
@@ -197,6 +223,7 @@
id.value = options.id || '';
payOrderId.value = options.payOrderId || '';
type.value = options.type || '';
returnTo.value = options.returnTo || '';
if (type.value == 2) {
state.orderType = 'aiRecharge';
@@ -228,6 +255,11 @@
sheep.$helper.toast('请选择余额支付');
return;
}
if (returnTo.value) {
uni.setStorageSync('pay_return_to', returnTo.value);
} else if (state.orderType === 'aiGoods') {
uni.setStorageSync('pay_return_to', 'aiStore_myshop');
}
if (state.payment === 'wallet') {
uni.showModal({
title: '提示',
+151 -35
View File
@@ -1,7 +1,7 @@
<template>
<s-pages title="确认订单">
<s-pages title="确认订单" :pink_bg="true">
<view class="p-b-132">
<AddressSelection v-model="addressState" theme="2" @getSettlementInfo="getSettlementInfo" />
<AddressSelection v-model="addressState" theme="2" />
<view class="p-x-32 m-t-24">
<view class="bg24 p-x-20 p-t-20 radius16">
<view v-if="settlementInfo.items && settlementInfo.items.length">
@@ -14,10 +14,41 @@
<view class="c25 size28">商品金额</view>
<view>¥{{ $fen2yuan(settlementInfo?.price?.totalPrice || 0) }}</view>
</view>
<view class="flex-row ju-between m-b-36">
<view
class="flex-row ju-between m-b-36"
v-if="addressState.deliveryType === DeliveryTypeEnum.EXPRESS.type"
>
<view class="c25 size28">运费</view>
<view>¥{{ $fen2yuan(settlementInfo?.price?.deliveryPrice || 0) }}</view>
</view>
<view
class="flex-row ju-between m-b-36"
v-if="addressState.deliveryType === DeliveryTypeEnum.PICK_UP.type"
>
<view class="c25 size28">联系人</view>
<uni-easyinput
class="order-input"
maxlength="20"
placeholder="请填写您的联系姓名"
v-model="addressState.receiverName"
:inputBorder="false"
:clearable="false"
/>
</view>
<view
class="flex-row ju-between m-b-36"
v-if="addressState.deliveryType === DeliveryTypeEnum.PICK_UP.type"
>
<view class="c25 size28">联系电话</view>
<uni-easyinput
class="order-input"
maxlength="20"
placeholder="请填写您的联系电话"
v-model="addressState.receiverMobile"
:inputBorder="false"
:clearable="false"
/>
</view>
<view class="flex-center ju-flex-end borderTop">
<span class="size26 line96">合计: </span>
<span class="c13 size28 m-l-12 line96 weight900"
@@ -28,42 +59,58 @@
</view>
</view>
<view class="p-x-32 btn">
<view class="ai-button2" @click="sub">确认订单</view>
<view class="ai-button2" :class="{ 'ai-button2--disabled': isSubmitting }" @click="sub"
>确认订单</view
>
</view>
</s-pages>
</template>
<script setup lang="ts">
import { ref, getCurrentInstance } from 'vue';
import { ref, getCurrentInstance, watch } from 'vue';
import AddressSelection from '@/pages/order/addressSelection.vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import aiOrder from '@/components/ai_order/ai_order';
let { proxy } = getCurrentInstance();
import api from '@/sheep/api/member/address';
import * as SpuApi from '@/sheep/api/ai/index';
import { DeliveryTypeEnum } from '@/sheep/helper/const';
const addressState = ref({
addressInfo: {},
deliveryType: 1,
isPickUp: false,
deliveryType: DeliveryTypeEnum.EXPRESS.type,
isPickUp: true,
pickUpInfo: {},
receiverName: '',
receiverMobile: '',
});
let remark_value = ref();
let spuId = ref();
let spuPrice = ref();
const isSubmitting = ref(false);
const settlementInfo = ref<any>({});
let addressId = ref('');
const getSettlementInfo = (id = '') => {
addressId.value = id;
SpuApi.getGiftSettlementInfo({
id: id,
const lastSettlementQuery = ref('');
const getSettlementRequestId = () => String(addressState.value.addressInfo?.id || '');
const getSettlementInfo = () => {
const query = {
id: getSettlementRequestId(),
spuId: spuId.value,
deliveryType: addressState.value.deliveryType,
pickUpStoreId:
addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type
? String(addressState.value.pickUpInfo?.id || '')
: undefined,
};
const queryKey = JSON.stringify(query);
if (queryKey === lastSettlementQuery.value) {
return;
}
lastSettlementQuery.value = queryKey;
SpuApi.getGiftSettlementInfo({
...query,
}).then((res: any) => {
settlementInfo.value = res.data || {};
// 设置收货地址
if (res.data.address) {
if (!addressState.value.addressInfo?.id && res.data.address) {
addressState.value.addressInfo = res.data.address;
}
// if (settlementInfo.value?.items?.length) {
@@ -82,31 +129,72 @@
});
};
const sub = async () => {
if (!addressId.value) return proxy.utils.toast('请选择地址');
let res: any = await SpuApi.createOrderOpen({
id: addressId.value,
spuId: spuId.value,
userRemark: remark_value.value,
});
if (res.code === 0) {
proxy.utils.toast('下单成功');
setTimeout(() => {
proxy.utils.go('/pages/AI/giftCashierDesk', {
id: res.data.id,
payOrderId: res.data.payOrderId,
});
}, 1000);
if (isSubmitting.value) {
return;
}
if (
addressState.value.deliveryType === DeliveryTypeEnum.EXPRESS.type &&
!addressState.value.addressInfo?.id
) {
return proxy.utils.toast('请选择收货地址');
}
if (addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type) {
if (!addressState.value.pickUpInfo?.id) {
return proxy.utils.toast('请选择自提门店');
}
if (addressState.value.receiverName === '' || addressState.value.receiverMobile === '') {
return proxy.utils.toast('请填写联系人或联系人电话');
}
if (!/^[\u4e00-\u9fa5\w]{2,16}$/.test(addressState.value.receiverName)) {
return proxy.utils.toast('请填写您的真实姓名');
}
if (!/^1(3|4|5|7|8|9|6)\d{9}$/.test(addressState.value.receiverMobile)) {
return proxy.utils.toast('请填写正确的手机号');
}
}
isSubmitting.value = true;
try {
let res: any = await SpuApi.createOrderOpen({
id: getSettlementRequestId(),
spuId: spuId.value,
deliveryType: addressState.value.deliveryType,
pickUpStoreId:
addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type
? addressState.value.pickUpInfo?.id
: undefined,
receiverName:
addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type
? addressState.value.receiverName
: undefined,
receiverPhone:
addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type
? addressState.value.receiverMobile
: undefined,
userRemark: remark_value.value,
});
if (res.code === 0) {
proxy.utils.toast('下单成功');
setTimeout(() => {
proxy.utils.go('/pages/AI/giftCashierDesk', {
id: res.data.id,
payOrderId: res.data.payOrderId,
returnTo: 'aiStore_plaza',
});
}, 1000);
return;
}
isSubmitting.value = false;
} catch (e) {
isSubmitting.value = false;
}
};
const getAddress = () => {
api.getAddressList().then((res) => {
api.getAddressList().then((res: any) => {
if (res.code === 0 && res.data?.length) {
// addressState.value.addressInfo = res.data[0];
// getSettlementInfo(res.data[0].id);
let index = res.data.findIndex((e) => e.defaultStatus);
let index = res.data.findIndex((e: any) => e.defaultStatus);
if (index !== -1) {
addressState.value.addressInfo = res.data[index];
getSettlementInfo(res.data[index].id);
getSettlementInfo();
} else {
getSettlementInfo();
}
@@ -120,15 +208,27 @@
// spuId.value = options.id;
// }
// if (options.price) {
// spuPrice.value = options.price;
// }
// getSettlementInfo();
// });
onLoad((e) => {
onLoad((e: any) => {
// getCartList();
spuId.value = e.id;
// console.log(e.id);
});
watch(
() => [
addressState.value.deliveryType,
addressState.value.addressInfo?.id,
addressState.value.pickUpInfo?.id,
spuId.value,
],
() => {
getSettlementInfo();
},
);
onShow(() => {
getAddress();
});
@@ -157,4 +257,20 @@
border-top: 1rpx solid #dfdfdf;
padding: 12rpx 0;
}
:deep(.order-input) {
width: 320rpx;
}
:deep(.order-input .uni-easyinput__content) {
background: transparent !important;
}
:deep(.order-input .uni-easyinput__content-input) {
text-align: right !important;
font-size: 26rpx;
height: 56rpx;
padding-right: 0 !important;
}
.ai-button2--disabled {
opacity: 0.6;
pointer-events: none;
}
</style>
+77 -7
View File
@@ -1,6 +1,6 @@
<!-- 订单详情 -->
<template>
<s-pages title="订单详情">
<s-pages title="订单详情" :pink_bg="true">
<view class="flex-center al-flex-end ju-between p-x-32 m-b-54">
<view>
<view class="size40 weight500 m-b-16">{{ statusObj[state.orderInfo.status]?.text }}</view>
@@ -42,6 +42,7 @@
:data="state.orderInfo"
type="4"
@getOrderDetail="getOrderDetail"
@openExpress="handleOpenExpress"
></card_order>
<!-- 价格信息 -->
@@ -73,7 +74,12 @@
<view class="copy" @click.stop="onCopy">
<image :src="`${$url}goods/copy1.png`" mode="scaleToFill" />
</view>
<truckLine :data="state.orderInfo" :code="3" v-if="state.orderInfo.deliveryTime"></truckLine>
<truckLine
:data="state.orderInfo"
:code="3"
v-if="state.orderInfo.deliveryTime"
@openExpress="handleOpenExpress"
></truckLine>
</view>
<view class="notice-item flex-row ju-between">
<text class="title c25">下单时间</text>
@@ -95,8 +101,14 @@
</view>
<view
class="flex btns bg16"
v-if="statusObj[state.orderInfo.status]?.btn1 || statusObj[state.orderInfo.status]?.btn2"
>
<view
v-if="hasExpress"
class="ai-button3 h_70 line70 size28"
:class="{ 'm-r-28': statusObj[state.orderInfo.status]?.btn1 || statusObj[state.orderInfo.status]?.btn2 }"
@click="handleOpenExpress"
>查看物流</view
>
<view
class="ai-button1 h_70 line70 size28"
:class="{
@@ -115,13 +127,21 @@
>
</view>
</view>
<ExpressListPopup
ref="expressListPopupRef"
popup-type="center"
:order-no="state.orderInfo.no || ''"
:order-data="state.orderInfo"
:delay-records="[]"
:order-id="orderId || state.orderInfo.id || 0"
/>
</s-pages>
</template>
<script setup>
import sheep from '@/sheep';
import { onLoad, onShow } from '@dcloudio/uni-app';
import { reactive, ref, getCurrentInstance } from 'vue';
import { reactive, ref, getCurrentInstance, computed } from 'vue';
import { isEmpty } from 'lodash-es';
import {
fen2yuan,
@@ -133,6 +153,7 @@
import DeliveryApi from '@/sheep/api/trade/delivery';
import PickUpVerify from '@/pages/order/pickUpVerify.vue';
import card_order from '@/components/orderItem/card_order.vue';
import ExpressListPopup from '@/components/orderItem/ExpressListPopup.vue';
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
const headerBg = sheep.$url.css('/static/img/shop/order/order_bg.png');
@@ -169,6 +190,12 @@
text: '已取消',
text1: '您的订单已取消!',
},
70: {
text: '现金待确认',
text1: '等待工作人员确认收款',
btn1: '切换支付',
btn2: '取消订单',
},
});
// ========== 门店自提(核销) ==========
@@ -234,7 +261,14 @@
}
if (state.orderInfo.status === 0 && type === 2) {
// 取消订单
cancelOrder();
cancelUnpaidOpenOrder();
}
if (Number(state.orderInfo.status) === 70 && type === 2) {
cancelOpenOrder();
}
if (Number(state.orderInfo.status) === 70 && type === 1) {
// 现金待确认切回线上支付
goPay();
}
if (state.orderInfo.status === 20 && type === 1) {
// 确认收货confirmReceive
@@ -253,8 +287,8 @@
payOrderId: state.orderInfo.payOrderId,
});
};
const cancelOrder = () => {
OrderApi.cancelOrder({
const cancelUnpaidOpenOrder = () => {
OrderApi.cancelUnpaidOpenOrder({
id: orderId.value,
}).then((res) => {
if (res.code === 0) {
@@ -262,6 +296,42 @@
}
});
};
const cancelOpenOrder = () => {
OrderApi.cancelOpenOrder({
id: orderId.value,
}).then((res) => {
if (res.code === 0) {
getOrderDetail();
}
});
};
const expressListPopupRef = ref();
const isPickUpOrder = () => Number(state.orderInfo?.deliveryType ?? 0) === 2;
const hasExpress = computed(() => {
const s = Number(state.orderInfo?.status ?? -1);
if ([15, 20, 30].includes(s)) return true;
if (Number(state.orderInfo?.logisticsId ?? 0) > 0) return true;
if (state.orderInfo?.logisticsNo && String(state.orderInfo.logisticsNo).trim()) return true;
if (state.orderInfo?.deliveryTime) return true;
return false;
});
const handleOpenExpress = () => {
const id = orderId.value || state.orderInfo?.id || 0;
if (!id) {
uni.showToast({
title: '订单信息异常',
icon: 'none',
});
return;
}
// 赠送店铺订单详情页:赠送订单(无论type多少)一律弹窗查看物流;自提兜底走原生
if (!isPickUpOrder()) {
expressListPopupRef.value?.open?.();
return;
}
sheep.$router.go('/pages/order/express/log', { id });
};
</script>
<style lang="scss" scoped>
+5 -5
View File
@@ -1,5 +1,5 @@
<template>
<s-pages title="AI店铺" :goLeft="false" @onClickLeft="onClickLeft">
<s-pages title="AI店铺" :pink_bg="true" :goLeft="false" @onClickLeft="onClickLeft">
<view class="p-x-32 h100 flex-column">
<view class="search flex-center m-t-48 m-b-56">
<view class="searchLeft flex1 flex-center p-l-40 p-r-40">
@@ -88,14 +88,14 @@
</s-pages>
</template>
<script setup>
import { ref, reactive, onMounted, watch, getCurrentInstance } from 'vue';
import SpuApi from '@/sheep/api/product/spu';
import CartApi from '@/sheep/api/trade/cart.js';
import { ref, watch, getCurrentInstance } from 'vue';
// import SpuApi from '@/sheep/api/product/spu';
// import CartApi from '@/sheep/api/trade/cart.js';
import * as api from '@/sheep/api/ai/index';
import aiOrder from '@/components/ai_order/ai_order';
import card_payment from '@/components/card_payment/card_payment';
import { onShow } from '@dcloudio/uni-app';
const { proxy } = getCurrentInstance();
// const { proxy } = getCurrentInstance();
const searchText = ref('');
const search = (text = '') => {
pageCommodity.value.downCallback();
+8 -3
View File
@@ -161,7 +161,7 @@
<radio color="#FB4D32" class="radio" value="1" :checked="radioValue" />
<view class="flex-center size24">
我已阅读并同意
<text class="c8" @click="go()">《臻选优购服务协议》</text>
<text class="c8" @click="go()">《臻选康源家服务协议》</text>
</view>
</label>
</radio-group>
@@ -333,7 +333,12 @@ onShow(async () => {
await loadPageData();
});
const onClickLeft = () => {
uni.switchTab({ url: '/pages/index/index' });
uni.switchTab({
url: '/pages/index/index',
fail: () => {
uni.reLaunch({ url: '/pages/index/index' });
},
});
};
let sysInfo = uni.getSystemInfoSync();
const windowHeight = sysInfo.windowHeight;
@@ -629,4 +634,4 @@ function getProduct(status) {
font-size: 51rpx;
line-height: 66rpx;
}
</style>
</style>
+110 -5
View File
@@ -1,6 +1,6 @@
<!-- 订单详情 -->
<template>
<s-pages title="订单详情">
<s-pages title="订单详情" :pink_bg="true">
<view class="flex-center al-flex-end ju-between p-x-32 m-b-54">
<view>
<view class="size40 weight500 m-b-16">{{ statusObj[state.orderInfo.status]?.text }}</view>
@@ -31,7 +31,7 @@
</view>
</view>
</view>
<view
class="detail-goods"
:style="[{ marginTop: state.orderInfo.receiverAreaId > 0 ? '0' : '-40rpx' }]"
@@ -41,10 +41,22 @@
class="order-goods"
v-if="state?.orderInfo?.items?.length > 0"
:data="state.orderInfo"
source="aishop"
:delay-records="state.delayRecords"
type="4"
@getOrderDetail="getOrderDetail"
@openExpress="handleOpenExpress"
></card_order>
<PickUpVerify
v-if="Number(state.orderInfo.deliveryType) === 2"
ref="pickUpVerifyRef"
:orderInfo="state.orderInfo"
:systemStore="systemStore"
source="aishop"
detailStyle="ai"
/>
<!-- 价格信息 -->
<view class="order-price-box bg24">
<view class="notice-item ss-flex ss-row-between" v-for="(v, i) in priceArr" :key="i">
@@ -96,8 +108,14 @@
</view>
<view
class="flex btns bg16"
v-if="statusObj[state.orderInfo.status]?.btn1 || statusObj[state.orderInfo.status]?.btn2"
>
<view
v-if="hasExpress"
class="ai-button3 h_70 line70 size28"
:class="{ 'm-r-28': statusObj[state.orderInfo.status]?.btn1 || statusObj[state.orderInfo.status]?.btn2 }"
@click="handleOpenExpress"
>查看物流</view
>
<view
class="ai-button1 h_70 line70 size28"
:class="{
@@ -115,13 +133,22 @@
>
</view>
</view>
<ExpressListPopup
ref="expressListPopupRef"
popup-type="center"
:order-no="state.orderInfo.no || ''"
:order-data="state.orderInfo"
:delay-records="state.delayRecords"
:order-id="orderId || state.orderInfo.id || 0"
@close="closeExpressListPopup"
/>
</s-pages>
</template>
<script setup>
import sheep from '@/sheep';
import { onLoad, onShow } from '@dcloudio/uni-app';
import { reactive, ref, getCurrentInstance } from 'vue';
import { reactive, ref, getCurrentInstance, computed } from 'vue';
import { isEmpty } from 'lodash-es';
import {
fen2yuan,
@@ -130,9 +157,10 @@
handleOrderButtons,
} from '@/sheep/hooks/useGoods';
import * as OrderApi from '@/sheep/api/ai/index';
import DeliveryApi from '@/sheep/api/trade/delivery';
import StoreApi from '@/sheep/api/trade/store';
import PickUpVerify from '@/pages/order/pickUpVerify.vue';
import card_order from '@/components/orderItem/card_order.vue';
import ExpressListPopup from '@/components/orderItem/ExpressListPopup.vue';
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
const headerBg = sheep.$url.css('/static/img/shop/order/order_bg.png');
@@ -142,6 +170,7 @@
orderInfo: {},
merchantTradeNo: '', // 商户订单号
comeinType: '', // 进入订单详情的来源类型
delayRecords: [],
});
let statusObj = ref({
0: {
@@ -169,6 +198,12 @@
text: '已取消',
text1: '您的订单已取消!',
},
70: {
text: '现金待确认',
text1: '等待工作人员确认收款',
btn1: '切换支付',
btn2: '取消订单',
},
});
// ========== 门店自提(核销) ==========
@@ -182,6 +217,20 @@
const pickUpVerifyRef = ref();
let orderId = ref();
const resolvePickUpStoreId = (data = {}) => {
return Number(
data?.pickUpStoreId ||
data?.pickUpStore?.id ||
data?.pickUpStore?.storeId ||
data?.pickUpStoreVO?.id ||
data?.pickUpStoreVO?.storeId ||
data?.store?.id ||
data?.store?.storeId ||
data?.storeId ||
0,
);
};
async function getOrderDetail() {
let id = orderId.value;
// 对详情数据进行适配
@@ -190,9 +239,30 @@
if (res.code === 0) {
state.orderInfo = res.data;
handleOrderButtons(state.orderInfo);
const pickUpStoreId = resolvePickUpStoreId(res.data);
if (pickUpStoreId > 0) {
const { data } = await StoreApi.getStoreById(pickUpStoreId);
systemStore.value = data || {};
} else {
systemStore.value = {};
}
if (state.orderInfo.deliveryType === 2 && state.orderInfo.payStatus) {
pickUpVerifyRef.value && pickUpVerifyRef.value.markCode(res.data.pickUpVerifyCode);
}
if (orderId.value) {
try {
const delayRes = await OrderApi.getAiOrderDelayRecords({ orderId: orderId.value });
if (delayRes.code === 0 && Array.isArray(delayRes.data)) {
state.delayRecords = delayRes.data;
} else {
state.delayRecords = [];
}
} catch (e) {
state.delayRecords = [];
}
} else {
state.delayRecords = [];
}
} else {
}
}
@@ -234,6 +304,13 @@
// 取消订单
cancelOrder();
}
if (Number(state.orderInfo.status) === 70 && type === 2) {
cancelOrder();
}
if (Number(state.orderInfo.status) === 70 && type === 1) {
// 现金待确认切回线上支付
goPay();
}
if (state.orderInfo.status === 20 && type === 1) {
// 确认收货confirmReceive
OrderApi.confirmReceive({
@@ -260,6 +337,34 @@
}
});
};
const expressListPopupRef = ref();
const closeExpressListPopup = () => {};
const isPickUpOrder = () => Number(state.orderInfo?.deliveryType ?? 0) === 2;
const hasExpress = computed(() => {
const s = Number(state.orderInfo?.status ?? -1);
if ([15, 20, 30].includes(s)) return true;
if (Number(state.orderInfo?.logisticsId ?? 0) > 0) return true;
if (state.orderInfo?.logisticsNo && String(state.orderInfo.logisticsNo).trim()) return true;
if (state.orderInfo?.deliveryTime) return true;
return false;
});
const handleOpenExpress = () => {
const id = orderId.value || state.orderInfo?.id || 0;
if (!id) {
uni.showToast({
title: '订单信息异常',
icon: 'none',
});
return;
}
// AI 店铺订单详情页:店铺订单(无论type多少)一律弹窗查看物流;自提兜底走原生
if (!isPickUpOrder()) {
expressListPopupRef.value?.open?.();
return;
}
sheep.$router.go('/pages/order/express/log', { id });
};
</script>
<style lang="scss" scoped>
+143 -51
View File
@@ -1,7 +1,7 @@
<template>
<s-pages title="确认订单">
<s-pages title="确认订单" :pink_bg="true">
<view class="p-b-132">
<AddressSelection v-model="addressState" theme="2" @getSettlementInfo="getSettlementInfo" />
<AddressSelection v-model="addressState" theme="2" />
<view class="p-x-32 m-t-24">
<view class="bg24 p-x-20 p-t-20 radius16">
<view v-if="settlementInfo.items && settlementInfo.items.length">
@@ -11,12 +11,34 @@
</view>
<view class="flex-row ju-between m-b-36">
<view class="c25 size28">商品金额</view>
<view>¥{{ $fen2yuan(settlementInfo?.price?.payPrice || 0) }}</view>
<view>¥{{ $fen2yuan(settlementInfo?.price?.totalPrice || 0) }}</view>
</view>
<view class="flex-row ju-between m-b-36">
<view class="flex-row ju-between m-b-36" v-if="addressState.deliveryType === DeliveryTypeEnum.EXPRESS.type">
<view class="c25 size28">运费</view>
<view>¥{{ $fen2yuan(settlementInfo?.price?.deliveryPrice || 0) }}</view>
</view>
<view class="flex-row ju-between m-b-36" v-if="addressState.deliveryType === DeliveryTypeEnum.PICK_UP.type">
<view class="c25 size28">联系人</view>
<uni-easyinput
class="order-input"
maxlength="20"
placeholder="请填写您的联系姓名"
v-model="addressState.receiverName"
:inputBorder="false"
:clearable="false"
/>
</view>
<view class="flex-row ju-between m-b-36" v-if="addressState.deliveryType === DeliveryTypeEnum.PICK_UP.type">
<view class="c25 size28">联系电话</view>
<uni-easyinput
class="order-input"
maxlength="20"
placeholder="请填写您的联系电话"
v-model="addressState.receiverMobile"
:inputBorder="false"
:clearable="false"
/>
</view>
<view class="flex-center ju-flex-end borderTop">
<span class="size26 line96">合计: </span>
<span class="c13 size28 m-l-12 line96 weight900"
@@ -32,54 +54,69 @@
</s-pages>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, onUnmounted, getCurrentInstance, watch, nextTick } from 'vue';
import { ref, getCurrentInstance, watch } from 'vue';
import AddressSelection from '@/pages/order/addressSelection.vue';
import { onLoad } from '@dcloudio/uni-app';
import aiOrder from '@/components/ai_order/ai_order';
import api from '@/sheep/api/member/address';
let { proxy } = getCurrentInstance();
import * as SpuApi from '@/sheep/api/ai/index';
import { DeliveryTypeEnum } from '@/sheep/helper/const';
const addressState = ref({
addressInfo: {}, // 选择的收货地址
deliveryType: 1, // 收货方式:1-快递配送,2-门店自提
isPickUp: false, // 门店自提是否开启
deliveryType: DeliveryTypeEnum.EXPRESS.type, // 收货方式:1-快递配送,2-门店自提
isPickUp: true, // 门店自提是否开启
pickUpInfo: {}, // 选择的自提门店信息
receiverName: '', // 收件人名称
receiverMobile: '', // 收件人手机
});
const cartList = ref([]);
const getCartList = () => {
SpuApi.getShopCartList({}).then((res) => {
let list = res.data || [];
if (list.length) {
list.forEach((e) => {
e.skuArr = JSON.parse(e.specification);
});
}
cartList.value = list;
});
};
// 获取订单结算信息
const settlementInfo = ref({});
let addressId = ref('');
const getSettlementInfo = (id = '') => {
addressId.value = id;
SpuApi.getSettlementInfo({
id: id,
}).then((res) => {
const settlementInfo = ref<any>({});
const lastSettlementQuery = ref('');
const getSettlementRequestId = () => String(addressState.value.addressInfo?.id || '');
const getSettlementInfo = () => {
const query = {
id: getSettlementRequestId(),
deliveryType: addressState.value.deliveryType,
pickUpStoreId:
addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type
? String(addressState.value.pickUpInfo?.id || '')
: undefined,
receiverName:
addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type
? addressState.value.receiverName
: undefined,
receiverPhone:
addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type
? addressState.value.receiverMobile
: undefined,
};
const queryKey = JSON.stringify(query);
if (queryKey === lastSettlementQuery.value) {
return;
}
lastSettlementQuery.value = queryKey;
SpuApi.getSettlementInfo(query).then((res: any) => {
settlementInfo.value = res.data || {};
if (proxy.$fen2yuan(settlementInfo?.price?.payPrice || 0) >= 5000) {
proxy.utils.toast('订单金额不能超过5000元');
if (
!addressState.value.addressInfo?.id &&
res.data?.address &&
addressState.value.deliveryType === DeliveryTypeEnum.EXPRESS.type
) {
addressState.value.addressInfo = res.data.address;
}
// if (proxy.$fen2yuan(settlementInfo?.price?.payPrice || 0) >= 5000) {
// proxy.utils.toast('订单金额不能超过5000元');
// }
if (settlementInfo.value?.items?.length) {
settlementInfo.value.items.forEach((e) => {
settlementInfo.value.items.forEach((e: any) => {
e.skuArr = e.items;
e.skuArr.forEach((item) => {
e.skuArr.forEach((item: any) => {
item.propertyText = '';
item.properties.forEach((e1) => {
item.properties.forEach((e1: any) => {
item.propertyText += e1.valueName + ' ';
});
});
@@ -87,36 +124,71 @@
}
});
};
const sub = async () => {
if (proxy.$fen2yuan(settlementInfo?.price?.payPrice || 0) >= 5000) {
proxy.utils.toast('订单金额不能超过5000元, 请重新选择商品');
return;
// if (proxy.$fen2yuan(settlementInfo?.price?.payPrice || 0) >= 5000) {
// proxy.utils.toast('订单金额不能超过5000元, 请重新选择商品');
// return;
// }
if (addressState.value.deliveryType === DeliveryTypeEnum.EXPRESS.type && !addressState.value.addressInfo?.id) {
return proxy.utils.toast('请选择收货地址');
}
if (!addressId.value) return proxy.utils.toast('请选择地址');
let res: any = await SpuApi.createOrder({ id: addressId.value });
if (addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type) {
if (!addressState.value.pickUpInfo?.id) {
return proxy.utils.toast('请选择自提门店');
}
if (addressState.value.receiverName === '' || addressState.value.receiverMobile === '') {
return proxy.utils.toast('请填写联系人或联系人电话');
}
if (!/^[\u4e00-\u9fa5\w]{2,16}$/.test(addressState.value.receiverName)) {
return proxy.utils.toast('请填写您的真实姓名');
}
if (!/^1(3|4|5|7|8|9|6)\d{9}$/.test(addressState.value.receiverMobile)) {
return proxy.utils.toast('请填写正确的手机号');
}
}
let res: any = await SpuApi.createOrder({
id: getSettlementRequestId(),
deliveryType: addressState.value.deliveryType,
pickUpStoreId:
addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type
? addressState.value.pickUpInfo?.id
: undefined,
receiverName:
addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type
? addressState.value.receiverName
: undefined,
receiverPhone:
addressState.value.deliveryType === DeliveryTypeEnum.PICK_UP.type
? addressState.value.receiverMobile
: undefined,
});
if (res.code === 0) {
proxy.utils.toast('下单成功');
// proxy.utils.toast('下单成功');
setTimeout(() => {
// proxy.utils.go('/pages/AI/cashierDesk', {
// id: res.data.id,
// payOrderId: res.data.payOrderId,
// });
uni.redirectTo({
url: '/pages/AI/cashierDesk?id=' + res.data.id + '&payOrderId=' + res.data.payOrderId,
url:
'/pages/AI/cashierDesk?id=' +
res.data.id +
'&payOrderId=' +
res.data.payOrderId +
'&from=aiStore',
});
}, 1000);
} else {
}
};
const getAddress = () => {
api.getAddressList().then((res) => {
api.getAddressList().then((res: any) => {
if (res.code === 0 && res.data?.length) {
// addressState.value.addressInfo = res.data[0];
// getSettlementInfo(res.data[0].id);
let index = res.data.findIndex((e) => e.defaultStatus);
let index = res.data.findIndex((e: any) => e.defaultStatus);
if (index !== -1) {
addressState.value.addressInfo = res.data[index];
getSettlementInfo(res.data[index].id);
getSettlementInfo();
} else {
getSettlementInfo();
}
@@ -125,22 +197,42 @@
}
});
};
watch(
() => [
addressState.value.deliveryType,
addressState.value.addressInfo?.id,
addressState.value.pickUpInfo?.id,
],
() => {
getSettlementInfo();
},
);
onLoad(() => {
// getCartList();
getAddress();
});
</script>
<style lang="scss" scoped>
.pages {
}
.bottom {
}
.borderTop {
border-top: 1px solid #d4d4d4;
}
:deep(.order-input) {
width: 320rpx;
}
:deep(.order-input .uni-easyinput__content) {
background: transparent !important;
}
:deep(.order-input .uni-easyinput__content-input) {
text-align: right !important;
font-size: 26rpx;
height: 56rpx;
padding-right: 0 !important;
}
.btn {
width: 100%;
position: fixed;
+97 -25
View File
@@ -1,5 +1,18 @@
<template>
<s-pages tabbar="/pages/cart/cart" title="购物车" :showLeftButton="false" color="#ffffff">
<s-pages
tabbar="/pages/cart/cart"
title="购物车"
:showLeftButton="false"
color="#EEF1FE"
>
<template #navRight>
<view v-if="state.list.length" class="cart-nav-right">
<view v-if="state.editMode" class="cart-nav-right__btn" @tap="onChangeEditMode(false)">
取消
</view>
<view v-else class="cart-nav-right__btn f500" @tap="onChangeEditMode(true)">管理</view>
</view>
</template>
<s-empty
v-if="state.list.length === 0"
icon="/static/cart-empty.png"
@@ -8,13 +21,6 @@
<!-- 头部 -->
<view v-if="state.list.length" class="cart-box ss-flex ss-flex-col ss-row-between">
<view class="cart-header ss-flex ss-col-center ss-row-between ss-p-x-30">
<view></view>
<view class="header-right">
<view v-if="state.editMode" class="" @tap="onChangeEditMode(false)"> 取消 </view>
<view v-else class="f500" @tap="onChangeEditMode(true)"> 管理 </view>
</view>
</view>
<!-- 内容 -->
<view class="cart-content ss-flex-1 ss-p-x-30 ss-m-b-40 m-b-100">
<view
@@ -73,8 +79,8 @@
:min="0"
:step="1"
@change="onNumberChange($event, item)"
background="var(--color18)"
color="var(--color34)"
background="#ffffff"
color="#333333"
/>
</template>
</s-goods-item>
@@ -82,7 +88,14 @@
</view>
</view>
<!-- 底部 -->
<su-fixed v-if="state.list.length > 0" :isInset="false" :val="valNum" bottom placeholder>
<su-fixed
v-if="state.list.length > 0"
:isInset="false"
:val="valNum"
:zIndex="70"
bottom
placeholder
>
<view class="cart-footer ss-flex ss-col-center ss-row-between ss-p-x-30 border-bottom">
<view class="ss-flex ss-col-center flex1">
<label class="check-box ss-flex ss-col-center ss-p-r-30 flex1" @tap="onSelectAll">
@@ -117,7 +130,11 @@
>
删除
</button>
<button v-else class="ss-reset-button pay-btn ui-Shadow-Main" @tap="onConfirm">
<button
v-else
class="ss-reset-button pay-btn ui-Shadow-Main checkout-btn"
@tap="onConfirm"
>
去结算
{{ state.selectedIds?.length ? `(${state.selectedIds.length})` : '' }}
</button>
@@ -187,10 +204,10 @@
sheep.$helper.toast('请先选择商品');
return;
}
if (fen2yuan(state.totalPriceSelected) >= 5000) {
sheep.$helper.toast('订单金额不能超过5000元, 请重新选择商品');
return;
}
// if (fen2yuan(state.totalPriceSelected) >= 5000) {
// sheep.$helper.toast('订单金额不能超过5000元, 请重新选择商品');
// return;
// }
await validateDeliveryType(state.selectedList.map((item) => item.spu).map((spu) => spu.id));
sheep.$router.go('/pages/order/confirm', {
data: JSON.stringify({
@@ -284,14 +301,7 @@
url: '/pages/goods/info?id=' + id,
});
};
let valNum = ref(0);
// #ifdef APP-PLUS
valNum.value = 0;
// #endif
// #ifndef APP-PLUS
valNum.value = 50;
// #endif
const valNum = ref(uni.upx2px(100));
</script>
<style lang="scss" scoped>
@@ -299,6 +309,19 @@
height: 72rpx;
}
.cart-nav-right {
display: flex;
align-items: center;
justify-content: flex-end;
height: 100%;
}
.cart-nav-right__btn {
font-size: 28rpx;
line-height: 1;
padding: 10rpx 8rpx;
}
.cart-box {
width: 100%;
box-sizing: border-box;
@@ -345,7 +368,56 @@
}
}
.ss-reset-button {
background: linear-gradient(270deg, #f7772e 0%, #ee0a24 99%);
color: #ffffff;
}
.ss-reset-button,
.ss-reset-button.checkout-btn {
background: linear-gradient(
to bottom right,
var(--accent-grad-start) 0%,
var(--accent-grad-end) 100%
);
}
:deep(.uni-numbox) {
height: 48rpx;
border-radius: 999rpx;
border: 2rpx solid rgba(0, 0, 0, 0.12);
background: #ffffff;
padding: 0;
box-sizing: border-box;
}
:deep(.uni-numbox__value) {
height: 44rpx;
line-height: 44rpx;
margin: 0;
width: 60rpx;
background: transparent !important;
font-size: 26rpx;
color: #333333 !important;
}
:deep(.uni-numbox .move-round),
:deep(.uni-numbox .add-round) {
width: 44rpx;
height: 44rpx;
line-height: 44rpx;
background: transparent !important;
font-size: 30rpx;
color: #333333 !important;
border-radius: 50%;
box-sizing: border-box;
}
:deep(.uni-numbox .move-round) {
border-right: 2rpx solid rgba(0, 0, 0, 0.12);
border-radius: 999rpx 0 0 999rpx;
}
:deep(.uni-numbox .add-round) {
border-left: 2rpx solid rgba(0, 0, 0, 0.12);
border-radius: 0 999rpx 999rpx 0;
}
</style>
@@ -1,7 +1,7 @@
<template>
<view class="detail-content-card ss-p-b-20">
<view class="card-content">
<mp-html :content="content"></mp-html>
<mp-html :content="content" :tag-style="tagStyle"></mp-html>
</view>
</view>
</template>
@@ -13,6 +13,10 @@
default: '',
},
});
const tagStyle = {
img: 'display:block;width:100%;height:auto;',
};
</script>
<style lang="scss" scoped>
@@ -129,6 +129,9 @@
const onCart = () => {
uni.switchTab({
url: '/pages/cart/cart',
fail: () => {
uni.reLaunch({ url: '/pages/cart/cart' });
},
});
};
</script>
+1 -1
View File
@@ -1,5 +1,5 @@
<template>
<s-pages class="set-wrap" title="搜索" color="#ffffff">
<s-pages class="set-wrap" title="搜索" color="#ffffff" :pink_bg="true">
<card_search :modelValue="searchText" class="goods_search" @search="search"></card_search>
<pages_commodity
+19 -2
View File
@@ -1,5 +1,5 @@
<template>
<s-pages title="我的收益">
<s-pages title="我的收益" :blue_bg="true" navPreset="float">
<view class="pages">
<!-- 1 -->
@@ -9,9 +9,10 @@
<view class="title">今日收益(元)</view>
<view class="num">{{ $fen2yuan(trendObj?.earnings || 0) }}</view>
<view class="line" />
<view class="flex align-center">
<view class="release-entry flex align-center" @click="goNoRelease">
<view class="title">未行权金额(元)</view>
<view class="num2">{{ $fen2yuan(norelease || 0) }}</view>
<text class="arrow">></text>
</view>
</view>
</view>
@@ -424,6 +425,12 @@
currentMonth2.value = year + '-' + month;
}
function goNoRelease() {
uni.navigateTo({
url: '/pages/home/noReleaseAmount',
});
}
onMounted(() => {
select_value.value = range.value[0].text
select_cur.value = range.value[0].value
@@ -478,6 +485,16 @@
margin-left: 40rpx;
}
.release-entry {
display: inline-flex;
}
.arrow {
font-size: 24rpx;
margin-left: 12rpx;
opacity: 0.8;
}
.line {
width: 418rpx;
height: 4rpx;
+561
View File
@@ -0,0 +1,561 @@
<template>
<s-pages title="银行卡" :pink_bg="true">
<view class="bg_img" style="min-height: 100vh">
<view class="p-32">
<view v-if="bankList.length" class="bank-list">
<view
v-for="(v, i) in bankList"
:key="i"
class="bank-card"
:style="{ backgroundColor: getBankCardColor(v?.bankName) }"
>
<view class="bank-card__menu" @tap.stop="openBankMenu(v)">
<uni-icons type="more-filled" size="18" color="rgba(255, 255, 255, 0.92)" />
</view>
<view class="bank-card__title">{{ v.bankName || "-" }}</view>
<view class="bank-card__row bank-card__row--meta">
<view class="bank-card__name">{{ v.trueName || "姓名" }}</view>
</view>
<view class="bank-card__row bank-card__row--no">
<view class="bank-card__mask-wrap">
<view class="bank-card__mask" :class="{ 'bank-card__mask--visible': isCardVisible(v) }">
{{ getCardDisplayText(v) }}
</view>
<view class="bank-card__eye" @tap.stop="toggleCardVisible(v)">
<uni-icons
:type="isCardVisible(v) ? 'eye-slash' : 'eye'"
size="18"
color="rgba(255, 255, 255, 0.9)"
/>
</view>
</view>
</view>
</view>
</view>
<view class="add-card" @click="onAddBankCard">
<view class="add-card__inner">
<view class="add-card__plus">+</view>
<view class="add-card__text">添加银行卡</view>
</view>
</view>
<s-empty
v-if="!bankList.length && !loading"
text="暂无绑定银行卡"
icon="/static/data-empty.png"
/>
</view>
<uni-popup ref="popupRef" type="center" border-radius="16rpx" background-color="#fff">
<view class="bank-popup">
<view class="bank-popup__title">{{ popupMode === "edit" ? "修改银行卡" : "添加银行卡" }}</view>
<view class="bank-popup__form">
<view class="bank-popup__row">
<view class="bank-popup__label">姓名</view>
<view class="bank-popup__input">
<uni-easyinput
v-model="form.trueName"
placeholder="请输入姓名"
:inputBorder="false"
:clearable="false"
/>
</view>
</view>
<view class="bank-popup__row">
<view class="bank-popup__label">银行卡号</view>
<view class="bank-popup__input">
<uni-easyinput
v-model="form.bankCardId"
type="number"
placeholder="请输入银行卡号"
:inputBorder="false"
:clearable="false"
/>
</view>
</view>
<view class="bank-popup__row">
<view class="bank-popup__label">银行</view>
<view class="bank-popup__input">
<uni-easyinput
v-model="form.bankName"
placeholder="请输入开户行"
:inputBorder="false"
:clearable="false"
/>
</view>
</view>
<view class="bank-popup__row">
<view class="bank-popup__label">支行</view>
<view class="bank-popup__input">
<uni-easyinput
v-model="form.bankAddress"
placeholder="请输入支行"
:inputBorder="false"
:clearable="false"
/>
</view>
</view>
</view>
<view class="bank-popup__actions">
<view class="bank-popup__btn bank-popup__btn--cancel" @click="closePopup">
取消
</view>
<view
class="bank-popup__btn bank-popup__btn--confirm"
:class="{ disabled: submitting }"
@click="submitPopup"
>
确认
</view>
</view>
</view>
</uni-popup>
</view>
</s-pages>
</template>
<script setup>
import { ref, reactive } from "vue";
import { onShow } from "@dcloudio/uni-app";
import sheep from "@/sheep";
import * as payApi from "@/sheep/api/home/pay";
let loading = ref(true);
let bankList = ref([]);
const getCardLast4 = (cardNumber) => {
const str = String(cardNumber || "");
return str ? str.slice(-4) : "----";
};
const getBankCardNo = (bank) => {
return bank?.bankCardId ?? bank?.cardNumber ?? "";
};
const formatBankCardNo = (cardNumber) => {
const digits = String(cardNumber || "").replace(/\s+/g, "");
if (!digits) return "";
return digits.replace(/(.{4})/g, "$1 ").trim();
};
const isValidBankCardNo = (cardNumber) => {
const digits = String(cardNumber || "").replace(/\s+/g, "");
if (!/^\d+$/.test(digits)) return false;
if (digits.length < 12 || digits.length > 19) return false;
let sum = 0;
let shouldDouble = false;
for (let i = digits.length - 1; i >= 0; i -= 1) {
let digit = Number(digits[i]);
if (shouldDouble) {
digit *= 2;
if (digit > 9) digit -= 9;
}
sum += digit;
shouldDouble = !shouldDouble;
}
return sum % 10 === 0;
};
const visibleBankId = ref(null);
const getBankIdentity = (bank) => {
const id = bank?.id;
if (id !== undefined && id !== null && String(id)) return String(id);
const cardNo = getBankCardNo(bank);
return String(cardNo || "");
};
const isCardVisible = (bank) => {
const key = getBankIdentity(bank);
return !!key && visibleBankId.value === key;
};
const toggleCardVisible = (bank) => {
const key = getBankIdentity(bank);
if (!key) return;
visibleBankId.value = visibleBankId.value === key ? null : key;
};
const getCardDisplayText = (bank) => {
const cardNo = getBankCardNo(bank);
if (!cardNo) return "**** **** **** ----";
return isCardVisible(bank)
? formatBankCardNo(cardNo)
: `**** **** **** ${getCardLast4(cardNo)}`;
};
const getBankCardColor = (bankName) => {
const name = String(bankName || "");
const fixed = [
{ keyword: "中国银行", color: "#c65253" },
{ keyword: "农业银行", color: "#008c77" },
{ keyword: "工商银行", color: "#83aac8" },
];
for (const item of fixed) {
if (name.includes(item.keyword)) return item.color;
}
const palette = [
"#c65253",
"#008c77",
"#83aac8",
"#6b5b95",
"#2f4858",
"#b56576",
"#3a86ff",
"#2a9d8f",
];
let hash = 0;
for (let i = 0; i < name.length; i += 1) {
hash = (hash * 31 + name.charCodeAt(i)) >>> 0;
}
return palette[hash % palette.length];
};
const getBankList = async () => {
loading.value = true;
const res = await payApi.getBankList({}).catch(() => ({ code: -1 }));
loading.value = false;
if (res.code === 0) {
bankList.value = Array.isArray(res.data) ? res.data : [];
} else {
bankList.value = [];
}
};
let popupRef = ref(null);
let submitting = ref(false);
let unbinding = ref(false);
const popupMode = ref("add");
const form = reactive({
id: undefined,
userId: undefined,
trueName: "",
bankCardId: "",
bankName: "",
bankAddress: "",
});
const resetForm = () => {
form.id = undefined;
form.userId = undefined;
form.trueName = "";
form.bankCardId = "";
form.bankName = "";
form.bankAddress = "";
};
const openPopup = (mode, bank = null) => {
popupMode.value = mode;
if (mode === "edit" && bank) {
form.id = bank?.id;
form.userId = bank?.userId;
form.trueName = bank?.trueName || "";
form.bankCardId = getBankCardNo(bank) || "";
form.bankName = bank?.bankName || "";
form.bankAddress = bank?.bankAddress || "";
} else {
resetForm();
}
popupRef.value?.open?.("center");
};
const closePopup = () => {
popupRef.value?.close?.();
};
const showActionSheetAsync = (itemList = []) =>
new Promise((resolve) => {
uni.showActionSheet({
itemList,
success: (res) => resolve(res),
fail: () => resolve(null),
});
});
const showModalAsync = ({ title = "提示", content = "" } = {}) =>
new Promise((resolve) => {
uni.showModal({
title,
content,
success: (res) => resolve(res),
fail: () => resolve(null),
});
});
const openBankMenu = async (bank) => {
const sheet = await showActionSheetAsync(["修改卡号", "解除绑定"]);
if (!sheet) return;
if (sheet.tapIndex === 0) {
openPopup("edit", bank);
return;
}
if (sheet.tapIndex !== 1) return;
const id = bank?.id;
if (!id) return sheep.$helper.toast("银行卡信息异常,请刷新重试");
const modalRes = await showModalAsync({
title: "确认解绑",
content: "确定解除绑定该银行卡吗?",
});
if (!modalRes?.confirm) return;
if (unbinding.value) return;
unbinding.value = true;
const res = await payApi.unbindBank({ id }).catch(() => ({ code: -1 }));
unbinding.value = false;
if (res.code === 0) {
if (visibleBankId.value === String(id)) {
visibleBankId.value = null;
}
sheep.$helper.toast("解绑成功");
getBankList();
} else {
sheep.$helper.toast(res.msg || "解绑失败");
}
};
const submitPopup = async () => {
if (submitting.value) return;
const trueName = String(form.trueName || "").trim();
const bankCardId = String(form.bankCardId || "").replace(/\s+/g, "");
const bankName = String(form.bankName || "").trim();
const bankAddress = String(form.bankAddress || "").trim();
if (!trueName) return sheep.$helper.toast("请输入姓名");
if (!bankCardId) return sheep.$helper.toast("请输入银行卡号");
if (!isValidBankCardNo(bankCardId)) return sheep.$helper.toast("请输入正确的银行卡号");
if (!bankName) return sheep.$helper.toast("请输入开户行");
if (!bankAddress) return sheep.$helper.toast("请输入支行");
if (popupMode.value === "edit" && !form.id) return sheep.$helper.toast("银行卡信息异常,请刷新重试");
submitting.value = true;
const res =
popupMode.value === "edit"
? await payApi
.updateBank({
id: form.id,
...(form.userId ? { userId: form.userId } : {}),
trueName,
bankCardId,
cardNumber: bankCardId,
bankName,
bankAddress,
})
.catch(() => ({ code: -1 }))
: await payApi
.addBank({
trueName,
bankCardId,
cardNumber: bankCardId,
bankName,
bankAddress,
})
.catch(() => ({ code: -1 }));
submitting.value = false;
if (res.code === 0) {
closePopup();
sheep.$helper.toast(popupMode.value === "edit" ? "修改成功" : "添加成功");
getBankList();
} else {
sheep.$helper.toast(res.msg || (popupMode.value === "edit" ? "修改失败" : "添加失败"));
}
};
const onAddBankCard = () => {
openPopup("add");
};
onShow(() => {
getBankList();
});
</script>
<style lang="scss" scoped>
.bank-list {
margin-bottom: 24rpx;
}
.bank-card {
border-radius: 18rpx;
padding: 34rpx 34rpx 30rpx;
margin-bottom: 26rpx;
box-shadow: 0 10rpx 26rpx rgba(0, 0, 0, 0.12);
color: #fff;
position: relative;
}
.bank-card__menu {
position: absolute;
top: 14rpx;
right: 14rpx;
width: 60rpx;
height: 60rpx;
display: flex;
align-items: center;
justify-content: center;
}
.bank-card__title {
font-size: 32rpx;
font-weight: 600;
line-height: 1.2;
}
.bank-card__row {
display: flex;
align-items: center;
justify-content: space-between;
}
.bank-card__row--meta {
margin-top: 30rpx;
font-size: 28rpx;
opacity: 0.95;
}
.bank-card__name {
font-size: 28rpx;
}
.bank-card__row--no {
margin-top: 24rpx;
align-items: flex-end;
}
.bank-card__mask-wrap {
position: relative;
width: 100%;
padding-right: 70rpx;
}
.bank-card__mask {
font-size: 32rpx;
letter-spacing: 1rpx;
opacity: 0.95;
white-space: pre;
}
.bank-card__mask--visible {
white-space: pre-wrap;
word-break: break-all;
}
.bank-card__eye {
position: absolute;
top: 50%;
right: 0;
transform: translateY(-50%);
width: 54rpx;
height: 54rpx;
display: flex;
align-items: center;
justify-content: center;
}
.add-card {
background: rgba(255, 255, 255, 0.92);
border-radius: 18rpx;
box-shadow: 0 10rpx 26rpx rgba(0, 0, 0, 0.08);
height: 120rpx;
display: flex;
align-items: center;
}
.add-card__inner {
display: flex;
align-items: center;
padding: 0 34rpx;
}
.add-card__plus {
font-size: 40rpx;
color: #2c2c2c;
width: 44rpx;
text-align: center;
margin-right: 14rpx;
}
.add-card__text {
font-size: 32rpx;
color: #2c2c2c;
}
.bank-popup {
width: 650rpx;
padding: 36rpx 32rpx 32rpx;
box-sizing: border-box;
}
.bank-popup__title {
font-size: 34rpx;
font-weight: 600;
color: #2c2c2c;
text-align: center;
margin-bottom: 26rpx;
}
.bank-popup__form {
border-radius: 14rpx;
overflow: hidden;
}
.bank-popup__row {
display: flex;
align-items: center;
padding: 16rpx 0;
border-bottom: 1rpx solid rgba(0, 0, 0, 0.08);
}
.bank-popup__row:last-child {
border-bottom: none;
}
.bank-popup__label {
width: 140rpx;
font-size: 28rpx;
color: #2c2c2c;
}
.bank-popup__input {
flex: 1;
}
.bank-popup__actions {
display: flex;
gap: 18rpx;
margin-top: 28rpx;
}
.bank-popup__btn {
flex: 1;
height: 84rpx;
border-radius: 12rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 30rpx;
}
.bank-popup__btn--cancel {
background: rgba(0, 0, 0, 0.06);
color: #2c2c2c;
}
.bank-popup__btn--confirm {
background: var(--color2);
color: #fff;
}
.bank-popup__btn--confirm.disabled {
opacity: 0.6;
}
</style>
+1 -1
View File
@@ -1,5 +1,5 @@
<template>
<s-pages title="计算">
<s-pages title="计算" :pink_bg="true">
<view class="p-x-32">
<view class="flex-center m-b-20">
<view class="w_150">利润:</view>
+590
View File
@@ -0,0 +1,590 @@
<template>
<s-pages :title="pageTitle" :pink_bg="true">
<view class="liquidation">
<view class="top_bar">
<view class="record_link" @click="goRecord">变现记录</view>
</view>
<view class="container">
<view class="card balance-card">
<view class="balance-label">当前可提现金额</view>
<view class="balance-value">{{ $fen2yuan(walletBalanceCents || 0) }}</view>
</view>
<view class="section-row">
<view class="section-title">转出资产</view>
</view>
<view class="card input-card">
<view class="amount-row">
<view class="amount-prefix">¥</view>
<uni-easyinput
v-model="amountInput"
type="digit"
:placeholder="amountPlaceholder"
placeholder-style="font-size: 64rpx;color:#C6C6C6;"
:inputBorder="false"
:min="0"
:clearSize="50"
@blur="onAmountBlur"
@confirm="submit"
/>
</view>
<view class="tip-text">{{ amountTipText }}</view>
</view>
<view class="card code-card">
<view class=" code-row--mobile">
<view class="code-label size28">手机号</view>
<uni-easyinput
v-model="smsMobile"
type="number"
placeholder="请输入手机号"
placeholder-style="font-size: 28rpx;color:#C6C6C6;"
:inputBorder="false"
:maxlength="11"
/>
</view>
<view
v-if="isHuaxiaType && showHuaxiaMobileTip"
:class="[
'huaxia-mobile-tip',
{ 'huaxia-mobile-tip--verified': isHuaxiaMobileVerified },
]"
>
{{ isHuaxiaMobileVerified ? '账户核验完成' : '请正确输入华夏手机号' }}
</view>
</view>
<view v-if="requireSmsCode" class="card code-card">
<view class="code-row">
<uni-easyinput
v-model="smsCode"
type="number"
placeholder="请输入验证码"
placeholder-style="font-size: 28rpx;color:#C6C6C6;"
:inputBorder="false"
:maxlength="6"
/>
<view class="code-btn" :class="{ disabled: smsCountdown > 0 }" @click="sendSmsCode">
{{ smsCountdown > 0 ? `${smsCountdown}s` : '获取验证码' }}
</view>
</view>
</view>
<view class="card tip-card">
<view class="tip-header">
<view class="tip-title">兑换提示</view>
<uni-icons type="info" color="#C6C6C6" size="22" />
</view>
<view class="tip-text">请慎重考虑,一经兑换,不可撤销</view>
</view>
</view>
<view class="bottom-bar">
<view class="confirm-btn" @click="submit">确定</view>
</view>
</view>
</s-pages>
</template>
<script setup>
import { computed, ref, watch, onBeforeUnmount } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import * as payApi from '@/sheep/api/home/pay';
import * as incrementApi from '@/sheep/api/increment';
import AuthUtil from '@/sheep/api/member/auth';
import sheep from '@/sheep';
const walletBalanceCents = ref(0);
const amount = ref('');
const smsCode = ref('');
const smsMobile = ref('');
const smsCountdown = ref(0);
const smsScene = 7;
let smsTimer = null;
const submitting = ref(false);
const liquidationType = ref(1);
const channelId = ref(null);
const pageTitle = computed(
() =>
({
1: '去变现',
2: '无双变现',
3: '华夏变现',
}[Number(liquidationType.value)] || '去变现'),
);
const integerOnly = computed(() => Number(liquidationType.value) === 2);
const isHuaxiaType = computed(() => Number(liquidationType.value) === 3);
const requireSmsCode = computed(() => !isHuaxiaType.value);
const amountPlaceholder = computed(() => (integerOnly.value ? '00' : '00.00'));
const amountTipText = computed(() =>
integerOnly.value ? '请输入整数变现金额' : isHuaxiaType.value ? '请输入变现金额' : '请输入去变现数量'
);
const huaxiaMobileRegistered = ref(null);
const checkingHuaxiaMobile = ref(false);
let huaxiaCheckTimer = null;
const isHuaxiaMobileVerified = computed(
() => huaxiaMobileRegistered.value === true,
);
const showHuaxiaMobileTip = computed(() => {
if (!isHuaxiaType.value) return false;
const mobile = String(smsMobile.value || '').trim();
if (!isMobileValid(mobile)) return false;
if (checkingHuaxiaMobile.value) return false;
return (
huaxiaMobileRegistered.value === false ||
huaxiaMobileRegistered.value === true
);
});
const isMobileValid = (val) => /^1\d{10}$/.test(String(val ?? '').trim());
const checkHuaxiaMobile = async (mobile) => {
if (!isHuaxiaType.value || !isMobileValid(mobile)) return;
checkingHuaxiaMobile.value = true;
try {
const params = { mobile };
if (channelId.value != null && channelId.value !== '') {
params.channelId = Number(channelId.value);
}
const res = await incrementApi
.checkHuaxiaMobile(params)
.catch(() => ({ code: -1, data: false }));
if (res?.code === 0) {
huaxiaMobileRegistered.value = !!res?.data;
} else {
huaxiaMobileRegistered.value = null;
}
} finally {
checkingHuaxiaMobile.value = false;
}
};
watch(
() => smsMobile.value,
(val) => {
huaxiaMobileRegistered.value = null;
if (huaxiaCheckTimer) {
clearTimeout(huaxiaCheckTimer);
huaxiaCheckTimer = null;
}
const mobile = String(val || '').trim();
if (!isHuaxiaType.value) return;
if (!isMobileValid(mobile)) return;
huaxiaCheckTimer = setTimeout(() => {
checkHuaxiaMobile(mobile);
}, 300);
},
);
const stopCountdown = () => {
if (smsTimer) {
clearInterval(smsTimer);
smsTimer = null;
}
};
const sanitizeAmountInput = (val) => {
let next = String(val ?? '').replace(integerOnly.value ? /[^\d]/g : /[^\d.]/g, '');
if (integerOnly.value) return next.replace(/^0+(\d)/, '$1');
const firstDot = next.indexOf('.');
if (firstDot !== -1) {
next = next.slice(0, firstDot + 1) + next.slice(firstDot + 1).replace(/\./g, '');
const [a, b = ''] = next.split('.');
next = `${a}.${b.slice(0, 2)}`;
}
return next;
};
const amountInput = computed({
get: () => String(amount.value ?? ''),
set: (v) => {
amount.value = sanitizeAmountInput(v);
},
});
const amountNumber = computed(() => {
const n = Number(amount.value);
return Number.isFinite(n) ? n : 0;
});
const availableYuan = computed(() => Number(walletBalanceCents.value || 0) / 100);
const refreshWallet = async () => {
const res = await payApi.getWallet().catch(() => ({ code: -1 }));
if (res?.code === 0) walletBalanceCents.value = res?.data?.withdrawAmount ?? 0;
};
const onAmountBlur = () => {
if (amountNumber.value < 0) {
sheep.$helper.toast('请输入正确金额');
amount.value = '0';
return;
}
if (integerOnly.value && String(amount.value || '').includes('.')) {
amount.value = String(Math.floor(amountNumber.value || 0));
}
if (amountNumber.value > availableYuan.value) {
sheep.$helper.toast('变现金额不能大于钱包余额');
amount.value = availableYuan.value > 0
? integerOnly.value
? String(Math.floor(availableYuan.value))
: String(availableYuan.value.toFixed(2))
: '0';
}
};
const resolveMobile = () => {
const mobile = String(smsMobile.value || '').trim();
if (!isMobileValid(mobile)) {
sheep.$helper.toast('请输入正确手机号');
return '';
}
return mobile;
};
const sendSmsCode = async () => {
if (isHuaxiaType.value) return;
if (smsCountdown.value > 0) return;
const amt = amountNumber.value;
if (!amt) {
sheep.$helper.toast(integerOnly.value ? '请输入整数变现金额' : '请输入去变现数量');
return;
}
if (integerOnly.value && !Number.isInteger(amt)) {
sheep.$helper.toast('无双变现金额只能输入整数');
return;
}
if (amt > availableYuan.value) {
sheep.$helper.toast('变现金额不能大于钱包余额');
return;
}
const mobile = resolveMobile();
if (!mobile) return;
const res = await AuthUtil.sendSmsCode({ mobile, scene: smsScene }).catch(() => ({ code: -1 }));
if (res?.code !== 0) return;
smsCountdown.value = 60;
if (smsTimer) clearInterval(smsTimer);
smsTimer = setInterval(() => {
smsCountdown.value -= 1;
if (smsCountdown.value <= 0) {
clearInterval(smsTimer);
smsTimer = null;
smsCountdown.value = 0;
}
}, 1000);
};
const submit = async () => {
if (submitting.value) return;
const amt = amountNumber.value;
if (!amt) {
sheep.$helper.toast(integerOnly.value ? '请输入整数变现金额' : (isHuaxiaType.value ? '请输入变现金额' : '请输入去变现数量'));
return;
}
if (integerOnly.value && !Number.isInteger(amt)) {
sheep.$helper.toast('无双变现金额只能输入整数');
return;
}
if (amt > availableYuan.value) {
sheep.$helper.toast('变现金额不能大于钱包余额');
amount.value = availableYuan.value > 0
? integerOnly.value
? String(Math.floor(availableYuan.value))
: String(availableYuan.value.toFixed(2))
: '0';
return;
}
const mobile = resolveMobile();
if (!mobile) return;
if (requireSmsCode.value) {
if (!String(smsCode.value || '').trim()) {
sheep.$helper.toast('请输入验证码');
return;
}
}
const money = Math.round(amt * 100);
const payload = { money, mobile, type: liquidationType.value };
if (requireSmsCode.value) {
payload.scene = smsScene;
payload.code = String(smsCode.value || '').trim();
}
if (channelId.value != null && channelId.value !== '') {
payload.channelId = Number(channelId.value);
}
submitting.value = true;
try {
const res = await incrementApi.walletLiquidation(payload).catch(() => ({ code: -1 }));
if (res?.code === 0) {
sheep.$helper.toast('变现成功,请等待审核');
amount.value = '';
smsCode.value = '';
refreshWallet();
return;
}
if (res?.code === 1006001000) {
uni.showModal({
title: '提示',
content: '您还未实名认证,是否前往实名认证?',
cancelText: '取消',
confirmText: '去认证',
success: (modalRes) => {
if (!modalRes?.confirm) return;
uni.navigateTo({
url: '/pages/public/realname',
});
},
});
} else if (res?.msg) {
sheep.$helper.toast(res.msg);
}
} finally {
submitting.value = false;
}
};
const goRecord = () => {
uni.navigateTo({
url: `/pages/home/liquidationRecord?type=${liquidationType.value}`,
});
};
onLoad((options) => {
const nextType = Number(options?.type || 1);
liquidationType.value = [1, 2, 3].includes(nextType) ? nextType : 1;
if (options?.channelId != null && options?.channelId !== '') {
channelId.value = Number(options.channelId);
}
try {
uni.setNavigationBarTitle({ title: pageTitle.value });
} catch (e) {}
});
watch(
() => liquidationType.value,
() => {
try {
uni.setNavigationBarTitle({ title: pageTitle.value });
} catch (e) {}
},
);
onShow(async () => {
refreshWallet();
const userStore = sheep.$store('user');
try {
await userStore.getInfo();
} catch (e) {}
const mobile = userStore?.userInfo?.mobile;
if (mobile && !smsMobile.value) smsMobile.value = mobile;
if (isHuaxiaType.value) {
const curMobile = String(smsMobile.value || '').trim();
if (isMobileValid(curMobile)) {
await checkHuaxiaMobile(curMobile);
}
}
});
onBeforeUnmount(() => {
stopCountdown();
if (huaxiaCheckTimer) {
clearTimeout(huaxiaCheckTimer);
huaxiaCheckTimer = null;
}
});
</script>
<style lang="scss" scoped>
.liquidation {
min-height: 100vh;
}
.top_bar {
padding: 22rpx 40rpx 0;
display: flex;
justify-content: flex-end;
}
.record_link {
height: 60rpx;
padding: 0 22rpx;
border-radius: 30rpx;
border: 2rpx solid rgba(0, 0, 0, 0.08);
background: rgba(255, 255, 255, 0.75);
color: #333333;
font-size: 26rpx;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
.container {
padding: 32rpx 40rpx 200rpx;
}
.card {
background: #f4f8f2;
border-radius: 24rpx;
padding: 28rpx;
box-shadow: 0 10rpx 26rpx rgba(0, 0, 0, 0.08);
}
.balance-card {
margin-bottom: 28rpx;
}
.balance-label {
color: #333333;
font-size: 26rpx;
line-height: 36rpx;
}
.balance-value {
margin-top: 12rpx;
color: #111111;
font-size: 72rpx;
font-weight: 700;
line-height: 84rpx;
}
.section-row {
display: flex;
align-items: center;
justify-content: space-between;
padding: 4rpx 4rpx 18rpx;
}
.section-title {
font-size: 28rpx;
color: #111111;
font-weight: 600;
}
.input-card {
padding: 24rpx 28rpx;
}
.code-card {
padding: 18rpx 22rpx;
margin: 20rpx 0;
}
.code-row {
display: flex;
align-items: center;
}
.code-row--mobile {
margin-bottom: 12rpx;
}
.code-btn {
margin-left: 18rpx;
min-width: 168rpx;
height: 68rpx;
padding: 0 18rpx;
border-radius: 16rpx;
background: rgba(54, 110, 238, 0.12);
color: #366eee;
font-size: 26rpx;
font-weight: 600;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
white-space: nowrap;
}
.code-btn.disabled {
opacity: 0.6;
}
.amount-row {
display: flex;
align-items: center;
}
.amount-prefix {
color: #111111;
font-size: 40rpx;
font-weight: 600;
margin-right: 14rpx;
}
:deep(.uni-easyinput__content) {
background: transparent !important;
border: none !important;
}
:deep(.uni-easyinput__content-input) {
height: 84rpx !important;
font-size: 64rpx !important;
color: #9a9a9a !important;
font-weight: 600;
}
:deep(.uni-input-input) {
color: #111111 !important;
font-weight: 700;
}
.huaxia-mobile-tip {
margin-top: 8rpx;
padding-left: 4rpx;
color: #ff4d4f;
font-size: 24rpx;
line-height: 36rpx;
&.huaxia-mobile-tip--verified {
color: #12b46b;
}
}
.tip-card {
margin-top: 20rpx;
padding: 28rpx;
}
.tip-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 14rpx;
}
.tip-title {
font-size: 26rpx;
color: #111111;
font-weight: 600;
}
.tip-text {
color: #8b8b8b;
font-size: 22rpx;
line-height: 32rpx;
}
.bottom-bar {
position: fixed;
left: 0;
right: 0;
bottom: 0;
padding: 22rpx 32rpx calc(22rpx + env(safe-area-inset-bottom));
background: #ffffff;
}
.confirm-btn {
height: 96rpx;
border-radius: 20rpx;
background: linear-gradient(90deg, #00a87a 0%, #02b06c 100%);
color: #ffffff;
font-size: 34rpx;
font-weight: 700;
display: flex;
align-items: center;
justify-content: center;
}
</style>
+161
View File
@@ -0,0 +1,161 @@
<template>
<s-pages :title="pageTitle" :pink_bg="true">
<card_mescroll ref="cardPages" @upCallback="getList" :height="height">
<view class="bg24 radius12 m-x-42 p-y-28 p-x-40" v-if="detailList.length">
<view
class="flex-between border-bottom"
style="height: 150rpx"
v-for="(v, i) in detailList"
:key="i"
@tap.stop="onRecordTap(v)"
>
<view class="c0">
<view class="size28"> 发起变现 </view>
<view class="c_999 size24 m-t-10">
{{ sheep.$helper.timeFormat(v.createTime, 'yyyy-mm-dd hh:MM:ss') }}
</view>
</view>
<view class="c0">
<view class="size28 price">
{{ fen2yuan(v.liquidationAmount) }}
</view>
<view class="status size24 m-t-10">
{{ v.statusDescription }}
</view>
</view>
</view>
</view>
</card_mescroll>
</s-pages>
</template>
<script setup>
import sheep from '@/sheep';
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import card_mescroll from '@/components/card_pages/card_mescroll.vue';
import { fen2yuan } from '@/sheep/hooks/useGoods';
import * as api from '@/sheep/api/increment';
import { getTokenPhone } from '@/sheep/api/infra/trade';
let detailList = ref([]);
let height = ref('100%');
const tokenLoading = ref(false);
const recordType = ref(1);
const pageTitle = ref('变现记录');
let sysInfo = uni.getSystemInfoSync();
height.value = sysInfo.windowHeight - sysInfo.statusBarHeight - uni.upx2px(88) + 'px';
let cardPages = ref(null);
const resolvePhone = (record) => {
const raw =
record?.phone ??
record?.mobile ??
record?.userMobile ??
record?.memberMobile ??
record?.memberPhone ??
record?.userPhone ??
'';
return String(raw || '').trim();
};
const requestLinkByPhone = async (phone) => {
const payload = await getTokenPhone(phone).catch(() => null);
if (!payload) throw new Error('请求失败');
if (payload?.code !== 0) {
throw new Error(payload?.msg || payload?.message || '请求失败');
}
const link = payload?.data?.link;
return String(link || '').trim();
};
const normalizeLink = (input) => {
let url = String(input || '').trim();
if (!url) return '';
url = url.replace(/[`"']/g, '').trim();
return url;
};
const openExternal = (url) => {
const nextUrl = normalizeLink(url);
if (!nextUrl) return false;
if (typeof plus !== 'undefined' && plus.runtime && typeof plus.runtime.openURL === 'function') {
plus.runtime.openURL(nextUrl);
return true;
}
if (typeof window !== 'undefined' && typeof window.open === 'function') {
window.open(nextUrl, '_blank');
return true;
}
uni.setClipboardData({
data: nextUrl,
success: () => {
uni.showModal({
content: '链接已复制,请在浏览器打开',
showCancel: false,
});
},
});
return true;
};
const onRecordTap = async (record) => {
if (recordType.value === 2) return;
const phone = resolvePhone(record);
if (!phone) {
sheep.$helper.toast('该记录未包含手机号');
return;
}
if (tokenLoading.value) return;
tokenLoading.value = true;
try {
const link = await requestLinkByPhone(phone);
const nextLink = normalizeLink(link);
if (!nextLink) {
sheep.$helper.toast('接口未返回 link');
return;
}
openExternal(nextLink);
} catch (e) {
sheep.$helper.toast(e?.message || '请求失败');
} finally {
tokenLoading.value = false;
}
};
const getList = async (mescroll) => {
const res = await api.walletLiquidationRecordPage({
pageNo: mescroll.num,
pageSize: mescroll.size,
type: recordType.value,
});
if (res.code === 0) {
const data = res.data?.list || [];
if (mescroll.num == 1) detailList.value = [];
detailList.value = detailList.value.concat(data);
cardPages.value.getState(true, data.length);
} else {
cardPages.value.getState(false);
}
};
onLoad((options) => {
const nextType = Number(options?.type || 1);
recordType.value = nextType === 2 ? 2 : 1;
pageTitle.value = recordType.value === 2 ? '无双变现记录' : '变现记录';
uni.setNavigationBarTitle({
title: pageTitle.value,
});
});
</script>
<style scoped lang="scss">
.price {
text-align: right;
}
.status {
text-align: right;
color: #366eee;
}
</style>
+347
View File
@@ -0,0 +1,347 @@
<template>
<s-pages title="收支明细" :blue_bg="true" navPreset="float">
<view class="page" @click="filterOpen = false">
<view class="hero-card">
<view class="hero-left">
<view class="hero-title">未行权金额</view>
<view class="hero-amount">{{ $fen2yuan(totalAmount) }}</view>
</view>
<image class="hero-illustration" src="/static/icon/mingxi.svg" mode="aspectFit" />
</view>
<view class="detail-card">
<view class="detail-header">
<view class="detail-title">收支明细</view>
<view class="detail-filter" @click.stop="filterOpen = !filterOpen">
{{ filterOptions[filterIndex]?.text || '全部' }}
<text class="detail-arrow">▼</text>
</view>
<view class="detail-filter-menu" v-if="filterOpen" @click.stop>
<view
class="detail-filter-item"
v-for="(opt, i) in filterOptions"
:key="opt.value"
@click.stop="onFilterChange(i)"
>
{{ opt.text }}
</view>
</view>
</view>
<view v-if="isIncomeFilter" class="income-tabs" @click.stop>
<view
v-for="tab in incomeTabs"
:key="tab.value"
class="income-tab"
:class="{ active: incomeTabValue === tab.value }"
@click.stop="onIncomeTabChange(tab.value)"
>
{{ tab.text }}
</view>
</view>
<card_mescroll ref="cardPages" @upCallback="getList" :height="listHeight">
<view class="detail-item" v-for="(item, index) in detailList" :key="index">
<view class="detail-main">
<view class="detail-name">{{ getItemTitle(item) }}</view>
<view class="detail-time">{{ formatDate(item.createTime) }}</view>
</view>
<view class="detail-amount">
{{ getItemAmount(item) > 0 ? '+' : '' }}{{ $fen2yuan(getItemAmount(item)) }}
</view>
</view>
</card_mescroll>
</view>
</view>
</s-pages>
</template>
<script setup>
import { ref } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import card_mescroll from '@/components/card_pages/card_mescroll.vue';
import * as api from '@/sheep/api/home/pay';
import { formatDate, sourceTypeObj } from '@/sheep/helper/utils';
const totalAmount = ref(0);
const detailList = ref([]);
const cardPages = ref(null);
const filterOpen = ref(false);
const filterIndex = ref(0);
const incomeTabValue = ref(null);
const filterOptions = [
// {
// value: 0,
// text: '全部',
// },
{
value: 1,
text: '佣金',
},
{
value: 2,
text: '收益',
},
{
value: 3,
text: '分红',
},
];
const incomeTabs = [
{ value: 4, text: '店长收益' },
{ value: 5, text: '权益收益' },
{ value: 6, text: '代理收益' },
];
const isIncomeFilter = ref(false);
const syncIncomeFilterFlag = () => {
const opt = filterOptions[filterIndex.value];
isIncomeFilter.value = Number(opt?.value) === 2;
};
const sysInfo = uni.getSystemInfoSync();
const listHeight =
sysInfo.windowHeight -
sysInfo.statusBarHeight -
uni.upx2px(88) -
uni.upx2px(280) -
uni.upx2px(32) -
uni.upx2px(40) +
'px';
const getHeaderData = async () => {
const res = await api.agentEarningsTrendNew({}).catch(() => ({ code: -1 }));
if (res.code === 0) {
totalAmount.value = res.data?.remainingEarningAll || 0;
}
};
const getList = async (mescroll) => {
const opt = filterOptions[filterIndex.value] || filterOptions[0];
const transactionType =
isIncomeFilter.value && incomeTabValue.value ? incomeTabValue.value : opt.value;
const res = await api
.agentEarningsIncomeDetailsPage({
pageNo: mescroll.num,
pageSize: mescroll.size,
...(transactionType ? { transactionType } : {}),
})
.catch(() => ({ code: -1 }));
if (res.code === 0) {
const list = res.data?.list || [];
if (mescroll.num === 1) detailList.value = [];
detailList.value = detailList.value.concat(list);
cardPages.value?.getState(true, list.length, res.data?.total);
return;
}
cardPages.value?.getState(false);
};
const getItemTitle = (item) => {
const incomeSourceTypeLabelMap = {
4: '店长收益',
5: '权益收益',
6: '代理收益',
};
const sourceType = Number(item?.sourceType);
return (
item?.remark ||
item?.title ||
incomeSourceTypeLabelMap[sourceType] ||
sourceTypeObj[sourceType || 1] ||
'未行权金额'
);
};
const getItemAmount = (item) => {
const raw = item?.totalEarnings ?? item?.amount ?? item?.price ?? item?.remainingEarning ?? 0;
const n = Number(raw);
return Number.isFinite(n) ? n : 0;
};
const onFilterChange = (i) => {
filterIndex.value = i;
filterOpen.value = false;
incomeTabValue.value = null;
syncIncomeFilterFlag();
cardPages.value?.mescrollTrigger();
};
const onIncomeTabChange = (val) => {
const next = Number(val);
incomeTabValue.value = incomeTabValue.value === next ? null : next;
cardPages.value?.mescrollTrigger();
};
onShow(() => {
getHeaderData();
syncIncomeFilterFlag();
cardPages.value?.mescrollTrigger();
});
</script>
<style lang="scss" scoped>
.page {
padding: 32rpx 40rpx 0;
}
.hero-card {
height: 220rpx;
border-radius: 16rpx;
padding: 36rpx 32rpx;
display: flex;
align-items: center;
justify-content: space-between;
// background: url("https://sycbuck.oss-cn-hangzhou.aliyuncs.com/app/home/agency2.png")
// center / 100% 100% no-repeat;
background: linear-gradient(135deg, #ffc6e6 0%, #fb7f33 100%);
margin-bottom: 32rpx;
}
.hero-left {
color: #ffffff;
}
.hero-title {
font-size: 36rpx;
line-height: 50rpx;
font-weight: 500;
// opacity: 0.75;
}
.hero-amount {
margin-top: 18rpx;
font-size: 68rpx;
line-height: 82rpx;
font-weight: 700;
}
.hero-illustration {
width: 220rpx;
height: 136rpx;
flex-shrink: 0;
filter: brightness(0) invert(1);
}
.detail-card {
background: rgba(255, 255, 255, 0.98);
border-radius: 24rpx 24rpx 0 0;
padding: 0 24rpx;
}
.detail-title {
font-size: 32rpx;
line-height: 110rpx;
color: #111111;
font-weight: 500;
}
.detail-header {
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
height: 110rpx;
}
.detail-filter {
height: 52rpx;
line-height: 52rpx;
padding: 0 18rpx;
background: #f2f4f7;
border-radius: 16rpx;
font-size: 24rpx;
color: #111111;
display: flex;
align-items: center;
}
.detail-arrow {
margin-left: 10rpx;
font-size: 22rpx;
}
.detail-filter-menu {
position: absolute;
right: 0;
top: 110rpx;
width: 160rpx;
background: #f2f4f7;
border-radius: 16rpx;
z-index: 10;
overflow: hidden;
}
.income-tabs {
display: flex;
align-items: center;
justify-content: flex-start;
gap: 12rpx;
}
.income-tab {
width: 132rpx;
padding: 5rpx 0;
display: flex;
align-items: center;
justify-content: center;
background: #fff;
border-radius: 14rpx;
overflow: hidden;
font-size: 22rpx;
color: #111111;
border: 2rpx solid #d9d9d9;
box-sizing: border-box;
}
.income-tab.active {
color: #fb4d32;
background: #ffefe5;
border-color: transparent;
}
.detail-filter-item {
text-align: center;
line-height: 72rpx;
font-size: 26rpx;
color: #111111;
}
.detail-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 32rpx 0;
border-bottom: 2rpx solid #f1f2f5;
}
.detail-main {
flex: 1;
padding-right: 24rpx;
}
.detail-name {
font-size: 28rpx;
line-height: 40rpx;
color: #111111;
}
.detail-time {
margin-top: 10rpx;
font-size: 24rpx;
line-height: 34rpx;
color: #999999;
}
.detail-amount {
flex-shrink: 0;
font-size: 32rpx;
line-height: 46rpx;
color: #ee0a24;
font-weight: 500;
}
</style>
+2 -2
View File
@@ -1,5 +1,5 @@
<template>
<s-pages title="修改密码">
<s-pages title="修改密码" :pink_bg="true">
<view class="pages flex-column ju-between">
<card_list class="cardList bg24" :arr="listArr">
<template #footer-2>
@@ -88,7 +88,7 @@
sendCode();
};
const sendCode = async () => {
AuthUtil.sendSmsCode(formData.value.mobile, 3).then((res) => {
AuthUtil.sendSmsCode({ mobile: formData.value.mobile, scene: 3 }).then((res) => {
if (res.code === 0) {
num.value = 60;
timer.value = setInterval(() => {
+1 -1
View File
@@ -1,5 +1,5 @@
<template>
<s-pages :bgStyle="{ color: 'var(--color1)' }" :title="dataObj.title">
<s-pages :bgStyle="{ color: 'var(--color1)' }" :title="dataObj.title" :pink_bg="true">
<view class="pages p-t-28 p-x-40">
<view class="radius12 pagesTop p-y-30 p-x-28 bg24">
<view class="c0">{{ dataObj.text0 }}</view>
+102 -24
View File
@@ -1,8 +1,8 @@
<template>
<s-pages title="提现">
<s-pages title="提现" :pink_bg="true">
<view class="pages p-y-28 p-x-40 c0">
<!-- <view class="m-b-20 tab-header">
<text class="tab-item" :class="{ active: type === 'yougou' }" @click="changeType('yougou')">优购提现</text>
<text class="tab-item" :class="{ active: type === 'yougou' }" @click="changeType('yougou')">康源家提现</text>
<text class="tab-item m-l-20" :class="{ active: type === 'huamao' }"
@click="changeType('huamao')">华贸提现</text>
</view> -->
@@ -17,9 +17,26 @@
<view class="flex-center border-bottom" style="height: 100rpx" v-for="(v, i) in list" :key="i">
<view class="c0">{{ v.title }}</view>
<uni-easyinput style="text-align: right" class="flex1" v-model="dataObj[v.value]"
:type="v.type || 'text'" :placeholder="v.placeholder" :inputBorder="false"
@input="(e) => inputChange(e, v)" />
<uni-easyinput
v-if="v.value === 'userAccount'"
style="text-align: right"
class="flex1"
:value="dataObj.userAccount"
:type="v.type || 'text'"
:placeholder="v.placeholder"
:inputBorder="false"
@focus="onUserAccountFocus"
@input="onUserAccountInput"
/>
<uni-easyinput
v-else
style="text-align: right"
class="flex1"
v-model="dataObj[v.value]"
:type="v.type || 'text'"
:placeholder="v.placeholder"
:inputBorder="false"
/>
</view>
</view>
</view>
@@ -51,6 +68,10 @@
<span class="c_FF2D2D">*</span>
{{ `提现时间为${config.brokerageWithdrawTime}` }}
</view>
<!-- <view>
<span class="c_FF2D2D">*</span>
一天(24小时)内只可提现1次
</view> -->
</view>
</view>
<view class="submit-btn" @click="onSubmit">提现</view>
@@ -111,7 +132,7 @@ let list = ref([{
{
title: '账号',
value: 'userAccount',
type: 'number',
// type: 'number',
placeholder: '请输入银行账号',
},
{
@@ -131,6 +152,42 @@ let dataObj = ref({
price: 0,
});
const getBankCardNo = (bank) => {
return bank?.bankCardId ?? bank?.cardNumber ?? '';
};
const isAccountAutofilled = ref(false);
const normalizeBankCardNo = (cardNo) => String(cardNo || '').replace(/\s+/g, '').trim();
const isValidBankCardNo = (cardNo) => {
const digits = normalizeBankCardNo(cardNo);
if (!/^\d+$/.test(digits)) return false;
if (digits.length < 12 || digits.length > 19) return false;
let sum = 0;
let shouldDouble = false;
for (let i = digits.length - 1; i >= 0; i -= 1) {
let digit = Number(digits[i]);
if (shouldDouble) {
digit *= 2;
if (digit > 9) digit -= 9;
}
sum += digit;
shouldDouble = !shouldDouble;
}
return sum % 10 === 0;
};
const maskBankCardNo = (cardNo) => {
const digits = normalizeBankCardNo(cardNo);
if (!digits) return '';
const last4 = digits.slice(-4);
return `**** **** **** ${last4}`;
};
const setAutofillAccount = (cardNo) => {
const digits = normalizeBankCardNo(cardNo);
dataObj.value.userAccount = maskBankCardNo(digits);
dataObj.value.bankCardId = digits;
isAccountAutofilled.value = !!digits;
};
let point = ref(0);
const getData = () => {
UserApi.getUserInfo().then((res) => {
@@ -184,7 +241,7 @@ const submit = () => {
return;
}
if (!dataObj.value.userAccount) {
sheep.$helper.toast('请输入账号账号');
sheep.$helper.toast('请输入银行账号');
return;
}
if (!dataObj.value.bankName) {
@@ -201,10 +258,17 @@ const submit = () => {
}
let obj = JSON.parse(JSON.stringify(dataObj.value));
obj.price = obj.price * 100;
const cardNo = normalizeBankCardNo(obj.bankCardId || obj.userAccount || '');
if (!cardNo || !isValidBankCardNo(cardNo)) {
sheep.$helper.toast('请输入正确的银行卡号');
return;
}
obj.userAccount = cardNo;
obj.bankCardId = cardNo;
obj.cardNumber = cardNo;
api.createBrokerageWithdraw(obj).then((res) => {
if (res.code === 0) {
dataObj.value = {
type: 2,
transferChannelCode: 'wx_lite',
price: 0,
};
@@ -262,40 +326,52 @@ const blur = () => {
return;
}
};
const inputChange = (e, v) => {
let obj = {
bankNo: e.detail.value,
};
if (v.value == 'userAccount') {
api.getBank(obj).then((res) => {
if (res.code === 0) {
console.log(res);
dataObj.value.bankName = res.data;
}
});
}
const onUserAccountFocus = () => {
if (!isAccountAutofilled.value) return;
isAccountAutofilled.value = false;
dataObj.value.userAccount = '';
dataObj.value.bankCardId = '';
};
const onUserAccountInput = (e) => {
const raw = typeof e === 'string' ? e : e?.detail?.value;
const value = String(raw || '');
dataObj.value.userAccount = value;
dataObj.value.bankCardId = value;
isAccountAutofilled.value = false;
if (!value) return;
const requestNo = value;
api.getBank({ bankNo: value }).then((res) => {
if (String(dataObj.value.bankCardId || '') !== requestNo) return;
if (res.code !== 0) return;
if (!res.data) return;
console.log(res);
dataObj.value.bankName = res.data;
});
};
let bankList = ref([]);
let bankText = ref([]);
const getBankList = () => {
api.getBankList({}).then((res) => {
if (res.code === 0) {
bankText.value = [];
bankList.value = [];
res.data.forEach((item) => {
// 取银行卡后四位
item.text = `${item.bankName}(${item.cardNumber.slice(-4)})`;
const cardNo = String(getBankCardNo(item) || '');
item.text = `${item.bankName}(${cardNo.slice(-4)})`;
bankText.value.push(item.text);
});
bankList.value = res.data;
if (res?.data?.length) {
let obj = res.data[0];
const cardNo = getBankCardNo(obj);
dataObj.value = {
...dataObj.value,
userName: obj.trueName,
userAccount: obj.cardNumber,
bankName: obj.bankName,
bankAddress: obj.bankAddress,
};
setAutofillAccount(cardNo);
}
}
});
@@ -307,12 +383,14 @@ const select = () => {
tapIndex
}) => {
let obj = bankList.value[tapIndex];
const cardNo = getBankCardNo(obj);
dataObj.value = {
...dataObj.value,
userName: obj.trueName,
userAccount: obj.cardNumber,
bankName: obj.bankName,
bankAddress: obj.bankAddress,
};
setAutofillAccount(cardNo);
},
fail: (error) => { },
});
+1 -1
View File
@@ -1,5 +1,5 @@
<template>
<s-pages title="提现记录">
<s-pages title="提现记录" :pink_bg="true">
<card_mescroll ref="cardPages" @upCallback="getList" :height="height">
<view class="bg24 radius12 m-x-42 p-y-28 p-x-40" v-if="detailList.length">
<view
+2 -2
View File
@@ -111,7 +111,7 @@
sendCode();
};
const sendCode = async () => {
AuthUtil.sendSmsCode(formData.value.mobile, 3).then((res) => {
AuthUtil.sendSmsCode({ mobile: formData.value.mobile, scene: 3 }).then((res) => {
if (res.code === 0) {
num.value = 60;
timer.value = setInterval(() => {
@@ -125,7 +125,7 @@
});
};
const sendCode1 = async () => {
AuthUtil.sendSmsCode(formData.value.mobile1, 3).then((res) => {
AuthUtil.sendSmsCode({ mobile: formData.value.mobile1, scene: 3 }).then((res) => {
if (res.code === 0) {
num1.value = 60;
timer1.value = setInterval(() => {
+896 -124
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+588 -128
View File
@@ -1,161 +1,621 @@
<template>
<s-layout title="邀请好友">
<view class="pages c34">
<view class="con w100" id="conId">
<view class="w100 conBg radius-8 hidden">
<image
class="w100"
:src="$url + 'home/invite1.png'"
mode="widthFix"
@longpress="saveImg"
/>
</view>
<view class="con_center w100 radius-8">
<view class="flex-center ju-flex-start">
<view class="head">
<image v-if="dataInfo?.avatar" :src="dataInfo?.avatar" mode="scaleToFill" />
<image v-else :src="`${$url}home/head.png`" mode="scaleToFill" />
</view>
<view>
<view class="con_name size32 f700 c0"
>{{ dataInfo?.nickname || '昵称' }},邀请您加入优购商城</view
>
<view class="size28 c0">财富未来 全新出发</view>
</view>
</view>
<view class="flex-center f700 size48 m-t-68 m-b-28 c0">
<view>邀请码</view>
<view>|</view>
<view>{{ inviteinfo?.inviteCode }}</view>
</view>
<view class="flex-center">
<view class="img m-b-22">
<Qrcode
ref="qrcodeRef"
:size="300"
@generated="onQrGenerated"
@longpress="saveServiceQrcode"
/>
</view>
</view>
<view class="center size20 c_999">扫描二维码, 注册并登录APP</view>
<s-layout :navbar="navBar" title="邀请好友" navPreset="float">
<view
class="share_page_bg"
id="captureBox"
:style="{ marginTop: `-${navHeight}px`, '--safe-top': `${safeTop}px` }"
>
<view class="slogan">
<image class="slogan_img" src="/static/share_bg.png" mode="widthFix" />
<view class="slogan__text">
<view class="slogan__title">邀请好友</view>
<view class="slogan__title">一起瓜分金种子</view>
<view class="slogan__sub">好友注册你得奖励</view>
</view>
</view>
<view class="submit-btn m-t-68" @click="saveImg">保存到相册</view>
<view class="share_card">
<view class="center m-t-22 m-b-14 label_text">我的邀请码</view>
<view class="invite_code_bar">
<view class="code_val">{{ inviteinfo?.inviteCode }}</view>
<view class="copy_btn" @click="copy(inviteinfo?.inviteCode)">
<image class="copy-icon-img" src="/static/icon/copy_1.png" mode="aspectFit" />
</view>
</view>
<view class="con_center">
<view class="flex-center">
<view class="code flex-center code_wrap">
<view class="img">
<Qrcode
ref="qrcodeRef"
:size="320"
@generated="onQrGenerated"
@longpress="saveServiceQrcode"
/>
</view>
</view>
</view>
<view class="qr_tip">扫描二维码,注册并登录APP</view>
<!-- <view class="btns">
<view class="square-btn-outline" @click="saveImg">
<view class="icon-down"></view>
保存邀请图片至相册
</view>
<view class="square-btn" @click="openShare">
<view class="icon-link"></view>
分享给好友
</view>
</view> -->
<uni-popup ref="popup" type="share">
<uni-popup-share title="分享到" @select="doShare"></uni-popup-share>
</uni-popup>
</view>
</view>
<view class="save_btn" @click="saveImg">保存到相册</view>
</view>
</s-layout>
</template>
<script setup lang="ts">
import Qrcode from './components/Qrcode';
import sheep from '@/sheep';
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import { ref, reactive, onMounted, onUnmounted, getCurrentInstance, watch, nextTick } from 'vue';
import * as api from '@/sheep/api/home/index';
let { proxy } = getCurrentInstance();
let dataInfo = ref({});
let inviteinfo = ref({});
let qrCodeUrl = ref(); //二维码地址
let qrcodeRef = ref();
onLoad(() => {});
//获取二维码
function generateQRCode(text) {
<script setup>
import Qrcode from './components/Qrcode';
import { getCurrentInstance, nextTick, ref } from 'vue';
import * as api from '@/sheep/api/home/index';
import { onPageScroll } from '@dcloudio/uni-app';
const instance = getCurrentInstance();
const proxy = instance?.proxy;
const sysInfoForNav = uni.getSystemInfoSync();
const safeTop = ref(sysInfoForNav?.statusBarHeight || 0);
const navHeight = ref((sysInfoForNav?.statusBarHeight || 0) + 44);
const navBar = ref('inner');
onPageScroll((e) => {
if ((e?.scrollTop || 0) > 20) {
navBar.value = 'normal';
} else {
navBar.value = 'inner';
}
});
const inviteinfo = ref({});
const qrCodeUrl = ref('');
const qrcodeRef = ref(null);
const popup = ref(null);
const generateQRCode = (text) => {
nextTick(() => {
qrcodeRef.value.createQRcode(text);
qrcodeRef.value?.createQRcode(text);
});
}
const getData = () => {
sheep
.$store('user')
.getInfo()
.then((res) => {
dataInfo.value = res;
});
};
const getinviteinfo = () => {
api.inviteinfo().then((res) => {
inviteinfo.value = res.data;
generateQRCode(res.data.inviteUrl);
// generateQRCode('http://mall.suwizihe.org.cn:5010/h5/#/?code=' + inviteinfo.value.inviteCode);
inviteinfo.value = res?.data || {};
if (inviteinfo.value?.inviteUrl) generateQRCode(inviteinfo.value.inviteUrl);
});
};
getinviteinfo();
getData();
let conRef = ref();
const saveServiceQrcode = () => {
qrcodeRef.value.savePhoto();
};
const saveImg = async () => {
// uni.saveImageToPhotosAlbum({
// filePath: 'http://mall.suwizihe.org.cn:5010/h5/#/?code=' + inviteinfo.value.inviteCode,//qrcodeUrl.value
// success: () => {
// uni.showToast({
// title: '保存成功!',
// });
// },
// fail: (err) => {
// console.log(err);
// uni.showToast({ title: '保存失败', icon: 'none' });
// },
// });
qrcodeRef.value.savePhoto();
// if (qrcodeUrl.value) {
// return;
// }
// if (qrcodeRef.value?.savePhoto) {
// qrcodeRef.value.savePhoto();
// } else {
// uni.showToast({ title: '二维码未生成', icon: 'none' });
// }
const getCaptureBoxRect = () =>
new Promise((resolve, reject) => {
uni
.createSelectorQuery()
.in(proxy)
.select('#captureBox')
.boundingClientRect((rect) => {
if (!rect) {
reject(new Error('captureBox not found'));
return;
}
resolve(rect);
})
.exec();
});
const saveToAlbum = (filePath) =>
new Promise((resolve, reject) => {
uni.saveImageToPhotosAlbum({
filePath,
success: () => resolve(true),
fail: (e) => reject(e),
});
});
const toFileUrlIfNeeded = (p) => (p.startsWith('file://') ? p : `file://${p}`);
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
let isSavingPoster = false;
const showSaveSuccessToast = () => {
uni.showToast({
title: '保存成功',
icon: 'success',
duration: 500,
});
setTimeout(() => uni.hideToast(), 500);
};
const drawCurrentWebviewToFile = async (params) => {
if (typeof plus === 'undefined' || !plus.webview || !plus.nativeObj) {
throw new Error('plus is not available');
}
const webview = plus.webview.getTopWebview?.() || plus.webview.currentWebview();
const bitmap = new plus.nativeObj.Bitmap(`share_bitmap_${Date.now()}`);
await new Promise((resolve, reject) => {
webview.draw(
bitmap,
() => resolve(true),
(e) => reject(e),
{ check: true },
);
});
const fileUrl = `_doc/share_capture_${Date.now()}.jpg`;
await new Promise((resolve, reject) => {
bitmap.save(
fileUrl,
params?.clip
? { overwrite: true, format: 'jpg', quality: 90, clip: params.clip }
: { overwrite: true, format: 'jpg', quality: 90 },
() => resolve(true),
(e) => reject(e),
);
});
bitmap.clear();
const localPath = plus.io.convertLocalFileSystemURL(fileUrl);
return {
localPath,
filePath: toFileUrlIfNeeded(localPath),
};
};
const savePoster = async () => {
// #ifdef APP-PLUS
if (isSavingPoster) return;
isSavingPoster = true;
try {
uni.showLoading({ title: '生成图片...' });
await nextTick();
for (let i = 0; i < 8; i++) {
if (qrCodeUrl.value) break;
await sleep(200);
}
const rect = await getCaptureBoxRect();
const sysInfo = uni.getSystemInfoSync();
const excludeTopPx = (sysInfo?.statusBarHeight || 0) + 44;
const ratioX =
typeof plus !== 'undefined' && plus.screen && plus.screen.resolutionWidth
? plus.screen.resolutionWidth / sysInfo.windowWidth
: sysInfo.pixelRatio || 1;
const ratioY =
typeof plus !== 'undefined' && plus.screen && plus.screen.resolutionHeight
? plus.screen.resolutionHeight / sysInfo.windowHeight
: sysInfo.pixelRatio || 1;
const maxWidth = Math.max(1, Math.floor(sysInfo.windowWidth * ratioX));
const maxHeight = Math.max(1, Math.floor(sysInfo.windowHeight * ratioY));
const clip = {
top: Math.max(0, Math.floor(((rect.top || 0) + excludeTopPx) * ratioY)),
left: Math.max(0, Math.floor((rect.left || 0) * ratioX)),
width: Math.max(1, Math.floor((rect.width || 1) * ratioX)),
height: Math.max(1, Math.floor(Math.max(1, (rect.height || 1) - excludeTopPx) * ratioY)),
};
const sideExpand = Math.max(0, Math.floor(30 * ratioX));
const bottomExpand = Math.max(0, Math.floor(20 * ratioY));
clip.left = Math.max(0, clip.left - sideExpand);
clip.width = clip.width + sideExpand * 2;
clip.height = clip.height + bottomExpand;
if (clip.left >= maxWidth) clip.left = maxWidth - 1;
if (clip.top >= maxHeight) clip.top = maxHeight - 1;
if (clip.left + clip.width > maxWidth) clip.width = maxWidth - clip.left;
if (clip.top + clip.height > maxHeight) clip.height = maxHeight - clip.top;
const { localPath, filePath } = await drawCurrentWebviewToFile({ clip });
try {
await saveToAlbum(localPath);
} catch (e) {
await saveToAlbum(filePath);
}
showSaveSuccessToast();
} catch (e) {
const msg =
(typeof e === 'string' && e) ||
e?.errMsg ||
e?.message ||
(e ? JSON.stringify(e) : 'unknown error');
uni.showModal({
title: '保存失败',
content:
msg.includes('authorize') || msg.includes('Permission')
? `${msg}\n\n请到系统设置开启相册权限后重试`
: msg,
showCancel: false,
});
} finally {
isSavingPoster = false;
uni.hideLoading();
}
// #endif
// #ifndef APP-PLUS
uni.showToast({ title: '仅App支持整页保存', icon: 'none' });
// #endif
};
const saveImg = async () => {
await savePoster();
};
const saveServiceQrcode = async () => {
await savePoster();
};
const onQrGenerated = (path) => {
qrCodeUrl.value = path;
};
const copy = (text) => {
const val = text || inviteinfo.value?.inviteCode || '';
if (!val) return;
uni.setClipboardData({
data: val,
success: () => {
uni.showToast({ icon: 'none', title: '复制成功' });
},
});
};
const openShare = () => {
popup.value?.open?.();
};
const mapShareProvider = (name) => {
if (!name) return '';
const m = {
wx: 'weixin',
ali: 'alipay',
qq: 'qq',
sina: 'sinaweibo',
};
return m[name] || '';
};
const doShare = async (res) => {
const provider = mapShareProvider(res?.item?.name);
if (!provider) {
uni.showToast({ title: '当前渠道不支持', icon: 'none' });
return;
}
// #ifdef APP-PLUS
try {
uni.showLoading({ title: '生成分享图片...' });
await nextTick();
for (let i = 0; i < 8; i++) {
if (qrCodeUrl.value) break;
await sleep(200);
}
const rect = await getCaptureBoxRect();
const sysInfo = uni.getSystemInfoSync();
const excludeTopPx = (sysInfo?.statusBarHeight || 0) + 44;
const ratioX =
typeof plus !== 'undefined' && plus.screen && plus.screen.resolutionWidth
? plus.screen.resolutionWidth / sysInfo.windowWidth
: sysInfo.pixelRatio || 1;
const ratioY =
typeof plus !== 'undefined' && plus.screen && plus.screen.resolutionHeight
? plus.screen.resolutionHeight / sysInfo.windowHeight
: sysInfo.pixelRatio || 1;
const maxWidth = Math.max(1, Math.floor(sysInfo.windowWidth * ratioX));
const maxHeight = Math.max(1, Math.floor(sysInfo.windowHeight * ratioY));
const clip = {
top: Math.max(0, Math.floor(((rect.top || 0) + excludeTopPx) * ratioY)),
left: Math.max(0, Math.floor((rect.left || 0) * ratioX)),
width: Math.max(1, Math.floor((rect.width || 1) * ratioX)),
height: Math.max(1, Math.floor(Math.max(1, (rect.height || 1) - excludeTopPx) * ratioY)),
};
const sideExpand = Math.max(0, Math.floor(30 * ratioX));
const bottomExpand = Math.max(0, Math.floor(20 * ratioY));
clip.left = Math.max(0, clip.left - sideExpand);
clip.width = clip.width + sideExpand * 2;
clip.height = clip.height + bottomExpand;
if (clip.left >= maxWidth) clip.left = maxWidth - 1;
if (clip.top >= maxHeight) clip.top = maxHeight - 1;
if (clip.left + clip.width > maxWidth) clip.width = maxWidth - clip.left;
if (clip.top + clip.height > maxHeight) clip.height = maxHeight - clip.top;
uni.hideLoading();
const { localPath: shareImage } = await drawCurrentWebviewToFile({ clip });
uni.share({
provider,
type: 1,
imageUrl: shareImage,
success: () => uni.showToast({ title: '分享成功' }),
fail: () => uni.showToast({ title: '分享失败', icon: 'none' }),
});
} catch (error) {
uni.hideLoading();
uni.showToast({ title: '截图失败', icon: 'none' });
}
// #endif
};
getinviteinfo();
</script>
<style lang="scss" scoped>
.pages {
height: 100vh;
padding: 32rpx 40rpx;
.share_page_bg {
position: relative;
min-height: 100vh;
padding: 570rpx 40rpx 80rpx;
box-sizing: border-box;
// background: #0b53d8;
}
.share_page_bg::before {
content: '';
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
background-image: url('/static/home/seedBg.png');
background-repeat: no-repeat;
background-position: center top;
background-size: cover;
pointer-events: none;
z-index: -1;
}
.slogan {
position: absolute;
top: var(--safe-top);
left: 0;
right: 0;
z-index: 0;
// padding: 0 40rpx;
box-sizing: border-box;
overflow: hidden;
border-radius: 0 0 30rpx 30rpx;
}
.slogan_img {
width: 100%;
display: block;
}
.slogan__text {
position: absolute;
left: 60rpx;
top: 100rpx;
z-index: 1;
}
.slogan__title {
font-size: 45rpx;
line-height: 60rpx;
font-weight: 800;
color: #ffffff;
}
.slogan__sub {
margin-top: 18rpx;
font-size: 28rpx;
line-height: 35rpx;
color: rgba(255, 255, 255, 0.88);
}
.share_card {
position: relative;
z-index: 0;
width: 100%;
border-radius: 28rpx;
background: rgba(255, 255, 255, 0.96);
box-shadow: 0 16rpx 40rpx rgba(0, 0, 0, 0.18);
overflow: hidden;
}
.con_center {
padding: 5rpx 40rpx 24rpx;
box-sizing: border-box;
}
.con {
position: relative;
.conBg {
position: absolute;
top: 0;
}
.con_center {
// position: absolute;
// top: 0;
position: relative;
padding: 56rpx 28rpx;
box-sizing: border-box;
z-index: 10;
}
.con_name {
font-size: 40rpx;
font-weight: 700;
color: #1f2d23;
}
.head {
width: 96rpx;
height: 96rpx;
border-radius: 50%;
overflow: hidden;
margin-right: 20rpx;
image {
width: 100%;
height: 100%;
}
.sub_title {
font-size: 28rpx;
color: #5d6b61;
}
.img {
padding: 20rpx;
.label_text {
font-size: 26rpx;
font-weight: 600;
color: #1a73ff;
}
.code {
width: 360rpx;
height: 360rpx;
border-radius: 22rpx;
background: #fff;
}
.con_name {
.code_wrap {
// box-shadow: 0 10rpx 28rpx rgba(31, 63, 132, 0.14);
}
.img {
width: 320rpx;
height: 320rpx;
// border-radius: 18rpx;
overflow: hidden;
background: #fff;
}
.invite_code_bar {
width: 80%;
margin: 0 auto;
display: flex;
justify-content: center;
align-items: center;
background: #f2f3f5;
border-radius: 18rpx;
overflow: hidden;
height: 90rpx;
}
.code_val {
// flex: 1;
color: #111;
font-size: 56rpx;
font-weight: 700;
letter-spacing: 4rpx;
text-align: center;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
background: transparent;
}
.copy_btn {
width: 80rpx;
height: 112rpx;
background: transparent;
display: flex;
align-items: center;
justify-content: center;
color: #1a73ff;
}
.icon-copy {
width: 28rpx;
height: 28rpx;
border: 2rpx solid currentColor;
border-radius: 6rpx;
position: relative;
box-sizing: border-box;
}
.icon-copy::before {
content: '';
position: absolute;
left: -10rpx;
top: 10rpx;
width: 28rpx;
height: 28rpx;
border: 2rpx solid currentColor;
border-radius: 6rpx;
box-sizing: border-box;
opacity: 0.7;
}
.copy-icon-img {
width: 44rpx;
height: 44rpx;
display: block;
}
.qr_tip {
margin-top: 0rpx;
text-align: center;
font-size: 22rpx;
color: #9aa0a6;
}
.save_btn {
margin-top: 32rpx;
width: 100%;
height: 104rpx;
border-radius: 18rpx;
color: #fff;
font-size: 34rpx;
font-weight: 600;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(135deg, var(--primary-grad-start) 0%, var(--primary-grad-end) 100%);
box-shadow: 0 18rpx 40rpx var(--primary-shadow);
}
.btns {
margin-top: 32rpx;
}
.square-btn-outline {
width: 100%;
padding: 30rpx 0;
border-radius: 12rpx;
display: flex;
justify-content: center;
align-items: center;
background: transparent;
color: #2b5f3d;
border: 2rpx solid #2b5f3d;
box-sizing: border-box;
}
.square-btn {
margin-top: 20rpx;
width: 100%;
padding: 30rpx 0;
border-radius: 12rpx;
display: flex;
justify-content: center;
align-items: center;
background: linear-gradient(90deg, #2f7a4a, #55a96d);
color: #fff;
}
.icon-down {
width: 0;
height: 0;
border-left: 12rpx solid transparent;
border-right: 12rpx solid transparent;
border-top: 16rpx solid currentColor;
margin-right: 14rpx;
}
.icon-link {
width: 30rpx;
height: 30rpx;
position: relative;
margin-right: 14rpx;
}
.icon-link::before,
.icon-link::after {
content: '';
position: absolute;
width: 18rpx;
height: 12rpx;
border: 4rpx solid rgba(255, 255, 255, 0.95);
border-radius: 18rpx;
top: 8rpx;
}
.icon-link::before {
left: 0;
transform: rotate(-18deg);
}
.icon-link::after {
right: 0;
transform: rotate(18deg);
}
</style>
+12 -2
View File
@@ -1,5 +1,5 @@
<template>
<s-pages title="我的社员">
<s-pages title="我的社员" navPreset="float" :blue_bg="true">
<!-- 头部 -->
<view class="header" :style="{ backgroundImage: 'url(' + $url + 'home/staff2.png' + ')' }">
<view class="header-content">
@@ -87,7 +87,17 @@
let cardPages = ref(null);
let height = ref('100%');
let sysInfo = uni.getSystemInfoSync();
height.value = sysInfo.windowHeight - sysInfo.statusBarHeight - uni.upx2px(88) + 'px';
const headerHeight = uni.upx2px(248);
const headerMargin = uni.upx2px(64);
const listTopMargin = uni.upx2px(16);
height.value =
sysInfo.windowHeight -
sysInfo.statusBarHeight -
uni.upx2px(88) -
headerHeight -
headerMargin -
listTopMargin +
'px';
const sum_list = ref([{
text: '总人数',
value: 0,
+183 -16
View File
@@ -1,18 +1,33 @@
<template>
<s-pages title="钱包">
<s-pages title="钱包" :pink_bg="true">
<!-- 头部 -->
<view class="header" :style="{ backgroundImage: 'url(' + $url + 'home/wallet2.png' + ')' }">
<view class="header" :style="{ backgroundImage: 'url(' + $url + 'home/wallet2.png' + ')' }" @click.stop>
<view class="header-content">
<view class="title" @click="jumpPage('充值', '/pages/home/recharge')">
钱包余额 <uni-icons type="right" color="#fff" size="28rpx" />
<view class="header-top">
<view class="title" @click="jumpPage('充值', '/pages/home/recharge')">
钱包余额 <uni-icons type="right" color="#fff" size="28rpx" />
</view>
<view class="more-trigger" @click.stop="toggleLiquidationMenu">
<uni-icons type="more-filled" color="#fff" size="34rpx" />
</view>
<view v-if="showLiquidationMenu && enabledLiquidations.length" class="more-menu">
<view
v-for="item in enabledLiquidations"
:key="item.type"
class="more-menu-item"
@click.stop="goLiquidationByType(item)"
>
{{ item.title }}
</view>
</view>
</view>
<view class="num size68 m-y-8" @click="jumpPage('充值', '/pages/home/recharge')">
{{ $fen2yuan(money_obj?.balance || 0) }}
</view>
<view class="line" />
<view class="flex m-t-22">
<view class="flex m-t-22 withdraw_row">
<view class="title"> 可提现金额 </view>
<view class="num m-l-34" @click="jumpPage('提现', '/pages/home/pay/withdraw')">
<view class="num m-l-34" @click="onWithdrawClick">
{{ $fen2yuan(money_obj?.withdrawAmount || 0) }}
</view>
</view>
@@ -25,7 +40,7 @@
<view class="title-right" />
</view>
<!-- 商品 -->
<su-sticky top="100rpx">
<su-sticky top="0">
<view class="goodsIndex">
<goods :list="tagList" v-if="tagList?.length"></goods>
</view>
@@ -34,14 +49,89 @@
</template>
<script setup>
import { ref } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import { ref, computed, onMounted } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import * as api from '@/sheep/api/home/pay';
import * as apiIndex from '@/sheep/api/index/index';
import * as incrementApi from '@/sheep/api/increment';
import goods from '@/components/goods/goods.vue';
const money_obj = ref();
const tagList = ref([]);
const showLiquidationMenu = ref(false);
const tradeChannelList = ref([]);
const LIQUIDATION_TYPE_META = {
1: { type: 1, title: '去变现', keywords: ['千里马', '去变现', '变现'] },
2: { type: 2, title: '无双变现', keywords: ['无双'] },
3: { type: 3, title: '华夏变现', keywords: ['华夏'] },
};
const matchLiquidationMeta = (channel) => {
const lt = Number(channel?.liquidationType);
if ([1, 2, 3].includes(lt) && LIQUIDATION_TYPE_META[lt]) {
return { type: lt, meta: LIQUIDATION_TYPE_META[lt] };
}
const name = String(channel?.channelName || channel?.name || '').trim();
if (!name) return null;
for (const key of Object.keys(LIQUIDATION_TYPE_META)) {
const m = LIQUIDATION_TYPE_META[key];
const keywords = Array.isArray(m?.keywords) ? m.keywords : [];
if (keywords.some((kw) => name.includes(kw))) {
return { type: Number(key), meta: m };
}
}
return null;
};
const enabledLiquidations = computed(() => {
const channels = Array.isArray(tradeChannelList.value) ? tradeChannelList.value : [];
const list = [];
const added = new Set();
channels.forEach((it) => {
if (Number(it?.status) !== 1) return;
const matched = matchLiquidationMeta(it);
if (!matched) return;
const type = matched.type;
const meta = matched.meta;
if (added.has(type)) return;
added.add(type);
list.push({
type,
title: meta.title,
channelId: it?.id ?? it?.channelId,
});
});
return list;
});
const withdrawChannelEnabled = computed(() => {
const channels = Array.isArray(tradeChannelList.value) ? tradeChannelList.value : [];
const exact = channels.find(
(it) => String(it?.channelName || it?.name || '').trim() === '去提现'
);
if (exact) return Number(exact?.status) === 1;
const fuzzy = channels.find((it) => {
const name = String(it?.channelName || it?.name || '').trim();
return name.includes('去提现');
});
if (fuzzy) return Number(fuzzy?.status) === 1;
const anyWithdrawLike = channels.find((it) => {
const name = String(it?.channelName || it?.name || '').trim();
return name.includes('提现');
});
if (anyWithdrawLike) return Number(anyWithdrawLike?.status) === 1;
return !channels.length;
});
const fetchTradeChannels = async () => {
try {
const res = await incrementApi.getTradeChannelList();
if (res?.code === 0 && Array.isArray(res?.data)) {
tradeChannelList.value = res.data;
}
} catch (e) {}
};
//获取钱包
function getData() {
@@ -62,36 +152,74 @@
onLoad(() => {
getData();
});
onMounted(() => {
fetchTradeChannels();
});
//充值提现弹框提示去跳转
function onWithdrawClick() {
showLiquidationMenu.value = false;
if (!withdrawChannelEnabled.value) {
return;
}
jumpPage('提现', '/pages/home/pay/withdraw');
}
function jumpPage(typeTxt, url) {
showLiquidationMenu.value = false;
uni.showModal({
// title: '',
content: '是否去' + typeTxt,
showCancel: true,
success: (res) => {
//用户点击确定
if (res.confirm) {
uni.navigateTo({
url: url,
});
uni.navigateTo({ url: url });
}
},
});
}
function toggleLiquidationMenu() {
showLiquidationMenu.value = !showLiquidationMenu.value;
}
function goLiquidationByType(item) {
showLiquidationMenu.value = false;
const type = Number(item?.type || 1);
const title = item?.title || LIQUIDATION_TYPE_META[type]?.title || '去变现';
const channelId = item?.channelId ? `&channelId=${item.channelId}` : '';
if (type === 1) {
uni.showModal({
content: '是否去' + title,
showCancel: true,
success: (res) => {
if (!res.confirm) return;
uni.navigateTo({
url: `/pages/home/liquidation?type=${type}${channelId}`,
});
},
});
return;
}
uni.navigateTo({
url: `/pages/home/liquidation?type=${type}${channelId}`,
});
}
</script>
<style lang="scss" scoped>
.header {
height: 318rpx;
// background: linear-gradient(270deg, #75AFF6 0%, #366DEE 98.57%);
margin: 32rpx;
background-size: 100% 100%;
background-repeat: no-repeat;
overflow: hidden;
position: relative;
.header-content {
padding: 80rpx 32rpx 24rpx;
.header-top {
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
}
.title {
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
@@ -100,6 +228,40 @@
line-height: 40rpx;
}
.more-trigger {
width: 52rpx;
height: 52rpx;
border-radius: 26rpx;
background: rgba(255, 255, 255, 0.14);
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.more-menu {
position: absolute;
top: 58rpx;
right: 0;
min-width: 200rpx;
padding: 10rpx;
border-radius: 18rpx;
background: rgba(26, 45, 88, 0.98);
box-shadow: 0 12rpx 30rpx rgba(0, 0, 0, 0.28);
z-index: 9999;
}
.more-menu-item {
height: 64rpx;
padding: 0 24rpx;
border-radius: 14rpx;
color: #ffffff;
font-size: 26rpx;
display: flex;
align-items: center;
white-space: nowrap;
}
.num {
font-family: Avenir, Avenir;
font-weight: 900;
@@ -116,6 +278,11 @@
rgba(255, 255, 255, 0) 100%
);
}
.withdraw_row {
align-items: center;
}
}
}
@@ -1,7 +1,7 @@
<template>
<view class="detail-content-card ss-p-b-20">
<view class="card-content">
<mp-html :content="content"></mp-html>
<mp-html :content="content" :tag-style="tagStyle"></mp-html>
</view>
</view>
</template>
@@ -13,6 +13,10 @@
default: '',
},
});
const tagStyle = {
img: 'display:block;width:100%;height:auto;',
};
</script>
<style lang="scss" scoped>
+1 -1
View File
@@ -1,5 +1,5 @@
<template>
<s-pages title="我的" leftUrl="/pages/index/index" :goLeft="false">
<s-pages title="我的" :pink_bg="true" leftUrl="/pages/index/index" :goLeft="false">
<view class="p-x-32 w100 h_364 relative m-t-42 color0">
<view class="p-x-32 w100 h100 absolute t0 l0">
<image class="w100 h100" src="/static/increment/bg.png" mode="scaleToFill" />
+686
View File
@@ -0,0 +1,686 @@
<template>
<s-pages
title="AI店铺"
navPreset="blue"
tabbar="/pages/index/aiStore"
:showLeftButton="false"
>
<view class="ai-store-page h100 flex-column">
<view v-if="index === 0" class="page-bg page-bg--ai"></view>
<view class="top-area" :class="{'top-area1': index === 1}">
<view class="tab-header">
<view
v-for="(tab, i) in nav"
:key="tab.id"
class="tab-item"
:class="{ active: index === i }"
@click="navChange(i)"
>
{{ tab.name }}
</view>
<view class="tab-line" :style="{ left: index === 0 ? '25%' : '75%' }"></view>
</view>
<view class="search-wrap flex-center" v-if="index === 0">
<view class="search-input flex1 flex-center">
<image class="search-icon-grey m-r-16" src="/static/icon/search.svg" mode="aspectFit" />
<uni-easyinput
class="flex1"
v-model="searchText"
type="text"
placeholder="搜索想要的商品"
:inputBorder="false"
:styles="{ color: '#333', fontSize: '28rpx' }"
placeholderStyle="color:#9AA7C7;font-size:28rpx;"
@blur="search"
@clear="clearSearch"
/>
</view>
<view class="search-btn flex-center" @click="search">
<image class="search-icon-white" src="/static/icon/search.svg" mode="aspectFit" />
</view>
</view>
<aistore_earnings_carousel v-if="index === 0" :pageSize="30" />
<view class="m-t-16 m-b-8" v-if="timeRound.length && index === 0">
<scroll-view scroll-x class="time-scroll">
<view class="flex">
<view
v-for="(item, i) in timeRound"
:key="item.id || i"
class="timeNav m-r-20"
:class="{ activeTime: selectedTimeId === item.id }"
@click="changeTimeRound(item, i)"
>
{{ item.name }}
</view>
</view>
</scroll-view>
</view>
<view style="padding: 80rpx 0 120rpx" v-if="index === 1">
<view style="position: relative">
<view class="shop-summary-card">
<view class="shop-summary-top flex-row">
<view class="shop-summary-icon-wrap shrink flex-center">
<image class="shop-summary-icon" src="/static/index/shop1.png" mode="aspectFit" />
</view>
<view class="shop-summary-info flex1">
<view class="shop-summary-title">{{ shopTitle }}</view>
<view class="shop-summary-id">ID:{{ shopSummary.shopId }}</view>
<!-- <view class="shop-summary-id">商品总数:{{ shopSummary.total }}</view> -->
</view>
</view>
<view class="shop-summary-bottom" v-if="index === 1">
<view class="shop-summary-metrics flex-center">
<view class="metric flex1">
<view class="metric-label">总收益</view>
<view class="metric-value">{{ $fen2yuan(shopSummary.totalEarnings) }}</view>
</view>
<view class="metric-divider"></view>
<view class="metric flex1">
<view class="metric-label">店铺数量</view>
<view class="metric-value">{{ shopSummary.shopCount }}</view>
</view>
<view class="metric-divider"></view>
<view class="metric flex1">
<view class="metric-label">店铺等级</view>
<view class="metric-value size30">{{ shopSummary.level || 0 }}</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
<view class="list-wrap flex1" :style="{ marginTop: index === 1 ? '110rpx' : '0' }">
<card_pages
ref="pageCommodity"
:navList="nav"
:currentTab="index"
@upCallback="getData"
:height="height"
:oneShow="true"
>
<template #content>
<aistore_tab1
v-if="index === 0"
:list="dataList"
@addCar="addCar"
@update="update"
@shipment="shipment"
/>
<aistore_tab2
v-if="index === 1"
:list="dataList"
:source="index"
@addCar="addCar"
@update="update"
@shipment="shipment"
/>
</template>
</card_pages>
</view>
</view>
<view v-if="index === 0">
<card_payment
ref="paymentRef"
@updataList="clearSearch"
@updatePrice="updatePrice"
:addShow="hasPaymentBar"
:minSalesCountShow="navName === '折扣区'"
:bottomOffset="tabbarBottomOffset"
/>
</view>
</s-pages>
</template>
<script setup>
import { ref, watch, computed } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import sheep from '@/sheep';
import * as api from '@/sheep/api/ai/index';
import card_pages from '@/components/card_pages/card_pages';
import card_payment from '@/components/card_payment/card_payment';
import aistore_earnings_carousel from './components/aistore_earnings_carousel.vue';
import aistore_tab1 from './components/aistore_tab1.vue';
import aistore_tab2 from './components/aistore_tab2.vue';
const HOME_DEFAULT_TAB_STORAGE_KEY = 'home.goods.defaultTabName';
const aiShopStatus = ref({
value: null,
checkedAt: 0,
});
const ensureAiShopOpened = async () => {
const now = Date.now();
if (aiShopStatus.value.value !== null && now - aiShopStatus.value.checkedAt < 60 * 1000) {
return Boolean(aiShopStatus.value.value);
}
const res = await api.checkShopStatus({});
if (res?.code !== 0) {
throw new Error('checkShopStatus_failed');
}
const opened = Boolean(res?.data);
aiShopStatus.value = {
value: opened ? 1 : 0,
checkedAt: now,
};
return opened;
};
const searchText = ref('');
const search = () => {
pageCommodity.value?.downCallback();
};
const clearSearch = () => {
searchText.value = '';
pageCommodity.value?.downCallback();
};
const timeRound = ref([]);
const selectedTimeId = ref(null);
const navName = ref('');
const timeRoundNameMap = computed(() => {
const arr = Array.isArray(timeRound.value) ? timeRound.value : [];
const map = {};
arr.forEach((it) => {
const id = it?.id;
if (id === null || id === undefined) return;
map[String(id)] = String(it?.name || '').trim();
});
return map;
});
const attachShoppingPlazaName = (item) => {
const map = timeRoundNameMap.value;
const id = item?.shoppingPlazaId ?? item?.roundTimeId;
const name = id === null || id === undefined ? '' : map[String(id)] || '';
return { ...item, shoppingPlazaName: name };
};
function changeTimeRound(e) {
navName.value = e.name;
selectedTimeId.value = e?.id ?? null;
pageCommodity.value?.downCallback();
}
function getSpuTimeList() {
api.getSpuTimeList({}).then((res) => {
if (res.code === 0) {
timeRound.value = res.data || [];
selectedTimeId.value = timeRound.value?.[0]?.id ?? null;
navName.value = timeRound.value?.[0]?.name ?? '';
}
});
}
const getCartList = async () => {
const res = await api.getShopCartList({});
if (res.code === 0) {
hasPaymentBar.value = index.value === 0 && Boolean(res.data.length);
}
};
onLoad((options) => {
const tab = Number(options?.tab);
if (tab === 1) {
navChange(1);
}
});
onShow(async () => {
try {
const opened = await ensureAiShopOpened();
if (!opened) {
const message = '您尚未开通AI店铺,无法查看购物车。请先开通AI店铺后再进行购买。';
uni.setStorageSync(HOME_DEFAULT_TAB_STORAGE_KEY, '会员优选');
uni.switchTab({
url: '/pages/index/index',
success: () => {
setTimeout(() => {
uni.showToast({
title: message,
icon: 'none',
duration: 2500,
});
}, 50);
},
fail: () => {
uni.reLaunch({
url: '/pages/index/index',
success: () => {
setTimeout(() => {
uni.showToast({
title: message,
icon: 'none',
duration: 2500,
});
}, 50);
},
});
},
});
return;
}
} catch (e) {
const message = '系统繁忙,请稍后重试';
uni.switchTab({
url: '/pages/index/index',
success: () => {
setTimeout(() => {
uni.showToast({
title: message,
icon: 'none',
duration: 2500,
});
}, 50);
},
fail: () => {
uni.reLaunch({
url: '/pages/index/index',
success: () => {
setTimeout(() => {
uni.showToast({
title: message,
icon: 'none',
duration: 2500,
});
}, 50);
},
});
},
});
return;
}
getSpuTimeList();
getCartList();
});
const update = () => {
pageCommodity.value?.downCallback();
};
const system = uni.getSystemInfoSync();
const tabbarBottomOffset = uni.upx2px(100) + Number(system.safeAreaInsets?.bottom || 0);
const paymentBarReserve = uni.upx2px(148);
const baseHeight =
system.windowHeight -
system.statusBarHeight -
uni.upx2px(88) -
uni.upx2px(76) -
uni.upx2px(48) -
uni.upx2px(20);
const index = ref(0);
const height = ref(`${baseHeight}px`);
const hasPaymentBar = ref(false);
watch(
() => hasPaymentBar.value,
() => {
const extra = hasPaymentBar.value ? paymentBarReserve : 0;
height.value = `${baseHeight - extra}px`;
},
{ immediate: true },
);
const nav = ref([
{ name: '选品广场', id: 1 },
{ name: '我的店铺', id: 2 },
]);
const userStore = sheep.$store('user');
const shopTitle = computed(() => {
const name = String(userStore?.userInfo?.nickname || userStore?.userInfo?.mobile || '').trim();
if (!name) return '我的店铺';
return `${name}的店铺`;
});
const pageCommodity = ref(null);
const dataList = ref([]);
const getData = async (mescroll) => {
if (mescroll?.dataObj?.index !== index.value) return;
let res = null;
if (index.value) {
res = await api.getMyShop({
pageNo: mescroll?.num || 1,
pageSize: mescroll?.size || 10,
keyWord: searchText.value || undefined,
status: mescroll?.params?.status,
});
} else {
const id = selectedTimeId.value;
res = await api.getSpuPage({
pageNo: mescroll?.num || 1,
pageSize: mescroll?.size || 10,
keyWord: searchText.value,
...(id !== null && id !== undefined && id !== '' ? { timeId: id } : {}),
...mescroll.params,
});
}
if (res.code !== 0) {
pageCommodity.value?.getState(false);
return;
}
let curPageData = [];
if (index.value) {
const root = res?.data || {};
if ((mescroll?.num || 1) === 1) {
shopSummary.value = {
title: '我的店铺',
totalEarnings: root?.totalRevenue ?? 0,
shopCount: root?.numberOfStores ?? 0,
level: root?.shopRating ?? 0,
total: root?.total ?? 0,
shopId: root?.shopId ?? '',
};
}
const list = Array.isArray(root?.storeList) ? root.storeList : [];
curPageData = list.map((it) => {
console.log(it)
const agencyTime = String(it?.agencyTime || '').trim();
const dateOnly = agencyTime ? agencyTime.split('T')[0].split(' ')[0] : '';
return {
skuId: it?.skuId ?? '',
name: it?.aiShopCommodityName ?? '',
createTime: dateOnly,
progress: 0,
earnings: it?.totalRevenue ?? 0,
totalRevenue: it?.totalRevenue ?? 0,
userPayPrice: it?.userPayPrice ?? 0,
leaf: it?.greenCredits ?? 0,
cover: it?.picUrl ?? '',
};
});
} else {
const raw = Array.isArray(res.data?.list) ? res.data.list : [];
curPageData = raw.map(attachShoppingPlazaName);
}
if (mescroll?.num === 1) dataList.value = [];
dataList.value = dataList.value.concat(curPageData);
pageCommodity.value?.getState(true, curPageData.length);
};
watch(
timeRound,
() => {
if (index.value !== 0) return;
if (!Array.isArray(dataList.value) || !dataList.value.length) return;
const map = timeRoundNameMap.value;
dataList.value = dataList.value.map((it) => {
const id = it?.shoppingPlazaId ?? it?.roundTimeId;
const name = id === null || id === undefined ? '' : map[String(id)] || '';
if (name === it?.shoppingPlazaName) return it;
return { ...it, shoppingPlazaName: name };
});
},
{ deep: true },
);
const paymentRef = ref(null);
const addCar = (data) => {
paymentRef.value?.addCar(data);
};
const navChange = (i) => {
index.value = i;
dataList.value = [];
pageCommodity.value?.downCallback();
if (index.value === 0) {
getCartList();
} else {
hasPaymentBar.value = false;
}
};
const updatePrice = (val) => {
hasPaymentBar.value = Boolean(val);
};
function shipment() {
pageCommodity.value?.downCallback();
}
const shopSummary = ref({
title: '我的店铺',
totalEarnings: 0,
shopCount: 0,
level: 0,
total: 0,
});
const formatAmount = (value) => {
const num = Number(value);
if (!Number.isFinite(num)) return '0.00';
const fixed = num.toFixed(2);
const [intPart, decPart] = fixed.split('.');
const withComma = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
return `${withComma}.${decPart}`;
};
</script>
<style lang="scss" scoped>
:deep(.scon) {
overflow-y: hidden !important;
}
.ai-store-page {
min-height: 100vh;
position: relative;
}
.page-bg {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
pointer-events: none;
z-index: 0;
}
.page-bg--ai {
background: url('/static/ai_bg.png') no-repeat center top;
background-size: 100% auto;
}
.top-area {
position: relative;
z-index: 1;
padding: 0 24rpx 24rpx;
}
.top-area1{
position: relative;
z-index: 1;
background: #2556ec;
}
.tab-header {
position: relative;
display: flex;
justify-content: center;
// margin-top: 12rpx;
}
.tab-item {
width: 50%;
text-align: center;
font-size: 34rpx;
line-height: 48rpx;
padding: 16rpx 0 22rpx;
color: rgba(255, 255, 255, 0.7);
&.active {
color: #ffffff;
font-weight: 700;
}
}
.tab-line {
position: absolute;
bottom: 6rpx;
width: 72rpx;
height: 6rpx;
background: #fff;
border-radius: 6rpx;
transform: translateX(-50%);
transition: left 0.25s ease;
}
.search-wrap {
margin-top: 12rpx;
padding: 0 10rpx;
}
.search-input {
height: 56rpx;
background: #ffffff;
border-radius: 40rpx;
padding: 0 28rpx;
}
.search-btn {
width: 56rpx;
height: 56rpx;
margin-left: 18rpx;
border-radius: 38rpx;
background: linear-gradient(to bottom right, #2c8cfa 0%, #3d5efb 100%);
}
.search-icon-grey {
width: 36rpx;
height: 36rpx;
}
.search-icon-white {
width: 36rpx;
height: 36rpx;
filter: brightness(0) invert(1);
}
.time-scroll {
width: 100%;
white-space: nowrap;
}
.timeNav {
display: inline-flex;
align-items: center;
height: 56rpx;
padding: 0 22rpx;
border-radius: 28rpx;
font-size: 28rpx;
// color: rgba(255, 255, 255, 0.85);
color: #2556ec;
background: rgba(255, 255, 255, 0.55);
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.01);
}
.activeTime {
color: #2556ec;
background: #ffffff;
font-weight: 700;
}
.list-wrap {
margin-top: 18rpx;
background: #f1f5ff;
border-radius: 30rpx 30rpx 0 0;
padding: 0 24rpx 50rpx;
overflow: hidden;
}
:deep(.ai-button1) {
background: linear-gradient(to bottom right, #2c8cfa 0%, #3d5efb 100%) !important;
}
.shop-summary-card {
width: 94% !important;
border-radius: 26rpx;
overflow: hidden;
position: absolute;
top: -60rpx;
left: 3%;
width: 100%;
box-sizing: border-box;
box-shadow: 0 8rpx 22rpx rgba(38, 107, 246, 0.45);
background: linear-gradient(135deg, #2c8cfa 0%, #3d5efb 100%);
}
.shop-summary-top {
padding: 30rpx 28rpx;
// background: linear-gradient(135deg, #2c8cfa 0%, #3d5efb 100%);
}
.shop-summary-icon-wrap {
width: 88rpx;
height: 88rpx;
border-radius: 24rpx;
background: rgba(255, 255, 255, 0.2);
backdrop-filter: blur(8rpx);
margin-right: 20rpx;
}
.shop-summary-icon {
width: 54rpx;
height: 54rpx;
}
.shop-summary-title {
font-size: 34rpx;
font-weight: 700;
color: #ffffff;
line-height: 44rpx;
}
.shop-summary-id {
margin-top: 6rpx;
font-size: 24rpx;
color: rgba(255, 255, 255, 0.85);
line-height: 32rpx;
}
.shop-summary-bottom {
background: rgba(255, 255, 255, 0.96);
padding: 22rpx 18rpx;
border-radius: 30rpx 30rpx 0 0;
// position: relative;
}
.shop-summary-metrics {
align-items: stretch;
// position: absolute;
}
.metric {
text-align: center;
}
.metric-label {
font-size: 24rpx;
color: #2c63ff;
line-height: 34rpx;
}
.metric-value {
margin-top: 10rpx;
font-size: 40rpx;
font-weight: 800;
color: #111111;
line-height: 44rpx;
}
.metric-divider {
width: 1rpx;
background: rgba(155, 170, 199, 0.55);
margin: 12rpx 0;
}
</style>
+1 -1
View File
@@ -1,5 +1,5 @@
<template>
<s-pages tabbar="/pages/cart/cart" title="购物车" :showLeftButton="false">
<s-pages tabbar="/pages/cart/cart" title="购物车" :pink_bg="true" :showLeftButton="false">
<s-empty
v-if="state.list.length === 0"
icon="/static/cart-empty.png"
+1 -1
View File
@@ -1,5 +1,5 @@
<template>
<s-pages tabbar="/pages/index/category" title="分类" :showLeftButton="false" color="#ffffff">
<s-pages title="分类" :pink_bg="true" :showLeftButton="false" color="#ffffff">
<card_search class="search" style="padding-bottom: 32rpx" @search="search"></card_search>
<view class="page_bottom flex-row">
<view class="classify shrink">
@@ -0,0 +1,229 @@
<template>
<view class="bar-rank-card">
<scroll-view class="bar-scroll" scroll-x :show-scrollbar="false" enhanced>
<view class="bar-scroll__inner" :style="{ width: chartWidth }">
<card_echart :options="chartOptions" />
</view>
</scroll-view>
</view>
</template>
<script setup>
import { computed, nextTick, onUnmounted, ref, watch } from 'vue';
import card_echart from '@/components/card_echart/card_echart.vue';
const props = defineProps({
active: {
type: Boolean,
default: true,
},
list: {
type: Array,
default: () => [],
},
colors: {
type: Array,
default: () => ['#FF6B6B', '#FFB020', '#2ED573', '#1E90FF', '#A66BFF'],
},
maxVisible: {
type: Number,
default: 6,
},
itemWidthRpx: {
type: Number,
default: 120,
},
yMaxFactor: {
type: Number,
default: 1.25,
},
animateOnce: {
type: Boolean,
default: true,
},
});
const animatedOnce = ref(false);
const displayList = ref([]);
let introTimer = null;
const normalizedList = computed(() => {
const raw = Array.isArray(props.list) ? props.list : [];
return raw.map((it, idx) => {
const id = it?.id ?? idx + 1;
const value = Number(it?.value) || 0;
const avatar = it?.avatar || '/static/head_null.png';
const label = String(it?.label || `Top${idx + 1}`);
return { id, value, avatar, label };
});
});
const chartWidth = computed(() => {
const n = normalizedList.value.length;
if (n <= props.maxVisible) return '100%';
return `${n * 96}rpx`;
});
const resetDisplay = () => {
displayList.value = normalizedList.value.map((it) => ({ ...it }));
};
const clearIntroTimer = () => {
if (introTimer) {
clearTimeout(introTimer);
introTimer = null;
}
};
const startIntroAnimation = async () => {
if (!props.active) return;
if (!props.animateOnce) {
resetDisplay();
return;
}
if (animatedOnce.value) {
resetDisplay();
return;
}
clearIntroTimer();
displayList.value = normalizedList.value.map((it) => ({ ...it, value: 0 }));
await nextTick();
introTimer = setTimeout(() => {
resetDisplay();
animatedOnce.value = true;
introTimer = null;
}, 80);
};
watch(
() => normalizedList.value,
() => {
if (!props.active) return;
if (animatedOnce.value && props.animateOnce) {
resetDisplay();
return;
}
startIntroAnimation();
},
{ deep: true, immediate: true },
);
watch(
() => props.active,
(val) => {
if (val) {
startIntroAnimation();
return;
}
clearIntroTimer();
resetDisplay();
},
{ immediate: true },
);
onUnmounted(() => {
clearIntroTimer();
});
const chartOptions = computed(() => {
const list = Array.isArray(displayList.value) ? displayList.value : [];
const xData = list.map((it) => it.label);
const palette =
Array.isArray(props.colors) && props.colors.length ? props.colors : ['#3d5efb'];
const barData = list.map((it, i) => ({
name: String(it?.id ?? ''),
value: Number(it?.value) || 0,
itemStyle: {
color: palette[i % palette.length],
borderRadius: [0, 0, 0, 0],
},
}));
const avatarData = list.map((it) => ({
name: String(it?.id ?? ''),
value: Number(it?.value) || 0,
symbol: `image://${it?.avatar || '/static/head_null.png'}`,
}));
const maxV = Math.max(...list.map((it) => Number(it?.value) || 0), 1);
const yMax = Math.ceil(maxV * (Number(props.yMaxFactor) || 1.25));
return {
animation: true,
animationDuration: 900,
animationEasing: 'cubicOut',
animationDurationUpdate: 900,
animationEasingUpdate: 'cubicOut',
grid: { left: 0, right: 0, top: 46, bottom: 22, containLabel: false },
xAxis: {
type: 'category',
data: xData,
axisLine: {
show: true,
lineStyle: { color: 'rgba(255,255,255,0.45)', width: 1 },
},
axisTick: { show: false },
axisLabel: {
show: true,
color: 'rgba(255,255,255,0.85)',
fontSize: 10,
margin: 10,
},
},
yAxis: { type: 'value', show: false, min: 0, max: yMax },
series: [
{
id: 'bars',
type: 'bar',
data: barData,
barWidth: 20,
barCategoryGap: 8,
universalTransition: true,
label: {
show: true,
position: 'inside',
color: '#ffffff',
fontSize: 10,
fontWeight: 700,
formatter: (p) => {
const v = Number(p?.value) || 0;
return v ? String(v) : '';
},
},
animationDelay: (idx) => idx * 140,
animationDelayUpdate: (idx) => idx * 140,
},
{
id: 'avatars',
type: 'pictorialBar',
data: avatarData,
symbolSize: [24, 24],
symbolPosition: 'end',
symbolOffset: [0, -28],
z: 10,
universalTransition: true,
animationDelay: (idx) => idx * 140,
animationDelayUpdate: (idx) => idx * 140,
},
],
};
});
</script>
<style scoped lang="scss">
.bar-rank-card {
margin-top: 18rpx;
padding: 12rpx 24rpx 12rpx;
height: 240rpx;
}
.bar-scroll {
width: 100%;
height: 100%;
}
.bar-scroll__inner {
height: 100%;
}
</style>
@@ -0,0 +1,443 @@
<template>
<view class="earnings-carousel">
<view class="earnings-header" @click="toggleCollapsed">
<view class="earnings-title">
<view class="earnings-title__icon">
<image class="earnings-title__icon-img" src="/static/icon/medal.png" mode="aspectFit" />
</view>
<view class="earnings-title__text">销量风云榜</view>
</view>
<view class="earnings-collapse-icon" :class="{ collapsed: isCollapsed }">
<text class="earnings-collapse-arrow">▾</text>
</view>
</view>
<view v-show="!isCollapsed" class="earnings-content">
<swiper
class="earnings-swiper"
:current="currentPageIndex"
:autoplay="autoplay && !isCollapsed"
:interval="interval"
:duration="duration"
:circular="swiperPages.length > 1"
:disable-touch="true"
:indicator-dots="false"
@change="onSwiperChange"
>
<swiper-item v-for="(page, pageIndex) in swiperPages" :key="pageIndex">
<view class="earnings-page">
<view class="earnings-row">
<view class="rank-card" v-for="(item, i) in page" :key="item.orderItemId || i">
<view class="rank-top">
<image class="rank-avatar" :src="getAvatar(item)" mode="aspectFill" />
</view>
<view class="rank-name lineOne">{{ item.nickname || maskMobile(item.mobile) || '-' }}</view>
<view class="rank-goods">
<image class="rank-goods__img" :src="getGoodsPic(item)" mode="aspectFill" />
<view class="rank-goods__mask">
<view class="rank-rate">{{ formatPercent(item.progress) }}</view>
<view class="rank-progress">
<view class="rank-progress__bar" :style="{ width: `${clampProgress(item.progress)}%` }" />
</view>
</view>
</view>
<view class="rank-goods__name lineOne">{{ item.spuName || '-' }}</view>
</view>
</view>
</view>
</swiper-item>
</swiper>
</view>
</view>
</template>
<script setup>
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
import sheep from '@/sheep';
import { earningsPage } from '@/sheep/api/ai/index';
const props = defineProps({
active: {
type: Boolean,
default: true,
},
pageSize: {
type: Number,
default: 30,
},
autoplay: {
type: Boolean,
default: true,
},
interval: {
type: Number,
default: 10000,
},
duration: {
type: Number,
default: 450,
},
defaultCollapsed: {
type: Boolean,
default: false,
},
});
const MAX_PAGES = 30;
const DISPLAY_SIZE = 5;
const isCollapsed = ref(Boolean(props.defaultCollapsed));
const toggleCollapsed = () => {
isCollapsed.value = !isCollapsed.value;
if (!isCollapsed.value) {
schedulePrefetchNext(true);
} else {
clearPrefetch();
}
};
const currentPageIndex = ref(0);
const total = ref(0);
const pagesMap = ref({});
const loadingMap = ref({});
const PREFETCH_ADVANCE_MS = 800;
let prefetchTimer = null;
const normalizeSize = (val, def) => {
const n = Math.floor(Number(val));
return Number.isFinite(n) && n > 0 ? n : def;
};
const autoplay = computed(() => props.autoplay && swiperPages.value.length > 1);
const interval = computed(() => {
const n = Number(props.interval);
return Number.isFinite(n) && n > 0 ? n : 10000;
});
const duration = computed(() => {
const n = Number(props.duration);
return Number.isFinite(n) && n >= 0 ? n : 450;
});
const totalPages = computed(() => MAX_PAGES);
const swiperPages = computed(() => {
return pages.value;
});
const normalizePageNo = (pageNo) => {
const n = Math.floor(Number(pageNo));
const tp = totalPages.value || 1;
if (!Number.isFinite(n) || tp <= 0) return 1;
if (n <= 0) return tp;
if (n > tp) return 1;
return n;
};
const normalizePageList = (list) => {
const arr = Array.isArray(list) ? list : [];
if (arr.length === DISPLAY_SIZE) return arr;
if (arr.length > DISPLAY_SIZE) return arr.slice(0, DISPLAY_SIZE);
return [...arr, ...Array.from({ length: DISPLAY_SIZE - arr.length }, () => ({}))];
};
const pages = computed(() => {
const arr = [];
const pageCount = totalPages.value || 1;
for (let i = 0; i < pageCount; i += 1) {
const key = String(i + 1);
arr.push(normalizePageList(pagesMap.value[key]));
}
return arr;
});
const fetchPage = async (pageNo) => {
const res = await earningsPage({
pageNo,
pageSize: normalizeSize(props.pageSize, 30),
}).catch(() => ({ code: -1 }));
if (res?.code !== 0) return;
const data = res?.data || {};
total.value = Number(data?.total) || 0;
const list = Array.isArray(data?.list) ? data.list : [];
pagesMap.value[String(pageNo)] = list;
};
const ensurePageLoaded = (pageNo, force = false) => {
const no = normalizePageNo(pageNo);
const key = String(no);
if (!force && pagesMap.value[key]) return Promise.resolve();
if (loadingMap.value[key]) return loadingMap.value[key];
const p = fetchPage(no).finally(() => {
loadingMap.value[key] = null;
});
loadingMap.value[key] = p;
return p;
};
const clearPrefetch = () => {
if (prefetchTimer) {
clearTimeout(prefetchTimer);
prefetchTimer = null;
}
};
const schedulePrefetchNext = (immediate = false) => {
clearPrefetch();
if (!props.active) return;
if (!autoplay.value) return;
const delay = immediate ? 0 : Math.max(0, interval.value - PREFETCH_ADVANCE_MS);
prefetchTimer = setTimeout(() => {
const nextPageNo = normalizePageNo(currentPageIndex.value + 2);
ensurePageLoaded(nextPageNo, true);
}, delay);
};
const onSwiperChange = (e) => {
const next = Number(e?.detail?.current);
if (!Number.isFinite(next)) return;
currentPageIndex.value = next;
const currentPageNo = normalizePageNo(next + 1);
const key = String(currentPageNo);
if (!pagesMap.value[key] && !loadingMap.value[key]) {
ensurePageLoaded(currentPageNo, true).finally(() => schedulePrefetchNext(false));
return;
}
schedulePrefetchNext(false);
};
const clampProgress = (val) => {
const n = Number(val);
if (!Number.isFinite(n)) return 0;
return Math.max(0, Math.min(100, n));
};
const formatPercent = (val) => {
const n = clampProgress(val);
return `${Math.round(n)}%`;
};
const getAvatar = (item) => {
const url = String(item?.avatar || '').trim();
return url ? sheep.$url.cdn(url) : '/static/head_null.png';
};
const getGoodsPic = (item) => {
const url = String(item?.picUrl || '').trim();
return url ? sheep.$url.cdn(url) : '/static/product_null.png';
};
const maskMobile = (mobile) => {
const s = String(mobile || '').trim();
if (!/^1\d{10}$/.test(s)) return '';
return `${s.slice(0, 3)}****${s.slice(7)}`;
};
const reset = async () => {
currentPageIndex.value = 0;
total.value = 0;
pagesMap.value = {};
loadingMap.value = {};
await ensurePageLoaded(1, true);
schedulePrefetchNext(true);
};
watch(
() => props.active,
(val) => {
if (val) {
reset();
}
},
{ immediate: true },
);
watch(
() => props.pageSize,
() => {
if (props.active) reset();
},
);
onMounted(() => {
if (props.active) reset();
});
onUnmounted(() => {
clearPrefetch();
});
</script>
<style scoped lang="scss">
.earnings-carousel {
margin-top: 18rpx;
padding: 16rpx 12rpx 0;
border-radius: 24rpx;
background: rgba(255, 255, 255, 0.75);
box-shadow: 0 16rpx 32rpx rgba(200, 213, 248, 0.8);
box-sizing: border-box;
}
.earnings-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 6rpx 12rpx;
}
.earnings-title {
display: flex;
align-items: center;
gap: 10rpx;
}
.earnings-title__icon {
width: 40rpx;
height: 40rpx;
border-radius: 20rpx;
background: linear-gradient(180deg, #93c5fd 0%, #1d4ed8 100%);
display: flex;
align-items: center;
justify-content: center;
}
.earnings-title__icon-img {
width: 28rpx;
height: 28rpx;
display: block;
}
.earnings-title__text {
font-size: 32rpx;
font-weight: 900;
color: #1d4ed8;
}
.earnings-collapse-icon {
width: 48rpx;
height: 48rpx;
display: flex;
align-items: center;
justify-content: center;
transition: transform 0.25s ease;
&.collapsed {
transform: rotate(-90deg);
}
.earnings-collapse-arrow {
font-size: 36rpx;
color: #1d4ed8;
line-height: 1;
font-weight: 700;
}
}
.earnings-content {
overflow: hidden;
}
.earnings-swiper {
height: 280rpx;
}
.earnings-page {
width: 100%;
height: 270rpx;
display: flex;
align-items: center;
}
.earnings-row {
width: 100%;
display: flex;
justify-content: space-between;
gap: 14rpx;
padding: 0 8rpx;
box-sizing: border-box;
}
.rank-card {
flex: 1;
min-width: 0;
border-radius: 12rpx;
background: rgba(255, 255, 255, 0.95);
padding: 16rpx 12rpx;
box-sizing: border-box;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1)
}
.rank-top {
display: flex;
align-items: center;
justify-content: center;
gap: 8rpx;
}
.rank-avatar {
width: 54rpx;
height: 54rpx;
border-radius: 32rpx;
background: #f2f3f6;
flex-shrink: 0;
}
.rank-name {
margin-top: 10rpx;
font-size: 22rpx;
color: #111827;
text-align: center;
}
.rank-rate {
font-size: 24rpx;
font-weight: 900;
color: #ffffff;
line-height: 1;
}
.rank-progress {
margin-top: 8rpx;
height: 12rpx;
border-radius: 999rpx;
background: rgba(255, 255, 255, 0.5);
overflow: hidden;
}
.rank-progress__bar {
height: 100%;
border-radius: 999rpx;
background: linear-gradient(90deg, #ffb347 0%, #ff8a00 100%);
}
.rank-goods {
margin-top: 14rpx;
position: relative;
border-radius: 14rpx;
background: #f3f5f8;
overflow: hidden;
height: 66rpx;
}
.rank-goods__img {
width: 100%;
height: 100%;
}
.rank-goods__mask {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
justify-content: center;
padding: 0 10rpx;
background: rgba(17, 24, 39, 0.32);
box-sizing: border-box;
}
.rank-goods__name {
margin-top: 10rpx;
font-size: 22rpx;
color: #111827;
text-align: center;
}
</style>
+20
View File
@@ -0,0 +1,20 @@
<template>
<view class="p-t-16" style="padding-bottom: 500rpx;">
<view class="m-b-24" v-for="(v, i) in list" :key="i">
<aiOrder :data="v" @addCar="emit('addCar', $event)" :source="0" @update="emit('update')" @shipment="emit('shipment')" />
</view>
</view>
</template>
<script setup>
import aiOrder from '@/components/ai_order/ai_order';
defineProps({
list: {
type: Array,
default: () => [],
},
});
const emit = defineEmits(['addCar', 'update', 'shipment']);
</script>
@@ -0,0 +1,216 @@
<template>
<view class="tab2-wrap p-x-32 p-t-16 p-b-24">
<view class="shop-card m-b-24" v-for="(v, i) in mockList" :key="v.id || i">
<view class="cover-wrap">
<image class="cover" :src="v.cover" mode="aspectFill" />
<view class="cover-mask" />
<view class="cover-content">
<view class="title lineOne">{{ v.name }}</view>
<view class="sub flex-center ju-flex-start m-t-10">
<view class="tag shrink">{{ v.level }}</view>
<view class="subText lineOne m-l-16">首次代理时间:{{ v.createTime }}</view>
</view>
</view>
</view>
<view class="body">
<view class="progress-row">
<view class="progress-label">目标达成:{{ v.progress }}%</view>
<view class="progress-bar">
<view class="progress" :style="{ width: `${v.progress}%` }" />
</view>
</view>
<view class="stats flex-between">
<view class="stat">
<view class="stat-title flex-between al-flex-center">
<view>店铺总收益</view>
<image class="stat-icon" src="/static/aiStore/earnings.png" mode="aspectFit" />
</view>
<view class="stat-value">¥{{ formatMoney(v.earnings) }}</view>
</view>
<view class="stat">
<view class="stat-title flex-between al-flex-center">
<view>绿色积分</view>
<image class="stat-icon" src="/static/aiStore/leaf.png" mode="aspectFit" />
</view>
<view class="stat-value leaf">{{ v.leaf }}</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref } from 'vue';
defineProps({
list: {
type: Array,
default: () => [],
},
source: {
type: Number,
default: 1,
},
});
const emit = defineEmits(['addCar', 'update', 'shipment']);
const mockList = ref([
{
id: 1,
name: '卓玛阳光防断洗发水',
level: 'LV.3 超级店长',
createTime: '2026-03-09',
progress: 75,
earnings: 200,
leaf: 3200,
cover: '/static/home/img1.png',
},
{
id: 2,
name: '治山贡鸡源头旗舰店',
level: 'LV.2 高级店长',
createTime: '2026-02-18',
progress: 62,
earnings: 870,
leaf: 5600,
cover: '/static/home/5.png',
},
{
id: 3,
name: '有购精选生活馆',
level: 'LV.1 初级店长',
createTime: '2026-01-25',
progress: 48,
earnings: 126.5,
leaf: 2100,
cover: '/static/home/6.png',
},
]);
const formatMoney = (value) => {
const num = Number(value);
if (!Number.isFinite(num)) return '0.00';
return num.toFixed(2);
};
</script>
<style lang="scss" scoped>
.tab2-wrap {
box-sizing: border-box;
}
.shop-card {
background: #ffffff;
border-radius: 24rpx;
overflow: hidden;
box-shadow: 0 16rpx 40rpx rgba(25, 80, 215, 0.12);
}
.cover-wrap {
position: relative;
height: 220rpx;
}
.cover {
width: 100%;
height: 100%;
}
.cover-mask {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
background: linear-gradient(180deg, rgba(0, 0, 0, 0.12) 0%, rgba(0, 0, 0, 0.55) 100%);
}
.cover-content {
position: absolute;
left: 24rpx;
right: 24rpx;
bottom: 20rpx;
color: #ffffff;
}
.title {
font-size: 34rpx;
font-weight: 600;
letter-spacing: 0.5rpx;
}
.subText {
font-size: 22rpx;
opacity: 0.92;
}
.tag {
padding: 6rpx 16rpx;
border-radius: 999rpx;
font-size: 22rpx;
border: 1rpx solid rgba(255, 255, 255, 0.4);
background: rgba(255, 255, 255, 0.22);
box-sizing: border-box;
}
.body {
padding: 24rpx;
}
.progress-label {
font-size: 24rpx;
color: #5b6b8a;
margin-bottom: 12rpx;
}
.progress-bar {
height: 12rpx;
border-radius: 999rpx;
background: #e9eef8;
overflow: hidden;
}
.progress {
height: 100%;
border-radius: 999rpx;
background: linear-gradient(90deg, #2c63ff 0%, #ff8a00 100%);
}
.stats {
margin-top: 20rpx;
}
.stat {
width: 48%;
padding: 20rpx 22rpx 12rpx;
border-radius: 20rpx;
box-sizing: border-box;
background: #f7faff;
border: 1rpx solid #e6ecfb;
}
.stat-title {
font-size: 22rpx;
color: #5b6b8a;
}
.stat-icon {
width: 28rpx;
height: 28rpx;
}
.stat-value {
font-size: 42rpx;
font-weight: 700;
color: #ff4d3f;
margin-top: 10rpx;
}
.stat-value.leaf {
color: #12b76a;
}
</style>
+258
View File
@@ -0,0 +1,258 @@
<template>
<view class="tab2-wrap p-x-32 p-b-300">
<view
class="shop-card m-b-24"
v-for="(v, i) in renderList"
:key="v.id || i"
@tap="toListRecord(v)"
>
<view class="shop-card-inner">
<view class="shop-card-top">
<view class="shop-name lineOne">{{ v.name }}</view>
</view>
<view class="meta-row flex-between">
<view class="progress-row">
<view class="progress-bar">
<view
class="progress"
:style="{ width: `${calcProgressPercent(v)}%` }"
></view>
<view class="progress-percent">{{ formatProgressPercent(v) }}%</view>
</view>
</view>
<view class="first-time"
>首次代理时间:{{ sheep.$helper.timeFormat(v.createTime, 'yyyy-mm-dd hh:MM:ss') }}</view
>
</view>
<view class="stats flex-between">
<view class="stat">
<view class="stat-head flex-between">
<view class="stat-title">店铺总收益</view>
<image class="stat-icon" src="/static/aiStore/earnings.png" mode="aspectFit" />
</view>
<view class="stat-value">¥{{ $fen2yuan(v.earnings) }}</view>
</view>
<view class="stat">
<view class="stat-head flex-between">
<view class="stat-title">绿色积分</view>
<image class="stat-icon" src="/static/aiStore/leaf.png" mode="aspectFit" />
</view>
<view class="stat-value leaf">{{ v.leaf || 0 }}</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { computed } from 'vue';
import sheep from '@/sheep';
const props = defineProps({
list: {
type: Array,
default: () => [],
},
source: {
type: Number,
default: 1,
},
});
const emit = defineEmits(['addCar', 'update', 'shipment']);
const renderList = computed(() => (Array.isArray(props.list) ? props.list : []));
const calcProgressPercent = (item) => {
const totalRevenue = Number(item?.totalRevenue ?? item?.earnings) || 0;
const userPayPrice = Number(item?.userPayPrice) || 0;
if (userPayPrice <= 0 || totalRevenue <= 0) return 0;
const pct = (totalRevenue / userPayPrice) * 100;
if (!Number.isFinite(pct)) return 0;
return Math.max(0, Math.min(100, pct));
};
const formatProgressPercent = (item) => {
return calcProgressPercent(item).toFixed(2);
};
const toListRecord = (item) => {
const skuId = item?.skuId ?? '';
const url =
'/pages/index/listRecord' +
`?skuId=${encodeURIComponent(String(skuId))}`;
uni.navigateTo({ url });
};
</script>
<style lang="scss" scoped>
.tab2-wrap {
box-sizing: border-box;
}
.shop-card {
background: #ffffff;
border-radius: 24rpx;
overflow: hidden;
box-shadow: 0 16rpx 40rpx rgba(25, 80, 215, 0.12);
}
.shop-card-inner {
padding: 24rpx;
}
.shop-card-top {
align-items: flex-end;
}
.shop-name {
flex: 1;
font-size: 34rpx;
font-weight: 600;
color: #1b2b4b;
letter-spacing: 0.5rpx;
}
.meta-row {
margin-top: 16rpx;
align-items: center;
gap: 16rpx;
}
.first-time {
flex-shrink: 0;
font-size: 22rpx;
color: #5b6b8a;
}
.progress-row {
flex: 1;
min-width: 180rpx;
}
.cover-wrap {
position: relative;
height: 220rpx;
}
.cover {
width: 100%;
height: 100%;
}
.cover-mask {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
background: linear-gradient(180deg, rgba(0, 0, 0, 0.12) 0%, rgba(0, 0, 0, 0.55) 100%);
}
.cover-content {
position: absolute;
left: 24rpx;
right: 24rpx;
bottom: 20rpx;
color: #ffffff;
}
.title {
font-size: 34rpx;
font-weight: 600;
letter-spacing: 0.5rpx;
}
.subText {
font-size: 22rpx;
opacity: 0.92;
}
.tag {
padding: 6rpx 16rpx;
border-radius: 999rpx;
font-size: 22rpx;
border: 1rpx solid rgba(255, 255, 255, 0.4);
background: rgba(255, 255, 255, 0.22);
box-sizing: border-box;
}
.body {
padding: 24rpx;
}
.progress-label {
font-size: 24rpx;
color: #5b6b8a;
margin-bottom: 12rpx;
}
.progress-bar {
position: relative;
height: 15rpx;
border-radius: 999rpx;
background: linear-gradient(90deg, #2c63ff 0%, #ff3b30 100%);
overflow: hidden;
}
.progress {
height: 13rpx;
margin: 1rpx;
border-radius: 999rpx;
background: rgba(255, 255, 255, 0.92);
}
.progress-percent {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
font-size: 18rpx;
font-weight: 600;
color: rgba(27, 43, 75, 0.92);
line-height: 1;
pointer-events: none;
text-shadow: 0 0 6rpx rgba(255, 255, 255, 0.9);
}
.stats {
margin-top: 20rpx;
}
.stat {
width: 48%;
padding: 20rpx 22rpx 12rpx;
border-radius: 20rpx;
box-sizing: border-box;
background: #f7faff;
border: 1rpx solid #e6ecfb;
}
.stat-head {
gap: 12rpx;
}
.stat-title {
font-size: 22rpx;
color: #5b6b8a;
}
.stat-icon {
width: 28rpx;
height: 28rpx;
}
.stat-value {
font-size: 42rpx;
font-weight: 700;
color: #ff4d3f;
margin-top: 10rpx;
}
.stat-value.leaf {
color: #12b76a;
}
</style>
+542 -269
View File
@@ -1,304 +1,577 @@
<!-- 首页,支持店铺装修 -->
<template>
<s-pages title="首页" :showLeftButton="false">
<view class="pagesIndex">
<s-custom-navbarIndex />
<view class="pages">
<s-banner v-if="template?.components[0]?.property.items?.length" :data="template.components[0].property"
:styles="template.components[0].property.style" />
<!-- 文字滚动 -->
<view class="noticeBar flex-center bg24 m-b-22" v-if="informText">
<s-layout title="首页" :showLeftButton="false" tabbar="/pages/index/index" navPreset="light">
<template #navRight>
<modeSwitch />
</template>
<view class="pagesIndex">
<view class="index-header">
<view class="index-header__left">
<view class="index-header__title">康源家园</view>
<view class="index-header__subtitle">AI店铺 · 一人店铺 · 共建共享</view>
</view>
<view class="index-notice-btn" @click="goNotice"></view>
</view>
<view class="pageContent">
<view class="floating-search-wrap">
<view class="floating-search" @click="goSearch">
<view class="floating-search-left">
<image
class="floating-search-icon_333"
src="/static/icon/search1.png"
mode="scaleToFill"
/>
<view class="floating-search-placeholder">搜索想要的商品</view>
</view>
<view class="floating-search-btn">
<image
class="floating-search-icon_fff"
src="/static/icon/search1.png"
mode="scaleToFill"
/>
</view>
</view>
</view>
<view class="pages">
<!-- <s-custom-navbarIndex /> -->
<view class="notice-card" v-if="mesArr.length">
<view class="notice-marquee-viewport">
<view
class="notice-marquee-track"
:class="{ 'is-scroll': mesArr.length > 1 }"
:style="mesArr.length > 1 ? { '--marquee-duration': marqueeDuration } : {}"
>
<view class="notice-marquee-content">
<view
v-for="(line, i) in mesArr"
:key="line.id || i"
class="notice-item notice-marquee-item flex-center h100"
>
<view class="notice-icon flex-center shrink">
<uni-icons type="person-filled" color="#2556EC" size="16" />
</view>
<view class="notice-text lineOne" v-html="line.messageContent"></view>
</view>
</view>
<view class="notice-marquee-content" v-if="mesArr.length > 1" aria-hidden="true">
<view
v-for="(line, i) in mesArr"
:key="`dup-${line.id || i}`"
class="notice-item notice-marquee-item flex-center h100"
>
<view class="notice-icon flex-center shrink">
<uni-icons type="person-filled" color="#2556EC" size="16" />
</view>
<view class="notice-text lineOne" v-html="line.messageContent"></view>
</view>
</view>
</view>
</view>
</view>
<s-banner
v-if="template?.components[0]?.property.items?.length"
:data="template.components[0].property"
:styles="template.components[0].property.style"
/>
<!-- 文字滚动 -->
<!-- <view class="noticeBar flex-center bg24 m-b-22" v-if="informText">
<image class="noticeImg shrink" src="/static/index/notice.png" mode="scaleToFill" />
<uni-notice-bar class="flex1" scrollable background-color="#ffffff" :text="informText"
color="#333333" :speed="100" />
</view>
<!-- <view class="navList flex-center ju-between">
</view> -->
<!-- <view class="ai-store-entry bg24" @click="goAiStore">ai店铺</view> -->
<!-- <view class="navList flex-center ju-between">
<view v-for="(v, i) in nav" :key="i" class="navItem flex-center flex-column" @click="go(v.url)">
<image class="navImg shrink" :src="`/static/index/${v.icon}`" mode="scaleToFill" />
<view class="size26 f500">{{ v.title }}</view>
</view>
</view> -->
<view class="activeList flex-row wrap ju-between" v-if="activeList?.length">
<view class="activeItem" :style="{
height: 160 + 'rpx',
width: `${activeList?.length === 1
? '100%'
: activeList?.length === 2
? 'calc((100% - 16rpx) / 2)'
: i === 0
? '100%'
: 'calc((100% - 16rpx) / 2)'
}`,
}" v-for="(v, i) in activeList" :key="i" @click="go(v)">
<image :src="sheep.$url.cdn(v.bannerImage)" mode="scaleToFill" />
</view>
</view>
</view>
<su-sticky top="100rpx">
<view class="goodsIndex">
<goods :list="tagList" v-if="tagList?.length" />
</view>
</su-sticky>
</view>
</s-pages>
<!-- 暂时废弃 -->
<!-- <view class="activeList flex-row wrap ju-between" v-if="activeList?.length">
<view
class="activeItem"
:style="{
height: 160 + 'rpx',
width: `${
activeList?.length === 1
? '100%'
: activeList?.length === 2
? 'calc((100% - 16rpx) / 2)'
: i === 0
? '100%'
: 'calc((100% - 16rpx) / 2)'
}`,
}"
v-for="(v, i) in activeList"
:key="i"
@click="go(v)"
>
<image :src="sheep.$url.cdn(v.bannerImage)" mode="scaleToFill" />
</view>
</view> -->
</view>
<view class="goodsIndex">
<goods :list="tagList" :defaultTabName="defaultTabName" v-if="tagList?.length" />
</view>
</view>
</view>
</s-layout>
</template>
<script setup>
import {
ref,
computed
} from 'vue';
import {
onLoad,
onPageScroll,
onPullDownRefresh
} from '@dcloudio/uni-app';
import goods from '@/components/goods/goods.vue';
import sheep from '@/sheep';
import $share from '@/sheep/platform/share';
import * as api from '@/sheep/api/index/index';
let template = ref({
page: {
backgroundColor: '#F2F4F7',
padding: '0 32rpx',
boxSiziong: 'border-box',
},
navigationBar: {},
components: [{
id: 'Banner',
property: {
autoplay: true,
indicator: 'number',
interval: 3000,
circular: true,
indicatorDots: false,
indicatorColor: '#D6D6D6', //点颜色
indicatorActiveColor: '#FE4246', //当前点颜色
items: [],
style: {
bgType: 'color',
bgColor: '#fff',
margin: '12rpx 0rpx',
marginBottom: '42rpx',
borderRadius: '24rpx',
height: '240rpx',
},
bgColor: '',
bgType: 'color',
marginBottom: 8,
type: 'default',
},
},],
});
let nav = ref([
{
icon: 'i1.png',
title: '大健康',
url: '',
},
{
icon: 'i2.png',
title: '大农业',
url: '',
},
{
icon: 'i3.png',
title: '大文旅',
url: '',
},
{
icon: 'i4.png',
title: '本地生活',
url: '',
},
{
icon: 'i5.png',
title: '数据处理',
url: '',
},
{
icon: 'i6.png',
title: '跨境电商',
url: '',
},
]);
import { ref, computed } from 'vue';
import { onLoad, onShow, onPullDownRefresh } from '@dcloudio/uni-app';
import goods from '@/components/goods/goods.vue';
import modeSwitch from '@/components/mode_switch/mode_switch.vue';
import sheep from '@/sheep';
import $share from '@/sheep/platform/share';
import * as api from '@/sheep/api/index/index';
import * as aiApi from '@/sheep/api/ai/index';
const HOME_DEFAULT_TAB_STORAGE_KEY = 'home.goods.defaultTabName';
const defaultTabName = ref('');
let template = ref({
page: {
backgroundColor: '#F2F4F7',
padding: '0 32rpx',
boxSiziong: 'border-box',
},
navigationBar: {},
components: [
{
id: 'Banner',
property: {
autoplay: true,
indicator: 'number',
interval: 3000,
circular: true,
indicatorDots: false,
indicatorColor: '#D6D6D6', //点颜色
indicatorActiveColor: '#FE4246', //当前点颜色
items: [],
style: {
bgType: 'color',
bgColor: '#fff',
margin: '12rpx 0rpx',
marginBottom: '42rpx',
borderRadius: '24rpx',
height: '240rpx',
},
bgColor: '',
bgType: 'color',
marginBottom: 8,
type: 'default',
},
},
],
});
const getBanner = () => {
api.getbannerlist({
position: 1,
}).then((res) => {
let data = res.data;
template.value.components[0].property.items = data;
});
};
const getBanner = () => {
api
.getbannerlist({
position: 1,
})
.then((res) => {
let data = res.data;
template.value.components[0].property.items = data;
});
};
// 商品标签列表
let tagList = ref([]);
const getproducttaglist = () => {
api.getproducttaglist({
categoryId: 1,
}).then((res) => {
tagList.value = res.data;
});
};
// 消息通知
let informText = ref('');
const getnotification = () => {
api.getnotification({}).then((res) => {
if (res?.code === 0) {
let data = res.data;
if (!data?.length) return;
// 拼接文案content
informText.value = data.map((item) => item.content).join(' ');
}
});
};
// 活动banner
let activeList = ref([]);
// 列数
let activeCol = ref(2);
const getappbanner = () => {
api.getappbanner({}).then((res) => {
if (res.data) {
activeList.value = res.data.list;
activeCol.value = res.data.bannerDisplayNum;
}
});
};
const getData = () => {
// banner
getBanner();
// 标签列表
getproducttaglist();
getnotification();
getappbanner();
};
onLoad((options) => {
getData();
// #ifdef MP
// 小程序识别二维码
if (options.scene) {
const sceneParams = decodeURIComponent(options.scene).split('=');
options[sceneParams[0]] = sceneParams[1];
}
// #endif
// 商品标签列表
let tagList = ref([]);
const getproducttaglist = () => {
api
.getproducttaglist({
categoryId: 1,
})
.then((res) => {
tagList.value = [res.data[res.data.length-1]];
});
};
// 消息通知
let informText = ref('');
const getnotification = () => {
api.getnotification({}).then((res) => {
if (res?.code === 0) {
let data = res.data;
if (!data?.length) return;
// 拼接文案content
informText.value = data.map((item) => item.content).join(' ');
}
});
};
// 活动banner
let activeList = ref([]);
// 列数
let activeCol = ref(2);
const getappbanner = () => {
api.getappbanner({}).then((res) => {
if (res.data) {
activeList.value = res.data.list;
activeCol.value = res.data.bannerDisplayNum;
}
});
};
// 预览模板
// if (options.templateId) {
// sheep.$store('app').init(options.templateId);
// }
const mesArr = ref([]);
const marqueeDuration = computed(() => {
const n = Array.isArray(mesArr.value) ? mesArr.value.length : 0;
const seconds = Math.max(14, n * 2);
return `${seconds}s`;
});
// 解析分享信息
if (options.spm) {
$share.decryptSpm(options.spm);
}
const getMessageList = async () => {
const res = await aiApi.getMessageList({ pageNo: 1, pageSize: 10 }).catch(() => ({ code: -1 }));
mesArr.value = res?.code === 0 ? res?.data || [] : [];
};
// 进入指定页面(完整页面路径)
if (options.page) {
sheep.$router.go(decodeURIComponent(options.page));
}
});
//跳转浏览器
const openExternal = (url) => {
if (!url) return;
if (typeof plus !== 'undefined' && plus.runtime && typeof plus.runtime.openURL === 'function') {
plus.runtime.openURL(url);
return;
}
if (typeof window !== 'undefined' && typeof window.open === 'function') {
window.open(url, '_blank');
return;
}
};
const go = (e) => {
// console.log(e);
if (!e.linkUrl) {
uni.showToast({
title: '功能开发中, 敬请期待',
icon: 'none',
});
return;
} else if (e.title === '华贸专区') {
openExternal(e.linkUrl);
} else {
uni.navigateTo({
url: e.linkUrl,
});
}
};
const getData = () => {
// banner
getBanner();
// 标签列表
getproducttaglist();
getnotification();
getappbanner();
getMessageList();
};
onLoad((options) => {
getData();
// #ifdef MP
// 小程序识别二维码
if (options.scene) {
const sceneParams = decodeURIComponent(options.scene).split('=');
options[sceneParams[0]] = sceneParams[1];
}
// #endif
// 下拉刷新
onPullDownRefresh(() => {
// sheep.$store('app').init();
getData();
setTimeout(function () {
uni.stopPullDownRefresh();
}, 1000);
});
// 预览模板
// if (options.templateId) {
// sheep.$store('app').init(options.templateId);
// }
onPageScroll(() => { });
// 解析分享信息
if (options.spm) {
$share.decryptSpm(options.spm);
}
// 进入指定页面(完整页面路径)
if (options.page) {
sheep.$router.go(decodeURIComponent(options.page));
}
});
onShow(() => {
const next = uni.getStorageSync(HOME_DEFAULT_TAB_STORAGE_KEY);
defaultTabName.value = next ? String(next) : '';
if (next) uni.removeStorageSync(HOME_DEFAULT_TAB_STORAGE_KEY);
const userStore = sheep.$store('user');
if (userStore?.isLogin) {
userStore.getInfo();
}
});
//跳转浏览器
const openExternal = (url) => {
if (!url) return;
if (typeof plus !== 'undefined' && plus.runtime && typeof plus.runtime.openURL === 'function') {
plus.runtime.openURL(url);
return;
}
if (typeof window !== 'undefined' && typeof window.open === 'function') {
window.open(url, '_blank');
return;
}
};
const go = (e) => {
// console.log(e);
if (!e.linkUrl) {
uni.showToast({
title: '功能开发中, 敬请期待',
icon: 'none',
});
return;
} else if (e.title === '华贸专区') {
openExternal(e.linkUrl);
} else {
uni.navigateTo({
url: e.linkUrl,
});
}
};
const goAiStore = () => {
uni.navigateTo({
url: '/pages/index/aiStore',
});
};
const goSearch = () => {
sheep.$router.go('/pages/public/search');
};
const goNotice = () => {
uni.showToast({
title: '功能开发中, 敬请期待',
icon: 'none',
});
};
// 下拉刷新
onPullDownRefresh(() => {
// sheep.$store('app').init();
getData();
setTimeout(function () {
uni.stopPullDownRefresh();
}, 1000);
});
</script>
<style scoped lang="scss">
.pages {
padding: 0 32rpx;
box-sizing: border-box;
}
.pages {
padding: 0 32rpx;
box-sizing: border-box;
}
.noticeBar {
background-color: #fff;
border-radius: 12rpx;
overflow: hidden;
padding-left: 12rpx;
box-sizing: border-box;
}
.noticeBar {
background-color: #fff;
border-radius: 12rpx;
overflow: hidden;
padding-left: 12rpx;
box-sizing: border-box;
}
.noticeImg {
width: 52rpx;
height: 52rpx;
}
.noticeImg {
width: 52rpx;
height: 52rpx;
}
:deep(.uni-noticebar) {
height: 92rpx;
border-radius: 12rpx;
overflow: hidden;
margin: 0;
font-weight: 500;
}
.notice-card {
padding: 20rpx 0 10rpx;
}
.navList {
margin-top: 40rpx;
margin-bottom: 52rpx;
.notice-item {
height: 50rpx;
padding: 0 20rpx;
border-radius: 999rpx;
background: rgba(242, 242, 242, 0.95);
}
.navItem {
width: 120rpx;
}
.notice-icon {
width: 34rpx;
height: 34rpx;
border-radius: 50%;
background: rgba(37, 86, 236, 0.12);
margin-right: 16rpx;
}
.navImg {
width: 84rpx;
height: 84rpx;
margin-bottom: 12rpx;
}
}
.notice-text {
width: 300rpx;
font-size: 22rpx;
color: #111111;
line-height: 50rpx;
}
/* .noticeBar{
.notice-marquee-viewport {
overflow: hidden;
height: 50rpx;
display: flex;
align-items: center;
border-radius: 30rpx;
}
.notice-marquee-track {
display: inline-flex;
align-items: center;
transform: translateX(0);
will-change: transform;
&.is-scroll {
animation: notice-marquee-move var(--marquee-duration, 16s) linear infinite;
}
}
.notice-marquee-content {
display: inline-flex;
align-items: center;
flex-shrink: 0;
}
.notice-marquee-item {
flex-shrink: 0;
margin-right: 20rpx;
}
@keyframes notice-marquee-move {
0% {
transform: translateX(0);
}
100% {
transform: translateX(-50%);
}
}
.ai-store-entry {
padding: 24rpx 28rpx;
margin-bottom: 22rpx;
border-radius: 24rpx;
font-size: 28rpx;
font-weight: 600;
color: #333333;
}
:deep(.uni-noticebar) {
height: 92rpx;
border-radius: 12rpx;
overflow: hidden;
margin: 0;
font-weight: 500;
}
.navList {
margin-top: 40rpx;
margin-bottom: 52rpx;
.navItem {
width: 120rpx;
}
.navImg {
width: 84rpx;
height: 84rpx;
margin-bottom: 12rpx;
}
}
/* .noticeBar{
border-radius: 12rpx;
overflow: hidden;
} */
.activeList {
.activeItem {
// width: calc((100% - 10rpx) / 2 - 10rpx);
margin-bottom: 16rpx;
.activeList {
.activeItem {
// width: calc((100% - 10rpx) / 2 - 10rpx);
margin-bottom: 16rpx;
image {
width: 100%;
height: 100%;
}
}
}
image {
width: 100%;
height: 100%;
}
}
}
.pagesIndex {
position: relative;
padding-top: 480rpx;
// background: linear-gradient(135deg, #2c8cfa 0%, #3d5efb 100%);
background-image: url('../../static/index/index_bg.jpeg');
background-size: 100% auto;
background-repeat: no-repeat;
background-position: center -20rpx;
.pageContent {
border-radius: 20rpx 20rpx 0 0;
position: relative;
padding-top: 50rpx;
background: #fff;
}
}
.pagesIndex {
position: relative;
}
</style>
.index-header {
position: absolute;
top: 0;
left: 0;
right: 0;
z-index: 20;
padding: calc(env(safe-area-inset-top) + 60rpx) 52rpx 0 52rpx;
display: flex;
align-items: center;
justify-content: space-between;
}
.index-header__left {
min-width: 0;
}
.index-header__title {
font-size: 44rpx;
line-height: 52rpx;
font-weight: 700;
color: #fff;
}
.index-header__subtitle {
margin-top: 10rpx;
font-size: 26rpx;
line-height: 34rpx;
color: rgba(255, 255, 255, 0.88);
}
.index-notice-btn {
position: relative;
width: 44rpx;
height: 44rpx;
background-image: url('/static/icon/ notice.png');
background-size: 100% 100%;
background-repeat: no-repeat;
background-position: center;
flex: 0 0 auto;
}
.floating-search-wrap {
position: absolute;
top: -50rpx;
left: 0;
width: 100%;
padding: 0 32rpx;
box-sizing: border-box;
z-index: 10;
}
.floating-search {
height: 88rpx;
width: 100%;
background: #ffffff;
border-radius: 88rpx;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 14rpx 0 22rpx;
box-sizing: border-box;
box-shadow: 0 8rpx 22rpx rgba(38, 107, 246, 0.55);
}
.floating-search-left {
display: flex;
align-items: center;
min-width: 0;
}
.floating-search-dot {
width: 28rpx;
height: 28rpx;
border-radius: 28rpx;
border: 4rpx solid #ffffff;
background: #ffffff;
box-sizing: border-box;
flex-shrink: 0;
}
.floating-search-placeholder {
margin-left: 16rpx;
color: #b8bcc6;
font-size: 28rpx;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.floating-search-btn {
width: 64rpx;
height: 64rpx;
border-radius: 64rpx;
padding: 0 20rpx;
background: linear-gradient(135deg, var(--primary-grad-start) 0%, var(--primary-grad-end) 100%);
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.floating-search-icon_fff {
width: 42rpx;
height: 42rpx;
filter: brightness(0) invert(1);
}
.floating-search-icon_333 {
width: 32rpx;
height: 32rpx;
}
</style>
+312
View File
@@ -0,0 +1,312 @@
<template>
<s-pages title="列表记录" navPreset="light">
<template #navRight>
<view class="share-btn" @tap="onShare">一键分享</view>
</template>
<view class="list-record-page">
<card_mescroll ref="cardPages" @upCallback="getList" :height="scrollHeight" :pageSize="pageSize">
<view class="hero">
<image class="hero-img" :src="cover || '/static/home/bc.png'" mode="aspectFill" />
</view>
<view class="record-list">
<view class="record-card" v-for="(item, i) in recordList" :key="item.id || i">
<view class="record-head flex-between">
<view class="record-title lineOne">{{ item.title }}</view>
<view class="record-status" :class="`status-${item.status}`">{{ item.statusText }}</view>
</view>
<view class="record-progress">
<view class="progress-bar">
<view class="progress" :style="{ width: `${item.progress}%` }"></view>
<view class="progress-percent">{{ formatPercent(item.progress) }}%</view>
</view>
</view>
<view class="record-meta">
<view class="meta-row flex-row-end">
<view class="record-total-inline">
<!-- <view class="total-price">¥{{ formatMoney(item.total) }}</view> -->
</view>
</view>
<view class="meta-row flex-between">
<view class="record-time">下单时间:{{ item.time }}</view>
<view class="record-qty">数量 {{ item.qty }}</view>
</view>
</view>
</view>
</view>
</card_mescroll>
</view>
</s-pages>
</template>
<script setup>
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import sheep from '@/sheep';
import { getAiShopPage } from '@/sheep/api/ai';
import card_mescroll from '@/components/card_pages/card_mescroll.vue';
const skuId = ref('');
const cover = ref('');
const recordList = ref([]);
const cardPages = ref(null);
const pageSize = 10;
const scrollHeight = ref('100%');
onLoad((query) => {
skuId.value = query?.skuId ?? query?.shopId ?? '';
const sysInfo = uni.getSystemInfoSync();
scrollHeight.value =
sysInfo.windowHeight - sysInfo.statusBarHeight - uni.upx2px(88) + 'px';
});
const formatPercent = (value) => {
const num = Number(value);
if (!Number.isFinite(num)) return '0.00';
return num.toFixed(2);
};
const formatRecordStatus = (status) => {
const map = {
1: '已上架',
2: '进行中',
3: '已完成',
};
return map[Number(status)] || '';
};
const mapOrderToRecord = (order) => {
const items = Array.isArray(order?.items) ? order.items : [];
const firstItem = items[0] || {};
const titleText = firstItem?.spuName || order?.no || '-';
const qty = Number(firstItem?.count ?? 0) || 0;
const status = Number(firstItem?.status ?? 0) || 0;
const statusText = formatRecordStatus(status);
const sumItemTotalPrice = items.reduce((acc, cur) => acc + (Number(cur?.totalPrice) || 0), 0);
const sumItemTotalRevenue = items.reduce((acc, cur) => acc + (Number(cur?.totalRevenue) || 0), 0);
const totalPrice = sumItemTotalPrice || (Number(order?.totalPrice ?? 0) || 0);
const totalRevenue = sumItemTotalRevenue || (Number(order?.totalRevenue ?? 0) || 0);
const progress =
totalPrice > 0
? Math.max(0, Math.min(100, (totalRevenue / totalPrice) * 100))
: 0;
const timeText = sheep.$helper?.timeFormat
? sheep.$helper.timeFormat(firstItem?.saleTime, 'yyyy-mm-dd hh:MM:ss')
: String(firstItem?.saleTime || '');
const payPriceFen = Number(order?.payPrice ?? 0) || 0;
const totalYuan = payPriceFen / 100;
return {
id: order?.id,
title: titleText,
status,
statusText,
progress,
qty,
time: timeText,
total: totalYuan,
};
};
const getList = async (mescroll) => {
if (!skuId.value) {
if (mescroll?.num === 1) recordList.value = [];
cardPages.value?.getState(true, 0);
return;
}
try {
const res = await getAiShopPage({
skuId: String(skuId.value),
pageNo: String(mescroll?.num || 1),
pageSize: String(mescroll?.size || pageSize),
}).catch(() => ({ code: -1 }));
if (res?.code !== 0) {
cardPages.value?.getState(false);
return;
}
const list = Array.isArray(res?.data?.list) ? res.data.list : [];
if (mescroll?.num === 1 && list.length) {
const firstItem = Array.isArray(list?.[0]?.items) ? list[0].items[0] : null;
const picUrl = firstItem?.picUrl || '';
if (picUrl) cover.value = sheep.$url.cdn(picUrl);
}
const mapped = list.map(mapOrderToRecord);
if (mescroll?.num === 1) recordList.value = [];
recordList.value = recordList.value.concat(mapped);
cardPages.value?.getState(true, list.length);
} catch (e) {
cardPages.value?.getState(false);
} finally {
}
};
const onShare = () => {
uni.showToast({ title: '分享功能开发中', icon: 'none' });
};
</script>
<style lang="scss" scoped>
:deep(.scon) {
overflow-y: hidden !important;
}
.list-record-page {
padding: 0 32rpx 32rpx;
min-height: 100%;
box-sizing: border-box;
}
.share-btn {
height: 56rpx;
padding: 0 18rpx;
border-radius: 18rpx;
background: rgba(255, 106, 74, 0.18);
color: #ff6a4a;
font-size: 24rpx;
display: flex;
align-items: center;
justify-content: center;
position: relative;
top: -2rpx;
}
.hero {
margin-top: 18rpx;
border-radius: 26rpx;
overflow: hidden;
background: #ffffff;
}
.hero-img {
width: 100%;
height: 340rpx;
display: block;
transform: 3s ease-in-out;
}
.record-list {
margin-top: 18rpx;
}
.record-card {
background: #ffffff;
border-radius: 24rpx;
padding: 24rpx;
margin-bottom: 18rpx;
box-shadow: 0 16rpx 40rpx rgba(0, 0, 0, 0.06);
}
.record-head {
align-items: center;
gap: 16rpx;
}
.record-title {
flex: 1;
font-size: 34rpx;
font-weight: 700;
color: #111111;
}
.record-status {
flex-shrink: 0;
font-size: 24rpx;
padding: 8rpx 16rpx;
border-radius: 999rpx;
line-height: 1;
color: #8a8a8a;
// background: #f3f4f6;
}
.status-1 {
color: #2563eb;
background: rgba(37, 99, 235, 0.1);
}
.status-2 {
color: #f97316;
background: rgba(249, 115, 22, 0.12);
}
.status-3 {
color: #16a34a;
background: rgba(22, 163, 74, 0.12);
}
.record-progress {
margin-top: 18rpx;
}
.progress-bar {
width: 60%;
height: 20rpx;
border-radius: 999rpx;
background: linear-gradient(90deg, #2c63ff 0%, #ff3b30 100%);
overflow: hidden;
position: relative;
}
.progress {
height: 13rpx;
margin: 3rpx;
border-radius: 999rpx;
background: rgba(255, 255, 255, 0.92);
}
.progress-percent {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
font-size: 18rpx;
font-weight: 600;
color: rgba(17, 17, 17, 0.9);
line-height: 1;
pointer-events: none;
text-shadow: 0 0 6rpx rgba(255, 255, 255, 0.9);
}
.record-meta {
margin-top: 18rpx;
display: flex;
flex-direction: column;
gap: 12rpx;
}
.meta-row {
align-items: baseline;
}
.record-total-inline {
display: flex;
align-items: baseline;
gap: 10rpx;
flex-shrink: 0;
}
.record-time {
font-size: 24rpx;
color: #111111;
flex: 1;
min-width: 0;
}
.record-qty {
font-size: 24rpx;
color: #333333;
}
.record-total {
margin-top: 18rpx;
align-items: baseline;
gap: 10rpx;
}
.total-price {
font-size: 34rpx;
font-weight: 800;
color: #ff3b30;
}
</style>
+484 -29
View File
@@ -1,71 +1,526 @@
<template>
<view class="start-page">
<image class="bg" :src="$url + 'home/startPage_yg.png'" mode="aspectFill" />
<view class="count-down" :class="{ enabled: canEnter }" @click.stop="onEnterClick">
{{ canEnter ? '进入' : `跳过 ${countDown}s` }}
<image v-if="USE_STATIC_START_PAGE" class="bg" src="/static/startPage.jpeg" mode="aspectFill" />
<video
v-if="!USE_STATIC_START_PAGE && bgSrc && isVideo"
class="bg"
:src="bgSrc"
autoplay
muted
:controls="false"
:show-fullscreen-btn="false"
:show-play-btn="false"
:show-center-play-btn="false"
:enable-progress-gesture="false"
:show-loading="true"
playsinline
webkit-playsinline
object-fit="cover"
@error="onMediaError"
@loadedmetadata="onVideoMetadata"
@canplay="onVideoReady"
@play="onVideoReady"
@timeupdate="onVideoTimeUpdate"
@ended="onVideoEnded"
@click="onMediaClick"
/>
<image
v-else-if="!USE_STATIC_START_PAGE && bgSrc && !isVideo"
class="bg"
:src="bgSrc"
mode="aspectFill"
@error="onMediaError"
@load="onImageLoaded"
@click="onMediaClick"
/>
<view
v-if="(USE_STATIC_START_PAGE || bgSrc) && mediaReady && countDown > 0 && !useNativeSkip"
class="count-down"
@click.stop="toHome"
>
<text class="count-down-text">{{ getSkipText() }}</text>
</view>
<view v-if="!USE_STATIC_START_PAGE && isLoading" class="loading-mask">
<view class="loading-box">
<view class="loading-spinner"></view>
<view class="loading-text">加载中...</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref, onMounted, onUnmounted } from 'vue'
import { ref, onMounted, onUnmounted, watch } from 'vue'
import * as IndexApi from '@/sheep/api/index/index'
import sheep from '@/sheep'
const countDown = ref(3)
let timer = null
const canEnter = ref(false)
const USE_STATIC_START_PAGE = false
onMounted(() => {
timer = setInterval(() => {
const DEFAULT_IMAGE_SECONDS = 3
const FIXED_VIDEO_SECONDS = 5
const bgSrc = ref('')
const jumpUrl = ref('')
const isVideo = ref(false)
const mediaReady = ref(false)
const isLoading = ref(false)
const useNativeSkip = ref(false)
let downloadToken = 0
let readyFallbackTimer = null
let countDownTimer = null
let jumpTimer = null
let videoCountdownBootTimer = null
let nativeSkipView = null
let nativeSkipViewId = ''
let plusReadyListenerBound = false
let lastVideoTime = 0
const appStore = sheep.$store('app')
const normalizeAppFileUrl = (path) => {
const p = String(path || '')
if (!p) return ''
if (/^https?:\/\//i.test(p)) return p
if (p.startsWith('file://')) return p
try {
if (typeof plus !== 'undefined' && plus?.io?.convertLocalFileSystemURL) {
const next = plus.io.convertLocalFileSystemURL(p)
return next || p
}
} catch (e) {}
if (p.startsWith('/')) return `file://${p}`
return p
}
const isVideoUrl = (url) => {
const u = String(url || '')
if (!u) return false
const clean = u.split('?')[0].split('#')[0]
return /\.(mp4|mov|m4v|webm|ogg)$/i.test(clean)
}
const fetchStartPage = async () => {
try {
const res = await IndexApi.getstartpage({})
if (res?.code !== 0) return false
const data = res?.data || {}
const media = String(data?.picUrl || '').trim()
const url = String(data?.url || '').trim()
if (!media) return false
jumpUrl.value = url
isVideo.value = isVideoUrl(media)
if (isVideo.value && typeof plus !== 'undefined') {
const token = (downloadToken += 1)
const downloadPromise = new Promise((resolve) => {
uni.downloadFile({
url: media,
success: (r) => resolve(r?.statusCode === 200 ? r.tempFilePath : ''),
fail: () => resolve(''),
})
})
downloadPromise.then((localPath) => {
const normalized = normalizeAppFileUrl(localPath)
if (!normalized) return
if (token !== downloadToken) return
if (mediaReady.value) return
bgSrc.value = normalized
})
const fastLocal = await Promise.race([
downloadPromise,
new Promise((resolve) => setTimeout(() => resolve(''), 1500)),
])
bgSrc.value = normalizeAppFileUrl(fastLocal) || media
return true
}
bgSrc.value = media
return true
} catch (e) {
return false
}
}
function onMediaError() {
toHome()
}
const countDown = ref(0)
const getSkipText = () => {
const s = Number(countDown.value) || 0
return s > 0 ? `跳过 ${s}s` : '跳过'
}
function closeNativeSplashIfNeeded() {
try {
if (typeof plus !== 'undefined' && plus?.navigator?.closeSplashscreen) {
plus.navigator.closeSplashscreen()
}
} catch (e) {}
}
function destroyNativeSkipView() {
try {
if (!nativeSkipView) return
if (typeof nativeSkipView.hide === 'function') nativeSkipView.hide()
if (typeof nativeSkipView.close === 'function') nativeSkipView.close()
} catch (e) {}
nativeSkipView = null
nativeSkipViewId = ''
useNativeSkip.value = false
}
function ensureNativeSkipView() {
try {
if (typeof plus === 'undefined') return
if (nativeSkipView) return
const screenWidth = Number(plus?.screen?.resolutionWidth || 0)
if (!screenWidth) return
const pxPerRpx = screenWidth / 750
const widthPx = Math.round(pxPerRpx * 180)
const heightPx = Math.round(pxPerRpx * 64)
const rightPx = Math.round(pxPerRpx * 60)
const topPx = Math.round(pxPerRpx * 100)
const leftPx = Math.max(0, screenWidth - rightPx - widthPx)
const radiusPx = Math.round(heightPx / 2)
const fontPx = Math.round(pxPerRpx * 28)
nativeSkipViewId = `start-page-skip-${Date.now()}-${Math.floor(Math.random() * 1e6)}`
nativeSkipView = new plus.nativeObj.View(
nativeSkipViewId,
{
top: `${topPx}px`,
left: `${leftPx}px`,
width: `${widthPx}px`,
height: `${heightPx}px`,
},
[]
)
nativeSkipView.drawRect(
{
color: 'rgba(0,0,0,0.4)',
radius: `${radiusPx}px`,
},
{
top: '0px',
left: '0px',
width: `${widthPx}px`,
height: `${heightPx}px`,
},
'bg'
)
nativeSkipView.addEventListener('click', () => {
toHome()
})
nativeSkipView.drawText(
getSkipText(),
{
top: '0px',
left: '0px',
width: `${widthPx}px`,
height: `${heightPx}px`,
},
{
size: `${fontPx}px`,
color: '#ffffff',
align: 'center',
verticalAlign: 'middle',
},
'text'
)
try {
const wv = typeof plus?.webview?.currentWebview === 'function' ? plus.webview.currentWebview() : null
if (wv && typeof wv.append === 'function') {
wv.append(nativeSkipView)
}
} catch (e) {}
nativeSkipView.show()
useNativeSkip.value = true
} catch (e) {
destroyNativeSkipView()
}
}
function updateNativeSkipText() {
try {
if (!nativeSkipView) return
const screenWidth = Number(plus?.screen?.resolutionWidth || 0)
if (!screenWidth) return
const pxPerRpx = screenWidth / 750
const widthPx = Math.round(pxPerRpx * 180)
const heightPx = Math.round(pxPerRpx * 64)
const fontPx = Math.round(pxPerRpx * 28)
nativeSkipView.drawText(
getSkipText(),
{
top: '0px',
left: '0px',
width: `${widthPx}px`,
height: `${heightPx}px`,
},
{
size: `${fontPx}px`,
color: '#ffffff',
align: 'center',
verticalAlign: 'middle',
},
'text'
)
} catch (e) {}
}
function clearTimers() {
if (readyFallbackTimer) clearTimeout(readyFallbackTimer)
readyFallbackTimer = null
if (countDownTimer) clearInterval(countDownTimer)
countDownTimer = null
if (jumpTimer) clearTimeout(jumpTimer)
jumpTimer = null
if (videoCountdownBootTimer) clearTimeout(videoCountdownBootTimer)
videoCountdownBootTimer = null
destroyNativeSkipView()
}
function startCountDown(seconds) {
const s = Math.max(1, Math.floor(Number(seconds) || 0))
countDown.value = s
if (countDownTimer) clearInterval(countDownTimer)
countDownTimer = setInterval(() => {
if (countDown.value <= 1) {
//点击进入
// countDown.value = 0
// canEnter.value = true
clearInterval(timer)
//直接进入
if (countDownTimer) clearInterval(countDownTimer)
countDownTimer = null
toHome()
return
}
countDown.value -= 1
}, 1000)
}
function scheduleJumpAfter(seconds) {
const ms = Math.max(0, Math.floor(Number(seconds) * 1000))
if (jumpTimer) clearTimeout(jumpTimer)
jumpTimer = setTimeout(() => {
toHome()
}, ms)
}
function onImageLoaded() {
if (mediaReady.value) return
mediaReady.value = true
isLoading.value = false
closeNativeSplashIfNeeded()
startCountDown(DEFAULT_IMAGE_SECONDS)
scheduleJumpAfter(DEFAULT_IMAGE_SECONDS + 0.2)
}
function onVideoReady() {
if (!mediaReady.value) {
mediaReady.value = true
isLoading.value = false
closeNativeSplashIfNeeded()
}
if (countDownTimer) return
if (videoCountdownBootTimer) return
videoCountdownBootTimer = setTimeout(() => {
videoCountdownBootTimer = null
if (countDownTimer) return
startCountDown(FIXED_VIDEO_SECONDS)
scheduleJumpAfter(FIXED_VIDEO_SECONDS + 0.2)
}, 300)
}
function onVideoMetadata(e) {
if (videoCountdownBootTimer) {
clearTimeout(videoCountdownBootTimer)
videoCountdownBootTimer = null
}
if (!mediaReady.value) {
mediaReady.value = true
isLoading.value = false
closeNativeSplashIfNeeded()
}
startCountDown(FIXED_VIDEO_SECONDS)
scheduleJumpAfter(FIXED_VIDEO_SECONDS + 0.2)
}
function onVideoTimeUpdate(e) {
const currentTime = Number(e?.detail?.currentTime || 0)
if (!Number.isFinite(currentTime) || currentTime <= 0) return
const loopDetected = lastVideoTime > 0.4 && currentTime + 0.2 < lastVideoTime
lastVideoTime = currentTime
if (loopDetected) {
toHome()
return
}
if (currentTime + 0.12 >= FIXED_VIDEO_SECONDS) {
toHome()
}
}
function onVideoEnded() {
toHome()
}
onMounted(() => {
closeNativeSplashIfNeeded()
if (USE_STATIC_START_PAGE) {
startCountDown(DEFAULT_IMAGE_SECONDS)
scheduleJumpAfter(DEFAULT_IMAGE_SECONDS + 0.2)
return
}
isLoading.value = true
fetchStartPage().then((ok) => {
if (!ok) {
toHome()
return
}
readyFallbackTimer = setTimeout(() => {
if (mediaReady.value) return
toHome()
}, isVideo.value ? 3500 : 2000)
})
})
onUnmounted(() => {
if (timer) clearInterval(timer)
clearTimers()
})
function toHome() {
uni.reLaunch({
url: '/pages/index/index'
})
clearTimers()
isLoading.value = false
const url = appStore?.bizMode === 'merchant' ? '/pages/merchant/pickupList' : '/pages/index/index'
uni.reLaunch({ url })
}
function onEnterClick() {
if (!canEnter.value) return
toHome()
function onMediaClick() {
const url = String(jumpUrl.value || '').trim()
if (!url) return
if (/^https?:\/\//i.test(url)) {
uni.navigateTo({
url: `/pages/public/webview?url=${encodeURIComponent(url)}`,
})
return
}
if (url.startsWith('/pages/')) {
uni.navigateTo({ url })
return
}
}
watch(
[() => isVideo.value, () => countDown.value],
([v, s]) => {
if (!v || s <= 0) {
destroyNativeSkipView()
return
}
if (typeof plus !== 'undefined') {
ensureNativeSkipView()
updateNativeSkipText()
return
}
if (plusReadyListenerBound) return
plusReadyListenerBound = true
try {
if (typeof document !== 'undefined' && document?.addEventListener) {
document.addEventListener(
'plusready',
() => {
plusReadyListenerBound = false
if (isVideo.value && countDown.value > 0) {
ensureNativeSkipView()
updateNativeSkipText()
}
},
{ once: true }
)
}
} catch (e) {}
},
{ immediate: true }
)
</script>
<style lang="scss" scoped>
.start-page {
position: relative;
position: fixed;
inset: 0;
width: 100vw;
height: 100vh;
overflow: hidden;
background: #fff;
}
.bg {
width: 100%;
height: 100%;
position: absolute;
inset: 0;
width: 100vw;
height: 100vh;
z-index: 0;
}
.count-down {
position: absolute;
top: calc(env(safe-area-inset-top) + 100rpx);
right: 60rpx;
padding: 18rpx 20rpx;
height: 64rpx;
padding: 0 20rpx;
border-radius: 50rpx;
font-size: 28rpx;
line-height: 1;
line-height: 32rpx;
color: #fff;
background: rgba(0, 0, 0, 0.4);
z-index: 10;
z-index: 999999;
display: flex;
align-items: center;
justify-content: center;
}
.count-down.enabled {
// background: rgba(54, 110, 238, 0.85);
.count-down-text {
color: #fff;
font-size: 28rpx;
line-height: 32rpx;
}
.loading-mask {
position: absolute;
inset: 0;
z-index: 9998;
display: flex;
align-items: center;
justify-content: center;
background: rgba(255, 255, 255, 0.1);
}
.loading-box {
padding: 22rpx 26rpx;
border-radius: 16rpx;
background: rgba(0, 0, 0, 0.45);
display: flex;
align-items: center;
gap: 16rpx;
}
.loading-spinner {
width: 32rpx;
height: 32rpx;
border-radius: 50%;
border: 4rpx solid rgba(255, 255, 255, 0.35);
border-top-color: rgba(255, 255, 255, 0.95);
animation: spin 0.85s linear infinite;
}
.loading-text {
font-size: 26rpx;
color: #fff;
line-height: 32rpx;
}
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
</style>
+417 -91
View File
@@ -1,19 +1,18 @@
<template>
<view class="pages theme-ai">
<view class="bc">
<image src="/static/home/bc.png" mode="scaleToFill" />
<view class="bc" :style="bcStyle">
</view>
<view class="con" :style="{ paddingTop: paddingTop + 'px' }">
<view class="con_top flex-center ju-flex-start">
<view class="head_info">
<view class="head">
<view class="head head-upload-entry" @click="openAvatarCrop">
<image v-if="dataInfo?.avatar" :src="dataInfo?.avatar" mode="scaleToFill" />
<image v-else :src="`${$url}home/head.png`" mode="scaleToFill" />
</view>
</view>
<view class="con_info flex-between w100">
<view class="con_left">
<view class="con_name ju-flex-start">
<view class="con_name c_fff ju-flex-start">
{{ dataInfo?.nickname || '昵称' }}
<image
:src="`${$url}home/${dataInfo.type}.svg`"
@@ -35,26 +34,36 @@
</view>
</view>
</view>
<view class="card_money flex-center ju-between p-x-32" @click="go('/pages/home/wallet')">
<!-- <view
<view class="b_fff" style="border-radius: 20rpx;">
<view class="card_money flex-center ju-between p-x-32" @click="go('/pages/home/wallet')">
<!-- <view
class="card_money flex-center ju-between p-x-32"
@click="go('/pages/home/pointsDetail?type=5')"
> -->
<view>
<view class="flex-center ju-flex-start m-b-8">
<view class="line34 size28" style="margin-right: 18rpx">钱包</view>
<view class="moneyNum line36 size36">¥ {{ $fen2yuan(dataInfo.wallet || 0) }}</view>
<view>
<view class="flex-center ju-flex-start m-b-8">
<view class="line34 size28 m-r-18">钱包</view>
<view class="moneyNum line36 size36">¥ {{ $fen2yuan(dataInfo.wallet || 0) }}</view>
</view>
<!-- <view class="c_fff line34">邀请好友下单得奖励</view> -->
</view>
<!-- <view class="c_fff line34">邀请好友下单得奖励</view> -->
<!-- <view class="moneyBtn" @click="go('/pages/home/pointsDetail?type=5')">立即提现</view> -->
</view>
<!-- <view class="moneyBtn" @click="go('/pages/home/pointsDetail?type=5')">立即提现</view> -->
</view>
<view class="card3 flex-center ju-evenly color_5">
<view v-for="(v, i) in moneyArr" :key="i" class="center" @click="go(v.url)">
<view class="card3_num m-b-8"
>{{ dataInfo[v.value] }}<text>{{ v.unit }}</text></view
<view class="card3 flex-center ju-evenly color_5">
<view
v-for="(v, i) in moneyArr"
:key="i"
class="center card3_item"
:class="{ 'card3_item--split': i !== 0 }"
@click="go(v.url)"
>
<view>{{ v.name || 0 }}</view>
<view
class="card3_num m-b-8"
:style="{ color: v.color || '' }"
>{{ dataInfo[v.value] }}<text>{{ v.unit }}</text></view
>
<view class="size32">{{ v.name || 0 }}</view>
</view>
</view>
</view>
<view class="card card4 bg24">
@@ -101,16 +110,47 @@
</view>
</view>
</view>
<view
v-if="showThirdPartyServiceCard&&false"
class="card card5 third-party-card bg24"
>
<view class="card_title">第三方服务</view>
<view class="flex-center card5_con wrap ju-flex-start">
<view
class="flex-center flex-column card5_item"
v-for="(v, i) in thirdPartyServiceList"
:key="i"
@click="onThirdPartyServiceClick(v)"
>
<view class="card5_icon third-party-icon m-b-18 w_84 h_84">
<image :src="getThirdPartyIcon(v.icon)" mode="scaleToFill" />
</view>
<view class="card5_name size28 color_3">{{ v.name }}</view>
</view>
</view>
</view>
</view>
</view>
<view class="h_150" style="background-color: #f2f4f7;"/>
<cardTabber path="/pages/index/user" placeholder />
</template>
<script setup lang="ts">
<script setup>
import sheep from '@/sheep';
import { ref, reactive, onMounted, onUnmounted, getCurrentInstance, watch, nextTick } from 'vue';
import cardTabber from '@/components/card_tabber/card_tabber.vue';
import {
ref,
reactive,
onMounted,
onUnmounted,
getCurrentInstance,
watch,
nextTick,
computed,
} from 'vue';
import { onShow } from '@dcloudio/uni-app';
import { getWallet } from '@/sheep/api/home/pay';
import * as incrementApi from '@/sheep/api/increment';
import UserApi from '@/sheep/api/member/user';
import OrderApi from '@/sheep/api/trade/order';
let { proxy } = getCurrentInstance();
@@ -118,6 +158,11 @@
let sysInfo = uni.getSystemInfoSync();
let paddingTop = ref(20);
paddingTop.value = sysInfo.statusBarHeight + uni.upx2px(88);
const headerBgHeight = computed(() => `${paddingTop.value + uni.upx2px(320)}px`);
const bcStyle = computed(() => ({
height: headerBgHeight.value,
background: 'linear-gradient(135deg, #2c8cfa 0%, #3d5efb 100%)',
}));
let realStatus = ref(0); //是否已经实名认证
let agentLevelObj = {
2: 'home/igency_1.png',
@@ -142,26 +187,14 @@
name: '绿色积分',
value: 'point',
url: '/pages/home/pointsDetail?type=1',
color: '#0ED72C',
},
// {
// id: 2,
// name: '佣金',
// value: 'commission_num',
// unit: '元',
// url: '/pages/home/pointsDetail?type=2',
// },
// {
// id: 3,
// name: '代理收益',
// value: 'agency_income',
// unit: '元',
// url: '/pages/home/pointsDetail?type=3',
// },
{
id: 4,
name: '消费金',
value: 'consumptionGold',
url: '/pages/home/pointsDetail?type=4',
color: '#FE5200',
},
]);
let orderList = ref([
@@ -197,60 +230,262 @@
},
]);
let menuList = ref([
{
name: '邀请好友',
icon: 'home/icon1.png',
url: '/pages/home/share',
},
// {
// name: '邀请好友',
// icon: 'home/icon1.png',
// url: '/pages/home/share',
// },
{
name: '收货地址',
icon: 'home/icon2.png',
url: '/pages/user/address/list',
},
{
name: '联系客服',
icon: 'home/icon3.png',
url: '',
},
{
name: '意见反馈',
icon: 'home/icon4.png',
url: '/pages/home/feedback',
},
{
name: '我的收藏',
icon: 'home/icon5.png',
url: '/pages/user/goods-collect',
},
{
name: '我的收益',
icon: 'home/icon6.png',
url: '/pages/home/agency',
},
{
name: '我的社员',
icon: 'home/icon8.png',
url: '/pages/home/staff',
},
// {
// name: '联系客服',
// icon: 'home/icon3.png',
// url: '',
// },
// {
// name: '意见反馈',
// icon: 'home/icon4.png',
// url: '/pages/home/feedback',
// },
// {
// name: '我的收藏',
// icon: 'home/icon5.png',
// url: '/pages/user/goods-collect',
// },
// {
// name: '我的收益',
// icon: 'home/icon6.png',
// url: '/pages/home/agency',
// },
// {
// name: '我的社员',
// icon: 'home/icon8.png',
// url: '/pages/home/staff',
// },
{
name: '设置',
icon: 'home/icon7.png',
url: '/pages/public/setting',
},
]);
const LIQUIDATION_TYPE_META = {
2: {
name: '无双',
title: '无双',
icon: '/static/icon/web/wushuang.png',
keywords: ['无双'],
},
3: {
name: '华夏',
title: '华夏',
inlineIcon: true,
keywords: ['华夏'],
},
};
const matchChannelMeta = (channel) => {
const lt = Number(channel?.liquidationType);
if ([2, 3].includes(lt) && LIQUIDATION_TYPE_META[lt]) {
return { liquidationType: lt, meta: LIQUIDATION_TYPE_META[lt] };
}
const name = String(channel?.channelName || channel?.name || '').trim();
if (!name) return null;
for (const key of Object.keys(LIQUIDATION_TYPE_META)) {
const m = LIQUIDATION_TYPE_META[key];
const keywords = Array.isArray(m?.keywords) ? m.keywords : [];
if (keywords.some((kw) => name.includes(kw))) {
return { liquidationType: Number(key), meta: m };
}
}
return null;
};
const WUSHUANG_DEFAULT_STORE_ID = 5;
const resolveWushuangStoreId = () => WUSHUANG_DEFAULT_STORE_ID;
const buildWushuangStoreUrl = (fallbackBaseUrl) => {
const id = resolveWushuangStoreId();
if (!id) return '';
let base = String(fallbackBaseUrl || '').trim().replace(/`/g, '').trim();
const tail = `/web/#/pages/store/index?store_id=${id}`;
if (/^https?:\/\//i.test(base)) {
const cleanBase = base.replace(/\/+$/, '');
return cleanBase + tail;
}
return `https://shop.wushuange.com${tail}`;
};
const buildHuaxiaInlineIcon = () => {
const svg =
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 84 84">' +
'<circle cx="42" cy="42" r="42" fill="#18b37b"/>' +
'<text x="42" y="42" font-family="PingFang SC,Helvetica Neue,Microsoft YaHei,Arial,sans-serif" font-weight="700" font-size="30" fill="#ffffff" text-anchor="middle" dominant-baseline="middle">华夏</text>' +
'</svg>';
return 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svg);
};
const tradeChannelList = ref([]);
const fetchTradeChannels = async () => {
try {
const res = await incrementApi.getTradeChannelList();
if (res?.code === 0 && Array.isArray(res?.data)) {
tradeChannelList.value = res.data.filter((it) => Number(it?.status) === 1);
}
} catch (e) {}
};
const normalizeChannelUrl = (raw, liquidationType) => {
let base = String(raw || '').trim().replace(/`/g, '').trim();
if (!base) return '';
if (Number(liquidationType) === 2) {
return buildWushuangStoreUrl(base);
}
return base;
};
const showThirdPartyServiceCard = computed(
() => thirdPartyServiceList.value.length > 0,
);
const thirdPartyServiceList = computed(() => {
const list = [];
const added = new Set();
const channels = Array.isArray(tradeChannelList.value) ? tradeChannelList.value : [];
channels.forEach((it) => {
if (Number(it?.status) !== 1) return;
const matched = matchChannelMeta(it);
if (!matched) return;
const lt = matched.liquidationType;
const meta = matched.meta;
if (added.has(lt)) return;
let url = '';
if (lt !== 3) {
url = normalizeChannelUrl(it?.baseUrl || it?.url, lt);
if (!url) return;
}
added.add(lt);
const item = {
name: meta.name,
title: meta.title,
url,
liquidationType: lt,
channelId: it?.id ?? it?.channelId,
channelBaseUrl: String(it?.baseUrl || it?.url || '').trim(),
};
if (meta.inlineIcon) {
item.icon = buildHuaxiaInlineIcon();
} else if (meta.icon) {
item.icon = meta.icon;
}
list.push(item);
});
return list;
});
const getThirdPartyIcon = (icon) => {
const iconText = String(icon || '');
if (iconText.startsWith('data:') || iconText.startsWith('/')) {
return iconText;
}
return iconText;
};
const showModalAsync = (options) =>
new Promise((resolve) => {
uni.showModal({
...(options || {}),
success: (res) => resolve(res),
fail: () => resolve({ confirm: false, cancel: true }),
});
});
const pendingThirdPartyItem = ref(null);
const ensureRealNameOrRedirect = async (item) => {
if (Number(realStatus.value || dataInfo.value?.realStatus) === 1) return true;
pendingThirdPartyItem.value = item || null;
const res = await showModalAsync({
title: '实名认证提示',
content: '使用华夏服务需先完成实名认证,是否前往认证?',
confirmText: '去认证',
cancelText: '取消',
confirmColor: '#2c8cfa',
});
if (!res?.confirm) {
pendingThirdPartyItem.value = null;
return false;
}
uni.navigateTo({
url: '/pages/public/realname?status=0',
});
return false;
};
const openThirdPartyService = (item) => {
if (!item?.url) return;
const title = encodeURIComponent(item.title || item.name || '第三方服务');
const rawUrl = String(item.url || '').trim();
const targetUrl = encodeURIComponent(rawUrl);
const openWebview = () => {
uni.navigateTo({
url: `/pages/public/webview?title=${title}&url=${targetUrl}`,
});
};
if (typeof plus !== 'undefined' && plus?.runtime) {
openWebview();
return;
}
if (typeof window !== 'undefined' && typeof window.open === 'function') {
const opened = window.open(rawUrl, '_blank');
if (opened) return;
window.location.href = rawUrl;
return;
}
openWebview();
};
const onThirdPartyServiceClick = async (item) => {
if (!item) return;
const isHuaxia =
Number(item?.liquidationType) === 3 || String(item?.name || '') === '华夏';
if (isHuaxia) {
const ok = await ensureRealNameOrRedirect(item);
if (!ok) return;
const query = {};
if (item?.channelId != null && item?.channelId !== '') {
query.channelId = Number(item.channelId);
}
const regRes = await incrementApi
.checkHuaxiaRegister(query)
.catch(() => ({ code: -1 }));
if (regRes?.code !== 0) {
if (regRes?.msg) {
uni.showToast({ title: regRes.msg, icon: 'none' });
}
return;
}
const data = regRes?.data || {};
const url = typeof data === 'string'
? String(data).trim()
: String(data?.url || data?.redirectUrl || '').trim();
if (!url) {
uni.showToast({ title: '跳转链接为空', icon: 'none' });
return;
}
openThirdPartyService({ ...item, url });
return;
}
openThirdPartyService(item);
};
const goReal = () => {
uni.navigateTo({
url: '/pages/public/realname?status=' + realStatus.value,
// query: obj,
});
};
const go = (path, obj) => {
if (!path) {
// 打电话
// uni.makePhoneCall({
// phoneNumber: '4000621698',
// });
uni.showToast({
title: '功能开发中, 敬请期待',
icon: 'none',
@@ -263,6 +498,52 @@
});
}
};
const updateAvatar = async (avatar) => {
if (!avatar) return;
const res = await UserApi.updateUser({
...dataInfo.value,
avatar,
});
if (res.code !== 0) {
uni.showToast({
title: '头像更新失败',
icon: 'none',
});
return;
}
dataInfo.value.avatar = avatar;
getData();
};
const openAvatarCrop = () => {
uni.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
success: (res) => {
const filePath = res?.tempFilePaths?.[0] || '';
const size = res?.tempFiles?.[0]?.size;
if (typeof size === 'number' && size > 1048576) {
uni.showToast({
title: '上传图片大小不能超过1MB',
icon: 'none',
});
return;
}
if (!filePath) return;
uni.navigateTo({
url: `/pages/public/avatarCrop?src=${encodeURIComponent(filePath)}`,
success: (navRes) => {
const eventChannel = navRes?.eventChannel;
if (!eventChannel) return;
eventChannel.on('success', ({ url }) => {
if (!url) return;
updateAvatar(url);
});
},
});
},
fail: () => {},
});
};
const getData = () => {
sheep
.$store('user')
@@ -293,10 +574,17 @@
}
});
};
onMounted(() => {
fetchTradeChannels();
});
onShow(async () => {
let res = await getData();
getData();
getNumData();
if (pendingThirdPartyItem.value && Number(realStatus.value || 0) === 1) {
const next = pendingThirdPartyItem.value;
pendingThirdPartyItem.value = null;
nextTick(() => onThirdPartyServiceClick(next));
}
});
</script>
<style lang="scss" scoped>
@@ -312,7 +600,9 @@
top: 0;
left: 0;
width: 100%;
height: 484rpx;
height: auto;
border-radius: 0 0 30rpx 30rpx;
overflow: hidden;
image {
width: 100%;
@@ -321,25 +611,23 @@
}
.con {
position: absolute;
top: 0;
left: 0;
padding: 0rpx 30rpx;
position: relative;
padding: 0rpx 40rpx;
box-sizing: border-box;
padding-bottom: 0;
width: 100%;
height: 100%;
z-index: 1;
.con_top {
margin-bottom: 36rpx;
align-items: flex-end;
align-items: center;
.head {
width: 130rpx;
height: 130rpx;
border-radius: 50%;
overflow: hidden;
position: relative;
image {
width: 100%;
@@ -347,25 +635,39 @@
}
}
.head-upload-entry {
box-shadow: 0 10rpx 24rpx rgba(0, 0, 0, 0.12);
}
.con_info {
margin-left: 24rpx;
display: flex;
flex-direction: column;
align-items: flex-start;
flex: 1;
flex-direction: row;
align-items: center;
justify-content: space-between;
// .con_left {
// display: flex;
// justify-content: center;
// align-items: flex-start;
// }
.con_left {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
min-width: 0;
}
.con_id {
background: linear-gradient(90deg, #50504e 0%, #292b28 100%);
// background: linear-gradient(90deg, #50504e 0%, #292b28 100%);
border-radius: 40rpx;
font-size: 20rpx;
font-size: 26rpx;
color: #ffffff;
// line-height: 36rpx;
// text-align: center;
padding: 7rpx 16rpx;
// padding: 7rpx 16rpx;
display: flex;
align-items: center;
display: inline-flex;
@@ -393,11 +695,11 @@
.auth-btn-type1 {
background: #fff;
color: #fb4d32;
color: var(--brand-blue);
}
.auth-btn-type2 {
background: linear-gradient(130deg, #fa8735 0%, #fe3b48 100%);
background: linear-gradient(130deg, var(--auth-grad-start) 0%, var(--auth-grad-end) 100%);
color: #fff;
}
@@ -424,11 +726,12 @@
}
.card_money {
height: 120rpx;
height: 100rpx;
box-sizing: border-box;
color: #ffe3b1;
background: url('/static/home/img1.png');
color: #ffffff;
background: linear-gradient(150deg, var(--wallet-grad-start) 0%, var(--wallet-grad-end) 100%);
font-size: 24rpx;
border-radius: 20rpx;
.moneyNum {
font-size: 30rpx;
@@ -462,6 +765,22 @@
}
}
.card3_item {
position: relative;
flex: 1;
}
.card3_item--split::before {
content: '';
position: absolute;
left: 0;
top: 50%;
width: 2rpx;
height: 90rpx;
background: rgba(0, 0, 0, 0.22);
transform: translateY(-50%);
}
.card4 {
.card4_icon {
width: 68rpx;
@@ -488,6 +807,13 @@
}
}
.third-party-card {
.third-party-icon {
border-radius: 50%;
box-shadow: 0 12rpx 28rpx rgba(0, 0, 0, 0.14);
}
}
.card {
background-color: #fff;
border-radius: 20rpx;
+972
View File
@@ -0,0 +1,972 @@
<template>
<s-layout
title="提货清单"
:showLeftButton="false"
tabbar="/pages/merchant/pickupList"
navPreset="light"
>
<template #navRight>
<modeSwitch />
</template>
<view class="page">
<view class="top-bar bg24">
<view v-if="storeList.length" class="store-row flex-center ju-between" @tap="openStoreSheet">
<view class="store-left flex-center">
<view class="store-label c_999 size24">当前网点</view>
<view class="store-name lineOne">{{ currentStoreName }}</view>
</view>
<view v-if="storeList.length > 1" class="store-arrow">
<uni-icons type="right" size="16" color="#7b8494" />
</view>
</view>
<view class="tabs">
<view
v-for="item in tabs"
:key="item.value"
class="tab"
:class="{ tabActive: currentTab === item.value }"
@tap="currentTab = item.value"
>
{{ item.label }}
</view>
</view>
<view class="search-row">
<view class="search-box flex-center">
<uni-icons type="search" size="18" color="#8a8a8a" />
<uni-easyinput
class="search-input flex1"
v-model="keyword"
placeholder="搜索订单号/商品名称"
:inputBorder="false"
:styles="{ fontSize: '28rpx' }"
/>
</view>
</view>
<view class="sort-row flex-center ju-between">
<view class="sort-label c_999 size24">下单时间排序</view>
<view class="sort-switch" @tap="toggleSort">
<view
class="sort-triangle sort-triangle--up"
:class="{ 'sort-triangle--active': sortAsc }"
></view>
<view
class="sort-triangle sort-triangle--down"
:class="{ 'sort-triangle--active': !sortAsc }"
></view>
</view>
</view>
</view>
<view class="list">
<view v-for="item in displayList" :key="item.id" class="card bg24">
<view class="card-hd flex-center ju-between">
<view class="status-wrap">
<view class="status" :class="{ statusWait: Number(item.status) === 1 }">
{{ item.statusName }}
</view>
<view v-if="getOrderItems(item).length > 1" class="goods-total">
共{{ getOrderItems(item).length }}件
</view>
</view>
<view class="time c_999 size24">
下单时间:{{ sheep.$helper.timeFormat(item.createTime, 'yyyy-mm-dd hh:MM') }}
</view>
</view>
<view v-if="getReceiverName(item) || getMaskedReceiverMobile(item)" class="buyer-top">
<view class="buyer-top__left">
<text v-if="getReceiverName(item)" class="buyer-top__name">{{ getReceiverName(item) }}</text>
<text v-if="getMaskedReceiverMobile(item)" class="buyer-top__mobile">
{{ getMaskedReceiverMobile(item) }}
</text>
</view>
</view>
<view class="card-bd flex-center al-flex-start">
<view class="goods-thumb">
<image
v-if="getItemPic(getMainItem(item))"
class="goods-thumb__img"
:src="getItemPic(getMainItem(item))"
mode="aspectFill"
/>
<view v-else class="goods-thumb__empty">暂无图片</view>
</view>
<view class="flex1">
<view class="name lineTwo">{{ getMainItem(item)?.spuName || '商品信息暂无' }}</view>
<view v-if="getItemSpec(getMainItem(item))" class="meta c_999 size24 m-t-8">
规格:{{ getItemSpec(getMainItem(item)) }}
</view>
<view class="meta c_999 size24 m-t-8">数量:x{{ getMainItem(item)?.count || 0 }}</view>
<view class="order-no-row c_999 size24 m-t-10">
<text class="order-no-row__text">订单号:{{ item.orderNo || '--' }}</text>
<view v-if="item.orderNo" class="order-no-row__copy" @tap.stop="copyOrderNo(item.orderNo)">
<image class="order-no-row__copy-icon" :src="`${$url}goods/copy2.svg`" mode="scaleToFill" />
</view>
</view>
</view>
</view>
<view
v-if="getReceiverMobileDigits(item) || Number(item.status) === 0 || Number(item.status) === 1"
class="actions"
>
<view v-if="getReceiverMobileDigits(item)" class="btn btnGhost" @tap.stop="callReceiver(item)">
<uni-icons type="phone" size="16" color="#2556ec" />
<text>拨打电话</text>
</view>
<view v-if="Number(item.status) === 0" class="btn btnPrimary" @tap="markPicked(item)">
标记已分拣
</view>
<view v-else-if="Number(item.status) === 1" class="btn btnOutline" @tap="goScan">
去核销
</view>
</view>
<view
v-if="getExtraItems(item).length"
class="fold-box"
:class="{ 'fold-box--active': isExpanded(item) }"
>
<view class="fold-trigger" @tap="toggleExpand(item)">
<view class="fold-trigger__left">
<view class="fold-trigger__badge">{{ getExtraItems(item).length }}</view>
<view class="fold-trigger__text">
{{ isExpanded(item) ? '收起其他商品' : `展开其他${getExtraItems(item).length}件商品` }}
</view>
</view>
<view class="fold-trigger__icon" :class="{ 'fold-trigger__icon--active': isExpanded(item) }">
<uni-icons
:type="isExpanded(item) ? 'top' : 'bottom'"
size="14"
color="#7b8494"
/>
</view>
</view>
<view v-if="isExpanded(item)" class="fold-panel">
<view
v-for="(goods, goodsIndex) in getExtraItems(item)"
:key="goods.orderItemId || goodsIndex"
class="fold-item"
>
<image
v-if="getItemPic(goods)"
class="fold-item__img"
:src="getItemPic(goods)"
mode="aspectFill"
/>
<view v-else class="fold-item__empty">暂无图片</view>
<view class="fold-item__info">
<view class="fold-item__name lineTwo">{{ goods.spuName || '商品信息暂无' }}</view>
<view v-if="getItemSpec(goods)" class="meta c_999 size24 m-t-8">
规格:{{ getItemSpec(goods) }}
</view>
<view class="meta c_999 size24 m-t-8">数量:x{{ goods.count || 0 }}</view>
</view>
</view>
</view>
</view>
</view>
<view v-if="displayList.length === 0 && !loading.value" class="empty c_999">暂无数据</view>
<view v-if="displayList.length > 0" class="load-more">
<view v-if="loadingMore" class="load-more__text c_999">加载中...</view>
<view v-else-if="finished" class="load-more__text c_999">没有更多了</view>
</view>
</view>
</view>
</s-layout>
</template>
<script setup>
import { computed, ref, watch } from 'vue';
import { onPullDownRefresh, onReachBottom, onShow } from '@dcloudio/uni-app';
import modeSwitch from '@/components/mode_switch/mode_switch.vue';
import sheep from '@/sheep';
import OrderStoreApi from '@/sheep/api/trade/orderStore';
import StoreApi from '@/sheep/api/trade/store';
const tabs = [
{ label: '全部', value: 'all' },
{ label: '待分拣', value: 0 },
{ label: '待取货', value: 1 },
];
const currentTab = ref('all');
const keyword = ref('');
const sortAsc = ref(false);
const list = ref([]);
const loading = ref(false);
const loadingMore = ref(false);
const finished = ref(false);
const pageNo = ref(1);
const pageSize = ref(10);
const total = ref(0);
const sum = ref(0);
const expandedMap = ref({});
const userStore = sheep.$store('user');
const storeList = ref([]);
const storeIdsKey = ref('');
const selectedStoreId = ref(0);
const storeLoading = ref(false);
const STORE_SELECTED_KEY = 'merchant.pickup.selectedStoreId';
const displayList = computed(() => list.value);
const sanitizeText = (value) => String(value || '').replace(/[`"'\s]/g, '');
const getStoreName = (store) => {
const name = String(store?.name || store?.storeName || store?.title || '').trim();
if (name) return name;
const id = Number(store?.id || 0);
return id ? `网点${id}` : '';
};
const currentStore = computed(() => {
const id = Number(selectedStoreId.value || 0);
const list = Array.isArray(storeList.value) ? storeList.value : [];
return list.find((s) => Number(s?.id || 0) === id) || list[0] || {};
});
const currentStoreName = computed(() => getStoreName(currentStore.value) || '请选择网点');
const toStoreIdsString = (raw) => {
if (raw === null || raw === undefined) return '';
if (Array.isArray(raw)) {
return raw.map((v) => String(v).trim()).filter(Boolean).join(',');
}
const s = String(raw).trim();
if (!s) return '';
if (s.includes(',')) return s.replace(/\s+/g, '');
const n = Number(s);
if (Number.isFinite(n) && n > 0) return String(n);
return s.replace(/\s+/g, '');
};
const getUserStoreIds = async () => {
const local = userStore?.userInfo || {};
const fromLocal =
local.storeIds ??
local.storeIdList ??
local.pickUpStoreIds ??
local.pickUpStoreIdList ??
local.storeId;
let storeIds = toStoreIdsString(fromLocal);
if (storeIds) return storeIds;
const fetched = await userStore.getInfo();
const fromFetched =
fetched?.storeIds ??
fetched?.storeIdList ??
fetched?.pickUpStoreIds ??
fetched?.pickUpStoreIdList ??
fetched?.storeId;
storeIds = toStoreIdsString(fromFetched);
return storeIds;
};
const ensureStoreList = async (force = false) => {
const storeIds = await getUserStoreIds();
if (!storeIds) {
storeList.value = [];
storeIdsKey.value = '';
selectedStoreId.value = 0;
return '';
}
if (storeLoading.value) return storeIds;
if (!force && storeIdsKey.value === storeIds && storeList.value.length) return storeIds;
storeLoading.value = true;
try {
const { code, data } = await StoreApi.getStoreListByStoreIds(storeIds);
if (code !== 0) return storeIds;
storeList.value = Array.isArray(data) ? data : [];
storeIdsKey.value = storeIds;
const currentSelected = Number(selectedStoreId.value || 0);
const existsSelected = storeList.value.some((s) => Number(s?.id || 0) === currentSelected);
if (!existsSelected) {
const preferred = Number(userStore?.userInfo?.storeId || 0);
const nextFromPreferred = storeList.value.find((s) => Number(s?.id || 0) === preferred);
const nextId = Number(nextFromPreferred?.id || storeList.value[0]?.id || 0);
if (nextId > 0) selectedStoreId.value = nextId;
}
return storeIds;
} finally {
storeLoading.value = false;
}
};
const ensurePickUpStoreId = async () => {
await ensureStoreList();
return Number(selectedStoreId.value || 0);
};
const resetPagination = () => {
pageNo.value = 1;
list.value = [];
finished.value = false;
total.value = 0;
sum.value = 0;
};
const buildParams = (storeId) => {
const params = {
pickUpStoreId: storeId,
pageNo: pageNo.value,
pageSize: pageSize.value,
sortAsc: sortAsc.value,
};
if (currentTab.value !== 'all') params.status = currentTab.value;
const k = String(keyword.value || '').trim();
if (k) params.keyword = k;
return params;
};
const toggleSort = () => {
sortAsc.value = !sortAsc.value;
resetPagination();
getList();
};
const getList = async (force = false, isLoadMore = false) => {
while (force && (loading.value || loadingMore.value)) {
await new Promise((resolve) => setTimeout(resolve, 50));
}
if (!isLoadMore && loading.value) return;
if (isLoadMore && (loadingMore.value || finished.value)) return;
const storeId = await ensurePickUpStoreId();
if (!(storeId > 0)) {
uni.showToast({ title: '缺少网点信息', icon: 'none' });
return;
}
if (isLoadMore) {
loadingMore.value = true;
} else {
loading.value = true;
}
const { data, code } = await OrderStoreApi.getStaffList(buildParams(storeId));
if (isLoadMore) {
loadingMore.value = false;
} else {
loading.value = false;
}
if (code !== 0) return;
const resList = Array.isArray(data?.list) ? data.list : [];
total.value = Number(data?.total || 0);
sum.value = Number(data?.sum || 0);
if (isLoadMore) {
list.value = [...list.value, ...resList];
} else {
list.value = resList;
}
if (list.value.length >= total.value || resList.length < pageSize.value) {
finished.value = true;
}
};
const loadMore = async () => {
if (finished.value || loadingMore.value || loading.value) return;
pageNo.value += 1;
await getList(false, true);
};
const openStoreSheet = () => {
if (storeList.value.length <= 1) return;
const itemList = storeList.value.map((s) => getStoreName(s) || '未命名网点');
uni.showActionSheet({
itemList,
success: ({ tapIndex }) => {
const next = Number(storeList.value?.[tapIndex]?.id || 0);
if (next > 0 && next !== selectedStoreId.value) {
selectedStoreId.value = next;
}
},
});
};
onShow(async () => {
const saved = Number(uni.getStorageSync(STORE_SELECTED_KEY) || 0);
if (saved > 0 && saved !== selectedStoreId.value) selectedStoreId.value = saved;
await ensureStoreList();
const current = Number(selectedStoreId.value || 0);
if (current > 0) uni.setStorageSync(STORE_SELECTED_KEY, current);
resetPagination();
await getList();
});
onPullDownRefresh(async () => {
try {
expandedMap.value = {};
resetPagination();
await ensureStoreList(true);
const current = Number(selectedStoreId.value || 0);
if (current > 0) uni.setStorageSync(STORE_SELECTED_KEY, current);
await getList(true);
} finally {
uni.stopPullDownRefresh();
}
});
onReachBottom(() => {
loadMore();
});
let searchTimer = null;
watch(
[currentTab, keyword, selectedStoreId],
() => {
if (searchTimer) clearTimeout(searchTimer);
searchTimer = setTimeout(() => {
resetPagination();
getList();
}, 300);
},
{ deep: false },
);
watch(
selectedStoreId,
(v) => {
const n = Number(v || 0);
if (n > 0) uni.setStorageSync(STORE_SELECTED_KEY, n);
},
{ deep: false },
);
const goScan = () => {
uni.reLaunch({ url: '/pages/merchant/scanVerify' });
};
const getOrderItems = (item) => {
return Array.isArray(item?.items) ? item.items.filter(Boolean) : [];
};
const getMainItem = (item) => {
return getOrderItems(item)[0] || null;
};
const getExtraItems = (item) => {
return getOrderItems(item).slice(1);
};
const getItemPic = (goods) => {
const text = sanitizeText(goods?.picUrl);
if (!text) return '';
if (/^https?:\/\//i.test(text)) return text;
return sheep.$url.cdn(text);
};
const getItemSpec = (goods) => {
return goods?.spec || '';
};
const getReceiverName = (item) => {
return String(item?.receiverName || item?.userName || item?.nickname || '').trim();
};
const maskMobile = (mobile) => {
const digits = String(mobile || '').replace(/\D/g, '');
if (digits.length < 7) return String(mobile || '').trim();
if (digits.length === 11) return `${digits.slice(0, 3)}****${digits.slice(7)}`;
return `${digits.slice(0, 3)}**${digits.slice(-4)}`;
};
const getMaskedReceiverMobile = (item) => {
const mobile = String(item?.receiverMobile || item?.receiverPhone || item?.mobile || '').trim();
return mobile ? maskMobile(mobile) : '';
};
const getReceiverMobileDigits = (item) => {
return String(item?.receiverMobile || item?.receiverPhone || item?.mobile || '').replace(/\D/g, '');
};
const callReceiver = (item) => {
const phoneNumber = getReceiverMobileDigits(item);
if (!phoneNumber) {
uni.showToast({ title: '暂无手机号', icon: 'none' });
return;
}
uni.makePhoneCall({
phoneNumber,
fail: () => {
uni.showToast({ title: '拨打失败', icon: 'none' });
},
});
};
const copyOrderNo = (orderNo) => {
const text = String(orderNo || '').trim();
if (!text) {
uni.showToast({ title: '暂无订单号', icon: 'none' });
return;
}
sheep.$helper.copyText(text);
};
const getExpandKey = (item) => {
return String(item?.orderId || item?.id || '');
};
const isExpanded = (item) => {
return Boolean(expandedMap.value[getExpandKey(item)]);
};
const toggleExpand = (item) => {
const key = getExpandKey(item);
if (!key) return;
expandedMap.value = {
...expandedMap.value,
[key]: !expandedMap.value[key],
};
};
const getPickUpCode = (item) => {
return item?.pickUpVerifyCode || item?.pickUpCode || '';
};
const markPicked = async (item) => {
const ids = Array.isArray(item?.ids) ? item.ids : [];
if (!ids.length) {
uni.showToast({ title: '缺少分拣ID', icon: 'none' });
return;
}
uni.showModal({
title: '提示',
content: '确认标记为已分拣吗?',
success: async ({ confirm }) => {
if (!confirm) return;
try {
const { code } = await OrderStoreApi.markSorted(ids);
if (code !== 0) return;
resetPagination();
await getList();
} catch (error) {
uni.showToast({ title: '标记失败,请稍后重试', icon: 'none' });
}
},
});
};
</script>
<style scoped lang="scss">
.page {
padding: 24rpx 24rpx 170rpx;
box-sizing: border-box;
}
.top-bar {
border-radius: 24rpx;
padding: 18rpx 20rpx 20rpx;
box-sizing: border-box;
margin-bottom: 18rpx;
}
.store-row {
padding: 10rpx 4rpx 14rpx;
border-bottom: 2rpx solid #f1f2f6;
margin-bottom: 14rpx;
}
.store-left {
min-width: 0;
gap: 12rpx;
}
.store-label {
flex-shrink: 0;
}
.store-name {
font-size: 28rpx;
color: #222;
font-weight: 600;
max-width: 520rpx;
}
.store-arrow {
flex-shrink: 0;
}
.tabs {
display: flex;
gap: 12rpx;
margin-bottom: 16rpx;
}
.tab {
padding: 14rpx 22rpx;
border-radius: 16rpx;
background: #f2f4f7;
color: #333;
font-size: 26rpx;
}
.tabActive {
background: rgba(37, 86, 236, 0.12);
color: #2556ec;
font-weight: 600;
}
.search-row {
width: 100%;
}
.search-box {
width: 100%;
border-radius: 18rpx;
background: #f6f7fb;
padding: 6rpx 16rpx;
box-sizing: border-box;
}
:deep(.search-input .uni-easyinput__content) {
background: transparent !important;
}
.sort-row {
margin-top: 14rpx;
padding-top: 14rpx;
border-top: 2rpx solid #f1f2f6;
}
.sort-switch {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 2rpx;
min-width: 60rpx;
padding: 10rpx 20rpx;
border-radius: 16rpx;
background: #f1f2f5;
box-sizing: border-box;
}
.sort-triangle {
width: 0;
height: 0;
border-left: 12rpx solid transparent;
border-right: 12rpx solid transparent;
}
.sort-triangle--up {
border-bottom: 14rpx solid #c5cad4;
}
.sort-triangle--up.sort-triangle--active {
border-bottom-color: #2556ec;
}
.sort-triangle--down {
border-top: 14rpx solid #c5cad4;
}
.sort-triangle--down.sort-triangle--active {
border-top-color: #2556ec;
}
.list {
display: flex;
flex-direction: column;
gap: 18rpx;
}
.card {
border-radius: 24rpx;
padding: 18rpx 18rpx 20rpx;
box-sizing: border-box;
}
.card-hd {
margin-bottom: 14rpx;
}
.buyer-top {
display: flex;
align-items: center;
gap: 12rpx;
padding: 10rpx 12rpx;
border-radius: 16rpx;
background: #f7f8fc;
margin-bottom: 14rpx;
}
.buyer-top__left {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 12rpx;
min-width: 0;
flex: 1;
}
.buyer-top__name {
font-size: 24rpx;
line-height: 34rpx;
color: #222;
font-weight: 600;
}
.buyer-top__mobile {
font-size: 24rpx;
line-height: 34rpx;
color: #7b8494;
}
.status-wrap {
display: flex;
align-items: center;
gap: 10rpx;
min-width: 0;
}
.status {
font-size: 24rpx;
color: #2556ec;
background: rgba(37, 86, 236, 0.12);
padding: 6rpx 14rpx;
border-radius: 14rpx;
}
.statusWait {
color: #6b4eff;
background: rgba(107, 78, 255, 0.12);
}
.goods-total {
font-size: 22rpx;
color: #8a8a8a;
}
.goods-thumb {
width: 140rpx;
height: 140rpx;
margin-right: 16rpx;
flex-shrink: 0;
position: relative;
}
.goods-thumb__img,
.goods-thumb__empty {
width: 100%;
height: 100%;
border-radius: 18rpx;
background: #f2f4f7;
}
.goods-thumb__img {
display: block;
}
.goods-thumb__empty {
color: #bbb;
font-size: 22rpx;
display: flex;
align-items: center;
justify-content: center;
border: 2rpx dashed #e3e6ee;
box-sizing: border-box;
}
.name {
font-size: 28rpx;
color: #222;
font-weight: 600;
}
.order-no-row {
display: flex;
align-items: center;
gap: 10rpx;
min-width: 0;
}
.order-no-row__text {
min-width: 0;
flex: 0 1 auto;
}
.order-no-row__copy {
width: 24rpx;
height: 24rpx;
display: inline-flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.order-no-row__copy-icon {
width: 100%;
height: 100%;
display: block;
}
.actions {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 16rpx;
margin-top: 16rpx;
padding-top: 16rpx;
border-top: 2rpx solid #f1f3f7;
}
.btn {
min-width: 176rpx;
height: 64rpx;
padding: 0 26rpx;
border-radius: 18rpx;
font-size: 24rpx;
line-height: 1;
display: inline-flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
font-weight: 600;
gap: 8rpx;
}
.btnPrimary {
background: #2556ec;
color: #fff;
}
.btnOutline {
border: 2rpx solid rgba(37, 86, 236, 0.6);
color: #2556ec;
}
.btnGhost {
min-width: 0;
padding: 0 20rpx;
border: 2rpx solid #dbe3f2;
color: #2556ec;
background: #f7faff;
}
.fold-box {
margin-top: 16rpx;
border-radius: 18rpx;
background: #f7f8fc;
border: 2rpx solid #eef1f6;
overflow: hidden;
transition: all 0.2s ease;
}
.fold-box--active {
background: #f5f7ff;
border-color: rgba(37, 86, 236, 0.18);
box-shadow: 0 8rpx 24rpx rgba(37, 86, 236, 0.06);
}
.fold-trigger {
padding: 18rpx 20rpx;
display: flex;
align-items: center;
justify-content: space-between;
}
.fold-trigger__left {
display: flex;
align-items: center;
min-width: 0;
gap: 12rpx;
}
.fold-trigger__badge {
min-width: 36rpx;
height: 36rpx;
padding: 0 10rpx;
border-radius: 999rpx;
background: rgba(37, 86, 236, 0.12);
color: #2556ec;
font-size: 22rpx;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
.fold-trigger__text {
font-size: 25rpx;
color: #4d5562;
}
.fold-trigger__icon {
width: 40rpx;
height: 40rpx;
border-radius: 20rpx;
background: #fff;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
border: 2rpx solid #eceff5;
box-sizing: border-box;
}
.fold-trigger__icon--active {
background: rgba(37, 86, 236, 0.1);
border-color: rgba(37, 86, 236, 0.14);
}
.fold-panel {
padding: 0 20rpx 18rpx;
border-top: 2rpx dashed #e6ebf4;
}
.fold-item {
display: flex;
align-items: flex-start;
padding-top: 16rpx;
}
.fold-item + .fold-item {
margin-top: 16rpx;
padding-top: 16rpx;
border-top: 2rpx solid #eceff5;
}
.fold-item__img,
.fold-item__empty {
width: 104rpx;
height: 104rpx;
border-radius: 14rpx;
flex-shrink: 0;
background: #f2f4f7;
}
.fold-item__img {
display: block;
}
.fold-item__empty {
color: #bbb;
font-size: 20rpx;
display: flex;
align-items: center;
justify-content: center;
border: 2rpx dashed #e3e6ee;
box-sizing: border-box;
}
.fold-item__info {
margin-left: 16rpx;
min-width: 0;
flex: 1;
}
.fold-item__name {
font-size: 26rpx;
color: #222;
font-weight: 600;
}
.empty {
text-align: center;
padding: 80rpx 0;
}
.load-more {
padding: 30rpx 0 10rpx;
text-align: center;
}
.load-more__text {
font-size: 24rpx;
}
</style>
+329
View File
@@ -0,0 +1,329 @@
<template>
<s-layout
title="扫码核销"
:showLeftButton="false"
tabbar="/pages/merchant/scanVerify"
navPreset="light"
>
<template #navRight>
<modeSwitch />
</template>
<view class="page">
<view class="seg bg24">
<view class="seg-item" :class="{ segActive: tab === 'scan' }" @tap="tab = 'scan'">
扫码核销
</view>
<view class="seg-item" :class="{ segActive: tab === 'input' }" @tap="tab = 'input'">
输入取货码
</view>
</view>
<view class="panel bg24" v-if="tab === 'scan'">
<view class="scan-box">
<view class="scan-box__inner">
<uni-icons type="scan" size="42" color="#2556EC" />
<view class="scan-title">请将用户订单二维码对准扫码框</view>
<view class="scan-tip c_999 size24">或点击下方按钮开始扫码</view>
</view>
</view>
<view class="btnScan" :class="{ btnScanDisabled: verifying }" @tap="startScan">
{{ verifying ? '核销中...' : '开始扫码' }}
</view>
</view>
<view class="panel bg24" v-else>
<view class="input-row">
<uni-easyinput
class="code-input"
v-model="manualCode"
placeholder="请输入取货码"
:inputBorder="false"
:styles="{ fontSize: '34rpx' }"
/>
</view>
<view class="btnScan" :class="{ btnScanDisabled: verifying }" @tap="confirmManual">
{{ verifying ? '核销中...' : '确认核销' }}
</view>
</view>
<view class="records bg24">
<view class="records-hd flex-center ju-between">
<view class="records-title">近期核销记录</view>
<view class="records-link" @tap="refreshRecords">刷新</view>
</view>
<view v-for="row in records" :key="row.id" class="record flex-center ju-between">
<view class="record-left">
<view class="record-code">取货码:{{ row.code }}</view>
<view class="record-time c_999 size24">{{ row.time }}</view>
</view>
<view class="record-right c_999 size24">{{ row.operator }}</view>
</view>
<view v-if="records.length === 0" class="empty c_999">暂无记录</view>
</view>
</view>
</s-layout>
</template>
<script setup>
import { ref } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import modeSwitch from '@/components/mode_switch/mode_switch.vue';
import sheep from '@/sheep';
import OrderStoreApi from '@/sheep/api/trade/orderStore';
const tab = ref('scan');
const manualCode = ref('');
const verifying = ref(false);
const userStore = sheep.$store('user');
const STORE_SELECTED_KEY = 'merchant.pickup.selectedStoreId';
const days = ref(7);
const records = ref([]);
const formatRecordTime = (value) => {
if (value === null || value === undefined) return '';
if (typeof value === 'string') {
const s = value.trim();
if (!s) return '';
const n = Number(s);
if (Number.isFinite(n)) return new Date(n).toLocaleString();
const d = new Date(s);
if (!Number.isNaN(d.getTime())) return d.toLocaleString();
return s;
}
const n = Number(value);
if (Number.isFinite(n)) return new Date(n).toLocaleString();
const d = new Date(value);
if (!Number.isNaN(d.getTime())) return d.toLocaleString();
return String(value);
};
const mapRecentRow = (row, index) => {
const raw = row || {};
const code = String(raw.pickUpVerifyCode || raw.pickUpCode || raw.code || '').trim();
const time = formatRecordTime(raw.completeTime || raw.completedTime || raw.verifyTime || raw.updateTime);
const operator = String(raw.operatorName || raw.staffName || raw.operator || raw.creator || '').trim();
const id = String(raw.id || raw.orderId || code || `${Date.now()}-${index}`);
return { id, code, time, operator };
};
const getPickUpStoreId = async () => {
const stored = Number(uni.getStorageSync(STORE_SELECTED_KEY) || 0);
if (stored > 0) return stored;
const local = Number(userStore?.userInfo?.storeId || 0);
if (local > 0) return local;
const fetched = await userStore.getInfo();
return Number(fetched?.storeId || 0);
};
const loadRecentRecords = async () => {
const storeId = await getPickUpStoreId();
if (!(storeId > 0)) {
records.value = [];
return;
}
const { code, data } = await OrderStoreApi.getRecentCompleted(storeId, days.value);
if (code !== 0) return;
const list = Array.isArray(data)
? data
: Array.isArray(data?.list)
? data.list
: Array.isArray(data?.records)
? data.records
: [];
records.value = list.map(mapRecentRow).filter((v) => v.code);
};
const verifyCode = async (code) => {
const pickUpVerifyCode = String(code || '').trim();
if (!pickUpVerifyCode) {
uni.showToast({ title: '核销码不能为空', icon: 'none' });
return false;
}
if (verifying.value) return false;
verifying.value = true;
try {
const { code: resCode } = await OrderStoreApi.verify(pickUpVerifyCode);
if (resCode !== 0) return false;
await loadRecentRecords();
return true;
} catch (error) {
uni.showToast({ title: '核销失败,请稍后重试', icon: 'none' });
return false;
} finally {
verifying.value = false;
}
};
const startScan = () => {
if (verifying.value) return;
uni.scanCode({
scanType: ['qrCode', 'barCode'],
success: async (res) => {
const code = String(res.result || '').trim();
if (!code) {
uni.showToast({ title: '未识别到内容', icon: 'none' });
return;
}
await verifyCode(code);
},
fail: () => {
uni.showToast({ title: '扫码失败', icon: 'none' });
},
});
};
const confirmManual = async () => {
const code = String(manualCode.value || '').trim();
if (!code) {
uni.showToast({ title: '请输入取货码', icon: 'none' });
return;
}
const success = await verifyCode(code);
if (success) {
manualCode.value = '';
}
};
const refreshRecords = async () => {
await loadRecentRecords();
};
onShow(async () => {
await loadRecentRecords();
});
</script>
<style scoped lang="scss">
.page {
padding: 24rpx 24rpx 170rpx;
box-sizing: border-box;
}
.seg {
border-radius: 24rpx;
padding: 10rpx;
box-sizing: border-box;
display: flex;
margin-bottom: 18rpx;
background: rgba(255, 255, 255, 0.98);
}
.seg-item {
flex: 1;
height: 76rpx;
display: flex;
align-items: center;
justify-content: center;
border-radius: 18rpx;
font-size: 28rpx;
color: #333;
}
.segActive {
background: rgba(37, 86, 236, 0.12);
color: #2556ec;
font-weight: 700;
}
.panel {
border-radius: 24rpx;
padding: 24rpx;
box-sizing: border-box;
margin-bottom: 18rpx;
}
.scan-box {
border-radius: 24rpx;
border: 2rpx dashed rgba(37, 86, 236, 0.35);
height: 360rpx;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 20rpx;
background: rgba(37, 86, 236, 0.04);
}
.scan-box__inner {
display: flex;
flex-direction: column;
align-items: center;
}
.scan-title {
margin-top: 18rpx;
font-size: 28rpx;
color: #333;
font-weight: 600;
}
.scan-tip {
margin-top: 10rpx;
}
.btnScan {
height: 92rpx;
border-radius: 24rpx;
background: #2556ec;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
font-size: 30rpx;
font-weight: 700;
}
.btnScanDisabled {
opacity: 0.7;
}
.input-row {
border-radius: 24rpx;
background: #f6f7fb;
padding: 18rpx 20rpx;
box-sizing: border-box;
margin-bottom: 20rpx;
}
:deep(.code-input .uni-easyinput__content) {
background: transparent !important;
}
.records {
border-radius: 24rpx;
padding: 18rpx;
box-sizing: border-box;
}
.records-hd {
padding-bottom: 12rpx;
border-bottom: 2rpx solid #f1f2f6;
}
.records-title {
font-size: 28rpx;
color: #222;
font-weight: 700;
}
.records-link {
font-size: 24rpx;
color: #2556ec;
}
.record {
padding: 16rpx 0;
border-bottom: 2rpx solid #f6f7fb;
}
.record-code {
font-size: 26rpx;
color: #333;
font-weight: 600;
}
.empty {
text-align: center;
padding: 70rpx 0;
}
</style>
+671
View File
@@ -0,0 +1,671 @@
<template>
<s-layout
title="网店管理"
:showLeftButton="false"
tabbar="/pages/merchant/storeManage"
navPreset="light"
>
<template #navRight>
<modeSwitch />
</template>
<view class="page">
<view class="stats">
<view class="stat bg24">
<view class="stat-label c_999 size24">总网店数</view>
<view class="stat-value">{{ stats.total }}</view>
</view>
<view class="stat bg24">
<view class="stat-label c_999 size24">营业中</view>
<view class="stat-value cGreen">{{ stats.open }}</view>
</view>
<view class="stat bg24">
<view class="stat-label c_999 size24">今日新增订单</view>
<view class="stat-value cOrange">{{ stats.todayOrders }}</view>
</view>
</view>
<view class="tool-row bg24">
<view class="search-box flex-center flex1">
<uni-icons type="search" size="18" color="#8a8a8a" />
<uni-easyinput
class="search-input flex1"
v-model="keyword"
placeholder="搜索网店名称/编号"
:inputBorder="false"
:styles="{ fontSize: '28rpx' }"
/>
</view>
<picker
mode="selector"
class="status-picker"
:value="statusIndex"
:range="statusOptions"
range-key="label"
@change="bindStatusChange"
>
<view class="status-picker__inner">
<text class="status-picker__text">{{ statusOptions[statusIndex].label }}</text>
<uni-icons type="bottom" size="14" color="#8a8a8a" />
</view>
</picker>
<!-- <view class="btnAdd" @tap="addStore">+ 新增网店</view> -->
</view>
<view class="table">
<view v-for="(row, index) in filteredList" :key="row.id" class="tr">
<view class="store-card flex-center">
<view class="store-rank">#{{ index + 1 }}</view>
<view class="store-cover">
<image
v-if="row.coverImage"
class="store-cover__img"
:src="row.coverImage"
mode="aspectFill"
/>
<view v-else class="store-cover__empty">暂无封面</view>
</view>
<view class="store-main">
<view class="store-main__top flex-center ju-between">
<view class="store-name lineOne">{{ row.name }}</view>
<view class="badge" :class="row.statusClass">
{{ row.statusText }}
</view>
</view>
<view class="store-code c_999">编号:{{ row.code || '--' }}</view>
<view class="store-contact c_999 lineOne">联系电话:{{ row.phone || '--' }}</view>
<view class="store-address c_999">{{ row.address || '--' }}</view>
<!-- 销量库存进度条模块:先隐藏,等接口 ready 再打开 -->
<!--
<view class="store-progress">
<view class="store-progress__head flex-center ju-between">
<view class="store-progress__label">销量 / 库存</view>
<view class="store-progress__value">{{ row.progressText }}</view>
</view>
<view class="store-progress__bar">
<view
class="store-progress__fill"
:style="{ width: `${row.progressPercent}%` }"
></view>
</view>
</view>
-->
</view>
</view>
<view class="store-actions flex-center ju-flex-end">
<view v-if="showEdit" class="op opPrimary" @tap="edit(row)">编辑</view>
<view
v-if="row.toggleActionText"
class="op"
:class="[
row.toggleActionText === '休息' ? 'opDanger' : 'opSuccess',
{ opDisabled: updatingStoreId === row.id },
]"
@tap="toggle(row)"
>
{{ updatingStoreId === row.id ? '处理中...' : row.toggleActionText }}
</view>
</view>
</view>
<view v-if="filteredList.length === 0" class="empty c_999">暂无数据</view>
</view>
</view>
</s-layout>
</template>
<script setup>
import { computed, ref } from 'vue';
import { onPullDownRefresh, onShow } from '@dcloudio/uni-app';
import modeSwitch from '@/components/mode_switch/mode_switch.vue';
import sheep from '@/sheep';
import OrderStoreApi from '@/sheep/api/trade/orderStore';
import StoreApi from '@/sheep/api/trade/store';
const keyword = ref('');
const statusIndex = ref(0);
const showEdit = false;
const list = ref([]);
const loading = ref(false);
const todayOrders = ref(0);
const updatingStoreId = ref(0);
const userStore = sheep.$store('user');
const statusOptions = [
{ label: '全部状态', value: '' },
{ label: '营业中', value: 1 },
{ label: '休息中', value: 2 },
];
const toStoreIdsString = (raw) => {
if (raw === null || raw === undefined) return '';
if (Array.isArray(raw)) {
return raw.map((v) => String(v).trim()).filter(Boolean).join(',');
}
const s = String(raw).trim();
if (!s) return '';
if (s.includes(',')) return s.replace(/\s+/g, '');
const n = Number(s);
if (Number.isFinite(n) && n > 0) return String(n);
return s.replace(/\s+/g, '');
};
const getUserStoreIds = async () => {
const local = userStore?.userInfo || {};
const fromLocal =
local.storeIds ??
local.storeIdList ??
local.pickUpStoreIds ??
local.pickUpStoreIdList ??
local.storeId;
let storeIds = toStoreIdsString(fromLocal);
if (storeIds) return storeIds;
const fetched = await userStore.getInfo();
const fromFetched =
fetched?.storeIds ??
fetched?.storeIdList ??
fetched?.pickUpStoreIds ??
fetched?.pickUpStoreIdList ??
fetched?.storeId;
storeIds = toStoreIdsString(fromFetched);
return storeIds;
};
const getStoreName = (store) => {
const name = String(store?.name || store?.storeName || store?.title || '').trim();
if (name) return name;
const id = Number(store?.id || 0);
return id ? `网点${id}` : '';
};
const getStoreCode = (store) => {
const v = store?.code ?? store?.storeCode ?? store?.no ?? store?.storeNo ?? store?.id;
return String(v ?? '').trim();
};
const getStorePhone = (store) => {
const v = store?.contactPhone ?? '';
return String(v ?? '').trim();
};
const getStoreAddress = (store) => {
const province = String(store?.province || '').trim();
const city = String(store?.city || '').trim();
const district = String(store?.district || '').trim();
const address = String(store?.address || '').trim();
const full = `${province}${city}${district}${address}`.trim();
if (full) return full;
return address;
};
const sanitizeUrl = (value) => String(value || '').replace(/[`"'\s]/g, '');
const getStoreCoverImage = (store) => {
const raw = sanitizeUrl(store?.coverImage || store?.image || store?.picUrl || '');
if (!raw) return '';
if (/^https?:\/\//i.test(raw)) return raw;
return sheep.$url.cdn(raw);
};
const statusMap = {
0: { text: '待审核', className: 'badgePending' },
1: { text: '营业中', className: 'badgeOpen' },
2: { text: '休息中', className: 'badgeRest' },
3: { text: '已关闭', className: 'badgeClosed' },
4: { text: '审核拒绝', className: 'badgeRejected' },
};
const getStoreStatus = (store) => {
const n = Number(store?.status);
return Number.isFinite(n) ? n : -1;
};
const getStoreProgressInfo = (store) => {
const sales = Math.max(0, Number(store?.sales ?? store?.salesCount) || 0);
const stock = Math.max(0, Number(store?.stock ?? store?.stocks) || 0);
const ratio = stock > 0 ? Math.round((sales / stock) * 100) : 0;
const progressPercent = Math.max(0, Math.min(100, ratio));
return {
sales,
stock,
progressPercent,
progressText: `${sales} / ${stock}`,
};
};
const normalizeRow = (store) => {
const status = getStoreStatus(store);
const statusConfig = statusMap[status] || { text: '--', className: '' };
const toggleActionText = status === 1 ? '休息' : status === 2 || status === 3 ? '营业' : '';
const progressInfo = getStoreProgressInfo(store);
return {
id: Number(store?.id || 0),
name: getStoreName(store),
code: getStoreCode(store),
phone: getStorePhone(store),
address: getStoreAddress(store),
coverImage: getStoreCoverImage(store),
sales: progressInfo.sales,
stock: progressInfo.stock,
progressPercent: progressInfo.progressPercent,
progressText: progressInfo.progressText,
status,
statusText: statusConfig.text,
statusClass: statusConfig.className,
isOpen: status === 1,
toggleActionText,
raw: store,
};
};
const filteredList = computed(() => {
const k = String(keyword.value || '').trim();
if (!k) return list.value;
return list.value.filter(
(row) =>
String(row.name).includes(k) ||
String(row.code).includes(k) ||
String(row.phone).includes(k) ||
String(row.address).includes(k),
);
});
const stats = computed(() => {
const total = Array.isArray(list.value) ? list.value.length : 0;
const open = Array.isArray(list.value) ? list.value.filter((r) => r.isOpen).length : 0;
return {
total,
open,
todayOrders: todayOrders.value,
};
});
const updateTodayOrders = async (storeIds = '') => {
const pickUpStoreId = toStoreIdsString(storeIds);
if (!pickUpStoreId) {
todayOrders.value = 0;
return;
}
try {
const { code, data } = await OrderStoreApi.getTodayNewCount(pickUpStoreId);
todayOrders.value = code === 0 ? Math.max(0, Number(data) || 0) : 0;
} catch (error) {
todayOrders.value = 0;
}
};
const getList = async (force = false) => {
while (force && loading.value) {
await new Promise((resolve) => setTimeout(resolve, 50));
}
if (loading.value) return;
loading.value = true;
try {
const storeIds = await getUserStoreIds();
if (!storeIds) {
list.value = [];
todayOrders.value = 0;
return;
}
const status = statusOptions[statusIndex.value]?.value;
const params = status === '' ? {} : { status };
const { code, data } = await StoreApi.getStoreListByStoreIds(storeIds, params);
if (code !== 0) {
todayOrders.value = 0;
return;
}
const rows = Array.isArray(data) ? data : [];
list.value = rows.map(normalizeRow).filter((r) => r.id > 0);
await updateTodayOrders(storeIds);
} finally {
loading.value = false;
}
};
const addStore = () => {
uni.showToast({ title: '功能开发中', icon: 'none' });
};
const bindStatusChange = (e) => {
statusIndex.value = Number(e?.detail?.value || 0);
getList();
};
const edit = () => {
uni.showToast({ title: '功能开发中', icon: 'none' });
};
const toggle = (row) => {
const storeId = Number(row?.id || 0);
const nextStatus = row?.status === 1 ? 2 : row?.status === 2 || row?.status === 3 ? 1 : 0;
const actionText = nextStatus === 1 ? '营业' : '休息';
if (!(storeId > 0) || !(nextStatus === 1 || nextStatus === 2) || updatingStoreId.value === storeId) return;
uni.showModal({
title: '提示',
content: `确认${actionText}该网店吗?`,
success: async ({ confirm }) => {
if (!confirm) return;
updatingStoreId.value = storeId;
try {
const { code } = await StoreApi.updateStatus(storeId, nextStatus);
if (code !== 0) return;
uni.showToast({ title: `${actionText}成功`, icon: 'success' });
await getList();
} catch (error) {
uni.showToast({ title: `${actionText}失败,请稍后重试`, icon: 'none' });
} finally {
updatingStoreId.value = 0;
}
},
});
};
onShow(() => {
getList();
});
onPullDownRefresh(async () => {
try {
await getList(true);
} finally {
uni.stopPullDownRefresh();
}
});
</script>
<style scoped lang="scss">
.page {
padding: 24rpx 24rpx 170rpx;
box-sizing: border-box;
}
.stats {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 16rpx;
margin-bottom: 18rpx;
}
.stat {
border-radius: 24rpx;
padding: 18rpx 18rpx 16rpx;
box-sizing: border-box;
}
.stat-value {
margin-top: 8rpx;
font-size: 44rpx;
font-weight: 800;
color: #222;
}
.cGreen {
color: #14a44d;
}
.cOrange {
color: #ff7a00;
}
.tool-row {
border-radius: 24rpx;
padding: 16rpx;
box-sizing: border-box;
display: flex;
align-items: center;
gap: 14rpx;
margin-bottom: 18rpx;
}
.search-box {
border-radius: 18rpx;
background: #f6f7fb;
padding: 6rpx 16rpx;
box-sizing: border-box;
}
:deep(.search-input .uni-easyinput__content) {
background: transparent !important;
}
.status-picker {
flex-shrink: 0;
min-width: 180rpx;
border-radius: 18rpx;
background: #f6f7fb;
padding: 0 18rpx;
box-sizing: border-box;
}
.status-picker__inner {
height: 72rpx;
display: flex;
align-items: center;
justify-content: space-between;
gap: 10rpx;
}
.status-picker__text {
font-size: 24rpx;
color: #333;
white-space: nowrap;
}
.btnAdd {
padding: 14rpx 18rpx;
border-radius: 18rpx;
background: #2556ec;
color: #fff;
font-size: 24rpx;
flex-shrink: 0;
}
.table {
padding: 0;
box-sizing: border-box;
background: transparent;
}
.tr {
margin-bottom: 18rpx;
padding: 18rpx 18rpx 20rpx;
border-radius: 24rpx;
background: #fff;
box-shadow: 0 8rpx 24rpx rgba(15, 23, 42, 0.05);
box-sizing: border-box;
}
.tr:last-child {
margin-bottom: 0;
}
.store-rank {
position: absolute;
left: 0;
top: 0;
min-width: 68rpx;
height: 36rpx;
padding: 0 12rpx;
border-radius: 0 18rpx 18rpx 0;
background: rgba(37, 86, 236, 0.1);
color: #2556ec;
font-size: 22rpx;
font-weight: 700;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
.store-card {
position: relative;
align-items: flex-start;
padding-top: 52rpx;
}
.store-cover {
width: 120rpx;
height: 120rpx;
border-radius: 18rpx;
overflow: hidden;
flex-shrink: 0;
background: #f2f4f7;
}
.store-cover__img,
.store-cover__empty {
width: 100%;
height: 100%;
}
.store-cover__img {
display: block;
}
.store-cover__empty {
display: flex;
align-items: center;
justify-content: center;
color: #b4bcc8;
font-size: 22rpx;
border: 2rpx dashed #e5e7eb;
box-sizing: border-box;
}
.store-main {
min-width: 0;
flex: 1;
margin-left: 18rpx;
}
.store-main__top {
align-items: flex-start;
gap: 16rpx;
}
.store-name {
min-width: 0;
flex: 1;
font-size: 28rpx;
color: #222;
font-weight: 700;
}
.store-code {
margin-top: 12rpx;
font-size: 24rpx;
}
.store-contact,
.store-address {
margin-top: 8rpx;
font-size: 24rpx;
line-height: 34rpx;
}
.store-progress {
margin-top: 14rpx;
}
.store-progress__head {
margin-bottom: 8rpx;
}
.store-progress__label,
.store-progress__value {
font-size: 22rpx;
color: #667085;
}
.store-progress__bar {
width: 100%;
height: 12rpx;
border-radius: 999rpx;
background: #edf1f7;
overflow: hidden;
}
.store-progress__fill {
height: 100%;
border-radius: 999rpx;
background: linear-gradient(90deg, #2556ec 0%, #5b8cff 100%);
}
.store-actions {
margin-top: 18rpx;
gap: 18rpx;
}
.badge {
padding: 6rpx 12rpx;
border-radius: 999rpx;
font-size: 22rpx;
flex-shrink: 0;
}
.badgeOpen {
color: #14a44d;
background: rgba(20, 164, 77, 0.12);
}
.badgePending {
color: #ff8a00;
background: rgba(255, 138, 0, 0.12);
}
.badgeRest {
color: #5b4eff;
background: rgba(91, 78, 255, 0.12);
}
.badgeClosed {
color: #8c8c8c;
background: rgba(140, 140, 140, 0.12);
}
.badgeRejected {
color: #ff4d4f;
background: rgba(255, 77, 79, 0.12);
}
.op {
font-size: 24rpx;
min-width: 120rpx;
height: 50rpx;
padding: 0 24rpx;
border-radius: 16rpx;
display: inline-flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
font-weight: 600;
border: 2rpx solid #e5e7eb;
background: #fff;
flex-shrink: 0;
}
.opPrimary {
color: #2556ec;
border-color: rgba(37, 86, 236, 0.2);
background: rgba(37, 86, 236, 0.06);
}
.opDanger {
color: #ff4d4f;
border-color: rgba(255, 77, 79, 0.28);
background: #fff5f5;
}
.opSuccess {
color: #14a44d;
border-color: rgba(20, 164, 77, 0.28);
background: #f2fbf5;
}
.opDisabled {
opacity: 0.6;
}
.empty {
text-align: center;
padding: 80rpx 0;
}
</style>
+13 -4
View File
@@ -10,7 +10,7 @@
/>
<view
class="item font-color"
:class="[state.deliveryType === '2' ? 'on' : 'on2', props.theme == '2' ? 'c0' : '']"
:class="[state.deliveryType === 2 ? 'on' : 'on2', props.theme == '2' ? 'c0' : '']"
@tap="switchDeliveryType(2)"
v-if="state.isPickUp"
/>
@@ -53,7 +53,7 @@
<!-- 情况二:门店的选择 -->
<view
class="address flex flex-wrap flex-center ss-row-between"
v-if="state.deliveryType === '2'"
v-if="state.deliveryType === 2"
@tap="onSelectAddress"
:class="{ 'bg24 c0': props.theme == '2' }"
>
@@ -62,8 +62,8 @@
>{{ state.pickUpInfo.name }}
<text class="phone">{{ state.pickUpInfo.phone }}</text>
</view>
<view class="line1">
{{ state.pickUpInfo.areaName }}{{ ', ' + state.pickUpInfo.detailAddress }}
<view class="line1 line2">
{{ formatPickUpAddress(state.pickUpInfo) }}
</view>
</view>
<view class="addressCon" v-else>
@@ -145,6 +145,15 @@
}
}
// 格式化自提门店地址,优先使用 address 字段
function formatPickUpAddress(info = {}) {
const address = info?.address || '';
if (address) return address;
const district = info?.district || '';
const description = info?.description || '';
return `${district}${description ? `, ${description}` : ''}`.trim();
}
// 收货方式切换
const switchDeliveryType = (type) => {
state.value.deliveryType = type;
+219 -35
View File
@@ -1,15 +1,29 @@
<!-- 售后申请 -->
<template>
<s-pages title="申请售后">
<s-pages title="申请售后" :pink_bg="true">
<!-- 售后商品 -->
<view class="goods-box">
<s-goods-item
:img="state.item.picUrl"
:title="state.item.spuName"
:skuText="state.item.properties?.map((property) => property.valueName).join(' ')"
:price="state.item.price"
:num="state.item.count"
/>
<template v-if="state.itemId > 0 && state.item?.id">
<s-goods-item
:img="state.item.picUrl"
:title="state.item.spuName"
:skuText="state.item.properties?.map((property) => property.valueName).join(' ')"
:price="state.item.price"
:num="state.item.count"
/>
</template>
<template v-else-if="state.orderItems?.length">
<s-goods-item
v-for="(item, index) in state.orderItems"
:key="item?.id || index"
:img="item.picUrl"
:title="item.spuName"
:skuText="item.properties?.map((property) => property.valueName).join(' ')"
:price="item.price"
:num="item.count"
:style="index < state.orderItems.length - 1 ? { marginBottom: '16rpx' } : {}"
/>
</template>
</view>
<uni-forms ref="form" v-model="formData" :rules="rules" label-position="top">
@@ -43,8 +57,8 @@
@tap="state.showModal = true"
>
<text class="item-title">退款金额</text>
<view class="ss-flex refund-cause ss-col-center">
<text class="ss-m-r-20">¥{{ fen2yuan(state.item.payPrice) }}</text>
<view class="ss-flex ss-col-center">
<text class="ss-m-r-20">¥{{ fen2yuan(state.payPrice) }}</text>
</view>
</view>
<!-- 申请原因 -->
@@ -117,19 +131,26 @@
<script setup>
import sheep from '@/sheep';
import { onLoad } from '@dcloudio/uni-app';
import { reactive, ref } from 'vue';
import { computed, reactive, ref } from 'vue';
import OrderApi from '@/sheep/api/trade/order';
import TradeConfigApi from '@/sheep/api/trade/config';
import { fen2yuan } from '@/sheep/hooks/useGoods';
import AfterSaleApi from '@/sheep/api/trade/afterSale';
import {
getOrderDetail as getAiOrderDetail,
getOpenOrderDetail,
} from '@/sheep/api/ai';
const form = ref(null);
const state = reactive({
orderId: 0, // 订单编号
itemId: 0, // 订单项编号
source: '', // 订单来源:空=普通商城订单 | aishop=店铺订单
order: {}, // 订单
item: {}, // 订单项
orderItems: [], // 用于展示的订单项列表(整单售后时展示全部,单品售后时展示单个)
config: {}, // 交易配置
payPrice: 0, // 退款金额:单品取item.payPrice,整单取外层order.payPrice
// 售后类型
wayList: [
@@ -154,25 +175,104 @@
});
const rules = reactive({});
// 提交表单
// 整数安全求和(避免浮点误差,兼容 iOS / 安卓 10 / 鸿蒙 / 低版本 Android WebView):
// 以分为单位的 payPrice 理论上应是整数,但接口返回偶尔会是浮点数(比如 100.00)。
// 用 Math.round(Number(x)*100)/100 做归一化后再累加,保证 0.1+0.2===0.3 的情况不出错。
function safeAddInt(...nums) {
let total = 0;
for (let i = 0; i < nums.length; i++) {
const raw = Number(nums[i] ?? 0) || 0;
const normalized = Math.round(raw * 100) / 100;
total = Math.round((total + normalized) * 100) / 100;
}
return Math.round(total); // 最终一定是整数分
}
// 按用户要求:申请售后展示/计算只处理 afterSaleStatus===0 的商品;其他状态的商品不展示、不算退款金额、不提交到接口。
// 单品售后(itemId>0)保持原逻辑,因为单品是用户从某个具体商品点进来的,一定是这一个。
// 整单售后(itemId===0):
// ① state.orderItems = data.items 里 afterSaleStatus===0 的那些;
// ② state.payPrice = 过滤后的商品 payPrice 整数累加(不用外层 order.payPrice,避免把其他状态的商品金额算进去);
// ③ submit() 里 targetItems 直接用 state.orderItems(已过滤,自然就不会包含非 0 的商品)。
function filterAfterSaleItems(items) {
if (!Array.isArray(items)) return [];
return items.filter((it) => {
const v = it?.afterSaleStatus === undefined ? it?.after_sale_status : it.afterSaleStatus;
return Number(v) === 0;
});
}
// 提交表单:接口 POST /trade/after-sale/create
// Body 直接就是数组:AppAfterSaleCreateReqVO[]
// - 单品售后(state.itemId > 0):数组只含 1 项,orderItemId = 当前商品项 id
// - 整单售后(state.itemId = 0):数组包含【仅 afterSaleStatus===0】的商品,每一项 orderItemId=对应商品项 id,refundPrice=对应商品项自己的 payPrice
// 每个 VO 字段:orderItemId(必填)、way(1仅退款/2退货退款 必填)、refundPrice(单位分 必填)
// applyReason(必填 string)、applyDescription(选填)、applyPicUrls(选填 数组或null)
async function submit() {
let data = {
orderItemId: state.itemId,
refundPrice: state.item.payPrice,
...formData,
};
const { code } = await AfterSaleApi.createAfterSale(data);
if (code === 0) {
uni.showToast({
title: '申请成功',
});
uni.navigateBack({
delta: 1,
});
if (!formData.way) {
uni.showToast({ title: '请选择售后类型', icon: 'none' });
return;
}
if (!formData.applyReason) {
uni.showToast({ title: '请选择申请原因', icon: 'none' });
return;
}
// 通用字段(整单/单品都一样)
// way:不再做前端值到后端值的映射,配置的是多少就传多少(wayList.value = '10' 仅退款 / '20' 退货退款,直接转整数传)
const way = parseInt(formData.way, 10);
const applyReason = String(formData.applyReason);
const applyDescription = String(formData.applyDescription || '');
// applyPicUrls:类型应该是数组或 null(用户最新要求);有值传数组,没值传 null(不传空字符串)
let applyPicUrls = null;
if (Array.isArray(formData.applyPicUrls)) {
const list = formData.applyPicUrls.filter(Boolean);
applyPicUrls = list.length ? list : null;
} else if (formData.applyPicUrls) {
applyPicUrls = [String(formData.applyPicUrls)];
} else {
uni.navigateBack({
delta: 1,
});
applyPicUrls = null;
}
// 选择要提交的订单项列表
let targetItems = [];
if (state.itemId > 0 && state.item?.id) {
// 单品售后:只传当前选择的这一个订单项
targetItems = [state.item];
} else {
// 整单售后:只传 afterSaleStatus===0 的商品(state.orderItems 已经在 onLoad 里过滤过一遍)
targetItems = Array.isArray(state.orderItems) ? state.orderItems.slice() : [];
// 保险:再过滤一次 afterSaleStatus===0,避免后续代码改动导致 orderItems 混入非 0 状态的商品
targetItems = filterAfterSaleItems(targetItems);
}
if (!targetItems.length) {
uni.showToast({ title: '缺少可申请售后的商品', icon: 'none' });
return;
}
// 组装数组 AppAfterSaleCreateReqVO[](直接就是数组,不要外层对象包裹)
const body = targetItems
.filter((it) => it && it.id)
.map((it) => ({
orderItemId: it.id,
way,
// 退款金额:按订单项自己的 payPrice;统一经 safeAddInt 归一化后取整数,避免浮点
refundPrice: safeAddInt(it.payPrice ?? 0),
applyReason,
applyDescription,
applyPicUrls,
}));
if (!body.length) {
uni.showToast({ title: '缺少订单项信息', icon: 'none' });
return;
}
const { code } = await AfterSaleApi.createAfterSale(body);
if (code === 0) {
uni.showToast({ title: '申请成功' });
uni.navigateBack({ delta: 1 });
} else {
uni.navigateBack({ delta: 1 });
}
}
//申请原因
@@ -210,21 +310,105 @@
}
onLoad(async (options) => {
// 解析参数
if (!options.orderId || !options.itemId) {
// 解析参数:兼容单品入口(传orderId+itemId)和整单入口(传订单对象即props.data.id)
const orderId = parseInt(options.orderId || options.id);
const itemId = options.itemId ? parseInt(options.itemId) : 0;
// 订单来源:'aishop' = 普通店铺订单;空=普通商城订单。
// 注:用 source/__source/orderSource 三个命名从 options 里读,但 NEVER 从整个订单对象里读"同名字段 type"来判断是否开通店铺订单。
const source = String(options.source || options.orderSource || options.__source || '').trim();
// 开通店铺订单标记:只从 openOrderType / openOrder 里读(而不是订单对象里通用的 type 字段,避免普通商城订单的 type=0~4 被误命中)。
const openOrderType = String(options.openOrderType || options.openOrder || '').trim();
if (!orderId) {
sheep.$helper.toast(`缺少订单信息,请检查`);
return;
}
state.orderId = options.orderId;
state.itemId = parseInt(options.itemId);
state.orderId = orderId;
state.itemId = itemId;
state.source = source;
// 读取订单信息
const { code, data } = await OrderApi.getOrderDetail(state.orderId);
// 读取订单详情:严格按入口参数分流,禁止普通商城订单 / 普通店铺订单误调开通店铺接口 /aishop/order/get-detail-open
//
// 开通店铺订单(ONLY:openOrderType === '5')
// → /aishop/order/get-detail-open
// 普通店铺订单(source === 'aishop' && 不是开通店铺)
// → /aishop/order/get-detail
// 普通商城订单(其他任何情况,包括没传 source/type 都算普通商城兜底)
// → /trade/order/get-detail ONLY
//
// 最后一道保险:如果我们选择了 getOpenOrderDetail,但返回的数据类型不是 5,说明命中错误 → 自动回退到对应接口。
let detailResult = null;
const isOpenOrder = openOrderType === '5';
const isAiStoreOrder = source === 'aishop';
async function loadMallOrder() {
return OrderApi.getOrderDetail(state.orderId);
}
async function loadAiOrder() {
return getAiOrderDetail({ id: state.orderId });
}
async function loadOpenOrder() {
const res = await getOpenOrderDetail({ id: state.orderId });
if (res?.code === 0 && res?.data && Number(res.data?.type) === 5) return res;
// 开了 openOrderType=5 但接口返回并不是 type=5 → 回退:按是否 aishop 来源决定
return isAiStoreOrder ? loadAiOrder() : loadMallOrder();
}
if (isOpenOrder) {
// 只有入口明确传 openOrderType=5 才调用开通店铺接口;返回不满足 type===5 时内部自动回退
detailResult = await loadOpenOrder();
} else if (isAiStoreOrder) {
// 普通店铺订单:只调店铺详情接口 /aishop/order/get-detail;绝对不碰 /get-detail-open
detailResult = await loadAiOrder();
} else {
// ★ 普通商城订单:只调 /trade/order/get-detail;永远不请求任何 aishop 前缀的接口
detailResult = await loadMallOrder();
}
if (!detailResult) {
return;
}
const { code, data } = detailResult;
if (code !== 0) {
return;
}
state.order = data;
state.item = data.items.find((item) => item.id === state.itemId) || {};
// 订单级 refundStatus:0 未退款 / 10 部分退款 / 20 全部退款
// 用户需求:如果是 20(全部退款),不允许再进入申请售后页面 → 直接提示并返回。
const __rStatus = data?.refundStatus === undefined ? data?.refund_status : data?.refundStatus;
if (Number(__rStatus) === 20) {
uni.showToast({ title: '该订单已全部退款,无需再次申请售后', icon: 'none' });
setTimeout(() => uni.navigateBack({ delta: 1 }), 600);
return;
}
// 按itemId精确查找订单项(单品入口),否则默认取第1项(整单入口仅用于商品卡片展示)
// 注意:无论单品还是整单,都只展示 + 计算 + 提交 afterSaleStatus===0 的商品。
const allItems = Array.isArray(data.items) ? data.items : [];
const applyableItems = filterAfterSaleItems(allItems); // 只留 afterSaleStatus===0
if (state.itemId > 0) {
// 单品售后:按用户点进来的 itemId 精确查找(理论上应该已经是 afterSaleStatus===0 的商品,不是的话就为空)
const picked = applyableItems.find((it) => Number(it.id) === Number(state.itemId)) || null;
state.item = picked || {};
state.orderItems = picked ? [picked] : [];
} else {
// 整单售后:仅展示 afterSaleStatus===0 的商品
state.item = applyableItems[0] || data.items?.[0] || {};
state.orderItems = applyableItems;
}
// 退款金额:
// - 单品售后(itemId>0):用订单项的 payPrice(精确匹配到的那一件)
// - 整单售后(itemId===0):使用【过滤后 afterSaleStatus===0 的商品的 payPrice 整数累加】
// 不再使用外层 order.payPrice,避免把其他状态的商品金额(已申请/已取消/已完成售后的商品)算进来导致误差。
if (state.itemId > 0 && state.item?.id) {
state.payPrice = safeAddInt(state.item.payPrice ?? 0);
} else {
if (!applyableItems.length) {
state.payPrice = 0;
} else {
state.payPrice = safeAddInt(...applyableItems.map((it) => it.payPrice ?? 0));
}
}
// 设置选项
if (state.order.status === 10) {
+8 -8
View File
@@ -1,5 +1,5 @@
<template>
<s-pages title="确认订单">
<s-pages title="确认订单" :pink_bg="true">
<!-- 头部地址选择【配送地址】【自提地址】 -->
<AddressSelection v-model="addressState" />
@@ -188,10 +188,10 @@
// 提交订单
function onConfirm() {
if (fen2yuan(state.orderInfo.price.payPrice) >= 5000) {
sheep.$helper.toast('订单金额不能超过5000元, 请重新选择商品');
return;
}
// if (fen2yuan(state.orderInfo.price.payPrice) >= 5000) {
// sheep.$helper.toast('订单金额不能超过5000元, 请重新选择商品');
// return;
// }
if (addressState.value.deliveryType === 1 && !addressState.value.addressInfo.id) {
sheep.$helper.toast('请选择收货地址');
return;
@@ -282,9 +282,9 @@
if (state.orderInfo.address) {
addressState.value.addressInfo = state.orderInfo.address;
}
if (fen2yuan(state.orderInfo.price.payPrice) >= 5000) {
sheep.$helper.toast('订单金额不能超过5000元');
}
// if (fen2yuan(state.orderInfo.price.payPrice) >= 5000) {
// sheep.$helper.toast('订单金额不能超过5000元');
// }
return code;
}
+812 -21
View File
@@ -1,6 +1,6 @@
<!-- 订单详情 -->
<template>
<s-pages title="订单详情">
<s-pages title="订单详情" :pink_bg="true">
<!-- 收货地址 -->
<view class="order-address-box flex-row bg24" v-if="state.orderInfo.receiverAreaId > 0">
<view class="cityImg">
@@ -20,17 +20,31 @@
</view>
<view
class="detail-goods"
:style="[{ marginTop: state.orderInfo.receiverAreaId > 0 ? '0' : '-40rpx' }]"
:style="[{ marginTop: state.orderInfo.receiverAreaId > 0 ? '0' : '0' }]"
>
<card_order
class="order-goods"
v-if="state?.orderInfo?.items?.length > 0"
:data="state.orderInfo"
:source="state.source"
:delay-records="state.delayRecords"
:hide-item-after-sale="isAiActionOrder"
type="2"
theme="2"
@getOrderDetail="getOrderDetail"
@openExpress="handleTruckLineExpress"
></card_order>
<PickUpVerify
v-if="Number(state.orderInfo.deliveryType) === 2"
ref="pickUpVerifyRef"
:orderInfo="state.orderInfo"
:systemStore="systemStore"
:source="state.source"
:orderType="state.orderType"
detailStyle="order"
/>
<!-- 价格信息 -->
<view class="order-price-box bg24">
<view class="notice-item ss-flex ss-row-between" v-for="(v, i) in priceArr" :key="i">
@@ -62,7 +76,13 @@
<view class="copy" @click.stop="onCopy">
<image :src="`${$url}goods/copy2.svg`" mode="scaleToFill" />
</view>
<truckLine :data="state.orderInfo" :code="1" v-if="state.orderInfo.deliveryTime"></truckLine>
<!-- 订单编号后不再展示物流 icon -->
<!-- <truckLine
:data="state.orderInfo"
:code="Number(isAiStoreOrder ? 2 : 1)"
v-if="state.orderInfo.deliveryTime"
@openExpress="handleTruckLineExpress"
></truckLine> -->
</view>
<view class="notice-item flex-row ju-between">
<text class="title c0">下单时间</text>
@@ -83,38 +103,124 @@
</view>
</view>
</view>
<su-fixed bottom placeholder bg="bg24" v-if="state.orderInfo.status != 30">
<su-fixed bottom placeholder bg="bg24" v-if="showBottomBar">
<view class="orderBan flex-column ju-center">
<card_orderBan :data="state.orderInfo" @downData="getOrderDetail" type="2"></card_orderBan>
<AiOrderActionBar
v-if="isAiActionOrder"
:status="Number(state.orderInfo.status)"
:disableDelayShipment="isPickUpOrder || !isAiStoreOrder"
:hasDelayedItems="hasDelayedItems"
:canDelayItems="canDelayItems"
:canShipItems="canShipItems"
:logisticsId="state.orderInfo.logisticsId"
:logisticsNo="state.orderInfo.logisticsNo"
:deliveryTime="state.orderInfo.deliveryTime"
:hasLogistics="hasLogistics"
:deliveryType="state.orderInfo.deliveryType"
:payStatus="state.orderInfo.payStatus"
:preparationStatus="state.orderInfo.preparationStatus"
:pickUpVerifyTime="state.orderInfo.pickUpVerifyTime"
:verifyTime="state.orderInfo.verifyTime"
:completedTime="state.orderInfo.completedTime"
:arriveStoreTime="state.orderInfo.arriveStoreTime"
:deliveredTime="state.orderInfo.deliveredTime"
@delay="delayShipment"
@now="nowShipment"
@confirm="confirmReceiveOrder"
@pay="goPay"
@cancel="cancelAiOrder"
@express="goExpressLog"
@remind="handleRemind"
/>
<card_orderBan
v-else
:data="state.orderInfo"
@downData="getOrderDetail"
@remind="handleRemind"
type="2"
></card_orderBan>
</view>
</su-fixed>
<ShipmentPopup
ref="nowShipmentPopupRef"
mode="now"
popup-type="center"
:order-no="state.orderInfo.no || ''"
:order-time="formatCreateTime(state.orderInfo.createTime) || ''"
:order-data="state.orderInfo"
:delay-records="state.delayRecords"
@close="closeNowShipmentPopup"
@submit="handleNowShipmentSubmit"
/>
<ShipmentPopup
ref="delayShipmentPopupRef"
mode="delay"
popup-type="center"
:order-no="state.orderInfo.no || ''"
:order-time="formatCreateTime(state.orderInfo.createTime) || ''"
:order-data="state.orderInfo"
:delay-records="state.delayRecords"
@close="closeDelayShipmentPopup"
@submit="handleDelayShipmentSubmit"
/>
<ReceiveItemPopup
ref="receiveItemPopupRef"
popup-type="center"
:order-no="state.orderInfo.no || ''"
:order-data="state.orderInfo"
:delay-records="state.delayRecords"
@close="closeReceiveItemPopup"
@submit="handleReceiveItemSubmit"
/>
<ExpressListPopup
ref="expressListPopupRef"
popup-type="center"
:order-no="state.orderInfo.no || ''"
:order-data="state.orderInfo"
:delay-records="state.delayRecords"
:order-id="resolveAiOrderId(state.orderInfo)"
@close="closeExpressListPopup"
/>
</s-pages>
</template>
<script setup>
import sheep from '@/sheep';
import { onLoad, onShow } from '@dcloudio/uni-app';
import { reactive, ref } from 'vue';
import { isEmpty } from 'lodash-es';
import {
fen2yuan,
formatOrderStatus,
formatOrderStatusDescription,
handleOrderButtons,
} from '@/sheep/hooks/useGoods';
import { computed, reactive, ref } from 'vue';
import { fen2yuan, handleOrderButtons } from '@/sheep/hooks/useGoods';
import OrderApi from '@/sheep/api/trade/order';
import DeliveryApi from '@/sheep/api/trade/delivery';
import PickUpVerify from '@/pages/order/pickUpVerify.vue';
import {
aiDelayedShipment,
aiPendingShipment,
confirmReceive as aiConfirmReceive,
giftConfirmReceive,
getOrderDetail as getAiOrderDetail,
getOpenOrderDetail,
cancelOrder as cancelAiOrderRequest,
cancelOpenOrder,
getAiOrderDelayRecords,
aiReceiveItem,
} from '@/sheep/api/ai';
import StoreApi from '@/sheep/api/trade/store';
import OrderStoreApi from '@/sheep/api/trade/orderStore';
import card_order from '@/components/orderItem/card_order.vue';
import truckLine from '@/components/truckLine/truckLine.vue'
import AiOrderActionBar from '@/components/orderItem/AiOrderActionBar.vue';
import ShipmentPopup from '@/components/orderItem/ShipmentPopup.vue';
import ReceiveItemPopup from '@/components/orderItem/ReceiveItemPopup.vue';
import ExpressListPopup from '@/components/orderItem/ExpressListPopup.vue';
import truckLine from '@/components/truckLine/truckLine.vue';
import PickUpVerify from '@/pages/order/pickUpVerify.vue';
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
const headerBg = sheep.$url.css('/static/img/shop/order/order_bg.png');
const state = reactive({
orderInfo: {},
merchantTradeNo: '', // 商户订单号
comeinType: '', // 进入订单详情的来源类型
orderType: '',
source: '',
delayRecords: [],
});
// ========== 门店自提(核销) ==========
@@ -124,8 +230,487 @@
const onCopy = () => {
sheep.$helper.copyText(state.orderInfo.no);
};
const formatCreateTime = (value) => {
if (!value) return '';
const s = sheep?.$helper?.timeFormat
? sheep.$helper.timeFormat(value, 'yyyy-mm-dd hh:MM:ss')
: String(value);
return s || '';
};
const pickUpVerifyRef = ref();
const remindLock = ref(false);
const resolvePickUpStoreIdForRemind = () => {
const data = state.orderInfo || {};
return Number(
data?.pickUpStoreId ||
data?.pickUpStore?.id ||
data?.pickUpStore?.storeId ||
data?.pickUpStoreVO?.id ||
data?.pickUpStoreVO?.storeId ||
data?.store?.id ||
data?.store?.storeId ||
systemStore.value?.id ||
systemStore.value?.storeId ||
data?.storeId ||
0,
);
};
const handleRemind = async () => {
return sheep.$helper.toast('已通知门店备货');
if (remindLock.value) {
sheep.$helper.toast('操作太频繁,请稍后再试');
return;
}
const pickUpStoreId = resolvePickUpStoreIdForRemind();
const orderId = state.orderInfo?.id || state.orderInfo?.orderId;
if (!orderId || !(pickUpStoreId > 0)) {
sheep.$helper.toast('订单信息异常');
return;
}
remindLock.value = true;
try {
const res = await OrderStoreApi.remindStore(pickUpStoreId, orderId);
if (res?.code === 0) {
sheep.$helper.toast(res?.msg || '已通知门店备货');
} else {
sheep.$helper.toast(res?.msg || '催一催失败,请稍后重试');
}
} catch (e) {
sheep.$helper.toast('催一催失败,请稍后重试');
} finally {
setTimeout(() => {
remindLock.value = false;
}, 5000);
}
};
const isAiActionOrder = computed(() => {
const orderType = Number(state.orderInfo?.type ?? state.orderType ?? 0);
return (
String(state.source) === 'aishop' ||
String(state.orderInfo?.__source) === 'aishop' ||
orderType === 4 ||
orderType === 5
);
});
const isPickUpOrder = computed(() => {
if (Number(state.orderInfo?.deliveryType) === 2) return true;
return Boolean(
state.orderInfo?.pickUpStoreId ||
state.orderInfo?.pickUpStore ||
state.orderInfo?.pickUpStoreVO ||
state.orderInfo?.pickUpVerifyCode,
);
});
const hasDelayedItems = computed(() => {
if (!isAiStoreOrder.value) return false;
if (isPickUpOrder.value) return false;
const records = Array.isArray(state.delayRecords)
? state.delayRecords
: Array.isArray(state.orderInfo?.delayRecords)
? state.orderInfo.delayRecords
: Array.isArray(state.orderInfo?.delayRecordList)
? state.orderInfo.delayRecordList
: [];
return records.some((record) => Number(record?.status) === 1);
});
const getCurrentDelayRecords = () => {
if (Array.isArray(state.delayRecords) && state.delayRecords.length > 0) return state.delayRecords;
const orderRecords = Array.isArray(state.orderInfo?.delayRecords)
? state.orderInfo.delayRecords
: Array.isArray(state.orderInfo?.delayRecordList)
? state.orderInfo.delayRecordList
: [];
return orderRecords;
};
const canDelayItems = computed(() => {
if (!isAiStoreOrder.value) return false;
if (isPickUpOrder.value) return false;
const delayRecords = getCurrentDelayRecords();
const hasActivated = delayRecords.some((record) => Number(record?.status) === 2);
if (hasActivated) return true;
if (delayRecords.length === 0) {
const totalCount = Number(state.orderInfo?.productCount || state.orderInfo?.totalCount || 0) || 0;
if (totalCount > 0) return true;
}
return false;
});
const canShipItems = computed(() => {
if (!isAiStoreOrder.value) return false;
if (isPickUpOrder.value) return false;
const delayRecords = getCurrentDelayRecords();
if (delayRecords.length === 0) {
const totalCount = Number(state.orderInfo?.productCount || state.orderInfo?.totalCount || 0) || 0;
return totalCount > 0;
}
return delayRecords.some((record) => {
const status = Number(record?.status);
return status === 1 || status === 2;
});
});
const hasLogistics = computed(() => {
const info = state.orderInfo || {};
if (Number(info.logisticsId) > 0) return true;
if (info.logisticsNo && String(info.logisticsNo).trim()) return true;
if (info.deliveryTime) return true;
const items = Array.isArray(info.items) ? info.items : [];
for (const item of items) {
if (Number(item?.logisticsId) > 0) return true;
if (item?.logisticsNo && String(item.logisticsNo).trim()) return true;
if (item?.deliveryTime) return true;
const subItems = Array.isArray(item?.items) ? item.items : [];
for (const sub of subItems) {
if (Number(sub?.logisticsId) > 0) return true;
if (sub?.logisticsNo && String(sub.logisticsNo).trim()) return true;
if (sub?.deliveryTime) return true;
}
}
return false;
});
const resolvePickUpStage = () => {
const data = state.orderInfo || {};
const external = Number(data?.preparationStatus);
const rawStatus = Number.isFinite(external) ? external : Number(data?.preparationStatus ?? data?.status ?? 0);
const isVerifyCompleted = Boolean(
data?.pickUpVerifyTime ||
data?.verifyTime ||
data?.completedTime ||
rawStatus === 30 ||
rawStatus === 3,
);
if (isVerifyCompleted) return 'done';
if (rawStatus === 1 || rawStatus === 2) return 'wait';
if (
data?.deliveryTime ||
data?.arriveStoreTime ||
data?.deliveredTime ||
rawStatus === 20
) {
return 'delivered';
}
return 'sorting';
};
const showBottomBar = computed(() => {
if (!isAiActionOrder.value) return true;
const status = Number(state.orderInfo?.status);
// 有物流信息(需要展示"查看物流")时,强制显示底部按钮栏
if (hasLogistics.value) return true;
if ([0, 15, 20, 30].includes(status)) return true;
if (!isAiStoreOrder.value) return hasLogistics.value;
// AI 店铺自提订单:分拣中/已送达门店时显示底部栏(展示催一催按钮);待取货/已核销后隐藏
if (isPickUpOrder.value) {
const stage = resolvePickUpStage();
return stage === 'sorting' || stage === 'delivered';
}
if (hasDelayedItems.value) return true;
return [10, 15, 50, 70].includes(status);
});
const resolvePickUpStoreId = (data = {}) => {
return Number(
data?.pickUpStoreId ||
data?.pickUpStore?.id ||
data?.pickUpStore?.storeId ||
data?.pickUpStoreVO?.id ||
data?.pickUpStoreVO?.storeId ||
data?.store?.id ||
data?.store?.storeId ||
data?.storeId ||
0,
);
};
const resolveAiOrderId = (data) => {
return data?.id || data?.orderId;
};
const isAiStoreOrder = computed(() => {
return String(state.source) === 'aishop' || String(state.orderInfo?.__source) === 'aishop';
});
const delayShipmentPopupRef = ref();
const nowShipmentPopupRef = ref();
const receiveItemPopupRef = ref();
const expressListPopupRef = ref();
const closeDelayShipmentPopup = () => {};
const closeNowShipmentPopup = () => {};
const closeReceiveItemPopup = () => {};
const closeExpressListPopup = () => {};
const reloadDelayRecords = async () => {
if (!isAiStoreOrder.value) {
state.delayRecords = [];
return;
}
const orderId = resolveAiOrderId(state.orderInfo);
if (!orderId) {
state.delayRecords = [];
return;
}
try {
const delayRes = await getAiOrderDelayRecords({ orderId });
if (delayRes.code === 0 && Array.isArray(delayRes.data)) {
state.delayRecords = delayRes.data;
return;
}
} catch (e) {
}
state.delayRecords = [];
};
const openDelayShipmentPopup = async () => {
const id = resolveAiOrderId(state.orderInfo);
if (!id) {
uni.showToast({
title: '订单信息异常',
icon: 'none',
});
return;
}
try {
await reloadDelayRecords();
} catch (e) {
}
delayShipmentPopupRef.value?.open();
};
const openNowShipmentPopup = () => {
const id = resolveAiOrderId(state.orderInfo);
if (!id) {
uni.showToast({
title: '订单信息异常',
icon: 'none',
});
return;
}
nowShipmentPopupRef.value?.open();
};
const handleDelayShipmentSubmit = async ({ items, close }) => {
const orderId = resolveAiOrderId(state.orderInfo);
if (!orderId || !Array.isArray(items) || items.length === 0) {
return;
}
const { code } = await aiDelayedShipment({
orderId,
items,
});
if (code === 0) {
close?.();
getOrderDetail();
}
};
const handleNowShipmentSubmit = async ({ items, close }) => {
const orderId = resolveAiOrderId(state.orderInfo);
if (!orderId || !Array.isArray(items) || items.length === 0) {
return;
}
const { code } = await aiPendingShipment({
orderId,
items,
});
if (code === 0) {
close?.();
getOrderDetail();
}
};
function delayShipment() {
if (isPickUpOrder.value) {
uni.showToast({
title: '自提订单不支持延迟发货',
icon: 'none',
});
return;
}
if (isAiStoreOrder.value) {
openDelayShipmentPopup();
return;
}
const id = resolveAiOrderId(state.orderInfo);
if (!id) {
uni.showToast({
title: '订单信息异常',
icon: 'none',
});
return;
}
uni.showModal({
title: '延迟发货',
content: '请您确认是否暂时不需要发货,确认后该产品将为您安排延迟发货',
confirmColor: '#FA7E31',
success: async function (res) {
if (!res.confirm) return;
const { code } = await aiDelayedShipment({
id,
status: 50,
});
if (code === 0) {
getOrderDetail();
}
},
});
}
function nowShipment() {
if (isPickUpOrder.value) {
uni.showToast({
title: '自提订单不支持立即发货',
icon: 'none',
});
return;
}
if (isAiStoreOrder.value) {
openNowShipmentPopup();
return;
}
const id = resolveAiOrderId(state.orderInfo);
if (!id) {
uni.showToast({
title: '订单信息异常',
icon: 'none',
});
return;
}
uni.showModal({
title: '立即发货',
content: '请您确认是否需要立即发货,确认后将尽快为您安排发货',
confirmColor: '#FA7E31',
success: async function (res) {
if (!res.confirm) return;
const { code } = await aiPendingShipment({
id,
status: 10,
});
if (code === 0) {
getOrderDetail();
}
},
});
}
const confirmReceiveOrder = async () => {
if (Number(state.orderInfo.status) === 15) {
receiveItemPopupRef.value?.open?.();
return;
}
const id = resolveAiOrderId(state.orderInfo);
if (!id) return;
const req =
Number(state.orderInfo?.type) === 5 || String(state.orderType) === '5'
? giftConfirmReceive
: aiConfirmReceive;
const { code } = await req({ id });
if (code === 0) {
getOrderDetail();
}
};
const handleReceiveItemSubmit = async ({ items }) => {
if (!Array.isArray(items) || items.length === 0) {
uni.showToast({
title: '请选择要确认收货的商品',
icon: 'none',
});
return;
}
const { code } = await aiReceiveItem({ items });
if (code === 0) {
receiveItemPopupRef.value?.close?.();
getOrderDetail();
}
};
const goPay = () => {
const id = resolveAiOrderId(state.orderInfo);
const payOrderId = state.orderInfo?.payOrderId;
if (!id || !payOrderId) {
uni.showToast({
title: '支付信息异常',
icon: 'none',
});
return;
}
sheep.$router.go('/pages/AI/cashierDesk', {
id,
payOrderId,
});
};
const goExpressLog = () => {
const id = resolveAiOrderId(state.orderInfo);
if (!id) {
uni.showToast({
title: '订单信息异常',
icon: 'none',
});
return;
}
// 店铺订单(source=aishop)、入店订单(type=4)、赠送店铺订单(type=5) 一律弹窗查看物流;只有普通商城订单走原生跳转
const orderType = Number(state.orderInfo?.type ?? state.orderType ?? 0);
const isStoreOrGiftOrInStore =
isAiStoreOrder.value || orderType === 4 || orderType === 5;
if (!isStoreOrGiftOrInStore) {
sheep.$router.go('/pages/order/express/log', { id });
return;
}
if (!isPickUpOrder.value) {
expressListPopupRef.value?.open?.();
return;
}
sheep.$router.go('/pages/order/express/log', { id });
};
const handleTruckLineExpress = () => {
const id = resolveAiOrderId(state.orderInfo);
if (!id) {
uni.showToast({
title: '订单信息异常',
icon: 'none',
});
return;
}
// 店铺订单(source=aishop)、入店订单(type=4)、赠送店铺订单(type=5) 一律弹窗查看物流;只有普通商城订单走原生跳转
const orderType = Number(state.orderInfo?.type ?? state.orderType ?? 0);
const isStoreOrGiftOrInStore =
isAiStoreOrder.value || orderType === 4 || orderType === 5;
if (!isStoreOrGiftOrInStore) {
sheep.$router.go('/pages/order/express/log', { id });
return;
}
if (!isPickUpOrder.value) {
expressListPopupRef.value?.open?.();
return;
}
sheep.$router.go('/pages/order/express/log', { id });
};
const cancelAiOrder = () => {
const id = resolveAiOrderId(state.orderInfo);
if (!id) return;
uni.showModal({
title: '提示',
content: '确定要取消订单吗?',
confirmColor: '#FA7E31',
success: async (res) => {
if (!res.confirm) return;
const request =
Number(state.orderInfo?.type) === 5 || String(state.orderType) === '5'
? cancelOpenOrder
: cancelAiOrderRequest;
const result = await request({ id });
if (result.code === 0) await getOrderDetail();
},
});
};
async function getOrderDetail() {
let id = state.orderInfo.id;
@@ -137,19 +722,79 @@
merchant_trade_no: state.merchantTradeNo,
});
} else {
res = await OrderApi.getOrderDetail(id);
// 开通店铺订单(type=5)优先级最高,独立接口,不影响正常商城订单/店铺订单
const isOpenOrder =
Number(state.orderInfo?.type) === 5 ||
String(state.orderType) === '5';
if (isOpenOrder) {
res = await getOpenOrderDetail({ id });
} else if (String(state.source) === 'aishop') {
res = await getAiOrderDetail({ id });
} else {
res = await OrderApi.getOrderDetail(id);
}
}
if (res.code === 0) {
state.orderInfo = res.data;
handleOrderButtons(state.orderInfo);
// 配送方式:门店自提
if (res.data.pickUpStoreId) {
const { data } = await DeliveryApi.getDeliveryPickUpStore(res.data.pickUpStoreId);
const isPickUp = Number(res.data?.deliveryType) === 2;
const pickUpStoreId = resolvePickUpStoreId(res.data);
if (isPickUp && pickUpStoreId > 0) {
const { data } = await StoreApi.getStoreById(pickUpStoreId);
systemStore.value = data || {};
} else {
systemStore.value = {};
}
// 自提订单:同步备货进度(用于核销区是否展示二维码、门店卡片是否展示、状态 Tag 同步)
if (isPickUp && (state.orderInfo.deliveryType === 2 || pickUpStoreId > 0) && state.orderInfo.payStatus) {
try {
const prepRes = await OrderStoreApi.getPreparationStatus(pickUpStoreId, state.orderInfo.id || state.orderInfo.orderId);
if (prepRes?.code === 0) {
const raw = prepRes.data;
if (raw !== null && typeof raw === 'object') {
const merged = raw?.orderInfo || raw;
state.orderInfo = {
...state.orderInfo,
...(merged || {}),
};
const nextStatus = Number(merged?.preparationStatus ?? merged?.status);
if (Number.isFinite(nextStatus)) {
state.orderInfo.preparationStatus = nextStatus;
}
} else {
const nextStatus = Number(raw);
if (Number.isFinite(nextStatus)) {
state.orderInfo.preparationStatus = nextStatus;
}
}
}
} catch (e) {
}
}
if (state.orderInfo.deliveryType === 2 && state.orderInfo.payStatus) {
pickUpVerifyRef.value && pickUpVerifyRef.value.markCode(res.data.pickUpVerifyCode);
}
// 店铺订单:延迟记录独立拉取
if (isAiStoreOrder.value) {
const orderId = resolveAiOrderId(state.orderInfo);
if (orderId) {
try {
const delayRes = await getAiOrderDelayRecords({ orderId });
if (delayRes.code === 0 && Array.isArray(delayRes.data)) {
state.delayRecords = delayRes.data;
} else {
state.delayRecords = [];
}
} catch (e) {
state.delayRecords = [];
}
} else {
state.delayRecords = [];
}
} else {
state.delayRecords = [];
}
} else {
sheep.$router.back();
}
@@ -170,6 +815,12 @@
if (state.comeinType === 'wechat') {
state.merchantTradeNo = options.merchant_trade_no;
}
if (options.type !== undefined) {
state.orderType = options.type;
}
if (options.source !== undefined) {
state.source = options.source;
}
state.orderInfo.id = id;
});
@@ -179,6 +830,11 @@
value: 'totalPrice',
type: 1,
},
{
title: '随机优惠',
value: 'randomDiscountPrice',
type: 1,
},
{
title: '消费金抵扣',
value: 'consumptionPrice',
@@ -450,10 +1106,145 @@
}
.orderBan {
height: 140rpx;
height: 100rpx;
width: 100%;
padding: 0 24rpx;
box-sizing: border-box;
box-shadow: 0px -4px 30px 0px rgba(0, 0, 0, 0.1);
}
.delay-popup {
width: 680rpx;
max-height: 78vh;
background: #ffffff;
border-radius: 24rpx;
padding: 32rpx 24rpx;
box-sizing: border-box;
overflow: hidden;
}
.delay-popup__header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12rpx;
}
.delay-popup__title {
font-size: 34rpx;
font-weight: 600;
color: #333333;
}
.delay-popup__order-no {
margin-top: 8rpx;
font-size: 22rpx;
line-height: 32rpx;
color: #999999;
word-break: break-all;
}
.delay-popup__order-time {
margin-top: 4rpx;
font-size: 22rpx;
line-height: 32rpx;
color: #999999;
}
.delay-popup__close {
width: 56rpx;
height: 56rpx;
border-radius: 50%;
background: #f3f4f6;
line-height: 56rpx;
text-align: center;
font-size: 36rpx;
color: #666666;
}
.delay-popup__desc {
font-size: 24rpx;
color: #999999;
margin-bottom: 24rpx;
}
.delay-popup__content {
max-height: 760rpx;
}
.delay-popup__item {
display: flex;
padding: 20rpx 0;
border-bottom: 1rpx solid #f2f2f2;
}
.delay-popup__item-image {
width: 144rpx;
height: 144rpx;
border-radius: 12rpx;
flex-shrink: 0;
margin-right: 20rpx;
background: #f5f5f5;
}
.delay-popup__item-main {
flex: 1;
min-width: 0;
}
.delay-popup__item-name {
font-size: 28rpx;
line-height: 40rpx;
color: #333333;
}
.delay-popup__item-sku {
margin-top: 10rpx;
font-size: 24rpx;
line-height: 34rpx;
color: #999999;
}
.delay-popup__item-footer {
margin-top: 20rpx;
}
.delay-popup__item-count {
font-size: 24rpx;
color: #666666;
}
.delay-popup__actions {
display: flex;
align-items: center;
gap: 20rpx;
margin-top: 32rpx;
}
.delay-popup__btn {
flex: 1;
height: 84rpx;
line-height: 84rpx;
text-align: center;
border-radius: 42rpx;
font-size: 28rpx;
font-weight: 500;
}
.delay-popup__btn--ghost {
background: #f2f3f5;
color: #333333;
}
.delay-popup__btn--primary {
background: linear-gradient(135deg, #fa8735 0%, #fe3b48 100%);
color: #ffffff;
}
.now-shipment-empty {
padding: 40rpx 24rpx;
text-align: center;
font-size: 26rpx;
color: #999999;
}
</style>
+95 -10
View File
@@ -58,38 +58,123 @@
import { onLoad } from '@dcloudio/uni-app';
import { computed, reactive } from 'vue';
import OrderApi from '@/sheep/api/trade/order';
import { getOrderDetail as getAiOrderDetail, getOpenOrderDetail, getOpenOrderExpressTrackList } from '@/sheep/api/ai';
import { getExpressTrackList } from '@/sheep/api/index/index';
import HighlightNumber from '@/pages/components/HighlightNumberText.vue';
const state = reactive({
info: [],
info: {},
tracks: [],
});
const goodsImages = computed(() => {
let array = [];
if (state.info.items) {
if (state.info && state.info.items) {
state.info.items.forEach((item) => {
array.push({
image: item.picUrl,
});
});
}
if (state.info && state.info.delayRecords && Array.isArray(state.info.delayRecords)) {
state.info.delayRecords.forEach((record) => {
if (record.picUrl || record.orderItemVO?.picUrl) {
array.push({
image: record.picUrl || record.orderItemVO?.picUrl,
});
}
});
}
return array;
});
async function getExpressDetail(id) {
const { data } = await OrderApi.getOrderExpressTrackList(id);
state.tracks = data;
async function getExpressDetail(options) {
const id = options?.id;
const codeRaw = options?.code;
const code =
codeRaw !== undefined && codeRaw !== null && String(codeRaw).trim() !== ''
? Number(codeRaw)
: 0;
const delayRecordId = options?.delayRecordId;
const hasDelayRecordId =
delayRecordId !== undefined &&
delayRecordId !== null &&
String(delayRecordId).trim() !== '';
if (id) {
state.info.id = id;
}
// 开通店铺订单(type===5):物流接口 /aishop/app/open/order/get-express-track-list
const isOpenOrder = Number(state.info?.type) === 5;
if (isOpenOrder) {
// 优先传 delayRecordId + code=2;没传 delayRecordId 就只传 code(具体 code 值看原 code 参数)
const params = { id };
if (code === 2 && hasDelayRecordId) {
params.code = 2;
params.delayRecordId = delayRecordId;
} else if (code > 0) {
params.code = code;
if (hasDelayRecordId) params.delayRecordId = delayRecordId;
} else {
params.code = 0;
}
try {
const { data } = await getOpenOrderExpressTrackList(params);
state.tracks = Array.isArray(data) ? data : [];
} catch (e) {
state.tracks = [];
}
return;
}
if (code === 2 && hasDelayRecordId) {
const { data } = await getExpressTrackList({
id,
code: 2,
delayRecordId,
});
state.tracks = data;
} else if (code > 0) {
const { data } = await getExpressTrackList({
id,
code,
});
state.tracks = data;
} else {
const { data } = await OrderApi.getOrderExpressTrackList(id);
state.tracks = data;
}
}
async function getOrderDetail(id) {
const { data } = await OrderApi.getOrderDetail(id);
state.info = data;
if (!id) return;
// 开通店铺订单(type===5):详情接口 /aishop/order/get-detail-open,优先尝试
try {
const { code: rc, data } = await getOpenOrderDetail({ id });
if (rc === 0 && data && Number(data?.type) === 5) {
state.info = data;
return;
}
} catch (e) {}
try {
const { data } = await OrderApi.getOrderDetail(id);
if (data) {
state.info = data;
return;
}
} catch (e) {}
try {
const { data } = await getAiOrderDetail({ id });
if (data) {
state.info = data;
}
} catch (e) {}
}
onLoad((options) => {
getExpressDetail(options.id);
getOrderDetail(options.id);
onLoad(async (options) => {
// 先拿订单详情(确定 type===5,以及填充 state.info),再拿物流
await getOrderDetail(options?.id);
await getExpressDetail(options || {});
});
function handlePhoneClick(data) {
+206 -83
View File
@@ -1,6 +1,6 @@
<!-- 订单列表 -->
<template>
<s-layout title="我的订单">
<s-layout title="我的订单" navPreset="blue">
<card_pages
ref="cardPages"
:navList="tabMaps"
@@ -12,6 +12,25 @@
>
<template #nav>
<view class="nav">
<view class="order-list-nav-top">
<view class="type-tabs p-x-32">
<view
class="type-tab-item center"
v-for="(v, i) in typeArr"
:key="i"
@click="navChangeType(i)"
>
<view
class="type-tab-text size32"
:class="{
activeTypeItem: state.currentType === i,
}"
>
{{ v.name }}
</view>
</view>
</view>
</view>
<scroll-view scroll-x show-scrollbar="false" class="scroll-x-wrapper w100 nowrap p-x-32">
<view class="flex-center ju-flex-start nowrap" style="width: auto">
<view
@@ -26,17 +45,23 @@
</view>
</view>
</scroll-view>
<view class="search flex-center">
<view class="flex1" style="background-color: #fff; border-radius: 32rpx"
><uni-easyinput
prefixIcon="search"
v-model="state.obj.keyWord"
placeholder="搜索商品名称/订单编号"
@iconClick="iconClick"
>
</uni-easyinput
></view>
<view class="searchBtn size32 c0" @click="downCallback(state.currentTab)">搜索</view>
<view class="search">
<view class="searchInput flex-center">
<view class="searchField flex-center flex1">
<image class="searchFieldIcon" src="/static/icon/search.svg" mode="aspectFit" />
<uni-easyinput
class="flex1"
v-model="state.obj.keyWord"
placeholder="搜索商品名称/订单编号"
:inputBorder="false"
@iconClick="iconClick"
>
</uni-easyinput>
</view>
<view class="searchBtn flex-center" @click="downCallback(state.currentTab)">
<image class="searchBtnIcon" src="/static/icon/search.svg" mode="aspectFit" />
</view>
</view>
</view>
</view>
</template>
@@ -47,6 +72,7 @@
:data="v"
@downData="downCallback(state.currentTab)"
:index="state.currentTab"
:isAfterSale="tabMaps[state.currentTab].id === 4"
>
</orderItem>
</view>
@@ -57,28 +83,20 @@
</template>
<script setup>
import { ref, reactive, getCurrentInstance, onMounted } from 'vue';
import { onLoad, onShow, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app';
import { ref, reactive } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import orderItem from '@/components/orderItem/orderItem.vue';
import {
fen2yuan,
formatOrderColor,
formatOrderStatus,
handleOrderButtons,
} from '@/sheep/hooks/useGoods';
import sheep from '@/sheep';
import _ from 'lodash-es';
import { isEmpty } from 'lodash-es';
import { handleOrderButtons } from '@/sheep/hooks/useGoods';
import OrderApi from '@/sheep/api/trade/order';
import AfterSaleApi from '@/sheep/api/trade/afterSale';
import { resetPagination } from '@/sheep/helper/utils';
const instance = getCurrentInstance();
import { getOrderPage as getAiOrderPage } from '@/sheep/api/ai';
let cardPages = ref(null);
// 数据
const state = reactive({
currentTab: 0, // 选中的 tabMaps 下标
currentType: 0, // 选中的 typeArr 下标
list: {},
pageSize: 10,
loadStatus: '',
@@ -87,6 +105,11 @@
},
});
const typeArr = [
{ id: 0, name: '商城订单' },
{ id: 1, name: '店铺订单' },
];
const tabMaps = [
{
id: 0,
@@ -95,7 +118,7 @@
{
id: 1,
name: '待支付',
value: 0,
value: '0,70',
},
{
id: 10,
@@ -119,24 +142,54 @@
},
];
let dataList = ref([]);
const mergeAiStatusValue = (baseValue, extraList = []) => {
const set = new Set();
String(baseValue || '')
.split(',')
.map((s) => s.trim())
.filter(Boolean)
.forEach((s) => set.add(s));
(Array.isArray(extraList) ? extraList : [])
.map((s) => String(s).trim())
.filter(Boolean)
.forEach((s) => set.add(s));
return Array.from(set).join(',');
};
async function getData(mescroll) {
let code = null;
let data = null;
dataList.value = [];
if (mescroll.dataObj.status != '50,60') {
let res = await OrderApi.getOrderPage({
pageNo: mescroll.num,
pageSize: mescroll.size,
status: mescroll.dataObj.status,
...state.obj,
});
const tab = tabMaps?.[mescroll?.dataObj?.i] || null;
const tabStatusValue = tab?.value;
const isAiStore = state.currentType === 1;
let status = tabStatusValue;
if (isAiStore) {
const tabId = String(tab?.id);
if (tabId === '10') {
status = mergeAiStatusValue(tabStatusValue, ['10', '15']);
} else if (tabId === '2') {
status = mergeAiStatusValue(tabStatusValue, ['15', '20']);
}
}
const obj = {
pageNo: mescroll.num,
pageSize: mescroll.size,
status,
...state.obj,
};
if (!obj.status && obj.status !== 0) delete obj.status;
if (!obj.keyWord) delete obj.keyWord;
const isAfterSaleTab = String(tab?.id) === '4';
if (state.currentType === 0 && isAfterSaleTab) {
const res = await AfterSaleApi.getAfterSalePage(obj);
code = res.code;
dataList.value[mescroll.dataObj.i] = res.data;
} else if (state.currentType === 1) {
const res = await getAiOrderPage(obj);
code = res.code;
dataList.value[mescroll.dataObj.i] = res.data;
} else {
let res = await AfterSaleApi.getAfterSalePage({
pageNo: mescroll.num,
pageSize: mescroll.size,
});
const res = await OrderApi.getOrderPage(obj);
code = res.code;
dataList.value[mescroll.dataObj.i] = res.data;
}
@@ -147,13 +200,29 @@
return;
}
dataList.value[mescroll.dataObj.i].list.forEach((order) => handleOrderButtons(order));
const pageData = dataList.value?.[mescroll.dataObj.i] || {};
const list = Array.isArray(pageData?.list)
? pageData.list
: Array.isArray(pageData)
? pageData
: [];
const nextListRaw =
state.currentType === 1 ? list.map((o) => ({ ...o, __source: 'aishop' })) : list;
const isMallOrder = state.currentType === 0;
let nextList = isMallOrder && !isAfterSaleTab
? nextListRaw.map((order) => {
const items = Array.isArray(order?.items) ? order.items.filter((item) => Number(item?.afterSaleStatus ?? 0) === 0) : [];
return { ...order, items };
})
: nextListRaw;
if (isMallOrder && !isAfterSaleTab) {
nextList = nextList.filter((order) => Array.isArray(order?.items) && order.items.length > 0);
}
nextList.forEach((order) => handleOrderButtons(order));
if (mescroll.num == 1) state.list[mescroll.dataObj.i] = [];
state.list[mescroll.dataObj.i] = state.list[mescroll.dataObj.i].concat(
dataList.value[mescroll.dataObj.i].list,
);
state.list[mescroll.dataObj.i] = state.list[mescroll.dataObj.i].concat(nextList);
if (cardPages.value) {
cardPages.value.getState(true, dataList.value[mescroll.dataObj.i].list.length);
cardPages.value.getState(true, nextList.length);
}
}
@@ -161,39 +230,27 @@
if (options.type) {
state.currentTab = Number(options.type);
}
// await getOrderList();
if (options.currentType !== undefined) {
state.currentType = Number(options.currentType);
}
});
let sysInfo = uni.getSystemInfoSync();
let height =
sysInfo.windowHeight - sysInfo.statusBarHeight - uni.upx2px(100) - uni.upx2px(200) + 'px';
onMounted(() => {});
// 加载更多
function loadMore() {
if (state.loadStatus === 'noMore') {
return;
}
state.pagination.pageNo++;
getOrderList();
}
// 上拉加载更多
// onReachBottom(() => {
// loadMore();
// });
sysInfo.windowHeight - sysInfo.statusBarHeight - uni.upx2px(100) - uni.upx2px(320) + 'px';
const navChange = (i) => {
state.currentTab = i;
console.log(state);
// if(cardPages.value){
// cardPages.value.downCallback()
// }
};
const downCallback = (i) => {
if (i && i === 0) {
navChange(i);
if (cardPages.value) {
cardPages.value.downCallback();
}
};
const navChangeType = (i) => {
state.currentType = i;
state.currentTab = 0;
state.list = {};
downCallback(state.currentTab);
};
const downCallback = () => {
if (cardPages.value) {
cardPages.value.downCallback();
}
@@ -219,16 +276,56 @@
.navItem {
padding: 18rpx 0;
color: rgba(255, 255, 255, 0.85);
}
.activeItem {
color: #ff3c48;
border-bottom: 6rpx solid #ff3c48;
color: #ffffff;
border-bottom: 6rpx solid rgba(255, 255, 255, 0.95);
}
.nav {
height: 200rpx;
background-color: #fff;
height: 320rpx;
background-color: #2556ec;
background-image: url('/static/index/logIn_bg.png');
background-size: 100% auto;
background-repeat: no-repeat;
background-position: top center;
border-radius: 0 0 30rpx 30rpx;
}
.order-list-nav-top {
height: 100rpx;
display: flex;
align-items: center;
background-color: transparent;
}
.type-tabs {
width: 100%;
display: flex;
align-items: center;
box-sizing: border-box;
}
.type-tab-item {
flex: 1;
height: 120rpx;
display: flex;
align-items: center;
justify-content: center;
}
.type-tab-text {
position: relative;
padding: 0 25rpx;
color: rgba(255, 255, 255, 0.85);
border-radius: 10rpx;
}
.activeTypeItem {
color: #ffffff;
background: linear-gradient(135deg, var(--countdown-grad-start), var(--countdown-grad-end));
}
.search {
@@ -238,19 +335,45 @@
margin-bottom: 16rpx;
}
.searchBtn {
margin-left: 16rpx;
}
:deep(.is-input-border) {
.searchInput {
background-color: #ffffff;
border-radius: 44rpx;
overflow: hidden;
height: 72rpx;
border-radius: 36rpx;
background-color: #f7f8fa;
border: none;
}
:deep(.is-input-border) {
background: rgba(255, 255, 255, 0.34);
.searchField {
height: 72rpx;
padding-left: 28rpx;
box-sizing: border-box;
}
.searchFieldIcon {
width: 32rpx;
height: 32rpx;
margin-right: 16rpx;
flex: 0 0 auto;
}
.searchBtn {
width: 96rpx;
height: 62rpx;
padding: 0 10rpx;
margin: 5rpx;
border-radius: 44rpx;
background: linear-gradient(135deg, var(--primary-grad-start), var(--primary-grad-end));
border: 2rpx solid rgba(255, 255, 255, 0.95);
}
:deep(.uni-easyinput__content) {
background-color: transparent;
height: 72rpx;
}
.searchBtnIcon {
width: 32rpx;
height: 32rpx;
filter: brightness(0) invert(1);
}
.orderCon {
+745
View File
@@ -0,0 +1,745 @@
<template>
<s-pages title="修改配送" :pink_bg="true">
<!-- 订单信息(商品) -->
<view class="modify-delivery">
<view class="bg24 m-b-12 order-info-card">
<view class="notice-item notice-item--center">
<view class="ss-flex ss-flex-1 flex-row ju-between">
<text class="title c0">订单编号</text>
<text class="detail right c0">{{ orderSn }}</text>
</view>
<view class="copy" @click.stop="onCopy(orderSn)">
<image :src="`${appUrl}goods/copy2.svg`" mode="scaleToFill" />
</view>
</view>
<view class="notice-item flex-row ju-between">
<text class="title c0">下单时间</text>
<text class="detail right c0">
{{ formatTime(orderCreateTime) }}
</text>
</view>
</view>
<view class="bg24 m-b-12 goods-card">
<view
class="con_item flex-center ju-between"
v-for="(v, i) in displayGoodsItems"
:key="v.key || i"
>
<view class="order_img shrink">
<image :src="`${resolvePicUrl(v)}`" mode="aspectFill" />
</view>
<view class="flex1">
<view class="flex-row ju-between m-b-6">
<view class="size28 spuName lineTwo c0 p-r-10">
{{ v.spuName }}
</view>
<view class="shrink price">
<span class="size24">¥</span>
<span class="size36" style="font-weight: 600">{{ fen2yuan(resolvePrice(v)) }}</span>
</view>
</view>
<view class="flex-row ju-between">
<view class="valueName size28 c19">
{{ formatSkuProperties(v.properties) }}
</view>
<view class="shrink size28 c0">
{{ `x${resolveCount(v)}` }}
</view>
</view>
</view>
</view>
<view v-if="!displayGoodsItems.length" class="goods-card__empty c15 size24">
商品信息加载中…
</view>
</view>
<!-- 配送方式 -->
<view class="bg24 m-b-12 delivery-card">
<view
class="address flex flex-wrap flex-center ss-row-between"
@tap="selectStore"
>
<view class="addressCon" v-if="deliveryInfo.pickUpInfo?.id">
<view class="name c0">
{{ deliveryInfo.pickUpInfo.name }}
<text class="phone">{{ deliveryInfo.pickUpInfo.phone || '' }}</text>
</view>
<view class="line1 line2 c0">
{{ formatPickUpAddress(deliveryInfo.pickUpInfo) }}
</view>
</view>
<view class="addressCon" v-else>
<view class="setaddress c0">选择自提门店</view>
</view>
<view class="iconfont">
<uni-icons type="right" color="#989898" size="18" />
</view>
</view>
<view class="delivery-contact">
<view class="delivery-contact__row">
<view class="delivery-contact__label c0">联系人</view>
<uni-easyinput
class="delivery-contact__input"
v-model="deliveryInfo.receiverName"
placeholder="请填写您的联系姓名"
:inputBorder="false"
:clearable="false"
placeholderStyle="color:#b0b3a6"
/>
</view>
<view class="delivery-contact__row">
<view class="delivery-contact__label c0">联系电话</view>
<uni-easyinput
class="delivery-contact__input"
v-model="deliveryInfo.receiverMobile"
type="number"
maxlength="11"
placeholder="请填写您的联系电话"
:inputBorder="false"
:clearable="false"
placeholderStyle="color:#b0b3a6"
/>
</view>
</view>
</view>
</view>
<su-fixed bottom placeholder>
<view class="footer-actions">
<view
class="save-btn"
:class="{ 'is-disabled': submitting }"
@click="onSave"
>确认修改</view>
</view>
</su-fixed>
</s-pages>
</template>
<script setup>
import { computed, reactive, ref } from 'vue';
import { onLoad, onUnload } from '@dcloudio/uni-app';
import sheep from '@/sheep';
import { fen2yuan } from '@/sheep/hooks/useGoods';
import OrderApi from '@/sheep/api/trade/order';
import StorePickupApi from '@/sheep/api/trade/storePickup';
import TradeConfigApi from '@/sheep/api/trade/config';
import {
getOrderDetail as getAiOrderDetail,
getOpenOrderDetail,
updateDeliveryType as updateAiDeliveryType,
} from '@/sheep/api/ai';
import { createDeliveryInfo, getDeliveryValidationMessage } from '@/sheep/helper/delivery';
// 与 main.js 中 app.config.globalProperties.$url 保持一致(goods/copy2.svg 等 OSS 静态资源前缀)
const appUrl = 'https://sycbuck.oss-cn-hangzhou.aliyuncs.com/app/';
const routeParams = ref({});
const orderId = ref('');
const orderTypeId = ref(1);
const backCurrentType = ref(0);
const source = ref('');
const orderType = ref('');
const orderData = ref({});
const submitting = ref(false);
let cleanupListeners = () => {};
const deliveryInfo = reactive(createDeliveryInfo());
// 基于「初始路由参数」判断订单类型/来源(拉取详情前必须先确定用哪个接口)
const resolveInitOrderType = () => {
const fromOptions = Number(orderType.value ?? orderTypeId.value ?? 0);
return fromOptions || 0;
};
const resolveInitOrderSource = () => String(source.value || '');
const initIsOpenOrder = () => resolveInitOrderType() === 5;
const initIsAiStoreOrder = () => resolveInitOrderSource() === 'aishop';
const initIsInStoreOrder = () => resolveInitOrderType() === 4;
const shouldUseAiDetailApiInitially = () => {
if (initIsOpenOrder() || initIsAiStoreOrder() || initIsInStoreOrder()) {
return true;
}
// 兜底:从店铺订单 tab(currentType=1)进入,或者 orderTypeId!=1,都不是普通商城订单
const t = resolveInitOrderType();
if (t && t !== 1) return true;
if (Number(backCurrentType.value) === 1) return true;
return false;
};
// 基于 orderData 返回值的二次判断(兼容详情返回后再次校正)
const resolveOrderType = () => {
const fromData = Number(orderData.value?.type ?? 0);
const fromInit = resolveInitOrderType();
return fromData || fromInit || 0;
};
const resolveOrderSource = () => {
const s1 = String(orderData.value?.__source || '');
const s2 = resolveInitOrderSource();
return s1 || s2 || '';
};
const isOpenOrder = computed(() => resolveOrderType() === 5);
const isAiStoreOrder = computed(() => resolveOrderSource() === 'aishop');
const isInStoreOrder = computed(() => resolveOrderType() === 4);
const shouldUseAiDetailApi = computed(() =>
isOpenOrder.value || isAiStoreOrder.value || isInStoreOrder.value,
);
const orderSn = computed(() => {
const d = orderData.value || {};
return d.no || d.orderSn || d.orderNo || '';
});
const orderCreateTime = computed(() => {
const d = orderData.value || {};
return d.createTime || d.payTime || d.orderTime || d.createdAt;
});
const formatTime = (v) => {
if (!v) return '';
if (sheep?.$helper?.timeFormat) {
return sheep.$helper.timeFormat(v, 'yyyy-mm-dd hh:MM:ss');
}
return String(v);
};
const resolvePicUrl = (item) =>
item?.thumbnail || item?.picUrl || item?.spuMainPicUrl || '';
const resolvePrice = (item) => item?.salePrice || item?.price || 0;
const resolveCount = (item) => item?.buyNum || item?.count || 1;
const formatSkuProperties = (properties = []) => {
if (!Array.isArray(properties) || !properties.length) return '';
return properties.map((p) => p?.valueName || '').filter(Boolean).join(' ');
};
const buildItemKey = (it, fallbackIndex) => {
const stableId = it?.id || it?.itemId || it?.orderItemId || it?.order_item_id || it?.item_id;
if (stableId !== undefined && stableId !== null && String(stableId) !== '') {
return `item-${stableId}`;
}
const spuId = it?.spuId || it?.spu_id || it?.productId || '';
const skuId = it?.skuId || it?.sku_id || '';
if (spuId || skuId) {
return `sku-${spuId}-${skuId}`;
}
return `idx-${fallbackIndex ?? 0}`;
};
const displayGoodsItems = computed(() => {
const raw = orderData.value?.items || [];
return raw.map((it, index) => ({
...it,
key: it?.key ?? buildItemKey(it, index),
}));
});
const formatPickUpAddress = (info = {}) => {
if (!info || typeof info !== 'object') return '';
const detail = info.detailAddress || info.address || '';
const area = info.areaName || info.district || '';
const province = info.provinceName || '';
const city = info.cityName || '';
const base = [province, city, area, detail]
.map((s) => (s ?? '').toString().trim())
.filter(Boolean)
.join('');
return base;
};
const loadDeliveryConfig = async () => {
try {
await TradeConfigApi.getTradeConfig();
} catch (e) {}
};
const resolveOrderDetailApi = () => {
// 优先用「初始路由参数」判断,保证第一次调用详情接口就命中正确的 API
if (shouldUseAiDetailApiInitially()) {
if (initIsOpenOrder()) return getOpenOrderDetail;
return getAiOrderDetail;
}
if (isOpenOrder.value) return getOpenOrderDetail;
if (isAiStoreOrder.value) return getAiOrderDetail;
if (isInStoreOrder.value) return getAiOrderDetail;
return OrderApi.getOrderDetail;
};
const resolveOrderDetailApiLabel = (api) => {
if (api === getOpenOrderDetail) return '/aishop/order/get-detail-open';
if (api === getAiOrderDetail) return '/aishop/order/get-detail';
if (api === OrderApi.getOrderDetail) return '/trade/order/get-detail(商城)';
return 'unknown';
};
const callOrderDetailApi = async () => {
const api = resolveOrderDetailApi();
if (api === OrderApi.getOrderDetail) {
return api(orderId.value);
}
return api({ id: orderId.value });
};
const getOrderDetail = async () => {
if (!orderId.value) return;
try {
const res = await callOrderDetailApi();
if (res?.code !== 0) return;
const data = res.data || {};
orderData.value = data;
deliveryInfo.deliveryType = 2;
const mainPickup = data?.pickup || data?.pickupInfo || data?.pickUpInfo || {};
const storeCandidate =
mainPickup?.pickUpStore ||
mainPickup?.store ||
mainPickup?.pickUpStoreVO ||
mainPickup ||
{};
const storeId =
Number(
data?.pickUpStoreId ||
mainPickup?.storeId ||
storeCandidate?.id ||
storeCandidate?.storeId ||
0,
) || 0;
const storeName =
mainPickup?.storeName || storeCandidate?.name || storeCandidate?.storeName || '';
const storeAddress =
mainPickup?.storeAddress ||
storeCandidate?.address ||
storeCandidate?.storeAddress ||
formatPickUpAddress(storeCandidate);
const storePhone =
mainPickup?.storePhone ||
mainPickup?.phone ||
storeCandidate?.phone ||
storeCandidate?.storePhone ||
storeCandidate?.mobile ||
'';
const pickUpId = storeId;
const pickUpStoreIdFinal = storeId || Number(storeCandidate?.storeId || 0) || 0;
if (!deliveryInfo.pickUpInfo || typeof deliveryInfo.pickUpInfo !== 'object') {
deliveryInfo.pickUpInfo = {};
}
const baseAssign = {
id: pickUpId,
storeId: pickUpStoreIdFinal,
name: storeName,
storeName,
address: storeAddress,
storeAddress,
phone: storePhone,
storePhone,
};
Object.keys(baseAssign).forEach((k) => {
const v = baseAssign[k];
if (v === undefined || v === null || v === '') {
delete deliveryInfo.pickUpInfo[k];
return;
}
deliveryInfo.pickUpInfo[k] = v;
});
if (!deliveryInfo.receiverName) {
deliveryInfo.receiverName =
mainPickup?.receiverName ||
mainPickup?.contactName ||
data?.receiverName ||
'';
}
if (!deliveryInfo.receiverMobile) {
deliveryInfo.receiverMobile =
mainPickup?.receiverMobile ||
mainPickup?.contactMobile ||
data?.receiverMobile ||
'';
}
} catch (e) {}
};
const onSave = async () => {
if (submitting.value) return;
const validationMessage = getDeliveryValidationMessage(deliveryInfo);
if (validationMessage) {
return uni.showToast({ title: validationMessage, icon: 'none' });
}
const payload = {
id: orderId.value,
deliveryType: 2,
pickUpStoreId: Number(deliveryInfo.pickUpInfo?.id) || 0,
receiverName: String(deliveryInfo.receiverName || '').trim(),
receiverMobile: String(deliveryInfo.receiverMobile || '').trim(),
};
submitting.value = true;
let shouldUnlock = true;
try {
const useAiUpdate = shouldUseAiDetailApiInitially() ||
(orderData.value && (
orderData.value.__source === 'aishop' ||
Number(orderData.value.type) === 4 ||
Number(orderData.value.type) === 5 ||
Number(orderData.value.orderType) === 4 ||
Number(orderData.value.orderType) === 5 ||
Number(orderTypeId.value) !== 1
));
const updateFn = useAiUpdate ? updateAiDeliveryType : OrderApi.updateDeliveryType;
const res = await updateFn(payload);
if (res?.code === 0) {
shouldUnlock = false;
uni.showToast({ title: '修改成功', icon: 'success' });
uni.$emit('REFRESH_ORDER_LIST');
setTimeout(() => {
sheep.$router.go('/pages/order/list', { currentType: backCurrentType.value });
}, 600);
}
} finally {
if (shouldUnlock) submitting.value = false;
}
};
const onCopy = (text) => {
if (!text) return;
sheep.$helper.copyText(String(text));
};
const selectStore = () => {
sheep.$router.go('/pages/user/goods_details_store/index');
};
const buildPickUpAddressFromRaw = function buildSafePickUpAddress(rawItemSafe) {
if (!rawItemSafe || typeof rawItemSafe !== 'object') return '';
const provinceSafe = String(rawItemSafe?.provinceName || rawItemSafe?.province || '').trim();
const citySafe = String(rawItemSafe?.cityName || rawItemSafe?.city || '').trim();
const areaSafe = String(rawItemSafe?.areaName || rawItemSafe?.area || rawItemSafe?.district || '').trim();
const detailSafe = String(
(rawItemSafe?.detailAddress != null ? rawItemSafe.detailAddress : '') +
((rawItemSafe?.address != null ? rawItemSafe.address : '') || ''),
).trim();
if (provinceSafe || citySafe || areaSafe || detailSafe) {
return [provinceSafe, citySafe, areaSafe, detailSafe].filter(Boolean).join('');
}
const districtSafe = String(rawItemSafe?.district || '').trim();
const descSafe = String(rawItemSafe?.description || '').trim();
const addrLineSafe = String(rawItemSafe?.address || '').trim();
return [districtSafe, descSafe, addrLineSafe].filter(Boolean).join(' ').trim();
};
const onStoreSelected = function onSafeStoreSelected(evtPayloadSafe) {
try {
const rawSafe =
(evtPayloadSafe && evtPayloadSafe.addressInfo) ||
(evtPayloadSafe && evtPayloadSafe.storeInfo) ||
(evtPayloadSafe && evtPayloadSafe.store) ||
null;
if (!rawSafe || typeof rawSafe !== 'object') return;
const rawItemSafe = rawSafe;
const storeIdSafe = Number(rawItemSafe?.id || rawItemSafe?.storeId || 0) || 0;
const storeNameSafe = String(
rawItemSafe?.name ||
rawItemSafe?.storeName ||
rawItemSafe?.shopName ||
rawItemSafe?.pickUpName ||
'',
).trim();
const addressSafe = String(
rawItemSafe?.storeAddress ||
rawItemSafe?.address ||
rawItemSafe?.pickUpAddress ||
buildPickUpAddressFromRaw(rawItemSafe),
).trim();
const phoneSafe = String(
rawItemSafe?.storePhone ||
rawItemSafe?.phone ||
rawItemSafe?.mobile ||
rawItemSafe?.telephone ||
rawItemSafe?.pickUpPhone ||
'',
).trim();
const latSafe = Number(rawItemSafe?.latitude) || 0;
const lngSafe = Number(rawItemSafe?.longitude) || 0;
const nextSafe = {
id: storeIdSafe,
storeId: storeIdSafe,
name: storeNameSafe,
storeName: storeNameSafe,
address: addressSafe,
storeAddress: addressSafe,
phone: phoneSafe,
storePhone: phoneSafe,
latitude: latSafe || undefined,
longitude: lngSafe || undefined,
};
// 根因级优化:
// 1) 不用 {...prev, ...next} 整对象替换 → 避免 Vue reactive trigger 太多响应式副作用,
// 被埋点/统计 SDK 采集到异常的空 entry 后读 .startTime 失败
// 2) 只写值非空的字段;字段名保持双兼容(id/storeId, name/storeName …)
if (!deliveryInfo.pickUpInfo || typeof deliveryInfo.pickUpInfo !== 'object') {
deliveryInfo.pickUpInfo = {};
}
Object.keys(nextSafe).forEach((kSafe) => {
const vSafe = nextSafe[kSafe];
if (vSafe === undefined || vSafe === null || vSafe === '') {
// 空 latitude/longitude 直接删掉,不保留 undefined 字段
delete deliveryInfo.pickUpInfo[kSafe];
return;
}
deliveryInfo.pickUpInfo[kSafe] = vSafe;
});
} catch (errSafe) {
}
};
onLoad(async (options) => {
routeParams.value = options || {};
orderId.value = options?.orderId || options?.id || '';
orderTypeId.value = Number(options?.orderTypeId || options?.typeId) || 1;
backCurrentType.value = Number(options?.currentType ?? 0);
if (options?.orderType !== undefined) {
orderType.value = options.orderType;
}
if (options?.type !== undefined) {
orderType.value = options.type;
}
if (options?.source !== undefined) {
source.value = options.source;
}
if (options?.__source !== undefined && !source.value) {
source.value = options.__source;
}
const onPickUpInfoSafe = (evtSafe) => {
try {
onStoreSelected(evtSafe);
} catch (errSafe) {
}
};
const onPickUpStoreSafe = (evtSafe) => {
try {
if (evtSafe?.storeInfo) {
onStoreSelected({ addressInfo: evtSafe.storeInfo });
}
} catch (errSafe) {
}
};
try {
// 先解绑旧的同名监听(避免 HMR/热更新叠加回调),再绑定新版
uni.$off('SELECT_PICK_UP_INFO');
uni.$off('SELECT_PICK_UP_STORE');
} catch (eSafe) { /* ignore */ }
uni.$on('SELECT_PICK_UP_INFO', onPickUpInfoSafe);
uni.$on('SELECT_PICK_UP_STORE', onPickUpStoreSafe);
cleanupListeners = () => {
try { uni.$off('SELECT_PICK_UP_INFO', onPickUpInfoSafe); } catch (eSafe) {}
try { uni.$off('SELECT_PICK_UP_STORE', onPickUpStoreSafe); } catch (eSafe) {}
};
await Promise.all([loadDeliveryConfig(), getOrderDetail()]);
});
onUnload(() => {
if (typeof cleanupListeners === 'function') {
try { cleanupListeners(); } catch (e) {}
}
});
</script>
<style lang="scss" scoped>
.modify-delivery {
min-height: 100vh;
box-sizing: border-box;
padding: 20rpx 24rpx 24rpx;
}
.order-info-card {
border-radius: 16rpx;
padding: 0 24rpx;
.notice-item {
padding: 24rpx 0;
.title {
font-size: 28rpx;
color: #999;
}
.detail {
font-size: 28rpx;
color: #000;
}
}
.notice-item--center {
.ss-flex > .title {
color: #999;
}
}
}
.notice-item {
display: flex;
align-items: center;
justify-content: space-between;
&.notice-item--center {
border-bottom: 1rpx solid #f2f2f2;
.copy {
width: 28rpx;
height: 28rpx;
margin-left: 12rpx;
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
image {
width: 100%;
height: 100%;
display: block;
}
}
}
}
.goods-card {
border-radius: 16rpx;
padding: 0 24rpx;
}
.goods-card__empty {
text-align: center;
padding: 40rpx 0;
}
.con_item {
padding: 24rpx 0;
border-top: 1rpx solid #f2f2f2;
&:first-child {
border-top: none;
}
}
.order_img {
width: 160rpx;
height: 160rpx;
border-radius: 12rpx;
overflow: hidden;
margin-right: 16rpx;
background: #f0f2f0;
image {
width: 100%;
height: 100%;
display: block;
}
}
.spuName {
line-height: 1.3;
color: #333;
}
.price {
color: #ff5542;
padding-left: 10rpx;
white-space: nowrap;
}
.valueName {
color: #8f97a0;
font-size: 26rpx;
}
.c19 {
color: #8f97a0;
}
.c0 {
color: #000;
}
.c15 {
color: #999;
}
.size24 {
font-size: 24rpx;
}
.size28 {
font-size: 28rpx;
}
.size36 {
font-size: 36rpx;
}
.lineTwo {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
word-break: break-all;
}
.delivery-card {
border-radius: 16rpx;
overflow: hidden;
background: #ffffff;
}
.address {
padding: 28rpx 24rpx;
box-sizing: border-box;
border-bottom: 1rpx solid #f2f2f2;
}
.addressCon {
flex: 1;
min-width: 0;
padding-right: 20rpx;
box-sizing: border-box;
.name {
font-size: 30rpx;
font-weight: 600;
line-height: 1.4;
margin-bottom: 6rpx;
.phone {
margin-left: 16rpx;
font-size: 28rpx;
font-weight: normal;
color: #333;
}
}
.line1.line2 {
font-size: 26rpx;
line-height: 1.4;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
word-break: break-all;
}
.setaddress {
font-size: 28rpx;
}
}
.iconfont {
flex-shrink: 0;
margin-left: 12rpx;
display: flex;
align-items: center;
}
.delivery-contact {
padding: 0 24rpx;
&__row {
display: flex;
align-items: center;
justify-content: space-between;
height: 96rpx;
border-bottom: 1rpx solid #f2f2f2;
&:last-child {
border-bottom: none;
}
}
&__label {
flex-shrink: 0;
width: 140rpx;
margin-right: 16rpx;
font-size: 28rpx;
}
&__input {
flex: 1;
min-width: 0;
margin-left: auto;
}
}
.footer-actions {
padding: 20rpx 32rpx calc(20rpx + env(safe-area-inset-bottom));
background: #ffffff;
box-shadow: 0 -2rpx 12rpx rgba(0, 0, 0, 0.04);
box-sizing: border-box;
}
.save-btn {
height: 96rpx;
line-height: 96rpx;
text-align: center;
color: #ffffff;
font-size: 32rpx;
font-weight: 600;
background: linear-gradient(131deg, #FA8735 0%, #FE3B48 100%);
border-radius: 48rpx;
&.is-disabled {
opacity: 0.6;
}
}
</style>
+457 -59
View File
@@ -2,27 +2,61 @@
<view class="order-details">
<!-- 自提商品核销 -->
<view v-if="orderInfo.deliveryType === 2 && orderInfo.payStatus" class="writeOff borRadius14">
<view class="title">核销信息</view>
<view class="grayBg flex-center">
<view class="pictrue">
<image
v-if="!!painterImageUrl"
:src="painterImageUrl"
:style="{ width: `${state.qrcodeSize}px`, height: `${state.qrcodeSize}px` }"
:show-menu-by-longpress="true"
/>
<view class="title-row">
<view class="title-left flex-center">
<view class="title">核销信息</view>
<view class="status-tag" :class="statusTagClass">{{ statusTagText }}</view>
</view>
<view class="progress-btn" @tap.stop="goStockProgress">备货进度</view>
</view>
<view class="gear">
<image :src="sheep.$url.static('/static/img/shop/writeOff.png')"></image>
</view>
<view class="num">{{ orderInfo.pickUpVerifyCode }}</view>
<template v-if="isSorting">
<view class="preparation-placeholder">
<view class="preparation-placeholder__emoji">📦</view>
<view class="preparation-placeholder__title">门店正快马加鞭备货中</view>
<view class="preparation-placeholder__desc">
分拣完成后将生成取货码并发送通知,请耐心等待~
</view>
</view>
<view v-if="isVerifyCompleted" class="num-wrap">
<view class="num num--done">该商品券已完成核销</view>
</view>
<view v-else class="num-wrap">
<view class="num num--pending">— 待备货完成后解锁 —</view>
</view>
</template>
<template v-else>
<view class="grayBg flex-center">
<view class="pictrue">
<image
v-if="!!painterImageUrl"
:src="painterImageUrl"
:style="{ width: `${state.qrcodeSize}px`, height: `${state.qrcodeSize}px` }"
:show-menu-by-longpress="true"
/>
<view v-if="isVerifyCompleted" class="verify-mask">
<view class="verify-mask__icon">
<uni-icons type="checkmarkempty" size="40" color="#ffffff" />
</view>
<view class="verify-mask__text">已核销</view>
</view>
</view>
</view>
<view class="gear">
<image :src="sheep.$url.static('/static/img/shop/writeOff.png')"></image>
</view>
<view v-if="isVerifyCompleted" class="num-wrap">
<view class="num num--done">该商品券已完成核销</view>
</view>
<view v-else class="num-wrap" @tap="copyVerifyCode">
<view class="num">{{ orderInfo.pickUpVerifyCode }}</view>
</view>
</template>
<view class="rules">
<view class="item">
<view class="rulesTitle flex flex-wrap align-center"> 核销时间 </view>
<view class="info">
每日:
<text class="time">{{ systemStore.openingTime }} - {{ systemStore.closingTime }}</text>
<text class="time">{{ openingTimeText }} - {{ closingTimeText }}</text>
</view>
</view>
<view class="item">
@@ -30,18 +64,25 @@
<text class="iconfont icon-shuoming1"></text>
使用说明
</view>
<view class="info">可将二维码出示给店员扫描或提供数字核销码</view>
<view class="info">{{ isSorting ? '分拣完成后将生成核销码,出示给店员扫描即可' : '可将二维码出示给店员扫描或提供数字核销码' }}</view>
</view>
</view>
</view>
<view
v-if="orderInfo.deliveryType === 2"
class="map flex flex-wrap align-center ss-row-between borRadius14"
v-if="orderInfo.deliveryType === 2 && !isSorting"
class="pickup-card borRadius14"
>
<view>自提地址信息</view>
<view class="place cart-color flex flex-wrap flex-center" @tap="showMaoLocation">
查看位置
<image v-if="coverImageUrl" class="pickup-cover" :src="coverImageUrl" mode="aspectFill" />
<view class="pickup-hd">
<view class="pickup-title">{{ systemStore.name || '自提门店' }}</view>
<view v-if="distanceText" class="pickup-distance">{{ distanceText }}</view>
</view>
<view class="pickup-address">{{ pickupAddressText || '--' }}</view>
<view class="pickup-hours">
<uni-icons type="clock" size="14" color="#8c8c8c" />
<view class="pickup-hours__text">营业时间:{{ openingTimeText }} - {{ closingTimeText }}</view>
</view>
<view class="pickup-btn" @tap="showMaoLocation">查看位置导航</view>
</view>
<!-- 海报画板:默认隐藏只用来生成海报。生成方式为主动调用 -->
<l-painter
@@ -57,7 +98,7 @@
<script setup>
import sheep from '@/sheep';
import { reactive, ref } from 'vue';
import { computed, reactive, ref } from 'vue';
const props = defineProps({
orderInfo: {
@@ -68,53 +109,215 @@
type: Object,
default() {},
},
});
const state = reactive({
qrcodeSize: 145,
source: {
type: String,
default: '',
},
orderType: {
type: [String, Number],
default: '',
},
detailStyle: {
type: String,
default: 'order',
},
});
/**
* 打开地图
*/
const showMaoLocation = () => {
if (!props.systemStore.latitude || !props.systemStore.longitude) {
sheep.$helper.toast('缺少经纬度信息无法查看地图!');
const resolvePickUpStoreId = () => {
return Number(
props.orderInfo?.pickUpStoreId ||
props.orderInfo?.pickUpStore?.id ||
props.orderInfo?.pickUpStore?.storeId ||
props.orderInfo?.pickUpStoreVO?.id ||
props.orderInfo?.pickUpStoreVO?.storeId ||
props.orderInfo?.store?.id ||
props.orderInfo?.store?.storeId ||
props.systemStore?.id ||
props.systemStore?.storeId ||
props.orderInfo?.storeId ||
0,
);
};
const goStockProgress = () => {
const id = props.orderInfo?.id || props.orderInfo?.orderId;
const pickUpStoreId = resolvePickUpStoreId();
const source = String(props.source || props.orderInfo?.__source || props.orderInfo?.source || '').trim();
const orderType = String(props.orderType || props.orderInfo?.type || '').trim();
const detailStyle = String(props.detailStyle || '').trim();
if (!id) return;
uni.navigateTo({
url: `/pages/order/stockProgress?id=${id}${
pickUpStoreId > 0 ? `&pickUpStoreId=${pickUpStoreId}` : ''
}${source ? `&source=${encodeURIComponent(source)}` : ''}${
orderType ? `&type=${encodeURIComponent(orderType)}` : ''
}${detailStyle ? `&detailStyle=${encodeURIComponent(detailStyle)}` : ''}`,
});
};
const copyVerifyCode = () => {
const code = String(props.orderInfo?.pickUpVerifyCode || '').trim();
if (!code) {
sheep.$helper.toast('暂无核销码');
return;
}
uni.openLocation({
latitude: props.systemStore.latitude,
longitude: props.systemStore.longitude,
scale: 8,
name: props.systemStore.name,
address: props.systemStore.areaName + props.systemStore.detailAddress,
uni.setClipboardData({
data: code,
success: () => {
sheep.$helper.toast('核销码已复制');
},
});
};
/**
* 拨打电话
* 打开地图
*/
const makePhone = () => {
uni.makePhoneCall({
phoneNumber: props.systemStore.phone,
const formatHm = (hm) => {
if (!Array.isArray(hm) || hm.length < 2) return '';
const h = String(hm[0]).padStart(2, '0');
const m = String(hm[1]).padStart(2, '0');
return `${h}:${m}`;
};
const openingTimeText = computed(() => {
return props.systemStore?.openingTime || formatHm(props.systemStore?.businessHoursStart) || '--';
});
const closingTimeText = computed(() => {
return props.systemStore?.closingTime || formatHm(props.systemStore?.businessHoursEnd) || '--';
});
const pickupAddressText = computed(() => {
const s = props.systemStore || {};
const province = s.province || '';
const city = s.city || '';
const district = s.district || '';
const address = s.address || '';
const legacy = `${s.areaName || ''}${s.detailAddress || ''}`;
return `${province}${city}${district}${address}` || legacy || s.description || '';
});
const distanceText = computed(() => {
const d = Number(props.systemStore?.distance);
if (!(d > 0)) return '';
const t = d >= 1000 ? `${(d / 1000).toFixed(1)}km` : `${Math.round(d)}m`;
return `距离${t}`;
});
const sanitizeUrl = (value) => String(value || '').replace(/[`"'\s]/g, '');
const coverImageUrl = computed(() => {
const raw = sanitizeUrl(props.systemStore?.coverImage);
if (!raw) return '';
if (/^https?:\/\//i.test(raw)) return raw;
return sheep.$url.cdn(raw);
});
const isVerifyCompleted = computed(() => {
const info = props.orderInfo || {};
const status = Number(info?.status);
return Boolean(
info?.pickUpVerifyTime ||
info?.verifyTime ||
info?.completedTime ||
status === 30 ||
status === 3,
);
});
const resolveStage = () => {
const data = props.orderInfo || {};
const external = Number(data?.preparationStatus);
const rawStatus = Number.isFinite(external) ? external : Number(data?.preparationStatus ?? data?.status ?? 0);
if (isVerifyCompleted.value) return 'done';
if (rawStatus === 1 || rawStatus === 2) return 'wait';
if (
data?.deliveryTime ||
data?.arriveStoreTime ||
data?.deliveredTime ||
rawStatus === 20
) {
return 'delivered';
}
return 'sorting';
};
const isSorting = computed(() => resolveStage() === 'sorting');
const state = reactive({
qrcodeSize: 145,
});
const statusTagText = computed(() => {
const s = resolveStage();
if (s === 'sorting') return '分拣中';
if (s === 'delivered') return '已送达门店';
if (s === 'wait') return '待取货';
if (s === 'done') return isVerifyCompleted.value ? '已核销' : '已完成';
return '';
});
const statusTagClass = computed(() => {
const s = resolveStage();
if (s === 'sorting') return 'status-tag--sorting';
if (s === 'delivered') return 'status-tag--delivered';
if (s === 'wait') return 'status-tag--wait';
return 'status-tag--done';
});
const addressText = computed(() => {
const s = props.systemStore || {};
const province = s.province || '';
const city = s.city || '';
const district = s.district || '';
const description = s.description || '';
const legacy = `${s.areaName || ''}${s.detailAddress || ''}`;
return `${province}${city}${district}${description}` || legacy || s.address || '';
});
const showMaoLocation = () => {
const latitude = Number(props.systemStore?.latitude);
const longitude = Number(props.systemStore?.longitude);
if (!(latitude && longitude)) {
sheep.$helper.toast('缺少经纬度信息无法查看地图!');
return;
}
uni.openLocation({
latitude,
longitude,
scale: 8,
name: props.systemStore?.name,
address: addressText.value,
});
};
const painterRef = ref(); // 海报画板
const painterImageUrl = ref(); // 海报 url
const showPainter = ref(true);
const lastMarkCodeText = ref('');
// 渲染海报
const renderPoster = async (poster) => {
if (!painterRef.value) return;
await painterRef.value.render(poster);
};
// 获得生成的图片
const setPainterImageUrl = (path) => {
painterImageUrl.value = path;
showPainter.value = false;
};
/**
* 生成核销二维码
*/
const markCode = (text) => {
const markCode = async (text) => {
const code = String(text || '').trim();
if (!code) return;
// 相同取货码无需重复生成,避免重复触发海报组件销毁/重建的空指针
if (lastMarkCodeText.value === code && painterImageUrl.value) return;
lastMarkCodeText.value = code;
// 如果 painterRef 已被销毁(showPainter=false 时 v-if 销毁了组件),先重建组件,等下一个 tick 再渲染
if (!painterRef.value) {
showPainter.value = true;
await new Promise((resolve) => setTimeout(resolve, 0));
}
renderPoster({
css: {
width: `${state.qrcodeSize}px`,
@@ -123,7 +326,7 @@
views: [
{
type: 'qrcode',
text: text,
text: code,
css: {
width: `${state.qrcodeSize}px`,
height: `${state.qrcodeSize}px`,
@@ -149,19 +352,118 @@
border-radius: 10rpx;
margin: 0 20rpx 20rpx 20rpx;
}
.order-details .writeOff {
background-color: #fff;
margin-top: 15rpx;
padding-bottom: 50rpx;
}
.order-details .writeOff .title {
.order-details .writeOff .title-row {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 30rpx;
color: #282828;
height: 87rpx;
border-bottom: 1px solid #f0f0f0;
padding: 0 24rpx;
line-height: 87rpx;
box-sizing: border-box;
}
.order-details .writeOff .title-left {
gap: 16rpx;
min-width: 0;
}
.order-details .writeOff .title {
font-size: 30rpx;
color: #282828;
height: 87rpx;
line-height: 87rpx;
}
.order-details .writeOff .status-tag {
flex-shrink: 0;
height: 44rpx;
line-height: 44rpx;
padding: 0 16rpx;
border-radius: 22rpx;
font-size: 22rpx;
font-weight: 500;
}
.order-details .writeOff .status-tag--sorting {
color: #e8852f;
background: rgba(232, 133, 47, 0.12);
}
.order-details .writeOff .status-tag--delivered {
color: #2556ec;
background: rgba(37, 86, 236, 0.1);
}
.order-details .writeOff .status-tag--wait {
color: #12a06a;
background: rgba(18, 160, 106, 0.1);
}
.order-details .writeOff .status-tag--done {
color: #86909c;
background: rgba(134, 144, 156, 0.12);
}
.order-details .writeOff .progress-btn {
height: 52rpx;
line-height: 52rpx;
padding: 0 16rpx;
border-radius: 26rpx;
font-size: 24rpx;
color: #5b4eff;
background: rgba(91, 78, 255, 0.12);
}
.preparation-placeholder {
width: 590rpx;
min-height: 384rpx;
margin: 50rpx auto 0 auto;
border-radius: 20rpx 20rpx 0 0;
background: linear-gradient(180deg, #fff7ea 0%, #ffe9c8 100%);
padding: 72rpx 48rpx 56rpx;
box-sizing: border-box;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
&__emoji {
font-size: 84rpx;
line-height: 1;
margin-bottom: 28rpx;
}
&__title {
font-size: 32rpx;
font-weight: 600;
color: #7a4a00;
line-height: 1.5;
margin-bottom: 14rpx;
}
&__desc {
font-size: 24rpx;
color: #a36d1a;
line-height: 1.7;
text-align: center;
}
}
.order-details .writeOff .num .num--pending {
background: #f7f8fa;
color: #98a2b3;
font-size: 26rpx;
letter-spacing: 2rpx;
}
.order-details .writeOff .grayBg {
@@ -174,6 +476,7 @@
}
.order-details .writeOff .grayBg .pictrue {
position: relative;
width: 290rpx;
height: 290rpx;
}
@@ -183,6 +486,35 @@
height: 100%;
}
.order-details .writeOff .grayBg .pictrue .verify-mask {
position: absolute;
inset: 0;
background: rgba(255, 255, 255, 0.82);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.order-details .writeOff .grayBg .pictrue .verify-mask__icon {
width: 112rpx;
height: 112rpx;
border-radius: 56rpx;
background: #56c33b;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 8rpx 20rpx rgba(86, 195, 59, 0.24);
}
.order-details .writeOff .grayBg .pictrue .verify-mask__text {
margin-top: 18rpx;
font-size: 40rpx;
line-height: 56rpx;
color: #2a7c1f;
font-weight: 600;
}
.order-details .writeOff .gear {
width: 590rpx;
height: 30rpx;
@@ -194,18 +526,35 @@
height: 100%;
}
.order-details .writeOff .num-wrap {
width: 590rpx;
margin: 0 auto;
}
.order-details .writeOff .num {
background-color: #f0c34c;
width: 590rpx;
width: 100%;
height: 84rpx;
color: #282828;
font-size: 48rpx;
margin: 0 auto;
border-radius: 0 0 20rpx 20rpx;
text-align: center;
padding-top: 4rpx;
}
.order-details .writeOff .num--done {
height: auto;
min-height: 84rpx;
padding-top: 0;
padding: 22rpx 24rpx;
box-sizing: border-box;
border-radius: 0 0 20rpx 20rpx;
background: #ffffff;
color: #b5b5b5;
font-size: 28rpx;
line-height: 40rpx;
}
.order-details .writeOff .rules {
margin: 46rpx 30rpx 0 30rpx;
border-top: 1px solid #f0f0f0;
@@ -238,23 +587,72 @@
margin-left: 20rpx;
}
.order-details .map {
height: 86rpx;
font-size: 30rpx;
color: #282828;
line-height: 86rpx;
border-bottom: 1px solid #f0f0f0;
.order-details .pickup-card {
margin-top: 15rpx;
background-color: #fff;
padding: 0 24rpx;
padding: 22rpx 24rpx 24rpx;
box-sizing: border-box;
}
.order-details .map .place {
.order-details .pickup-hd {
display: flex;
align-items: center;
justify-content: space-between;
}
.order-details .pickup-title {
font-size: 30rpx;
color: #282828;
font-weight: 700;
}
.order-details .pickup-distance {
padding: 4rpx 12rpx;
border-radius: 999rpx;
font-size: 22rpx;
color: #2556ec;
background: rgba(37, 86, 236, 0.12);
}
.order-details .pickup-address {
margin-top: 10rpx;
font-size: 26rpx;
width: 176rpx;
height: 50rpx;
border-radius: 25rpx;
line-height: 50rpx;
text-align: center;
color: #666;
line-height: 36rpx;
}
.order-details .pickup-cover {
width: 100%;
height: 168rpx;
border-radius: 16rpx;
display: block;
margin-bottom: 14rpx;
background: #f2f4f7;
}
.order-details .pickup-hours {
margin-top: 10rpx;
display: flex;
align-items: center;
gap: 10rpx;
}
.order-details .pickup-hours__text {
font-size: 24rpx;
color: #8c8c8c;
}
.order-details .pickup-btn {
margin-top: 16rpx;
height: 76rpx;
border-radius: 16rpx;
border: 2rpx solid rgba(37, 86, 236, 0.35);
background: #fff;
color: #2556ec;
font-size: 28rpx;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
</style>
+435
View File
@@ -0,0 +1,435 @@
<template>
<s-layout title="备货进度" navPreset="light">
<view class="page">
<view class="card bg24">
<view class="timeline">
<view v-for="(step, i) in steps" :key="step.key" class="step">
<view class="left">
<view class="dot" :class="dotClass(step)">
<uni-icons v-if="step.state === 'done'" type="checkmarkempty" size="16" color="#fff" />
<image
v-else-if="step.key === 'delivered'"
class="dot-icon"
:src="truckIconSrc(step)"
mode="aspectFit"
/>
<uni-icons
v-else-if="step.key === 'sorting'"
type="gift"
size="16"
:color="step.state === 'active' ? '#fff' : '#b9bec8'"
/>
<uni-icons
v-else-if="step.key === 'wait'"
type="cart"
size="16"
:color="step.state === 'active' ? '#fff' : '#b9bec8'"
/>
<uni-icons v-else type="location" size="16" :color="step.state === 'active' ? '#fff' : '#b9bec8'" />
</view>
<view v-if="i !== steps.length - 1" class="line" :class="lineClass(i)"></view>
</view>
<view class="right">
<view class="title" :class="{ titleActive: step.state !== 'todo' }">{{ step.title }}</view>
<view v-if="step.time" class="time">{{ step.time }}</view>
<view v-if="step.desc" class="desc">{{ step.desc }}</view>
<!-- 分拣进度条已隐藏 -->
<view v-if="step.key === 'wait'" class="hint">{{ step.hint }}</view>
</view>
</view>
</view>
</view>
<view class="goods-card bg24">
<card_order
v-if="goodsCardData.items.length"
class="order-goods"
:data="goodsCardData"
:type="goodsCardType"
theme="2"
/>
<view v-else class="goods-empty">暂无商品信息</view>
</view>
</view>
<su-fixed bottom placeholder bg="bg24">
<view class="footer">
<button class="btn" @tap="notifyStore">通知门店备货</button>
</view>
</su-fixed>
</s-layout>
</template>
<script setup>
import { computed, reactive, ref } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import sheep from '@/sheep';
import OrderApi from '@/sheep/api/trade/order';
import OrderStoreApi from '@/sheep/api/trade/orderStore';
import { getOrderDetail as getAiOrderDetail, getOpenOrderDetail } from '@/sheep/api/ai';
import card_order from '@/components/orderItem/card_order.vue';
const state = reactive({
orderId: 0,
pickUpStoreId: 0,
preparationStatus: null,
source: '',
orderType: '',
detailStyle: 'order',
orderInfo: {},
loading: false,
});
const sortingPercent = ref(72);
const goodsItems = computed(() => {
const list =
state.orderInfo?.items ||
state.orderInfo?.orderItems ||
state.orderInfo?.itemList ||
state.orderInfo?.productList;
return Array.isArray(list) ? list : [];
});
const goodsCardType = computed(() => (String(state.detailStyle) === 'ai' ? '4' : '2'));
const goodsCardData = computed(() => {
return {
...(state.orderInfo || {}),
items: goodsItems.value,
};
});
const formatTime = (t) => {
if (!t) return '';
return sheep.$helper.timeFormat(t, 'yyyy-mm-dd hh:MM:ss');
};
const resolvePickUpStoreId = (data = {}) => {
return Number(
data?.pickUpStoreId ||
data?.pickUpStore?.id ||
data?.pickUpStore?.storeId ||
data?.pickUpStoreVO?.id ||
data?.pickUpStoreVO?.storeId ||
data?.store?.id ||
data?.store?.storeId ||
data?.storeId ||
0,
);
};
const resolveStage = (data = {}, preparationStatus) => {
const external = Number(preparationStatus);
const rawStatus = Number.isFinite(external) ? external : Number(data?.preparationStatus ?? data?.status ?? 0);
if (data?.pickUpVerifyTime || data?.verifyTime || data?.completedTime || rawStatus === 30 || rawStatus === 3) {
return 'done';
}
if (rawStatus === 1 || rawStatus === 2) return 'wait';
if (
data?.deliveryTime ||
data?.arriveStoreTime ||
data?.deliveredTime ||
rawStatus === 20
) {
return 'delivered';
}
return 'sorting';
};
const stage = computed(() => {
return resolveStage(state.orderInfo, state.preparationStatus);
});
const hasVerifyCode = computed(() => {
if (stage.value === 'sorting') return false;
return Boolean(state.orderInfo?.pickUpVerifyCode) && Boolean(state.orderInfo?.payStatus);
});
const steps = computed(() => {
const createTime = formatTime(state.orderInfo?.createTime);
const s = stage.value;
const sortingState = s === 'sorting' ? 'active' : 'done';
const deliveredState = s === 'delivered' ? 'active' : s === 'sorting' ? 'todo' : 'done';
const waitState = s === 'wait' ? 'active' : s === 'done' ? 'done' : 'todo';
return [
{
key: 'created',
title: '已下单',
time: createTime,
state: 'done',
},
{
key: 'sorting',
title: '商品分拣中',
desc: '',
state: sortingState,
},
{
key: 'delivered',
title: '已送达门店',
desc: deliveredState === 'todo' ? '等待物流更新' : '',
state: deliveredState,
},
{
key: 'wait',
title: '待取货',
hint: hasVerifyCode.value ? `取货码:${state.orderInfo?.pickUpVerifyCode || ''}` : '到达门店后将发送取货通知',
state: waitState,
},
];
});
const dotClass = (step) => {
if (step.state === 'done') return 'dotDone';
if (step.state === 'active' && step.key === 'delivered') return 'dotDeliveredActive';
if (step.state === 'active' && step.key === 'wait') return 'dotWaitActive';
if (step.state === 'active') return 'dotActive';
return 'dotTodo';
};
const lineClass = (index) => {
const cur = steps.value[index];
if (cur?.state === 'todo') return 'lineTodo';
return 'lineDone';
};
const truckIconSrc = (step) => {
const fill = step?.state === 'active' ? '#ffffff' : '#b9bec8';
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path fill="${fill}" d="M382.507 768a149.333 149.333 0 0 1-295.68 0h-44.16V256a42.667 42.667 0 0 1 42.666-42.667h597.334A42.667 42.667 0 0 1 725.333 256v85.333h128l128 173.056V768h-86.826a149.376 149.376 0 0 1-295.68 0zM640 298.667H128v343.466a149.333 149.333 0 0 1 241.621 40.534h242.091A150.5 150.5 0 0 1 640 642.133zm85.333 256H896v-12.16l-85.675-115.84h-84.992zm21.334 256a64 64 0 1 0 0-128.043 64 64 0 0 0 0 128.043m-448-64a64 64 0 1 0-128 0 64 64 0 0 0 128 0"/></svg>`;
return `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;
};
const getDetail = async () => {
if (!state.orderId || state.loading) return;
if (!state.orderInfo || !Object.keys(state.orderInfo).length || !(state.pickUpStoreId > 0)) {
const detailRes =
String(state.orderType) === '5'
? await getOpenOrderDetail({ id: state.orderId })
: String(state.source) === 'aishop'
? await getAiOrderDetail({ id: state.orderId })
: await OrderApi.getOrderDetail(state.orderId);
if (detailRes?.code === 0) {
const detailData = detailRes.data?.orderInfo || detailRes.data || {};
state.orderInfo = detailData;
state.pickUpStoreId = resolvePickUpStoreId(detailData);
}
}
if (!(state.pickUpStoreId > 0)) {
uni.showToast({
title: '缺少门店信息',
icon: 'none',
});
return;
}
state.loading = true;
const res = await OrderStoreApi.getPreparationStatus(state.pickUpStoreId, state.orderId);
state.loading = false;
if (res?.code !== 0) return;
const data = res.data;
if (data !== null && typeof data === 'object') {
const merged = data?.orderInfo || data;
state.orderInfo = {
...(state.orderInfo || {}),
...(merged || {}),
};
const next = Number(merged?.preparationStatus ?? merged?.status);
if (Number.isFinite(next)) state.preparationStatus = next;
} else {
const next = Number(data);
if (Number.isFinite(next)) state.preparationStatus = next;
}
if (!(state.pickUpStoreId > 0)) state.pickUpStoreId = resolvePickUpStoreId(state.orderInfo);
};
const notifyStore = () => {
uni.showToast({
title: '已通知门店',
icon: 'none',
});
};
onLoad((options) => {
const id = Number(options?.id || 0);
if (id) state.orderId = id;
const pickUpStoreId = Number(options?.pickUpStoreId || options?.storeId || 0);
if (pickUpStoreId > 0) state.pickUpStoreId = pickUpStoreId;
state.source = String(options?.source || '').trim();
state.orderType = String(options?.type || '').trim();
state.detailStyle = String(options?.detailStyle || 'order').trim() || 'order';
});
onShow(() => {
getDetail();
});
</script>
<style scoped lang="scss">
.page {
padding: 24rpx 24rpx 170rpx;
box-sizing: border-box;
}
.card {
border-radius: 24rpx;
padding: 26rpx 22rpx;
box-sizing: border-box;
margin-bottom: 18rpx;
}
.timeline {
display: flex;
flex-direction: column;
gap: 34rpx;
}
.step {
display: flex;
align-items: stretch;
}
.left {
position: relative;
width: 56rpx;
flex-shrink: 0;
display: flex;
justify-content: flex-start;
}
.dot {
width: 40rpx;
height: 40rpx;
border-radius: 20rpx;
display: flex;
align-items: center;
justify-content: center;
margin: 2rpx auto 0;
position: relative;
z-index: 2;
}
.dotDone {
background: #21c28a;
}
.dotActive {
background: #5b4eff;
}
.dotTodo {
background: #fff;
border: 2rpx solid #e6e8ef;
box-sizing: border-box;
}
.dotDeliveredActive {
background: #fa7e31;
}
.dotWaitActive {
background: #21c28a;
}
.dot-icon {
width: 18rpx;
height: 18rpx;
}
.line {
position: absolute;
left: 50%;
transform: translateX(-50%);
top: 46rpx;
bottom: -34rpx;
width: 4rpx;
border-radius: 2rpx;
}
.lineDone {
background: rgba(0, 0, 0, 0.08);
}
.lineTodo {
background: rgba(0, 0, 0, 0.05);
}
.right {
flex: 1;
padding-left: 10rpx;
}
.title {
font-size: 30rpx;
color: #c9c9c9;
font-weight: 600;
line-height: 1.2;
}
.titleActive {
color: #222;
}
.time {
margin-top: 8rpx;
font-size: 24rpx;
color: #9aa0a6;
}
.desc {
margin-top: 8rpx;
font-size: 24rpx;
color: #9aa0a6;
}
.bar-wrap {
margin-top: 14rpx;
}
.bar {
width: 100%;
height: 10rpx;
border-radius: 6rpx;
background: rgba(0, 0, 0, 0.06);
overflow: hidden;
}
.bar-fill {
height: 100%;
border-radius: 6rpx;
background: #21c28a;
}
.hint {
margin-top: 10rpx;
font-size: 24rpx;
color: #9aa0a6;
}
.goods-card {
border-radius: 24rpx;
padding: 22rpx;
box-sizing: border-box;
}
.goods-empty {
padding: 24rpx 0;
text-align: center;
font-size: 26rpx;
color: #9aa0a6;
}
.footer {
padding: 18rpx 24rpx 28rpx;
}
.btn {
width: 100%;
height: 96rpx;
line-height: 96rpx;
border-radius: 20rpx;
background: #5b4eff;
color: #fff;
font-size: 32rpx;
font-weight: 600;
}
</style>
+26 -11
View File
@@ -1,12 +1,15 @@
<!-- 收银台 -->
<template>
<s-pages title="收银台">
<s-pages title="收银台" :pink_bg="true">
<view class="ss-modal-box ss-flex-col">
<!-- 订单信息 -->
<view class="modal-header ss-flex-col ss-col-center ss-row-center">
<view class="money-box ss-m-b-20">
<text class="money-text">{{ fen2yuan(state.orderInfo.price) }}</text>
</view>
<view class="size22 c_money">
已优惠{{ fen2yuan(state.orderInfo.randomDiscountPrice) }}元
</view>
<view class="time-text">
<text>{{ payDescText }}</text>
</view>
@@ -28,12 +31,7 @@
src="/static/pay/cod_disabled.png"
mode="aspectFit"
/>
<image
class="pay-icon"
v-else
:src="item.icon"
mode="aspectFit"
/>
<image class="pay-icon" v-else :src="item.icon" mode="aspectFit" />
<text class="pay-title c0">{{ item.title }}</text>
</view>
<view class="check-box ss-flex ss-col-center ss-p-l-10">
@@ -61,6 +59,9 @@
<button v-else-if="state.payStatus === -1" class="ss-reset-button past-due-btn" disabled>
支付已过期
</button>
<button v-else-if="state.payStatus === 3" class="submit-btn" @tap="onPay">
切换支付方式
</button>
<button
v-else
class="submit-btn"
@@ -91,7 +92,7 @@
const state = reactive({
orderType: 'goods', // 订单类型; goods - 商品订单, recharge - 充值订单
orderInfo: {}, // 支付单信息
payStatus: 0, // 0=检测支付环境, -2=未查询到支付单信息, -1=支付已过期, 1=待支付,2=订单已支付
payStatus: 0, // 0=检测支付环境, -2=未查询到支付单信息, -1=支付已过期, 1=待支付,2=订单已支付,3=现金待确认
payMethods: [], // 可选的支付方式
payment: '', // 选中的支付方式
});
@@ -136,7 +137,11 @@
},
});
} else {
console.log('支付方式:'+state.payment, '订单类型:'+state.orderType, '订单ID:'+state.orderInfo.id);
console.log(
'支付方式:' + state.payment,
'订单类型:' + state.orderType,
'订单ID:' + state.orderInfo.id,
);
sheep.$platform.pay(state.payment, state.orderType, state.orderInfo.id);
}
};
@@ -146,6 +151,9 @@
if (state.payStatus === 2) {
return '该订单已支付';
}
if (state.payStatus === 3) {
return '现金待确认';
}
// if (state.payStatus === 1 && state.orderInfo?.expireTime) {
// const time = useDurationTime(state.orderInfo.expireTime);
// if (time?.ms <= 0) {
@@ -182,6 +190,10 @@
state.payStatus = -1;
return;
}
if (Number(state.orderInfo.status) === 40) {
state.payStatus = 3;
return;
}
state.payStatus = 1; // 待支付
}
@@ -210,7 +222,7 @@
// 设置支付状态
checkPayStatus();
// 获得支付方式
// 现金待确认不再展示支付渠道
await setPayMethods();
}
@@ -221,7 +233,10 @@
return;
}
console.log(data);
state.payMethods = getPayMethods(data);
// 现金待确认状态下去除现金渠道,仅展示可切换的线上渠道
state.payMethods = getPayMethods(data).filter(
(item) => item.value !== 'cash' || state.payStatus !== 3,
);
console.log(state.payMethods);
state.payMethods.find((item) => {
console.log(item);
+43 -8
View File
@@ -1,6 +1,6 @@
<!-- 支付结果页面 -->
<template>
<s-pages :bgStyle="{ color: theme == 1 ? '#FFF' : '#F2F4F7' }" title="支付结果">
<s-pages :bgStyle="{ color: theme == 1 ? '#FFF' : '#F2F4F7' }" title="支付结果" :pink_bg="true">
<view class="pay-result-box ss-flex-col ss-row-center ss-col-center">
<!-- 信息展示 -->
<view class="pay-waiting ss-m-b-30" v-if="payResult === 'waiting'" />
@@ -35,13 +35,7 @@
<button
class="back-btn ss-reset-button"
:class="{ c0: theme == 2 }"
@tap="
sheep.$router.redirect(
state.orderType === 'aiGoods' || state.orderType === 'aiRecharge'
? '/pages/AI/index'
: '/pages/index/index',
)
"
@tap="onBackHome"
>
返回首页
</button>
@@ -127,6 +121,47 @@
}
});
// 选品广场购买返回
const goAiStoreMyShopTab = () => {
const url = '/pages/index/aiStore?tab=0';//选品广场
uni.redirectTo({
url,
fail: () => {
uni.reLaunch({ url });
},
});
};
const goAiStorePlazaTab = () => {
const url = '/pages/index/aiStore';
uni.redirectTo({
url,
fail: () => {
uni.reLaunch({ url });
},
});
};
const onBackHome = () => {
const returnTo = uni.getStorageSync('pay_return_to');
if (returnTo === 'aiStore_myshop') {
uni.removeStorageSync('pay_return_to');
goAiStoreMyShopTab();
return;
}
if (returnTo === 'aiStore_plaza') {
uni.removeStorageSync('pay_return_to');
goAiStorePlazaTab();
return;
}
const orderType = String(state.orderType || '').trim();
if (orderType === 'aiGoods') {
goAiStoreMyShopTab();
return;
}
sheep.$router.redirect('/pages/index/index');
};
function showRepayModal() {
if (state.result !== 'failed') return;
uni.showModal({
+124
View File
@@ -0,0 +1,124 @@
<template>
<s-pages title="裁剪头像" :purple_bg="true">
<template #navRight>
<view class="nav-cancel" @click="cancel">取消</view>
</template>
<view class="avatar-crop-page">
<avatarCropper :src="src" @confirm="onConfirm" @error="onError" />
<view v-if="uploading" class="loading-mask">
<view class="loading-box">上传中...</view>
</view>
</view>
</s-pages>
</template>
<script setup>
import { ref, getCurrentInstance } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { baseUrl } from '@/sheep/config';
import avatarCropper from '@/components/avatar_uploader/avatar_cropper.vue';
const { proxy } = getCurrentInstance();
const src = ref('');
const uploading = ref(false);
const eventChannel = ref(null);
onLoad((options) => {
src.value = decodeURIComponent(String(options?.src || '').trim());
eventChannel.value = proxy.getOpenerEventChannel ? proxy.getOpenerEventChannel() : null;
});
const uploadAvatar = async (filePath) => {
const token = uni.getStorageSync('token') ? uni.getStorageSync('token') : undefined;
const tenantId = uni.getStorageSync('tenant-id');
const result = await new Promise((resolve, reject) => {
uni.uploadFile({
url: baseUrl + '/app-api/infra/file/upload',
filePath,
name: 'file',
formData: {
directory: 'head',
'tenant-id': tenantId,
token: token,
},
header: {},
success: (res) => resolve(res),
fail: (err) => reject(err),
});
}).catch(() => null);
if (!result) throw new Error('upload_failed');
let data = null;
try {
data = typeof result.data === 'string' ? JSON.parse(result.data) : result.data;
} catch (e) {
throw new Error('upload_parse_failed');
}
const url = data?.data || '';
if (!url) throw new Error('upload_no_url');
return url;
};
const onConfirm = async (croppedFilePath) => {
if (uploading.value) return;
uploading.value = true;
try {
const url = await uploadAvatar(croppedFilePath);
if (eventChannel.value && eventChannel.value.emit) {
eventChannel.value.emit('success', { url });
}
uni.navigateBack();
} catch (e) {
uni.showToast({ title: '上传失败,请重试', icon: 'none' });
} finally {
uploading.value = false;
}
};
const onError = () => {
uni.showToast({ title: '处理失败,请重试', icon: 'none' });
};
const cancel = () => {
if (uploading.value) return;
uni.navigateBack();
};
</script>
<style lang="scss" scoped>
.avatar-crop-page {
position: relative;
height: 100%;
}
.nav-cancel {
padding: 0 24rpx;
height: 88rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 30rpx;
color: rgba(51, 51, 51, 0.9);
}
.loading-mask {
position: absolute;
inset: 0;
z-index: 999;
display: flex;
align-items: center;
justify-content: center;
background: rgba(0, 0, 0, 0.35);
}
.loading-box {
padding: 18rpx 26rpx;
border-radius: 14rpx;
background: rgba(0, 0, 0, 0.55);
color: #fff;
font-size: 28rpx;
}
</style>
+1 -1
View File
@@ -1,5 +1,5 @@
<template>
<s-pages title="华贸专区">
<s-pages title="华贸专区" :pink_bg="true">
<view class="container">
<web-view :src="url" />
</view>
+361 -110
View File
@@ -1,38 +1,75 @@
<template>
<!-- 空登陆页 -->
<s-layout navbar="inner" title="登录" color="#19203b">
<view class="login">
<s-layout navbar="inner" title="登录" navPreset="float">
<view class="login" @tap="onPageTap">
<view class="login_top_img w100" :style="{ top: -height + 'px' }">
<image :src="$url + 'index/login_bg1.png'" mode="widthFix" class="w100" />
<image src="@/static/index/login_bg.png" mode="widthFix" class="w100" />
</view>
<view class="login_con w100 flex-column ju-between">
<view class="login_top">
<view class="font-Heavy size52 c0">Hello!</view>
<view class="font-Heavy size52 c0">欢迎使用优购商城</view>
<view class="font-Heavy size52 c1">Hello!</view>
<view class="font-Heavy size52 c1">欢迎使用康源家园</view>
</view>
<view class="flex1 bottomCon">
<view class="bottomCon">
<view class="login_bottom">
<view class="size40 f500 title">{{ dataObj.con[type].title }}</view>
<view class="form">
<uni-forms ref="form" label-position="top">
<view v-for="(v, i) in dataObj.con[type].arr" :key="i">
<uni-forms-item
:required="false"
:required="dataObj.formArr[v].required !== false"
:label="dataObj.formArr[v].title"
:name="dataObj.formArr[v].value"
>
<view class="flex-center border_bottom">
<view class="flex-center border_bottom login-input-wrap" @tap.stop>
<image class="input-icon" :src="inputIconMap[v]" mode="aspectFit" />
<uni-easyinput
v-model="formData[dataObj.formArr[v].value]"
:placeholder="dataObj.formArr[v].placeholder"
:type="dataObj.formArr[v].type"
:inputBorder="false"
:maxlength="dataObj.formArr[v].max"
:disabled="dataObj.formArr[v].value === 'inviteCode'"
@focus="() => onInputFocus(dataObj.formArr[v].value)"
@input="() => onInputInput(dataObj.formArr[v].value)"
/>
<view v-if="v == 2" class="c_primary size28" @click="getCode">{{
<view v-if="v == 2" class="c_code size28" @click="getCode">{{
num > 0 && num < 60 ? num + 's后重新获取' : '获取验证码'
}}</view>
<view v-if="v == 6" class="invite-scan-icon _icon-scan" @tap.stop="onInviteScan"></view>
<view
v-if="shouldShowDropdownIcon(dataObj.formArr[v].value)"
class="login-suggest-icon"
@tap.stop="() => onToggleDropdown(dataObj.formArr[v].value)"
>
<uni-icons type="bottom" size="18" color="#C6C6C6" />
</view>
</view>
<scroll-view
v-if="shouldShowSuggestionList(dataObj.formArr[v].value)"
class="login-suggest"
scroll-y="true"
:show-scrollbar="false"
enhanced
@tap.stop
@touchmove.stop
>
<view
v-for="item in suggestionListFor(dataObj.formArr[v].value)"
:key="item.mobile"
class="login-suggest-item"
@tap.stop="() => onSelectSuggestion(item)"
>
<template v-if="dataObj.formArr[v].value === 'password'">
<view class="login-suggest-title">{{ formatPasswordPreview(item.password) }}</view>
<view class="login-suggest-sub">{{ item.mobile }}</view>
</template>
<template v-else>
<view class="login-suggest-title">{{ item.mobile }}</view>
<view class="login-suggest-sub">{{ item.hasPassword ? '已保存密码' : '仅保存账号' }}</view>
</template>
</view>
</scroll-view>
</uni-forms-item>
</view>
</uni-forms>
@@ -41,19 +78,19 @@
<view class="flex-row">
<view class="">{{ dataObj.con[type].text }}</view>
<view
class="c_primary"
class="c_switch"
@click="typeChange(dataObj.btns[dataObj.con[type].btn1].value)"
>{{ dataObj.btns[dataObj.con[type].btn1].text }}</view
>
</view>
<view
class="c_primary"
class="c_switch"
@click="typeChange(dataObj.btns[dataObj.con[type].btn2].value)"
v-if="dataObj.con[type].btn2"
>{{ dataObj.btns[dataObj.con[type].btn2]?.text }}</view
>
</view>
<view class="submit-btn" @click="$debounce(sub, 1000)">
<view class="submit-btn" :class="{ 'submit-btn--disabled': submitLoading }" @tap="handleSubmit">
{{ dataObj.con[type].sub }}
</view>
</view>
@@ -61,12 +98,12 @@
<view class="radio-box">
<radio-group @change="radioChange">
<label class="flex-center">
<radio color="#FA7E31" class="radio" value="1" :checked="false" />
<radio color="#C02F3B" class="radio" value="1" :checked="false" />
<view class="flex-center size24">
我已阅读并同意
<text class="c_primary" @click="go(2)">《用户服务协议》</text>
<text class="c_agreement" @click="go(2)">《用户服务协议》</text>
和
<text class="c_primary" @click="go(1)">《隐私政策》</text>
<text class="c_agreement" @click="go(1)">《隐私政策》</text>
</view>
</label>
</radio-group>
@@ -78,14 +115,28 @@
</template>
<script setup>
import { ref, reactive } from 'vue';
import { ref, reactive, computed, nextTick } from 'vue';
import sheep from '@/sheep';
import { onLoad } from '@dcloudio/uni-app';
import { gethotupdatelist } from '@/sheep/api/index/index';
import AuthUtil from '@/sheep/api/member/auth';
import { scanInviteCode } from '@/utils/qrScanner';
let type = ref(2);
let formData = reactive({});
let formData = reactive({
mobile: '',
code: '',
password: '',
confirmPassword: '',
inviteCode: '',
});
let num = ref(0);
const inputIconMap = {
1: '/static/icon/icon1.png',
2: '/static/icon/icon2.png',
3: '/static/icon/icon3.png',
4: '/static/icon/icon3.png',
5: '/static/icon/icon4.png',
6: '/static/icon/icon5.png',
};
let dataObj = reactive({
con: {
1: {
@@ -108,8 +159,7 @@
},
3: {
title: '用户注册',
arr: [1, 4, 5],
// arr: [1, 2, 4, 5],
arr: [1, 2, 4, 5, 6],
text: '已有账号,',
btn1: 4,
btn2: 3,
@@ -159,6 +209,13 @@
value: 'confirmPassword',
placeholder: '请再次输入您的密码',
},
6: {
title: '邀请码',
type: 'text',
value: 'inviteCode',
max: 32,
placeholder: '请扫码获取邀请码',
},
},
btns: {
1: {
@@ -169,10 +226,10 @@
text: '密码登录',
value: 2,
},
// 3: {
// text: '验证码登录',
// value: 1,
// },
3: {
text: '验证码登录',
value: 1,
},
4: {
text: '去登录',
value: 2,
@@ -218,6 +275,132 @@
const radioChange = (e) => {
radioValue.value = e.detail.value;
};
const LOGIN_HISTORY_KEY = 'login-history';
const HISTORY_LIMIT = 20;
const loginHistory = ref([]);
const dropdownVisibleFor = ref('');
const submitLoading = ref(false);
const hasAnyHistory = computed(() => {
const list = Array.isArray(loginHistory.value) ? loginHistory.value : [];
return list.length > 0;
});
const canUseLoginHistory = computed(() => {
const arr = dataObj?.con?.[type.value]?.arr;
return Array.isArray(arr) && arr.includes(3);
});
const mobileQuery = computed(() => String(formData.mobile || '').trim());
const filteredHistory = computed(() => {
const query = mobileQuery.value;
const list = Array.isArray(loginHistory.value) ? loginHistory.value : [];
const normalized = list
.filter((item) => item && item.mobile)
.map((item) => ({
mobile: String(item.mobile),
password: item.password ? String(item.password) : '',
updatedAt: Number(item.updatedAt || 0),
hasPassword: Boolean(item.password),
}))
.sort((a, b) => b.updatedAt - a.updatedAt);
if (!query) return normalized;
return normalized.filter((item) => item.mobile.includes(query));
});
const passwordHistory = computed(() => filteredHistory.value.filter((item) => item.hasPassword));
function loadLoginHistory() {
try {
const raw = uni.getStorageSync(LOGIN_HISTORY_KEY);
const parsed = raw ? JSON.parse(raw) : [];
loginHistory.value = Array.isArray(parsed) ? parsed : [];
} catch (e) {
loginHistory.value = [];
}
}
function persistLoginHistory() {
try {
uni.setStorageSync(LOGIN_HISTORY_KEY, JSON.stringify(loginHistory.value.slice(0, HISTORY_LIMIT)));
} catch (e) {}
}
function upsertLoginHistory({ mobile, password }) {
const nextMobile = String(mobile || '').trim();
if (!/^1\d{10}$/.test(nextMobile)) return;
const nextPassword = String(password || '');
const now = Date.now();
const next = Array.isArray(loginHistory.value) ? [...loginHistory.value] : [];
const existingIndex = next.findIndex((item) => String(item?.mobile || '') === nextMobile);
const payload = { mobile: nextMobile, password: nextPassword, updatedAt: now };
if (existingIndex >= 0) next.splice(existingIndex, 1, payload);
else next.unshift(payload);
loginHistory.value = next.sort((a, b) => Number(b.updatedAt || 0) - Number(a.updatedAt || 0));
persistLoginHistory();
}
function onPageTap() {
dropdownVisibleFor.value = '';
}
function onToggleDropdown(field) {
if (!canUseLoginHistory.value) return;
const next = dropdownVisibleFor.value === field ? '' : field;
if (next && !suggestionListFor(field).length) return;
dropdownVisibleFor.value = next;
}
function onInputFocus(field) {
if (!canUseLoginHistory.value) return;
if (field !== 'mobile' && field !== 'password') return;
if (!suggestionListFor(field).length) return;
dropdownVisibleFor.value = field;
}
function onInputInput(field) {
if (!canUseLoginHistory.value) return;
if (field !== 'mobile') return;
if (!filteredHistory.value.length) {
dropdownVisibleFor.value = '';
return;
}
if (dropdownVisibleFor.value !== 'mobile') dropdownVisibleFor.value = 'mobile';
}
function shouldShowDropdownIcon(field) {
if (!canUseLoginHistory.value) return false;
if (!hasAnyHistory.value) return false;
return field === 'mobile' || field === 'password';
}
function shouldShowSuggestionList(field) {
if (!canUseLoginHistory.value) return false;
if (dropdownVisibleFor.value !== field) return false;
return suggestionListFor(field).length > 0;
}
function suggestionListFor(field) {
if (field === 'password') return passwordHistory.value;
return filteredHistory.value;
}
function onSelectSuggestion(item) {
formData.mobile = item.mobile;
if (item.hasPassword) formData.password = item.password;
dropdownVisibleFor.value = '';
nextTick(() => {
uni.hideKeyboard();
});
}
function formatPasswordPreview(value) {
const text = String(value || '');
if (!text) return '******';
const len = Math.min(Math.max(text.length, 6), 12);
return '•'.repeat(len);
}
const sub = async () => {
if (!radioValue.value) {
uni.showToast({
@@ -230,14 +413,18 @@
let arr = dataObj.con[type.value].arr;
let obj = {};
for (let i = 0; i < arr.length; i++) {
if (!formData[dataObj.formArr[arr[i]].value]) {
const formItem = dataObj.formArr[arr[i]];
const valueKey = formItem?.value;
const required = formItem?.required !== false;
const value = formData[valueKey];
if (required && !value) {
uni.showToast({
title: dataObj.formArr[arr[i]].placeholder,
title: formItem?.placeholder,
icon: 'none',
});
return;
}
obj[dataObj.formArr[arr[i]].value] = formData[dataObj.formArr[arr[i]].value];
if (value || required) obj[valueKey] = value;
}
let url = '';
switch (type.value) {
@@ -260,18 +447,37 @@
case 4: //忘记密码
break;
}
url(obj).then((res) => {
if (res.code === 0) {
if (type.value == 3) {
typeChange(2);
return;
}
sheep.$store('user').getInfo();
setTimeout(() => {
uni.reLaunch({ url: '/pages/index/index' });
}, 1000);
if (!url) return;
const res = await url(obj).catch(() => null);
if (res?.code === 0) {
if (type.value == 3) {
typeChange(2);
return;
}
});
if (type.value === 2) {
upsertLoginHistory({ mobile: formData.mobile, password: formData.password });
}
sheep.$store('user').getInfo();
setTimeout(() => {
uni.reLaunch({ url: '/pages/index/index' });
}, 1000);
}
};
const handleSubmit = async () => {
if (submitLoading.value) return;
submitLoading.value = true;
dropdownVisibleFor.value = '';
uni.hideKeyboard();
await nextTick();
await new Promise((resolve) => setTimeout(resolve, 80));
try {
await sub();
} finally {
setTimeout(() => {
submitLoading.value = false;
}, 300);
}
};
let timer = ref();
const getCode = () => {
@@ -313,7 +519,7 @@
numType = 4;
break;
}
AuthUtil.sendSmsCode(formData.mobile, numType).then((res) => {
AuthUtil.sendSmsCode({ mobile: formData.mobile, scene: numType }).then((res) => {
if (res.code === 0) {
num.value = 60;
timer.value = setInterval(() => {
@@ -329,77 +535,25 @@
const go = (type) => {
uni.navigateTo({ url: '/pages/home/agreement?type=' + type });
};
onLoad(async () => {});
const onInviteScan = async () => {
const code = await scanInviteCode({ toastOnError: true, allowCamera: false });
if (!code) return;
formData.inviteCode = code;
};
onLoad(async () => {
loadLoginHistory();
});
let sysInfo = uni.getSystemInfoSync();
const windowHeight = sysInfo.windowHeight;
let height = ref(0);
height.value = sysInfo.statusBarHeight + uni.upx2px(88);
const wgtUp = async () => {
// console.log(plus.runtime);
let res = await gethotupdatelist();
if (res.code !== 0) return;
let filePath = res.data.filePath;
let localVersion = uni.getSystemInfoSync().appWgtVersion;
if (res.data.versionNumber != localVersion) {
uni.showModal({
title: '提示',
content: '发现新的版本,是否更新?',
confirmColor: '#FA7E31',
success: (res) => {
downloadFile(filePath);
},
});
}
};
const downloadFile = (url) => {
uni.downloadFile({
url: url,
success: (downloadResult) => {
uni.showToast({
title: '更新中....',
icon: 'none',
});
if (downloadResult) {
if (downloadResult.statusCode === 200) {
plus.runtime.install(
downloadResult.tempFilePath,
{
force: true,
},
function () {
uni.showModal({
title: '成功提示',
content: '热更新成功,请重启应用',
confirmColor: '#FA7E31',
showCancel: false,
success: function (res) {
if (res.confirm) {
plus.runtime.restart(); //自动重启软件
}
},
});
},
function (e) {
uni.showModal({
title: '失败提示',
content: e,
showCancel: false,
confirmColor: '#FA7E31',
});
},
);
}
}
},
});
};
</script>
<style lang="scss" scoped>
.login {
position: relative;
min-height: 100vh;
padding-bottom: 200rpx;
.login_top_img {
position: absolute;
z-index: 1;
@@ -422,35 +576,132 @@
margin-bottom: 48rpx;
}
.bottomCon {
width: 90%;
margin: 0 auto;
background-color: #ffffff;
border-radius: 80rpx 80rpx 0 0;
border-radius: 40rpx;
position: absolute;
top: 220rpx;
left: 5%;
box-sizing: border-box;
overflow: hidden;
padding: 0 0 20rpx;
}
.login_bottom {
// background: linear-gradient(144deg, #19203b 0%, #070c18 100%);
padding: 60rpx;
border-radius: 40rpx;
padding: 40rpx;
box-sizing: border-box;
}
.border_bottom {
border-bottom: 1px solid #999999;
background-color: #f3f4f7;
border-radius: 10rpx;
padding: 0 24rpx;
box-sizing: border-box;
min-height: 80rpx;
}
.submit-btn {
margin-top: 18rpx;
margin-top: 40rpx;
height: 108rpx;
border-radius: 54rpx;
font-size: 36rpx;
font-weight: 700;
background: linear-gradient(
135deg,
var(--primary-grad-start, #2c8cfa) 0%,
var(--primary-grad-end, #3d5efb) 100%
);
box-shadow: 0 18rpx 44rpx var(--primary-shadow, rgba(47, 124, 246, 0.35));
}
.submit-btn--disabled {
opacity: 0.72;
}
.input-icon {
width: 40rpx;
height: 40rpx;
margin-right: 16rpx;
flex-shrink: 0;
}
.radio-box {
padding-top: 100rpx;
padding-bottom: 60rpx;
background-color: #ffffff;
padding-top: 20rpx;
padding-bottom: 36rpx;
// background-color: #ffffff;
}
.radio {
transform: scale(0.6);
}
.btns {
margin-top: 70rpx;
margin-top: 40rpx;
}
.title {
margin-bottom: 70rpx;
margin-bottom: 30rpx;
}
:deep(.uni-radio-input) {
background-color: transparent;
}
.c_agreement {
color: #c02f3b;
}
.c_switch {
color: #c02f3b;
}
.c_code {
color: #c02f3b;
}
:deep(.border_bottom .uni-easyinput__content) {
border: none !important;
background: transparent !important;
}
.login-input-wrap {
position: relative;
}
.login-suggest-icon {
padding-left: 12rpx;
padding-right: 6rpx;
display: flex;
align-items: center;
}
.invite-scan-icon {
margin-left: auto;
padding-left: 12rpx;
padding-right: 6rpx;
display: flex;
align-items: center;
font-size: 36rpx;
color: #c6c6c6;
}
.login-suggest {
position: absolute;
left: 0;
right: 0;
top: calc(100% + 8rpx);
background: #ffffff;
border-radius: 20rpx;
box-shadow: 0 16rpx 40rpx rgba(0, 0, 0, 0.12);
z-index: 20;
overflow: hidden;
max-height: 420rpx;
}
.login-suggest-item {
padding: 20rpx 24rpx;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 2rpx solid rgba(0, 0, 0, 0.06);
box-sizing: border-box;
}
.login-suggest-item:last-child {
border-bottom: none;
}
.login-suggest-title {
font-size: 28rpx;
font-weight: 700;
color: #111111;
}
.login-suggest-sub {
font-size: 22rpx;
color: #9aa0aa;
font-weight: 600;
}
</style>
+1 -1
View File
@@ -1,5 +1,5 @@
<template>
<s-pages title="账号注销">
<s-pages title="账号注销" :pink_bg="true">
<view class="pages p-x-20">
<view class="card bg24">
<view class="card_title flex-center ju-between">
+1 -1
View File
@@ -1,6 +1,6 @@
<!-- 搜索界面 -->
<template>
<s-pages class="set-wrap" title="搜索" color="#ffffff">
<s-pages class="set-wrap" title="搜索" color="#ffffff" :pink_bg="true">
<view class="">
<card_search class="search" style="margin-bottom: 32rpx" @search="onSearch"></card_search>
<view class="search_top">
+24 -26
View File
@@ -1,5 +1,5 @@
<template>
<s-pages title="设置">
<s-pages title="设置" :purple_bg="true">
<view class="setPage">
<view class="card1">
<card_list :arr="listArr">
@@ -30,7 +30,6 @@
import { ref, computed, reactive, onMounted } from 'vue';
import AuthUtil from '@/sheep/api/member/auth';
import card_list from '@/components/card_list/card_list.vue';
import { baseUrl } from '@/sheep/config';
import UserApi from '@/sheep/api/member/user';
const appInfo = computed(() => sheep.$store('app').info);
const isLogin = computed(() => sheep.$store('user').isLogin);
@@ -76,6 +75,13 @@
link: 'navigateTo',
to: '/pages/home/pass',
},
{
id: '12',
title: '银行卡',
clickable: true,
link: 'navigateTo',
to: '/pages/home/bankCard',
},
{
id: '5',
title: '隐私政策',
@@ -171,35 +177,27 @@
const upImg = () => {
uni.chooseImage({
count: 1, //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
success: function (res) {
const tempFilePaths = res.tempFilePaths;
const tempFiles = res.tempFiles;
let resSize = tempFiles[0].size;
if (resSize > 1048576) {
count: 1,
sizeType: ['original', 'compressed'],
success: (res) => {
const filePath = res?.tempFilePaths?.[0] || '';
const size = res?.tempFiles?.[0]?.size;
if (typeof size === 'number' && size > 1048576) {
uni.showToast({
title: '上传图片大小不能超过1MB',
icon: 'error',
icon: 'none',
});
return;
}
const token = uni.getStorageSync('token') ? uni.getStorageSync('token') : undefined;
let tenant_id = uni.getStorageSync('tenant-id');
uni.uploadFile({
url: baseUrl + '/app-api/infra/file/upload', //仅为示例,非真实的接口地址
filePath: tempFilePaths[0],
name: 'file',
formData: {
directory: 'head',
'tenant-id': tenant_id,
token: token,
},
header: {},
success: (uploadFileRes) => {
let url = JSON.parse(uploadFileRes.data).data;
upData({
avatar: url,
if (!filePath) return;
uni.navigateTo({
url: `/pages/public/avatarCrop?src=${encodeURIComponent(filePath)}`,
success: (navRes) => {
const eventChannel = navRes?.eventChannel;
if (!eventChannel) return;
eventChannel.on('success', ({ url }) => {
if (!url) return;
upData({ avatar: url });
});
},
});
+154 -169
View File
@@ -1,191 +1,176 @@
<template>
<s-pages title="版本号">
<s-pages title="版本号" :pink_bg="true">
<view class="pages relative h100 p-t-50">
<view class="w_150 h_150 m-b-50" style="margin: 0 auto">
<image class="w100 h100" src="/static/logo.png" mode="scaleToFill" />
</view>
<view class="center"> 最新版本号: {{ newversion }} </view>
<view class="center m-t-50"> 当前版本号: {{ version }} </view>
<!-- <view class="center m-t-50">当前环境api:{{ baseUrl }}</view> -->
<!-- #ifdef APP-PLUS -->
<view class="flex-center m-t-100 absolute b50 w100 p-x-32">
<view class="ai-button2 m-r-20" @click="downloadFile()">更新最新版本</view>
<view class="ai-button2 m-r-20" @click="onClickUpdate()">更新最新版本</view>
<view class="ai-button2" @click="copy()">复制APP下载链接</view>
</view>
<!-- #endif -->
</view>
<view v-if="showUpdateProgress" class="update-progress-mask">
<view class="update-progress-card">
<view class="update-progress-title">{{ updateProgressText }}</view>
<view class="update-progress-bar">
<view class="update-progress-bar__fill" :style="{ width: updateProgress + '%' }"></view>
</view>
<view class="update-progress-percent">{{ updateProgress }}%</view>
</view>
</view>
</s-pages>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, onUnmounted, getCurrentInstance, watch, nextTick } from 'vue';
import { gethotupdatelist, getAndroidAppUrl } from '@/sheep/api/index/index';
import sheep from '@/sheep';
let { proxy } = getCurrentInstance();
let newversion = ref('');
let version = ref('');
let filePath = ref();
let androidUrl = ref(); //安卓apk地址
<script setup>
import { ref, onMounted } from 'vue'
import { createHotUpdate, downloadAndOpenApk } from '@/utils/hotUpdate'
import { getAndroidAppUrl, gethotupdatelist } from '@/sheep/api/index/index'
// import { baseUrl } from '@/sheep/config';
const newversion = ref('')
const version = ref('')
const appVersion = ref('')
const wgtVersion = ref('')
const updateInfoRef = ref({})
const apkPath = ref('')
const wgtUp = async () => {
// console.log(plus.runtime);
let res = await gethotupdatelist();
if (res.code !== 0) return;
filePath.value = res.data.filePath;
let localVersion = uni.getSystemInfoSync().appWgtVersion;
version.value = localVersion;
newversion.value = res.data.versionNumber;
if (res.data.versionNumber != localVersion) {
if (res.data.type == 'min') {
if (res.data.isForceUpdate) {
// 强制更新
downloadFile();
} else {
uni.showModal({
title: '提示',
content: '发现新的版本,是否更新?',
confirmColor: '#FA7E31',
success: (res) => {
if (res.confirm) {
downloadFile();
} else if (res.cancel) {
if (res.data.isForceUpdate) {
plus.runtime.quit(); //退出应用
}
}
},
});
}
} else {
uni.showModal({
title: '提示',
content: '发现新的版本,请到立即更新到最新版本',
confirmText: '立即更新',
cancelText: res.data.isForceUpdate ? '关闭' : '取消',
confirmColor: '#FA7E31',
const showUpdateProgress = ref(false)
const updateProgress = ref(0)
const updateProgressText = ref('下载中...')
success: (res) => {
if (res.confirm) {
updateApp(filePath.value);
} else if (res.cancel) {
if (res.data.isForceUpdate) {
plus.runtime.quit(); //退出应用
}
}
},
});
}
}
};
const updateApp = (url) => {
uni.showLoading({
title: '下载中',
});
uni.downloadFile({
url: url, //下载地址
success: (res) => {
console.log(res, '下载成功');
if (res.statusCode === 200) {
console.log('下载成功');
uni.hideLoading();
uni.showToast({
title: '下载成功',
icon: 'success',
});
uni.saveFile({
tempFilePath: res.tempFilePath,
success: function (res) {
uni.openDocument({
filePath: res.savedFilePath,
success: function (res) {
console.log(res, '打开安装包');
},
});
},
fail: (err) => {
console.log(err, '打开安装包-失败');
},
});
}
},
fail(e) {
uni.hideLoading();
uni.showToast({
title: '下载失败,请检查网络',
icon: 'none',
});
console.log(e);
},
});
};
const copy = () => {
uni.setClipboardData({
data: androidUrl.value,
success: () => {
uni.showToast({
title: '链接已复制,请在浏览器打开',
icon: 'none',
});
},
});
};
const downloadFile = () => {
if (newversion.value == version.value) {
uni.showToast({ title: '已经是最新版本', icon: 'none' });
return;
}
let url = filePath.value;
uni.downloadFile({
url: url,
success: (downloadResult) => {
uni.showToast({
title: '更新中....',
icon: 'none',
});
if (downloadResult) {
if (downloadResult.statusCode === 200) {
plus.runtime.install(
downloadResult.tempFilePath,
{
force: true,
},
function () {
uni.showModal({
title: '成功提示',
content: '热更新成功,请重启应用',
confirmColor: '#FA7E31',
showCancel: false,
success: function (res) {
if (res.confirm) {
plus.runtime.restart(); //自动重启软件
}
},
});
},
function (e) {
uni.showModal({
title: '失败提示',
content: e,
showCancel: false,
confirmColor: '#FA7E31',
});
},
);
}
}
},
});
};
const progress = {
show: (text) => {
showUpdateProgress.value = true
updateProgress.value = 0
updateProgressText.value = String(text || '下载中...')
},
set: (p, text) => {
updateProgress.value = Math.max(0, Math.min(100, Number(p) || 0))
if (text) updateProgressText.value = String(text)
},
hide: () => {
showUpdateProgress.value = false
},
}
//获取安卓apk
function getAndroid() {
getAndroidAppUrl().then((res) => {
console.log(res.data);
androidUrl.value = res.data || 'http://8.136.55.200:1080/app.apk';
});
const hotUpdate = createHotUpdate({
progress,
apkMode: 'download',
getLatest: gethotupdatelist,
})
const wgtUp = async () => {
const payload = await hotUpdate.fetchLatest()
if (!payload) return
const { updateInfo, localWgtVersion, localAppVersion, localCompareVersion, latestVersion } = payload
updateInfoRef.value = updateInfo || {}
wgtVersion.value = String(localWgtVersion || '')
appVersion.value = String(localAppVersion || '')
version.value = String(localCompareVersion || localAppVersion || localWgtVersion || '')
newversion.value = String(latestVersion || '')
apkPath.value = String(updateInfo?.apkPath || '')
}
const onClickUpdate = async () => {
await wgtUp()
await hotUpdate.promptAndUpdate(updateInfoRef.value, { source: 'manual' })
}
const copy = async () => {
if (!apkPath.value) {
try {
const res = await getAndroidAppUrl({})
apkPath.value = String(res?.data || '')
} catch (e) {}
}
onMounted(() => {
getAndroid();
wgtUp();
});
if (!apkPath.value) {
uni.showToast({ title: '暂无下载链接', icon: 'none' })
return
}
const url = apkPath.value
uni.setClipboardData({
data: url,
success: () => {
uni.showToast({ title: '链接已复制', icon: 'none' })
uni.showModal({
title: '提示',
content: '是否立即下载更新?',
confirmText: '立即下载',
cancelText: '暂不下载',
confirmColor: 'var(--color2)',
success: (res) => {
if (!res?.confirm) return
downloadAndOpenApk(apkPath.value, { progress })
},
})
},
})
}
onMounted(() => {
// #ifdef APP-PLUS
wgtUp()
// #endif
})
</script>
<style lang="scss" scoped>
.pages {
}
.update-progress-mask {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.45);
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
padding: 40rpx;
box-sizing: border-box;
}
.update-progress-card {
width: 100%;
max-width: 560rpx;
background: #fff;
border-radius: 16rpx;
padding: 32rpx;
box-sizing: border-box;
}
.update-progress-title {
font-size: 28rpx;
color: #333;
text-align: center;
margin-bottom: 20rpx;
}
.update-progress-bar {
height: 18rpx;
background: rgba(0, 0, 0, 0.08);
border-radius: 999rpx;
overflow: hidden;
}
.update-progress-bar__fill {
height: 100%;
background: var(--color2);
border-radius: 999rpx;
width: 0%;
transition: width 0.2s linear;
}
.update-progress-percent {
font-size: 28rpx;
color: #333;
text-align: center;
margin-top: 16rpx;
}
</style>
+25 -3
View File
@@ -1,7 +1,14 @@
<!-- 网页加载 -->
<template>
<s-layout :title="title" />
<iframe :src="url" frameborder="0" class="iframe" />
<view class="container">
<!-- #ifdef APP-PLUS || MP -->
<web-view :src="url" class="webview" />
<!-- #endif -->
<!-- #ifdef H5 -->
<iframe :src="url" frameborder="0" class="iframe" />
<!-- #endif -->
</view>
</template>
<script setup>
@@ -10,15 +17,30 @@
const url = ref();
const title = ref();
const safeDecode = (value) => {
const text = String(value || '');
if (!text) return '';
try {
return decodeURIComponent(text);
} catch (e) {
return text;
}
};
onLoad((e) => {
url.value = e.url;
title.value = e.title;
url.value = safeDecode(e.url);
title.value = safeDecode(e.title);
console.log(e);
});
</script>
<style lang="scss" scoped>
.container {
width: 100%;
height: 100vh;
}
.webview,
.iframe {
width: 100%;
height: 100%;

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