增加群聊功能
This commit is contained in:
45
http/api/market/chat.js
Normal file
45
http/api/market/chat.js
Normal file
@@ -0,0 +1,45 @@
|
||||
import http from "@/http/http.js";
|
||||
const request = http.request;
|
||||
const urlType = "market";
|
||||
|
||||
export function chatCouponCreate(data) {
|
||||
return request({
|
||||
url: urlType + `/admin/chat/coupon/create`,
|
||||
method: "post",
|
||||
data: {
|
||||
...data,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function chatCouponPage(params) {
|
||||
return request({
|
||||
url: urlType + `/admin/chat/coupon/page`,
|
||||
method: "get",
|
||||
params: {
|
||||
...params,
|
||||
},
|
||||
});
|
||||
}
|
||||
export function chatCouponExpired(id) {
|
||||
return request({
|
||||
url: urlType + `/admin/chat/coupon/expired/${id}`,
|
||||
method: "delete",
|
||||
});
|
||||
}
|
||||
|
||||
export function chatCouponGrant(data) {
|
||||
return request({
|
||||
url: urlType + `/admin/chat/coupon/grant`,
|
||||
method: "post",
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
export function chatCouponRecord(params) {
|
||||
return request({
|
||||
url: urlType + `/admin/chat/coupon/record`,
|
||||
method: "get",
|
||||
params,
|
||||
});
|
||||
}
|
||||
14
http/api/market/chatCoupon.js
Normal file
14
http/api/market/chatCoupon.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import http from "@/http/http.js";
|
||||
const request = http.request;
|
||||
const urlType = "market";
|
||||
|
||||
export function chatCoupon(params) {
|
||||
return request({
|
||||
url: urlType + `/admin/coupon/chatCoupon`,
|
||||
method: "get",
|
||||
params: {
|
||||
...params,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ envConfig.changeEnv(storageManage.env("development")); //测试
|
||||
|
||||
// 测试服
|
||||
// #ifdef H5
|
||||
let baseUrl = "/api/";
|
||||
let baseUrl = "/javaapi/";
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
// let baseUrl = 'https://tapi.cashier.sxczgkj.cn/'
|
||||
@@ -204,7 +204,6 @@ function upload(uri, data, file, showLoading = true, extParams = {}) {
|
||||
// 放置token
|
||||
let headerObject = {};
|
||||
// headerObject[appConfig.tokenKey] = storageManage.token()
|
||||
|
||||
return commonsProcess(showLoading, () => {
|
||||
return uni
|
||||
.uploadFile(
|
||||
@@ -213,7 +212,7 @@ function upload(uri, data, file, showLoading = true, extParams = {}) {
|
||||
url: baseUrl + uri,
|
||||
formData: data,
|
||||
name: "file",
|
||||
filePath: file.path || file.url,
|
||||
filePath: file.path || file.url ||file,
|
||||
header: getHeader(),
|
||||
},
|
||||
extParams
|
||||
|
||||
87
http/php/chat.js
Normal file
87
http/php/chat.js
Normal file
@@ -0,0 +1,87 @@
|
||||
import { request } from "./request";
|
||||
const prveUrl = "chat/";
|
||||
|
||||
/**
|
||||
* 群消息
|
||||
* @param {Object} data
|
||||
* @returns
|
||||
*/
|
||||
export const groupInfo = (data) => {
|
||||
return request(prveUrl + "group/info", "POST", data, true);
|
||||
};
|
||||
|
||||
export const commonPhrase = (data) => {
|
||||
return request(prveUrl + "common-phrase/index", "POST", data, true);
|
||||
};
|
||||
export const commonPhraseAdd = (data) => {
|
||||
return request(prveUrl + "common-phrase/add", "POST", data, true);
|
||||
};
|
||||
|
||||
|
||||
export const commonPhraseDel = (data) => {
|
||||
return request(prveUrl + "common-phrase/del", "POST", data, true);
|
||||
};
|
||||
|
||||
|
||||
export const groupCreate = (data) => {
|
||||
return request(prveUrl + "group/create", "POST", data, true);
|
||||
};
|
||||
|
||||
export const groupJoin = (data) => {
|
||||
return request(prveUrl + "group/join", "POST", data, true);
|
||||
};
|
||||
export const groupGetGroupUrl = (data) => {
|
||||
return request(prveUrl + "group/getgrepurl", "POST", data, true);
|
||||
};
|
||||
|
||||
export const groupQuit = (data) => {
|
||||
return request(prveUrl + "group/quit", "POST", data, true);
|
||||
};
|
||||
|
||||
export const groupTarsGroup = (data) => {
|
||||
return request(prveUrl + "group/tarsgroup", "POST", data, true);
|
||||
};
|
||||
|
||||
export const groupAnnouncement = (data) => {
|
||||
return request(prveUrl + "group/announcement", "POST", data, true);
|
||||
};
|
||||
export const groupMute = (data) => {
|
||||
return request(prveUrl + "group/mute", "POST", data, true);
|
||||
};
|
||||
|
||||
export const groupMunute = (data) => {
|
||||
return request(prveUrl + "group/unmute", "POST", data, true);
|
||||
};
|
||||
|
||||
export const groupKick = (data) => {
|
||||
return request(prveUrl + "group/kick", "POST", data, true);
|
||||
};
|
||||
|
||||
export const groupMembers = (data) => {
|
||||
return request(prveUrl + "group/members", "POST", data, true);
|
||||
};
|
||||
|
||||
|
||||
export const messageHistory = (data) => {
|
||||
return request(prveUrl + "message/history", "POST", data, true);
|
||||
};
|
||||
|
||||
export const messageMarkRead = (data) => {
|
||||
return request(prveUrl + "message/mark-read", "POST", data, true);
|
||||
};
|
||||
|
||||
export const messageMarkReadAll = (data) => {
|
||||
return request(prveUrl + "message/mark-read-all", "POST", data, true);
|
||||
};
|
||||
|
||||
export const messageUnreadCount = (data) => {
|
||||
return request(prveUrl + "message/unread-count", "POST", data, true);
|
||||
};
|
||||
|
||||
export const messageSessionList = (data) => {
|
||||
return request(prveUrl + "message/sessionlist", "POST", data, true);
|
||||
};
|
||||
|
||||
export const groupDoNotDisturb = (data) => {
|
||||
return request(prveUrl + "group/do-not-disturb", "POST", data, true);
|
||||
};
|
||||
@@ -1,5 +1,9 @@
|
||||
//服务器接口地址
|
||||
const baseURL : string = 'https://newblockwlx.sxczgkj.cn/index.php/api/'
|
||||
// const baseURL : string = 'https://newblockwlx.sxczgkj.cn/index.php/api/'
|
||||
let baseURL : string = 'http://192.168.1.42:8787/api/'
|
||||
// #ifdef H5
|
||||
baseURL='/phpapi/api/'
|
||||
// #endif
|
||||
// 封装公共请求方法
|
||||
function request(url : string, method : "GET" | "POST" | undefined, data : object | any, toast : boolean) {
|
||||
let networkType = ''
|
||||
@@ -26,7 +30,8 @@ function request(url : string, method : "GET" | "POST" | undefined, data : objec
|
||||
header = {
|
||||
'content-type': 'application/json',
|
||||
'clinttype':uni.getStorageSync('clint_type'),
|
||||
'bausertoken': uni.getStorageSync('phpuserinfo').token
|
||||
'bausertoken': uni.getStorageSync('phpuserinfo').token||'',
|
||||
'token': uni.getStorageSync('iToken').tokenValue||'',
|
||||
};
|
||||
uni.request({
|
||||
url: baseURL + url,
|
||||
@@ -66,6 +71,7 @@ function request(url : string, method : "GET" | "POST" | undefined, data : objec
|
||||
}
|
||||
},
|
||||
fail(err) {
|
||||
console.log(err)
|
||||
uni.hideLoading()
|
||||
//请求失败
|
||||
uni.showToast({
|
||||
|
||||
644
pageChat/chat.vue
Normal file
644
pageChat/chat.vue
Normal file
@@ -0,0 +1,644 @@
|
||||
<template>
|
||||
<view class="min-page bg-f7 u-font-28 color-333" :style="pageHeight">
|
||||
<view class="top u-flex u-row-between">
|
||||
<view>
|
||||
<text style="max-width: 286rpx" class="u-line-1 u-font-32">
|
||||
{{ groupInfo.name }}
|
||||
</text>
|
||||
<text class="u-m-l-22">(22人)</text>
|
||||
</view>
|
||||
<view class="" @click="toMore()">
|
||||
<view class="u-flex u-row-center">
|
||||
<up-icon name="more-dot-fill" color="#333" size="14"></up-icon>
|
||||
</view>
|
||||
<view class="color-666">更多</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="box-1">
|
||||
<!-- @refresherrefresh="refresherrefresh" -->
|
||||
|
||||
<scroll-view
|
||||
scroll-y
|
||||
refresher-background="transparent"
|
||||
style="height: 100%"
|
||||
@scrolltoupper="refresherrefresh"
|
||||
:refresher-enabled="false"
|
||||
:scroll-with-animation="false"
|
||||
:refresher-triggered="scrollView.refresherTriggered"
|
||||
:scroll-into-view="scrollView.intoView"
|
||||
>
|
||||
<view class="scroll-view-box">
|
||||
<view class="talk-list">
|
||||
<view
|
||||
:id="'msg-' + index"
|
||||
v-for="(item, index) in chatStore.chatList"
|
||||
:key="index"
|
||||
>
|
||||
<!-- 发消息 -->
|
||||
<template
|
||||
v-if="item.operate_type == 'sendMsg' || item.is_user_send == 1"
|
||||
>
|
||||
<view class="shop u-flex u-row-right">
|
||||
<view class="u-p-r-18">
|
||||
<view class="u-flex u-row-right">
|
||||
<view class="tag">商家</view>
|
||||
<view class="color-000">{{ shopInfo.shopName }}</view>
|
||||
</view>
|
||||
<view
|
||||
class="u-m-t-14 msg"
|
||||
:class="['type' + item.msg_type]"
|
||||
>
|
||||
<chatItem :item="item"></chatItem>
|
||||
</view>
|
||||
</view>
|
||||
<up-avatar
|
||||
size="122rpx"
|
||||
shape="square"
|
||||
bg-color="#fff"
|
||||
></up-avatar>
|
||||
</view>
|
||||
</template>
|
||||
<!-- 收消息 -->
|
||||
<template v-else>
|
||||
<view class="user u-flex">
|
||||
<up-avatar
|
||||
size="122rpx"
|
||||
:src="item.avatar"
|
||||
shape="square"
|
||||
bg-color="#fff"
|
||||
></up-avatar>
|
||||
<view class="u-p-l-18">
|
||||
<view class="color-000 u-line-1">{{ item.nick_name }}</view>
|
||||
<view
|
||||
class="u-m-t-14 msg u-p-l-30"
|
||||
:class="['type' + item.msg_type]"
|
||||
>
|
||||
<chatItem :item="item"></chatItem>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
<up-loadmore v-if="isEnd" :status="isEnd?'nomore':'loading'"></up-loadmore>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<!-- <view :style="bottomSlotHeight"></view> -->
|
||||
|
||||
<view class="bottom" :class="[showMoreBtn ? '' : 'safe-bottom']">
|
||||
<view class="u-flex" style="padding: 14rpx 28rpx">
|
||||
<!-- <input
|
||||
type="text"
|
||||
class="u-flex-1 u-m-r-52 iput"
|
||||
placeholder="请输入内容"
|
||||
v-model="msg"
|
||||
/> -->
|
||||
<view class="u-flex-1 u-m-r-52 iput">
|
||||
<up-input
|
||||
v-model="msg"
|
||||
border="none"
|
||||
placeholder="请输入内容"
|
||||
></up-input>
|
||||
</view>
|
||||
<button class="send-btn" v-if="msg.trim().length > 0" @click="sendText">
|
||||
发送
|
||||
</button>
|
||||
<up-icon
|
||||
name="plus-circle"
|
||||
color="#666"
|
||||
size="40rpx"
|
||||
@click="showMoreBtnToggle"
|
||||
v-else
|
||||
></up-icon>
|
||||
</view>
|
||||
<view class="more-btn" v-if="showMoreBtn">
|
||||
<view
|
||||
v-for="(item, index) in moreBtns"
|
||||
@click="moreBtnsClick(item, index)"
|
||||
class="u-flex-col u-row-cemter u-col-center"
|
||||
>
|
||||
<view class="u-flex icon">
|
||||
<image :src="item.icon" class="img" mode="aspectFill"></image>
|
||||
</view>
|
||||
<view class="u-m-t-8">{{ item.title }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 发送优惠券 -->
|
||||
<Modal
|
||||
title="发送优惠券"
|
||||
v-model="modalData.show"
|
||||
confirmText="确认发送"
|
||||
@close="closeModal"
|
||||
@confirm="confirmCoupon"
|
||||
>
|
||||
<view class="u-p-30">
|
||||
<view class="font-bold u-m-b-16">自定义文案</view>
|
||||
<up-input
|
||||
v-model="modalData.form.title"
|
||||
placeholder="请输入自定义文案"
|
||||
:placeholderStyle="placeholderStyle"
|
||||
></up-input>
|
||||
<view class="font-bold u-m-b-16 u-m-t-32">发放数量(张)</view>
|
||||
|
||||
<up-number-box
|
||||
v-model="modalData.form.giveNum"
|
||||
inputWidth="240rpx"
|
||||
@change="valChange"
|
||||
></up-number-box>
|
||||
|
||||
<view class="font-bold u-m-b-16 u-m-t-32">每人限领量(张)</view>
|
||||
<up-number-box
|
||||
v-model="modalData.form.getLimit"
|
||||
inputWidth="240rpx"
|
||||
@change="valChange"
|
||||
></up-number-box>
|
||||
<view class="font-bold u-m-b-16 u-m-t-32">选择优惠券</view>
|
||||
<chooseCoupon v-model="modalData.form.couponId"></chooseCoupon>
|
||||
</view>
|
||||
</Modal>
|
||||
</view>
|
||||
</template>
|
||||
<script setup>
|
||||
import {
|
||||
onReady,
|
||||
onReachBottom,
|
||||
onLoad,
|
||||
onPageScroll,
|
||||
} from "@dcloudio/uni-app";
|
||||
import {
|
||||
ref,
|
||||
inject,
|
||||
onMounted,
|
||||
nextTick,
|
||||
reactive,
|
||||
watch,
|
||||
computed,
|
||||
} from "vue";
|
||||
import { useChatStore } from "@/store/chat";
|
||||
import * as chatApi from "@/http/php/chat";
|
||||
import * as chatCouponApi from "@/http/api/market/chat";
|
||||
import { uploadFile } from "@/http/api/index.js";
|
||||
import go from "@/commons/utils/go.js";
|
||||
import Modal from "./components/modal.vue";
|
||||
import chooseCoupon from "./components/coupon.vue";
|
||||
import chatItem from "./components/chat-item.vue";
|
||||
const placeholderStyle = {
|
||||
color: "#999",
|
||||
fontSize: "28rpx",
|
||||
};
|
||||
|
||||
function refresherrefresh() {
|
||||
console.log("refresherrefresh");
|
||||
// 关键:同时判断「正在加载」和「无更多数据」,只要一个为真就关闭刷新
|
||||
if (isLoading.value || isEnd.value) {
|
||||
scrollView.refresherTriggered = false; // 立即关闭刷新状态
|
||||
if (isEnd.value) {
|
||||
uni.showToast({ title: "没有更多了", icon: "none" });
|
||||
}
|
||||
return; // 终止后续逻辑
|
||||
}
|
||||
|
||||
query.page++;
|
||||
getMsgList();
|
||||
}
|
||||
|
||||
const scrollView = reactive({
|
||||
refresherTriggered: false,
|
||||
intoView: "",
|
||||
safeAreaHeight: 0,
|
||||
});
|
||||
|
||||
const showMoreBtn = ref(false);
|
||||
function showMoreBtnToggle() {
|
||||
showMoreBtn.value = !showMoreBtn.value;
|
||||
if (showMoreBtn.value) {
|
||||
}
|
||||
}
|
||||
const modalData = reactive({
|
||||
show: false,
|
||||
form: {
|
||||
title: "",
|
||||
getLimit: 1,
|
||||
giveNum: 1,
|
||||
couponId: "",
|
||||
},
|
||||
});
|
||||
const websocketUtil = inject("websocketUtil");
|
||||
websocketUtil.closeSocket();
|
||||
websocketUtil.offMessage();
|
||||
|
||||
const chatStore = useChatStore();
|
||||
chatStore.onReceiveMsg = (msg) => {
|
||||
nextTick(() => {
|
||||
scrollView.intoView = "msg-0";
|
||||
});
|
||||
};
|
||||
chatStore.connectSocket();
|
||||
const msg = ref("");
|
||||
|
||||
const shopInfo = uni.getStorageSync("shopInfo");
|
||||
|
||||
const moreBtns = ref([
|
||||
{
|
||||
icon: "/pageChat/static/pic.png",
|
||||
title: "发送照片",
|
||||
value: "pic",
|
||||
},
|
||||
{
|
||||
icon: "/pageChat/static/video.png",
|
||||
title: "发送视频",
|
||||
value: "video",
|
||||
},
|
||||
{
|
||||
icon: "/pageChat/static/coupon.png",
|
||||
title: "发送优惠券",
|
||||
value: "coupon",
|
||||
},
|
||||
]);
|
||||
|
||||
function moreBtnsClick(item, index) {
|
||||
if (item.value == "coupon") {
|
||||
modalData.show = true;
|
||||
return;
|
||||
}
|
||||
if (item.value == "pic") {
|
||||
sendImg();
|
||||
}
|
||||
if (item.value == "video") {
|
||||
sendVideo();
|
||||
}
|
||||
}
|
||||
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: "发送中",
|
||||
});
|
||||
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 {
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
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();
|
||||
if (fileRes) {
|
||||
sendMsg({
|
||||
image_url: fileRes,
|
||||
msg_type: 5,
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: "发送失败",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const groupInfo = ref({});
|
||||
async function init() {
|
||||
const res = await chatApi.groupInfo({
|
||||
group_id: options.group_id,
|
||||
});
|
||||
console.log(res);
|
||||
groupInfo.value = res || {};
|
||||
getMsgList();
|
||||
}
|
||||
const query = reactive({
|
||||
page: 1,
|
||||
size: 10,
|
||||
});
|
||||
async function getMsgList() {
|
||||
// 提前拦截:已无更多数据,直接关闭状态
|
||||
if (isEnd.value) {
|
||||
scrollView.refresherTriggered = false;
|
||||
isLoading.value = false;
|
||||
uni.showToast({ title: "没有更多了", icon: "none" });
|
||||
return;
|
||||
}
|
||||
|
||||
isLoading.value = true;
|
||||
try {
|
||||
const msgRes = await chatApi.messageHistory({
|
||||
...query,
|
||||
chat_type: "2",
|
||||
session_id: options.session_id,
|
||||
to_id: options.group_id,
|
||||
shop_id: options.group_id,
|
||||
group_id: options.group_id,
|
||||
});
|
||||
const data = msgRes.list || [];
|
||||
const selector = `msg-${query.page == 1 ? 0 : chatStore.chatList.length}`;
|
||||
|
||||
if (query.page == 1) {
|
||||
chatStore.chatList = data;
|
||||
} else {
|
||||
chatStore.chatList.push(...data);
|
||||
}
|
||||
|
||||
isEnd.value = chatStore.chatList.length >= msgRes.total;
|
||||
nextTick(() => {
|
||||
scrollView.intoView = selector;
|
||||
console.log(selector);
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("加载历史消息异常", err);
|
||||
// 加载失败回退页码,避免页码错乱
|
||||
if (query.page > 1) query.page--;
|
||||
} finally {
|
||||
console.log('scrollView',scrollView)
|
||||
setTimeout(() => {
|
||||
scrollView.refresherTriggered = false;
|
||||
isLoading.value = false;
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
|
||||
const options = reactive({});
|
||||
onLoad((opt) => {
|
||||
Object.assign(options, opt);
|
||||
init();
|
||||
|
||||
// #ifdef H5
|
||||
scrollView.safeAreaHeight = uni.getSystemInfoSync().safeArea.height;
|
||||
// #endif
|
||||
});
|
||||
|
||||
function toMore() {
|
||||
go.to("PAGES_CHAT_GROUP_INFO", {
|
||||
group_id: groupInfo.value.id,
|
||||
});
|
||||
}
|
||||
function sendText() {
|
||||
if (!msg.value.trim().length) return;
|
||||
sendMsg({ content: msg.value, msg_type: 1 });
|
||||
msg.value = "";
|
||||
}
|
||||
|
||||
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: "",
|
||||
...msg,
|
||||
});
|
||||
}
|
||||
function closeModal() {
|
||||
modalData.form = {
|
||||
title: "",
|
||||
getLimit: 1,
|
||||
giveNum: 1,
|
||||
couponId: "",
|
||||
};
|
||||
}
|
||||
function confirmCoupon() {
|
||||
console.log(modalData.form);
|
||||
if (!modalData.form.title) {
|
||||
uni.showToast({
|
||||
title: "请输入自定义文案",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!modalData.form.couponId) {
|
||||
uni.showToast({
|
||||
title: "请选择优惠券",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!modalData.form.giveNum) {
|
||||
uni.showToast({
|
||||
title: "请输入发放数量",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!modalData.form.getLimit) {
|
||||
uni.showToast({
|
||||
title: "请输入每人限领量",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
chatCouponApi.chatCouponCreate(modalData.form).then((res) => {
|
||||
if (res) {
|
||||
modalData.show = false;
|
||||
const couponJson = JSON.parse(res.couponJson);
|
||||
sendMsg({
|
||||
coupon: { ...couponJson, title: modalData.form.title },
|
||||
msg_type: 4,
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: "发送失败",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function previewImage(url) {
|
||||
uni.previewImage({
|
||||
urls: [url],
|
||||
});
|
||||
}
|
||||
|
||||
//是否到底了
|
||||
const isBottom = ref(false);
|
||||
|
||||
const isLoading = ref(false);
|
||||
|
||||
//消息是否完了
|
||||
const isEnd = ref(false);
|
||||
|
||||
watch(
|
||||
() => chatStore.chatList.length,
|
||||
(newVal, oldVal) => {}
|
||||
);
|
||||
|
||||
const bottomSlotHeight = computed(() => {
|
||||
if (showMoreBtn.value) {
|
||||
return {
|
||||
height: "180px",
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
height: "88px",
|
||||
};
|
||||
}
|
||||
});
|
||||
onReady(() => {});
|
||||
const pageHeight = computed(() => {
|
||||
const safeAreaHeight = scrollView.safeAreaHeight;
|
||||
if (safeAreaHeight > 0) {
|
||||
return `height: calc(${safeAreaHeight}px - var(--window-top));`;
|
||||
}
|
||||
return "";
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.top {
|
||||
background-color: #fff;
|
||||
padding: 40rpx 32rpx;
|
||||
}
|
||||
.min-page {
|
||||
height: calc(100vh - var(--window-top));
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
justify-content: space-between;
|
||||
align-items: stretch;
|
||||
}
|
||||
.talk-list {
|
||||
padding: 30rpx 28rpx 30rpx 26rpx;
|
||||
display: flex;
|
||||
flex-direction: column-reverse;
|
||||
flex-wrap: nowrap;
|
||||
align-content: flex-start;
|
||||
justify-content: flex-end;
|
||||
align-items: stretch;
|
||||
// 添加弹性容器,让内容自动在顶部
|
||||
&::before {
|
||||
content: ".";
|
||||
display: inline;
|
||||
visibility: hidden;
|
||||
line-height: 0;
|
||||
font-size: 0;
|
||||
flex: 1 0 auto;
|
||||
height: 1px;
|
||||
}
|
||||
}
|
||||
.box-1 {
|
||||
width: 100%;
|
||||
height: 0;
|
||||
flex: 1 0 auto;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
.user {
|
||||
margin-bottom: 88rpx;
|
||||
.msg {
|
||||
padding: 16rpx 20rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
}
|
||||
.shop {
|
||||
margin-bottom: 88rpx;
|
||||
.tag {
|
||||
margin-right: 32rpx;
|
||||
padding: 8rpx 20rpx;
|
||||
border: 1px solid #d9d9d9;
|
||||
border-radius: 8rpx;
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
}
|
||||
.msg {
|
||||
padding: 16rpx 20rpx;
|
||||
border-radius: 8rpx;
|
||||
&.type1 {
|
||||
background-color: #fff;
|
||||
}
|
||||
&.type4 {
|
||||
background-color: #fff;
|
||||
}
|
||||
.img {
|
||||
width: 50vw;
|
||||
}
|
||||
}
|
||||
}
|
||||
.bottom {
|
||||
height: auto;
|
||||
z-index: 2;
|
||||
border-top: #e5e5e5 solid 1px;
|
||||
box-sizing: content-box;
|
||||
background-color: #f3f3f3;
|
||||
|
||||
/* 兼容iPhoneX */
|
||||
padding-bottom: 0;
|
||||
padding-bottom: constant(safe-area-inset-bottom);
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
&.safe-bottom {
|
||||
padding-bottom: calc(env(safe-area-inset-bottom) + 4rpx);
|
||||
}
|
||||
.iput {
|
||||
background-color: #f8f8f8;
|
||||
padding: 16rpx 20rpx;
|
||||
}
|
||||
}
|
||||
.send-btn {
|
||||
background-color: $my-main-color;
|
||||
color: #fff;
|
||||
line-height: 1;
|
||||
padding: 16rpx 20rpx;
|
||||
border-radius: 8rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
.more-btn {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 30rpx;
|
||||
background-color: #f0f0f0;
|
||||
gap: 74rpx;
|
||||
text-align: center;
|
||||
color: #666;
|
||||
padding-bottom: calc(env(safe-area-inset-bottom) + 4rpx);
|
||||
|
||||
.icon {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
.img {
|
||||
height: 70rpx;
|
||||
width: 70rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.scroll-view-box {
|
||||
display: flex;
|
||||
flex-direction: column-reverse;
|
||||
}
|
||||
</style>
|
||||
64
pageChat/components/chat-item.vue
Normal file
64
pageChat/components/chat-item.vue
Normal file
@@ -0,0 +1,64 @@
|
||||
<template>
|
||||
<text class="" v-if="item.msg_type == 1">{{ item.content }}</text>
|
||||
<image
|
||||
v-if="item.msg_type == 2"
|
||||
:src="item.image_url"
|
||||
class="img"
|
||||
mode="widthFix"
|
||||
@click="previewImage(item.image_url)"
|
||||
></image>
|
||||
<video
|
||||
@error="videoErrorCallback"
|
||||
v-if="item.msg_type == 5"
|
||||
:src="item.image_url"
|
||||
class="img"
|
||||
mode="widthFix"
|
||||
@click="previewVideo(item.video_url)"
|
||||
></video>
|
||||
<view class="" v-if="item.msg_type == 4">
|
||||
<view>发优惠券了!数量有限!快来领取吧!</view>
|
||||
<view class="u-m-t-16 bg-f7 coupon u-flex">
|
||||
<view class="left">
|
||||
<view class="price">
|
||||
<text class="u-font-32">¥</text>
|
||||
<text style="font-size: 72rpx;">15</text>
|
||||
</view>
|
||||
<view class="u-font-24 color-999 no-wrap">满{{item.coupon.fullAmount}}可用</view>
|
||||
</view>
|
||||
<view class="right u-p-l-28">
|
||||
<view class="u-font-32 ">优惠券名称叫什么</view>
|
||||
<view class="u-font-24 color-999 u-m-t-8">有效期:2002.1.22-2022.1.22</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const props = defineProps({
|
||||
item: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.img {
|
||||
width: 50vw;
|
||||
}
|
||||
.coupon{
|
||||
padding: 16rpx 10rpx;
|
||||
border-radius: 16rpx;
|
||||
.price{
|
||||
color: #FF1C1C;
|
||||
font-weight: 700;
|
||||
}
|
||||
.left{
|
||||
padding-right: 26rpx;
|
||||
border-right: 1rpx solid #EDEDED;
|
||||
}
|
||||
.right{
|
||||
|
||||
}
|
||||
}
|
||||
</style>
|
||||
201
pageChat/components/choose-coupon.vue
Normal file
201
pageChat/components/choose-coupon.vue
Normal file
@@ -0,0 +1,201 @@
|
||||
<template>
|
||||
<view class="">
|
||||
<up-popup :show="show" mode="bottom">
|
||||
<view class="">
|
||||
<view class="top u-flex u-row-between">
|
||||
<text class="font-bold u-font-32 color-333">{{ title }}</text>
|
||||
<up-icon size="18" name="close" @click="show = false"></up-icon>
|
||||
</view>
|
||||
<scroll-view
|
||||
ref="couponScroll"
|
||||
:scroll-y="true"
|
||||
style="max-height: 50vh"
|
||||
@scroll="scroll"
|
||||
:scroll-top="scrollTop"
|
||||
>
|
||||
<view
|
||||
v-for="(item, index) in list"
|
||||
:key="index"
|
||||
class="item"
|
||||
@click="itemClick(item)"
|
||||
:class="[selGoods && selGoods.id == item.id ? 'selected' : '']"
|
||||
>
|
||||
<view class="u-flex u-row-between">
|
||||
<view class="u-flex gap-20">
|
||||
<!-- <view class="u-flex" @click.stop="preview(item)">
|
||||
<up-image
|
||||
:src="item.coverImg"
|
||||
width="80rpx"
|
||||
height="80rpx"
|
||||
></up-image>
|
||||
</view> -->
|
||||
|
||||
<text class="u-font-32 color-333">{{ item.title }}</text>
|
||||
</view>
|
||||
<text class="u-font-32 color-red u-p-l-30"
|
||||
></text
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
<up-empty v-if="list.length == 0" class="u-p-30" text="暂无数据"></up-empty>
|
||||
</scroll-view>
|
||||
<view class="bottom">
|
||||
<view class="btn cancel" @click="close">{{ cancelText }}</view>
|
||||
<view class="btn success" @click="confirm">{{ confirmText }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</up-popup>
|
||||
</view>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, onMounted, watch } from "vue";
|
||||
const modelValue = defineModel({
|
||||
type: String,
|
||||
default: "",
|
||||
});
|
||||
const show = defineModel("show", {
|
||||
type: String,
|
||||
default: "",
|
||||
});
|
||||
const couponName = defineModel("couponName", {
|
||||
type: String,
|
||||
default: "",
|
||||
});
|
||||
|
||||
const props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
default: "选择优惠券",
|
||||
},
|
||||
confirmText: {
|
||||
type: String,
|
||||
default: "确认",
|
||||
},
|
||||
cancelText: {
|
||||
type: String,
|
||||
default: "取消",
|
||||
},
|
||||
list: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
});
|
||||
|
||||
const selGoods = ref("");
|
||||
function itemClick(item) {
|
||||
if (selGoods.value && selGoods.value.id == item.id) {
|
||||
selGoods.value = "";
|
||||
return;
|
||||
}
|
||||
selGoods.value = item;
|
||||
}
|
||||
|
||||
const scrollTop = ref(0);
|
||||
function scroll(e) {
|
||||
scrollTop.value = e.detail.scrollTop;
|
||||
}
|
||||
function preview(item) {
|
||||
uni.previewImage({
|
||||
urls: item.images || [item.coverImg],
|
||||
});
|
||||
}
|
||||
watch(
|
||||
() => modelValue.value,
|
||||
(newVal, oldVal) => {
|
||||
console.log(newVal, oldVal);
|
||||
selGoods.value = props.list.find((item) => item.id == newVal);
|
||||
console.log(selGoods.value);
|
||||
if (selGoods.value) {
|
||||
couponName.value = selGoods.value.title;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.list.length,
|
||||
(newVal, oldVal) => {
|
||||
selGoods.value = props.list.find((item) => item.id == modelValue.value);
|
||||
console.log(selGoods.value);
|
||||
if (selGoods.value) {
|
||||
modelValue.value = selGoods.value.id;
|
||||
couponName.value = selGoods.value.title;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
function close() {
|
||||
show.value = false;
|
||||
}
|
||||
|
||||
const emit = defineEmits(["confirm"]);
|
||||
function confirm() {
|
||||
if (!selGoods.value) {
|
||||
uni.showToast({
|
||||
title: "请选择优惠券",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
modelValue.value = selGoods.value.id;
|
||||
show.value = false;
|
||||
emit("confirm", selGoods.value);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.popup-content {
|
||||
background: #fff;
|
||||
width: 640rpx;
|
||||
border-radius: 18rpx;
|
||||
}
|
||||
.top {
|
||||
padding: 40rpx 48rpx;
|
||||
border-bottom: 1px solid #d9d9d9;
|
||||
}
|
||||
.bottom {
|
||||
padding: 48rpx 52rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
border-top: 1px solid #d9d9d9;
|
||||
gap: 50rpx;
|
||||
.btn {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
padding: 18rpx 60rpx;
|
||||
border-radius: 100rpx;
|
||||
font-size: 32rpx;
|
||||
border: 2rpx solid transparent;
|
||||
&.success {
|
||||
background-color: $my-main-color;
|
||||
color: #fff;
|
||||
}
|
||||
&.cancel {
|
||||
border-color: #d9d9d9;
|
||||
box-shadow: 0 4rpx 0 0 #00000005;
|
||||
}
|
||||
}
|
||||
}
|
||||
.item {
|
||||
padding: 10rpx 30rpx;
|
||||
border: 1px solid #d9d9d9;
|
||||
margin: 10rpx;
|
||||
border-radius: 8rpx;
|
||||
transition: all 0.3s ease-in-out;
|
||||
box-shadow: 0 0 10px transparent;
|
||||
&.selected {
|
||||
border-color: $my-main-color;
|
||||
box-shadow: 0 0 10px $my-main-color;
|
||||
}
|
||||
}
|
||||
.choose-goods {
|
||||
display: flex;
|
||||
padding: 24rpx;
|
||||
align-items: center;
|
||||
border-radius: 8rpx;
|
||||
border: 2rpx solid #d9d9d9;
|
||||
background: #fff;
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
}
|
||||
</style>
|
||||
198
pageChat/components/choose-goods.vue
Normal file
198
pageChat/components/choose-goods.vue
Normal file
@@ -0,0 +1,198 @@
|
||||
<template>
|
||||
<view class="">
|
||||
<view @click="show = true">
|
||||
<slot v-if="$slots.default"> </slot>
|
||||
<view v-else class="choose-goods u-flex u-row-between">
|
||||
<text class="color-999" v-if="!modelValue">请选择商品</text>
|
||||
<text class="color-333 u-m-r-32 u-line-1" v-else>{{ goodsName }}</text>
|
||||
<up-icon size="14" name="arrow-down"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<up-popup :show="show" mode="bottom">
|
||||
<view class="">
|
||||
<view class="top u-flex u-row-between">
|
||||
<text class="font-bold u-font-32 color-333">{{ title }}</text>
|
||||
<up-icon size="18" name="close" @click="show = false"></up-icon>
|
||||
</view>
|
||||
<scroll-view :scroll-y="true" style="max-height: 50vh" @scroll="scroll" :scroll-top="scrollTop">
|
||||
<view
|
||||
v-for="(item, index) in list"
|
||||
:key="index"
|
||||
class="item"
|
||||
@click="itemClick(item)"
|
||||
:class="[selGoods&&selGoods.id == item.id ? 'selected' : '']"
|
||||
>
|
||||
<view class="u-flex u-row-between">
|
||||
<view class="u-flex gap-20">
|
||||
<view class="u-flex" @click.stop="preview(item)">
|
||||
<up-image
|
||||
:src="item.coverImg"
|
||||
width="80rpx"
|
||||
height="80rpx"
|
||||
></up-image>
|
||||
</view>
|
||||
|
||||
<text class="u-font-32 color-333">{{ item.name }}</text>
|
||||
</view>
|
||||
<text class="u-font-32 color-red u-p-l-30"
|
||||
>¥{{ item.lowPrice }}</text
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class="bottom">
|
||||
<view class="btn cancel" @click="close">{{ cancelText }}</view>
|
||||
<view class="btn success" @click="confirm">{{ confirmText }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</up-popup>
|
||||
</view>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, onMounted, watch } from "vue";
|
||||
import { getProductList } from "@/http/api/product.js";
|
||||
const show = ref(false);
|
||||
const modelValue = defineModel({
|
||||
type: String,
|
||||
default: "",
|
||||
});
|
||||
|
||||
const goodsName = defineModel("goodsName", {
|
||||
type: String,
|
||||
default: "",
|
||||
});
|
||||
|
||||
const props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
default: "选择商品",
|
||||
},
|
||||
confirmText: {
|
||||
type: String,
|
||||
default: "确认",
|
||||
},
|
||||
cancelText: {
|
||||
type: String,
|
||||
default: "取消",
|
||||
},
|
||||
});
|
||||
|
||||
const selGoods = ref("");
|
||||
function itemClick(item) {
|
||||
if (selGoods.value&& selGoods.value.id == item.id) {
|
||||
selGoods.value = "";
|
||||
return;
|
||||
}
|
||||
selGoods.value = item;
|
||||
}
|
||||
const list = ref([]);
|
||||
|
||||
const scrollTop = ref(0);
|
||||
function scroll(e) {
|
||||
scrollTop.value = e.detail.scrollTop;
|
||||
}
|
||||
function preview(item) {
|
||||
uni.previewImage({
|
||||
urls: item.images || [item.coverImg],
|
||||
});
|
||||
}
|
||||
watch(
|
||||
() => modelValue.value,
|
||||
(newVal, oldVal) => {
|
||||
console.log(newVal, oldVal);
|
||||
selGoods.value = list.value.find((item) => item.id == newVal);
|
||||
console.log(selGoods.value);
|
||||
if(selGoods.value){
|
||||
goodsName.value = selGoods.value.name;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(()=>list.value.length,(newVal,oldVal)=>{
|
||||
selGoods.value = list.value.find((item) => item.id == modelValue.value);
|
||||
console.log(selGoods.value);
|
||||
if(selGoods.value){
|
||||
modelValue.value = selGoods.value.id;
|
||||
goodsName.value = selGoods.value.name;
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
function close() {
|
||||
show.value = false;
|
||||
}
|
||||
function confirm() {
|
||||
if (!selGoods.value) {
|
||||
uni.showToast({
|
||||
title: "请选择商品",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
modelValue.value = selGoods.value.id;
|
||||
show.value = false;
|
||||
}
|
||||
onMounted(() => {
|
||||
getProductList().then((res) => {
|
||||
list.value = res;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.popup-content {
|
||||
background: #fff;
|
||||
width: 640rpx;
|
||||
border-radius: 18rpx;
|
||||
}
|
||||
.top {
|
||||
padding: 40rpx 48rpx;
|
||||
border-bottom: 1px solid #d9d9d9;
|
||||
}
|
||||
.bottom {
|
||||
padding: 48rpx 52rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
border-top: 1px solid #d9d9d9;
|
||||
gap: 50rpx;
|
||||
.btn {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
padding: 18rpx 60rpx;
|
||||
border-radius: 100rpx;
|
||||
font-size: 32rpx;
|
||||
border: 2rpx solid transparent;
|
||||
&.success {
|
||||
background-color: $my-main-color;
|
||||
color: #fff;
|
||||
}
|
||||
&.cancel {
|
||||
border-color: #d9d9d9;
|
||||
box-shadow: 0 4rpx 0 0 #00000005;
|
||||
}
|
||||
}
|
||||
}
|
||||
.item {
|
||||
padding: 10rpx 30rpx;
|
||||
border: 1px solid #d9d9d9;
|
||||
margin: 10rpx;
|
||||
border-radius: 8rpx;
|
||||
transition: all 0.3s ease-in-out;
|
||||
box-shadow: 0 0 10px transparent;
|
||||
&.selected {
|
||||
border-color: $my-main-color;
|
||||
box-shadow: 0 0 10px $my-main-color;
|
||||
}
|
||||
}
|
||||
.choose-goods {
|
||||
display: flex;
|
||||
padding: 24rpx;
|
||||
align-items: center;
|
||||
border-radius: 8rpx;
|
||||
border: 2rpx solid #d9d9d9;
|
||||
background: #fff;
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
}
|
||||
</style>
|
||||
92
pageChat/components/coupon-list.vue
Normal file
92
pageChat/components/coupon-list.vue
Normal file
@@ -0,0 +1,92 @@
|
||||
<template>
|
||||
<view>
|
||||
<view
|
||||
class="u-flex u-row-between u-m-b-24"
|
||||
style="gap: 40rpx"
|
||||
v-for="(item, index) in modelValue"
|
||||
:key="index"
|
||||
>
|
||||
<view
|
||||
class="choose-coupon u-flex-1 u-flex u-row-between"
|
||||
@click="showCoupon(item, index)"
|
||||
>
|
||||
<template v-if="item.title">
|
||||
<text>{{ item.title }}</text>
|
||||
<view class="u-flex" @click.stop="item.title = ''">
|
||||
<up-icon name="close" size="14"></up-icon>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<text class="color-999">选择赠送券</text>
|
||||
<up-icon name="arrow-down" size="14"></up-icon>
|
||||
</template>
|
||||
</view>
|
||||
<view class="u-flex-1 u-flex">
|
||||
<view class="u-flex-1 choose-coupon u-flex">
|
||||
<input
|
||||
class="u-flex-1"
|
||||
placeholder=""
|
||||
type="number"
|
||||
v-model="item.num"
|
||||
placeholder-class="color-999 u-font-28"
|
||||
/>
|
||||
<text class="no-wrap color-999">张/1个码</text>
|
||||
</view>
|
||||
<view class="u-m-l-20">
|
||||
<up-icon name="minus-circle-fill" color="#EB4F4F" size="18" @click="removeCoupon(index)"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<chooseCoupon
|
||||
v-model="chooseCouponData.couponId"
|
||||
v-model:show="chooseCouponData.show"
|
||||
@confirm="confirmCoupon"
|
||||
:list="couponList"
|
||||
></chooseCoupon>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, ref, onMounted } from "vue";
|
||||
import chooseCoupon from "./choose-coupon.vue";
|
||||
import { couponPage } from "@/http/api/market/index.js";
|
||||
|
||||
const chooseCouponData = reactive({
|
||||
couponId: "",
|
||||
show: false,
|
||||
index: -1,
|
||||
item: null,
|
||||
});
|
||||
const modelValue = defineModel({
|
||||
type: Array,
|
||||
default: () => [],
|
||||
});
|
||||
const couponList = ref([]);
|
||||
function showCoupon(item, index) {
|
||||
chooseCouponData.couponId = item ? item.id : "";
|
||||
chooseCouponData.show = true;
|
||||
chooseCouponData.index = index;
|
||||
chooseCouponData.item = item;
|
||||
}
|
||||
function confirmCoupon(e) {
|
||||
modelValue.value[chooseCouponData.index].id = e.id;
|
||||
modelValue.value[chooseCouponData.index].title = e.title;
|
||||
}
|
||||
function removeCoupon(index) {
|
||||
modelValue.value.splice(index, 1);
|
||||
}
|
||||
onMounted(() => {
|
||||
couponPage({ size: 999 }).then((res) => {
|
||||
couponList.value = res.records;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.choose-coupon {
|
||||
padding: 10rpx 20rpx;
|
||||
border-radius: 8rpx;
|
||||
border: 1px solid #d9d9d9;
|
||||
}
|
||||
</style>
|
||||
75
pageChat/components/coupon.vue
Normal file
75
pageChat/components/coupon.vue
Normal file
@@ -0,0 +1,75 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="u-flex u-row-between u-m-b-24" style="gap: 40rpx">
|
||||
<view
|
||||
class="choose-coupon u-flex-1 u-flex u-row-between"
|
||||
@click="showCoupon(item, index)"
|
||||
>
|
||||
<template v-if="couponName">
|
||||
<text>{{ couponName }}</text>
|
||||
<view class="u-flex" @click.stop="modelValue = ''">
|
||||
<up-icon name="close" size="14"></up-icon>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<text class="color-999">选择赠送券</text>
|
||||
<up-icon name="arrow-down" size="14"></up-icon>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
<chooseCoupon
|
||||
v-model="chooseCouponData.couponId"
|
||||
v-model:show="chooseCouponData.show"
|
||||
@confirm="confirmCoupon"
|
||||
:list="couponList"
|
||||
></chooseCoupon>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, ref, onMounted, computed } from "vue";
|
||||
import chooseCoupon from "./choose-coupon.vue";
|
||||
import { chatCoupon } from "@/http/api/market/chatCoupon.js";
|
||||
|
||||
const chooseCouponData = reactive({
|
||||
couponId: "",
|
||||
show: false,
|
||||
index: -1,
|
||||
item: null,
|
||||
});
|
||||
const modelValue = defineModel({
|
||||
default: "",
|
||||
});
|
||||
|
||||
const couponName = computed(() => {
|
||||
if (modelValue.value) {
|
||||
const item = couponList.value.find((item) => item.id === modelValue.value);
|
||||
return item?.title || "";
|
||||
}
|
||||
return "";
|
||||
});
|
||||
const couponList = ref([]);
|
||||
function showCoupon(item, index) {
|
||||
chooseCouponData.couponId = modelValue.value;
|
||||
chooseCouponData.show = true;
|
||||
}
|
||||
function confirmCoupon(e) {
|
||||
modelValue.value=e.id
|
||||
}
|
||||
function removeCoupon(index) {
|
||||
modelValue.value.splice(index, 1);
|
||||
}
|
||||
onMounted(() => {
|
||||
chatCoupon({ size: 999 }).then((res) => {
|
||||
couponList.value = res.records;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.choose-coupon {
|
||||
padding: 10rpx 20rpx;
|
||||
border-radius: 8rpx;
|
||||
border: 1px solid #d9d9d9;
|
||||
}
|
||||
</style>
|
||||
108
pageChat/components/date-time-picker.vue
Normal file
108
pageChat/components/date-time-picker.vue
Normal file
@@ -0,0 +1,108 @@
|
||||
<template>
|
||||
<view>
|
||||
<view @click="open">
|
||||
<slot v-if="$slots.default"> </slot>
|
||||
<view v-else class="choose-goods u-flex u-row-between">
|
||||
<text class="color-999" v-if="!startTime && !endTime"
|
||||
>请选择日期范围</text
|
||||
>
|
||||
<text class="color-333 u-font-24 u-m-r-32 " v-else
|
||||
>{{ startTime }} - {{ endTime }}</text
|
||||
>
|
||||
<view class="u-flex" v-if="startTime&&endTime" @click.stop="clear">
|
||||
<up-icon name="close" size="14"></up-icon>
|
||||
</view>
|
||||
<up-icon size="14" name="arrow-right" v-else ></up-icon>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<my-date-pickerview
|
||||
@confirm="datePickerConfirm"
|
||||
mode="all"
|
||||
ref="datePicker"
|
||||
></my-date-pickerview>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
const datePicker = ref(null);
|
||||
const startTime = defineModel("startTime", {
|
||||
default: () => "",
|
||||
type: String,
|
||||
});
|
||||
const endTime = defineModel("endTime", {
|
||||
default: () => "",
|
||||
type: String,
|
||||
});
|
||||
|
||||
function clear(){
|
||||
startTime.value = "";
|
||||
endTime.value = "";
|
||||
}
|
||||
function open() {
|
||||
datePicker.value.toggle();
|
||||
}
|
||||
function datePickerConfirm(e) {
|
||||
startTime.value = e.start;
|
||||
endTime.value = e.end;
|
||||
console.log(e);
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.popup-content {
|
||||
background: #fff;
|
||||
width: 640rpx;
|
||||
border-radius: 18rpx;
|
||||
}
|
||||
.top {
|
||||
padding: 40rpx 48rpx;
|
||||
border-bottom: 1px solid #d9d9d9;
|
||||
}
|
||||
.bottom {
|
||||
padding: 48rpx 52rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
border-top: 1px solid #d9d9d9;
|
||||
gap: 50rpx;
|
||||
.btn {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
padding: 18rpx 60rpx;
|
||||
border-radius: 100rpx;
|
||||
font-size: 32rpx;
|
||||
border: 2rpx solid transparent;
|
||||
&.success {
|
||||
background-color: $my-main-color;
|
||||
color: #fff;
|
||||
}
|
||||
&.cancel {
|
||||
border-color: #d9d9d9;
|
||||
box-shadow: 0 4rpx 0 0 #00000005;
|
||||
}
|
||||
}
|
||||
}
|
||||
.item {
|
||||
padding: 10rpx 30rpx;
|
||||
border: 1px solid #d9d9d9;
|
||||
margin: 10rpx;
|
||||
border-radius: 8rpx;
|
||||
transition: all 0.3s ease-in-out;
|
||||
box-shadow: 0 0 10px transparent;
|
||||
&.selected {
|
||||
border-color: $my-main-color;
|
||||
box-shadow: 0 0 10px $my-main-color;
|
||||
}
|
||||
}
|
||||
.choose-goods {
|
||||
display: flex;
|
||||
padding: 24rpx;
|
||||
align-items: center;
|
||||
border-radius: 8rpx;
|
||||
border: 2rpx solid #d9d9d9;
|
||||
background: #fff;
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
min-height: 90rpx;
|
||||
}
|
||||
</style>
|
||||
85
pageChat/components/modal.vue
Normal file
85
pageChat/components/modal.vue
Normal file
@@ -0,0 +1,85 @@
|
||||
<template>
|
||||
<view>
|
||||
<up-popup :show="show" mode="center">
|
||||
<view class="popup-content">
|
||||
<view class="top u-flex u-row-between">
|
||||
<text class="font-bold u-font-32 color-333">{{ title }}</text>
|
||||
<up-icon size="18" name="close" @click="close"></up-icon>
|
||||
</view>
|
||||
<up-line></up-line>
|
||||
<scroll-view style="max-height: 50vh" :scroll-y="true">
|
||||
<slot></slot>
|
||||
</scroll-view>
|
||||
<up-line></up-line>
|
||||
|
||||
<view class="bottom">
|
||||
<view class="btn cancel" @click="close">{{ cancelText }}</view>
|
||||
<view class="btn success" @click="confirm">{{ confirmText }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</up-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
const props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
default: "标题",
|
||||
},
|
||||
confirmText: {
|
||||
type: String,
|
||||
default: "保存",
|
||||
},
|
||||
cancelText: {
|
||||
type: String,
|
||||
default: "取消",
|
||||
},
|
||||
});
|
||||
const show = defineModel({
|
||||
type: Boolean,
|
||||
default: false,
|
||||
});
|
||||
const emits = defineEmits(["close", "confirm"]);
|
||||
function close() {
|
||||
show.value = false;
|
||||
emits("close");
|
||||
}
|
||||
function confirm() {
|
||||
emits("confirm");
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.popup-content {
|
||||
background: #fff;
|
||||
width: 640rpx;
|
||||
border-radius: 18rpx;
|
||||
}
|
||||
.top {
|
||||
padding: 40rpx 48rpx;
|
||||
}
|
||||
.bottom {
|
||||
padding: 48rpx 52rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 50rpx;
|
||||
.btn {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
padding: 18rpx 60rpx;
|
||||
border-radius: 100rpx;
|
||||
font-size: 32rpx;
|
||||
border: 2rpx solid transparent;
|
||||
white-space: nowrap;
|
||||
&.success {
|
||||
background-color: $my-main-color;
|
||||
color: #fff;
|
||||
}
|
||||
&.cancel {
|
||||
border-color: #d9d9d9;
|
||||
box-shadow: 0 4rpx 0 0 #00000005;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
49
pageChat/components/shop-sel-action-sheet.vue
Normal file
49
pageChat/components/shop-sel-action-sheet.vue
Normal file
@@ -0,0 +1,49 @@
|
||||
<template>
|
||||
<view>
|
||||
<up-action-sheet
|
||||
:round="14"
|
||||
:actions="list"
|
||||
:title="title"
|
||||
:show="show"
|
||||
closeOnClickAction
|
||||
cancelText="取消"
|
||||
@close="close"
|
||||
@select="sheetSelect"
|
||||
></up-action-sheet>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup >
|
||||
import { ref, reactive, onMounted } from "vue";
|
||||
import { getShopList } from "@/http/api/shop.js";
|
||||
|
||||
const props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
default: "请选择",
|
||||
},
|
||||
});
|
||||
const list = ref([]);
|
||||
const show=defineModel({
|
||||
name: "show",
|
||||
default: false,
|
||||
})
|
||||
function close() {
|
||||
show.value = false;
|
||||
}
|
||||
|
||||
const emit=defineEmits(["choose"]);
|
||||
function sheetSelect(e) {
|
||||
console.log(e);
|
||||
emit("choose", e);
|
||||
}
|
||||
onMounted(() => {
|
||||
getShopList().then((res) => {
|
||||
list.value = res.map((v) => ({
|
||||
...v,
|
||||
value: v.shopId,
|
||||
name: v.shopName,
|
||||
}));
|
||||
});
|
||||
});
|
||||
</script>
|
||||
184
pageChat/coupon-activity/detail.vue
Normal file
184
pageChat/coupon-activity/detail.vue
Normal file
@@ -0,0 +1,184 @@
|
||||
<template>
|
||||
<view class="min-page bg-f7 u-font-28 color-333 u-p-t-32">
|
||||
<view class="bg-fff">
|
||||
<view class="default-box u-flex u-row-between border-bottom">
|
||||
<text class="font-bold">优惠券名称</text>
|
||||
<text>{{ couponActivity.couponJson.couponName }}</text>
|
||||
</view>
|
||||
<view class="default-box u-flex u-row-between border-bottom">
|
||||
<text class="font-bold">发放数量</text>
|
||||
<text>{{ couponActivity.giveNum }}</text>
|
||||
</view>
|
||||
<view class="default-box u-flex u-row-between border-bottom">
|
||||
<text class="font-bold">已领取数量</text>
|
||||
<text>{{ couponActivity.giveNum - couponActivity.leftNum }}</text>
|
||||
</view>
|
||||
<view class="default-box u-flex u-row-between border-bottom">
|
||||
<text class="font-bold">剩余数量</text>
|
||||
<text>{{ couponActivity.leftNum }}</text>
|
||||
</view>
|
||||
<view class="default-box u-flex u-row-between border-bottom">
|
||||
<text class="font-bold">已使用数量</text>
|
||||
<text>{{ couponActivity.useNum }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="u-flex u-row-right default-box u-p-r-32 bg-fff">
|
||||
<up-select
|
||||
:options="statusOptions"
|
||||
@select="selectItem"
|
||||
labelName="label"
|
||||
>
|
||||
<template #text>
|
||||
<view class="select">
|
||||
<text v-if="selStatus">{{ selStatus.label }}</text>
|
||||
<text v-else class="color-999">请选择状态</text>
|
||||
<up-icon name="arrow-down"></up-icon>
|
||||
</view>
|
||||
</template>
|
||||
<template #icon> <view></view></template>
|
||||
</up-select>
|
||||
</view>
|
||||
|
||||
<view class="u-m-t-32 table bg-fff">
|
||||
<view class="header">
|
||||
<view class="user">用户</view>
|
||||
<view class="gettime">领取时间</view>
|
||||
<view class="usetime">使用时间</view>
|
||||
<view class="status">状态</view>
|
||||
<view class="operation">操作</view>
|
||||
</view>
|
||||
<view class="body">
|
||||
<view class="item" v-for="(item,index) in 10" :key="index">
|
||||
<view class="user">用户昵称(40239)</view>
|
||||
<view class="gettime">2025/06/27 20:07:18)</view>
|
||||
<view class="usetime">2025/01/15 08:02:38</view>
|
||||
<view class="status">已使用</view>
|
||||
<view class="operation status3">失效</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<up-loadmore :status="isEnd ? 'nomore' : 'loading'"></up-loadmore>
|
||||
<view style="height: 40px"></view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
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";
|
||||
const statusOptions = ref([
|
||||
{ label: "全部", value: "" },
|
||||
{ label: "未使用", value: 0 },
|
||||
{ label: "已使用", value: 1 },
|
||||
{ label: "已过期", value: 2 },
|
||||
]);
|
||||
const selStatus = ref("");
|
||||
const query = reactive({
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
status: "",
|
||||
});
|
||||
const options = reactive({
|
||||
id: "",
|
||||
});
|
||||
|
||||
function selectItem(item) {
|
||||
selStatus.value = item;
|
||||
}
|
||||
|
||||
watch(
|
||||
() => selStatus.value,
|
||||
(newVal, oldVal) => {
|
||||
query.status = newVal.value;
|
||||
refresh();
|
||||
}
|
||||
);
|
||||
|
||||
function refresh() {
|
||||
query.page = 1;
|
||||
isEnd.value = false;
|
||||
getList();
|
||||
}
|
||||
|
||||
const couponActivity = ref({});
|
||||
|
||||
const list = ref([]);
|
||||
const isEnd = ref(false);
|
||||
function getList() {
|
||||
chatCouponApi.chatCouponRecord({ ...query, id: options.id }).then((res) => {
|
||||
if (query.page == 1) {
|
||||
list.value = res.records;
|
||||
} else {
|
||||
list.value.push(...res.records);
|
||||
}
|
||||
isEnd.value = query.page >= res.totalPage * 1;
|
||||
});
|
||||
}
|
||||
|
||||
onReachBottom(() => {
|
||||
if (!isEnd.value) {
|
||||
query.page++;
|
||||
getList();
|
||||
}
|
||||
});
|
||||
onLoad((opt) => {
|
||||
Object.assign(options, opt);
|
||||
const item = uni.getStorageSync("cach_couponActivity");
|
||||
couponActivity.value = item || {};
|
||||
console.log(item);
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.default-box {
|
||||
padding: 24rpx 28rpx;
|
||||
}
|
||||
.select {
|
||||
padding: 20rpx;
|
||||
border-radius: 8rpx;
|
||||
border: 2rpx solid #d9d9d9;
|
||||
min-width: 322rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.table{
|
||||
.user{
|
||||
width: 142rpx;
|
||||
}
|
||||
.gettime{
|
||||
width: 172rpx;
|
||||
}
|
||||
.usetime{
|
||||
width: 158rpx;
|
||||
}
|
||||
.status{
|
||||
width: 84rpx;
|
||||
}
|
||||
.operation{
|
||||
width: 56rpx;
|
||||
&.status3{
|
||||
color: #FF383C;
|
||||
}
|
||||
}
|
||||
.header{
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 32rpx 16rpx;
|
||||
color: #666;
|
||||
border-bottom: 1px solid #E5E5E5;
|
||||
}
|
||||
.body{
|
||||
.item{
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 24rpx 16rpx;
|
||||
border-bottom: 1px solid #E5E5E5;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
252
pageChat/coupon-activity/index.vue
Normal file
252
pageChat/coupon-activity/index.vue
Normal file
@@ -0,0 +1,252 @@
|
||||
<template>
|
||||
<view class="min-page bg-f7">
|
||||
<up-sticky>
|
||||
<view class="top">
|
||||
<my-tabs
|
||||
:list="tabs.list"
|
||||
v-model="tabs.selIndex"
|
||||
@change="tabsChange"
|
||||
textKey="label"
|
||||
></my-tabs>
|
||||
</view>
|
||||
</up-sticky>
|
||||
|
||||
<view class="list">
|
||||
<view class="item" v-for="(item, index) in list" :key="index">
|
||||
<view class="u-flex u-row-between">
|
||||
<view>{{ item.couponJson.couponName }}</view>
|
||||
|
||||
<view class="u-flex">
|
||||
<view class="status" :class="['status' + item.status]">{{
|
||||
returnStateText(item)
|
||||
}}</view>
|
||||
<view class="Id">ID:{{ item.id }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-28 desc">
|
||||
<view class="u-flex">
|
||||
<text class="color-666 text-right u-m-r-48" style="min-width: 96rpx"
|
||||
>使用门槛</text
|
||||
>
|
||||
<text class="color-333"
|
||||
>满{{ item.couponJson.fullAmount }}元可用</text
|
||||
>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-16">
|
||||
<text class="color-666 text-right u-m-r-48" style="min-width: 96rpx"
|
||||
>有效期</text
|
||||
>
|
||||
<text class="color-333"
|
||||
>领券后{{ item.couponJson.validDays }}天过期</text
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-24">
|
||||
<view
|
||||
class="u-flex u-flex-col u-row-center u-font-24 u-col-center text-center"
|
||||
>
|
||||
<view class="color-333 font-bold">{{ item.giveNum }}</view>
|
||||
<view class="color-666 u-m-t-16">发放数量</view>
|
||||
</view>
|
||||
<view
|
||||
class="u-flex u-flex-col u-row-center u-font-24 u-col-center text-center"
|
||||
>
|
||||
<view class="color-333 font-bold">{{
|
||||
item.giveNum - item.leftNum
|
||||
}}</view>
|
||||
<view class="color-666 u-m-t-16">已领取</view>
|
||||
</view>
|
||||
|
||||
<view
|
||||
class="u-flex u-flex-col u-row-center u-font-24 u-col-center text-center"
|
||||
>
|
||||
<view class="color-333 font-bold">{{ item.leftNum }}</view>
|
||||
<view class="color-666 u-m-t-16">剩余</view>
|
||||
</view>
|
||||
|
||||
<view
|
||||
class="u-flex u-flex-col u-row-center u-font-24 u-col-center text-center"
|
||||
>
|
||||
<view class="color-333 font-bold">{{ item.useNum }}</view>
|
||||
<view class="color-666 u-m-t-16">已使用</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-16 u-flex u-row-right" style="gap: 16rpx">
|
||||
<view class="btn cancel" @click="cancel(item)">失效</view>
|
||||
<view class="btn primary" @click="toDetail(item)"> 查看</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<up-loadmore :status="isEnd ? 'nomore' : 'loading'"></up-loadmore>
|
||||
<view style="height: 40px"></view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onReachBottom } 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";
|
||||
function toDetail(item) {
|
||||
uni.setStorageSync("cach_couponActivity", item);
|
||||
go.to("PAGES_CHAT_COUPON_ACTIVITY_DETAIL", {
|
||||
id: item.id,
|
||||
});
|
||||
}
|
||||
const tabs = reactive({
|
||||
list: [
|
||||
{
|
||||
label: "全部",
|
||||
value: "",
|
||||
},
|
||||
{
|
||||
label: "发放中",
|
||||
value: 1,
|
||||
},
|
||||
{
|
||||
label: "已失效",
|
||||
value: 3,
|
||||
},
|
||||
],
|
||||
selIndex: 0,
|
||||
});
|
||||
|
||||
const query = reactive({
|
||||
page: 1,
|
||||
size: 10,
|
||||
});
|
||||
function cancelChatCoupon(item) {
|
||||
chatCouponApi.chatCouponExpired(item.id).then((res) => {
|
||||
if (res) {
|
||||
uni.showToast({
|
||||
title: "操作成功",
|
||||
icon: "none",
|
||||
});
|
||||
refresh();
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: "取消失败",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
function cancel(item) {
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "确定取消该优惠券吗?",
|
||||
confirmText: "确定",
|
||||
cancelText: "取消",
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
cancelChatCoupon(item);
|
||||
} else if (res.cancel) {
|
||||
console.log("用户点击取消");
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
function returnStateText(item) {
|
||||
if (item.status == 1) {
|
||||
return "发放中";
|
||||
} else if (item.status == 3) {
|
||||
return "已失效";
|
||||
}
|
||||
}
|
||||
function tabsChange(e) {
|
||||
tabs.selIndex = e;
|
||||
refresh();
|
||||
}
|
||||
function refresh() {
|
||||
query.page = 1;
|
||||
isEnd.value = false;
|
||||
init();
|
||||
}
|
||||
const list = ref([]);
|
||||
|
||||
const isEnd = ref(false);
|
||||
function init() {
|
||||
chatCouponApi
|
||||
.chatCouponPage({ ...query, status: tabs.list[tabs.selIndex].value })
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
const arr = (res.records || []).map((v) => {
|
||||
return {
|
||||
...v,
|
||||
couponJson: JSON.parse(v.couponJson),
|
||||
};
|
||||
});
|
||||
if (query.page == 1) {
|
||||
list.value = arr;
|
||||
} else {
|
||||
list.value.push(...arr);
|
||||
}
|
||||
console.log(list.value);
|
||||
isEnd.value = query.page >= res.totalPage * 1;
|
||||
});
|
||||
}
|
||||
onReachBottom(() => {
|
||||
if (!isEnd.value) {
|
||||
query.page++;
|
||||
init();
|
||||
}
|
||||
});
|
||||
onShow(init);
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.top {
|
||||
padding: 20rpx 62rpx;
|
||||
background-color: #fff;
|
||||
}
|
||||
.list {
|
||||
padding: 32rpx 28rpx;
|
||||
.item {
|
||||
padding: 32rpx;
|
||||
background-color: #fff;
|
||||
margin-bottom: 28rpx;
|
||||
.desc {
|
||||
padding: 32rpx 28rpx;
|
||||
background: #f8f8f8;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
.status {
|
||||
padding: 4rpx 12rpx;
|
||||
border-radius: 8rpx;
|
||||
font-size: 24rpx;
|
||||
&.status1 {
|
||||
color: rgba(52, 199, 89, 1);
|
||||
background-color: rgba(52, 199, 89, 0.15);
|
||||
}
|
||||
&.status3 {
|
||||
color: #999999;
|
||||
background-color: rgba(153, 153, 153, 0.15);
|
||||
}
|
||||
}
|
||||
.Id {
|
||||
padding: 8rpx 6rpx;
|
||||
margin-left: 36rpx;
|
||||
font-size: 18rpx;
|
||||
color: #999;
|
||||
border-radius: 4rpx;
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
}
|
||||
}
|
||||
.btn {
|
||||
padding: 8rpx 42rpx;
|
||||
border-radius: 100rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: 700;
|
||||
&.cancel {
|
||||
background-color: #f8f8f8;
|
||||
color: #999999;
|
||||
}
|
||||
&.primary {
|
||||
background-color: $my-main-color;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
179
pageChat/group-info/index.vue
Normal file
179
pageChat/group-info/index.vue
Normal file
@@ -0,0 +1,179 @@
|
||||
<template>
|
||||
<view class="min-page bg-f7 u-font-28">
|
||||
<view class="user-list bg-fff">
|
||||
<view class="u-flex u-row-between u-col-center">
|
||||
<text class="color-000">群成员(22人)</text>
|
||||
<text class="color-red" @click="showRemove = !showRemove">移除</text>
|
||||
</view>
|
||||
<view class="list u-m-t-26">
|
||||
<view
|
||||
class="u-flex u-flex-col u-row-center u-col-center relative"
|
||||
v-for="(item, index) in userLists"
|
||||
:key="index"
|
||||
>
|
||||
<up-avatar
|
||||
size="104rpx"
|
||||
shape="square"
|
||||
:src="item.avatar"
|
||||
round="8rpx"
|
||||
></up-avatar>
|
||||
<view class="u-m-t-8 color-000">{{ item.nick_name }}</view>
|
||||
<view
|
||||
class="remove u-absolute"
|
||||
v-if="showRemove && item.role != 1"
|
||||
@click="removeMember(item)"
|
||||
>
|
||||
<up-icon
|
||||
name="minus-circle-fill"
|
||||
size="24rpx"
|
||||
color="#FF2424"
|
||||
></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-center color-666 u-m-t-30" v-if="hasMore">
|
||||
<text class="u-m-r-20">查看更多</text>
|
||||
<up-icon name="arrow-down" size="24rpx" color="#666"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="bottom">
|
||||
<view class="u-flex u-row-between default-padding bg-fff border-bottom">
|
||||
<text>群聊名称</text>
|
||||
<view class="u-flex color-666">
|
||||
<text>{{ groupInfo.name }}</text>
|
||||
<up-icon name="arrow-right" size="24rpx" color="#666"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between default-padding bg-fff border-bottom">
|
||||
<view>
|
||||
<view>禁言</view>
|
||||
<view class="color-999 u-font-24">
|
||||
开启后,顾客将不能在群内发消息</view
|
||||
>
|
||||
</view>
|
||||
<up-switch
|
||||
v-model="groupInfo.is_mute"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
@change="groupMuteChange"
|
||||
></up-switch>
|
||||
</view>
|
||||
<view
|
||||
class="u-flex u-row-between default-padding bg-fff"
|
||||
@click="go.to('PAGES_CHAT_COUPON_ACTIVITY')"
|
||||
>
|
||||
<text>优惠券领取记录</text>
|
||||
<view class="u-flex color-666">
|
||||
<text class="color-main">去查看</text>
|
||||
<up-icon name="arrow-right" size="24rpx" color="#318AFE"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script setup>
|
||||
import go from "@/commons/utils/go.js";
|
||||
import * as chatApi from "@/http/php/chat";
|
||||
import { onShow, onLoad } from "@dcloudio/uni-app";
|
||||
import { reactive, toRefs, computed, watch, onMounted, ref } from "vue";
|
||||
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 groupMuteChange(e) {
|
||||
if (e) {
|
||||
chatApi
|
||||
.groupMute({
|
||||
group_id: options.group_id,
|
||||
})
|
||||
.then((res) => {
|
||||
if (res) {
|
||||
uni.showToast({
|
||||
title: "已禁言",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
chatApi
|
||||
.groupMunute({
|
||||
group_id: options.group_id,
|
||||
})
|
||||
.then((res) => {
|
||||
if (res) {
|
||||
uni.showToast({
|
||||
title: "禁言已取消",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
const showRemove = ref(false);
|
||||
let allUser = [];
|
||||
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);
|
||||
});
|
||||
}
|
||||
onShow(() => {
|
||||
getMembers();
|
||||
});
|
||||
|
||||
function removeMember(item) {
|
||||
chatApi
|
||||
.groupKick({ group_id: options.group_id, target_uid: item.user_id })
|
||||
.then((res) => {
|
||||
if (res) {
|
||||
uni.showToast({
|
||||
title: "移除成功",
|
||||
icon: "none",
|
||||
});
|
||||
setTimeout(() => {
|
||||
getMembers();
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.user-list {
|
||||
padding: 32rpx 28rpx;
|
||||
.list {
|
||||
gap: 20rpx;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, 1fr);
|
||||
}
|
||||
}
|
||||
.color-red {
|
||||
color: #ff2424;
|
||||
}
|
||||
.bottom {
|
||||
margin: 28rpx;
|
||||
border-radius: 16rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
.default-padding {
|
||||
padding: 32rpx 28rpx;
|
||||
}
|
||||
.relative {
|
||||
position: relative;
|
||||
}
|
||||
.remove {
|
||||
top: -6rpx;
|
||||
right: -6rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -1,3 +1,99 @@
|
||||
<template>
|
||||
<view></view>
|
||||
</template>
|
||||
<view class="min-page bg-f7 color-333 u-font-28">
|
||||
<up-sticky>
|
||||
<view class="top u-flex u-row-between">
|
||||
<view></view>
|
||||
<view class="u-flex" @click="clearAllmsg">
|
||||
<text class="color-666 u-m-r-12">清空未读</text>
|
||||
<image src="/pageChat/static/clear.png" class="clear"></image>
|
||||
</view>
|
||||
</view>
|
||||
</up-sticky>
|
||||
<view class="list">
|
||||
<view
|
||||
class="item u-flex"
|
||||
v-for="(item, index) in list"
|
||||
:key="item.id"
|
||||
@click="toDetail(item)"
|
||||
>
|
||||
<view class="u-flex">
|
||||
<up-avatar
|
||||
size="118rpx"
|
||||
:src="item.avatar"
|
||||
shape="square"
|
||||
round="8rpx"
|
||||
></up-avatar>
|
||||
</view>
|
||||
<view class="u-flex-1 u-flex u-row-between u-p-l-14">
|
||||
<view style="max-width: 364rpx">
|
||||
<view class="color-000 u-line-1">{{ item.name }}</view>
|
||||
<view class="u-m-t-28 u-line-1 u-font-24 color-999"
|
||||
>用户昵称:这里是消息内容这里,,,,</view
|
||||
>
|
||||
</view>
|
||||
<view class="color-333 u-font-24">{{ item.send_time }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import go from "@/commons/utils/go.js";
|
||||
|
||||
import * as chatApi from "@/http/php/chat";
|
||||
import { ref } from "vue";
|
||||
import { onShow } from "@dcloudio/uni-app";
|
||||
const list = ref([]);
|
||||
|
||||
async function getList() {
|
||||
const res = await chatApi.messageSessionList({});
|
||||
list.value = (res.list || []).filter(v=>!v.is_del)
|
||||
}
|
||||
|
||||
async function clearAllmsg() {
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "确定要清空所有消息吗?",
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
const res = await chatApi.clearAllmsg({});
|
||||
if (res) {
|
||||
uni.showToast({
|
||||
title: "清空成功",
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
getList();
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function toDetail(item) {
|
||||
go.to("PAGES_CHAT_CHAT", { group_id: item.group_id,session_id: item.session_id });
|
||||
}
|
||||
|
||||
onShow(getList);
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.top {
|
||||
padding: 32rpx 28rpx;
|
||||
background-color: #fff;
|
||||
}
|
||||
.clear {
|
||||
width: 38rpx;
|
||||
height: 38rpx;
|
||||
}
|
||||
.list {
|
||||
padding: 36rpx 28rpx;
|
||||
.item {
|
||||
padding: 32rpx 28rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
BIN
pageChat/static/clear.png
Normal file
BIN
pageChat/static/clear.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
BIN
pageChat/static/coupon.png
Normal file
BIN
pageChat/static/coupon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
BIN
pageChat/static/pic.png
Normal file
BIN
pageChat/static/pic.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
BIN
pageChat/static/video.png
Normal file
BIN
pageChat/static/video.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
40
pages.json
40
pages.json
@@ -827,6 +827,46 @@
|
||||
"navigationBarTitleText": "分销"
|
||||
}
|
||||
}]
|
||||
},
|
||||
{
|
||||
"root":"pageChat",
|
||||
"pages": [{
|
||||
"pageId": "PAGES_CHAT_INDEX",
|
||||
"path": "index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "消息"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pageId": "PAGES_CHAT_CHAT",
|
||||
"path": "chat",
|
||||
"style": {
|
||||
"navigationBarTitleText": "群聊"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pageId": "PAGES_CHAT_GROUP_INFO",
|
||||
"path": "group-info/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "群管理"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pageId": "PAGES_CHAT_COUPON_ACTIVITY",
|
||||
"path": "coupon-activity/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "优惠券管理"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pageId": "PAGES_CHAT_COUPON_ACTIVITY_DETAIL",
|
||||
"path": "coupon-activity/detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "查看优惠券"
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
|
||||
],
|
||||
|
||||
@@ -194,7 +194,6 @@
|
||||
*/
|
||||
const getCode = () => {
|
||||
authCaptcha().then(res => {
|
||||
console.log(res)
|
||||
vdata.formData.img = res.code
|
||||
vdata.formData.uuid = res.uuid
|
||||
})
|
||||
|
||||
@@ -78,12 +78,26 @@
|
||||
},
|
||||
async init() {
|
||||
const res = await menusStore.getMenus()
|
||||
this.tabbar = res.filter(v => v.type == 0 && v.children.length && !v.hidden).map(v => {
|
||||
const arr=res.filter(v => v.type == 0 && v.children.length && !v.hidden).map(v => {
|
||||
return {
|
||||
...v,
|
||||
children: v.children.filter(child => child.type == 0 && !child.hidden)
|
||||
}
|
||||
})
|
||||
arr.push({
|
||||
title: '群聊管理',
|
||||
miniIcon: '',
|
||||
miniPath: '',
|
||||
type: 0,
|
||||
children: [
|
||||
{
|
||||
title:'群聊管理',
|
||||
miniIcon:'https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/3/ef5566de3c10411e96fa4213381836a9.png',
|
||||
miniPath:'pageChat/index',
|
||||
}
|
||||
]
|
||||
})
|
||||
this.tabbar = arr
|
||||
console.log(this.tabbar);
|
||||
},
|
||||
// 点击左边的栏目切换
|
||||
|
||||
@@ -1,17 +1,103 @@
|
||||
import { defineStore } from "pinia";
|
||||
// import * as shopApi from "@/http/api/shop.js";
|
||||
|
||||
// #ifdef H5
|
||||
const socketUrl = "http://192.168.1.42:2348";
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
const socketUrl = "ws://192.168.1.42:2348";
|
||||
// #endif
|
||||
|
||||
// 聊天
|
||||
export const useChatStore = defineStore("chat", {
|
||||
state: () => {
|
||||
return {
|
||||
socketUrl,
|
||||
isConnect: false,
|
||||
socketTask: null,
|
||||
onReceiveMsg:()=>{
|
||||
|
||||
},
|
||||
chatList: [],
|
||||
};
|
||||
},
|
||||
actions: {
|
||||
sendMessage(message) {
|
||||
this.chatList.push(message);
|
||||
init() {
|
||||
if (!this.isConnect) {
|
||||
return uni.showToast({
|
||||
title: "请先连接socket",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
this.sendMessage(
|
||||
{
|
||||
type: "OnbocChat",
|
||||
operate_type: "init",
|
||||
shop_id: uni.getStorageSync("shopId"),
|
||||
token: uni.getStorageSync("iToken").tokenValue || "",
|
||||
},
|
||||
false
|
||||
);
|
||||
},
|
||||
sendMessage(msg, isAutoAppend = true) {
|
||||
if (!this.isConnect) {
|
||||
return uni.showToast({
|
||||
title: "请先连接socket",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
console.log(this.socketTask);
|
||||
const message = isAutoAppend
|
||||
? {
|
||||
type: "OnbocChat",
|
||||
operate_type: "sendMsg",
|
||||
shop_id: uni.getStorageSync("shopId"),
|
||||
token: uni.getStorageSync("iToken").tokenValue || "",
|
||||
...msg,
|
||||
}
|
||||
: msg;
|
||||
this.socketTask.send({
|
||||
data: JSON.stringify(message),
|
||||
success: (res) => {
|
||||
console.log("发送成功", res);
|
||||
},
|
||||
fail: (error) => {
|
||||
console.log("发送失败", error);
|
||||
},
|
||||
});
|
||||
},
|
||||
connectSocket() {
|
||||
this.socketTask = uni.connectSocket({
|
||||
url: socketUrl,
|
||||
success: (res) => {},
|
||||
fail: (res) => {
|
||||
console.log(res);
|
||||
},
|
||||
});
|
||||
|
||||
this.socketTask.onOpen((res) => {
|
||||
this.isConnect = true;
|
||||
this.init();
|
||||
});
|
||||
|
||||
this.socketTask.onMessage((res) => {
|
||||
const data = JSON.parse(res.data);
|
||||
console.log("收到服务器消息", data);
|
||||
if(data.msg){
|
||||
uni.showToast({
|
||||
title: data.msg,
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
|
||||
if(data&&data.operate_type=="sendMsg"){
|
||||
this.chatList.unshift(data.data);
|
||||
this.onReceiveMsg(data.data);
|
||||
console.log(this.chatList);
|
||||
}
|
||||
|
||||
});
|
||||
},
|
||||
},
|
||||
unistorage: true, // 开启后对 state 的数据读写都将持久化
|
||||
unistorage: false, // 开启后对 state 的数据读写都将持久化
|
||||
});
|
||||
|
||||
@@ -7,11 +7,17 @@ export default defineConfig({
|
||||
],
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
'/javaapi': {
|
||||
// target: 'https://cashier.sxczgkj.com', // 目标服务器地址
|
||||
target: 'http://192.168.1.42/', // 目标服务器地址
|
||||
changeOrigin: true, // 是否更改请求源
|
||||
rewrite: path => path.replace(/^\/api/, '')
|
||||
rewrite: path => path.replace(/^\/javaapi/, '')
|
||||
},
|
||||
'/phpapi': {
|
||||
// target: 'https://cashier.sxczgkj.com', // 目标服务器地址
|
||||
target: 'http://192.168.1.42:8787/', // 目标服务器地址
|
||||
changeOrigin: true, // 是否更改请求源
|
||||
rewrite: path => path.replace(/^\/phpapi/, '')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user