nonLogisticsGold.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. <template>
  2. <view class="withdraw">
  3. <view class="content">
  4. <view class="withdraw-body">
  5. <view class="gold-box">
  6. <view class="gold-item">
  7. <view class="header">
  8. <h3 class="title">存金克重</h3>
  9. <view class="live-gold">
  10. 实时金价
  11. <text class="price">{{ viprealGoldprice.toFixed(2) }}</text>
  12. </view>
  13. </view>
  14. <view class="input-box">
  15. <input
  16. type="text"
  17. class="inpu-box-ds"
  18. placeholder="请输入克重"
  19. v-model="extract"
  20. @input="onKeyInput"
  21. placeholder-style="color: #999999; font-size: 28rpx;"
  22. />
  23. </view>
  24. <!-- <view class="header">
  25. <span class="title">淘宝订单号</span>
  26. </view>
  27. <view class="input-box">
  28. <input
  29. type="text"
  30. class="inpu-box-ds"
  31. placeholder="请输入淘宝定单号"
  32. v-model="expressNo"
  33. @input="onKeyInput"
  34. placeholder-style="color: #999999; font-size: 28rpx;"
  35. />
  36. </view> -->
  37. </view>
  38. </view>
  39. <view class="info-money" style="font-size: 16px">
  40. <text class="info-money-num" v-if="extract"
  41. >预存金额= {{ extract }} * {{ viprealGoldprice.toFixed(2) }} =
  42. {{ totalPrice }}元</text
  43. >
  44. <text class="info-money-num" v-else>预存金额0元</text>
  45. </view>
  46. <view class="img-container">
  47. <view class="img-title">
  48. <span class="title">实物图片</span>
  49. </view>
  50. <view class="img-box" style="margin-top: 10px">
  51. <view class="upload-box">
  52. <up-upload
  53. :fileList="imageList"
  54. uploadIcon="plus"
  55. @afterRead="afterRead"
  56. @delete="deletePic"
  57. name="1"
  58. multiple
  59. :maxCount="3"
  60. >
  61. <template #trigger>
  62. <view class="upload-block">
  63. <uni-icons
  64. size="38"
  65. color="#ccc"
  66. type="plusempty"
  67. ></uni-icons>
  68. </view>
  69. </template>
  70. </up-upload>
  71. </view>
  72. </view>
  73. </view>
  74. <view class="submit-box">
  75. <view
  76. :class="'tx' + (is_post ? '' : '-active')"
  77. style="margin-top: 10px"
  78. class="submit"
  79. >
  80. <button @click="handleShowModel">提交存金</button>
  81. </view>
  82. <view class="aggregate" @click="aggregate = !aggregate">
  83. <image
  84. class="choose"
  85. :src="
  86. aggregate
  87. ? '/static/recycle/choose.png'
  88. : '/static/recycle/nochoose.png'
  89. "
  90. mode="scaleToFill"
  91. ></image>
  92. <view class="aggre">
  93. 阅读并同意
  94. <span class="aggre-text" @click="showAggre">《存金协议》</span>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. <uni-popup
  101. ref="singPopup"
  102. type="bottom"
  103. borderRadius="10px 10px 0 0"
  104. maskBackgroundColor="rgba(0,0,0,0)"
  105. >
  106. <view class="signContent">
  107. <scroll-view scrollY class="scroll">
  108. <up-parse :content="agreement"></up-parse>
  109. </scroll-view>
  110. <view
  111. class="comfireBtn footer"
  112. @click="
  113. aggregate = true;
  114. $refs.singPopup.close();
  115. "
  116. >
  117. 我已详细知悉
  118. </view>
  119. </view>
  120. </uni-popup>
  121. </view>
  122. </template>
  123. <script setup>
  124. import { ref, computed, watch } from "vue";
  125. import { onLoad, onShow } from "@dcloudio/uni-app";
  126. import { noLogisticsCreateAPI } from "@/api/functions";
  127. import { useImageUpload } from "@/hooks/useImageUpload";
  128. import { agreementGetoneApi } from "@/api/user";
  129. import useRealGoldPrice from "@/hooks/useRealGoldPrice";
  130. const { imageList, afterRead, deletePic, uploadLoading } = useImageUpload({
  131. pid: 9,
  132. model: "gold",
  133. });
  134. const maoding = ref(0);
  135. const props = defineProps(["viprealGoldprice"]);
  136. const singPopup = ref(null);
  137. const agreement = ref("");
  138. const type = ref("store"); // 初始值与原data一致
  139. const is_lock = ref(false);
  140. const needPrice = ref(0);
  141. const extract = ref(null);
  142. const is_post = ref(false);
  143. const totalPrice = ref(0);
  144. const aggregate = ref(false);
  145. // const expressNo = ref("");
  146. // 获取实时金价
  147. const { realGoldprice } = useRealGoldPrice("RTJ_Au");
  148. const viprealGoldprice = computed(() => Number(realGoldprice.value));
  149. // 获取协议
  150. function agreementGetoneFn() {
  151. // 资产说明
  152. agreementGetoneApi({ name: "saveGold" }).then((res) => {
  153. agreement.value = res.data?.content;
  154. });
  155. }
  156. // 页面生命周期(对应原onLoad)
  157. onShow(() => {});
  158. const showAggre = () => {
  159. agreementGetoneFn();
  160. singPopup.value?.open();
  161. };
  162. const onKeyInput = (e) => {
  163. extract.value = e.target.value;
  164. };
  165. // 提交存金
  166. const handleShowModel = async () => {
  167. if (!extract.value) {
  168. return uni.showToast({
  169. title: "请输入克重",
  170. duration: 2000,
  171. icon: "none",
  172. });
  173. }
  174. // if (!expressNo.value) {
  175. // return uni.showToast({
  176. // title: "请输入快递单号",
  177. // duration: 2000,
  178. // icon: "none",
  179. // });
  180. // }
  181. const res = await noLogisticsCreateAPI({
  182. depositWeight: extract.value,
  183. image: imageList.value.map((v) => v.info.url),
  184. // taobaoOrderNo: expressNo.value,
  185. });
  186. uni.showToast({ title: "下单成功!" });
  187. setTimeout(() => {
  188. uni.navigateTo({
  189. url: "/pages/users/vault/index",
  190. });
  191. }, 1000);
  192. };
  193. watch(
  194. () => extract.value,
  195. (val) => {
  196. if (val) {
  197. totalPrice.value = (
  198. Number(extract.value) * Number(props.viprealGoldprice)
  199. ).toFixed(2);
  200. is_post.value = true;
  201. } else {
  202. is_post.value = false;
  203. }
  204. },
  205. { immediate: true }
  206. );
  207. </script>
  208. <style lang="scss" scoped>
  209. page {
  210. height: 100%;
  211. background-color: #ededed;
  212. }
  213. .upload-box {
  214. .upload-block {
  215. width: 160rpx;
  216. height: 160rpx;
  217. border: 1px solid #ccc;
  218. border-radius: 10rpx;
  219. display: flex;
  220. flex-direction: column;
  221. justify-content: center;
  222. align-items: center;
  223. color: #ccc;
  224. font-weight: 700;
  225. font-size: 26rpx;
  226. }
  227. }
  228. .info-money-num {
  229. color: #999999;
  230. font-size: 26rpx;
  231. }
  232. .submit-box {
  233. margin-top: 300rpx;
  234. }
  235. .submit {
  236. width: 100%;
  237. display: flex;
  238. justify-content: center;
  239. button {
  240. background-color: #dca12b;
  241. color: #fff;
  242. width: 450rpx;
  243. height: 72rpx;
  244. display: flex;
  245. font-size: 30rpx;
  246. justify-content: center;
  247. align-items: center;
  248. border-radius: 30rpx;
  249. }
  250. }
  251. .header {
  252. padding-left: 5px;
  253. position: relative;
  254. display: flex;
  255. align-items: center;
  256. justify-content: space-between;
  257. padding: 10px 10px;
  258. border-radius: 5px;
  259. // background-color: #fff;
  260. // font-weight: bold;
  261. font-size: 18px;
  262. .live-gold {
  263. font-weight: 500;
  264. font-size: 32rpx;
  265. font-family: "黑体";
  266. .price {
  267. color: #d0a34a;
  268. margin-left: 10rpx;
  269. font-weight: bold;
  270. font-size: 38rpx;
  271. }
  272. }
  273. .item {
  274. display: flex;
  275. align-items: center;
  276. margin-top: 15px;
  277. .targe {
  278. display: flex;
  279. justify-content: center;
  280. align-items: center;
  281. color: #fff;
  282. width: 35px;
  283. height: 35px;
  284. border-radius: 50%;
  285. background-color: #cc9933;
  286. }
  287. .address {
  288. width: 440rpx;
  289. margin: 0 10px;
  290. font-size: 28rpx;
  291. .receive-address {
  292. letter-spacing: 9px;
  293. }
  294. }
  295. .end {
  296. display: flex;
  297. justify-content: center;
  298. align-items: center;
  299. .copy {
  300. color: #888888;
  301. border-radius: 3px;
  302. border: 1px solid #888888;
  303. font-size: 24rpx;
  304. padding: 6rpx 23rpx;
  305. }
  306. }
  307. }
  308. &::before {
  309. position: absolute;
  310. /*绝对定位*/
  311. top: 50%;
  312. /*Y轴方向偏移自身高度的50%*/
  313. transform: translatey(-50%);
  314. /*Y轴方向偏移微调*/
  315. left: 0;
  316. /*紧靠容器左边缘*/
  317. content: "";
  318. /*伪元素需要有内容才能显示*/
  319. width: 2px;
  320. /*伪元素宽度*/
  321. height: 15px;
  322. /*伪元素高度*/
  323. background-color: #daa520;
  324. /*伪元素颜色*/
  325. }
  326. .title {
  327. font-weight: 500;
  328. font-size: 32rpx;
  329. font-family: "黑体";
  330. }
  331. }
  332. .gold-box {
  333. padding-top: 30rpx;
  334. .gold-item {
  335. .input-box {
  336. display: flex;
  337. background-color: #ededed;
  338. border-radius: 5px;
  339. height: 90rpx;
  340. align-items: center;
  341. justify-content: space-around;
  342. font-size: 28rpx;
  343. margin: 20rpx 0;
  344. // color:#c7c7c7 ;
  345. input {
  346. padding-left: 12rpx;
  347. width: 92%;
  348. }
  349. }
  350. }
  351. }
  352. .img-container {
  353. padding: 30rpx 0;
  354. .img-title {
  355. padding-left: 5px;
  356. position: relative;
  357. display: flex;
  358. align-items: center;
  359. justify-content: space-between;
  360. padding: 10px 10px;
  361. border-radius: 5px;
  362. font-weight: 500;
  363. font-size: 32rpx;
  364. font-family: "黑体";
  365. &::before {
  366. position: absolute;
  367. top: 50%;
  368. transform: translatey(-50%);
  369. left: 0;
  370. content: "";
  371. width: 2px;
  372. height: 15px;
  373. background-color: #daa520;
  374. }
  375. }
  376. }
  377. .withdraw {
  378. height: 100%;
  379. background-color: #f7f7f7;
  380. height: 100%;
  381. border-radius: 10px 10px 0 0;
  382. position: relative;
  383. // top: -20rpx;
  384. padding: 0 25rpx;
  385. top: -67rpx;
  386. &-body {
  387. // background-color: #fff;
  388. padding: 0 28rpx;
  389. font-size: 14px;
  390. .input-money {
  391. display: flex;
  392. align-items: center;
  393. justify-content: center;
  394. font-weight: 600;
  395. border-bottom: 1px solid #eaeef1;
  396. .rmb {
  397. font-size: 16px;
  398. }
  399. .t-input {
  400. height: 1.9em;
  401. font-size: 2.5em;
  402. border: none;
  403. position: relative;
  404. left: 3.5%;
  405. outline: none;
  406. }
  407. }
  408. .info-money {
  409. font-size: 26rpx;
  410. margin-left: 34rpx;
  411. &-num {
  412. color: #c9c9c9;
  413. }
  414. }
  415. .aggregate {
  416. display: flex;
  417. align-items: center;
  418. justify-content: center;
  419. padding: 10px;
  420. .aggre {
  421. font-size: 28rpx;
  422. margin-left: 10px;
  423. color: #929292;
  424. .aggre-text {
  425. color: #cc9933;
  426. }
  427. }
  428. }
  429. .choose {
  430. width: 16px;
  431. height: 16px;
  432. }
  433. }
  434. }
  435. .tx-active {
  436. button {
  437. color: #fff;
  438. background: #c4bba6;
  439. }
  440. }
  441. .signContent {
  442. background-color: #f8f8f8;
  443. padding: 20px;
  444. box-sizing: border-box;
  445. display: flex;
  446. justify-content: center;
  447. align-items: center;
  448. flex-direction: column;
  449. border-radius: 20px 20px 0 0;
  450. .scroll {
  451. // background-color: #fff;
  452. padding: 4px;
  453. height: 300px;
  454. overflow-y: hidden;
  455. border: 1px solid #dfdfdf;
  456. }
  457. .footer {
  458. margin-top: 10px;
  459. color: #fff;
  460. padding: 4px 20px;
  461. border-radius: 20px;
  462. background: linear-gradient(to right, #8ed187, #5dd665);
  463. }
  464. }
  465. </style>