Mention.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <div class="vh100">
  3. <!-- 导航栏 -->
  4. <div class="nav-bar">
  5. <div class="back-btn" @click="$router.back()">
  6. <i class="arrow-left"></i>
  7. </div>
  8. <div class="title">提现</div>
  9. </div>
  10. <div style="width: 95%; margin: 0 auto;">
  11. <div style="margin-top: 20px;">温馨提示</div>
  12. <div style="margin-top: 10px;">所有提现经国务院批准,由中央财政部联合拨款支出,用于帮扶人民群众救助贫困家庭,全程无需任何的费用</div>
  13. </div>
  14. <div class="ptb20 bgPart plr20">
  15. <div class="bd_input ptb10 plr10 tc flex1 radius4">
  16. <div class="flex between">
  17. <span>当前币种</span>
  18. <span>人民币</span>
  19. </div>
  20. </div>
  21. <div class="ft18"></div>
  22. <div class="mt10">可用 {{ availableBalance }}元</div>
  23. <div class="mt10">提现最小 {{ minWithdrawAmount }}元</div>
  24. <div class="mt10">预计到账 {{ amount || '0.00' }}元</div>
  25. </div>
  26. <div class="plr20">
  27. <div class="mb20">
  28. <div>提现金额</div>
  29. <div class="flex alcenter between bdb1f">
  30. <input
  31. type="number"
  32. class="h40 flex1 input-uni"
  33. placeholder="最低提现金额20"
  34. v-model="amount"
  35. pattern="[0-9]*"
  36. >
  37. <div class="flex alcenter">
  38. <span class="blue ft14 pr10 bdr_white50">元</span>
  39. <div class="pl10" @click="setMaxAmount">全部</div>
  40. </div>
  41. </div>
  42. </div>
  43. <div class="mb20">
  44. <div>登录密码</div>
  45. <div class="flex alcenter between bdb1f h40">
  46. <input
  47. :type="showPassword ? 'text' : 'password'"
  48. class="h40 flex1 input-uni"
  49. placeholder="请输入登录密码"
  50. v-model="password"
  51. >
  52. <img
  53. :src="require(`@/assets/${showPassword ? 'eye-open.png' : 'eye-close.png'}`)"
  54. class="eye-icon"
  55. @click="togglePassword"
  56. >
  57. </div>
  58. </div>
  59. <div
  60. class="mt40 bgBlue radius4 ptb10 white ft14 tc mb10 withdraw-btn"
  61. @click="handleWithdraw"
  62. >
  63. 提现
  64. </div>
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. import { getUserInfo } from '@/api/home';
  70. import { withdrawCoin } from '@/api/profile';
  71. export default {
  72. name: 'Mention',
  73. data() {
  74. return {
  75. userInfo: {},
  76. amount: '',
  77. password: '',
  78. showPassword: false,
  79. type: ''
  80. }
  81. },
  82. computed: {
  83. minWithdrawAmount() {
  84. switch(this.type) {
  85. case '1':
  86. return 10000;
  87. case '2':
  88. return 10000;
  89. default:
  90. return 20;
  91. }
  92. },
  93. availableBalance() {
  94. switch(this.type) {
  95. case '1':
  96. return this.userInfo.coins || 0;
  97. case '2':
  98. return this.userInfo.money || 0;
  99. default:
  100. return this.userInfo.dayred || 0;
  101. }
  102. }
  103. },
  104. created() {
  105. this.type = this.$route.query.type || '';
  106. this.getUserInfo();
  107. },
  108. methods: {
  109. async getUserInfo() {
  110. try {
  111. const res = await getUserInfo();
  112. this.userInfo = res.data;
  113. } catch (error) {
  114. console.error('获取用户信息失败:', error);
  115. }
  116. },
  117. setMaxAmount() {
  118. this.amount = this.availableBalance;
  119. },
  120. togglePassword() {
  121. this.showPassword = !this.showPassword;
  122. },
  123. async handleWithdraw() {
  124. if (!this.amount) {
  125. alert('请输入提现金额');
  126. return;
  127. }
  128. if (this.amount < this.minWithdrawAmount) {
  129. alert(`提现金额不能小于${this.minWithdrawAmount}元`);
  130. return;
  131. }
  132. if (!this.password) {
  133. alert('请输入登录密码');
  134. return;
  135. }
  136. try {
  137. const params = {
  138. type: this.type || '3',
  139. price: this.amount,
  140. payPwd: this.password
  141. };
  142. let res = await withdrawCoin(params);
  143. if(res.code == 1){
  144. alert('提现申请已提交')
  145. }else{
  146. alert(res.msg)
  147. }
  148. // 刷新用户信息
  149. await this.getUserInfo();
  150. } catch (error) {
  151. console.error('提现失败:', error);
  152. alert('提现失败,请重试');
  153. }
  154. }
  155. }
  156. }
  157. </script>
  158. <style scoped>
  159. .vh100 {
  160. min-height: 100vh;
  161. background:#fff;
  162. background-size: 100% 100%;
  163. background-position: 0 0;
  164. background-repeat: no-repeat;
  165. }
  166. .nav-bar {
  167. height: 44px;
  168. background-color: #ed4b39;
  169. color: #fff;
  170. display: flex;
  171. align-items: center;
  172. position: relative;
  173. padding: 0 15px;
  174. }
  175. .back-btn {
  176. width: 24px;
  177. height: 44px;
  178. display: flex;
  179. align-items: center;
  180. cursor: pointer;
  181. }
  182. .arrow-left {
  183. width: 12px;
  184. height: 12px;
  185. border-left: 2px solid #fff;
  186. border-bottom: 2px solid #fff;
  187. transform: rotate(45deg);
  188. }
  189. .title {
  190. position: absolute;
  191. left: 50%;
  192. transform: translateX(-50%);
  193. font-size: 16px;
  194. font-weight: 500;
  195. }
  196. .ptb20 { padding: 20px 0; }
  197. .plr20 { padding: 0 20px; }
  198. .ptb10 { padding: 10px 0; }
  199. .plr10 { padding: 0 10px; }
  200. .mt10 { margin-top: 10px; }
  201. .mt40 { margin-top: 40px; }
  202. .mb20 { margin-bottom: 20px; }
  203. .mb10 { margin-bottom: 10px; }
  204. .pr10 { padding-right: 10px; }
  205. .pl10 { padding-left: 10px; }
  206. .bgPart {
  207. background: rgba(255, 255, 255, 0.9);
  208. border-radius: 8px;
  209. margin :15px 0 ;
  210. }
  211. .bd_input {
  212. background: #fff;
  213. border: 1px solid #eee;
  214. }
  215. .flex { display: flex; }
  216. .between { justify-content: space-between;padding: 10px; }
  217. .alcenter { align-items: center; }
  218. .tc { text-align: center; }
  219. .flex1 { flex: 1; }
  220. .radius4 { border-radius: 4px; }
  221. .ft18 { font-size: 18px; }
  222. .ft14 { font-size: 14px; }
  223. .blue { color: #ed4b39; }
  224. .white { color: #fff; }
  225. .bdb1f {
  226. border-bottom: 1px solid #f5f5f5;
  227. }
  228. .bdr_white50 {
  229. border-right: 1px solid rgba(255,255,255,0.5);
  230. }
  231. .h40 {
  232. height: 40px;
  233. line-height: 40px;
  234. }
  235. .input-uni {
  236. border: none;
  237. outline: none;
  238. background: transparent;
  239. width: 100%;
  240. padding: 0 10px;
  241. }
  242. .eye-icon {
  243. width: 20px;
  244. height: 20px;
  245. cursor: pointer;
  246. }
  247. .bgBlue {
  248. background: #ed4b39;
  249. cursor: pointer;
  250. }
  251. .withdraw-btn:active {
  252. opacity: 0.9;
  253. }
  254. </style>