chat.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923
  1. <template>
  2. <view>
  3. <view class="flex_c page" @touchmove="touchmove">
  4. <scroll-view class="flex1 scroll-Y" @tap.stop="onPage" id="scroll-view" lower-threshold="100" scroll-y
  5. scroll-with-animation :scroll-top="scroll_top" @scroll="scroll" @scrolltoupper="scrolltoupper"
  6. @scrolltolower="scrolltolower">
  7. <view class="scroll-view-str" :style="{height: `${reserveHeight}px`}" v-if="reserveHeight>0"></view>
  8. <view class="messageList_">
  9. <template v-for="(item, index) in history.messages">
  10. <!-- #ifdef APP || H5 -->
  11. <view class="z_index2" :class="`oneheight_${index}`" style="transform: rotate(-180deg)"
  12. :key="item.messageId + index" v-if="!item.isHide">
  13. <view class="icon_ text_26 color__ time">
  14. {{ renderMessageDate(item, index) }}
  15. </view>
  16. <view :key="item.messageId + index" v-if="!item.recalled">
  17. <item :isMy="isSelf(item.senderId)" :myid="myid" :item="item" @onClick="onItem"
  18. @onLongpress="onLongpress" @mention="mention" @imgLoad="imgLoad"></item>
  19. </view>
  20. <view class="icon_ text_26 recalled" v-else>
  21. <view class="">
  22. <text v-if="isSelf(item.senderId)">你</text>
  23. <text v-else>{{ item.senderData.name }}</text>
  24. 撤回了一条消息
  25. </view>
  26. <view class="recalled-edit" v-if="item.type === 'text' && isSelf(item.senderId)"
  27. @click="recalledEdit(item)">重新编辑</view>
  28. </view>
  29. </view>
  30. <!-- #endif -->
  31. <!-- #ifdef MP -->
  32. <view class="z_index2" style="transform: rotate(-180deg)" :key="item.messageId"
  33. v-if="!item.isHide">
  34. <view class="icon_ text_26 color__ time">
  35. {{ renderMessageDate(item, index) }}
  36. </view>
  37. <view :key="item.messageIds" v-if="!item.recalled">
  38. <item :isMy="isSelf(item.senderId)" :myid="myid" :item="item" @onClick="onItem"
  39. @onLongpress="onLongpress" @mention="mention"></item>
  40. </view>
  41. <view class="icon_ text_26 recalled" v-else>
  42. <view class="">
  43. <text v-if="isSelf(item.senderId)">你</text>
  44. <text v-else>{{ item.senderData.name }}</text>
  45. 撤回了一条消息
  46. </view>
  47. <view class="recalled-edit" v-if="item.type === 'text' && isSelf(item.senderId)"
  48. @click="recalledEdit(item)">重新编辑</view>
  49. </view>
  50. </view>
  51. <!-- #endif -->
  52. </template>
  53. </view>
  54. </scroll-view>
  55. <view class="bottomOperationRef">
  56. <view class="bottom-btn-group">
  57. <!-- <view class="btn-item">
  58. <image src="https://jymini.oss-cn-guangzhou.aliyuncs.com/mini/star.svg"></image>
  59. <view class="name">评价服务</view>
  60. </view> -->
  61. <view class="btn-item" @click="showOrder(1)">
  62. <image src="https://jymini.oss-cn-guangzhou.aliyuncs.com/mini/order.svg"></image>
  63. <view class="name">我的订单</view>
  64. </view>
  65. </view>
  66. <view class="bottom-operation-box">
  67. <view class="input-text">
  68. <textarea class="input" placeholder="输入点什么呢..." auto-height="true" confirm-type="send" type="text" :focus="isFocus"
  69. :maxlength="-1" :adjust-position="false" v-model="text" confirm-hold
  70. :show-confirm-bar="false" @input="input" @confirm="sendingText" @focus="focus"
  71. @blur="blured" @keyboardheightchange="keyboardheightchange" />
  72. </view>
  73. <view class="check-img">
  74. <view class="check-icon" @click="tapEmoji"><image src="@/static/image/face.svg" mode="aspectFill"></image></view>
  75. <view class="check-icon" @click="tapMore"><image src="@/static/image/more.svg" mode="aspectFill"></image></view>
  76. </view>
  77. </view>
  78. <view class="safe-box"></view>
  79. <view class="keyboardheight" :style="{ height: keyboardHeight + 'px' }"></view>
  80. </view>
  81. <view>
  82. <emoji v-model="isEmoji" @onEmoji="onEmoji" @deleteFn="deleteFn" @sendingText="sendingText"
  83. @sendingEmojiPack="sendingEmojiPack"></emoji>
  84. </view>
  85. <view>
  86. <more v-model="isMore" @onMore="onMore"></more>
  87. </view>
  88. </view>
  89. <uni-popup ref="addresspopup" type="bottom" border-radius="10px 10px 0 0" background-color="#ffffff" :mask-click="false">
  90. <view class="order-popup">
  91. <view class="order-title">
  92. <view class="name">补充收货地址</view>
  93. <view class="close" @click="showAddress(2)"><image src="/static/image/close.png"></image></view>
  94. </view>
  95. <view class="order-body">
  96. <view class="form-feedbak">
  97. <view class="title"><text>*</text>收件人</view>
  98. <view class="form-textarea">
  99. <input v-model="addressForm.nickname" placeholder="请输入" class="u-input" />
  100. </view>
  101. </view>
  102. <view class="form-feedbak">
  103. <view class="title"><text>*</text>手机号码</view>
  104. <view class="form-textarea">
  105. <input v-model="addressForm.mobile" placeholder="请填写手机号码" class="u-input" />
  106. </view>
  107. </view>
  108. <view class="form-feedbak">
  109. <view class="title"><text>*</text>所属地区</view>
  110. <view class="form-textarea">
  111. <uni-data-picker placeholder="请选择地址" popup-title="请选择城市" :localdata="cityData" @change="addressChange" @nodeclick="addressChange">
  112. </uni-data-picker>
  113. </view>
  114. </view>
  115. <view class="form-feedbak">
  116. <view class="title"><text>*</text>详细地址</view>
  117. <view class="form-textarea">
  118. <input v-model="addressForm.address" placeholder="请输入" class="u-input" />
  119. </view>
  120. </view>
  121. <view class="submit-btn">
  122. <button class="btn" @click="submitForm" :loading="submitState" :disabled="submitState">{{submitState?'提交中':'提交'}}</button>
  123. </view>
  124. </view>
  125. </view>
  126. </uni-popup>
  127. <uni-popup ref="orderpopup" type="bottom" border-radius="10px 10px 0 0" background-color="#ffffff" :mask-click="false">
  128. <view class="order-popup">
  129. <view class="order-title">
  130. <view class="name">我的订单</view>
  131. <view class="close" @click="showOrder(2)"><image src="/static/image/close.png"></image></view>
  132. </view>
  133. <view class="order-body" v-if="orderData.length > 0">
  134. <view class="m-order-s" v-for="(items,index) in orderData" :key="index">
  135. <view class="order-img"><image :src="items.img" mode="widthFix"></image></view>
  136. <view class="order-info">
  137. <view class="title">{{items.product.product_name}}</view>
  138. <view class="desc">{{items.out_order_no}}</view>
  139. <view class="price">{{ $dialog.formatMoney(items.price,true) }}</view>
  140. </view>
  141. <view class="status-btn-group">
  142. <view class="status danger" @click="sendOrder(items)">发送</view>
  143. <view class="status info" v-if="items.status=='0'">未支付</view>
  144. <view class="status primary" v-if="items.status=='1'">待使用</view>
  145. <view class="status success" v-if="items.status=='2'">已完成</view>
  146. <view class="status danger" v-if="items.status=='3'">已退款</view>
  147. <view class="status warn" v-if="items.status=='4'">退款中</view>
  148. <view class="status info" v-if="items.status=='5'">已关闭</view>
  149. </view>
  150. </view>
  151. </view>
  152. <view class="order-body" v-else>
  153. <view class="empty-body">暂无数据...</view>
  154. </view>
  155. <view class="view-more" v-if="orderMore" @click="showOrder(1)">{{orderLoading?'加载中...':'展开更多'}}</view>
  156. </view>
  157. </uni-popup>
  158. </view>
  159. </template>
  160. <script>
  161. var app;
  162. let getSelectedTextRangeSetInterval = null;
  163. let inputValue = '';
  164. let cursor = 0; //输入框光标
  165. let scroll_top = 0;
  166. import emoji from '@/components/bottom-operation/emoji.vue';
  167. import more from '@/components/bottom-operation/more.vue';
  168. import item from '@/components/item/index';
  169. // 浏览照片数组
  170. let imageList = [];
  171. // 是否是手动触发的列表滑动
  172. let isBottomOperationScrollToBottom = false;
  173. import {
  174. show,
  175. formatDate,
  176. throttle,
  177. openimg,
  178. getLocation,
  179. to as tofn
  180. } from '@/utils/index.js';
  181. import {
  182. mapState
  183. } from 'vuex';
  184. var {Push} = require("@/static/js/push.js")
  185. import * as Api from "@/static/api/service.js";
  186. import form from "@/static/js/form.js";
  187. export default {
  188. components: {
  189. emoji,
  190. more,
  191. item
  192. },
  193. data() {
  194. return {
  195. submitState:false,
  196. serviceId:null, // 客服ID
  197. reserveHeight:0,
  198. isFocus: false, //键盘焦点
  199. isEmoji:false,
  200. isMore:false,
  201. keyboardHeight:0,
  202. optionsData:null,
  203. testData:null,
  204. text:"",
  205. // 历史数据
  206. history: {
  207. messages: [],
  208. allLoaded: false
  209. },
  210. showOrderState:false,
  211. orderMore:false,
  212. orderLoading:false,
  213. storeData:null,
  214. sendId:null,
  215. myid:"",
  216. pushObj:null,
  217. wsAuth:"https://tran.jsshuita.cn/plugin/webman/push/auth",
  218. wsUrl: 'wss://tran.jsshuita.cn/ws',
  219. page:2,
  220. size:10,
  221. orderPage:1,
  222. orderData:[],
  223. noService:false,
  224. addressData:null,
  225. addressForm:{},
  226. cityData:[],
  227. userAvatar:null
  228. }
  229. },
  230. computed: mapState({
  231. //显示时间
  232. renderMessageDate() {
  233. return (message, index) => {
  234. if (message.timestamp - this.history.messages[index + 1]?.timestamp > 3 * 60 * 1000) {
  235. return formatDate(message.timestamp, 'timestamp');
  236. }
  237. return '';
  238. };
  239. },
  240. // 是否本人isMy
  241. isSelf() {
  242. return (senderId) => {
  243. const {
  244. member_id = this.myid
  245. } = {"member_id":this.myid};
  246. return senderId === `${member_id}`;
  247. };
  248. },
  249. }),
  250. onLoad(options) {
  251. var app = this;
  252. app.optionsData = options;
  253. uni.setNavigationBarTitle({
  254. title:"加载中..."
  255. });
  256. app.getService(options)
  257. },
  258. beforeDestroy() {
  259. cursor = 0;
  260. this.pushObj.disconnect()
  261. },
  262. onPageScroll(e) {
  263. // this.$refs.bottomOperationRef.closeAll();
  264. },
  265. onReady() {
  266. // this.videoPlayer.context = uni.createVideoContext('videoPlayer', this);
  267. },
  268. methods: {
  269. initPush(){
  270. var _this = this;
  271. this.pushObj = new Push({
  272. "url":this.wsUrl,
  273. "app_key":"265c33b73d5c04f918978577df2c48d2",
  274. "auth":this.wsAuth
  275. });
  276. var user_channel = this.pushObj.subscribe('user-' + this.myid);
  277. user_channel.on('message', function (data) {
  278. // console.log(data);
  279. _this.formatMsg(data);
  280. })
  281. },
  282. addressChange(data){
  283. if (data.detail) {
  284. this.addressForm.city = JSON.stringify(data.detail.value);
  285. }
  286. },
  287. submitForm(){
  288. var formData = this.addressForm;
  289. var validation = form.validation(formData,[
  290. {name:"nickname",rule:["required"],msg:["请输入"]},
  291. {name:"mobile",rule:["required","isMobile"],msg:["请填写手机号码","手机号码格式错误"]},
  292. {name:"city",rule:["required"],msg:["请选择地区"]},
  293. {name:"address",rule:["required"],msg:["请输入"]},
  294. ]);
  295. if(validation){
  296. this.$dialog.showSuccess(validation);
  297. return false;
  298. }
  299. formData.order = JSON.stringify(this.addressData);
  300. this.submitState = true;
  301. Api.address(formData).then((res)=>{
  302. if (res.code == 0) {
  303. return this.$dialog.showSuccess(res.msg);
  304. }
  305. this.$dialog.showSuccess(res.msg);
  306. this.showAddress(2)
  307. return
  308. })
  309. },
  310. imgLoad(data){},
  311. onItem(data,index){
  312. switch(data.type) {
  313. case "address":
  314. var order = data.payload.address;
  315. order.msgId = data.messageId;
  316. this.addressData = order;
  317. Api.city().then((res)=>{
  318. this.cityData = res.data;
  319. this.showAddress(1)
  320. })
  321. break;
  322. case "order":
  323. var order = data.payload.order;
  324. break;
  325. case "image":
  326. uni.previewImage({
  327. urls:[data.payload.url]
  328. })
  329. break;
  330. case "pay":
  331. var payInfo = data.payload.pay;
  332. if (payInfo.status == 1) {
  333. return this.$dialog.showSuccess("已完成支付")
  334. }
  335. uni.navigateToMiniProgram({
  336. appId:payInfo.appid,
  337. path:payInfo.path,
  338. success(){},
  339. fail(){}
  340. })
  341. break;
  342. default:
  343. break;
  344. }
  345. },
  346. onLongpress(data){
  347. },
  348. // 滚动中
  349. scroll(e) {
  350. scroll_top = e.detail.scrollTop;
  351. // this.$refs.operateRef.close();
  352. if (isBottomOperationScrollToBottom) return;
  353. // this.$refs.bottomOperationRef.closeAll();
  354. },
  355. // 滚动到底部
  356. scrolltolower() {
  357. if (this.history.allLoaded) return;
  358. console.log('触底')
  359. this.getMoreMsg()
  360. // this.loadHistoryMessage();
  361. },
  362. // 滚动到顶部
  363. scrolltoupper() {
  364. console.log('滚动到顶部')
  365. },
  366. showAddress(type){
  367. if (type == 2) {
  368. this.$refs.addresspopup.close()
  369. return ;
  370. }
  371. this.$refs.addresspopup.open()
  372. },
  373. showOrder(type){
  374. if (type == 2) {
  375. this.$refs.orderpopup.close()
  376. return ;
  377. }
  378. this.orderLoading = true;
  379. Api.order({"size":this.size,"page":this.orderPage}).then((res)=>{
  380. this.orderLoading = false;
  381. if (res.code == 0) {
  382. return this.$dialog.showSuccess(res.msg)
  383. }
  384. this.orderData = this.orderData.concat(res.data.rows);
  385. this.$refs.orderpopup.open()
  386. this.orderPage = res.data.page + 1;
  387. this.orderMore = true;
  388. })
  389. },
  390. getMoreMsg(){
  391. this.history.allLoaded = true;
  392. var formData = this.optionsData;
  393. formData.page = this.page;
  394. Api.msg(formData).then((res)=>{
  395. if(res.code == 0) {
  396. return this.$dialog.showSuccess(res.msg)
  397. }
  398. if (res.data.rows.length > 0) {
  399. this.page ++;
  400. var msgData = []
  401. var list = res.data.rows
  402. // 同步混入数据
  403. list.forEach((item, ix) => {
  404. var payload = {};
  405. if (item.type == 'text') {
  406. payload.text = item.content
  407. }
  408. if (item.type == 'order') {
  409. var order = JSON.parse(item.content)
  410. payload.order = order
  411. }
  412. if (item.type == 'pay') {
  413. var order = JSON.parse(item.content)
  414. payload.pay = order
  415. }
  416. if (item.type == 'address') {
  417. var order = JSON.parse(item.content)
  418. payload.address = order
  419. }
  420. if (item.type == 'image') {
  421. payload = {
  422. contentType: 'image/png',
  423. name: 'uni-image.png',
  424. size: 82942,
  425. url: item.content,
  426. width: 2732,
  427. height: 2732,
  428. thumbnail: item.content
  429. };
  430. }
  431. const message = {
  432. groupId: item.poi_id,
  433. senderData: {
  434. avatar:item.avatar
  435. },
  436. senderId: (item.source==1?item.openid:item.service_id),
  437. messageId: item.msgId,
  438. payload: payload,
  439. timestamp: item.time,
  440. type: item.type,
  441. recalled: false,
  442. status: 'success',
  443. isHide: 0
  444. };
  445. msgData[ix] = message
  446. });
  447. // console.log(msgData)
  448. // 模拟只有少量数据
  449. // this.history.messages = [list[0],list[1],list[2]];
  450. this.history.messages = [...this.history.messages, ...msgData];
  451. this.history.allLoaded = false;
  452. // if (this.history.messages.length > 20) return;
  453. // msgData.forEach((item,index)=>{
  454. // this.formatMsg(item);
  455. // })
  456. } else {
  457. this.history.allLoaded = true;
  458. }
  459. })
  460. },
  461. getService(options){
  462. Api.shareout(options).then((res)=>{
  463. if (res.code && res.code == 0) {
  464. return app.$dialog.showSuccess(res.msg)
  465. }
  466. console.log(res.data)
  467. uni.setNavigationBarTitle({
  468. title:"与"+res.data.store.poi_name+"对话中"
  469. })
  470. this.storeData = res.data.store;
  471. this.sendId = res.data.sendId;
  472. this.serviceId = res.data.serviceId;
  473. this.myid = res.data.sendId;
  474. this.userAvatar = res.data.avatar;
  475. if (res.data.msg.rows.length > 0) {
  476. var msgData = res.data.msg.rows
  477. msgData.forEach((item,index)=>{
  478. this.formatMsg(item);
  479. })
  480. }
  481. if (res.data.code == 3) { // 无客服在线
  482. this.noService = true;
  483. this.emptyService()
  484. }
  485. this.initPush()
  486. })
  487. },
  488. emptyService(){
  489. const message = {
  490. groupId: this.storeData.poi_id,
  491. senderData: {
  492. avatar:"https://washmy.oss-cn-guangzhou.aliyuncs.com/storage/20260511/23627b2cb8f73a8a90b95c31d726e6ecad0cbb9a.png"
  493. },
  494. senderId: this.serviceId,
  495. messageId: Date.now(),
  496. payload: {
  497. text:"亲!当前无客服在线,请咨询商家电话客服哦!"
  498. },
  499. timestamp: Date.now(),
  500. type: "text",
  501. recalled: false,
  502. status: 'success',
  503. isHide: 0
  504. };
  505. this.pushList(message);
  506. },
  507. formatMsg(item){
  508. var payload = {};
  509. if (item.type == 'text') {
  510. payload.text = item.content
  511. }
  512. if (item.type == 'order') {
  513. var order = JSON.parse(item.content)
  514. payload.order = order
  515. }
  516. if (item.type == 'pay') {
  517. var order = JSON.parse(item.content)
  518. payload.pay = order
  519. }
  520. if (item.type == 'address') {
  521. var order = JSON.parse(item.content)
  522. payload.address = order
  523. }
  524. if (item.type == 'image') {
  525. payload = {
  526. contentType: 'image/png',
  527. name: 'uni-image.png',
  528. size: 82942,
  529. url: item.content,
  530. width: 2732,
  531. height: 2732,
  532. thumbnail: item.content
  533. };
  534. }
  535. const message = {
  536. groupId: item.poi_id,
  537. senderData: {
  538. avatar:item.avatar
  539. },
  540. senderId: (item.source==1?item.openid:item.service_id),
  541. messageId: item.msgId,
  542. payload: payload,
  543. timestamp: item.time,
  544. type: item.type,
  545. recalled: false,
  546. status: 'success',
  547. isHide: 0
  548. };
  549. this.pushList(message);
  550. },
  551. // 更多操作相关===============
  552. onMore(item) {
  553. // console.log(item)
  554. switch (item.type) {
  555. case 'img':
  556. this.sendImageMessage();
  557. break;
  558. case 'video':
  559. this.sendVideoMessage();
  560. break;
  561. case 'order':
  562. this.showOrder(1);
  563. break;
  564. }
  565. },
  566. sendOrder(items){
  567. var orderData = {};
  568. orderData.img = items.img;
  569. orderData.name = items.product.product_name;
  570. orderData.goods_id = items.life_goods_id;
  571. orderData.order = items.out_order_no;
  572. orderData.price = (parseInt(items.pay_money) / 100).toFixed(2);
  573. orderData.status = items.status;
  574. Api.send({type:"order",content: JSON.stringify(orderData),sendId: this.serviceId,groupId: this.storeData.poi_id}).then((res)=>{
  575. if (res.code == 0) {
  576. return this.$dialog.showSuccess(res.msg)
  577. }
  578. this.showOrder(2);
  579. this.sendMessage({
  580. payload: {
  581. order: orderData
  582. },
  583. type: 'order'
  584. });
  585. })
  586. },
  587. // 创建发送照片内容
  588. sendImageMessage() {
  589. uni.chooseImage({
  590. count: 1,
  591. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  592. success: async (res) => {
  593. res.tempFiles.forEach((file) => {
  594. console.log(file);
  595. this.createImageMessage(file);
  596. });
  597. },
  598. fail(e) {
  599. console.log("选择失败",e)
  600. }
  601. });
  602. },
  603. // 创建发送照片内容
  604. createImageMessage(file) {
  605. Api.upload(file.path,{type:"image",sendId: this.serviceId,groupId: this.storeData.poi_id}).then((res)=>{
  606. var respData = JSON.parse(res);
  607. if (respData.code == 0) {
  608. return this.$dialog.showSuccess(respData.msg)
  609. }
  610. this.sendMessage({
  611. payload: {
  612. contentType: 'image/png',
  613. name: 'uni-image.png',
  614. size: 82942,
  615. url: respData.data.path,
  616. width: 2732,
  617. height: 2732,
  618. thumbnail: respData.data.path
  619. },
  620. type: 'image'
  621. });
  622. })
  623. },
  624. // 创建发送视频内容
  625. sendVideoMessage() {
  626. uni.chooseVideo({
  627. success: async (res) => {
  628. console.log(res);
  629. this.createVideoMessage(res);
  630. }
  631. });
  632. },
  633. createVideoMessage(file) {
  634. this.sendMessage({
  635. payload: {
  636. video: {
  637. name: '3003009356267921_uni-video.mp4',
  638. url: file.tempFilePath,
  639. width: 640,
  640. height: 352,
  641. contentType: 'video/mp4',
  642. size: 501774,
  643. duration: 8.32
  644. },
  645. thumbnail: {
  646. name: 'uni-thumbnail.jpg',
  647. url: '封面路径',
  648. width: 364,
  649. height: 200,
  650. contentType: 'image/jpg'
  651. }
  652. },
  653. type: 'video'
  654. });
  655. },
  656. sendMessage({payload,type}){
  657. const message = {
  658. groupId: this.storeData.poi_id,
  659. senderData: {
  660. avatar:this.userAvatar
  661. },
  662. senderId: this.sendId,
  663. messageId: Date.now(),
  664. payload: payload,
  665. timestamp: Date.now(),
  666. type: type,
  667. recalled: false,
  668. status: 'success',
  669. isHide: 0
  670. };
  671. this.pushList(message);
  672. },
  673. // 组装item
  674. initMessageItem(message, index) {
  675. message['isHide'] = 0;
  676. if (index === 0 && (message.type === 'text' || message.type === 'text_quote')) {
  677. this.onSetText(message.payload.text);
  678. }
  679. },
  680. // 文本触发效果相关========
  681. onSetText(text) {
  682. // 触发礼花
  683. throttle(() => {
  684. if (text.includes('[彩带]')) {
  685. this.$refs.mScreenAnimationLihua.show();
  686. uni.vibrateLong();
  687. }
  688. }, 4000);
  689. },
  690. sendingEmojiPack(){
  691. },
  692. // 删除表情
  693. deleteFn() {
  694. const str = this.text.charAt(this.text.length - 1);
  695. if (str === ']') {
  696. let metaChars = /\[.*?(\u4e00*\u597d*)\]/g;
  697. let xstr = '';
  698. this.text.replace(metaChars, (match) => {
  699. xstr = match;
  700. });
  701. var text = this.text;
  702. function del(str) {
  703. return text.slice(0, text.length - str.length);
  704. }
  705. this.text = del(xstr);
  706. } else {
  707. this.text = this.text.substring(0, this.text.length - 1);
  708. }
  709. },
  710. onEmoji(key) {
  711. const text = `${this.text.slice(0, cursor)}${key}${this.text.slice(cursor)}`;
  712. this.text = text;
  713. },
  714. tapEmoji() {
  715. this.isEmoji = !this.isEmoji;
  716. if (this.isEmoji) {
  717. this.isKeyboard = true;
  718. }
  719. this.isMore = false;
  720. },
  721. tapMore() {
  722. this.isMore = !this.isMore;
  723. this.isEmoji = false;
  724. },
  725. touchmove(){
  726. this.isFocus = false;
  727. this.isFocisEmojius = false;
  728. this.isMore = false;
  729. this.isKeyboard = false;
  730. this.keyboardHeight = 0
  731. },
  732. onPage(){},
  733. // 监听输入
  734. input() {
  735. // if (inputValue.length > this.text.length) {} else {
  736. // const str = this.text.charAt(this.text.length - 1);
  737. // }
  738. // inputValue = this.text;
  739. },
  740. blured(){
  741. this.isFocus = false;
  742. this.keyboardHeight = 0
  743. },
  744. // 获取焦点
  745. focus(e) {
  746. this.testData = JSON.stringify(e.detail);
  747. this.isFocus = true;
  748. this.isEmoji = false;
  749. this.isMore = false;
  750. this.keyboardHeight = (e.detail.height==100)?0:e.detail.height
  751. },
  752. keyboardheightchange(e){
  753. // app.$dialog.showSuccess('asdasdasd')
  754. console.log(e)
  755. },
  756. sendingText() {
  757. if (this.text === '')
  758. return ;
  759. let body = this.text;
  760. if (this.text.length >= 50) {
  761. body = this.text.substring(0, 30) + '...';
  762. }
  763. Api.send({type:"text",content: this.text,sendId: this.serviceId,groupId: this.storeData.poi_id}).then((res)=>{
  764. if (res.code == 0) {
  765. return this.$dialog.showSuccess(res.msg)
  766. }
  767. this.sendMessage({
  768. payload: {
  769. text: this.text
  770. },
  771. type: 'text'
  772. });
  773. this.text = '';
  774. })
  775. },
  776. async pushList(message) {
  777. this.initMessageItem(message);
  778. this.history.messages.unshift(message);
  779. // 是否触发文字动效果
  780. if (message.type === 'text' || message.type === 'text_quote') {
  781. this.onSetText(message.payload.text);
  782. }
  783. // 缓存照片地址,
  784. if (message.type === 'image' || message.type === 'image_transmit') {
  785. imageList.push(message.payload.url);
  786. }
  787. },
  788. }
  789. }
  790. </script>
  791. <style lang="scss">
  792. @import '@/static/index.scss';
  793. .order-popup .order-title{display: flex;align-items: center;justify-content: space-between;font-size: 28upx;padding: 20upx;}
  794. .order-popup .order-title image{width: 40upx;height: 40upx;}
  795. .order-popup .order-body{height: 40vh;overflow: auto;padding: 20upx;}
  796. .view-more{text-align: center;font-size: 24upx;color: #666;padding: 20upx;}
  797. .submit-btn{
  798. background-color: #fff;
  799. border-radius: 20upx 0;
  800. padding: 20upx;
  801. }
  802. .submit-btn .btn{
  803. text-align: center;
  804. width: 100%;
  805. height: 80upx;
  806. line-height: 80upx;
  807. background-color: #956937;
  808. color: #fff;
  809. font-size: 30upx;
  810. border-radius: 40upx;
  811. }
  812. .form-feedbak{
  813. background-color: #fff;
  814. border-radius: 20upx;
  815. }
  816. .form-feedbak .title{
  817. line-height: 80upx;
  818. font-size: 28upx;
  819. }
  820. .form-feedbak .title text{
  821. color: #f00;
  822. margin-right: 10upx;
  823. }
  824. .form-feedbak .form-textarea{
  825. background-color: #f8f8f8;
  826. padding: 20upx;
  827. }
  828. .u-textarea{
  829. font-size: 24upx;
  830. }
  831. .u-input{
  832. font-size: 24upx;
  833. }
  834. .m-order-s{background-color: #f8f8f8;border-radius: 10upx;display: flex;font-size: 28upx;position: relative;margin-bottom: 20upx;}
  835. .m-order-s .order-img {display: flex;align-items: center;justify-content: center;}
  836. .m-order-s .order-img image{width: 150upx;height: 150upx;}
  837. .m-order-s .order-info {padding: 15upx;flex:1;overflow: hidden;}
  838. .m-order-s .order-info .title{font-size: 28upx;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;}
  839. .m-order-s .order-info .desc{font-size: 24upx;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;color: #999;}
  840. .m-order-s .order-info .price{font-size: 28upx;color: #f00;}
  841. .m-order-s .status-btn-group{position: absolute;right: 0;bottom: 0;display: flex;align-items: center;gap: 15upx;}
  842. .m-order-s .status{border-radius: 10upx 0 10upx 0;background-color: #909399;font-size: 24upx;color: #fff;padding: 10upx;}
  843. .m-order-s .status.info{background-color: #909399;}
  844. .m-order-s .status.primary{background-color: #409eff;}
  845. .m-order-s .status.success{background-color: #67c23a;}
  846. .m-order-s .status.danger{background-color: #f56c6c;}
  847. .m-order-s .status.warn{background-color: #e6a23c;}
  848. .bottomOperationRef{background-color: #f6f6f6;}
  849. .bottom-btn-group{display: flex;gap: 20upx;padding: 10rpx 14rpx;}
  850. .bottom-btn-group .btn-item{display: flex;align-items: center;gap: 10upx;font-size: 24upx;background-color: #f6f6f6;padding: 10rpx 14rpx;border-radius: 10upx;}
  851. .bottom-btn-group .btn-item image{width: 30upx;height: 30upx;}
  852. .bottom-operation-box{display: flex;padding: 20rpx 20rpx 0 20rpx;gap: 20rpx;align-items: flex-end;}
  853. .bottom-operation-box .check-img{display: flex;align-items: center;justify-content: center;}
  854. .bottom-operation-box .check-img .check-icon{width: 84rpx;height: 84rpx;display: flex;align-items: center;justify-content: center;}
  855. .bottom-operation-box .check-img image{width: 75%;height: 75%;}
  856. .bottom-operation-box .input-text{flex: 1;width: 100%;
  857. box-sizing: border-box;
  858. padding: 10rpx 14rpx;
  859. min-height: 84rpx;
  860. max-height: 300rpx;
  861. overflow: auto;
  862. border-radius: 10rpx;
  863. background-color: #fff}
  864. .bottom-operation-box .input{margin: 10rpx 0;width: 100%;font-size: 24upx;height: 100%;background-color: transparent;min-height: 48rpx;
  865. max-height: 300rpx;}
  866. .safe-box{width: 100%;height: env(safe-area-inset-bottom);background-color: #f6f6f6;}
  867. .page {
  868. position: fixed;
  869. z-index: 1;
  870. top: 0;
  871. left: 0;
  872. bottom: 0;
  873. right: 0;
  874. background-color: #ededed;
  875. }
  876. .scroll-Y {
  877. width: 100%;
  878. height: 0;
  879. transition: all 0.2s;
  880. transform: rotate(180deg);
  881. background-color: #ededed;
  882. padding: 20upx 0;
  883. ::-webkit-scrollbar {
  884. display: none;
  885. }
  886. }
  887. .scroll-view-str {
  888. width: 100%;
  889. }
  890. .time {
  891. width: 100%;
  892. color: #a3a3a3;
  893. line-height: 100rpx;
  894. }
  895. .recalled {
  896. width: 100%;
  897. height: 50rpx;
  898. margin: 20rpx 0;
  899. color: #a3a3a3;
  900. .recalled-edit {
  901. color: #5a6693;
  902. margin-left: 14rpx;
  903. }
  904. }
  905. </style>