PageThree.vue 36 KB

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