save_gold.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. <template>
  2. <view class="deposit-page">
  3. <view class="top-tabs-container">
  4. <view
  5. class="tab-item"
  6. :class="{ active: activeTab === 'mail' }"
  7. @click="activeTab = 'mail'"
  8. >
  9. 邮寄存金
  10. </view>
  11. <!-- <view
  12. class="tab-item"
  13. :class="{ active: activeTab === 'warehouse' }"
  14. @click="activeTab = 'warehouse'"
  15. >
  16. 无物流存金
  17. </view> -->
  18. </view>
  19. <view class="content-body" v-if="activeTab === 'mail'">
  20. <view class="card-section">
  21. <view class="section-title">自主邮寄</view>
  22. <view class="address-box">
  23. <view class="icon-location">收</view>
  24. <view class="address-info">
  25. <view class="info-line"
  26. >{{ appStore.$wxConfig.mailerName || "回收部" }} |
  27. {{ contact.phone }}</view
  28. >
  29. <view class="info-line">地址 | {{ contact.address }}</view>
  30. </view>
  31. <view class="copy-btn" @click="copyAddress">复制</view>
  32. </view>
  33. </view>
  34. <view class="card-section">
  35. <view class="section-title">快递单号</view>
  36. <view class="input-row">
  37. <up-input
  38. type="text"
  39. v-model="formData.trackingNumber"
  40. placeholder="请输入正确的快递单号"
  41. placeholder-class="placeholder"
  42. border="none"
  43. />
  44. <image class="icon-scan" src="/static/images/scan-icon.png" />
  45. </view>
  46. </view>
  47. <view class="card-section">
  48. <view class="section-title">快递图片</view>
  49. <view class="upload-box">
  50. <up-upload
  51. :fileList="imageList"
  52. @afterRead="afterRead"
  53. @delete="deletePic"
  54. name="1"
  55. multiple
  56. :maxCount="1"
  57. >
  58. <template #trigger>
  59. <view class="upload-block">
  60. <uni-icons size="38" color="#ccc" type="plusempty"></uni-icons>
  61. </view>
  62. </template>
  63. </up-upload>
  64. </view>
  65. </view>
  66. <view class="card-section">
  67. <!-- <template v-for="metal in metalInputs" > -->
  68. <view class="input-row with-arrow">
  69. <text class="input-label">{{ metalTypeText }}克重</text>
  70. <up-input
  71. type="digit"
  72. v-model="formData.weight"
  73. placeholder="请输入"
  74. placeholder-class="placeholder"
  75. class="text-right"
  76. border="none"
  77. />
  78. <text class="arrow">g</text>
  79. </view>
  80. <!-- </template> -->
  81. </view>
  82. <view class="submit-section">
  83. <button class="submit-btn" @click="handleSubmit">立即提交</button>
  84. <!-- 协议选择 -->
  85. <view
  86. class="agreement-section"
  87. style="display: flex; align-items: center"
  88. >
  89. <up-checkbox
  90. v-model:checked="agreedToTerms"
  91. shape="square"
  92. activeColor="#e9c279"
  93. usedAlone
  94. :customStyle="{ marginRight: '12rpx' }"
  95. >
  96. <template #label>
  97. <text class="agreement-text"> 阅读并同意 </text>
  98. </template>
  99. </up-checkbox>
  100. <view class="agreement-link" @click="showAgreement"
  101. >《存金协议》</view
  102. >
  103. </view>
  104. </view>
  105. <!-- 协议弹窗 -->
  106. <up-popup
  107. :show="showAgreementPopup"
  108. mode="center"
  109. border-radius="20"
  110. width="80%"
  111. height="60%"
  112. >
  113. <view class="popup-content">
  114. <view class="popup-header"></view>
  115. <scroll-view scroll-y scroll-left="50" class="popup-body">
  116. <view class="agreement-content">
  117. <Aggrement />
  118. </view>
  119. </scroll-view>
  120. <view class="popup-footer">
  121. <!-- <button class="popup-btn" @click="closeAgreement">
  122. 我已详细知悉
  123. </button> -->
  124. <up-button
  125. class="popup-btn"
  126. text="我已详细知悉"
  127. @click="closeAgreement"
  128. ></up-button>
  129. </view>
  130. </view>
  131. </up-popup>
  132. <view class="info-image-section">
  133. <view class="item-image">
  134. <!-- <image
  135. style="width: 100%"
  136. mode="widthFix"
  137. src="/static//images/formula.png"
  138. /> -->
  139. </view>
  140. <view class="tip-box">
  141. <view class="title">温馨提示</view>
  142. <view class="tip-content"
  143. >※寄出快递前,客户留底打包视频及快递单号,以便工作人员签收快递核验※</view
  144. >
  145. </view>
  146. <view class="item-image">
  147. <!-- <image
  148. style="width: 100%"
  149. mode="widthFix"
  150. src="/static/images/gold_table.png"
  151. /> -->
  152. </view>
  153. <view class="text-section">
  154. <view class="paragraph"
  155. >1、下午三点前收到寄回包裹当天处理,三点之后统一隔天处理(48小时内打款)</view
  156. >
  157. <view class="paragraph"
  158. >2、如有塑料膜,珐琅、烤漆,镶嵌等辅料,熔烧会产生损耗,按实际熔烧后成色、克重回收;</view
  159. >
  160. <view class="paragraph"
  161. >3、任意时间可提交订单,客服在线时间为早10点~晚8点;</view
  162. >
  163. <view class="paragraph"
  164. >4、如用户担心货品运输风险,建议您保价邮寄。(更多咨询请联系在线客服);</view
  165. >
  166. </view>
  167. <view class="item-image qr_code">
  168. <!-- <image
  169. style="width: 100%"
  170. mode="widthFix"
  171. src="/static/images/tpy_qr_code.jpg"
  172. /> -->
  173. </view>
  174. <view class="text-section">
  175. <view class="paragraph"
  176. >5、黄金到账时间:通常情况下,在线上平台确认金重后,黄金会实时存入用户贵金属账户中;</view
  177. >
  178. <view class="paragraph">6、线上存金,需选择自主邮寄;</view>
  179. <view class="paragraph"
  180. >7、足金,K金一定要分开装袋,如熔完后出现因足金K金未分开而造成的成色不足,则需客户自己承担。</view
  181. >
  182. </view>
  183. <view class="alert-text">
  184. <view class="paragraph">注:周日休息,请错开时间!</view>
  185. <view class="paragraph"
  186. >客服热线:19925434991 客服微信:19925434991</view
  187. >
  188. </view>
  189. </view>
  190. </view>
  191. </view>
  192. </template>
  193. <script setup>
  194. import { ref, reactive, computed } from "vue";
  195. import { onLoad } from "@dcloudio/uni-app";
  196. import { useAppStore } from "@/stores/app";
  197. import { useImageUpload } from "@/hooks/useImageUpload";
  198. import Aggrement from "./aggrement.vue";
  199. import { liveExchange } from "@/api/vault";
  200. import { useToast } from "@/hooks/useToast";
  201. // 当前激活的Tab
  202. const activeTab = ref("mail");
  203. const { Toast } = useToast();
  204. const appStore = useAppStore();
  205. const { imageList, afterRead, deletePic, uploadLoading } = useImageUpload({
  206. pid: 9,
  207. model: "gold",
  208. });
  209. // 联系人信息 - 从 appStore 获取
  210. const contact = computed(() => ({
  211. phone: appStore.$wxConfig.mailerPhone,
  212. address: appStore.$wxConfig.mailingAddress,
  213. }));
  214. // 表单数据
  215. const formData = reactive({
  216. trackingNumber: "", // 订单号
  217. imageUrl: "", // 上传的图片URL
  218. weight: "",
  219. weights: {
  220. gold: "",
  221. kGold: "",
  222. platinum: "",
  223. silver: "",
  224. },
  225. agreeToTerms: false,
  226. });
  227. // 金属输入项配置
  228. const metalInputs = ref([
  229. { label: "黄金金重", key: "gold", metalType: 1 },
  230. { label: "铂金金重", key: "kGold", metalType: 2 },
  231. { label: "白银金重", key: "platinum", metalType: 3 },
  232. // { label: "白银金重", key: "silver", metalType: 4 },
  233. ]);
  234. //metalType 金属类型(1黄金、2铂金、3白银···)
  235. const metalType = ref(1);
  236. const metalTypeText = computed(() => {
  237. return metalType.value == 1
  238. ? "黄金"
  239. : metalType.value == 2
  240. ? "铂金"
  241. : metalType.value == 3
  242. ? "白银"
  243. : "";
  244. });
  245. // 复制地址方法
  246. const copyAddress = () => {
  247. const fullText = `${appStore.$wxConfig.mailerName || "回收部"}:${
  248. contact.phone
  249. } 地址: ${contact.address}`;
  250. uni.setClipboardData({
  251. data: fullText,
  252. success: () => {
  253. Toast({
  254. title: "地址已复制",
  255. icon: "none",
  256. });
  257. },
  258. });
  259. };
  260. // 协议弹窗相关逻辑
  261. const showAgreementPopup = ref(false);
  262. const showAgreement = () => {
  263. showAgreementPopup.value = true;
  264. };
  265. const closeAgreement = () => {
  266. showAgreementPopup.value = false;
  267. };
  268. // 协议勾选状态
  269. const agreedToTerms = ref(false);
  270. onLoad((p) => {
  271. metalType.value = p.type;
  272. });
  273. // 提交表单方法
  274. const handleSubmit = async () => {
  275. if (!agreedToTerms.value) {
  276. Toast({
  277. title: "请先阅读并同意存金协议",
  278. icon: "none",
  279. });
  280. return;
  281. }
  282. if (!formData.trackingNumber) {
  283. Toast({
  284. title: "请填写快递单号",
  285. icon: "none",
  286. });
  287. return;
  288. }
  289. if (!formData.weight || Number(formData.weight) <= 0) {
  290. Toast({
  291. title: `请填写${metalTypeText.value}金重`,
  292. icon: "none",
  293. });
  294. return;
  295. }
  296. if (!imageList.value || imageList.value.length === 0) {
  297. Toast({
  298. title: "请上传快递图片",
  299. icon: "none",
  300. });
  301. return;
  302. }
  303. if (uploadLoading.value) {
  304. Toast({
  305. title: "正在上传图片",
  306. icon: "none",
  307. });
  308. return;
  309. }
  310. try {
  311. uni.showLoading({
  312. title: "提交中...",
  313. });
  314. const params = {
  315. userId: appStore.uid,
  316. operationType: 1, // 1 - 存金
  317. orderNo: formData.trackingNumber,
  318. weight: formData.weight,
  319. metalType: metalType.value,
  320. price: 0,
  321. type: 1,
  322. imageUrl: imageList.value[0].info.url,
  323. };
  324. await liveExchange(params);
  325. setTimeout(() => {
  326. uni.navigateBack();
  327. }, 500);
  328. Toast({ title: "提交成功" });
  329. } catch (error) {
  330. console.error("liveExchange", error);
  331. const title = typeof error === "string" ? error : "提交失败";
  332. Toast({ title });
  333. } finally {
  334. uni.hideLoading();
  335. }
  336. };
  337. </script>
  338. <style lang="scss">
  339. // 页面和主题变量
  340. $page-bg-color: #f7f7f7;
  341. $theme-color: #e9c279;
  342. $text-primary: #333;
  343. $text-secondary: #999;
  344. $white: #ffffff;
  345. $border-color: #f0f0f0;
  346. page {
  347. background-color: $page-bg-color;
  348. color: $text-primary;
  349. }
  350. .deposit-page {
  351. padding-bottom: 40rpx;
  352. }
  353. // 顶部 Tabs
  354. .top-tabs-container {
  355. display: flex;
  356. justify-content: center;
  357. align-items: center;
  358. padding: 30rpx 0;
  359. background-color: $white;
  360. gap: 80rpx;
  361. border-bottom: 1px solid $border-color;
  362. .tab-item {
  363. font-size: 30rpx;
  364. color: $text-secondary;
  365. padding-bottom: 10rpx;
  366. border-bottom: 2px solid transparent;
  367. transition: all 0.3s ease;
  368. &.active {
  369. font-weight: bold;
  370. color: $theme-color;
  371. border-bottom-color: $theme-color;
  372. }
  373. }
  374. }
  375. .content-body {
  376. padding: 30rpx;
  377. }
  378. // 卡片样式
  379. .card-section {
  380. background-color: $white;
  381. border-radius: 16rpx;
  382. padding: 30rpx;
  383. margin-bottom: 24rpx;
  384. .section-title {
  385. font-size: 30rpx;
  386. line-height: 30rpx;
  387. font-weight: bold;
  388. margin-bottom: 20rpx;
  389. position: relative;
  390. padding-left: 20rpx;
  391. &::before {
  392. content: "";
  393. width: 4rpx;
  394. height: 100%;
  395. background: #daa520;
  396. position: absolute;
  397. left: 0;
  398. top: 0;
  399. }
  400. }
  401. }
  402. .upload-box {
  403. border-top: 1rpx solid #ccc;
  404. padding: 50rpx 0 0;
  405. ::v-deep .u-upload__wrap__preview__image {
  406. width: 143rpx !important;
  407. height: 143rpx !important;
  408. }
  409. .upload-block {
  410. width: 150rpx;
  411. height: 150rpx;
  412. border: 1px solid #ccc;
  413. border-radius: 10rpx;
  414. display: flex;
  415. flex-direction: column;
  416. justify-content: center;
  417. align-items: center;
  418. color: #ccc;
  419. font-weight: 700;
  420. font-size: 26rpx;
  421. }
  422. }
  423. // 地址框
  424. .address-box {
  425. display: flex;
  426. align-items: center;
  427. background-color: #fcf9f3;
  428. padding: 20rpx;
  429. border-radius: 12rpx;
  430. .icon-location {
  431. width: 70rpx;
  432. height: 70rpx;
  433. line-height: 70rpx;
  434. color: #fff;
  435. text-align: center;
  436. background-color: #cc9933;
  437. border-radius: 50rpx;
  438. margin-right: 20rpx;
  439. flex-shrink: 0;
  440. }
  441. .address-info {
  442. flex-grow: 1;
  443. font-size: 26rpx;
  444. line-height: 1.6;
  445. }
  446. .copy-btn {
  447. flex-shrink: 0;
  448. margin-left: 20rpx;
  449. padding: 10rpx 24rpx;
  450. border: 1px solid $theme-color;
  451. color: $theme-color;
  452. border-radius: 30rpx;
  453. font-size: 24rpx;
  454. }
  455. }
  456. // 输入行
  457. .input-row {
  458. display: flex;
  459. align-items: center;
  460. border-bottom: 1px solid $border-color;
  461. padding: 20rpx 0;
  462. .placeholder {
  463. color: #cccccc;
  464. }
  465. input {
  466. flex-grow: 1;
  467. font-size: 28rpx;
  468. }
  469. .icon-scan {
  470. width: 40rpx;
  471. height: 40rpx;
  472. margin-left: 20rpx;
  473. }
  474. .input-label {
  475. font-size: 28rpx;
  476. color: $text-primary;
  477. margin-right: 15rpx;
  478. }
  479. .text-right {
  480. text-align: right;
  481. }
  482. &.with-arrow {
  483. .arrow {
  484. font-size: 28rpx;
  485. color: $header-color;
  486. margin-left: 10rpx;
  487. }
  488. }
  489. // &:last-child {
  490. // border-bottom: none;
  491. // }
  492. }
  493. // 图片上传
  494. .image-uploader {
  495. width: 160rpx;
  496. height: 160rpx;
  497. border: 2rpx dashed $text-secondary;
  498. border-radius: 12rpx;
  499. display: flex;
  500. justify-content: center;
  501. align-items: center;
  502. color: $text-secondary;
  503. font-size: 60rpx;
  504. overflow: hidden;
  505. .preview-image {
  506. width: 100%;
  507. height: 100%;
  508. }
  509. }
  510. // 提交区域
  511. .submit-section {
  512. margin-top: 40rpx;
  513. .submit-btn {
  514. background-color: $theme-color;
  515. color: $white;
  516. border-radius: 50rpx;
  517. font-size: 32rpx;
  518. height: 90rpx;
  519. line-height: 90rpx;
  520. &:after {
  521. border: none;
  522. }
  523. }
  524. .agreement-box {
  525. display: flex;
  526. justify-content: center;
  527. align-items: center;
  528. margin-top: 30rpx;
  529. font-size: 24rpx;
  530. color: $text-secondary;
  531. }
  532. }
  533. .agreement-section {
  534. margin: 30rpx 0 40rpx;
  535. display: flex;
  536. align-items: center;
  537. }
  538. .agreement-text {
  539. font-size: 28rpx;
  540. color: #666;
  541. }
  542. .agreement-link {
  543. color: #e9c279;
  544. text-decoration: underline;
  545. margin-left: 4rpx;
  546. }
  547. // 弹窗样式
  548. .popup-content {
  549. width: 80vw;
  550. padding: 40rpx 40rpx 0;
  551. height: 80vh;
  552. // display: flex;
  553. // flex-direction: column;
  554. }
  555. .popup-header {
  556. display: flex;
  557. justify-content: space-between;
  558. align-items: center;
  559. margin-bottom: 30rpx;
  560. .popup-title {
  561. font-size: 36rpx;
  562. font-weight: bold;
  563. color: #333;
  564. }
  565. .popup-close {
  566. font-size: 48rpx;
  567. color: #666;
  568. cursor: pointer;
  569. }
  570. }
  571. .popup-footer {
  572. margin-top: 30rpx;
  573. .popup-btn {
  574. width: 100%;
  575. background: #e9c279;
  576. color: white;
  577. border: none;
  578. border-radius: 12rpx;
  579. padding: 30rpx 30rpx;
  580. font-size: 32rpx;
  581. }
  582. }
  583. .popup-body {
  584. height: 85%;
  585. // flex: 1;
  586. // min-height: 0; // 关键,防止flex塌陷
  587. .agreement-content {
  588. font-size: 28rpx;
  589. line-height: 1.6;
  590. color: #666;
  591. }
  592. }
  593. // 说明图片区域
  594. .info-image-section {
  595. margin-top: 40rpx;
  596. .tip-box {
  597. .title {
  598. color: #cc9933;
  599. }
  600. }
  601. .paragraph {
  602. color: #cc9933;
  603. }
  604. .qr_code {
  605. width: 200rpx;
  606. }
  607. .alert-text {
  608. margin: 20rpx 0 0;
  609. .paragraph {
  610. color: red;
  611. }
  612. }
  613. }
  614. </style>