chat.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  1. <template>
  2. <view>
  3. <view style="width: 100%; padding-bottom: 140rpx">
  4. <view style="display: flex; flex-direction: column" v-for="(item, index) in ListItem" :key="index">
  5. <view style="margin-top: 15rpx; width: 100%; text-align: center; font-size: 26rpx; color: #999999">
  6. {{ item.createTime }}
  7. </view>
  8. <view v-if="item.sendType === 2" style="width: 83%; margin-right: 15%">
  9. <view class="chat-listitem" style="float: left; margin-left: 10rpx">
  10. <view>
  11. <image src="../../static/images/img/kefu.png" class="chat-listitem-image"></image>
  12. </view>
  13. <view v-if="item.content && item.type === 1" class="chat-listitem-text" style="margin-left: 20rpx">{{ item.content }}</view>
  14. <image
  15. @tap="viewImg(item.content)"
  16. v-if="item.content && item.type === 2"
  17. :src="item.content"
  18. style="height: 200rpx; width: 200rpx; margin-left: 20rpx"
  19. ></image>
  20. </view>
  21. </view>
  22. <view v-if="item.sendType === 1" style="width: 83%; margin-left: 15%">
  23. <view class="chat-listitem" style="float: right">
  24. <view v-if="item.content && item.type === 1" @longpress="copy(item.content)" class="chat-listitem-text" style="margin-right: 20rpx">
  25. {{ item.content }}
  26. </view>
  27. <view
  28. v-if="item.content && item.type === 4"
  29. @click="goShop(item.content[3])"
  30. style="width: 400rpx; background: #ffffff; height: max-content; margin-right: 20rpx; margin-top: 10rpx; border-radius: 20rpx"
  31. >
  32. <image :src="item.content[0]" class="chat-listitem-image-type4" style="width: 400rpx; height: 350rpx"></image>
  33. <view style="padding: 10rpx; padding-bottom: 20rpx">
  34. <view style="color: #ed5732; font-size: 34rpx">
  35. <text style="font-size: 22rpx">¥</text>
  36. {{ item.content[2] }}
  37. </view>
  38. <view
  39. style="
  40. overflow: hidden;
  41. text-overflow: ellipsis;
  42. display: -webkit-box;
  43. -webkit-line-clamp: 2;
  44. -webkit-box-orient: vertical;
  45. width: 100%;
  46. height: 75upx;
  47. "
  48. >
  49. {{ item.content[1] }}
  50. </view>
  51. </view>
  52. </view>
  53. <view
  54. v-if="item.content && item.type === 3"
  55. style="width: 500rpx; background: #ffffff; height: max-content; margin-right: 20rpx; margin-top: 10rpx; border-radius: 20rpx; padding: 15rpx 10rpx"
  56. >
  57. <view style="color: #000000; font-weight: 600; margin-left: 10rpx">你正在咨询的订单</view>
  58. <view style="display: flex">
  59. <image :src="item.content[0]" class="chat-listitem-image-type4" style="margin-left: 7rpx; margin-top: 20rpx; width: 110rpx; height: 110rpx"></image>
  60. <view style="margin-top: 15rpx; padding: 10rpx 0rpx 5rpx 10rpx; width: 75%; background: #f5f5f5; margin-left: 10rpx">
  61. <view
  62. style="
  63. font-size: 28rpx;
  64. overflow: hidden;
  65. text-overflow: ellipsis;
  66. display: -webkit-box;
  67. -webkit-line-clamp: 2;
  68. -webkit-box-orient: vertical;
  69. height: 75upx;
  70. width: 100%;
  71. "
  72. >
  73. {{ item.content[1] }}
  74. </view>
  75. <view style="color: #ed5732; font-size: 28rpx">
  76. <text style="font-size: 22rpx">¥</text>
  77. {{ item.content[5] }}
  78. </view>
  79. </view>
  80. </view>
  81. <view style="color: #999999; margin-top: 10rpx; margin-left: 12rpx">
  82. <view>订单编号:{{ item.content[3] }}</view>
  83. <view style="margin-top: 10rpx">创建时间:{{ item.content[4] }}</view>
  84. </view>
  85. <view
  86. style="
  87. float: right;
  88. margin-right: 10rpx;
  89. margin-top: 15rpx;
  90. background: #f9221d;
  91. color: #ffffff;
  92. border-radius: 50rpx;
  93. width: 150rpx;
  94. height: 50rpx;
  95. font-size: 24rpx;
  96. text-align: center;
  97. line-height: 50rpx;
  98. "
  99. @click="goDingdanDetail(item.content[2])"
  100. >
  101. 查看
  102. </view>
  103. </view>
  104. <image
  105. @tap="viewImg(item.content)"
  106. v-if="item.content && item.type === 2"
  107. :src="item.content"
  108. style="height: 200rpx; width: 200rpx; margin-right: 20rpx"
  109. ></image>
  110. <view>
  111. <image v-if="item.chat.userHead" :src="item.chat.userHead" class="chat-listitem-image"></image>
  112. <image v-else src="../../static/logo.png" class="chat-listitem-image"></image>
  113. </view>
  114. </view>
  115. </view>
  116. <!-- <view v-if="item.sendType === 4" style="width: 83%;margin-left: 15%;">
  117. <view class="chat-listitem" style="float: right;">
  118. <view style="height: max-content;">
  119. <image :src="type4[0]" mode=""></image>
  120. </view>
  121. <image @tap="viewImg(item.content)" v-if="item.content && item.type === 2" :src="item.content" style="height: 200rpx;width: 170rpx;margin-right: 20rpx;"></image>
  122. <view>
  123. <image :src="item.chat.userHead" class="chat-listitem-image"></image>
  124. </view>
  125. </view>
  126. </view> -->
  127. </view>
  128. </view>
  129. <view
  130. v-if="ShopState"
  131. style="width: 95%; margin-left: 20rpx; height: 150upx; position: fixed; bottom: 120upx; z-index: 99; background-color: #ffffff; border-radius: 20rpx"
  132. >
  133. <view style="display: flex; width: 100%; color: #000000; padding: 20rpx">
  134. <image :src="Shopimage" style="width: 110rpx; height: 110rpx"></image>
  135. <view style="margin-left: 20rpx; width: 400rpx">
  136. <view style="font-size: 34rpx; color: #000000; overflow: hidden; text-overflow: ellipsis; flex-wrap: nowrap; white-space: nowrap; width: 98%">
  137. {{ ShopTitle }}
  138. </view>
  139. <view style="margin-top: 20rpx; color: #ed5732; font-size: 34rpx">¥{{ Shopmoney }}</view>
  140. </view>
  141. <view style="text-align: right">
  142. <image @click="ShopClose" src="../../static/images/img/close.png" style="width: 30rpx; height: 30rpx"></image>
  143. <view
  144. style="
  145. margin-top: 20rpx;
  146. background: #f9221d;
  147. color: #ffffff;
  148. border-radius: 50rpx;
  149. width: 150rpx;
  150. height: 50rpx;
  151. font-size: 24rpx;
  152. text-align: center;
  153. line-height: 50rpx;
  154. "
  155. @click="goMaijia"
  156. >
  157. 发送给商家
  158. </view>
  159. </view>
  160. </view>
  161. </view>
  162. <view
  163. v-if="orderState"
  164. style="width: 95%; margin-left: 20rpx; height: 150upx; position: fixed; bottom: 120upx; z-index: 99; background-color: #ffffff; border-radius: 20rpx"
  165. >
  166. <view style="display: flex; width: 100%; color: #000000; padding: 20rpx">
  167. <image :src="orderimage" style="width: 110rpx; height: 110rpx"></image>
  168. <view style="margin-left: 20rpx; width: 400rpx">
  169. <view style="font-size: 34rpx; color: #000000; overflow: hidden; text-overflow: ellipsis; flex-wrap: nowrap; white-space: nowrap; width: 98%">
  170. 你可能想咨询该订单
  171. </view>
  172. <view style="margin-top: 20rpx; color: #ed5732; font-size: 34rpx">¥{{ ordermoney }}</view>
  173. </view>
  174. <view style="text-align: right">
  175. <image @click="orderClose" src="../../static/images/img/close.png" style="width: 30rpx; height: 30rpx"></image>
  176. <view
  177. style="
  178. margin-top: 20rpx;
  179. background: #f9221d;
  180. color: #000000;
  181. border-radius: 50rpx;
  182. width: 150rpx;
  183. height: 50rpx;
  184. font-size: 24rpx;
  185. text-align: center;
  186. line-height: 50rpx;
  187. "
  188. @click="goDingdan"
  189. >
  190. 发送订单
  191. </view>
  192. </view>
  193. </view>
  194. </view>
  195. <!-- 底部聊天输入框 -->
  196. <view class="input-box">
  197. <view class="justify-between padding-lr" style="display: flex; margin-top: 15rpx; width: 100%; background-color: #eee; padding-top: 4upx">
  198. <image
  199. src="../../static/images/img/add.png"
  200. @click="chooseImage(['album'])"
  201. style="width: 50rpx; height: 50rpx; margin-top: 8rpx; margin-right: 12rpx; border-radius: 52upx"
  202. ></image>
  203. <input
  204. confirm-type="send"
  205. @confirm="setChatSave(1)"
  206. type="text"
  207. v-model="content"
  208. style="width: 72%; height: 70rpx; background: #fff; margin: 4rpx 10rpx 0; border-radius: 70rpx; padding-left: 10rpx; color: #000000"
  209. />
  210. <view class="save" @tap="setChatSave(1)">发送</view>
  211. </view>
  212. </view>
  213. <!-- 用于图片压缩的canvas画布 -->
  214. <canvas
  215. :style="{
  216. width: cw + 'px',
  217. height: cw + 'px',
  218. position: 'absolute',
  219. zIndex: -1,
  220. left: '-10000rpx',
  221. top: '-10000rpx'
  222. }"
  223. canvas-id="zipCanvas"
  224. ></canvas>
  225. <!--画布结束-->
  226. </view>
  227. </template>
  228. <script>
  229. import configdata from '../../common/config.js'
  230. import getLessLimitSizeImage from '@/utils/imageCompress.js'
  231. export default {
  232. data() {
  233. return {
  234. connected: false,
  235. connecting: false,
  236. msg: false,
  237. type4: [],
  238. listRight: {
  239. chat: {
  240. userHead: ''
  241. },
  242. content: '',
  243. sendType: 1,
  244. type: 1
  245. },
  246. content: '',
  247. chatId: '',
  248. type: 1,
  249. ListItem: [],
  250. ShopState: false,
  251. ShopordersId: '',
  252. Shopimage: '',
  253. Shopmoney: '',
  254. ShopTitle: '',
  255. orderState: false,
  256. ordersId: '',
  257. orderimage: '',
  258. orderNum: '',
  259. ordermoney: '',
  260. orderTitle: '',
  261. orderCreateTime: '',
  262. className: '',
  263. Shopsales: '',
  264. hand: 1,
  265. index: 0,
  266. page: 0,
  267. size: 1000,
  268. countDown: '',
  269. //画板边长默认是屏幕宽度,正方形画布
  270. cw: uni.getSystemInfoSync().windowWidth
  271. }
  272. },
  273. computed: {
  274. showMsg() {
  275. if (this.connected) {
  276. if (this.msg) {
  277. return '收到消息:' + this.msg
  278. } else {
  279. return '等待接收消息'
  280. }
  281. } else {
  282. return '尚未连接'
  283. }
  284. }
  285. },
  286. onUnload() {
  287. uni.closeSocket()
  288. uni.hideLoading()
  289. },
  290. onLoad(d) {
  291. if (d.className) {
  292. this.className = d.className
  293. if (d.className === 'shop') {
  294. this.ShopState = true
  295. this.ShopordersId = d.ordersId
  296. this.Shopimage = d.image
  297. this.Shopmoney = d.money
  298. this.Shopsales = d.sales
  299. this.ShopTitle = d.title
  300. } else if (d.className === 'order') {
  301. this.orderState = true
  302. this.ordersId = d.id
  303. this.orderimage = d.image
  304. this.ordermoney = d.money
  305. this.orderTitle = d.title
  306. this.orderNum = d.orderNum
  307. this.orderCreateTime = d.createTime
  308. }
  309. }
  310. this.getChatSave()
  311. this.connect()
  312. },
  313. onShow() {
  314. if (this.connected || this.connecting) {
  315. } else {
  316. this.connect()
  317. }
  318. },
  319. onHide() {
  320. uni.closeSocket()
  321. },
  322. methods: {
  323. copy(content) {
  324. uni.showModal({
  325. title: '温馨提示',
  326. content: '确认要复制此文字吗?',
  327. showCancel: true,
  328. cancelText: '取消',
  329. confirmText: '确认',
  330. success: (res) => {
  331. if (res.confirm) {
  332. uni.setClipboardData({
  333. data: content,
  334. success: (r) => {
  335. this.$queue.showToast('复制成功')
  336. }
  337. })
  338. }
  339. }
  340. })
  341. },
  342. h5Copy(content) {
  343. if (!document.queryCommandSupported('copy')) {
  344. // 不支持
  345. return false
  346. }
  347. let textarea = document.createElement('textarea')
  348. textarea.value = content
  349. textarea.readOnly = 'readOnly'
  350. document.body.appendChild(textarea)
  351. textarea.select() // 选择对象
  352. textarea.setSelectionRange(0, content.length) //核心
  353. let result = document.execCommand('copy') // 执行浏览器复制命令
  354. textarea.remove()
  355. return result
  356. },
  357. getDateDiff(data) {
  358. // 传进来的data必须是日期格式,不能是时间戳
  359. //var str = data;
  360. //将字符串转换成时间格式
  361. var timePublish = new Date(data)
  362. var timeNow = new Date()
  363. var minute = 1000 * 60
  364. var hour = minute * 60
  365. var day = hour * 24
  366. var month = day * 30
  367. var result = '2'
  368. var diffValue = timeNow - timePublish
  369. var diffMonth = diffValue / month
  370. var diffWeek = diffValue / (7 * day)
  371. var diffDay = diffValue / day
  372. var diffHour = diffValue / hour
  373. var diffMinute = diffValue / minute
  374. if (diffMonth > 3) {
  375. result = timePublish.getFullYear() + '-'
  376. result += timePublish.getMonth() + '-'
  377. result += timePublish.getDate()
  378. } else if (diffMonth > 1) {
  379. //月
  380. result = data.substring(0, 10)
  381. } else if (diffWeek > 1) {
  382. //周
  383. result = data.substring(0, 10)
  384. } else if (diffDay > 1) {
  385. //天
  386. result = data.substring(0, 10)
  387. } else if (diffHour > 1) {
  388. //小时
  389. result = parseInt(diffHour) + '小时前'
  390. } else if (diffMinute > 1) {
  391. //分钟
  392. result = parseInt(diffMinute) + '分钟前'
  393. } else {
  394. result = '刚刚'
  395. }
  396. return result
  397. },
  398. goDingdanDetail(id) {
  399. uni.navigateTo({
  400. url: '../member/orderdetail?id=' + id
  401. })
  402. },
  403. goShop(ordersId) {
  404. uni.navigateTo({
  405. url: './commoditydetail?ordersId=' + ordersId
  406. })
  407. },
  408. ShopClose() {
  409. this.ShopState = false
  410. },
  411. orderClose() {
  412. this.orderState = false
  413. },
  414. goDingdan() {
  415. this.orderState = false
  416. this.setChatSave(3)
  417. },
  418. goMaijia() {
  419. this.ShopState = false
  420. this.setChatSave(4)
  421. },
  422. connect() {
  423. let userId = this.$queue.getData('userId')
  424. if (this.connected || this.connecting) {
  425. uni.showModal({
  426. content: '正在连接或者已经连接,请勿重复连接',
  427. showCancel: false
  428. })
  429. return false
  430. }
  431. let token = uni.getStorageSync('token')
  432. this.connecting = true
  433. uni.showLoading({
  434. title: '连接中...',
  435. mask: true // 是否显示透明蒙层,防止触摸穿透
  436. })
  437. uni.connectSocket({
  438. // url: 'wss://game.shengqianxiong.com.cn/wss/websocket/' + userId,
  439. // url: 'ws://74165o0188.uicp.fun/sqx_fast/websocket/' + userId,
  440. url: this.config('WSHOST') + userId,
  441. data() {
  442. return {
  443. msg: 'Hello'
  444. }
  445. },
  446. header: {
  447. 'content-type': 'application/json',
  448. token: token
  449. },
  450. method: 'GET',
  451. success(res) {
  452. // 这里是接口调用成功的回调,不是连接成功的回调,请注意
  453. },
  454. fail(err) {
  455. // 这里是接口调用失败的回调,不是连接失败的回调,请注意
  456. }
  457. })
  458. uni.onSocketOpen((res) => {
  459. this.connecting = false
  460. this.connected = true
  461. uni.hideLoading()
  462. // uni.showToast({
  463. // icon: 'none',
  464. // title: '连接成功'
  465. // })
  466. console.log('onOpen', res)
  467. })
  468. uni.onSocketError((err) => {
  469. this.connecting = false
  470. this.connected = false
  471. uni.hideLoading()
  472. uni.showModal({
  473. content: '网络较差,请稍后再试',
  474. showCancel: false
  475. })
  476. console.log('onError', err)
  477. })
  478. uni.onSocketMessage((res) => {
  479. // let that = this;
  480. // let datas = JSON.parse(res.data)
  481. // let data = {
  482. // chat: {
  483. // userHead: '../../static/logo.png'
  484. // },
  485. // content: datas.content,
  486. // type: datas.type,
  487. // sendType: datas.sendType
  488. // }
  489. // that.ListItem.push(data);
  490. this.getTimeOrListItem1()
  491. console.log('onMessage', res)
  492. })
  493. uni.onSocketClose((res) => {
  494. this.connected = false
  495. this.startRecive = false
  496. this.msg = false
  497. console.log('onClose', res)
  498. })
  499. },
  500. close() {
  501. uni.closeSocket()
  502. },
  503. getTimeOrListItem1() {
  504. let data = {
  505. chatId: this.chatId
  506. }
  507. this.$Request.getT('/app/chats/list', data).then((res) => {
  508. this.ListItem = []
  509. if (res.data) {
  510. var time = ''
  511. res.data.forEach((d) => {
  512. d.createTime = this.getDateDiff(d.createTime)
  513. if (d.createTime === time) {
  514. d.createTime = ''
  515. } else {
  516. time = d.createTime
  517. }
  518. if (!d.chat.userHead) {
  519. // d.chat.userHead = '../../static/logo.png';
  520. let avatar = this.$queue.getData('avatar')
  521. d.chat.userHead = avatar
  522. }
  523. if (d.type === 4) {
  524. let data = d.content.split(',')
  525. d.content = data
  526. }
  527. if (d.type === 3) {
  528. let data = d.content.split(',')
  529. d.content = data
  530. }
  531. this.ListItem.push(d)
  532. })
  533. setTimeout(() => {
  534. uni.pageScrollTo({
  535. scrollTop: 99999,
  536. duration: 0
  537. })
  538. }, 50)
  539. }
  540. uni.hideLoading()
  541. })
  542. },
  543. getChatSave() {
  544. let userId = this.$queue.getData('userId')
  545. let phone = this.$queue.getData('phone')
  546. let userName = this.$queue.getData('userName')
  547. if (!phone) {
  548. phone = this.$queue.getData('userName')
  549. }
  550. let avatar = this.$queue.getData('avatar') ? this.$queue.getData('avatar') : ''
  551. let shopUserName = this.$queue.getData('shopUserName') ? this.$queue.getData('shopUserName') : ''
  552. let data = {
  553. userId: userId,
  554. userHead: avatar,
  555. userName: shopUserName,
  556. storeId: '0',
  557. storeHead: '',
  558. storeName: ''
  559. }
  560. this.$Request.postJson('/app/chats/save', data).then((res) => {
  561. if (res.status === 0) {
  562. this.chatId = res.data.chatId
  563. uni.showLoading({
  564. title: '加载中...',
  565. mask: true // 是否显示透明蒙层,防止触摸穿透
  566. })
  567. this.getTimeOrListItem1()
  568. }
  569. })
  570. },
  571. setChatSave(type) {
  572. //type:1文字 2图片
  573. if (type === 1 && this.content == '') {
  574. this.$queue.showToast('请输入聊天内容')
  575. return
  576. }
  577. if (this.chatId == '' || this.chatId == undefined) {
  578. this.$queue.showToast('网络较差,请稍后再试')
  579. return
  580. }
  581. let userId = this.$queue.getData('userId')
  582. if (type === 4) {
  583. this.content = this.Shopimage + ',' + this.ShopTitle + ',' + this.Shopmoney + ',' + this.ShopordersId
  584. }
  585. if (type === 3) {
  586. this.content = this.orderimage + ',' + this.orderTitle + ',' + this.ordersId + ',' + this.orderNum + ',' + this.orderCreateTime + ',' + this.ordermoney
  587. }
  588. let avatar = this.$queue.getData('avatar') ? this.$queue.getData('avatar') : ''
  589. let shopUserName = this.$queue.getData('shopUserName') ? this.$queue.getData('shopUserName') : ''
  590. let data = {
  591. userId: userId,
  592. userHead: avatar,
  593. userName: shopUserName,
  594. content: this.content,
  595. chatId: this.chatId,
  596. type: type,
  597. storeId: '0',
  598. sendType: '1',
  599. storeName: ''
  600. }
  601. data = JSON.stringify(data)
  602. let that = this
  603. uni.sendSocketMessage({
  604. data: data,
  605. success(res) {
  606. let avatar = that.$queue.getData('avatar')
  607. if (!avatar) {
  608. avatar = '../../static/logo.png'
  609. }
  610. setTimeout(() => {
  611. that.getTimeOrListItem1()
  612. }, 50)
  613. console.log(that.content)
  614. },
  615. fail(err) {
  616. console.log(err)
  617. }
  618. })
  619. this.content = ''
  620. },
  621. //发送图片
  622. chooseImage(sourceType) {
  623. uni.chooseImage({
  624. count: 1,
  625. sourceType: ['album', 'camera'],
  626. success: (res) => {
  627. for (let i = 0; i < res.tempFiles.length; i++) {
  628. //这里的id和页面中写的html代码的canvas的id要一致
  629. let canvasId = 'zipCanvas'
  630. //原图的路径
  631. let imagePath = res.tempFiles[i].path
  632. //大小限制
  633. let limitSize = 1024 * 2
  634. //初始绘画区域是画布自身的宽度也就是屏幕宽度
  635. let drawWidth = uni.getSystemInfoSync().windowWidth
  636. let that = this
  637. let token = uni.getStorageSync('shopToken')
  638. getLessLimitSizeImage(canvasId, imagePath, limitSize, drawWidth, that, (resPath) => {
  639. uni.showLoading({
  640. title: '上传中'
  641. })
  642. uni.uploadFile({
  643. url: that.config('APIHOST1') + '/admin/new-file/upload',
  644. filePath: resPath,
  645. header: {
  646. token: token
  647. },
  648. name: 'file',
  649. success: (uploadFileRes) => {
  650. this.content = JSON.parse(uploadFileRes.data).data
  651. this.setChatSave(2)
  652. uni.hideLoading()
  653. },
  654. fail: () => {
  655. uni.showToast({
  656. title: '上传失败',
  657. icon: 'error'
  658. })
  659. }
  660. })
  661. })
  662. }
  663. }
  664. })
  665. },
  666. config: function (name) {
  667. var info = null
  668. if (name) {
  669. var name2 = name.split('.') //字符分割
  670. if (name2.length > 1) {
  671. info = configdata[name2[0]][name2[1]] || null
  672. } else {
  673. info = configdata[name] || null
  674. }
  675. if (info == null) {
  676. // let web_config = cache.get("web_config");
  677. // if (web_config) {
  678. // if (name2.length > 1) {
  679. // info = web_config[name2[0]][name2[1]] || null;
  680. // } else {
  681. // info = web_config[name] || null;
  682. // }
  683. // }
  684. }
  685. }
  686. return info
  687. },
  688. //查看大图
  689. viewImg(item) {
  690. let imgsArray = []
  691. imgsArray[0] = item
  692. uni.previewImage({
  693. current: 0,
  694. urls: imgsArray
  695. })
  696. }
  697. }
  698. }
  699. </script>
  700. <style>
  701. page {
  702. /* background: #1c1b20; */
  703. }
  704. .input-box {
  705. position: fixed;
  706. bottom: 0;
  707. left: 0;
  708. height: 100rpx;
  709. width: 100%;
  710. display: flex;
  711. box-sizing: content-box;
  712. z-index: 999;
  713. /* background-color: #ececec; */
  714. /* padding: 0 5rpx; */
  715. }
  716. .chat-listitem {
  717. display: flex;
  718. margin-top: 20rpx;
  719. padding: 10rpx;
  720. }
  721. .chat-listitem-text {
  722. color: #000000;
  723. background: #ffffff;
  724. margin-top: 10rpx;
  725. width: fit-content;
  726. padding: 15rpx;
  727. font-size: 30rpx;
  728. height: max-content;
  729. word-wrap: break-word;
  730. word-break: break-all;
  731. border-radius: 10rpx;
  732. }
  733. .chat-listitem-image-type4 {
  734. color: #000000;
  735. background: #ffffff;
  736. width: fit-content;
  737. font-size: 30rpx;
  738. height: max-content;
  739. word-wrap: break-word;
  740. word-break: break-all;
  741. border-top-left-radius: 20rpx;
  742. border-top-right-radius: 20rpx;
  743. }
  744. .chat-listitem-image {
  745. margin-top: 5rpx;
  746. width: 75rpx;
  747. height: 75rpx;
  748. border-radius: 5rpx;
  749. }
  750. .save {
  751. width: 130rpx;
  752. text-align: center;
  753. border-radius: 10rpx;
  754. height: 70rpx;
  755. color: #fff;
  756. background: #1789fd;
  757. margin: 5rpx 10rpx 0;
  758. line-height: 70rpx;
  759. }
  760. </style>