|
@@ -219,6 +219,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
});
|
|
|
exports.default = void 0;
|
|
|
var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ 35));
|
|
|
+var _toConsumableArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/toConsumableArray */ 18));
|
|
|
var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ 11));
|
|
|
var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ 37));
|
|
|
var _websocket = _interopRequireDefault(__webpack_require__(/*! @/common/websocket.js */ 93));
|
|
@@ -250,7 +251,8 @@ var _default = {
|
|
|
list: [],
|
|
|
total: 0,
|
|
|
skip: 0,
|
|
|
- limit: 20,
|
|
|
+ limit: 6,
|
|
|
+ page: 0,
|
|
|
record: '',
|
|
|
// 全局唯一录音管理区
|
|
|
inrecord: false,
|
|
@@ -261,6 +263,10 @@ var _default = {
|
|
|
// 全局音频播放
|
|
|
poaMessgae: 'poaMessgae',
|
|
|
//滚动到最底部
|
|
|
+ // 判断是否跳到最后一条
|
|
|
+ is_bottom: true,
|
|
|
+ // 判断是否下拉刷新复位
|
|
|
+ triggered: false,
|
|
|
//实时通信
|
|
|
client: null,
|
|
|
subscription: null
|
|
@@ -280,25 +286,18 @@ var _default = {
|
|
|
uni.setNavigationBarTitle({
|
|
|
title: e && e.title || '聊天室'
|
|
|
});
|
|
|
- // 全局唯一录音管理器
|
|
|
- that.record = uni.getRecorderManager();
|
|
|
- _context.next = 8;
|
|
|
+ _context.next = 7;
|
|
|
return that.searchToken();
|
|
|
- case 8:
|
|
|
- _context.next = 10;
|
|
|
+ case 7:
|
|
|
+ _context.next = 9;
|
|
|
return that.searchConfig();
|
|
|
- case 10:
|
|
|
- _context.next = 12;
|
|
|
+ case 9:
|
|
|
+ _context.next = 11;
|
|
|
return that.searchOther();
|
|
|
- case 12:
|
|
|
- _context.next = 14;
|
|
|
+ case 11:
|
|
|
+ _context.next = 13;
|
|
|
return that.search();
|
|
|
- case 14:
|
|
|
- // 滚动到最底部
|
|
|
- that.poalast();
|
|
|
- // stomp协议请求 实时链接
|
|
|
- that.initWS();
|
|
|
- case 16:
|
|
|
+ case 13:
|
|
|
case "end":
|
|
|
return _context.stop();
|
|
|
}
|
|
@@ -310,6 +309,31 @@ var _default = {
|
|
|
}
|
|
|
return onLoad;
|
|
|
}(),
|
|
|
+ onShow: function () {
|
|
|
+ var _onShow = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
|
+ var that;
|
|
|
+ return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
|
+ while (1) {
|
|
|
+ switch (_context2.prev = _context2.next) {
|
|
|
+ case 0:
|
|
|
+ that = this; // 全局唯一录音管理器
|
|
|
+ that.record = uni.getRecorderManager();
|
|
|
+ // 滚动到最底部
|
|
|
+ that.poalast();
|
|
|
+ // stomp协议请求 实时链接
|
|
|
+ that.initWS();
|
|
|
+ case 4:
|
|
|
+ case "end":
|
|
|
+ return _context2.stop();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, _callee2, this);
|
|
|
+ }));
|
|
|
+ function onShow() {
|
|
|
+ return _onShow.apply(this, arguments);
|
|
|
+ }
|
|
|
+ return onShow;
|
|
|
+ }(),
|
|
|
// 离开页面是关闭连接
|
|
|
// 我的业务是仿微信这种,每次连接人不同,频繁建立新连接,根据自己需要决定什么时候关闭连接
|
|
|
onUnload: function onUnload() {
|
|
@@ -338,11 +362,11 @@ var _default = {
|
|
|
},
|
|
|
search: function search() {
|
|
|
var _this = this;
|
|
|
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
|
- var that, info, arr;
|
|
|
- return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
|
+ return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
|
+ var that, info, res, list;
|
|
|
+ return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
|
while (1) {
|
|
|
- switch (_context2.prev = _context2.next) {
|
|
|
+ switch (_context3.prev = _context3.next) {
|
|
|
case 0:
|
|
|
that = _this; // 聊天记录
|
|
|
info = {
|
|
@@ -352,24 +376,26 @@ var _default = {
|
|
|
group: that.groupId,
|
|
|
doctor: that.doctorId
|
|
|
};
|
|
|
- _context2.next = 4;
|
|
|
+ _context3.next = 4;
|
|
|
return that.$api("/chat", 'GET', _objectSpread({}, info));
|
|
|
case 4:
|
|
|
- arr = _context2.sent;
|
|
|
- if (arr.errcode == '0') {
|
|
|
- that.$set(that, "list", arr.data);
|
|
|
+ res = _context3.sent;
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ list = [].concat((0, _toConsumableArray2.default)(res.data.reverse()), (0, _toConsumableArray2.default)(that.list));
|
|
|
+ that.$set(that, "list", list);
|
|
|
+ that.$set(that, "total", res.total);
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
- title: arr.errmsg,
|
|
|
+ title: res.errmsg,
|
|
|
icon: 'none'
|
|
|
});
|
|
|
}
|
|
|
case 6:
|
|
|
case "end":
|
|
|
- return _context2.stop();
|
|
|
+ return _context3.stop();
|
|
|
}
|
|
|
}
|
|
|
- }, _callee2);
|
|
|
+ }, _callee3);
|
|
|
}))();
|
|
|
},
|
|
|
// 处理时间
|
|
@@ -526,11 +552,11 @@ var _default = {
|
|
|
// 发送消息
|
|
|
toSend: function toSend(e) {
|
|
|
var _this2 = this;
|
|
|
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
|
+ return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
|
var that, mess, data, res;
|
|
|
- return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
|
+ return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
|
while (1) {
|
|
|
- switch (_context3.prev = _context3.next) {
|
|
|
+ switch (_context4.prev = _context4.next) {
|
|
|
case 0:
|
|
|
that = _this2;
|
|
|
mess = {
|
|
@@ -541,10 +567,10 @@ var _default = {
|
|
|
doctor: that.doctorId
|
|
|
};
|
|
|
data = _objectSpread(_objectSpread({}, e), mess);
|
|
|
- _context3.next = 5;
|
|
|
+ _context4.next = 5;
|
|
|
return that.$api("/chat", 'POST', data);
|
|
|
case 5:
|
|
|
- res = _context3.sent;
|
|
|
+ res = _context4.sent;
|
|
|
if (res.errcode == '0') {
|
|
|
that.search();
|
|
|
that.$set(that, "isRecorder", false);
|
|
@@ -557,12 +583,40 @@ var _default = {
|
|
|
}
|
|
|
case 7:
|
|
|
case "end":
|
|
|
- return _context3.stop();
|
|
|
+ return _context4.stop();
|
|
|
}
|
|
|
}
|
|
|
- }, _callee3);
|
|
|
+ }, _callee4);
|
|
|
}))();
|
|
|
},
|
|
|
+ // 下拉刷新分页
|
|
|
+ getFresh: function getFresh(e) {
|
|
|
+ var that = this;
|
|
|
+ that.$set(that, "triggered", true);
|
|
|
+ var list = that.list;
|
|
|
+ var limit = that.limit;
|
|
|
+ setTimeout(function () {
|
|
|
+ if (that.total > list.length) {
|
|
|
+ uni.showLoading({
|
|
|
+ title: '加载中',
|
|
|
+ mask: true
|
|
|
+ });
|
|
|
+ var page = that.page + 1;
|
|
|
+ that.$set(that, "page", page);
|
|
|
+ var skip = page * limit;
|
|
|
+ that.$set(that, "skip", skip);
|
|
|
+ that.$set(that, "is_bottom", false);
|
|
|
+ that.search();
|
|
|
+ uni.hideLoading();
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: "\u6CA1\u6709\u66F4\u591A\u804A\u5929\u8BB0\u5F55\u4E86",
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ that.triggered = false;
|
|
|
+ }, 1000);
|
|
|
+ },
|
|
|
// 定位到消息最后一行
|
|
|
poalast: function poalast() {
|
|
|
var that = this;
|