PageOne.vue 14 KB

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