withdraw.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <Theme>
  3. <view class="wrap">
  4. <Navbar fixed border title="提现">
  5. <template #right>
  6. <navMenu :options="{ icon: 'icon-home', text: '主页' }" />
  7. <view class="nav_right" @click.stop="handleTo">
  8. <trans _t="记录" />
  9. </view>
  10. </template>
  11. </Navbar>
  12. <view class="content">
  13. <view class="bank">
  14. <view class="bank_item">
  15. <view class="label">
  16. <trans _t="可用余额" />({{ symbol.symbol }})
  17. </view>
  18. <view class="value">{{ symbol.symbol }}{{ Moneyhtml(userInfo.money) }}
  19. </view>
  20. </view>
  21. </view>
  22. <view class="bank">
  23. <view class="bank_item">
  24. <view class="label">
  25. <trans _t="提款金额" />({{ symbol.symbol }})
  26. </view>
  27. <view class="money_value">
  28. <Input v-model="money" shape="square" type="number" :placeholder="t('请输入提款金额')" />
  29. <view class="all" @click="all">
  30. <trans _t="全部" />
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="edit_bank" @click="() => popupRef.open()">
  36. <view class="edit_label">
  37. <trans _t="编辑您的银行卡" />
  38. </view>
  39. <i class="icon-font icon-back"></i>
  40. </view>
  41. <view class="btn" @click="submit">
  42. <trans _t="提款" />
  43. </view>
  44. </view>
  45. <popup title="您的银行卡账户" isClose ref="popupRef">
  46. <template #content>
  47. <view class="bank_info">
  48. <view class="info_name">
  49. <view class="label">
  50. <trans _t="姓名" />
  51. </view>
  52. <view class="value">
  53. <Input v-model="bank.name" shape="square" :placeholder="t('请填写持卡人姓名')" />
  54. </view>
  55. </view>
  56. <view class="info_bank">
  57. <view class="label">
  58. <trans _t="银行名称" />
  59. </view>
  60. <view class="value">
  61. <Input v-model="bank.bank" shape="square" :placeholder="t('请填写银行名称')" />
  62. </view>
  63. </view>
  64. <view class="info_card">
  65. <view class="label">
  66. <trans _t="银行卡" />
  67. </view>
  68. <view class="value">
  69. <Input v-model="bank.card" shape="square" :placeholder="t('请填写银行卡')" />
  70. </view>
  71. </view>
  72. </view>
  73. </template>
  74. <template #footer>
  75. <view class="footer_btn" :style="{ opacity: (bank.name && bank.card && bank.card) ? 1 : .5 }"
  76. @click="AddBank">
  77. <trans _t="保存" />
  78. </view>
  79. </template>
  80. </popup>
  81. </view>
  82. </Theme>
  83. </template>
  84. <script setup>
  85. import Navbar from "@/components/navbar";
  86. import navMenu from "@/components/nav_menu";
  87. import popup from "@/components/popup"
  88. import { ref, onMounted, computed, nextTick } from "vue";
  89. import { useUserStore, useSystemStore } from "@/store"
  90. import Input from "@/components/input"
  91. import { t } from "@/locale"
  92. import { USER_BANK_ADD, USER_BANK, USER_EXTRACT } from "@/api"
  93. import { Toast, Moneyhtml } from "@/utils";
  94. import { onShow } from "@dcloudio/uni-app"
  95. const useUser = useUserStore();
  96. const useSystem = useSystemStore();
  97. const popupRef = ref(null);
  98. const money = ref('');
  99. const userInfo = computed(() => useUser.getuserInfo);
  100. const currency = computed(() => useSystem.getCurrency);
  101. const symbol = computed(() => useSystem.getSymbol);
  102. const bank = ref({
  103. name: '',
  104. bank: '',
  105. card: ''
  106. })
  107. const handleTo = () => {
  108. uni.navigateTo({ url: '/pages/bank/withdraw_list' })
  109. }
  110. const all = () => {
  111. if (userInfo.value.money && Number(userInfo.value.money)) {
  112. money.value = userInfo.value.money
  113. }
  114. }
  115. const AddBank = async () => {
  116. if (!bank.value.name && !bank.value.card && !bank.value.bank) return;
  117. try {
  118. const res = await USER_BANK_ADD(bank.value);
  119. bank.value = res.data
  120. nextTick(() => {
  121. popupRef.value && popupRef.value.close();
  122. })
  123. } catch (error) {
  124. Toast(error.msg)
  125. }
  126. }
  127. const submit = async () => {
  128. if (!money.value) return Toast(t('请输入提款金额'));
  129. if (!bank.value.id) return popupRef.value && popupRef.value.open();
  130. try {
  131. const res = await USER_EXTRACT({
  132. money: money.value,
  133. bankid: bank.value.id
  134. });
  135. Toast(res.msg, 1000).then(() => {
  136. setTimeout(() => {
  137. uni.navigateTo({ url: '/pages/bank/withdraw_list' })
  138. }, 1000)
  139. })
  140. } catch (error) {
  141. Toast(error.msg
  142. )
  143. }
  144. }
  145. const getBankInfo = async () => {
  146. try {
  147. const res = await USER_BANK();
  148. if (!res.data) return;
  149. bank.value = res.data[0];
  150. } catch (error) { }
  151. }
  152. onShow(() => {
  153. useUser.getUserInfo();
  154. getBankInfo();
  155. })
  156. </script>
  157. <style lang="less" scoped>
  158. @import url('@/style.less');
  159. .wrap {
  160. min-height: 100vh;
  161. background-color: var(--bg);
  162. .nav_right {
  163. color: var(--text);
  164. .size(28rpx);
  165. margin-left: 16rpx;
  166. }
  167. .content {
  168. padding: 24rpx;
  169. .bank {
  170. padding: 16rpx 24rpx;
  171. border-radius: 16rpx;
  172. background-color: var(--light);
  173. margin-bottom: 24rpx;
  174. .bank_item {
  175. .label {
  176. color: var(--text);
  177. .size(28rpx);
  178. line-height: 50rpx;
  179. font-weight: 700;
  180. }
  181. .value {
  182. color: var(--black);
  183. font-weight: 700;
  184. .size(48rpx);
  185. line-height: 92rpx;
  186. text {
  187. .size(28rpx);
  188. margin-right: 12rpx;
  189. }
  190. }
  191. .money_value {
  192. .ver();
  193. margin-top: 16rpx;
  194. column-gap: 16rpx;
  195. /deep/ .u-input {
  196. border-radius: 16rpx;
  197. .u-input__content__field-wrapper__field {
  198. height: 38px;
  199. }
  200. }
  201. .all {
  202. color: var(--text);
  203. .size(28rpx);
  204. padding: 0 12rpx;
  205. }
  206. }
  207. }
  208. }
  209. .edit_bank {
  210. padding: 16rpx 24rpx;
  211. border-radius: 16rpx;
  212. background-color: var(--light);
  213. .flex_position(space-between);
  214. .edit_label {
  215. .size(28rpx);
  216. color: var(--text);
  217. line-height: 60rpx;
  218. }
  219. .icon-back {
  220. color: #7d8fb3;
  221. transform: rotateY(180deg);
  222. .size();
  223. }
  224. }
  225. .btn {
  226. height: 90rpx;
  227. padding: 16rpx 30rpx;
  228. .size(28rpx);
  229. border-radius: 16rpx;
  230. background-color: var(--black);
  231. color: var(--light);
  232. font-weight: 700;
  233. .flex_center();
  234. margin-top: 50rpx;
  235. }
  236. }
  237. .bank_info {
  238. width:100%;
  239. .flex();
  240. flex-direction: column;
  241. row-gap: 24rpx;
  242. .info_name,
  243. .info_bank,
  244. .info_card {
  245. .ver();
  246. .label {
  247. color: var(--text);
  248. .size(28rpx);
  249. width: 160rpx;
  250. }
  251. .value {
  252. flex: 1;
  253. /deep/ .u-input {
  254. border-radius: 16rpx;
  255. .u-input__content__field-wrapper__field {
  256. height: 38px;
  257. }
  258. }
  259. }
  260. }
  261. }
  262. .footer_btn {
  263. height: 76rpx;
  264. padding: 16rpx 30rpx;
  265. .size(28rpx);
  266. border-radius: 16rpx;
  267. background-color: var(--black);
  268. color: var(--light);
  269. font-weight: 700;
  270. .flex_center();
  271. margin-top: 50rpx;
  272. }
  273. }
  274. </style>