Compare commits

..

No commits in common. "0d226b19ea40ba90597efb3f82a1c60424e14d05" and "59bf3fdb7ad4be8e96f4837b3c0b16d5e977e3e3" have entirely different histories.

17 changed files with 59 additions and 72 deletions

View File

@ -57,7 +57,7 @@ packages/customerService/index/index
</template>
<script>
import { menuButtonInfo, picUrl, request } from '@/utils'
import { menuButtonInfo, picUrl, request } from '../../../utils'
import { apiArr } from '@/api/customerService'
import mqttTool from '@/utils/mqtt'
@ -221,7 +221,7 @@ export default {
//
this.startKeepalive()
//
await this.loadHistoryMessages()
this.loadHistoryMessages()
} catch (error) {
console.error('初始化聊天失败', error)
this.connectingStatus = '连接失败,请检查网络'
@ -324,16 +324,15 @@ export default {
//
//
historyMessages.map(msg => (
this.messages = [{
content: msg.content,
time: new Date(msg.create_time).getTime(),
isSelf: msg.send_client === this.chatTarget.openId,
isLoading: false
}, ...this.messages])) //
const formattedMessages = historyMessages.map(msg => ({
content: msg.content,
time: new Date(msg.create_time).getTime(),
isSelf: msg.send_client === this.chatTarget.openId,
isLoading: false
})).reverse() //
//
// this.messages = [...formattedMessages, ...this.messages]
this.messages = [...formattedMessages, ...this.messages]
//
this.pageNum++

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -17114,6 +17114,7 @@ Object.defineProperty(exports, "__esModule", {
});
exports.default = void 0;
var _mqtt = _interopRequireDefault(__webpack_require__(/*! mqtt/dist/mqtt */ 300));
var _vue = _interopRequireDefault(__webpack_require__(/*! vue */ 25));
var _buffer = __webpack_require__(/*! buffer */ 53);
// 引入Buffer适配小程序环境
@ -17133,14 +17134,13 @@ mqttTool.connect = function (params) {
username: 'dev01',
password: '211561',
clean: true,
useSSL: true,
reconnectPeriod: 1000,
protocolVersion: 4,
connectTimeout: 600000,
cleanSession: false
};
var client = null;
client = _mqtt.default.connect('wxs://gmqt.hshuishang.com:443/mqtt', options);
client = _mqtt.default.connect('wx://api.hshuishang.com:8084/mqtt', options);
console.log('WX', client);
mqttTool.client = client;
@ -17248,18 +17248,7 @@ mqttTool.publish = function (params) {
});
});
};
mqttTool.disconnect = function () {
return new Promise(function (resolve, reject) {
if (mqttTool.client == null) {
resolve('未连接');
console.log('App_text' + ':unconnect 未连接');
return;
}
mqttTool.client.end();
mqttTool.client = null;
resolve('连接终止');
});
};
_vue.default.prototype.$mqtt = mqttTool;
var _default = mqttTool;
exports.default = _default;
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../HBuilderX/plugins/uniapp-cli/node_modules/webpack/buildin/global.js */ 3)))

View File

@ -7,7 +7,7 @@
"urlCheck": false,
"es6": false,
"postcss": false,
"minified": false,
"minified": true,
"newFeature": true,
"bigPackageSizeSupport": true
},

View File

@ -2,8 +2,20 @@
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "uniapp-ZHSQ",
"setting": {
"compileHotReLoad": true,
"urlCheck": true
"compileHotReLoad": true
},
"libVersion": "3.9.1"
"libVersion": "3.9.1",
"condition": {
"miniprogram": {
"list": [
{
"name": "packages/customerService/changeService/index",
"pathName": "packages/customerService/changeService/index",
"query": "",
"scene": null,
"launchMode": "default"
}
]
}
}
}

View File

@ -1,14 +1,13 @@
import mqtt from 'mqtt/dist/mqtt'
import Vue from 'vue'
// 引入Buffer适配小程序环境
import { Buffer } from 'buffer'
import { Buffer } from 'buffer';
// 挂载到全局,确保所有文件可访问
if (typeof window !== 'undefined') {
window.Buffer = Buffer
} else
if (typeof global !== 'undefined') {
global.Buffer = Buffer
}
window.Buffer = Buffer;
} else if (typeof global !== 'undefined') {
global.Buffer = Buffer;
}
let mqttTool = {
client: null
@ -20,46 +19,45 @@ mqttTool.connect = function(params, callbacks = {}){
username: 'dev01',
password: '211561',
clean: true,
useSSL: true,
reconnectPeriod: 1000,
protocolVersion: 4,
connectTimeout: 600000,
cleanSession: false
}
let client = null
client = mqtt.connect('wxs://gmqt.hshuishang.com:443/mqtt', options)
client = mqtt.connect('wx://api.hshuishang.com:8084/mqtt', options)
console.log('WX', client)
mqttTool.client = client
// 设置连接状态回调
if (callbacks.onConnect) {
client.on('connect', callbacks.onConnect)
}
if (callbacks.onDisconnect) {
client.on('disconnect', callbacks.onDisconnect)
}
if (callbacks.onError) {
client.on('error', callbacks.onError)
}
if (callbacks.onReconnect) {
client.on('reconnect', callbacks.onReconnect)
}
client.on('connect', function(){
client.on('connect', function() {
console.log('MQTT连接成功')
})
client.on('error', function(error){
client.on('error', function(error) {
console.log('MQTT连接错误:', error)
})
client.on('reconnect', function(){
client.on('reconnect', function() {
console.log('MQTT正在重连...')
})
return client
}
@ -148,16 +146,5 @@ mqttTool.publish = function(params){
})
})
}
mqttTool.disconnect = function(){
return new Promise((resolve, reject) => {
if (mqttTool.client == null) {
resolve('未连接')
console.log('App_text' + ':unconnect 未连接')
return
}
mqttTool.client.end()
mqttTool.client = null
resolve('连接终止')
})
}
Vue.prototype.$mqtt = mqttTool
export default mqttTool