增加分享优惠券功能
This commit is contained in:
@@ -80,7 +80,10 @@
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
<up-loadmore v-if="isEnd" :status="isEnd?'nomore':'loading'"></up-loadmore>
|
||||
<up-loadmore
|
||||
v-if="isEnd"
|
||||
:status="isEnd ? 'nomore' : 'loading'"
|
||||
></up-loadmore>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
@@ -377,7 +380,7 @@ async function getMsgList() {
|
||||
// 加载失败回退页码,避免页码错乱
|
||||
if (query.page > 1) query.page--;
|
||||
} finally {
|
||||
console.log('scrollView',scrollView)
|
||||
console.log("scrollView", scrollView);
|
||||
setTimeout(() => {
|
||||
scrollView.refresherTriggered = false;
|
||||
isLoading.value = false;
|
||||
@@ -389,7 +392,9 @@ const options = reactive({});
|
||||
onLoad((opt) => {
|
||||
Object.assign(options, opt);
|
||||
init();
|
||||
|
||||
chatApi.messageMarkReadAll({
|
||||
session_ids: options.session_id,
|
||||
});
|
||||
// #ifdef H5
|
||||
scrollView.safeAreaHeight = uni.getSystemInfoSync().safeArea.height;
|
||||
// #endif
|
||||
@@ -398,6 +403,7 @@ onLoad((opt) => {
|
||||
function toMore() {
|
||||
go.to("PAGES_CHAT_GROUP_INFO", {
|
||||
group_id: groupInfo.value.id,
|
||||
session_id: options.session_id,
|
||||
});
|
||||
}
|
||||
function sendText() {
|
||||
|
||||
@@ -72,6 +72,13 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-16 u-flex u-row-right" style="gap: 16rpx">
|
||||
<view
|
||||
class="btn share"
|
||||
@click="toShare(item)"
|
||||
v-if="item.status == 1"
|
||||
>
|
||||
分享</view
|
||||
>
|
||||
<view class="btn cancel" @click="cancel(item)">失效</view>
|
||||
<view class="btn primary" @click="toDetail(item)"> 查看</view>
|
||||
</view>
|
||||
@@ -84,13 +91,22 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onReachBottom } from "@dcloudio/uni-app";
|
||||
import * as chatApi from "@/http/php/chat";
|
||||
|
||||
import { onReachBottom, onLoad } from "@dcloudio/uni-app";
|
||||
import { reactive, ref, watch } from "vue";
|
||||
import { onShow } from "@dcloudio/uni-app";
|
||||
import go from "@/commons/utils/go.js";
|
||||
import * as chatCouponApi from "@/http/api/market/chat";
|
||||
|
||||
import { useChatStore } from "@/store/chat";
|
||||
|
||||
const chatStore = useChatStore();
|
||||
chatStore.onReceiveMsg = (msg) => {};
|
||||
chatStore.connectSocket();
|
||||
|
||||
function toDetail(item) {
|
||||
uni.setStorageSync("cach_couponActivity", item);
|
||||
uni.setStorageSync("cach_couponActivity", item);
|
||||
go.to("PAGES_CHAT_COUPON_ACTIVITY_DETAIL", {
|
||||
id: item.id,
|
||||
});
|
||||
@@ -133,6 +149,43 @@ function cancelChatCoupon(item) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function sendMsg(msg) {
|
||||
chatStore.sendMessage({
|
||||
to_id: groupInfo.value.id,
|
||||
to_user_type: groupInfo.value.id,
|
||||
chat_type: 2,
|
||||
content: msg.value,
|
||||
image_url: "",
|
||||
order_id: "",
|
||||
session_id: options.session_id,
|
||||
...msg,
|
||||
});
|
||||
}
|
||||
function toShare(item) {
|
||||
sendMsg({
|
||||
coupon: { ...item.couponJson, title: item.title },
|
||||
msg_type: 4,
|
||||
});
|
||||
|
||||
uni.navigateBack({
|
||||
delta: 2,
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
const options = reactive({});
|
||||
const groupInfo = ref({});
|
||||
onLoad((opt) => {
|
||||
Object.assign(options, opt);
|
||||
chatApi
|
||||
.groupInfo({
|
||||
group_id: options.group_id,
|
||||
})
|
||||
.then((res) => {
|
||||
groupInfo.value = res || {};
|
||||
});
|
||||
});
|
||||
function cancel(item) {
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
@@ -248,5 +301,10 @@ onShow(init);
|
||||
background-color: $my-main-color;
|
||||
color: #fff;
|
||||
}
|
||||
&.share {
|
||||
background-color: #ecf5ff;
|
||||
color: $my-main-color;
|
||||
border: 1px solid $my-main-color;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -61,7 +61,10 @@
|
||||
</view>
|
||||
<view
|
||||
class="u-flex u-row-between default-padding bg-fff"
|
||||
@click="go.to('PAGES_CHAT_COUPON_ACTIVITY')"
|
||||
@click="go.to('PAGES_CHAT_COUPON_ACTIVITY', {
|
||||
group_id: options.group_id,
|
||||
session_id: options.session_id,
|
||||
})"
|
||||
>
|
||||
<text>优惠券领取记录</text>
|
||||
<view class="u-flex color-666">
|
||||
|
||||
@@ -16,13 +16,16 @@
|
||||
:key="item.id"
|
||||
@click="toDetail(item)"
|
||||
>
|
||||
<view class="u-flex">
|
||||
<view class="u-flex avatar">
|
||||
<up-avatar
|
||||
size="118rpx"
|
||||
:src="item.avatar"
|
||||
shape="square"
|
||||
round="8rpx"
|
||||
></up-avatar>
|
||||
<view class="bandage" v-if="item.unread_count > 0">{{
|
||||
item.unread_count >= 99 ? "99" : item.unread_count
|
||||
}}</view>
|
||||
</view>
|
||||
<view class="u-flex-1 u-flex u-row-between u-p-l-14">
|
||||
<view style="max-width: 364rpx">
|
||||
@@ -48,23 +51,25 @@ const list = ref([]);
|
||||
|
||||
async function getList() {
|
||||
const res = await chatApi.messageSessionList({});
|
||||
list.value = (res.list || []).filter(v=>!v.is_del)
|
||||
list.value = (res.list || []).filter((v) => !v.is_del);
|
||||
}
|
||||
|
||||
async function clearAllmsg() {
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "确定要清空所有消息吗?",
|
||||
content: "确定要清空所有未读消息吗?",
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
const res = await chatApi.clearAllmsg({});
|
||||
const res = await chatApi.messageMarkReadAll({session_ids: list.value.map(v=>v.session_id).join(',')});
|
||||
if (res) {
|
||||
uni.showToast({
|
||||
title: "清空成功",
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
getList();
|
||||
setTimeout(() => {
|
||||
getList();
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -72,10 +77,21 @@ async function clearAllmsg() {
|
||||
}
|
||||
|
||||
function toDetail(item) {
|
||||
go.to("PAGES_CHAT_CHAT", { group_id: item.group_id,session_id: item.session_id });
|
||||
go.to("PAGES_CHAT_CHAT", {
|
||||
group_id: item.group_id,
|
||||
session_id: item.session_id,
|
||||
});
|
||||
}
|
||||
|
||||
onShow(getList);
|
||||
const messageUnreadCount = ref(0);
|
||||
onShow(() => {
|
||||
getList();
|
||||
// 获取未读消息总数
|
||||
chatApi.messageUnreadCount({}).then((res) => {
|
||||
console.log(res);
|
||||
messageUnreadCount.value = res.total;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -94,6 +110,25 @@ onShow(getList);
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
margin-bottom: 16rpx;
|
||||
.avatar {
|
||||
position: relative;
|
||||
.bandage {
|
||||
position: absolute;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: 50%;
|
||||
background: #ff1c1c;
|
||||
font-size: 24rpx;
|
||||
color: #ffffff;
|
||||
width: 38rpx;
|
||||
height: 38rpx;
|
||||
text-align: center;
|
||||
line-height: 38rpx;
|
||||
right: -10rpx;
|
||||
top: -10rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -15,9 +15,7 @@ export const useChatStore = defineStore("chat", {
|
||||
socketUrl,
|
||||
isConnect: false,
|
||||
socketTask: null,
|
||||
onReceiveMsg:()=>{
|
||||
|
||||
},
|
||||
onReceiveMsg: () => {},
|
||||
chatList: [],
|
||||
};
|
||||
},
|
||||
@@ -83,20 +81,35 @@ export const useChatStore = defineStore("chat", {
|
||||
this.socketTask.onMessage((res) => {
|
||||
const data = JSON.parse(res.data);
|
||||
console.log("收到服务器消息", data);
|
||||
if(data.msg){
|
||||
if (data.msg) {
|
||||
uni.showToast({
|
||||
title: data.msg,
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
|
||||
if(data&&data.operate_type=="sendMsg"){
|
||||
|
||||
if (data && data.operate_type == "sendMsg") {
|
||||
this.chatList.unshift(data.data);
|
||||
this.onReceiveMsg(data.data);
|
||||
console.log(this.chatList);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
this.socketTask.onError((res) => {
|
||||
this.isConnect = false;
|
||||
console.log("连接错误", res);
|
||||
});
|
||||
|
||||
this.socketTask.onClose(() => {
|
||||
this.isConnect = false;
|
||||
console.log("连接已关闭");
|
||||
this.connectSocket();
|
||||
});
|
||||
},
|
||||
|
||||
closeSocket() {
|
||||
this.socketTask.close();
|
||||
this.isConnect = false;
|
||||
},
|
||||
},
|
||||
unistorage: false, // 开启后对 state 的数据读写都将持久化
|
||||
|
||||
Reference in New Issue
Block a user