chat.vue 27 KB

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