PageOne.vue 13 KB

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