PageThree.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173
  1. <template>
  2. <view class="page-three-container">
  3. <!-- 支付信息卡片 -->
  4. <view class="info-card">
  5. <view class="info-card-title">支付信息</view>
  6. <u-row class="info-row" justify="space-between">
  7. <u-col span="5.8">
  8. <view class="info-label">开户人</view>
  9. <u-input v-model="paymentInfo.customName" placeholder="请输入开户人姓名" class="info-input"
  10. @blur="handleCustomNameInput" />
  11. </u-col>
  12. <u-col span="5.8">
  13. <view class="info-label">银行名称</view>
  14. <u-input v-model="paymentInfo.bankName" placeholder="请输入银行名称" class="info-input"
  15. :disabled="isAlipayPayment" @blur="handleBankNameInput" />
  16. </u-col>
  17. </u-row>
  18. <u-row class="info-row">
  19. <u-col span="12">
  20. <view class="info-label">{{ bankAccountLabel }}</view>
  21. <u-input v-model="paymentInfo.bankAccount" :placeholder="bankAccountPlaceholder" class="info-input"
  22. :type="isAlipayPayment ? 'text' : 'number'" @input="handleBankAccountInput" />
  23. </u-col>
  24. </u-row>
  25. <u-row class="info-row">
  26. <u-col span="12">
  27. <view class="info-label">身份证号</view>
  28. <u-input v-model="paymentInfo.idNumber" placeholder="请输入身份证号" class="info-input"
  29. @blur="handleIdNumberInput" />
  30. </u-col>
  31. </u-row>
  32. <u-row class="info-row">
  33. <u-col span="12">
  34. <view class="info-label">支付方式选择</view>
  35. <u-radio-group iconPlacement="left" v-model="paymentMethodRadio" placement="column"
  36. @change="handlePaymentMethodRadioChange">
  37. <u-radio shape="circle" label="小葫芦线上支付" name="online" :customStyle="{marginBottom: '16rpx'}"/>
  38. <u-radio shape="circle" label="小葫芦线上支付宝" name="online_alipay" :customStyle="{marginBottom: '16rpx'}" />
  39. <u-radio shape="circle" label="线下支付" name="offline" :customStyle="{marginBottom: '16rpx'}"/>
  40. </u-radio-group>
  41. </u-col>
  42. </u-row>
  43. <u-row class="info-row">
  44. <u-col span="12">
  45. <view class="info-label">支付方式</view>
  46. <u-input :disabled="paymentMethodRadio === 'online'||paymentMethodRadio === 'online_alipay'" v-model="paymentMethod" placeholder="请输入支付方式"
  47. class="info-input" />
  48. </u-col>
  49. </u-row>
  50. </view>
  51. <!-- 核价信息卡片 -->
  52. <view v-if="hasInquiryInfo" class="info-card">
  53. <view class="info-card-title">核价信息</view>
  54. <u-row class="info-row">
  55. <u-col span="6">
  56. <view class="info-label">核价次数</view>
  57. <view class="info-value">{{ currentReceipt.inquiryCount || 0 }}</view>
  58. </u-col>
  59. <u-col span="6">
  60. <view class="info-label">核价价格</view>
  61. <view class="info-value">¥{{ currentReceipt.inquiryPrice || 0 }}</view>
  62. </u-col>
  63. </u-row>
  64. </view>
  65. <!-- 高清实物图卡片 -->
  66. <view class="card-wrap">
  67. <view class="detail-image-section">
  68. <view class="detail-image-header">
  69. <text class="detail-image-title">高清实物图(拖拽排序)</text>
  70. <u-button type="primary" shape="circle" plain text="核价" size="small" class="pricing-btn" @click="handlePricing"></u-button>
  71. </view>
  72. <view class="detail-image-content">
  73. <view class="detail-image-list">
  74. <view v-for="(item, index) in displayImages" :key="item.id || `detail-${index}`" class="detail-image-item"
  75. :class="{
  76. 'dragging': draggingIndex === index,
  77. 'can-drop': canDropIndex === index && draggingIndex !== index
  78. }" :style="draggingIndex === index ? draggingStyle : ''" @touchstart.stop="onTouchStart($event, index)"
  79. @touchmove.stop="onTouchMove($event, index)" @touchend.stop="onTouchEnd">
  80. <PicComp :src="item.fileUrl" @needPreviewPic="previewImageDetail" />
  81. <view class="image-type-tag">{{ getImageType(index) }}</view>
  82. <view class="detail-delete-btn" @click.stop="handleHideImage(item, index)">
  83. ×
  84. </view>
  85. </view>
  86. <view class="detail-upload-btn" @click="handleUploadImage">
  87. <u-icon name="plus" size="40rpx" color="#999" />
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. <!-- 支付总额卡片 -->
  94. <view class="card-wrap payment-card">
  95. <view class="payment-section">
  96. <view class="payment-total-container">
  97. <text class="payment-label">支付总额</text>
  98. <view class="payment-amount-wrap">
  99. <u-input v-model="paymentAmount" class="payment-amount" type="number" decimal="2" prefix="¥" />
  100. </view>
  101. <view class="pay-now-btn-wrap">
  102. <u-button type="primary" shape="circle" plain text="立即支付" size="small" @click="handlePayNowClick"></u-button>
  103. </view>
  104. </view>
  105. <view class="payment-buttons-row">
  106. <view class="payment-button" @click="handleUnpaidClick">
  107. <u-icon name="star" size="40rpx" color="#ff9500" />
  108. <text class="button-text">未收</text>
  109. </view>
  110. <view class="payment-button" @click="handleFollowUpClick">
  111. <u-icon name="chat" size="40rpx" color="#108cff" />
  112. <text class="button-text">待跟进</text>
  113. </view>
  114. </view>
  115. </view>
  116. </view>
  117. <!-- 下一步按钮 -->
  118. <u-button class="next-btn" @click="handleNext" type="primary" size="middle">
  119. 下一步
  120. </u-button>
  121. <!-- 未收评级模态窗 -->
  122. <u-modal showCancelButton showConfirmButton @confirm="confirmUnpaid" @cancel="onUnpaidModalCancel"
  123. :show="unpaidModalVisible" title="未收评级">
  124. <view class="modal-content">
  125. <u-rate v-model="unpaidRating" :count="5" :size="50" active-color="#ff9500" />
  126. <view class="unpaid-benefit-fee-wrap">
  127. <view class="unpaid-benefit-fee-label">好处费</view>
  128. <u-input v-model="unpaidBenefitFee" class="unpaid-benefit-fee-input" type="number" :decimal="2"
  129. placeholder="请输入好处费(金额)" @input="handleUnpaidBenefitFeeInput" />
  130. </view>
  131. </view>
  132. </u-modal>
  133. <!-- 待跟进模态窗 -->
  134. <u-modal showCancelButton showConfirmButton @confirm="confirmFollowUp" @cancel="followUpModalVisible = false"
  135. :show="followUpModalVisible" title="填写跟进细节">
  136. <view class="modal-content">
  137. <u--textarea v-model="followUpNotes" placeholder="请输入情况" confirm-type="done"
  138. style="width: 100%; margin-bottom: 30rpx;" />
  139. </view>
  140. </u-modal>
  141. <!-- 确认支付模态窗 -->
  142. <u-modal showCancelButton showConfirmButton @confirm="confirmRiskWarning" @cancel="riskWarningModalVisible = false"
  143. confirmText="确认并继续付款" :show="riskWarningModalVisible" title="付款警示" :content="'湖南耒阳地区身份证号请确认!'">
  144. </u-modal>
  145. <!-- 核价对话框 -->
  146. <add-inquiry-dialog ref="pricingDialog" :clueId="pricingClueId" :editOrAdd="pricingEditOrAdd"
  147. :editInfo="pricingEditInfo" :type="2" />
  148. <u-modal :show="payNowModalVisible" title="确认支付信息" :showConfirmButton="false">
  149. <view class="modal-content">
  150. <view class="payment-amount-display">¥{{ paymentAmount }}</view>
  151. <view class="payment-info-section">
  152. <view class="info-item">
  153. <text class="info-label">收款姓名:</text>
  154. <text class="info-value">{{ paymentInfo.customName || '未填写' }}</text>
  155. </view>
  156. <view class="info-item">
  157. <text class="info-label">开户银行:</text>
  158. <text class="info-value">{{ paymentInfo.bankName || '未填写' }}</text>
  159. </view>
  160. <view class="info-item">
  161. <text class="info-label">银行卡号:</text>
  162. <text class="info-value">{{ paymentInfo.bankAccount || '未填写' }}</text>
  163. </view>
  164. <view class="info-item">
  165. <text class="info-label">支付方式:</text>
  166. <text class="info-value">{{ paymentMethod || '未填写' }}</text>
  167. </view>
  168. </view>
  169. <u-button type="primary" size="large" @click="confirmTransfer" style="margin-top: 40rpx;">
  170. 确认转账
  171. </u-button>
  172. <u-button type="primary" :plain="true" @click="payNowModalVisible = false" size="large"
  173. style="margin-top: 20rpx;">
  174. 取消
  175. </u-button>
  176. </view>
  177. </u-modal>
  178. </view>
  179. </template>
  180. <script>
  181. import PicComp from './PicComp.vue'
  182. import imageUpload from '../utils/imageUpload.js'
  183. import addInquiryDialog from '@/components/add-inquiry-dialog/index.vue'
  184. export default {
  185. name: 'PageThree',
  186. components: {
  187. PicComp,
  188. addInquiryDialog
  189. },
  190. props: {
  191. orderDetail: {
  192. type: Object,
  193. default: () => ({})
  194. },
  195. orderId: {
  196. type: String,
  197. default: ''
  198. },
  199. currentReceipt: {
  200. type: Object,
  201. default: () => ({})
  202. }
  203. },
  204. data() {
  205. return {
  206. paymentInfo: {
  207. customName: '',
  208. bankName: '',
  209. bankAccount: '',
  210. idNumber: ''
  211. },
  212. paymentMethodRadio: 'offline',
  213. paymentMethod: '',
  214. paymentAmount: '0.00',
  215. detailImages: [],
  216. // 拖拽相关
  217. draggingIndex: -1,
  218. canDropIndex: -1,
  219. startX: 0,
  220. startY: 0,
  221. currentX: 0,
  222. currentY: 0,
  223. // 模态窗
  224. unpaidModalVisible: false,
  225. followUpModalVisible: false,
  226. payNowModalVisible: false,
  227. riskWarningModalVisible: false,
  228. unpaidRating: 0,
  229. unpaidBenefitFee: '',
  230. followUpNotes: '',
  231. // 核价相关
  232. pricingClueId: '',
  233. pricingEditOrAdd: 'receptFormAdd',
  234. pricingEditInfo: {}
  235. }
  236. },
  237. computed: {
  238. // 显示前6个图片用于拖拽
  239. displayImages() {
  240. return this.detailImages.slice(0, 6)
  241. },
  242. // 拖拽时的样式
  243. draggingStyle() {
  244. if (this.draggingIndex === -1) return ''
  245. return {
  246. transform: `translate(${this.currentX - this.startX}px, ${this.currentY - this.startY}px)`,
  247. zIndex: 1000
  248. }
  249. },
  250. // 是否为支付宝支付
  251. isAlipayPayment() {
  252. return this.paymentMethodRadio === 'online_alipay'
  253. },
  254. // 银行账号标签
  255. bankAccountLabel() {
  256. return this.isAlipayPayment ? '支付宝账号' : '银行账号'
  257. },
  258. // 银行账号占位符
  259. bankAccountPlaceholder() {
  260. return this.isAlipayPayment ? '请输入支付宝账号' : '请输入银行账号'
  261. },
  262. // 是否有核价信息
  263. hasInquiryInfo() {
  264. return this.currentReceipt && (this.currentReceipt.inquiryCount || this.currentReceipt.inquiryPrice)
  265. }
  266. },
  267. watch: {
  268. // 支付信息已保存到 receiptForm,不再从 orderDetail(sendForm) 读取
  269. currentReceipt: {
  270. handler(newVal, oldVal) {
  271. if (newVal) {
  272. this.paymentAmount = newVal.tableFee || '0.00'
  273. // 从回单表 receiptForm 回填支付信息(与 PC 端一致)
  274. this.paymentInfo.customName = newVal.customName || ''
  275. this.paymentInfo.bankName = newVal.bankName || ''
  276. this.paymentInfo.bankAccount = newVal.bankCardNumber || ''
  277. this.paymentInfo.idNumber = newVal.idCard || ''
  278. this.initPaymentMethod(newVal.paymentMethod)
  279. // 只有当 receipt id 变化时才重新加载图片,避免 fileIds 更新时重新加载
  280. if (!oldVal || oldVal.id !== newVal.id) {
  281. this.loadDetailImages()
  282. }
  283. }
  284. },
  285. deep: true,
  286. immediate: true
  287. }
  288. },
  289. methods: {
  290. /**
  291. * 刷新图片列表(供父组件调用)
  292. */
  293. async refreshImageList() {
  294. await this.loadDetailImages()
  295. },
  296. /**
  297. * 加载细节图
  298. */
  299. async loadDetailImages() {
  300. if (!this.currentReceipt.id || !this.orderDetail.itemBrand) return
  301. try {
  302. const list = await imageUpload.getFileList(
  303. '2',
  304. '3',
  305. this.currentReceipt.id,
  306. this.orderDetail.itemBrand,
  307. this.currentReceipt.clueId
  308. )
  309. // 按照 fileIds 排序
  310. if (this.currentReceipt.fileIds && list && list.length > 0) {
  311. const sortedIds = this.currentReceipt.fileIds.split(',')
  312. list.sort((a, b) => {
  313. const indexA = sortedIds.indexOf(a.id)
  314. const indexB = sortedIds.indexOf(b.id)
  315. // 如果都不在列表中,保持原顺序
  316. if (indexA === -1 && indexB === -1) return 0
  317. // 如果 a 不在列表中,放到后面
  318. if (indexA === -1) return 1
  319. // 如果 b 不在列表中,放到后面
  320. if (indexB === -1) return -1
  321. // 都在列表中,按 index 排序
  322. return indexA - indexB
  323. })
  324. }
  325. this.detailImages = list || []
  326. } catch (error) {
  327. console.error('加载细节图失败:', error)
  328. }
  329. },
  330. /**
  331. * 初始化支付方式
  332. */
  333. initPaymentMethod(value) {
  334. if (value === '小葫芦线上支付') {
  335. this.paymentMethod = '小葫芦线上支付'
  336. this.paymentMethodRadio = 'online'
  337. } else if (value === '小葫芦线上支付宝') {
  338. this.paymentMethod = '小葫芦线上支付宝'
  339. this.paymentMethodRadio = 'online_alipay'
  340. this.paymentInfo.bankName = '支付宝'
  341. } else {
  342. this.paymentMethod = value || ''
  343. this.paymentMethodRadio = 'offline'
  344. }
  345. },
  346. /**
  347. * 支付方式选择改变
  348. */
  349. handlePaymentMethodRadioChange(value) {
  350. if (value === 'online') {
  351. this.paymentMethod = '小葫芦线上支付'
  352. // 恢复银行名称输入框
  353. if (this.paymentInfo.bankName === '支付宝') {
  354. this.paymentInfo.bankName = ''
  355. }
  356. } else if (value === 'online_alipay') {
  357. this.paymentMethod = '小葫芦线上支付宝'
  358. // 自动设置银行名称为支付宝
  359. this.paymentInfo.bankName = '支付宝'
  360. } else {
  361. this.paymentMethod = ''
  362. // 恢复银行名称输入框
  363. if (this.paymentInfo.bankName === '支付宝') {
  364. this.paymentInfo.bankName = ''
  365. }
  366. }
  367. },
  368. /**
  369. * 开户人输入处理 - 只允许中文
  370. */
  371. handleCustomNameInput(value) {
  372. // 只保留中文字符(包括中文标点)
  373. const chineseReg = /[^\u4e00-\u9fa5]/g
  374. this.paymentInfo.customName = String(value || '').replace(chineseReg, '')
  375. },
  376. /**
  377. * 银行名称输入处理 - 只允许中文
  378. */
  379. handleBankNameInput(value) {
  380. // 只保留中文字符(包括中文标点)
  381. const chineseReg = /[^\u4e00-\u9fa5]/g
  382. this.paymentInfo.bankName = String(value || '').replace(chineseReg, '')
  383. },
  384. /**
  385. * 银行账号输入处理 - 只允许数字
  386. */
  387. handleBankAccountInput(value) {
  388. // 只保留数字
  389. const numberReg = /[^\d]/g
  390. this.paymentInfo.bankAccount = String(value || '').replace(numberReg, '')
  391. },
  392. /**
  393. * 身份证号输入处理 - 允许数字和X
  394. */
  395. handleIdNumberInput(value) {
  396. // 只保留数字和X
  397. const reg = /[^\dxX]/g
  398. this.paymentInfo.idNumber = String(value || '').replace(reg, '')
  399. },
  400. /**
  401. * 获取图片类型
  402. */
  403. getImageType(index) {
  404. const types = ['正面', '反面', '侧面', '扣子', '编号']
  405. return types[index] || `细节${index - 4}`
  406. },
  407. /**
  408. * 触摸开始
  409. */
  410. onTouchStart(event, index) {
  411. if (this.draggingIndex !== -1) return
  412. this.draggingIndex = index
  413. const touch = event.touches[0]
  414. this.startX = touch.clientX
  415. this.startY = touch.clientY
  416. this.currentX = touch.clientX
  417. this.currentY = touch.clientY
  418. },
  419. /**
  420. * 触摸移动
  421. */
  422. onTouchMove(event, index) {
  423. if (this.draggingIndex === -1 || this.draggingIndex !== index) return
  424. const touch = event.touches[0]
  425. this.currentX = touch.clientX
  426. this.currentY = touch.clientY
  427. this.findTargetIndex(touch.clientX, touch.clientY)
  428. },
  429. /**
  430. * 触摸结束
  431. */
  432. async onTouchEnd() {
  433. if (this.draggingIndex === -1) return
  434. if (this.canDropIndex !== -1 && this.canDropIndex !== this.draggingIndex) {
  435. // 交换位置
  436. const images = [...this.detailImages]
  437. const temp = images[this.draggingIndex]
  438. images[this.draggingIndex] = images[this.canDropIndex]
  439. images[this.canDropIndex] = temp
  440. this.detailImages = images
  441. }
  442. this.resetDragState()
  443. //每次拖拽结束后把新的顺序传送给接口
  444. const fileIds = this.detailImages.map(item => item.id).join(',')
  445. await uni.$u.api.updateReceiptForm({
  446. id: this.currentReceipt.id,
  447. fileIds: fileIds
  448. })
  449. this.$emit('update-file-ids', fileIds)
  450. },
  451. /**
  452. * 查找目标索引
  453. */
  454. findTargetIndex(x, y) {
  455. const query = uni.createSelectorQuery().in(this)
  456. query.selectAll('.detail-image-item').boundingClientRect((rects) => {
  457. if (!rects || rects.length === 0) return
  458. let targetIndex = -1
  459. for (let i = 0; i < rects.length; i++) {
  460. if (i === this.draggingIndex) continue
  461. const rect = rects[i]
  462. if (x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom) {
  463. targetIndex = i
  464. break
  465. }
  466. }
  467. this.canDropIndex = targetIndex
  468. }).exec()
  469. },
  470. /**
  471. * 重置拖拽状态
  472. */
  473. resetDragState() {
  474. this.draggingIndex = -1
  475. this.canDropIndex = -1
  476. this.startX = 0
  477. this.startY = 0
  478. this.currentX = 0
  479. this.currentY = 0
  480. },
  481. /**
  482. * 上传图片
  483. */
  484. async handleUploadImage() {
  485. try {
  486. const filePaths = await imageUpload.chooseImage(9)
  487. const uploadResults = await imageUpload.uploadFiles(filePaths)
  488. await imageUpload.bindOrderFile(
  489. this.currentReceipt.clueId,
  490. this.currentReceipt.id,
  491. '3',
  492. uploadResults
  493. )
  494. await this.loadDetailImages()
  495. //上传新图片完成之后也要把新数据给接口
  496. const fileIds = this.detailImages.map(item => item.id).join(',')
  497. await uni.$u.api.updateReceiptForm({
  498. id: this.currentReceipt.id,
  499. fileIds: fileIds
  500. })
  501. this.$emit('update-file-ids', fileIds)
  502. } catch (error) {
  503. console.error('上传失败:', error)
  504. }
  505. },
  506. /**
  507. * 隐藏图片
  508. */
  509. async handleHideImage(item, index) {
  510. const itemIndex = this.detailImages.findIndex(img => img.id === item.id || img.fileUrl === item.fileUrl)
  511. if (itemIndex !== -1) {
  512. this.detailImages.splice(itemIndex, 1)
  513. // 更新 fileIds
  514. const fileIds = this.detailImages.map(item => item.id).join(',')
  515. try {
  516. await uni.$u.api.updateReceiptForm({
  517. id: this.currentReceipt.id,
  518. fileIds: fileIds
  519. })
  520. this.$emit('update-file-ids', fileIds)
  521. uni.$u.toast('图片已隐藏')
  522. } catch (error) {
  523. console.error('更新失败:', error)
  524. }
  525. }
  526. },
  527. /**
  528. * 预览图片
  529. */
  530. previewImageDetail(src) {
  531. const urlList = this.detailImages.map(item => item.fileUrl)
  532. uni.previewImage({
  533. urls: urlList,
  534. current: src
  535. })
  536. },
  537. /**
  538. * 未收点击
  539. */
  540. handleUnpaidClick() {
  541. this.unpaidBenefitFee = ''
  542. this.unpaidModalVisible = true
  543. },
  544. /**
  545. * 未收弹窗取消 - 重置好处费
  546. */
  547. onUnpaidModalCancel() {
  548. this.unpaidModalVisible = false
  549. this.unpaidBenefitFee = ''
  550. },
  551. /**
  552. * 好处费输入 - 限制仅可输入金额(数字、最多两位小数)
  553. */
  554. handleUnpaidBenefitFeeInput(e) {
  555. const value = (e && e.detail && e.detail.value !== undefined) ? e.detail.value : e
  556. let val = String(value ?? '').trim()
  557. if (!val) {
  558. this.unpaidBenefitFee = ''
  559. return
  560. }
  561. // 只保留数字和第一个小数点,且小数点后最多两位
  562. const parts = val.replace(/[^\d.]/g, '').split('.')
  563. if (parts.length > 2) {
  564. val = parts[0] + '.' + parts.slice(1).join('')
  565. }
  566. if (parts.length === 2 && parts[1].length > 2) {
  567. val = parts[0] + '.' + parts[1].slice(0, 2)
  568. }
  569. this.unpaidBenefitFee = val
  570. },
  571. /**
  572. * 待跟进点击
  573. */
  574. handleFollowUpClick() {
  575. this.followUpModalVisible = true
  576. },
  577. /**
  578. * 立即支付点击
  579. */
  580. async handlePayNowClick() {
  581. // 与 PC 端一致:先做必填校验
  582. if (this.paymentAmount <= 0) {
  583. uni.$u.toast('请填写正确的支付总额')
  584. return
  585. }
  586. // 支付方式必填(与 PC 一致)
  587. if (!this.paymentMethod) {
  588. uni.$u.toast('请填写支付方式')
  589. return
  590. }
  591. // 仅线上支付时校验开户人/银行/身份证;线下支付不校验(与 PC 一致)
  592. if (this.paymentMethodRadio === 'online' || this.paymentMethodRadio === 'online_alipay') {
  593. if (!this.paymentInfo.customName || !this.paymentInfo.bankName ||
  594. !this.paymentInfo.bankAccount || !this.paymentInfo.idNumber) {
  595. uni.$u.toast('请填写完整的开户人信息、身份证号、银行名称、银行卡号')
  596. return
  597. }
  598. }
  599. // 保存支付信息到回单表(后端需 sendFormId 才能更新发单表的开户人/银行/身份证等)
  600. await uni.$u.api.updateReceiptForm({
  601. id: this.currentReceipt.id,
  602. sendFormId: this.currentReceipt.sendFormId || this.orderDetail.id,
  603. tableFee: this.paymentAmount,
  604. fileIds: this.detailImages.map(item => item.id).join(','),
  605. customName: this.paymentInfo.customName || '',
  606. bankName: this.paymentInfo.bankName || '',
  607. bankCardNumber: this.paymentInfo.bankAccount || '',
  608. idCard: this.paymentInfo.idNumber || ''
  609. })
  610. // 湖南耒阳身份证号确认(仅当已填写身份证时校验,与 PC 一致)
  611. if (this.paymentInfo.idNumber && String(this.paymentInfo.idNumber).startsWith('430481')) {
  612. this.riskWarningModalVisible = true
  613. return
  614. }
  615. // 线下支付:不弹确认框,直接更新支付方式并进入下一步(后端需 sendFormId 更新发单表支付方式)
  616. if (this.paymentMethodRadio === 'offline') {
  617. await uni.$u.api.updateReceiptForm({
  618. id: this.currentReceipt.id,
  619. sendFormId: this.currentReceipt.sendFormId || this.orderDetail.id,
  620. paymentMethod: this.paymentMethod || ''
  621. })
  622. this.handleNext()
  623. return
  624. }
  625. this.payNowModalVisible = true
  626. },
  627. /**
  628. * 确认风险警示
  629. */
  630. async confirmRiskWarning() {
  631. this.riskWarningModalVisible = false
  632. // 线下支付:不弹确认框,直接更新支付方式并进入下一步(后端需 sendFormId 更新发单表支付方式)
  633. if (this.paymentMethodRadio === 'offline') {
  634. await uni.$u.api.updateReceiptForm({
  635. id: this.currentReceipt.id,
  636. sendFormId: this.currentReceipt.sendFormId || this.orderDetail.id,
  637. paymentMethod: this.paymentMethod || ''
  638. })
  639. this.handleNext()
  640. return
  641. }
  642. this.payNowModalVisible = true
  643. },
  644. /**
  645. * 确认转账
  646. */
  647. async confirmTransfer() {
  648. this.payNowModalVisible = false
  649. // 支付方式保存(后端需 sendFormId 更新发单表)
  650. await uni.$u.api.updateReceiptForm({
  651. id: this.currentReceipt.id,
  652. sendFormId: this.currentReceipt.sendFormId || this.orderDetail.id,
  653. paymentMethod: this.paymentMethod || ''
  654. })
  655. // 根据 radio 选择判断:线上支付(online / online_alipay)需调用支付接口,线下则直接下一步
  656. if (this.paymentMethodRadio === 'online' || this.paymentMethodRadio === 'online_alipay') {
  657. this.$emit('confirm-pay')
  658. } else {
  659. this.handleNext()
  660. }
  661. },
  662. /**
  663. * 确认未收
  664. */
  665. async confirmUnpaid() {
  666. try {
  667. // 若填写了好处费,先更新回单表
  668. if (this.currentReceipt?.id && (this.unpaidBenefitFee !== '' && this.unpaidBenefitFee != null)) {
  669. await uni.$u.api.updateReceiptForm({
  670. id: this.currentReceipt.id,
  671. benefitFee: this.unpaidBenefitFee
  672. })
  673. }
  674. await uni.$u.api.addOrderFollow({
  675. orderId: this.orderId,
  676. content: `未收评分_${this.unpaidRating}`
  677. })
  678. await uni.$u.api.oderForm({
  679. status: '4',
  680. id: this.orderId
  681. })
  682. uni.$u.toast('提交未收评级成功')
  683. this.unpaidModalVisible = false
  684. this.unpaidBenefitFee = ''
  685. // 刷新当前收单数据,以便第四页好处费等字段同步
  686. this.$emit('price-updated')
  687. } catch (error) {
  688. console.error('提交失败:', error)
  689. uni.$u.toast('提交失败')
  690. }
  691. },
  692. /**
  693. * 确认跟进
  694. */
  695. async confirmFollowUp() {
  696. try {
  697. await uni.$u.api.addOrderFollow({
  698. orderId: this.orderId,
  699. content: `待跟进_${this.followUpNotes}`
  700. })
  701. uni.$u.toast('提交待跟进记录成功')
  702. this.followUpModalVisible = false
  703. this.followUpNotes = ''
  704. } catch (error) {
  705. console.error('提交失败:', error)
  706. uni.$u.toast('提交失败')
  707. }
  708. },
  709. /**
  710. * 下一步
  711. */
  712. async handleNext() {
  713. // 与 PC 端一致:支付信息通过 updateReceiptForm 保存;后端需 sendFormId 才能更新发单表的开户人/银行/身份证等
  714. await uni.$u.api.updateReceiptForm({
  715. id: this.currentReceipt.id,
  716. sendFormId: this.currentReceipt.sendFormId || this.orderDetail.id,
  717. tableFee: this.paymentAmount,
  718. fileIds: this.detailImages.map(item => item.id).join(','),
  719. customName: this.paymentInfo.customName || '',
  720. bankName: this.paymentInfo.bankName || '',
  721. bankCardNumber: this.paymentInfo.bankAccount || '',
  722. idCard: this.paymentInfo.idNumber || '',
  723. // paymentMethod: this.paymentMethod || ''
  724. })
  725. this.$emit('save', {
  726. nowPage: 'formThree',
  727. form: {
  728. ...this.paymentInfo
  729. },
  730. fileIds: this.detailImages.map(item => item.id).join(',')
  731. })
  732. this.$emit('next', {
  733. nowPage: 'formThree',
  734. form: {
  735. ...this.paymentInfo
  736. }
  737. })
  738. },
  739. /**
  740. * 核价
  741. */
  742. async handlePricing() {
  743. const brandList = await this.$getDicts("crm_form_brand");
  744. if (!this.currentReceipt || !this.currentReceipt.clueId) {
  745. uni.$u.toast('缺少线索ID')
  746. return
  747. }
  748. if (!this.currentReceipt.brand) {
  749. uni.$u.toast('缺少品牌信息')
  750. return
  751. }
  752. if (!this.displayImages || this.displayImages.length === 0) {
  753. uni.$u.toast('请先上传图片')
  754. return
  755. }
  756. //我这里询价要用receiptid来询价
  757. this.pricingClueId = this.currentReceipt.id
  758. // brand 是品牌的 id(dictValue),itemBrand 是品牌的 label(dictLabel)
  759. const brandDictLabel = this.currentReceipt.brand
  760. const brandDictValue = brandList.find(item => item.dictLabel === this.currentReceipt.brand).dictValue;
  761. // 将图片转换为 imgsUrl 格式
  762. const imgsUrl = this.displayImages.map(item => item.fileUrl).filter(url => url)
  763. // 检查是否已有核价记录
  764. try {
  765. const data = {
  766. clueId: this.currentReceipt.clueId,
  767. type: 2
  768. }
  769. const res = await uni.$u.api.inquiryDetail(data)
  770. if (res.code === 200 && res.data) {
  771. // 编辑模式:保留原有数据,但更新品牌和图片
  772. this.pricingEditOrAdd = 'editForm'
  773. this.pricingEditInfo = {
  774. ...res.data,
  775. dictLabel: brandDictLabel || res.data.dictLabel,
  776. dictValue: brandDictValue || res.data.dictValue,
  777. imgsUrl: imgsUrl.length > 0 ? imgsUrl : (res.data.imgsUrl || [])
  778. }
  779. this.$nextTick(() => {
  780. this.$refs.pricingDialog.showDialog()
  781. })
  782. } else {
  783. // 新增模式:设置品牌和图片
  784. this.pricingEditOrAdd = 'editForm'
  785. this.pricingEditInfo = {
  786. dictLabel: brandDictLabel,
  787. dictValue: brandDictValue,
  788. imgsUrl: imgsUrl,
  789. model: this.currentReceipt.model,
  790. code: '',
  791. price: ''
  792. }
  793. this.$nextTick(() => {
  794. this.$refs.pricingDialog.showDialog()
  795. })
  796. }
  797. } catch (error) {
  798. // 如果没有记录,则新增
  799. this.pricingEditOrAdd = 'receptFormAdd'
  800. this.pricingEditInfo = {
  801. dictLabel: brandDictLabel,
  802. dictValue: brandDictValue,
  803. imgsUrl: imgsUrl,
  804. model: this.currentReceipt.model,
  805. code: '',
  806. price: ''
  807. }
  808. this.$nextTick(() => {
  809. this.$refs.pricingDialog.showDialog()
  810. })
  811. }
  812. },
  813. }
  814. }
  815. </script>
  816. <style scoped lang="scss">
  817. @import '../styles/common.scss';
  818. .page-three-container {
  819. @extend .page-container;
  820. padding-bottom: 100rpx;
  821. }
  822. .info-card {
  823. @extend .card-wrap;
  824. padding: 20rpx;
  825. margin-top: 20rpx;
  826. box-sizing: border-box;
  827. width: 100%;
  828. max-width: 100%;
  829. }
  830. .info-card-title {
  831. @include font-styles($size: title, $weight: bold, $color: primary);
  832. margin-bottom: 25rpx;
  833. padding-bottom: 15rpx;
  834. border-bottom: 1rpx solid map-get($colors, border);
  835. }
  836. .info-row {
  837. margin-bottom: 20rpx;
  838. }
  839. .info-label {
  840. @include font-styles($size: tiny, $weight: regular, $color: tertiary);
  841. margin-bottom: 8rpx;
  842. display: block;
  843. }
  844. .info-input {
  845. border-radius: 8rpx;
  846. border: 1rpx solid #e5e7eb;
  847. padding: 12rpx 16rpx;
  848. width: 100%;
  849. box-sizing: border-box;
  850. }
  851. .detail-image-section {
  852. padding: 20rpx;
  853. }
  854. .detail-image-header {
  855. display: grid;
  856. grid-template-columns: 1fr auto;
  857. margin-bottom: 20rpx;
  858. padding-bottom: 20rpx;
  859. padding-right: 100rpx; /* 右侧留空,避免被固定页面导航遮挡,使整行(含核价按钮)左移 */
  860. border-bottom: 1rpx solid map-get($colors, border);
  861. }
  862. .detail-image-title {
  863. @include font-styles($size: content, $weight: bold, $color: primary);
  864. }
  865. .detail-image-list {
  866. display: flex;
  867. flex-wrap: wrap;
  868. gap: 20rpx;
  869. position: relative;
  870. }
  871. .detail-image-item {
  872. position: relative;
  873. width: 200rpx;
  874. height: 200rpx;
  875. touch-action: none;
  876. transition: transform 0.2s ease, opacity 0.2s ease;
  877. z-index: 1;
  878. box-sizing: border-box;
  879. &.dragging {
  880. opacity: 0.6;
  881. transform: scale(1.05);
  882. z-index: 999;
  883. box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.2);
  884. }
  885. &.can-drop {
  886. outline: 2rpx dashed #108cff;
  887. outline-offset: -2rpx;
  888. background-color: rgba(16, 140, 255, 0.1);
  889. border-radius: 8rpx;
  890. }
  891. }
  892. .image-type-tag {
  893. position: absolute;
  894. top: 10rpx;
  895. left: 10rpx;
  896. background-color: rgba(0, 0, 0, 0.6);
  897. color: white;
  898. padding: 5rpx 10rpx;
  899. border-radius: 12rpx;
  900. font-size: 22rpx;
  901. z-index: 1;
  902. }
  903. .detail-delete-btn {
  904. position: absolute;
  905. top: -10rpx;
  906. right: -10rpx;
  907. width: 40rpx;
  908. height: 40rpx;
  909. background-color: #ff4d4f;
  910. color: #fff;
  911. border-radius: 50%;
  912. display: flex;
  913. align-items: center;
  914. justify-content: center;
  915. font-weight: bold;
  916. z-index: 10;
  917. cursor: pointer;
  918. }
  919. .detail-upload-btn {
  920. width: 200rpx;
  921. height: 200rpx;
  922. border: 8rpx dashed #ddd;
  923. border-radius: 30rpx;
  924. display: flex;
  925. align-items: center;
  926. justify-content: center;
  927. background-color: #f9f9f9;
  928. cursor: pointer;
  929. }
  930. .pricing-button {
  931. margin-top: 0;
  932. }
  933. .payment-card {
  934. margin-top: 20rpx;
  935. }
  936. .payment-section {
  937. padding: 20rpx;
  938. }
  939. .payment-total-container {
  940. background-color: #f5f7fa;
  941. border: 2rpx solid #e5e7eb;
  942. border-radius: 12rpx;
  943. padding: 0rpx 30rpx;
  944. display: flex;
  945. align-items: center;
  946. justify-content: space-between;
  947. margin-bottom: 24rpx;
  948. }
  949. .payment-label {
  950. font-size: 36rpx;
  951. font-weight: 700;
  952. min-width: 140rpx;
  953. flex-shrink: 0;
  954. }
  955. .payment-amount-wrap {
  956. flex: 1;
  957. display: flex;
  958. justify-content: center;
  959. align-items: center;
  960. min-width: 0;
  961. }
  962. .payment-amount-wrap .payment-amount {
  963. font-size: 48rpx;
  964. font-weight: 600;
  965. color: #f53f3f;
  966. width: 100%;
  967. max-width: 240rpx;
  968. border: none;
  969. text-align: center;
  970. }
  971. /* 让 u-input 内部输入框文字居中 */
  972. .payment-amount-wrap :deep(.u-input__content__field-wrapper__field),
  973. .payment-amount-wrap :deep(input) {
  974. text-align: center !important;
  975. }
  976. .pay-now-btn-wrap {
  977. flex-shrink: 0;
  978. display: inline-flex;
  979. }
  980. .payment-total-container .pay-now-btn-wrap .u-button,
  981. .payment-total-container .pay-now-btn-wrap .u-btn {
  982. width: auto !important;
  983. min-width: 0 !important;
  984. flex: none !important;
  985. }
  986. .payment-buttons-row {
  987. display: flex;
  988. gap: 20rpx;
  989. margin-bottom: 24rpx;
  990. }
  991. .payment-button {
  992. flex: 1;
  993. border-radius: 12rpx;
  994. padding: 5rpx 0;
  995. display: flex;
  996. flex-direction: column;
  997. align-items: center;
  998. justify-content: center;
  999. background-color: #f5f7fa;
  1000. border: 2rpx solid #e5e7eb;
  1001. cursor: pointer;
  1002. gap: 12rpx;
  1003. }
  1004. .button-text {
  1005. font-size: 28rpx;
  1006. font-weight: 500;
  1007. color: inherit;
  1008. }
  1009. .modal-content {
  1010. width: 100%;
  1011. padding: 40rpx 20rpx;
  1012. display: flex;
  1013. flex-direction: column;
  1014. align-items: center;
  1015. }
  1016. .unpaid-benefit-fee-wrap {
  1017. width: 100%;
  1018. margin-top: 32rpx;
  1019. display: flex;
  1020. flex-direction: column;
  1021. align-items: flex-start;
  1022. }
  1023. .unpaid-benefit-fee-label {
  1024. font-size: 28rpx;
  1025. color: #333;
  1026. margin-bottom: 16rpx;
  1027. }
  1028. .unpaid-benefit-fee-input {
  1029. width: 100%;
  1030. border: 2rpx solid #e5e7eb;
  1031. border-radius: 12rpx;
  1032. padding: 20rpx 24rpx;
  1033. box-sizing: border-box;
  1034. }
  1035. .payment-amount-display {
  1036. font-size: 64rpx;
  1037. font-weight: bold;
  1038. color: #108cff;
  1039. text-align: center;
  1040. margin-bottom: 40rpx;
  1041. width: 100%;
  1042. }
  1043. .payment-info-section {
  1044. width: 100%;
  1045. background-color: #f5f7fa;
  1046. border: 2rpx solid #e5e7eb;
  1047. border-radius: 12rpx;
  1048. padding: 30rpx 20rpx;
  1049. margin-bottom: 40rpx;
  1050. }
  1051. .info-item {
  1052. display: flex;
  1053. margin-bottom: 20rpx;
  1054. align-items: center;
  1055. justify-content: space-between;
  1056. &:last-child {
  1057. margin-bottom: 0;
  1058. }
  1059. }
  1060. .next-btn {
  1061. position: fixed;
  1062. bottom: 10rpx;
  1063. left: 2.5%;
  1064. width: 95%;
  1065. height: 80rpx;
  1066. line-height: 80rpx;
  1067. text-align: center;
  1068. border-radius: 20rpx;
  1069. z-index: 1000;
  1070. }
  1071. </style>