im聊天室接口报错问题

master
2023-02-08 11:59:15 +08:00
parent 83031507b9
commit e7879aac65
6 changed files with 72 additions and 59 deletions

View File

@ -67,7 +67,7 @@ export function getTalk(talkId) {
// 从商品页点击 客服 跳转 获取商品详情
export function jumpObtain(skuId, goodsId) {
return http.request({
url: `${api.im}/goods/goods/sku/${goodsId}/${skuId}`,
url: `/goods/goods/sku/${goodsId}/${skuId}`,
method: Method.GET,
});
}

View File

@ -4,9 +4,12 @@
*/
// 开发环境
const dev = {
im: "https://im-api.pickmall.cn",
common: "https://common-api.pickmall.cn",
buyer: "https://buyer-api.pickmall.cn",
im: "https://im-api.pickmall.cn",
common: "https://common-api.pickmall.cn",
buyer: "https://buyer-api.pickmall.cn",
// common: "http://192.168.0.113:8890",
// buyer: "http://192.168.0.113:8888",
// im: "http://192.168.0.113:8885",
};
// 生产环境
const prod = {

View File

@ -1,20 +1,15 @@
<template>
<view class="log-list">
<!-- 提现记录 -->
<view
class="log-way"
v-if="cashLogData.length != 0"
v-for="(item, index) in cashLogData"
:key="index"
>
<view class="log-way" v-if="cashLogData.length != 0" v-for="(item, index) in cashLogData" :key="index">
<view class="log-item">
<view class="log-item-view">
<view class="title">{{
item.distributionCashStatus == "APPLY"
? "待处理"
: item.distributionCashStatus == "PASS"
? "通过"
: "拒绝"
? "通过"
: "拒绝"
}}</view>
<view class="price">+{{ item.price | unitPrice }}</view>
</view>
@ -25,12 +20,7 @@
</view>
</view>
<!-- 分销业绩 -->
<view
class="log-way"
v-if="achievementData.length != 0"
v-for="(item, index) in achievementData"
:key="index"
>
<view class="log-way" v-if="achievementData.length != 0" v-for="(item, index) in achievementData" :key="index">
<view class="log-item">
<view class="log-item-view">
<view class="title">{{ item.goodsName }}</view>
@ -56,7 +46,7 @@
<script>
import { cashLog, distributionOrderList } from "@/api/goods";
export default {
data() {
data () {
return {
cashLogData: [], //
achievementData: [], //,
@ -76,7 +66,7 @@ export default {
},
};
},
onLoad(option) {
onLoad (option) {
let title;
option.type == 0 ? (title = "分销业绩") : (title = "提现记录");
@ -87,15 +77,15 @@ export default {
this.type = option.type;
option.type == 0 ? this.achievement() : this.history();
},
mounted() {},
onReachBottom() {
mounted () { },
onReachBottom () {
this.status = "loading";
this.type == 0 ? this.achParams.pageNumber++ : this.params.pageNumber++;
this.type == 0 ? this.achievement() : this.history();
},
methods: {
//
achievement() {
achievement () {
uni.showLoading({
title: "加载中",
});
@ -110,7 +100,7 @@ export default {
});
},
//
history() {
history () {
uni.showLoading({
title: "加载中",
});
@ -131,15 +121,18 @@ export default {
.empty {
margin: 40rpx 0;
}
.price {
color: $main-color;
font-weight: bold;
}
.log-list {
padding: 0 8rpx;
overflow: hidden;
margin: 20rpx 0;
}
.log-way {
margin: 10rpx 0;
overflow: hidden;
@ -147,22 +140,26 @@ export default {
border-radius: 10rpx;
padding: 20rpx 0;
}
.title {
font-size: 30rpx;
font-weight: bold;
}
.log-item-view {
padding: 8rpx 32rpx;
display: flex;
font-size: 13px;
justify-content: space-between;
}
.log-item-footer {
padding: 8rpx 32rpx;
display: flex;
font-size: 13px;
justify-content: space-between;
}
.log-item-footers {
padding: 8rpx 32rpx;
display: flex;

View File

@ -10,7 +10,8 @@
<!-- 消息 -->
<view class="flex-column-start" v-if="msgList.length" v-for="(item, index) in msgList" :key="index">
<view class="flex-row-start column-time">
<view v-show="compareTime(index, item.createTime)" class="flex-row-start date-text">
<view v-show="compareTime(index, item.createTime)" class="flex-row-start date-text"
v-text="beautifyTime(item.createTime)">
</view>
</view>
<!-- 用户消息 头像可选加入-->
@ -122,9 +123,13 @@
</view>
</view>
</view>
<!-- 防止消息底部被遮 -->
<view v-if="showHide && !localImGoodsId && showHideModel" class="flex-row-start margin-left margin-top"
style="height: 120rpx;">
</view>
<!-- 如果没有聊天记录定位到底部 -->
<view
:style="{ position: msgList.length == 0 ? 'fixed' : '', bottom: msgList.length == 0 ? '50px' : '', width: msgList.length == 0 ? '100%' : '' }">
:style="{ position: msgList.length == 0 ? 'fixed' : '', bottom: msgList.length == 0 ? '66px' : '', width: msgList.length == 0 ? '100%' : '' }">
<view class="cartMessage" v-if="showHide && !localImGoodsId && showHideModel">
<view class="goodsCard u-flex u-row-between u-p-b-0">
<view class="imagebox" @click="jumpGoodDelic(item)">
@ -148,20 +153,21 @@
</view>
</view>
</view>
<!-- loading是显示 -->
<view v-show="msgLoad" class="flex-row-start margin-left margin-top">
<!-- <view v-show="msgLoad" class=" margin-left margin-top">
<view class="chat-img flex-row-center">
<!-- <image style="height: 75rpx;width: 75rpx;" src="../../static/image/robt.png" mode="aspectFit"></image> -->
<image style="height: 75rpx;width: 75rpx;" src="../../static/image/robt.png" mode="aspectFit"></image>
</view>
<view class="flex" style="width: 500rpx;">
<view class="margin-left padding-chat flex-column-start"
style="border-radius: 35rpx;background-color: #f9f9f9;">
<!-- <view class="cuIcon-loading turn-load" style="font-size: 35rpx;color: #3e9982;">
<view class="cuIcon-loading turn-load" style="font-size: 35rpx;color: #3e9982;">
</view> -->
</view>
</view>
</view>
</view>
</view> -->
<!-- 防止消息底部被遮 -->
<view style="height: 120rpx;">
</view>
@ -223,8 +229,6 @@ export default {
}
},
onLoad (options) {
console.log(5555555555555555);
console.log(emojistwo);
// goodsid
this.showHideModel = options.goodsid
// localimGoodId
@ -275,7 +279,6 @@ export default {
// this.ws.connect();
this.sokcet();
},
onPullDownRefresh () {
this.params.pageNumber = this.params.pageNumber + 1
this.getTalkMessage()
@ -433,12 +436,11 @@ export default {
uni.connectSocket({
url: url,
});
}, 5 * 1000)
}, 999999)
}
});
//
uni.onSocketMessage(function (res) {
console.log(res.data);
res.data = JSON.parse(res.data)
console.log(res.data.result);
if (res.data.messageResultType == 'MESSAGE') {

View File

@ -9,7 +9,7 @@ import Vue from "vue";
* @param location
* @returns {*}
*/
export function unitPrice(val, unit, location) {
export function unitPrice (val, unit, location) {
if (!val) val = 0;
let price = Foundation.formatPrice(val);
if (location === "before") {
@ -26,7 +26,7 @@ export function unitPrice(val, unit, location) {
* @param {*} val
* @returns
*/
export function goodsFormatPrice(val) {
export function goodsFormatPrice (val) {
if (typeof val == "undefined") {
return val;
}
@ -39,7 +39,7 @@ export function goodsFormatPrice(val) {
* 脱敏姓名
*/
export function noPassByName(str) {
export function noPassByName (str) {
if (null != str && str != undefined) {
if (str.length <= 3) {
return "*" + str.substring(1, str.length);
@ -59,7 +59,7 @@ export function noPassByName(str) {
* @param format
* @returns {*|string}
*/
export function unixToDate(unix, format) {
export function unixToDate (unix, format) {
let _format = format || "yyyy-MM-dd hh:mm:ss";
const d = new Date(unix * 1000);
const o = {
@ -90,12 +90,11 @@ export function unixToDate(unix, format) {
*
* @param {Object} datetime
*/
export function beautifyTime(datetime = "") {
export function beautifyTime (datetime = "") {
if (datetime == null || datetime == undefined || !datetime) {
return "";
}
datetime = datetime.replace(/-/g, "/");
datetime = timestampToTime(datetime).replace(/-/g, "/");
let time = new Date();
let outTime = new Date(datetime);
@ -140,13 +139,24 @@ export function unixToDate(unix, format) {
minutes = Math.abs(minutes);
return `${minutes}分钟前`;
}
// 时间转换
function timestampToTime (timestamp) {
var date = new Date(timestamp);//时间戳为10位需*1000时间戳为13位的话不需乘1000
var Y = date.getFullYear() + '-';
var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
var D = date.getDate() + ' ';
var h = date.getHours() + ':';
var m = date.getMinutes() + ':';
var s = date.getSeconds();
return Y + M + D + h + m + s;
}
/**
* 13888888888 -> 138****8888
* @param mobile
* @returns {*}
*/
export function secrecyMobile(mobile) {
export function secrecyMobile (mobile) {
mobile = String(mobile);
if (!/\d{11}/.test(mobile)) {
return mobile;
@ -159,7 +169,7 @@ export function secrecyMobile(mobile) {
*
* @param {Object} datetime
*/
export function formatTime(datetime) {
export function formatTime (datetime) {
if (datetime == null) return "";
datetime = datetime.replace(/-/g, "/");
@ -214,7 +224,7 @@ export function secrecyMobile(mobile) {
* @param {String} cFormat
* @returns {String | null}
*/
export function parseTime(time, cFormat) {
export function parseTime (time, cFormat) {
if (arguments.length === 0) {
return null;
}
@ -263,7 +273,7 @@ export function secrecyMobile(mobile) {
* 清除逗号
*
*/
export function clearStrComma(str) {
export function clearStrComma (str) {
str = str.replace(/,/g, ""); //取消字符串中出现的所有逗号
return str;
}
@ -273,7 +283,7 @@ export function clearStrComma(str) {
* @param val 如果为auth则判断是否登录
* 如果传入 auth 则为判断是否登录
*/
export function isLogin(val) {
export function isLogin (val) {
let userInfo = storage.getUserInfo();
if (val == "auth") {
return userInfo && userInfo.id ? true : false;
@ -283,19 +293,19 @@ export function isLogin(val) {
}
/**
* 跳转im
*/
export function talkIm(storeId){
if(isLogin('auth')){
*/
export function talkIm (storeId) {
if (isLogin('auth')) {
uni.navigateTo({
url: `/pages/tabbar/home/web-view?IM=${storeId}`,
});
}
else{
else {
tipsToLogin()
}
}
export function tipsToLogin() {
export function tipsToLogin () {
if (!isLogin("auth")) {
uni.showModal({
title: "提示",
@ -319,7 +329,7 @@ export function tipsToLogin() {
/**
* 获取用户信息并重新添加到缓存里面
*/
export async function userInfo() {
export async function userInfo () {
let res = await getUserInfo();
if (res.data.success) {
storage.setUserInfo(res.data.result);
@ -333,7 +343,7 @@ export async function userInfo() {
* @returns
*/
export function forceLogin() {
export function forceLogin () {
let userInfo = storage.getUserInfo();
if (!userInfo || !userInfo.id) {
// #ifdef MP-WEIXIN
@ -358,7 +368,7 @@ export function forceLogin() {
* 获取当前加载的页面对象
* @param val
*/
export function getPages(val) {
export function getPages (val) {
const pages = getCurrentPages(); //获取加载的页面
const currentPage = pages[pages.length - 1]; //获取当前页面的对象
const url = currentPage.route; //当前页面url
@ -369,7 +379,7 @@ export function getPages(val) {
/**
* 跳转到登录页面
*/
export function navigateToLogin(type = "navigateTo") {
export function navigateToLogin (type = "navigateTo") {
/**
* 此处进行条件编译判断
* 微信小程序跳转到微信小程序登录页面
@ -390,7 +400,7 @@ export function navigateToLogin(type = "navigateTo") {
/**
* 服务状态列表
*/
export function serviceStatusList(val) {
export function serviceStatusList (val) {
let statusList = {
APPLY: "申请售后",
PASS: "通过售后",
@ -410,7 +420,7 @@ export function serviceStatusList(val) {
/**
* 订单状态列表
*/
export function orderStatusList(val) {
export function orderStatusList (val) {
let orderStatusList = {
UNDELIVERED: "待发货",
UNPAID: "未付款",

View File

@ -54,6 +54,7 @@ export default class SocketService {
};
// 得到服务端发送过来的数据
this.ws.onmessage = (msg) => {
// console.log(msg.data)
this.registerCallBack(msg.data);
};
}