chat.vue 21 KB

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