goldBullionStock.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <view class="content">
  3. <view class="tabs-wrap">
  4. <!-- 新增tabs导航 -->
  5. <view class="takeout-tabs">
  6. <view
  7. class="tab-item"
  8. :class="['tab-active', currentTab === 0 ? 'active' : '']"
  9. @click="currentTab = 0"
  10. >邮寄存金</view
  11. >
  12. <view
  13. class="tab-item"
  14. :key="currentTab"
  15. :class="['tab-active', currentTab === 1 ? 'active' : '']"
  16. @click="currentTab = 1"
  17. >无物流存金</view
  18. >
  19. </view>
  20. </view>
  21. <view v-if="!currentTab">
  22. <gold-mail-form :content="content" :agreement="agreement">
  23. </gold-mail-form>
  24. </view>
  25. <view v-else>
  26. <non-logistics-gold :viprealGoldprice="viprealGoldprice">
  27. </non-logistics-gold>
  28. </view>
  29. </view>
  30. </template>
  31. <script setup>
  32. import { ref, onMounted, computed } from "vue";
  33. import GoldMailForm from "./GoldMailForm.vue";
  34. import nonLogisticsGold from "./nonLogisticsGold.vue";
  35. import { agreementGetoneApi } from "@/api/user";
  36. import { useStoreRights } from "@/stores/rights";
  37. import useRealGoldPrice from "@/hooks/useRealGoldPrice";
  38. import { number } from "../../../../uni_modules/uview-plus/libs/function/test";
  39. const {
  40. realGoldprice, // 黄金实时销售价(基础)
  41. } = useRealGoldPrice({});
  42. const rightsStore = useStoreRights();
  43. // 响应式数据
  44. const currentTab = ref(0);
  45. const content = ref("");
  46. const agreement = ref("");
  47. // Vue 3 中使用 onMounted 替代 onLoad
  48. // 获取协议
  49. function agreementGetoneFn() {
  50. agreementGetoneApi({ name: "saveGoldRules" }).then((res) => {
  51. content.value = res.data?.content;
  52. });
  53. // 资产说明
  54. agreementGetoneApi({ name: "saveGold" }).then((res) => {
  55. agreement.value = res.data?.content;
  56. });
  57. }
  58. // 黄金调整价
  59. const adjustGoldprice = computed(() => {
  60. const res = rightsStore.userBenefits.nobleMeta.find(
  61. (gold) => gold.name == "黄金"
  62. );
  63. return res;
  64. });
  65. // 获取实时金价
  66. const viprealGoldprice = computed(
  67. () =>
  68. Number(realGoldprice.value) -
  69. Number(rightsStore.userBenefits.buy) +
  70. Number(adjustGoldprice.value.sellPriceAdjust)
  71. );
  72. onMounted((options) => {
  73. agreementGetoneFn();
  74. });
  75. // const someComputed = computed(() => { ... })
  76. // function someMethod() { ... }
  77. </script>
  78. <style scoped lang="scss">
  79. /* 新增tabs样式 */
  80. .takeout-tabs {
  81. display: flex;
  82. height: 120rpx;
  83. overflow: hidden;
  84. position: relative;
  85. top: 85rpx;
  86. }
  87. .tabs-wrap {
  88. height: 270rpx;
  89. }
  90. .tab-item {
  91. width: 50%;
  92. height: 100%;
  93. display: flex;
  94. justify-content: center;
  95. align-items: center;
  96. position: relative;
  97. box-sizing: border-box;
  98. color: #484848;
  99. font-size: 30rpx;
  100. &.active {
  101. color: #000;
  102. font-weight: 500;
  103. color: #000000;
  104. }
  105. }
  106. .tab-item.active::after {
  107. content: "";
  108. position: absolute;
  109. bottom: 0;
  110. /* 修改为0,使三角形显示在底部 */
  111. left: 50%;
  112. transform: translateX(-50%);
  113. z-index: 100;
  114. border-style: solid;
  115. border-width: 0 20rpx 20rpx 20rpx;
  116. /* 使用rpx单位 */
  117. border-color: transparent transparent #f7f7f7 transparent;
  118. width: 0;
  119. height: 0;
  120. opacity: 1;
  121. /* 设置为可见 */
  122. transform-origin: center top;
  123. animation: showTriangle 0.3s ease-out forwards;
  124. }
  125. /* 添加动画定义 */
  126. @keyframes showTriangle {
  127. from {
  128. opacity: 0;
  129. transform: translate(-50%, 10rpx);
  130. }
  131. to {
  132. opacity: 1;
  133. transform: translate(-50%, 0);
  134. }
  135. }
  136. .content {
  137. position: relative;
  138. height: 100%;
  139. // background-color: #ededed;
  140. // background: url('https://mp-ad17e5cd-05c1-4df9-b060-556e25dac130.cdn.bspapp.com/mini/static/20250529221733.jpg') top center no-repeat;
  141. // background-size: 100% 40%;
  142. // background-color: #f7f7f7;
  143. background: $uni-bg-primary !important;
  144. }
  145. ::v-deep .uni-input-placeholder {
  146. font-size: 14px;
  147. color: #bdbdbd;
  148. }
  149. </style>