PageOne.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. <template>
  2. <view class="page-one-container">
  3. <!-- 图片资料标题 -->
  4. <view class="page-header">
  5. <text class="page-title">图片资料</text>
  6. <u-button
  7. size="small"
  8. @click="handleSaveAllImages"
  9. class="save-all-btn"
  10. >
  11. 保存实物图
  12. </u-button>
  13. </view>
  14. <!-- 聊天记录/通话记录卡片 -->
  15. <view class="card-wrap">
  16. <view class="card-title">
  17. <text
  18. :class="{ 'active': recordType === 'chat' }"
  19. @click="recordType = 'chat'"
  20. >
  21. 聊天记录
  22. </text>
  23. <text class="divider">|</text>
  24. <text
  25. :class="{ 'active': recordType === 'call' }"
  26. @click="recordType = 'call'"
  27. >
  28. 通话记录
  29. </text>
  30. </view>
  31. <!-- 聊天记录 -->
  32. <view v-if="recordType === 'chat'" class="image-upload-container">
  33. <view class="image-list">
  34. <view
  35. v-for="(item, index) in chatRecordsList"
  36. :key="`chat-${index}`"
  37. class="image-item"
  38. >
  39. <PicComp
  40. :src="item.fileUrl"
  41. @needPreviewPic="previewImage"
  42. />
  43. <view class="delete-btn" @click="handleDeleteImage(item)">×</view>
  44. </view>
  45. <view
  46. class="upload-btn"
  47. @click="handleUploadImage('chatRecords')"
  48. >
  49. <u-icon name="plus" size="40" color="#999" />
  50. </view>
  51. </view>
  52. </view>
  53. <!-- 通话录音 -->
  54. <view v-if="recordType === 'call'" class="call-records-container">
  55. <sound-recorder
  56. v-for="item in soundRecordList"
  57. :key="item.fileName"
  58. :data="item"
  59. @handleDelectThisSoundRecord="handleDeleteSoundRecord"
  60. />
  61. </view>
  62. </view>
  63. <!-- 实物图卡片 -->
  64. <view class="card-wrap">
  65. <view class="card-title">实物图</view>
  66. <view class="image-upload-container">
  67. <view class="image-list">
  68. <view
  69. v-for="(item, index) in truePicList"
  70. :key="`truePic-${index}`"
  71. class="image-item"
  72. >
  73. <PicComp
  74. :src="item.fileUrl"
  75. @needPreviewPic="previewTrueImage"
  76. />
  77. <view class="delete-btn" @click="handleDeleteImage(item)">×</view>
  78. </view>
  79. <view
  80. class="upload-btn"
  81. @click="handleUploadImage('truePic')"
  82. >
  83. <u-icon name="plus" size="40" color="#999" />
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. <!-- 基本信息卡片 -->
  89. <view class="info-card">
  90. <view class="info-card-title">基本信息</view>
  91. <u-row class="info-row">
  92. <u-col span="6">
  93. <view class="info-label">发单人</view>
  94. <view class="info-value">{{ orderDetail.createNickName || '未填写' }}</view>
  95. </u-col>
  96. <u-col span="6">
  97. <view class="info-label">型号</view>
  98. <view class="info-value">{{ orderDetail.model || '未填写' }}</view>
  99. </u-col>
  100. </u-row>
  101. <u-row class="info-row">
  102. <u-col span="6">
  103. <view class="info-label">上门时间</view>
  104. <view class="info-value">{{ orderDetail.visitTime || '未填写' }}</view>
  105. </u-col>
  106. <u-col span="6">
  107. <view class="info-label">地址</view>
  108. <view class="info-value">{{ orderDetail.address || '未填写' }}</view>
  109. </u-col>
  110. </u-row>
  111. </view>
  112. <!-- 联系方式卡片 -->
  113. <view class="contact-card">
  114. <view
  115. class="contact-item phone-card"
  116. @click="handlePhoneClick"
  117. >
  118. <u-icon name="phone" size="40" color="#07C160" />
  119. <view class="contact-title">电话</view>
  120. <view v-if="orderDetail.phone" class="red-dot"></view>
  121. </view>
  122. <view
  123. class="contact-item wechat-card"
  124. @click="handleWechatClick"
  125. >
  126. <u-icon name="chat" size="40" color="#07C160" />
  127. <view class="contact-title">微信</view>
  128. <view v-if="orderDetail.wechat" class="red-dot"></view>
  129. </view>
  130. </view>
  131. <!-- 下一步按钮 -->
  132. <view class="space-block"></view>
  133. <u-button
  134. class="next-btn"
  135. @click="handleNext"
  136. type="primary"
  137. size="middle"
  138. >
  139. 下一步
  140. </u-button>
  141. </view>
  142. </template>
  143. <script>
  144. import PicComp from './PicComp.vue'
  145. import soundRecorder from '@/components/soundRecorder/soundRecorder.vue'
  146. import imageUpload from '../utils/imageUpload.js'
  147. export default {
  148. name: 'PageOne',
  149. components: {
  150. PicComp,
  151. soundRecorder
  152. },
  153. props: {
  154. orderDetail: {
  155. type: Object,
  156. default: () => ({})
  157. },
  158. orderId: {
  159. type: String,
  160. default: ''
  161. },
  162. currentReceipt: {
  163. type: Object,
  164. default: () => ({})
  165. }
  166. },
  167. data() {
  168. return {
  169. recordType: 'chat', // 'chat' | 'call'
  170. chatRecordsList: [],
  171. truePicList: [],
  172. soundRecordList: []
  173. }
  174. },
  175. watch: {
  176. currentReceipt: {
  177. handler(newVal) {
  178. if (newVal && newVal.id) {
  179. this.loadImageList()
  180. this.loadCallRecords()
  181. }
  182. },
  183. immediate: true,
  184. deep: true
  185. }
  186. },
  187. methods: {
  188. /**
  189. * 加载图片列表
  190. */
  191. async loadImageList() {
  192. if (!this.currentReceipt.id || !this.orderDetail.itemBrand) return
  193. try {
  194. // 加载聊天记录
  195. const chatList = await imageUpload.getFileList(
  196. '2',
  197. '1',
  198. this.currentReceipt.id,
  199. this.orderDetail.itemBrand,
  200. this.currentReceipt.clueId
  201. )
  202. this.chatRecordsList = chatList || []
  203. // 加载实物图
  204. const truePicList = await imageUpload.getFileList(
  205. '2',
  206. '2',
  207. this.currentReceipt.id,
  208. this.orderDetail.itemBrand,
  209. this.currentReceipt.clueId
  210. )
  211. this.truePicList = truePicList || []
  212. } catch (error) {
  213. console.error('加载图片列表失败:', error)
  214. }
  215. },
  216. /**
  217. * 加载通话记录
  218. */
  219. async loadCallRecords() {
  220. if (!this.currentReceipt.clueId) return
  221. try {
  222. const { data } = await uni.$u.api.getCallClueFileByClueId({
  223. clueId: this.currentReceipt.clueId
  224. })
  225. this.soundRecordList = data || []
  226. } catch (error) {
  227. console.error('加载通话记录失败:', error)
  228. }
  229. },
  230. /**
  231. * 上传图片
  232. */
  233. async handleUploadImage(type) {
  234. try {
  235. const filePaths = await imageUpload.chooseImage(9)
  236. const uploadResults = await imageUpload.uploadFiles(filePaths)
  237. // 绑定订单文件
  238. const orderFileType = type === 'truePic' ? '2' : '1'
  239. await imageUpload.bindOrderFile(
  240. this.currentReceipt.clueId,
  241. this.currentReceipt.id,
  242. orderFileType,
  243. uploadResults
  244. )
  245. // 刷新列表
  246. this.loadImageList()
  247. } catch (error) {
  248. console.error('上传图片失败:', error)
  249. }
  250. },
  251. /**
  252. * 删除图片
  253. */
  254. async handleDeleteImage(item) {
  255. uni.showModal({
  256. title: '提示',
  257. content: '确定要删除这张图片吗?',
  258. success: async (res) => {
  259. if (res.confirm) {
  260. try {
  261. await imageUpload.deleteFile(item.id)
  262. this.loadImageList()
  263. } catch (error) {
  264. console.error('删除图片失败:', error)
  265. }
  266. }
  267. }
  268. })
  269. },
  270. /**
  271. * 删除录音
  272. */
  273. async handleDeleteSoundRecord({ id }) {
  274. uni.showModal({
  275. title: '提示',
  276. content: '是否确定删除?',
  277. success: async (res) => {
  278. if (res.confirm) {
  279. try {
  280. await uni.$u.api.deleteClueFile([id])
  281. uni.showToast({
  282. title: '删除成功',
  283. icon: 'success'
  284. })
  285. this.loadCallRecords()
  286. } catch (error) {
  287. uni.showToast({
  288. title: '删除失败',
  289. icon: 'error'
  290. })
  291. }
  292. }
  293. }
  294. })
  295. },
  296. /**
  297. * 预览图片
  298. */
  299. previewImage(src) {
  300. const urlList = this.chatRecordsList.map(item => item.fileUrl)
  301. uni.previewImage({
  302. urls: urlList,
  303. current: src
  304. })
  305. },
  306. /**
  307. * 预览实物图
  308. */
  309. previewTrueImage(src) {
  310. const urlList = this.truePicList.map(item => item.fileUrl)
  311. uni.previewImage({
  312. urls: urlList,
  313. current: src
  314. })
  315. },
  316. /**
  317. * 保存全部图片
  318. */
  319. async handleSaveAllImages() {
  320. const allUrls = this.truePicList.map(item => item.fileUrl)
  321. if (allUrls.length === 0) {
  322. uni.showToast({
  323. title: '没有图片可保存',
  324. icon: 'none'
  325. })
  326. return
  327. }
  328. uni.showModal({
  329. title: '保存图片',
  330. content: `是否将 ${allUrls.length} 张图片保存到本地相册?`,
  331. confirmText: '保存',
  332. success: (res) => {
  333. if (res.confirm) {
  334. imageUpload.saveImagesToLocal(allUrls)
  335. }
  336. }
  337. })
  338. },
  339. /**
  340. * 电话点击
  341. */
  342. handlePhoneClick() {
  343. if (!this.orderDetail.phone) {
  344. uni.showToast({
  345. title: '该订单暂时没有电话号码',
  346. icon: 'none'
  347. })
  348. return
  349. }
  350. uni.makePhoneCall({
  351. phoneNumber: this.orderDetail.phone,
  352. success: () => {
  353. this.$store.commit('call/SET_FORM', {
  354. clueId: this.orderDetail.clueId,
  355. type: '3',
  356. callee: this.orderDetail.phone
  357. })
  358. }
  359. })
  360. },
  361. /**
  362. * 微信点击
  363. */
  364. handleWechatClick() {
  365. if (!this.orderDetail.wechat) {
  366. uni.showToast({
  367. title: '该订单暂时没有微信号',
  368. icon: 'none'
  369. })
  370. return
  371. }
  372. uni.setClipboardData({
  373. data: this.orderDetail.wechat,
  374. success: () => {
  375. uni.showToast({
  376. title: '微信号已复制',
  377. icon: 'none'
  378. })
  379. }
  380. })
  381. },
  382. /**
  383. * 下一步
  384. */
  385. handleNext() {
  386. this.$emit('next', {
  387. nowPage: 'formOne',
  388. form: {}
  389. })
  390. }
  391. }
  392. }
  393. </script>
  394. <style scoped lang="scss">
  395. @import '../styles/common.scss';
  396. .page-one-container {
  397. @extend .page-container;
  398. padding-bottom: 100rpx;
  399. }
  400. .page-header {
  401. display: flex;
  402. justify-content: space-between;
  403. align-items: center;
  404. margin-bottom: 20rpx;
  405. }
  406. .page-title {
  407. @include font-styles($size: title, $weight: bold, $color: primary);
  408. }
  409. .save-all-btn {
  410. border-radius: 20rpx;
  411. border-color: #007AFF;
  412. color: #007AFF;
  413. }
  414. .card-wrap {
  415. @extend .card-wrap;
  416. margin-top: 20rpx;
  417. }
  418. .card-title {
  419. padding: 20rpx;
  420. border-bottom: 1rpx solid map-get($colors, border);
  421. display: flex;
  422. align-items: center;
  423. text {
  424. padding: 0 10rpx;
  425. cursor: pointer;
  426. &.active {
  427. color: map-get($colors, primary);
  428. font-weight: bold;
  429. }
  430. }
  431. .divider {
  432. margin: 0 10rpx;
  433. color: #ddd;
  434. }
  435. }
  436. .image-upload-container {
  437. padding: 20rpx;
  438. }
  439. .image-list {
  440. display: flex;
  441. flex-wrap: wrap;
  442. gap: 20rpx;
  443. }
  444. .image-item {
  445. position: relative;
  446. width: 200rpx;
  447. height: 200rpx;
  448. box-sizing: border-box;
  449. }
  450. .delete-btn {
  451. position: absolute;
  452. top: -10rpx;
  453. right: -10rpx;
  454. width: 40rpx;
  455. height: 40rpx;
  456. background-color: #ff4d4f;
  457. color: #fff;
  458. border-radius: 50%;
  459. display: flex;
  460. align-items: center;
  461. justify-content: center;
  462. font-size: 30rpx;
  463. font-weight: bold;
  464. z-index: 10;
  465. cursor: pointer;
  466. }
  467. .upload-btn {
  468. width: 200rpx;
  469. height: 200rpx;
  470. border: 8rpx dashed #ddd;
  471. border-radius: 30rpx;
  472. display: flex;
  473. align-items: center;
  474. justify-content: center;
  475. background-color: #f9f9f9;
  476. box-sizing: border-box;
  477. cursor: pointer;
  478. }
  479. .call-records-container {
  480. padding: 20rpx;
  481. }
  482. .info-card {
  483. @extend .card-wrap;
  484. padding: 20rpx;
  485. margin-top: 20rpx;
  486. }
  487. .info-card-title {
  488. @include font-styles($size: title, $weight: bold, $color: primary);
  489. margin-bottom: 25rpx;
  490. padding-bottom: 15rpx;
  491. border-bottom: 1rpx solid map-get($colors, border);
  492. }
  493. .info-row {
  494. margin-bottom: 20rpx;
  495. }
  496. .info-label {
  497. @include font-styles($size: tiny, $weight: regular, $color: tertiary);
  498. margin-bottom: 8rpx;
  499. }
  500. .info-value {
  501. @include font-styles($size: small, $weight: regular, $color: secondary);
  502. word-break: break-all;
  503. }
  504. .contact-card {
  505. display: flex;
  506. justify-content: space-between;
  507. margin: 20rpx 0;
  508. gap: 20rpx;
  509. }
  510. .contact-item {
  511. flex: 1;
  512. @extend .card-wrap;
  513. padding: 20rpx;
  514. display: flex;
  515. flex-direction: column;
  516. align-items: center;
  517. position: relative;
  518. cursor: pointer;
  519. }
  520. .contact-title {
  521. @include font-styles($size: tiny, $weight: regular, $color: tertiary);
  522. margin-top: 10rpx;
  523. }
  524. .red-dot {
  525. position: absolute;
  526. top: 15rpx;
  527. right: 15rpx;
  528. width: 25rpx;
  529. height: 25rpx;
  530. background-color: #ff4d4f;
  531. border-radius: 50%;
  532. box-shadow: 0 0 4rpx rgba(255, 77, 79, 0.3);
  533. }
  534. .space-block {
  535. height: 100rpx;
  536. }
  537. .next-btn {
  538. position: fixed;
  539. bottom: 10rpx;
  540. left: 2.5%;
  541. width: 95%;
  542. height: 80rpx;
  543. line-height: 80rpx;
  544. text-align: center;
  545. border-radius: 20rpx;
  546. }
  547. </style>