From 6590a3514becafeac934b788b4797501c8762679 Mon Sep 17 00:00:00 2001
From: YeMingfei666 <1619116647@qq.com>
Date: Thu, 4 Dec 2025 17:17:59 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E4=BF=AE=E5=A4=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pageChat/chat.vue | 4 ++
pageChat/components/chat-item.vue | 109 +++++++++++++++++++++++------
pageChat/coupon-activity/index.vue | 3 +-
3 files changed, 95 insertions(+), 21 deletions(-)
diff --git a/pageChat/chat.vue b/pageChat/chat.vue
index 77ec76f..b7f0bd7 100644
--- a/pageChat/chat.vue
+++ b/pageChat/chat.vue
@@ -50,6 +50,10 @@
>
+
+ {{item.hasGet||0}}人已领取
+ 优惠券
+
{{ item.coupon.title }}
-
-
+
+
+
¥
- 15
+ {{
+ item.coupon.discountAmount
+ }}
+
+ 满{{ item.coupon.fullAmount }}可用
- 满{{item.coupon.fullAmount}}可用
-
+
+
+
+
+ 商品兑换券
+
+ 满{{ item.coupon.fullAmount }}可用
+
+
+
+
+
+
+ {{ item.coupon.discountRate / 100 }}折
+
+ 满{{ item.coupon.fullAmount }}可用
+
+
+
+
+
+ 第二件半价券
+
+
+
+
+
+
+
+ 买一送一券
+
+
+
+
{{item.coupon.couponName}}
有效期:{{ returnTime(item.coupon) }}
@@ -34,6 +85,7 @@
+
diff --git a/pageChat/coupon-activity/index.vue b/pageChat/coupon-activity/index.vue
index 3043a56..7e4df64 100644
--- a/pageChat/coupon-activity/index.vue
+++ b/pageChat/coupon-activity/index.vue
@@ -163,8 +163,9 @@ function sendMsg(msg) {
});
}
function toShare(item) {
+ const hasGet=item.couponJson.giveNum-item.couponJson.leftNum
sendMsg({
- coupon: { ...item.couponJson, title: item.title,activity_id:item.id },
+ coupon: { ...item.couponJson, title: item.title,activity_id:item.id, hasGet:hasGet<=0?0:hasGet} ,
chat_coupon_id:item.id,
msg_type: 4,
});
From 885ef57c9333f357553c781ac8b3406208d95485 Mon Sep 17 00:00:00 2001
From: YeMingfei666 <1619116647@qq.com>
Date: Fri, 5 Dec 2025 09:37:30 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E8=81=8A=E5=A4=A9=E5=8A=9F=E8=83=BD?=
=?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=8C=E9=83=A8=E5=88=86=E9=97=AE=E9=A2=98?=
=?UTF-8?q?=E4=BF=AE=E5=A4=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pageChat/chat.vue | 159 +++++++++----
pageChat/components/chat-item.vue | 14 +-
pageChat/group-info/index.vue | 32 ++-
pageChat/index.vue | 208 +++++++++++++----
pageMarket/superVip/components/config.vue | 18 ++
pageMarket/superVip/vip-lv-add.vue | 13 +-
pagesOrder/detail/components/list.vue | 7 +
store/chat.js | 260 ++++++++++++++++++----
store/market.js | 2 +-
9 files changed, 554 insertions(+), 159 deletions(-)
diff --git a/pageChat/chat.vue b/pageChat/chat.vue
index b7f0bd7..586cd8b 100644
--- a/pageChat/chat.vue
+++ b/pageChat/chat.vue
@@ -59,6 +59,7 @@
size="122rpx"
shape="square"
bg-color="#fff"
+ :src="shopInfo.logo"
>
@@ -234,9 +235,7 @@ const modalData = reactive({
couponId: "",
},
});
-const websocketUtil = inject("websocketUtil");
-websocketUtil.closeSocket();
-websocketUtil.offMessage();
+
const chatStore = useChatStore();
chatStore.onReceiveMsg = (msg) => {
@@ -282,56 +281,122 @@ function moreBtnsClick(item, index) {
function videoErrorCallback(e) {
console.error("视频播放失败", e);
}
-function sendImg() {
- uni.chooseImage({
- count: 3, //默认9
- sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
- sourceType: ["album", "camera "],
- success: async function (res) {
- uni.showLoading({
- title: "发送中",
+// 图片选择与发送优化
+async function sendImg() {
+ try {
+ // 1. 调用图片选择API,添加fail回调
+ const res = await new Promise((resolve, reject) => {
+ uni.chooseImage({
+ count: 3,
+ sizeType: ["original", "compressed"],
+ sourceType: ["album", "camera"],
+ success: resolve,
+ fail: reject // 捕获选择失败(含权限拒绝)
});
- console.log(res);
- for (let i = 0; i < res.tempFiles.length; i++) {
- const fileRes = await uploadFile(res.tempFiles[i]);
- if (fileRes) {
- sendMsg({
- image_url: fileRes,
- msg_type: 2,
- });
- } else {
- }
- }
- uni.hideLoading();
- },
- });
-}
+ });
-function sendVideo() {
- uni.chooseVideo({
- count: 1, //默认9
- sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
- sourceType: ["album", "camera "],
- success: async function (res) {
- uni.showLoading({
- title: "发送中",
- });
- console.log(res);
- const fileRes = await uploadFile({ path: res.tempFilePath });
- uni.hideLoading();
+ uni.showLoading({ title: "发送中" });
+ console.log("选择图片成功", res);
+
+ // 2. 批量上传图片(保持原有逻辑)
+ for (let i = 0; i < res.tempFiles.length; i++) {
+ const fileRes = await uploadFile(res.tempFiles[i]);
if (fileRes) {
sendMsg({
image_url: fileRes,
- msg_type: 5,
- });
- } else {
- uni.showToast({
- title: "发送失败",
- icon: "none",
+ msg_type: 2,
});
}
- },
- });
+ }
+ } catch (err) {
+ console.error("图片选择/发送失败", err);
+ // 3. 处理权限拒绝场景
+ handlePermissionError(err, "图片");
+ } finally {
+ // 4. 确保加载弹窗关闭(无论成功/失败)
+ uni.hideLoading();
+ }
+}
+
+// 视频选择与发送优化
+async function sendVideo() {
+ try {
+ // 1. 调用视频选择API,添加fail回调
+ const res = await new Promise((resolve, reject) => {
+ uni.chooseVideo({
+ count: 1,
+ sizeType: ["original", "compressed"],
+ sourceType: ["album", "camera"],
+ success: resolve,
+ fail: reject // 捕获选择失败(含权限拒绝)
+ });
+ });
+
+ uni.showLoading({ title: "发送中" });
+ console.log("选择视频成功", res);
+
+ // 2. 上传视频(保持原有逻辑)
+ const fileRes = await uploadFile({ path: res.tempFilePath });
+ if (fileRes) {
+ sendMsg({
+ image_url: fileRes,
+ msg_type: 5,
+ });
+ } else {
+ uni.showToast({
+ title: "视频发送失败",
+ icon: "none",
+ });
+ }
+ } catch (err) {
+ console.error("视频选择/发送失败", err);
+ // 3. 处理权限拒绝场景
+ handlePermissionError(err, "视频");
+ } finally {
+ // 4. 确保加载弹窗关闭(无论成功/失败)
+ uni.hideLoading();
+ }
+}
+
+// 通用权限错误处理函数
+function handlePermissionError(err, mediaType) {
+ const errMsg = err.errMsg || "";
+ // 识别权限拒绝关键词(兼容不同平台)
+ const isAuthDenied = [
+ "auth deny",
+ "permission denied",
+ "auth denied",
+ "用户拒绝"
+ ].some(keyword => errMsg.includes(keyword));
+
+ if (isAuthDenied) {
+ // 弹窗提示用户,并引导至设置页
+ uni.showModal({
+ title: "权限提示",
+ content: `需要${mediaType}权限才能使用该功能,请前往设置开启`,
+ confirmText: "去设置",
+ cancelText: "取消",
+ success: (modalRes) => {
+ if (modalRes.confirm) {
+ // 跳转到小程序设置页
+ uni.openSetting({
+ success: (settingRes) => {
+ console.log("设置页返回结果", settingRes);
+ // 可根据需要添加权限开启后的回调逻辑
+ }
+ });
+ }
+ }
+ });
+ } else {
+ // 其他错误(如取消选择),仅轻提示
+ if (!errMsg.includes("cancel")) {
+ uni.showToast({
+ title: `${mediaType}选择失败`,
+ icon: "none"
+ });
+ }
+ }
}
const groupInfo = ref({});
@@ -432,7 +497,7 @@ function sendMsg(msg) {
content: msg.value,
image_url: "",
order_id: "",
- session_id: "",
+ session_id: groupInfo.value.session_id||options.session_id,
...msg,
});
}
diff --git a/pageChat/components/chat-item.vue b/pageChat/components/chat-item.vue
index a85ca45..3e47e97 100644
--- a/pageChat/components/chat-item.vue
+++ b/pageChat/components/chat-item.vue
@@ -13,11 +13,10 @@
:src="item.image_url"
class="img"
mode="widthFix"
- @click="previewVideo(item.video_url)"
>
{{ item.coupon.title }}
-
+
@@ -76,10 +75,10 @@
-
- {{item.coupon.couponName}}
- 有效期:{{ returnTime(item.coupon) }}
-
+
+ {{ item.coupon.couponName }}
+
+
@@ -141,5 +140,8 @@ function returnTime(coupon){
color: #999;
}
}
+.u-col-stretch{
+ align-items: stretch;
+}
diff --git a/pageChat/group-info/index.vue b/pageChat/group-info/index.vue
index ae4f9c4..7bc5124 100644
--- a/pageChat/group-info/index.vue
+++ b/pageChat/group-info/index.vue
@@ -2,7 +2,7 @@
- 群成员(22人)
+ 群成员({{allUser.length}}人)
移除
@@ -17,7 +17,7 @@
:src="item.avatar"
round="8rpx"
>
- {{ item.nick_name }}
+ {{ item.nick_name }}
- 查看更多
-
+
+ 查看更多
+
+
@@ -61,10 +63,12 @@
优惠券领取记录
@@ -122,16 +126,20 @@ function groupMuteChange(e) {
});
}
const showRemove = ref(false);
-let allUser = [];
+let allUser = ref([]);
const userLists = ref([]);
const hasMore = ref(false);
function getMembers() {
chatApi.groupMembers({ group_id: options.group_id }).then((res) => {
- allUser = res.user_list || [];
- hasMore.value = allUser.length > 20;
- userLists.value = allUser.slice(0, 20);
+ allUser.value = res.user_list || [];
+ hasMore.value = allUser.value.length > 20;
+ userLists.value = allUser.value.slice(0, 20);
});
}
+
+function loadMore() {
+ userLists.value=allUser.value
+}
onShow(() => {
getMembers();
});
diff --git a/pageChat/index.vue b/pageChat/index.vue
index 9464027..b0583b8 100644
--- a/pageChat/index.vue
+++ b/pageChat/index.vue
@@ -1,63 +1,175 @@
-
-
-
+
+
+
+
+
清空未读
-
-
-
- {{
- item.unread_count >= 99 ? "99" : item.unread_count
- }}
-
-
-
- {{ item.name }}
- 用户昵称:这里是消息内容这里,,,,
+
+
+
+
+
+ {{
+ item.unread_count >= 99 ? "99" : item.unread_count
+ }}
+
+
+
+ {{ item.name }}
+ {{
+ item.msg
+ }}
+
+ {{ item.send_time }}
+
- {{ item.send_time }}
-
-
+
+
-
-
-
-