diff --git a/src/App.vue b/src/App.vue index 8413ea35..f991459d 100644 --- a/src/App.vue +++ b/src/App.vue @@ -7,6 +7,7 @@ // uni.hideTabBar({ // fail: () => {}, // }); + // 加载Shopro底层依赖 ShoproInit(); }); diff --git a/src/main.scss b/src/main.scss index 82fb7f98..b87c5fcb 100644 --- a/src/main.scss +++ b/src/main.scss @@ -14,5 +14,8 @@ page { background-color: #222222; color: #ffffff; font-size: 14px; + height: 100%; --wot-color-theme: #ffcd32; + --wot-backtop-bg: #ffcd32; + --wot-dark-background: #222; } diff --git a/src/main.ts b/src/main.ts index a2400157..e00b21aa 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,5 @@ import App from './App.vue'; -import { createSSRApp, defineComponent, h } from 'vue'; +import { createSSRApp } from 'vue'; // @ts-ignore import { setupPinia } from './sheep/store'; import './main.scss'; @@ -7,7 +7,9 @@ import 'virtual:uno.css'; export function createApp() { const app = createSSRApp(App); + setupPinia(app); + return { app, }; diff --git a/src/pages.json b/src/pages.json index ca03f7ea..e1498f87 100644 --- a/src/pages.json +++ b/src/pages.json @@ -4,10 +4,89 @@ "custom": { "^uni-(.*)": "@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue", "^su-(.*)": "@/sheep/ui/su-$1/su-$1.vue", + "^s-(.*)": "@/sheep/components/s-$1/s-$1.vue", "^wd-(.*)": "wot-design-uni/components/wd-$1/wd-$1.vue" } }, "pages": [ + // { + // "path": "pages/index/index", + // "aliasPath": "/", + // "style": { + // "navigationBarTitleText": "首页", + // "enablePullDownRefresh": true + // }, + // "meta": { + // "auth": false, + // "sync": true, + // "title": "首页", + // "group": "商城" + // } + // }, + // { + // "path": "pages/index/user", + // "style": { + // "navigationBarTitleText": "个人中心", + // "enablePullDownRefresh": true + // }, + // "meta": { + // "sync": true, + // "title": "个人中心", + // "group": "商城" + // } + // }, + // { + // "path": "pages/index/category", + // "style": { + // "navigationBarTitleText": "商品分类" + // }, + // "meta": { + // "sync": true, + // "title": "商品分类", + // "group": "商城" + // } + // }, + // { + // "path": "pages/index/cart", + // "style": { + // "navigationBarTitleText": "购物车" + // }, + // "meta": { + // "sync": true, + // "title": "购物车", + // "group": "商城" + // } + // }, + // { + // "path": "pages/index/login", + // "style": { + // "navigationBarTitleText": "登录" + // } + // }, + // { + // "path": "pages/index/search", + // "style": { + // "navigationBarTitleText": "搜索" + // }, + // "meta": { + // "sync": true, + // "title": "搜索", + // "group": "商城" + // } + // }, + // { + // "path": "pages/index/page", + // "style": { + // "navigationBarTitleText": "" + // }, + // "meta": { + // "auth": false, + // "sync": true, + // "title": "自定义页面", + // "group": "商城" + // } + // }, + { "path": "pages/home/home", "style": { @@ -100,12 +179,614 @@ } ] } + + // { + // "root": "pages/goods", + // "pages": [ + // { + // "path": "index", + // "style": { + // "navigationBarTitleText": "商品详情" + // }, + // "meta": { + // "sync": true, + // "title": "普通商品", + // "group": "商品" + // } + // }, + // { + // "path": "groupon", + // "style": { + // "navigationBarTitleText": "拼团商品" + // }, + // "meta": { + // "sync": true, + // "title": "拼团商品", + // "group": "商品" + // } + // }, + + // { + // "path": "seckill", + // "style": { + // "navigationBarTitleText": "秒杀商品" + // }, + // "meta": { + // "sync": true, + // "title": "秒杀商品", + // "group": "商品" + // } + // }, + // { + // "path": "point", + // "style": { + // "navigationBarTitleText": "积分商品" + // }, + // "meta": { + // "sync": true, + // "title": "积分商品", + // "group": "商品" + // } + // }, + // { + // "path": "list", + // "style": { + // "navigationBarTitleText": "商品列表" + // }, + // "meta": { + // "sync": true, + // "title": "商品列表", + // "group": "商品" + // } + // }, + // { + // "path": "comment/add", + // "style": { + // "navigationBarTitleText": "评价商品" + // }, + // "meta": { + // "auth": true + // } + // }, + // { + // "path": "comment/list", + // "style": { + // "navigationBarTitleText": "商品评价" + // } + // } + // ] + // }, + // { + // "root": "pages/order", + // "pages": [ + // { + // "path": "detail", + // "style": { + // "navigationBarTitleText": "订单详情" + // }, + // "meta": { + // "auth": true, + // "title": "订单详情" + // } + // }, + // { + // "path": "confirm", + // "style": { + // "navigationBarTitleText": "确认订单" + // }, + // "meta": { + // "auth": true, + // "title": "确认订单" + // } + // }, + // { + // "path": "list", + // "style": { + // "navigationBarTitleText": "我的订单", + // "enablePullDownRefresh": true + // }, + // "meta": { + // "auth": true, + // "sync": true, + // "title": "用户订单", + // "group": "订单中心" + // } + // }, + // { + // "path": "aftersale/apply", + // "style": { + // "navigationBarTitleText": "申请售后" + // }, + // "meta": { + // "auth": true, + // "title": "申请售后" + // } + // }, + // { + // "path": "aftersale/return-delivery", + // "style": { + // "navigationBarTitleText": "退货物流" + // }, + // "meta": { + // "auth": true, + // "title": "退货物流" + // } + // }, + // { + // "path": "aftersale/list", + // "style": { + // "navigationBarTitleText": "售后列表" + // }, + // "meta": { + // "auth": true, + // "sync": true, + // "title": "售后订单", + // "group": "订单中心" + // } + // }, + // { + // "path": "aftersale/detail", + // "style": { + // "navigationBarTitleText": "售后详情" + // }, + // "meta": { + // "auth": true, + // "title": "售后详情" + // } + // }, + // { + // "path": "aftersale/log", + // "style": { + // "navigationBarTitleText": "售后进度" + // }, + // "meta": { + // "auth": true, + // "title": "售后进度" + // } + // }, + // { + // "path": "express/log", + // "style": { + // "navigationBarTitleText": "物流轨迹" + // }, + // "meta": { + // "auth": true, + // "title": "物流轨迹" + // } + // } + // ] + // }, + // { + // "root": "pages/user", + // "pages": [ + // { + // "path": "info", + // "style": { + // "navigationBarTitleText": "我的信息" + // }, + // "meta": { + // "auth": true, + // "sync": true, + // "title": "用户信息", + // "group": "用户中心" + // } + // }, + // { + // "path": "goods-collect", + // "style": { + // "navigationBarTitleText": "我的收藏" + // }, + // "meta": { + // "auth": true, + // "sync": true, + // "title": "商品收藏", + // "group": "用户中心" + // } + // }, + // { + // "path": "goods-log", + // "style": { + // "navigationBarTitleText": "我的足迹" + // }, + // "meta": { + // "auth": true, + // "sync": true, + // "title": "浏览记录", + // "group": "用户中心" + // } + // }, + // { + // "path": "address/list", + // "style": { + // "navigationBarTitleText": "收货地址" + // }, + // "meta": { + // "auth": true, + // "sync": true, + // "title": "地址管理", + // "group": "用户中心" + // } + // }, + // { + // "path": "address/edit", + // "style": { + // "navigationBarTitleText": "编辑地址" + // }, + // "meta": { + // "auth": true, + // "title": "编辑地址" + // } + // }, + // { + // "path": "goods_details_store/index", + // "style": { + // "navigationBarTitleText": "自提门店" + // }, + // "meta": { + // "auth": true, + // "sync": true, + // "title": "地址管理", + // "group": "用户中心" + // } + // }, + // { + // "path": "wallet/money", + // "style": { + // "navigationBarTitleText": "我的余额" + // }, + // "meta": { + // "auth": true, + // "sync": true, + // "title": "用户余额", + // "group": "用户中心" + // } + // }, + // { + // "path": "wallet/score", + // "style": { + // "navigationBarTitleText": "我的积分" + // }, + // "meta": { + // "auth": true, + // "sync": true, + // "title": "用户积分", + // "group": "用户中心" + // } + // } + // ] + // }, + // { + // "root": "pages/commission", + // "pages": [ + // { + // "path": "index", + // "style": { + // "navigationBarTitleText": "分销" + // }, + // "meta": { + // "auth": true, + // "sync": true, + // "title": "分销中心", + // "group": "分销商城" + // } + // }, + // { + // "path": "wallet", + // "style": { + // "navigationBarTitleText": "我的佣金" + // }, + // "meta": { + // "auth": true, + // "sync": true, + // "title": "用户佣金", + // "group": "分销中心" + // } + // }, + // { + // "path": "goods", + // "style": { + // "navigationBarTitleText": "推广商品" + // }, + // "meta": { + // "auth": true, + // "sync": true, + // "title": "推广商品", + // "group": "分销商城" + // } + // }, + // { + // "path": "order", + // "style": { + // "navigationBarTitleText": "分销订单" + // }, + // "meta": { + // "auth": true, + // "sync": true, + // "title": "分销订单", + // "group": "分销商城" + // } + // }, + // { + // "path": "team", + // "style": { + // "navigationBarTitleText": "我的团队" + // }, + // "meta": { + // "auth": true, + // "sync": true, + // "title": "我的团队", + // "group": "分销商城" + // } + // }, + // { + // "path": "promoter", + // "style": { + // "navigationBarTitleText": "推广人排行榜" + // }, + // "meta": { + // "auth": true, + // "sync": true, + // "title": "推广人排行榜", + // "group": "分销商城" + // } + // }, + // { + // "path": "commission-ranking", + // "style": { + // "navigationBarTitleText": "佣金排行榜" + // }, + // "meta": { + // "auth": true, + // "sync": true, + // "title": "佣金排行榜", + // "group": "分销商城" + // } + // }, + // { + // "path": "withdraw", + // "style": { + // "navigationBarTitleText": "申请提现" + // }, + // "meta": { + // "auth": true, + // "sync": true, + // "title": "申请提现", + // "group": "分销商城" + // } + // } + // ] + // }, + // { + // "root": "pages/app", + // "pages": [ + // { + // "path": "sign", + // "style": { + // "navigationBarTitleText": "签到中心" + // }, + // "meta": { + // "auth": true, + // "sync": true, + // "title": "签到中心", + // "group": "应用" + // } + // } + // ] + // }, + // { + // "root": "pages/public", + // "pages": [ + // { + // "path": "setting", + // "style": { + // "navigationBarTitleText": "系统设置" + // }, + // "meta": { + // "sync": true, + // "title": "系统设置", + // "group": "通用" + // } + // }, + // { + // "path": "richtext", + // "style": { + // "navigationBarTitleText": "富文本" + // }, + // "meta": { + // "sync": true, + // "title": "富文本", + // "group": "通用" + // } + // }, + // { + // "path": "faq", + // "style": { + // "navigationBarTitleText": "常见问题" + // }, + // "meta": { + // "sync": true, + // "title": "常见问题", + // "group": "通用" + // } + // }, + // { + // "path": "error", + // "style": { + // "navigationBarTitleText": "错误页面" + // } + // }, + // { + // "path": "webview", + // "style": { + // "navigationBarTitleText": "" + // } + // } + // ] + // }, + // { + // "root": "pages/coupon", + // "pages": [ + // { + // "path": "list", + // "style": { + // "navigationBarTitleText": "领券中心" + // }, + // "meta": { + // "sync": true, + // "title": "领券中心", + // "group": "优惠券" + // } + // }, + // { + // "path": "detail", + // "style": { + // "navigationBarTitleText": "优惠券" + // }, + // "meta": { + // "auth": false, + // "sync": true, + // "title": "优惠券详情", + // "group": "优惠券" + // } + // } + // ] + // }, + // { + // "root": "pages/chat", + // "pages": [ + // { + // "path": "index", + // "style": { + // "navigationBarTitleText": "客服", + // "app-plus": { + // "softinputMode": "adjustResize" + // } + // }, + // "meta": { + // "auth": true, + // "sync": true, + // "title": "客服", + // "group": "客服" + // } + // } + // ] + // }, + // { + // "root": "pages/pay", + // "pages": [ + // { + // "path": "index", + // "style": { + // "navigationBarTitleText": "收银台" + // } + // }, + // { + // "path": "result", + // "style": { + // "navigationBarTitleText": "支付结果" + // } + // }, + // { + // "path": "recharge", + // "style": { + // "navigationBarTitleText": "充值余额" + // }, + // "meta": { + // "auth": true, + // "sync": true, + // "title": "充值余额", + // "group": "支付" + // } + // }, + // { + // "path": "recharge-log", + // "style": { + // "navigationBarTitleText": "充值记录" + // }, + // "meta": { + // "auth": true, + // "sync": true, + // "title": "充值记录", + // "group": "支付" + // } + // } + // ] + // }, + // { + // "root": "pages/activity", + // "pages": [ + // { + // "path": "groupon/detail", + // "style": { + // "navigationBarTitleText": "拼团详情" + // } + // }, + // { + // "path": "groupon/order", + // "style": { + // "navigationBarTitleText": "我的拼团", + // "enablePullDownRefresh": true + // }, + // "meta": { + // "auth": true, + // "sync": true, + // "title": "拼团订单", + // "group": "营销活动" + // } + // }, + // { + // "path": "index", + // "style": { + // "navigationBarTitleText": "营销商品" + // }, + // "meta": { + // "sync": true, + // "title": "营销商品", + // "group": "营销活动" + // } + // }, + // { + // "path": "groupon/list", + // "style": { + // "navigationBarTitleText": "拼团活动" + // }, + // "meta": { + // "sync": true, + // "title": "拼团活动", + // "group": "营销活动" + // } + // }, + // { + // "path": "seckill/list", + // "style": { + // "navigationBarTitleText": "秒杀活动" + // }, + // "meta": { + // "sync": true, + // "title": "秒杀活动", + // "group": "营销活动" + // } + // }, + // { + // "path": "point/list", + // "style": { + // "navigationBarTitleText": "积分商城" + // }, + // "meta": { + // "sync": true, + // "title": "积分商城", + // "group": "营销活动" + // } + // } + // ] + // } ], "globalStyle": { "navigationBarTextStyle": "black", "navigationBarTitleText": "交友聊天", "navigationBarBackgroundColor": "#F8F8F8", - "backgroundColor": "#F8F8F8" + "backgroundColor": "#F8F8F8", + "navigationStyle": "custom" }, "tabBar": { "color": "#fff", diff --git a/src/pages/activity/groupon/detail.vue b/src/pages/activity/groupon/detail.vue new file mode 100644 index 00000000..f9ef7816 --- /dev/null +++ b/src/pages/activity/groupon/detail.vue @@ -0,0 +1,539 @@ + + + + + + diff --git a/src/pages/activity/groupon/list.vue b/src/pages/activity/groupon/list.vue new file mode 100644 index 00000000..0cd8bc97 --- /dev/null +++ b/src/pages/activity/groupon/list.vue @@ -0,0 +1,225 @@ + + + + diff --git a/src/pages/activity/groupon/order.vue b/src/pages/activity/groupon/order.vue new file mode 100644 index 00000000..a93cc6e0 --- /dev/null +++ b/src/pages/activity/groupon/order.vue @@ -0,0 +1,240 @@ + + + + + + diff --git a/src/pages/activity/index.vue b/src/pages/activity/index.vue new file mode 100644 index 00000000..95739155 --- /dev/null +++ b/src/pages/activity/index.vue @@ -0,0 +1,214 @@ + + + + diff --git a/src/pages/activity/point/list.vue b/src/pages/activity/point/list.vue new file mode 100644 index 00000000..7630fd21 --- /dev/null +++ b/src/pages/activity/point/list.vue @@ -0,0 +1,76 @@ + + + diff --git a/src/pages/activity/seckill/list.vue b/src/pages/activity/seckill/list.vue new file mode 100644 index 00000000..16eca3b8 --- /dev/null +++ b/src/pages/activity/seckill/list.vue @@ -0,0 +1,460 @@ + + + + diff --git a/src/pages/app/sign.vue b/src/pages/app/sign.vue new file mode 100644 index 00000000..e0263741 --- /dev/null +++ b/src/pages/app/sign.vue @@ -0,0 +1,452 @@ + + + + + + diff --git a/src/pages/chat/components/goods.vue b/src/pages/chat/components/goods.vue new file mode 100644 index 00000000..eabdd218 --- /dev/null +++ b/src/pages/chat/components/goods.vue @@ -0,0 +1,21 @@ + + + + diff --git a/src/pages/chat/components/messageInput.vue b/src/pages/chat/components/messageInput.vue new file mode 100644 index 00000000..1c7be68d --- /dev/null +++ b/src/pages/chat/components/messageInput.vue @@ -0,0 +1,110 @@ + + + + + diff --git a/src/pages/chat/components/messageList.vue b/src/pages/chat/components/messageList.vue new file mode 100644 index 00000000..e021e029 --- /dev/null +++ b/src/pages/chat/components/messageList.vue @@ -0,0 +1,293 @@ + + + + + diff --git a/src/pages/chat/components/messageListItem.vue b/src/pages/chat/components/messageListItem.vue new file mode 100644 index 00000000..b91472c8 --- /dev/null +++ b/src/pages/chat/components/messageListItem.vue @@ -0,0 +1,297 @@ + + + + + diff --git a/src/pages/chat/components/optimize-input.vue b/src/pages/chat/components/optimize-input.vue new file mode 100644 index 00000000..73f3ceb5 --- /dev/null +++ b/src/pages/chat/components/optimize-input.vue @@ -0,0 +1,540 @@ + + + + + diff --git a/src/pages/chat/components/order.vue b/src/pages/chat/components/order.vue new file mode 100644 index 00000000..15f27208 --- /dev/null +++ b/src/pages/chat/components/order.vue @@ -0,0 +1,114 @@ + + + + + diff --git a/src/pages/chat/components/select-popup.vue b/src/pages/chat/components/select-popup.vue new file mode 100644 index 00000000..60711af2 --- /dev/null +++ b/src/pages/chat/components/select-popup.vue @@ -0,0 +1,151 @@ + + + + + diff --git a/src/pages/chat/components/toolsPopup.vue b/src/pages/chat/components/toolsPopup.vue new file mode 100644 index 00000000..f47ce3fc --- /dev/null +++ b/src/pages/chat/components/toolsPopup.vue @@ -0,0 +1,166 @@ + + + + + diff --git a/src/pages/chat/index.vue b/src/pages/chat/index.vue new file mode 100644 index 00000000..2c7d8172 --- /dev/null +++ b/src/pages/chat/index.vue @@ -0,0 +1,222 @@ + + + + + diff --git a/src/pages/chat/util/constants.js b/src/pages/chat/util/constants.js new file mode 100644 index 00000000..1b8eba97 --- /dev/null +++ b/src/pages/chat/util/constants.js @@ -0,0 +1,19 @@ +export const KeFuMessageContentTypeEnum = { + TEXT: 1, // 文本消息 + IMAGE: 2, // 图片消息 + VOICE: 3, // 语音消息 + VIDEO: 4, // 视频消息 + SYSTEM: 5, // 系统消息 + // ========== 商城特殊消息 ========== + PRODUCT: 10,// 商品消息 + ORDER: 11,// 订单消息" +}; +export const UserTypeEnum = { + MEMBER: 1, // 会员 面向 c 端,普通用户 + ADMIN: 2, // 管理员 面向 b 端,管理后台 +}; +// Promotion 的 WebSocket 消息类型枚举类 +export const WebSocketMessageTypeConstants = { + KEFU_MESSAGE_TYPE: 'kefu_message_type', // 客服消息类型 + KEFU_MESSAGE_ADMIN_READ: 'kefu_message_read_status_change' // 客服消息管理员已读 +} diff --git a/src/pages/chat/util/emoji.js b/src/pages/chat/util/emoji.js new file mode 100644 index 00000000..83e6e842 --- /dev/null +++ b/src/pages/chat/util/emoji.js @@ -0,0 +1,58 @@ +export const emojiList = [ + { name: '[笑掉牙]', file: 'xiaodiaoya.png' }, + { name: '[可爱]', file: 'keai.png' }, + { name: '[冷酷]', file: 'lengku.png' }, + { name: '[闭嘴]', file: 'bizui.png' }, + { name: '[生气]', file: 'shengqi.png' }, + { name: '[惊恐]', file: 'jingkong.png' }, + { name: '[瞌睡]', file: 'keshui.png' }, + { name: '[大笑]', file: 'daxiao.png' }, + { name: '[爱心]', file: 'aixin.png' }, + { name: '[坏笑]', file: 'huaixiao.png' }, + { name: '[飞吻]', file: 'feiwen.png' }, + { name: '[疑问]', file: 'yiwen.png' }, + { name: '[开心]', file: 'kaixin.png' }, + { name: '[发呆]', file: 'fadai.png' }, + { name: '[流泪]', file: 'liulei.png' }, + { name: '[汗颜]', file: 'hanyan.png' }, + { name: '[惊悚]', file: 'jingshu.png' }, + { name: '[困~]', file: 'kun.png' }, + { name: '[心碎]', file: 'xinsui.png' }, + { name: '[天使]', file: 'tianshi.png' }, + { name: '[晕]', file: 'yun.png' }, + { name: '[啊]', file: 'a.png' }, + { name: '[愤怒]', file: 'fennu.png' }, + { name: '[睡着]', file: 'shuizhuo.png' }, + { name: '[面无表情]', file: 'mianwubiaoqing.png' }, + { name: '[难过]', file: 'nanguo.png' }, + { name: '[犯困]', file: 'fankun.png' }, + { name: '[好吃]', file: 'haochi.png' }, + { name: '[呕吐]', file: 'outu.png' }, + { name: '[龇牙]', file: 'ziya.png' }, + { name: '[懵比]', file: 'mengbi.png' }, + { name: '[白眼]', file: 'baiyan.png' }, + { name: '[饿死]', file: 'esi.png' }, + { name: '[凶]', file: 'xiong.png' }, + { name: '[感冒]', file: 'ganmao.png' }, + { name: '[流汗]', file: 'liuhan.png' }, + { name: '[笑哭]', file: 'xiaoku.png' }, + { name: '[流口水]', file: 'liukoushui.png' }, + { name: '[尴尬]', file: 'ganga.png' }, + { name: '[惊讶]', file: 'jingya.png' }, + { name: '[大惊]', file: 'dajing.png' }, + { name: '[不好意思]', file: 'buhaoyisi.png' }, + { name: '[大闹]', file: 'danao.png' }, + { name: '[不可思议]', file: 'bukesiyi.png' }, + { name: '[爱你]', file: 'aini.png' }, + { name: '[红心]', file: 'hongxin.png' }, + { name: '[点赞]', file: 'dianzan.png' }, + { name: '[恶魔]', file: 'emo.png' }, +]; + +export let emojiPage = {}; +emojiList.forEach((item, index) => { + if (!emojiPage[Math.floor(index / 30) + 1]) { + emojiPage[Math.floor(index / 30) + 1] = []; + } + emojiPage[Math.floor(index / 30) + 1].push(item); +}); diff --git a/src/pages/chat/util/useWebSocket.js b/src/pages/chat/util/useWebSocket.js new file mode 100644 index 00000000..4b592764 --- /dev/null +++ b/src/pages/chat/util/useWebSocket.js @@ -0,0 +1,150 @@ +import { onBeforeUnmount, reactive, ref } from 'vue'; +import { baseUrl, websocketPath } from '@/sheep/config'; +import { copyValueToTarget } from '@/sheep/helper/utils'; +import { getRefreshToken } from '@/sheep/request'; + +/** + * WebSocket 创建 hook + * @param opt 连接配置 + * @return {{options: *}} + */ +export function useWebSocket(opt) { + const options = reactive({ + url: (baseUrl + websocketPath).replace('http', 'ws') + '?token=' + getRefreshToken(), // ws 地址 + isReconnecting: false, // 正在重新连接 + reconnectInterval: 3000, // 重连间隔,单位毫秒 + heartBeatInterval: 5000, // 心跳间隔,单位毫秒 + pingTimeoutDuration: 1000, // 超过这个时间,后端没有返回pong,则判定后端断线了。 + heartBeatTimer: null, // 心跳计时器 + destroy: false, // 是否销毁 + pingTimeout: null, // 心跳检测定时器 + reconnectTimeout: null, // 重连定时器ID的属性 + onConnected: () => {}, // 连接成功时触发 + onClosed: () => {}, // 连接关闭时触发 + onMessage: (data) => {}, // 收到消息 + }); + const SocketTask = ref(null); // SocketTask 由 uni.connectSocket() 接口创建 + + const initEventListeners = () => { + // 监听 WebSocket 连接打开事件 + SocketTask.value.onOpen(() => { + console.log('WebSocket 连接成功'); + // 连接成功时触发 + options.onConnected(); + // 开启心跳检查 + startHeartBeat(); + }); + // 监听 WebSocket 接受到服务器的消息事件 + SocketTask.value.onMessage((res) => { + try { + if (res.data === 'pong') { + // 收到心跳重置心跳超时检查 + resetPingTimeout(); + } else { + options.onMessage(JSON.parse(res.data)); + } + } catch (error) { + console.error(error); + } + }); + // 监听 WebSocket 连接关闭事件 + SocketTask.value.onClose((event) => { + // 情况一:实例销毁 + if (options.destroy) { + options.onClosed(); + } else { + // 情况二:连接失败重连 + // 停止心跳检查 + stopHeartBeat(); + // 重连 + reconnect(); + } + }); + }; + + // 发送消息 + const sendMessage = (message) => { + if (SocketTask.value && !options.destroy) { + SocketTask.value.send({ data: message }); + } + }; + // 开始心跳检查 + const startHeartBeat = () => { + options.heartBeatTimer = setInterval(() => { + sendMessage('ping'); + options.pingTimeout = setTimeout(() => { + // 如果在超时时间内没有收到 pong,则认为连接断开 + reconnect(); + }, options.pingTimeoutDuration); + }, options.heartBeatInterval); + }; + // 停止心跳检查 + const stopHeartBeat = () => { + clearInterval(options.heartBeatTimer); + resetPingTimeout(); + }; + + // WebSocket 重连 + const reconnect = () => { + if (options.destroy || !SocketTask.value) { + // 如果WebSocket已被销毁或尚未完全关闭,不进行重连 + return; + } + + // 重连中 + options.isReconnecting = true; + + // 清除现有的重连标志,以避免多次重连 + if (options.reconnectTimeout) { + clearTimeout(options.reconnectTimeout); + } + + // 设置重连延迟 + options.reconnectTimeout = setTimeout(() => { + // 检查组件是否仍在运行和WebSocket是否关闭 + if (!options.destroy) { + // 重置重连标志 + options.isReconnecting = false; + // 初始化新的WebSocket连接 + initSocket(); + } + }, options.reconnectInterval); + }; + + const resetPingTimeout = () => { + if (options.pingTimeout) { + clearTimeout(options.pingTimeout); + options.pingTimeout = null; // 清除超时ID + } + }; + + const close = () => { + options.destroy = true; + stopHeartBeat(); + if (options.reconnectTimeout) { + clearTimeout(options.reconnectTimeout); + } + if (SocketTask.value) { + SocketTask.value.close(); + SocketTask.value = null; + } + }; + + const initSocket = () => { + options.destroy = false; + copyValueToTarget(options, opt); + SocketTask.value = uni.connectSocket({ + url: options.url, + complete: () => {}, + success: () => {}, + }); + initEventListeners(); + }; + + initSocket(); + + onBeforeUnmount(() => { + close(); + }); + return { options }; +} diff --git a/src/pages/commission/commission-ranking.vue b/src/pages/commission/commission-ranking.vue new file mode 100644 index 00000000..50fc76fe --- /dev/null +++ b/src/pages/commission/commission-ranking.vue @@ -0,0 +1,239 @@ + + + + + diff --git a/src/pages/commission/components/account-info.vue b/src/pages/commission/components/account-info.vue new file mode 100644 index 00000000..d904b8df --- /dev/null +++ b/src/pages/commission/components/account-info.vue @@ -0,0 +1,125 @@ + + + + + + \ No newline at end of file diff --git a/src/pages/commission/components/account-type-select.vue b/src/pages/commission/components/account-type-select.vue new file mode 100644 index 00000000..c39c7a72 --- /dev/null +++ b/src/pages/commission/components/account-type-select.vue @@ -0,0 +1,171 @@ + + + + + + diff --git a/src/pages/commission/components/commission-auth.vue b/src/pages/commission/components/commission-auth.vue new file mode 100644 index 00000000..9a484fad --- /dev/null +++ b/src/pages/commission/components/commission-auth.vue @@ -0,0 +1,101 @@ + + + + + + diff --git a/src/pages/commission/components/commission-info.vue b/src/pages/commission/components/commission-info.vue new file mode 100644 index 00000000..79f7cd86 --- /dev/null +++ b/src/pages/commission/components/commission-info.vue @@ -0,0 +1,114 @@ + + + + + + diff --git a/src/pages/commission/components/commission-log.vue b/src/pages/commission/components/commission-log.vue new file mode 100644 index 00000000..cee3b3cb --- /dev/null +++ b/src/pages/commission/components/commission-log.vue @@ -0,0 +1,181 @@ + + + + + + diff --git a/src/pages/commission/components/commission-menu.vue b/src/pages/commission/components/commission-menu.vue new file mode 100644 index 00000000..42498f5e --- /dev/null +++ b/src/pages/commission/components/commission-menu.vue @@ -0,0 +1,145 @@ + + + + + + diff --git a/src/pages/commission/goods.vue b/src/pages/commission/goods.vue new file mode 100644 index 00000000..f4638f7f --- /dev/null +++ b/src/pages/commission/goods.vue @@ -0,0 +1,165 @@ + + + + + + diff --git a/src/pages/commission/index.vue b/src/pages/commission/index.vue new file mode 100644 index 00000000..28c077cc --- /dev/null +++ b/src/pages/commission/index.vue @@ -0,0 +1,57 @@ + + + + + + diff --git a/src/pages/commission/order.vue b/src/pages/commission/order.vue new file mode 100644 index 00000000..94be9b7f --- /dev/null +++ b/src/pages/commission/order.vue @@ -0,0 +1,332 @@ + + + + + + diff --git a/src/pages/commission/promoter.vue b/src/pages/commission/promoter.vue new file mode 100644 index 00000000..2dfcc2b3 --- /dev/null +++ b/src/pages/commission/promoter.vue @@ -0,0 +1,288 @@ + + + + + diff --git a/src/pages/commission/team.vue b/src/pages/commission/team.vue new file mode 100644 index 00000000..ba86814d --- /dev/null +++ b/src/pages/commission/team.vue @@ -0,0 +1,604 @@ + + + + + + diff --git a/src/pages/commission/wallet.vue b/src/pages/commission/wallet.vue new file mode 100644 index 00000000..73024dbc --- /dev/null +++ b/src/pages/commission/wallet.vue @@ -0,0 +1,643 @@ + + + + + + diff --git a/src/pages/commission/withdraw.vue b/src/pages/commission/withdraw.vue new file mode 100644 index 00000000..fb661866 --- /dev/null +++ b/src/pages/commission/withdraw.vue @@ -0,0 +1,486 @@ + + + + + + diff --git a/src/pages/components/HighlightNumberText.vue b/src/pages/components/HighlightNumberText.vue new file mode 100644 index 00000000..0b00f352 --- /dev/null +++ b/src/pages/components/HighlightNumberText.vue @@ -0,0 +1,81 @@ + + + + + diff --git a/src/pages/coupon/detail.vue b/src/pages/coupon/detail.vue new file mode 100644 index 00000000..96114a3e --- /dev/null +++ b/src/pages/coupon/detail.vue @@ -0,0 +1,390 @@ + + + + + + diff --git a/src/pages/coupon/list.vue b/src/pages/coupon/list.vue new file mode 100644 index 00000000..2afffd75 --- /dev/null +++ b/src/pages/coupon/list.vue @@ -0,0 +1,222 @@ + + + + + diff --git a/src/pages/goods/comment/add.vue b/src/pages/goods/comment/add.vue new file mode 100644 index 00000000..c52024c0 --- /dev/null +++ b/src/pages/goods/comment/add.vue @@ -0,0 +1,190 @@ + + + + + + diff --git a/src/pages/goods/comment/list.vue b/src/pages/goods/comment/list.vue new file mode 100644 index 00000000..ed55988b --- /dev/null +++ b/src/pages/goods/comment/list.vue @@ -0,0 +1,168 @@ + + + + + + diff --git a/src/pages/goods/components/detail/comment-item.vue b/src/pages/goods/components/detail/comment-item.vue new file mode 100644 index 00000000..518db2a8 --- /dev/null +++ b/src/pages/goods/components/detail/comment-item.vue @@ -0,0 +1,94 @@ + + + + + + diff --git a/src/pages/goods/components/detail/detail-activity-tip.vue b/src/pages/goods/components/detail/detail-activity-tip.vue new file mode 100644 index 00000000..e80fe392 --- /dev/null +++ b/src/pages/goods/components/detail/detail-activity-tip.vue @@ -0,0 +1,99 @@ + + + + + diff --git a/src/pages/goods/components/detail/detail-cell-sku.vue b/src/pages/goods/components/detail/detail-cell-sku.vue new file mode 100644 index 00000000..11f1b204 --- /dev/null +++ b/src/pages/goods/components/detail/detail-cell-sku.vue @@ -0,0 +1,31 @@ + + + diff --git a/src/pages/goods/components/detail/detail-cell.vue b/src/pages/goods/components/detail/detail-cell.vue new file mode 100644 index 00000000..b4c56dd5 --- /dev/null +++ b/src/pages/goods/components/detail/detail-cell.vue @@ -0,0 +1,60 @@ + + + + + + diff --git a/src/pages/goods/components/detail/detail-comment-card.vue b/src/pages/goods/components/detail/detail-comment-card.vue new file mode 100644 index 00000000..cc48dfde --- /dev/null +++ b/src/pages/goods/components/detail/detail-comment-card.vue @@ -0,0 +1,106 @@ + + + + + + diff --git a/src/pages/goods/components/detail/detail-content-card.vue b/src/pages/goods/components/detail/detail-content-card.vue new file mode 100644 index 00000000..38d45f98 --- /dev/null +++ b/src/pages/goods/components/detail/detail-content-card.vue @@ -0,0 +1,54 @@ + + + + + diff --git a/src/pages/goods/components/detail/detail-navbar.vue b/src/pages/goods/components/detail/detail-navbar.vue new file mode 100644 index 00000000..d454ec0f --- /dev/null +++ b/src/pages/goods/components/detail/detail-navbar.vue @@ -0,0 +1,257 @@ + + + + + + diff --git a/src/pages/goods/components/detail/detail-progress.vue b/src/pages/goods/components/detail/detail-progress.vue new file mode 100644 index 00000000..a6210b16 --- /dev/null +++ b/src/pages/goods/components/detail/detail-progress.vue @@ -0,0 +1,40 @@ + + + + + + diff --git a/src/pages/goods/components/detail/detail-skeleton.vue b/src/pages/goods/components/detail/detail-skeleton.vue new file mode 100644 index 00000000..5eebf50c --- /dev/null +++ b/src/pages/goods/components/detail/detail-skeleton.vue @@ -0,0 +1,177 @@ + + + + + diff --git a/src/pages/goods/components/detail/detail-tabbar.vue b/src/pages/goods/components/detail/detail-tabbar.vue new file mode 100644 index 00000000..bcae5bef --- /dev/null +++ b/src/pages/goods/components/detail/detail-tabbar.vue @@ -0,0 +1,169 @@ + + + + + + diff --git a/src/pages/goods/components/groupon/groupon-card-list.vue b/src/pages/goods/components/groupon/groupon-card-list.vue new file mode 100644 index 00000000..2c752140 --- /dev/null +++ b/src/pages/goods/components/groupon/groupon-card-list.vue @@ -0,0 +1,140 @@ + + + + + + diff --git a/src/pages/goods/components/list/list-goods-card.vue b/src/pages/goods/components/list/list-goods-card.vue new file mode 100644 index 00000000..d02519ff --- /dev/null +++ b/src/pages/goods/components/list/list-goods-card.vue @@ -0,0 +1,103 @@ + + + + + + diff --git a/src/pages/goods/components/list/list-navbar.vue b/src/pages/goods/components/list/list-navbar.vue new file mode 100644 index 00000000..c21e6793 --- /dev/null +++ b/src/pages/goods/components/list/list-navbar.vue @@ -0,0 +1,93 @@ + + + + + + diff --git a/src/pages/goods/groupon.vue b/src/pages/goods/groupon.vue new file mode 100644 index 00000000..0fc81cfd --- /dev/null +++ b/src/pages/goods/groupon.vue @@ -0,0 +1,562 @@ + + + + + + diff --git a/src/pages/goods/index.vue b/src/pages/goods/index.vue new file mode 100644 index 00000000..901c8919 --- /dev/null +++ b/src/pages/goods/index.vue @@ -0,0 +1,672 @@ + + + + + diff --git a/src/pages/goods/list.vue b/src/pages/goods/list.vue new file mode 100644 index 00000000..8a5259a2 --- /dev/null +++ b/src/pages/goods/list.vue @@ -0,0 +1,407 @@ + + + + + diff --git a/src/pages/goods/point.vue b/src/pages/goods/point.vue new file mode 100644 index 00000000..631d9404 --- /dev/null +++ b/src/pages/goods/point.vue @@ -0,0 +1,483 @@ + + + + + + diff --git a/src/pages/goods/seckill.vue b/src/pages/goods/seckill.vue new file mode 100644 index 00000000..c76e9487 --- /dev/null +++ b/src/pages/goods/seckill.vue @@ -0,0 +1,575 @@ + + + + + + diff --git a/src/pages/home/city.vue b/src/pages/home/city.vue index 5588890b..dd2ca882 100644 --- a/src/pages/home/city.vue +++ b/src/pages/home/city.vue @@ -1,15 +1,11 @@