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