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) { export function jumpObtain(skuId, goodsId) {
return http.request({ return http.request({
url: `${api.im}/goods/goods/sku/${goodsId}/${skuId}`, url: `/goods/goods/sku/${goodsId}/${skuId}`,
method: Method.GET, method: Method.GET,
}); });
} }

View File

@ -7,6 +7,9 @@ const dev = {
im: "https://im-api.pickmall.cn", im: "https://im-api.pickmall.cn",
common: "https://common-api.pickmall.cn", common: "https://common-api.pickmall.cn",
buyer: "https://buyer-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 = { const prod = {

View File

@ -1,12 +1,7 @@
<template> <template>
<view class="log-list"> <view class="log-list">
<!-- 提现记录 --> <!-- 提现记录 -->
<view <view class="log-way" v-if="cashLogData.length != 0" v-for="(item, index) in cashLogData" :key="index">
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 class="log-item-view"> <view class="log-item-view">
<view class="title">{{ <view class="title">{{
@ -25,12 +20,7 @@
</view> </view>
</view> </view>
<!-- 分销业绩 --> <!-- 分销业绩 -->
<view <view class="log-way" v-if="achievementData.length != 0" v-for="(item, index) in achievementData" :key="index">
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 class="log-item-view"> <view class="log-item-view">
<view class="title">{{ item.goodsName }}</view> <view class="title">{{ item.goodsName }}</view>
@ -56,7 +46,7 @@
<script> <script>
import { cashLog, distributionOrderList } from "@/api/goods"; import { cashLog, distributionOrderList } from "@/api/goods";
export default { export default {
data() { data () {
return { return {
cashLogData: [], // cashLogData: [], //
achievementData: [], //, achievementData: [], //,
@ -76,7 +66,7 @@ export default {
}, },
}; };
}, },
onLoad(option) { onLoad (option) {
let title; let title;
option.type == 0 ? (title = "分销业绩") : (title = "提现记录"); option.type == 0 ? (title = "分销业绩") : (title = "提现记录");
@ -87,15 +77,15 @@ export default {
this.type = option.type; this.type = option.type;
option.type == 0 ? this.achievement() : this.history(); option.type == 0 ? this.achievement() : this.history();
}, },
mounted() {}, mounted () { },
onReachBottom() { onReachBottom () {
this.status = "loading"; this.status = "loading";
this.type == 0 ? this.achParams.pageNumber++ : this.params.pageNumber++; this.type == 0 ? this.achParams.pageNumber++ : this.params.pageNumber++;
this.type == 0 ? this.achievement() : this.history(); this.type == 0 ? this.achievement() : this.history();
}, },
methods: { methods: {
// //
achievement() { achievement () {
uni.showLoading({ uni.showLoading({
title: "加载中", title: "加载中",
}); });
@ -110,7 +100,7 @@ export default {
}); });
}, },
// //
history() { history () {
uni.showLoading({ uni.showLoading({
title: "加载中", title: "加载中",
}); });
@ -131,15 +121,18 @@ export default {
.empty { .empty {
margin: 40rpx 0; margin: 40rpx 0;
} }
.price { .price {
color: $main-color; color: $main-color;
font-weight: bold; font-weight: bold;
} }
.log-list { .log-list {
padding: 0 8rpx; padding: 0 8rpx;
overflow: hidden; overflow: hidden;
margin: 20rpx 0; margin: 20rpx 0;
} }
.log-way { .log-way {
margin: 10rpx 0; margin: 10rpx 0;
overflow: hidden; overflow: hidden;
@ -147,22 +140,26 @@ export default {
border-radius: 10rpx; border-radius: 10rpx;
padding: 20rpx 0; padding: 20rpx 0;
} }
.title { .title {
font-size: 30rpx; font-size: 30rpx;
font-weight: bold; font-weight: bold;
} }
.log-item-view { .log-item-view {
padding: 8rpx 32rpx; padding: 8rpx 32rpx;
display: flex; display: flex;
font-size: 13px; font-size: 13px;
justify-content: space-between; justify-content: space-between;
} }
.log-item-footer { .log-item-footer {
padding: 8rpx 32rpx; padding: 8rpx 32rpx;
display: flex; display: flex;
font-size: 13px; font-size: 13px;
justify-content: space-between; justify-content: space-between;
} }
.log-item-footers { .log-item-footers {
padding: 8rpx 32rpx; padding: 8rpx 32rpx;
display: flex; 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-column-start" v-if="msgList.length" v-for="(item, index) in msgList" :key="index">
<view class="flex-row-start column-time"> <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>
</view> </view>
<!-- 用户消息 头像可选加入--> <!-- 用户消息 头像可选加入-->
@ -122,9 +123,13 @@
</view> </view>
</view> </view>
</view> </view>
<!-- 防止消息底部被遮 -->
<view v-if="showHide && !localImGoodsId && showHideModel" class="flex-row-start margin-left margin-top"
style="height: 120rpx;">
</view>
<!-- 如果没有聊天记录定位到底部 --> <!-- 如果没有聊天记录定位到底部 -->
<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="cartMessage" v-if="showHide && !localImGoodsId && showHideModel">
<view class="goodsCard u-flex u-row-between u-p-b-0"> <view class="goodsCard u-flex u-row-between u-p-b-0">
<view class="imagebox" @click="jumpGoodDelic(item)"> <view class="imagebox" @click="jumpGoodDelic(item)">
@ -148,20 +153,21 @@
</view> </view>
</view> </view>
</view> </view>
<!-- loading是显示 --> <!-- 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"> <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>
<view class="flex" style="width: 500rpx;"> <view class="flex" style="width: 500rpx;">
<view class="margin-left padding-chat flex-column-start" <view class="margin-left padding-chat flex-column-start"
style="border-radius: 35rpx;background-color: #f9f9f9;"> 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>
</view>
<!-- 防止消息底部被遮 --> <!-- 防止消息底部被遮 -->
<view style="height: 120rpx;"> <view style="height: 120rpx;">
</view> </view>
@ -223,8 +229,6 @@ export default {
} }
}, },
onLoad (options) { onLoad (options) {
console.log(5555555555555555);
console.log(emojistwo);
// goodsid // goodsid
this.showHideModel = options.goodsid this.showHideModel = options.goodsid
// localimGoodId // localimGoodId
@ -275,7 +279,6 @@ export default {
// this.ws.connect(); // this.ws.connect();
this.sokcet(); this.sokcet();
}, },
onPullDownRefresh () { onPullDownRefresh () {
this.params.pageNumber = this.params.pageNumber + 1 this.params.pageNumber = this.params.pageNumber + 1
this.getTalkMessage() this.getTalkMessage()
@ -433,12 +436,11 @@ export default {
uni.connectSocket({ uni.connectSocket({
url: url, url: url,
}); });
}, 5 * 1000) }, 999999)
} }
}); });
// //
uni.onSocketMessage(function (res) { uni.onSocketMessage(function (res) {
console.log(res.data);
res.data = JSON.parse(res.data) res.data = JSON.parse(res.data)
console.log(res.data.result); console.log(res.data.result);
if (res.data.messageResultType == 'MESSAGE') { if (res.data.messageResultType == 'MESSAGE') {

View File

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

View File

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