增加聊天功能

This commit is contained in:
2025-12-04 17:14:47 +08:00
parent ca829d7f00
commit 6f1185be3a
25 changed files with 2504 additions and 2 deletions

11
common/api/market/chat.js Normal file
View File

@@ -0,0 +1,11 @@
// 引入 request 文件
import request from "@/common/api/request.js";
import { prveUrl } from "./config.js";
export const couponGrant = (data) => {
return request({
url: prveUrl + "/user/chat/coupon/grant",
method: "post",
data: data,
});
};

64
common/api/upload.js Normal file
View File

@@ -0,0 +1,64 @@
function getHeader() {
let token = uni.cache.get("token") || "";
const shopId = uni.cache.get("shopId") * 1;
const userInfo = uni.cache.get("userInfo") || {};
return {
version: uni.conf.version,
type: uni.getSystemInfoSync().platform,
// #ifdef APP-PLUS
platformType: "APP",
// #endif
// #ifdef H5
platformType: "H5",
// #endif
// #ifdef MP-WEIXIN
platformType: "WX",
// #endif
// #ifdef MP-ALIPAY
platformType: "ALI",
// #endif
token,
id: userInfo.id || "",
shopId: shopId || "",
userId: userInfo.id || "",
};
}
// 上传
export function upload(uri, file, data, showLoading = true, extParams = {}) {
return new Promise((resolve, reject) => {
uni.showLoading();
uni
.uploadFile(
Object.assign(
{
url: uni.conf.baseUrl + uri,
formData: data,
name: "file",
filePath: file.path || file.url || file,
header: getHeader(),
},
extParams
)
)
.then((httpData) => {
// uni.upload 返回bodyData 的是 string类型。 需要解析。
httpData.data = JSON.parse(httpData.data);
if( httpData.data.code==200){
resolve( httpData.data.data);
}
reject()
})
.catch((err) => {
reject();
uni.hideLoading();
infoBox.showErrorToast(`上传失败`);
});
});
}
export const uploadFile = (file, data) => {
return upload("/account/user/common/upload", file, data);
};

View File

@@ -37,6 +37,8 @@ export const changeEnv = (env) => {
uni.conf = {
debug: true,
baseUrl: "http://192.168.1.42",
phpUrl:'http://192.168.1.42:8787/api/',
phpChatWx:'ws://192.168.1.42:2348',
version: 100,
autoRemoveCache,
baseUrlwws: "ws://192.168.1.42:2348",

View File

@@ -105,6 +105,7 @@ page,
justify-content: center;
}
.u-flex-col{
display: flex;
flex-direction: column!important;
}
.min-h-100vh{
@@ -115,4 +116,59 @@ page,
}
.align-center{
align-items: center;
}
}
.u-row-between{
justify-content: space-between;
}
.u-row-right {
justify-content: flex-end;
}
// 定义字体(rpx)单位大于或等于20的都为rpx单位字体
@for $i from 20 through 40 {
.u-font-#{$i} {
font-size: $i + rpx;
}
}
.min-page{
/* #ifdef H5 */
min-height: calc(100vh - 44px);
/* #endif */
/* #ifndef H5 */
min-height: 100vh;
/* #endif */
}
.bg-f7{
background-color: #F7F7F7;
}
.default-box-padding{
padding: 32rpx 28rpx;
}
.default-box-radius{
border-radius: 16rpx;
}
.default-box-x-padding{
padding-left: 28rpx;
padding-right: 28rpx;
}
.default-box-y-padding{
padding-top: 32rpx;
padding-bottom: 32rpx;
}
$height: 70rpx;
.u-col-baseline{
align-items: baseline;
}
.text-right{
text-align: right;
}
.u-row-center{
justify-content: center;
}
.u-col-center{
align-items: center;
}