优化聊天头像大小
This commit is contained in:
@@ -1,104 +1,72 @@
|
||||
<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">({{ membersRes.user_list.length }}人)</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" -->
|
||||
<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">({{ membersRes.user_list.length }}人)</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 ||
|
||||
item.from_id == shopInfo.id
|
||||
"
|
||||
>
|
||||
<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
|
||||
class="text-center u-m-t-20"
|
||||
v-if="item.msg_type == 4 && item.hasGet"
|
||||
>
|
||||
<text>{{ item.hasGet || 0 }}人已领取</text>
|
||||
<text class="color-main">优惠券</text>
|
||||
</view>
|
||||
</view>
|
||||
<up-avatar
|
||||
size="122rpx"
|
||||
shape="square"
|
||||
bg-color="#fff"
|
||||
:src="shopInfo.logo"
|
||||
></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 }}</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>
|
||||
<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 || item.from_id == shopInfo.id">
|
||||
<view class="shop u-flex u-row-right">
|
||||
<view class="u-p-r-18">
|
||||
<view class="u-flex u-row-right name-wrap">
|
||||
<view class="tag">商家</view>
|
||||
<view class="name">{{ shopInfo.shopName }}</view>
|
||||
</view>
|
||||
<view class="u-m-t-14 msg" :class="['type' + item.msg_type]">
|
||||
<chatItem :item="item"></chatItem>
|
||||
</view>
|
||||
<view class="text-center u-m-t-20" v-if="item.msg_type == 4 && item.hasGet">
|
||||
<text>{{ item.hasGet || 0 }}人已领取</text>
|
||||
<text class="color-main">优惠券</text>
|
||||
</view>
|
||||
</view>
|
||||
<up-avatar size="70rpx" shape="square" bg-color="#fff" :src="shopInfo.logo"></up-avatar>
|
||||
</view>
|
||||
</template>
|
||||
<!-- 收消息 -->
|
||||
<template v-else>
|
||||
<view class="user u-flex">
|
||||
<up-avatar size="70rpx" :src="item.avatar" shape="square" bg-color="#fff"></up-avatar>
|
||||
<view class="u-p-l-18">
|
||||
<view class="name u-line-1">{{ item.nick }}</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> -->
|
||||
|
||||
@@ -110,111 +78,64 @@
|
||||
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="60rpx"
|
||||
@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-center 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>
|
||||
<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="60rpx" @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-center 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"
|
||||
maxlength="12"
|
||||
></up-input>
|
||||
<view class="font-bold u-m-b-16 u-m-t-32">发放数量(张)</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" maxlength="12"></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"
|
||||
:max="modalData.form.giveNum"
|
||||
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>
|
||||
<view class="font-bold u-m-b-16 u-m-t-32">每人限领量(张)</view>
|
||||
<up-number-box v-model="modalData.form.getLimit" :max="modalData.form.giveNum" 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,
|
||||
onShow,
|
||||
onPageScroll,
|
||||
} from "@dcloudio/uni-app";
|
||||
import {
|
||||
ref,
|
||||
inject,
|
||||
onMounted,
|
||||
onUnmounted,
|
||||
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";
|
||||
import { onReady, onReachBottom, onLoad, onShow, onPageScroll } from '@dcloudio/uni-app';
|
||||
import { ref, inject, onMounted, onUnmounted, 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) {
|
||||
}
|
||||
return; // 终止后续逻辑
|
||||
}
|
||||
console.log('refresherrefresh');
|
||||
// 关键:同时判断「正在加载」和「无更多数据」,只要一个为真就关闭刷新
|
||||
if (isLoading.value || isEnd.value) {
|
||||
scrollView.refresherTriggered = false; // 立即关闭刷新状态
|
||||
if (isEnd.value) {
|
||||
}
|
||||
return; // 终止后续逻辑
|
||||
}
|
||||
|
||||
query.page++;
|
||||
getMsgList();
|
||||
@@ -245,14 +166,14 @@ const modalData = reactive({
|
||||
const chatStore = useChatStore();
|
||||
|
||||
const handleReceiveMsg = (msg) => {
|
||||
nextTick(() => {
|
||||
scrollView.intoView = "msg-0";
|
||||
});
|
||||
nextTick(() => {
|
||||
scrollView.intoView = 'msg-0';
|
||||
});
|
||||
};
|
||||
|
||||
// 注册消息回调
|
||||
chatStore.registerReceiveMsgCallback(handleReceiveMsg);
|
||||
const msg = ref("");
|
||||
const msg = ref('');
|
||||
|
||||
const shopInfo = uni.getStorageSync('shopInfo');
|
||||
|
||||
@@ -290,17 +211,17 @@ function videoErrorCallback(e) {
|
||||
console.error('视频播放失败', e);
|
||||
}
|
||||
async function sendImg() {
|
||||
try {
|
||||
// 1. 调用图片选择API,添加fail回调
|
||||
const res = await new Promise((resolve, reject) => {
|
||||
uni.chooseImage({
|
||||
count: 3,
|
||||
sizeType: ["original", "compressed"],
|
||||
sourceType: ["album", "camera"],
|
||||
success: resolve,
|
||||
fail: reject, // 捕获选择失败(含权限拒绝)
|
||||
});
|
||||
});
|
||||
try {
|
||||
// 1. 调用图片选择API,添加fail回调
|
||||
const res = await new Promise((resolve, reject) => {
|
||||
uni.chooseImage({
|
||||
count: 3,
|
||||
sizeType: ['original', 'compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: resolve,
|
||||
fail: reject // 捕获选择失败(含权限拒绝)
|
||||
});
|
||||
});
|
||||
|
||||
uni.showLoading({ title: '发送中' });
|
||||
console.log('选择图片成功', res);
|
||||
@@ -327,17 +248,17 @@ async function sendImg() {
|
||||
|
||||
// 视频选择与发送优化
|
||||
async function sendVideo() {
|
||||
try {
|
||||
// 1. 调用视频选择API,添加fail回调
|
||||
const res = await new Promise((resolve, reject) => {
|
||||
uni.chooseVideo({
|
||||
count: 1,
|
||||
sizeType: ["original", "compressed"],
|
||||
sourceType: ["album", "camera"],
|
||||
success: resolve,
|
||||
fail: reject, // 捕获选择失败(含权限拒绝)
|
||||
});
|
||||
});
|
||||
try {
|
||||
// 1. 调用视频选择API,添加fail回调
|
||||
const res = await new Promise((resolve, reject) => {
|
||||
uni.chooseVideo({
|
||||
count: 1,
|
||||
sizeType: ['original', 'compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: resolve,
|
||||
fail: reject // 捕获选择失败(含权限拒绝)
|
||||
});
|
||||
});
|
||||
|
||||
uni.showLoading({ title: '发送中' });
|
||||
console.log('选择视频成功', res);
|
||||
@@ -367,61 +288,56 @@ async function sendVideo() {
|
||||
|
||||
// 通用权限错误处理函数
|
||||
function handlePermissionError(err, mediaType) {
|
||||
const errMsg = err.errMsg || "";
|
||||
// 识别权限拒绝关键词(兼容不同平台)
|
||||
const isAuthDenied = [
|
||||
"auth deny",
|
||||
"permission denied",
|
||||
"auth denied",
|
||||
"用户拒绝",
|
||||
].some((keyword) => errMsg.includes(keyword));
|
||||
const errMsg = err.errMsg || '';
|
||||
// 识别权限拒绝关键词(兼容不同平台)
|
||||
const isAuthDenied = ['auth deny', 'permission denied', 'auth denied', '用户拒绝'].some((keyword) => errMsg.includes(keyword));
|
||||
|
||||
if (isAuthDenied) {
|
||||
// 弹窗提示用户,并引导至设置页
|
||||
uni.showModal({
|
||||
title: "权限提示",
|
||||
content: `需要${mediaType}权限才能使用该功能,请前往设置开启`,
|
||||
confirmText: "去设置",
|
||||
cancelText: "取消",
|
||||
success: (modalRes) => {
|
||||
if (modalRes.confirm) {
|
||||
// 跳转到小程序设置页
|
||||
uni.openSetting({
|
||||
success: (settingRes) => {
|
||||
console.log("设置页返回结果", settingRes);
|
||||
// 可根据需要添加权限开启后的回调逻辑
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
} else {
|
||||
// 其他错误(如取消选择),仅轻提示
|
||||
if (!errMsg.includes("cancel")) {
|
||||
uni.showToast({
|
||||
title: `${mediaType}选择失败`,
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
}
|
||||
if (isAuthDenied) {
|
||||
// 弹窗提示用户,并引导至设置页
|
||||
uni.showModal({
|
||||
title: '权限提示',
|
||||
content: `需要${mediaType}权限才能使用该功能,请前往设置开启`,
|
||||
confirmText: '去设置',
|
||||
cancelText: '取消',
|
||||
success: (modalRes) => {
|
||||
if (modalRes.confirm) {
|
||||
// 跳转到小程序设置页
|
||||
uni.openSetting({
|
||||
success: (settingRes) => {
|
||||
console.log('设置页返回结果', settingRes);
|
||||
// 可根据需要添加权限开启后的回调逻辑
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 其他错误(如取消选择),仅轻提示
|
||||
if (!errMsg.includes('cancel')) {
|
||||
uni.showToast({
|
||||
title: `${mediaType}选择失败`,
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const groupInfo = ref({});
|
||||
async function init() {
|
||||
const res = await chatApi.groupInfo({
|
||||
group_id: options.group_id,
|
||||
});
|
||||
console.log(res);
|
||||
groupInfo.value = res || {};
|
||||
if (res) {
|
||||
chatStore.connectSocket();
|
||||
// 确保状态监听已初始化
|
||||
if (!chatStore._listenersInitialized) {
|
||||
chatStore.initStateListeners();
|
||||
chatStore._listenersInitialized = true;
|
||||
}
|
||||
}
|
||||
getMsgList();
|
||||
const res = await chatApi.groupInfo({
|
||||
group_id: options.group_id
|
||||
});
|
||||
console.log(res);
|
||||
groupInfo.value = res || {};
|
||||
if (res) {
|
||||
chatStore.connectSocket();
|
||||
// 确保状态监听已初始化
|
||||
if (!chatStore._listenersInitialized) {
|
||||
chatStore.initStateListeners();
|
||||
chatStore._listenersInitialized = true;
|
||||
}
|
||||
}
|
||||
getMsgList();
|
||||
}
|
||||
const query = reactive({
|
||||
page: 1,
|
||||
@@ -475,30 +391,30 @@ async function getMsgList() {
|
||||
|
||||
const options = reactive({});
|
||||
const membersRes = reactive({
|
||||
user_list: [],
|
||||
user_list: []
|
||||
});
|
||||
onLoad((opt) => {
|
||||
Object.assign(options, opt);
|
||||
init();
|
||||
chatApi.messageMarkReadAll({
|
||||
session_ids: options.group_id,
|
||||
});
|
||||
chatStore.group_id = options.group_id;
|
||||
chatApi.groupMembers({ group_id: options.group_id }).then((res) => {
|
||||
console.log(res);
|
||||
membersRes.user_list = res.user_list || [];
|
||||
});
|
||||
// #ifdef H5
|
||||
scrollView.safeAreaHeight = uni.getSystemInfoSync().safeArea.height;
|
||||
// #endif
|
||||
Object.assign(options, opt);
|
||||
init();
|
||||
chatApi.messageMarkReadAll({
|
||||
session_ids: options.group_id
|
||||
});
|
||||
chatStore.group_id = options.group_id;
|
||||
chatApi.groupMembers({ group_id: options.group_id }).then((res) => {
|
||||
console.log(res);
|
||||
membersRes.user_list = res.user_list || [];
|
||||
});
|
||||
// #ifdef H5
|
||||
scrollView.safeAreaHeight = uni.getSystemInfoSync().safeArea.height;
|
||||
// #endif
|
||||
});
|
||||
|
||||
onShow(() => {
|
||||
// 页面显示时,检查连接状态
|
||||
if (!chatStore.isConnect || !chatStore.socketTask) {
|
||||
console.log("聊天页显示,检查Socket连接");
|
||||
chatStore.forceReconnect();
|
||||
}
|
||||
// 页面显示时,检查连接状态
|
||||
if (!chatStore.isConnect || !chatStore.socketTask) {
|
||||
console.log('聊天页显示,检查Socket连接');
|
||||
chatStore.forceReconnect();
|
||||
}
|
||||
});
|
||||
|
||||
function toMore() {
|
||||
@@ -514,16 +430,16 @@ function sendText() {
|
||||
}
|
||||
|
||||
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: groupInfo.value.session_id || options.session_id,
|
||||
...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: groupInfo.value.session_id || options.session_id,
|
||||
...msg
|
||||
});
|
||||
}
|
||||
function closeModal() {
|
||||
modalData.form = {
|
||||
@@ -534,57 +450,57 @@ function closeModal() {
|
||||
};
|
||||
}
|
||||
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;
|
||||
}
|
||||
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,
|
||||
activity_id: res.id,
|
||||
},
|
||||
chat_coupon_id: res.id,
|
||||
msg_type: 4,
|
||||
});
|
||||
closeModal();
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: "发送失败",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
});
|
||||
chatCouponApi.chatCouponCreate(modalData.form).then((res) => {
|
||||
if (res) {
|
||||
modalData.show = false;
|
||||
const couponJson = JSON.parse(res.couponJson);
|
||||
sendMsg({
|
||||
coupon: {
|
||||
...couponJson,
|
||||
title: modalData.form.title,
|
||||
activity_id: res.id
|
||||
},
|
||||
chat_coupon_id: res.id,
|
||||
msg_type: 4
|
||||
});
|
||||
closeModal();
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '发送失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function previewImage(url) {
|
||||
@@ -627,11 +543,13 @@ const pageHeight = computed(() => {
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
// 组件卸载时,移除消息回调
|
||||
chatStore.removeReceiveMsgCallback(handleReceiveMsg);
|
||||
// 组件卸载时,移除消息回调
|
||||
chatStore.removeReceiveMsgCallback(handleReceiveMsg);
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
$grayColor: #9e9e9e;
|
||||
$grayBorderColor: #bebebe;
|
||||
.top {
|
||||
background-color: #fff;
|
||||
padding: 40rpx 32rpx;
|
||||
@@ -674,13 +592,14 @@ onUnmounted(() => {
|
||||
margin-bottom: 88rpx;
|
||||
align-items: flex-start;
|
||||
.name {
|
||||
margin-top: -8upx;
|
||||
color: #999;
|
||||
margin-top: -4upx;
|
||||
color: $grayColor;
|
||||
font-size: 24upx;
|
||||
}
|
||||
.msg {
|
||||
padding: 16rpx 20rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 8rpx;
|
||||
border-radius: 20rpx;
|
||||
}
|
||||
}
|
||||
.shop {
|
||||
@@ -688,21 +607,22 @@ onUnmounted(() => {
|
||||
align-items: flex-start;
|
||||
.tag {
|
||||
margin-right: 32rpx;
|
||||
padding: 8rpx 20rpx;
|
||||
border: 1px solid #d9d9d9;
|
||||
padding: 4rpx 12rpx;
|
||||
border: 1px solid $grayBorderColor;
|
||||
border-radius: 8rpx;
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
font-size: 20rpx;
|
||||
color: $grayColor;
|
||||
}
|
||||
.name-wrap {
|
||||
margin-top: -12upx;
|
||||
margin-top: -8upx;
|
||||
}
|
||||
.name {
|
||||
color: #999;
|
||||
color: $grayColor;
|
||||
font-size: 24upx;
|
||||
}
|
||||
.msg {
|
||||
padding: 16rpx 20rpx;
|
||||
border-radius: 8rpx;
|
||||
border-radius: 20rpx;
|
||||
&.type1 {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user