pageThree.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. <template>
  2. <view class="page-container">
  3. <!-- 支付信息录入卡片 -->
  4. <view class="info-card">
  5. <view class="info-card-title">支付信息</view>
  6. <!-- 开户人和银行名称同一行 -->
  7. <u-row class="info-row" justify="space-between">
  8. <u-col span="5.8">
  9. <view class="info-label">开户人</view>
  10. <u-input v-model="paymentInfo.accountHolder" placeholder="请输入开户人姓名" class="info-input" />
  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. </u-col>
  16. </u-row>
  17. <!-- 银行账号单独一行 -->
  18. <u-row class="info-row">
  19. <u-col span="12">
  20. <view class="info-label">银行账号</view>
  21. <u-input v-model="paymentInfo.bankAccount" placeholder="请输入银行账号" class="info-input" />
  22. </u-col>
  23. </u-row>
  24. <!-- 身份证号单独一行 -->
  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. </u-col>
  30. </u-row>
  31. </view>
  32. <view class="card_wrap">
  33. <view class="detail-image-section">
  34. <view class="detail-image-header">
  35. <div class="detail-image-title">高清实物图(拖拽排序)</div>
  36. </view>
  37. <view class="detail-image-content">
  38. <view class="detail-image-list">
  39. <!-- 替换drag事件为touch事件 -->
  40. <view class="detail-image-item" v-for="(item, index) in localDetailImages"
  41. :key="'detail-' + index" :style="{ opacity: draggingIndex === index ? 0.5 : 1 }"
  42. @touchstart="onTouchStart($event, index)" @touchmove="onTouchMove($event, index)"
  43. @touchend="onTouchEnd">
  44. <pic-comp :src="item"></pic-comp>
  45. <view class="image-type-tag">{{ getImageType(index) }}</view>
  46. <view class="detail-delete-btn" @click="deleteImage(index)">×</view>
  47. </view>
  48. <view class="detail-upload-btn" @click="uploadDetailImage">
  49. <u-icon name="plus" size="40rpx" color="#999"></u-icon>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <!-- 支付总额卡片 -->
  56. <view class="card_wrap payment-card">
  57. <view class="payment-section">
  58. <view class="payment-total-container">
  59. <text class="payment-label">支付总额</text>
  60. <text class="payment-amount">¥0.00</text>
  61. </view>
  62. <view class="payment-buttons-row">
  63. <view class="payment-button" @click="handleUnpaidClick">
  64. <u-icon name="star" size="40rpx" color="#ff9500"></u-icon>
  65. <text class="button-text">未收</text>
  66. </view>
  67. <view class="payment-button" @click="handleFollowUpClick">
  68. <u-icon name="chat" size="40rpx" color="#108cff"></u-icon>
  69. <text class="button-text">待跟进</text>
  70. </view>
  71. </view>
  72. <view class="pay-now-button" @click="handlePayNowClick">
  73. <text class="button-text">立即支付</text>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. </template>
  79. <script>
  80. import picComp from './picComp.vue'
  81. export default {
  82. components: {
  83. picComp
  84. },
  85. props: {
  86. detailImages: {
  87. type: Array,
  88. default: () => []
  89. }
  90. },
  91. data() {
  92. return {
  93. // 支付信息
  94. paymentInfo: {
  95. accountHolder: '', // 开户人
  96. bankName: '', // 银行名称
  97. bankAccount: '', // 银行账号
  98. idNumber: '' // 身份证号
  99. },
  100. // Local copy of detailImages prop to avoid direct mutation
  101. localDetailImages: [...this.detailImages],
  102. // 拖拽相关状态
  103. draggingIndex: -1, // 当前正在拖拽的元素索引
  104. startX: 0, // 触摸起始X坐标
  105. startY: 0 // 触摸起始Y坐标
  106. };
  107. },
  108. watch: {
  109. detailImages: {
  110. handler(newVal) {
  111. this.localDetailImages = [...newVal];
  112. },
  113. deep: true
  114. }
  115. },
  116. methods: {
  117. // 上传高清细节图
  118. uploadDetailImage() {
  119. uni.chooseImage({
  120. count: 9 - this.localDetailImages.length, // 最多选择9张
  121. sizeType: ['compressed'], // 压缩图片
  122. sourceType: ['album', 'camera'], // 从相册选择或拍照
  123. success: (res) => {
  124. const tempFilePaths = res.tempFilePaths;
  125. // 将图片路径添加到数组中
  126. this.localDetailImages = [...this.localDetailImages, ...tempFilePaths];
  127. },
  128. fail: (err) => {
  129. console.error('选择图片失败:', err);
  130. uni.showToast({
  131. title: '选择图片失败',
  132. icon: 'none'
  133. });
  134. }
  135. });
  136. },
  137. // 删除图片
  138. deleteImage(index) {
  139. uni.showModal({
  140. title: '提示',
  141. content: '确定要删除这张图片吗?',
  142. success: (res) => {
  143. if (res.confirm) {
  144. this.localDetailImages.splice(index, 1);
  145. }
  146. }
  147. });
  148. },
  149. // 获取图片类型
  150. getImageType(index) {
  151. const types = ['正面', '反面', '侧面', '扣子', '编号'];
  152. return types[index] || `细节${index - 4}`;
  153. },
  154. // 触摸开始(替代dragstart)
  155. onTouchStart(event, index) {
  156. this.draggingIndex = index;
  157. // 记录触摸起始坐标
  158. this.startX = event.touches[0].clientX;
  159. this.startY = event.touches[0].clientY;
  160. console.log('开始拖拽:', index);
  161. },
  162. // 触摸移动(替代dragover/drop)
  163. onTouchMove(event, currentIndex) {
  164. if (this.draggingIndex === -1) return; // 没有正在拖拽的元素则返回
  165. const moveX = event.touches[0].clientX;
  166. const moveY = event.touches[0].clientY;
  167. const diffX = moveX - this.startX;
  168. const diffY = moveY - this.startY;
  169. // 简单的拖拽距离判断(避免轻微滑动就触发交换)
  170. if (Math.abs(diffX) > 20 || Math.abs(diffY) > 20) {
  171. // 获取当前触摸位置对应的元素索引
  172. const targetIndex = this.getTargetIndexByPosition(moveX, moveY);
  173. if (targetIndex !== -1 && targetIndex !== this.draggingIndex) {
  174. // 交换数组元素(核心排序逻辑)
  175. [this.localDetailImages[this.draggingIndex], this.localDetailImages[targetIndex]] =
  176. [this.localDetailImages[targetIndex], this.localDetailImages[this.draggingIndex]];
  177. // 更新拖拽索引为目标索引(实现连续拖拽)
  178. this.draggingIndex = targetIndex;
  179. // 重置起始坐标
  180. this.startX = moveX;
  181. this.startY = moveY;
  182. }
  183. }
  184. },
  185. // 触摸结束(替代dragend)
  186. onTouchEnd() {
  187. console.log('拖拽结束');
  188. this.draggingIndex = -1; // 重置拖拽状态
  189. },
  190. // 根据触摸坐标获取目标元素索引(核心辅助方法)
  191. getTargetIndexByPosition(x, y) {
  192. // 获取所有图片元素的位置信息
  193. const query = uni.createSelectorQuery().in(this);
  194. return new Promise((resolve) => {
  195. query.selectAll('.detail-image-item').boundingClientRect(rects => {
  196. for (let i = 0; i < rects.length; i++) {
  197. const rect = rects[i];
  198. // 判断坐标是否在元素范围内
  199. if (
  200. x >= rect.left &&
  201. x <= rect.right &&
  202. y >= rect.top &&
  203. y <= rect.bottom
  204. ) {
  205. resolve(i);
  206. return;
  207. }
  208. }
  209. resolve(-1);
  210. }).exec();
  211. });
  212. },
  213. // 下一步按钮点击事件
  214. handleNextClick() {
  215. this.$emit('handleNextClick', {
  216. nowPage: 'formThree',
  217. form: {
  218. detailImages: this.localDetailImages,
  219. paymentInfo: this.paymentInfo
  220. }
  221. });
  222. },
  223. // 未收按钮点击事件
  224. handleUnpaidClick() {
  225. console.log('点击了未收按钮');
  226. },
  227. // 待跟进按钮点击事件
  228. handleFollowUpClick() {
  229. console.log('点击了待跟进按钮');
  230. },
  231. // 立即支付按钮点击事件
  232. handlePayNowClick() {
  233. console.log('点击了立即支付按钮');
  234. }
  235. }
  236. }
  237. </script>
  238. <style lang="scss" scoped>
  239. // 导入公共样式
  240. @import './common.scss';
  241. // 主样式
  242. .page-container {
  243. box-sizing: border-box;
  244. padding: 0;
  245. background-color: map-get($colors, bg);
  246. font-family: map-get($font, family);
  247. -webkit-font-smoothing: map-get($font, smoothing);
  248. font-smoothing: map-get($font, smoothing);
  249. }
  250. .card_wrap {
  251. @include card;
  252. margin-bottom: 20rpx;
  253. &:hover {
  254. @include shadow(2);
  255. }
  256. }
  257. .detail-image-section {
  258. padding: map-get($sizes, padding-sm) map-get($sizes, padding);
  259. }
  260. .detail-image-content {
  261. margin-top: 20rpx;
  262. .detail-image-list {
  263. display: flex;
  264. flex-wrap: wrap;
  265. gap: 20rpx;
  266. }
  267. .detail-image-item {
  268. position: relative;
  269. width: 200rpx;
  270. height: 200rpx;
  271. box-sizing: border-box;
  272. touch-action: none; // 禁止浏览器默认触摸行为
  273. transition: opacity 0.2s; // 拖拽时的透明度过渡
  274. &:active {
  275. opacity: 0.7;
  276. }
  277. }
  278. .image-type-tag {
  279. position: absolute;
  280. top: 10rpx;
  281. left: 10rpx;
  282. background-color: rgba(0, 0, 0, 0.6);
  283. color: white;
  284. padding: 5rpx 10rpx;
  285. border-radius: 12rpx;
  286. font-size: 22rpx;
  287. z-index: 1;
  288. }
  289. .detail-delete-btn {
  290. position: absolute;
  291. top: -10rpx;
  292. right: -10rpx;
  293. width: 40rpx;
  294. height: 40rpx;
  295. background-color: #ff4d4f;
  296. color: #fff;
  297. border-radius: 50%;
  298. display: flex;
  299. align-items: center;
  300. justify-content: center;
  301. @include font-styles($size: small, $weight: bold);
  302. z-index: 10;
  303. }
  304. .detail-upload-btn {
  305. width: 200rpx;
  306. height: 200rpx;
  307. border: 8rpx dashed #ddd;
  308. border-radius: 30rpx;
  309. display: flex;
  310. align-items: center;
  311. justify-content: center;
  312. background-color: #f9f9f9;
  313. box-sizing: border-box;
  314. cursor: pointer;
  315. &:hover {
  316. border-color: #108cff;
  317. background-color: rgba(16, 140, 255, 0.05);
  318. }
  319. }
  320. .no-images {
  321. @include font-styles($size: content, $weight: regular, $color: tertiary);
  322. text-align: center;
  323. padding: 80rpx 0;
  324. background-color: #f9f9f9;
  325. border-radius: 12rpx;
  326. margin-top: 20rpx;
  327. }
  328. }
  329. .detail-image-header {
  330. display: flex;
  331. justify-content: space-between;
  332. align-items: center;
  333. margin-bottom: map-get($sizes, margin-sm);
  334. padding-bottom: map-get($sizes, margin-sm);
  335. border-bottom: 1rpx solid map-get($colors, border);
  336. }
  337. .detail-image-title {
  338. @include font-styles($size: content, $weight: bold, $color: primary);
  339. }
  340. /* 支付信息卡片样式 */
  341. .info-card {
  342. @include card;
  343. margin-top: 20rpx;
  344. margin-bottom: 20rpx;
  345. padding: map-get($sizes, padding-sm) map-get($sizes, padding);
  346. box-sizing: border-box;
  347. &:hover {
  348. @include shadow(2);
  349. }
  350. .u-col {
  351. padding: 0;
  352. box-sizing: border-box;
  353. }
  354. .u-col:first-child {
  355. padding-right: 15rpx;
  356. }
  357. .u-col:last-child {
  358. padding-left: 15rpx;
  359. }
  360. }
  361. .info-card-title {
  362. @include font-styles($size: title, $weight: bold, $color: primary);
  363. margin-bottom: 25rpx;
  364. padding-bottom: 15rpx;
  365. border-bottom: 1rpx solid map-get($colors, border);
  366. }
  367. .info-row {
  368. margin-bottom: 20rpx;
  369. box-sizing: border-box;
  370. padding: 0;
  371. }
  372. .info-label {
  373. @include font-styles($size: tiny, $weight: regular, $color: tertiary);
  374. margin-bottom: 8rpx;
  375. display: block;
  376. }
  377. .info-input {
  378. border-radius: 8rpx;
  379. border: 1rpx solid #e5e7eb;
  380. padding: 12rpx 16rpx;
  381. width: 100%;
  382. box-sizing: border-box;
  383. @include font-styles($size: small, $weight: regular, $color: secondary);
  384. }
  385. /* 支付总额卡片样式 */
  386. .payment-card {
  387. @include card;
  388. margin-top: 20rpx;
  389. margin-bottom: 20rpx;
  390. }
  391. .payment-section {
  392. padding: map-get($sizes, padding-sm) map-get($sizes, padding);
  393. }
  394. .payment-total-container {
  395. background-color: #f5f7fa;
  396. border: 2rpx solid #e5e7eb;
  397. border-radius: 12rpx;
  398. padding: 24rpx 30rpx;
  399. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
  400. display: flex;
  401. align-items: center;
  402. justify-content: space-between;
  403. margin-bottom: 24rpx;
  404. }
  405. .payment-label {
  406. font-size: 36rpx;
  407. color: map-get($colors, text-primary);
  408. font-weight: 700;
  409. min-width: 140rpx;
  410. }
  411. .payment-amount {
  412. font-size: 48rpx;
  413. font-weight: 600;
  414. color: #f53f3f;
  415. font-family: Consolas, 'Courier New', monospace, -apple-system, BlinkMacSystemFont;
  416. }
  417. /* 支付按钮行样式 */
  418. .payment-buttons-row {
  419. display: flex;
  420. gap: 20rpx;
  421. margin-bottom: 24rpx;
  422. }
  423. .payment-button {
  424. flex: 1;
  425. border-radius: 12rpx;
  426. padding: 24rpx 0;
  427. display: flex;
  428. flex-direction: column;
  429. align-items: center;
  430. justify-content: center;
  431. background-color: #f5f7fa;
  432. border: 2rpx solid #e5e7eb;
  433. cursor: pointer;
  434. transition: all 0.3s ease;
  435. gap: 12rpx;
  436. }
  437. .payment-button:hover {
  438. background-color: #e6f7ed;
  439. border-color: #00b42a;
  440. transform: translateY(-2rpx);
  441. box-shadow: 0 4rpx 12rpx rgba(0, 180, 42, 0.15);
  442. }
  443. /* 立即支付按钮样式 */
  444. .pay-now-button {
  445. width: 100%;
  446. border-radius: 12rpx;
  447. padding: 32rpx 0;
  448. display: flex;
  449. flex-direction: column;
  450. align-items: center;
  451. justify-content: center;
  452. background-color: #108cff;
  453. color: #fff;
  454. cursor: pointer;
  455. transition: all 0.3s ease;
  456. gap: 12rpx;
  457. box-shadow: 0 4rpx 12rpx rgba(16, 140, 255, 0.2);
  458. }
  459. .pay-now-button:hover {
  460. background-color: #007aff;
  461. transform: translateY(-2rpx);
  462. box-shadow: 0 6rpx 16rpx rgba(16, 140, 255, 0.25);
  463. }
  464. .button-text {
  465. font-size: 28rpx;
  466. font-weight: 500;
  467. color: inherit;
  468. }
  469. </style>