diff --git a/http/api/market/chat.js b/http/api/market/chat.js
new file mode 100644
index 0000000..ab9f423
--- /dev/null
+++ b/http/api/market/chat.js
@@ -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,
+ });
+}
diff --git a/http/api/market/chatCoupon.js b/http/api/market/chatCoupon.js
new file mode 100644
index 0000000..a79c79b
--- /dev/null
+++ b/http/api/market/chatCoupon.js
@@ -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,
+ },
+ });
+}
+
diff --git a/http/http.js b/http/http.js
index 6fceecc..eb2d791 100644
--- a/http/http.js
+++ b/http/http.js
@@ -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
diff --git a/http/php/chat.js b/http/php/chat.js
new file mode 100644
index 0000000..e9933a4
--- /dev/null
+++ b/http/php/chat.js
@@ -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);
+};
\ No newline at end of file
diff --git a/http/php/request.ts b/http/php/request.ts
index ff62e98..d2199f5 100644
--- a/http/php/request.ts
+++ b/http/php/request.ts
@@ -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({
diff --git a/pageChat/chat.vue b/pageChat/chat.vue
new file mode 100644
index 0000000..f1894a7
--- /dev/null
+++ b/pageChat/chat.vue
@@ -0,0 +1,644 @@
+
+
+
+
+
+ {{ groupInfo.name }}
+
+ (22人)
+
+
+
+
+
+ 更多
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 商家
+ {{ shopInfo.shopName }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ item.nick_name }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ item.title }}
+
+
+
+
+
+
+
+ 自定义文案
+
+ 发放数量(张)
+
+
+
+ 每人限领量(张)
+
+ 选择优惠券
+
+
+
+
+
+
+
diff --git a/pageChat/components/chat-item.vue b/pageChat/components/chat-item.vue
new file mode 100644
index 0000000..278a8b4
--- /dev/null
+++ b/pageChat/components/chat-item.vue
@@ -0,0 +1,64 @@
+
+ {{ item.content }}
+
+
+
+ 发优惠券了!数量有限!快来领取吧!
+
+
+
+ ¥
+ 15
+
+ 满{{item.coupon.fullAmount}}可用
+
+
+ 优惠券名称叫什么
+ 有效期:2002.1.22-2022.1.22
+
+
+
+
+
+
+
+
diff --git a/pageChat/components/choose-coupon.vue b/pageChat/components/choose-coupon.vue
new file mode 100644
index 0000000..d7197ea
--- /dev/null
+++ b/pageChat/components/choose-coupon.vue
@@ -0,0 +1,201 @@
+
+
+
+
+
+ {{ title }}
+
+
+
+
+
+
+
+
+ {{ item.title }}
+
+
+
+
+
+
+
+ {{ cancelText }}
+ {{ confirmText }}
+
+
+
+
+
+
+
+
diff --git a/pageChat/components/choose-goods.vue b/pageChat/components/choose-goods.vue
new file mode 100644
index 0000000..bbd9da3
--- /dev/null
+++ b/pageChat/components/choose-goods.vue
@@ -0,0 +1,198 @@
+
+
+
+
+
+ 请选择商品
+ {{ goodsName }}
+
+
+
+
+
+
+
+ {{ title }}
+
+
+
+
+
+
+
+
+
+
+ {{ item.name }}
+
+ ¥{{ item.lowPrice }}
+
+
+
+
+ {{ cancelText }}
+ {{ confirmText }}
+
+
+
+
+
+
+
+
diff --git a/pageChat/components/coupon-list.vue b/pageChat/components/coupon-list.vue
new file mode 100644
index 0000000..824d273
--- /dev/null
+++ b/pageChat/components/coupon-list.vue
@@ -0,0 +1,92 @@
+
+
+
+
+
+ {{ item.title }}
+
+
+
+
+
+
+ 选择赠送券
+
+
+
+
+
+
+ 张/1个码
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pageChat/components/coupon.vue b/pageChat/components/coupon.vue
new file mode 100644
index 0000000..afeff02
--- /dev/null
+++ b/pageChat/components/coupon.vue
@@ -0,0 +1,75 @@
+
+
+
+
+
+ {{ couponName }}
+
+
+
+
+
+
+ 选择赠送券
+
+
+
+
+
+
+
+
+
+
diff --git a/pageChat/components/date-time-picker.vue b/pageChat/components/date-time-picker.vue
new file mode 100644
index 0000000..9234ac3
--- /dev/null
+++ b/pageChat/components/date-time-picker.vue
@@ -0,0 +1,108 @@
+
+
+
+
+
+ 请选择日期范围
+ {{ startTime }} - {{ endTime }}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pageChat/components/modal.vue b/pageChat/components/modal.vue
new file mode 100644
index 0000000..7308c90
--- /dev/null
+++ b/pageChat/components/modal.vue
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/pageChat/components/shop-sel-action-sheet.vue b/pageChat/components/shop-sel-action-sheet.vue
new file mode 100644
index 0000000..db51b63
--- /dev/null
+++ b/pageChat/components/shop-sel-action-sheet.vue
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pageChat/coupon-activity/detail.vue b/pageChat/coupon-activity/detail.vue
new file mode 100644
index 0000000..ad11d1a
--- /dev/null
+++ b/pageChat/coupon-activity/detail.vue
@@ -0,0 +1,184 @@
+
+
+
+
+ 优惠券名称
+ {{ couponActivity.couponJson.couponName }}
+
+
+ 发放数量
+ {{ couponActivity.giveNum }}
+
+
+ 已领取数量
+ {{ couponActivity.giveNum - couponActivity.leftNum }}
+
+
+ 剩余数量
+ {{ couponActivity.leftNum }}
+
+
+ 已使用数量
+ {{ couponActivity.useNum }}
+
+
+
+
+
+
+
+ {{ selStatus.label }}
+ 请选择状态
+
+
+
+
+
+
+
+
+
+
+
+ 用户昵称(40239)
+ 2025/06/27 20:07:18)
+ 2025/01/15 08:02:38
+ 已使用
+ 失效
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pageChat/coupon-activity/index.vue b/pageChat/coupon-activity/index.vue
new file mode 100644
index 0000000..382a1c3
--- /dev/null
+++ b/pageChat/coupon-activity/index.vue
@@ -0,0 +1,252 @@
+
+
+
+
+
+
+
+
+
+
+
+ {{ item.couponJson.couponName }}
+
+
+ {{
+ returnStateText(item)
+ }}
+ ID:{{ item.id }}
+
+
+
+
+ 使用门槛
+ 满{{ item.couponJson.fullAmount }}元可用
+
+
+ 有效期
+ 领券后{{ item.couponJson.validDays }}天过期
+
+
+
+
+ {{ item.giveNum }}
+ 发放数量
+
+
+ {{
+ item.giveNum - item.leftNum
+ }}
+ 已领取
+
+
+
+ {{ item.leftNum }}
+ 剩余
+
+
+
+ {{ item.useNum }}
+ 已使用
+
+
+
+ 失效
+ 查看
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pageChat/group-info/index.vue b/pageChat/group-info/index.vue
new file mode 100644
index 0000000..9f7254d
--- /dev/null
+++ b/pageChat/group-info/index.vue
@@ -0,0 +1,179 @@
+
+
+
+
+ 群成员(22人)
+ 移除
+
+
+
+
+ {{ item.nick_name }}
+
+
+
+
+
+
+ 查看更多
+
+
+
+
+
+
+ 群聊名称
+
+ {{ groupInfo.name }}
+
+
+
+
+
+ 禁言
+
+ 开启后,顾客将不能在群内发消息
+
+
+
+
+ 优惠券领取记录
+
+ 去查看
+
+
+
+
+
+
+
+
diff --git a/pageChat/index.vue b/pageChat/index.vue
index 99bfd3b..b190149 100644
--- a/pageChat/index.vue
+++ b/pageChat/index.vue
@@ -1,3 +1,99 @@
-
-
\ No newline at end of file
+
+
+
+
+
+ 清空未读
+
+
+
+
+
+
+
+
+
+
+
+ {{ item.name }}
+ 用户昵称:这里是消息内容这里,,,,
+
+ {{ item.send_time }}
+
+
+
+
+
+
+
+
+
diff --git a/pageChat/static/clear.png b/pageChat/static/clear.png
new file mode 100644
index 0000000..e07b381
Binary files /dev/null and b/pageChat/static/clear.png differ
diff --git a/pageChat/static/coupon.png b/pageChat/static/coupon.png
new file mode 100644
index 0000000..e02df91
Binary files /dev/null and b/pageChat/static/coupon.png differ
diff --git a/pageChat/static/pic.png b/pageChat/static/pic.png
new file mode 100644
index 0000000..4069281
Binary files /dev/null and b/pageChat/static/pic.png differ
diff --git a/pageChat/static/video.png b/pageChat/static/video.png
new file mode 100644
index 0000000..a82291f
Binary files /dev/null and b/pageChat/static/video.png differ
diff --git a/pages.json b/pages.json
index 084b837..1fd5aba 100644
--- a/pages.json
+++ b/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": "查看优惠券"
+ }
+ }
+
+ ]
}
],
diff --git a/pages/login/index.vue b/pages/login/index.vue
index 296ac27..87ace27 100644
--- a/pages/login/index.vue
+++ b/pages/login/index.vue
@@ -194,7 +194,6 @@
*/
const getCode = () => {
authCaptcha().then(res => {
- console.log(res)
vdata.formData.img = res.code
vdata.formData.uuid = res.uuid
})
diff --git a/pages/permission/permission.vue b/pages/permission/permission.vue
index d83b0eb..d1d3416 100644
--- a/pages/permission/permission.vue
+++ b/pages/permission/permission.vue
@@ -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);
},
// 点击左边的栏目切换
diff --git a/store/chat.js b/store/chat.js
index 57a55b7..45cda84 100644
--- a/store/chat.js
+++ b/store/chat.js
@@ -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 的数据读写都将持久化
});
diff --git a/vite.config.js b/vite.config.js
index fac8e0c..dbb46b2 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -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/, '')
}
}
}