Wallet.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. <template>
  2. <div class="wallet-page">
  3. <div class="wallet-list flex-between">
  4. <div class="gradient flex-center-between li" v-for="(item, index) in 2" :key="index">
  5. <div class="wallet-list-li-left">
  6. <div class="">{{ index == 0 ? $t('common.mibi') : $t('common.baomibi') }} {{ $t('personalCenter.yue') }}</div>
  7. <div class="">{{ index == 0 ? appStore?.userInfo?.pointsBalance || 0 || 0 : appStore?.userInfo?.baoMiBalance
  8. || 0 }}</div>
  9. </div>
  10. <div class="wallet-list-li-right flex-align-center">
  11. <div @click="show = true" class="flex-align-center btn" v-if="index == 1">
  12. <img src="/src/assets/imgs/my/tixian@2x.png" alt="">
  13. <div class="">{{ $t('personalCenter.shenqingtixian') }}</div>
  14. </div>
  15. <div @click="changeTransformation(index)" class="flex-align-center btn">
  16. <img src="/src/assets/imgs/my/zhuanhuan@2x.png" alt="">
  17. <div class="">{{ index == 0 ? $t('personalCenter.zhuanhuanbaomibi') : $t('personalCenter.zhuanghuanmibi') }}
  18. </div>
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. <el-tabs v-model="form.changeType" class="demo-tabs" @tab-click="handleClick">
  24. <el-tab-pane :label="$t(tab.label)" v-for="tab in tabs" :key="tab.name" :name="tab.name">
  25. <div class="tabs flex-align-center" v-if="form.changeType != 3">
  26. <div @click="changeType(index)" :class="{ active: index + 1 == form.balanceType }" class="tab"
  27. v-for="(item, index) in 2">{{
  28. index == 0 ? $t('common.mibi') : $t('common.baomibi') }}{{ $t('personalCenter.details') }}
  29. </div>
  30. </div>
  31. <template v-if="form.changeType == 3">
  32. <div class="wallet-page-list">
  33. <div class="lis" v-for="(item, index) in list" :key="index">
  34. <div class="flex-center-between">
  35. <el-tag
  36. :type="item.applyStatus == 0 ? 'primary' : item.applyStatus == 1 ? 'success' : item.applyStatus == 2 ? 'danger' : ''">{{
  37. item.applyStatus == 0 ? '待审核' : item.applyStatus == 1 ? '已通过' : '未通过' }}</el-tag>
  38. <div class="price">¥{{ item.applyAmount }}</div>
  39. </div>
  40. <div class="flex-center-between">
  41. <div class="">订单号:{{ item.applyNo }}</div>
  42. <div class="">手续费:{{ item.feeAmount }}</div>
  43. </div>
  44. <div class="flex-center-between">
  45. <div class="">提现方式:{{ item.settleType == 'alipay' ? '支付宝' : item.settleType == 'wechat' ? '微信' : '银行卡'
  46. }}</div>
  47. <div class="">提现账号:{{ item.receiveAccount }}</div>
  48. </div>
  49. <div class="flex-center-between">
  50. <div class="">申请时间:{{ item.createTime }}</div>
  51. <el-text v-if=" item.applyStatus == 2" class="mx-1" type="danger">拒绝理由:{{ item.auditRemark }}</el-text>
  52. </div>
  53. </div>
  54. </div>
  55. </template>
  56. <template v-else>
  57. <div class="wallet-page-list" v-if="list?.length">
  58. <div v-for="(item, index) in list" :key="index" class="li">
  59. <div class="title">
  60. <div class="">{{ item.bizTypeName }}</div>
  61. <div class="">{{ item.createTime }}</div>
  62. </div>
  63. <div class="price" :class="{ green: form.changeType == 1 }">{{ form.changeType == 1 ? '+' : '' }}{{
  64. item.balanceChange }}</div>
  65. </div>
  66. </div>
  67. </template>
  68. </el-tab-pane>
  69. </el-tabs>
  70. <template v-if="list?.length">
  71. <Pagination :total="form.total" :page-size="form.pageSize" :current-page="form.pageNum"
  72. @page-change="handlePageChange" />
  73. </template>
  74. <el-empty v-else :description="$t('common.empty')" />
  75. <el-dialog v-model="dialogVisible"
  76. :title="`${transformationIndex == 0 ? $t('personalCenter.zhuanhuanbaomibi') : $t('personalCenter.zhuanghuanmibi')}`"
  77. width="523">
  78. <el-form :model="walletForm" label-width="auto" label-position="top" :rules="rules" ref="ruleFormRefs">
  79. <el-row>
  80. <el-col :span="24">
  81. <div class="input">
  82. <el-form-item :label="$t('common.use') + $t('common.baomibi')" v-if="transformationIndex" prop="orderAmt">
  83. <el-input-number v-model="walletForm.orderAmt" :min="1" :max="appStore?.userInfo?.baoMiBalance"
  84. controls-position="right" size="large" @change="handleChange" style="width: 100%;"
  85. :placeholder="$t('common.placeholderInput')" align="left" :input-style="{ fontSize: '28px' }"
  86. class="inputStyle" />
  87. </el-form-item>
  88. <el-form-item :label="$t('common.use') + $t('common.mibi')" v-else prop="orderAmt">
  89. <el-input-number v-model="walletForm.orderAmt" :min="Number(configTxt.configValue)"
  90. :max="appStore?.userInfo?.pointsBalance" :step="Number(configTxt.configValue)"
  91. controls-position="right" size="large" @change="handleChange" style="width: 100%;"
  92. :placeholder="$t('common.placeholderInput')" align="left" :input-style="{ fontSize: '28px' }"
  93. class="inputStyle" />
  94. </el-form-item>
  95. </div>
  96. </el-col>
  97. </el-row>
  98. <div class="line">
  99. <img src="/src/assets/imgs/my/arrow-left-right-fill@2x.png" alt="">
  100. </div>
  101. <el-row>
  102. <el-col :span="24">
  103. <div class="input">
  104. <el-form-item v-if="transformationIndex"
  105. :label="$t('common.available') + $t('common.mibi') + `(手续费率:${walletForm.feeRate})`">
  106. <el-input v-model="walletForm.targetAmount" :placeholder="$t('common.placeholderInput')" readonly
  107. disabled :input-style="{ fontSize: '28px' }" class="inputStyle" />
  108. </el-form-item>
  109. <el-form-item v-else :label="$t('common.available') + $t('common.baomibi')">
  110. <el-input v-model="walletForm.targetAmount" :placeholder="$t('common.placeholderInput')" readonly
  111. disabled :input-style="{ fontSize: '28px' }" class="inputStyle" />
  112. </el-form-item>
  113. </div>
  114. </el-col>
  115. </el-row>
  116. <div class="" style="font-size: 14px;margin-top: 16px;"> <text style="color: #E43434;">*</text> {{
  117. configTxt.configName }}{{ configTxt.configValue }}</div>
  118. </el-form>
  119. <template #footer>
  120. <div class="dialog-footer flex-center">
  121. <el-button @click="dialogVisible = false">{{ $t('common.cancel') }}</el-button>
  122. <el-button class="gradient" type="primary" @click="confirmTransformation(ruleFormRefs)">
  123. {{ $t('common.confirm') }}
  124. </el-button>
  125. </div>
  126. </template>
  127. </el-dialog>
  128. <el-dialog v-model="show" :title="$t('personalCenter.shenqingtixian')" width="500">
  129. <el-form ref="ruleFormRef" :model="ruleForm" :rules="rules" label-width="auto">
  130. <el-row>
  131. <el-col :span="24">
  132. <el-form-item label="提现金额" prop="applyAmount">
  133. <el-input type="number" :min="1" :max="appStore?.userInfo?.baoMiBalance" v-model="ruleForm.applyAmount"
  134. :placeholder="$t('common.placeholderInput')" />
  135. </el-form-item>
  136. </el-col>
  137. </el-row>
  138. <el-row>
  139. <el-col :span="24">
  140. <el-form-item label="提现方式" prop="settleType">
  141. <el-select v-model="ruleForm.settleType" placeholder="Select" style="width: 100%">
  142. <el-option label="支付宝" value="alipay" />
  143. <el-option label="银行卡" value="bank_card" />
  144. </el-select>
  145. </el-form-item>
  146. </el-col>
  147. </el-row>
  148. <el-row>
  149. <el-col :span="24">
  150. <el-form-item label="姓名" prop="withdrawPerson">
  151. <el-input v-model="ruleForm.withdrawPerson" :placeholder="$t('common.placeholderInput')" />
  152. </el-form-item>
  153. </el-col>
  154. </el-row>
  155. <el-row>
  156. <el-col :span="24">
  157. <el-form-item label="账号" prop="receiveAccount">
  158. <el-input v-model="ruleForm.receiveAccount" :placeholder="$t('common.placeholderInput')" />
  159. </el-form-item>
  160. </el-col>
  161. </el-row>
  162. </el-form>
  163. <template #footer>
  164. <div class="dialog-footer flex-center">
  165. <el-button @click="show = false">{{ $t('common.cancel') }}</el-button>
  166. <el-button class="gradient" type="primary" @click="submitForm(ruleFormRef)">{{
  167. $t('common.confirm') }}</el-button>
  168. </div>
  169. </template>
  170. </el-dialog>
  171. </div>
  172. </template>
  173. <script lang="ts" setup>
  174. import { ref, onMounted } from 'vue'
  175. import type { TabsPaneContext } from 'element-plus'
  176. import Pagination from '@/components/Pagination.vue'
  177. import { getUserInfo } from '@/api/auth'
  178. import { payConfigDearch, calRate } from '@/api/order'
  179. import { recordList, applyWithdraw, withdrawList } from '@/api/my'
  180. import { createOrder } from '@/api/order.js'
  181. import { useAppStore } from '@/pinia/appStore'
  182. import DGTMessage from '@/utils/message'
  183. import { useI18n } from 'vue-i18n'
  184. const { t } = useI18n()
  185. const appStore = useAppStore();
  186. const tabs = ref([
  187. { label: 'personalCenter.incomeDetails', name: 1 },
  188. { label: 'personalCenter.usageRecord', name: 2 },
  189. { label: 'personalCenter.withdrawHistory', name: 3 },
  190. ])
  191. const list = ref([])
  192. const form = ref({
  193. pageNum: 1,
  194. pageSize: 10,
  195. total: 0,
  196. balanceType: 1,//1-米币 2-暴米币
  197. changeType: 1,//1-增加 2-减少
  198. orderByColumn: 'create_time',
  199. isAsc: 'desc'
  200. })
  201. const walletForm = ref({
  202. payMethod: '',
  203. orderType: '',
  204. productId: '',
  205. orderNum: null,
  206. orderAmt: 1,
  207. feeRate: 0,
  208. targetAmount: 0
  209. })
  210. const ruleFormRef = ref()
  211. const configTxt = ref({})
  212. const userInfo = ref({})//用户信息
  213. const dialogVisible = ref(false);
  214. const transformationIndex = ref(0);
  215. const show = ref(false);
  216. const ruleForm = ref({
  217. applyAmount: null,
  218. settleType: "alipay",
  219. withdrawPerson: "",
  220. receiveAccount: ""
  221. })
  222. const ruleFormRefs = ref()
  223. const validatePass = (rule: any, value: any, callback: any) => {
  224. if (!value) {
  225. callback(new Error(t('common.placeholderInput')))
  226. } else if (Number(value) % Number(configTxt.value.configValue) !== 0 && transformationIndex.value == 0) {
  227. callback(new Error(`米币数量必须为${configTxt.value.configValue}的整倍数`))
  228. } else {
  229. callback()
  230. }
  231. }
  232. const validatePass1 = (rule: any, value: any, callback: any) => {
  233. if (!value) {
  234. callback(new Error(t('common.placeholderInput')))
  235. return
  236. } else if (Number(value) > appStore.userInfo.baoMiBalance) {
  237. callback(new Error(`余额不足`))
  238. } else {
  239. callback()
  240. }
  241. }
  242. const rules = ref({
  243. applyAmount: [
  244. { required: true, validator: validatePass1, trigger: 'blur' }
  245. ],
  246. settleType: [
  247. { required: true, message: t('common.qingxuanze'), trigger: 'blur' }
  248. ],
  249. withdrawPerson: [
  250. { required: true, message: t('common.placeholderInput'), trigger: 'blur' }
  251. ],
  252. receiveAccount: [
  253. { required: true, message: t('common.placeholderInput'), trigger: 'blur' }
  254. ],
  255. orderAmt: [
  256. { required: true, trigger: 'blur', validator: validatePass },
  257. ],
  258. })
  259. const submitForm = async (formEl) => {
  260. console.log(formEl)
  261. if (!formEl) return
  262. await formEl.validate(async (valid, fields) => {
  263. if (valid) {
  264. let res = await applyWithdraw(ruleForm.value);
  265. if (res.code === 200) {
  266. show.value = false;
  267. appStore.USERINFO();
  268. getList()
  269. DGTMessage.success(t('common.success'));
  270. }
  271. }
  272. })
  273. }
  274. // 确认转换
  275. const confirmTransformation = async (formEl) => {
  276. if (!formEl) return
  277. await formEl.validate(async (valid, fields) => {
  278. if (valid) {
  279. let res = await createOrder({
  280. payMethod: walletForm.value.payMethod,
  281. orderType: walletForm.value.orderType,
  282. productId: '',
  283. orderNum: walletForm.value.targetAmount,
  284. orderAmt: walletForm.value.orderAmt
  285. })
  286. if (res.code === 200) {
  287. if (res.data.paySuccess) {
  288. dialogVisible.value = false;
  289. appStore.USERINFO();
  290. DGTMessage.success(`${transformationIndex.value ? t('personalCenter.zhuanhuanbaomibi') : t('personalCenter.zhuanghuanmibi')}${t('common.success')}`)
  291. }
  292. }
  293. }
  294. })
  295. }
  296. // 米币暴米币转换
  297. const changeTransformation = async (index: any) => {
  298. transformationIndex.value = index;
  299. walletForm.value.payMethod = index ? 'BMI' : 'MI';
  300. walletForm.value.orderType = index ? 'exchange_mi' : 'exchange_bmi';
  301. let { data } = await payConfigDearch({ id: '03' });
  302. let result = data.filter((item: any) => item.configCode == 'bmb_to_mb_rate')
  303. if (result.length) {
  304. configTxt.value = result[0]
  305. }
  306. walletForm.value.orderAmt = index == 0 ? Number(configTxt.value.configValue) : 1
  307. handleChange()
  308. dialogVisible.value = true;
  309. }
  310. const handleChange = async () => {
  311. if (walletForm.value.orderAmt) {
  312. if (transformationIndex.value == 0 && Number(walletForm.value.orderAmt) % Number(configTxt.value.configValue) !== 0) return
  313. let res = await calRate({
  314. orderType: walletForm.value.orderType,
  315. orderNum: walletForm.value.orderAmt
  316. });
  317. if (res.code === 200) {
  318. walletForm.value.feeRate = res.data.feeRate
  319. walletForm.value.targetAmount = res.data.targetAmount
  320. }
  321. }
  322. }
  323. // 米币暴米币切换
  324. const changeType = (index) => {
  325. form.value.pageNum = 1;
  326. form.value.balanceType = index + 1;
  327. getList()
  328. }
  329. const handleClick = (tab: TabsPaneContext) => {
  330. form.value.pageNum = 1;
  331. form.value.changeType = tab.props.name;
  332. getList()
  333. }
  334. const getList = async () => {
  335. let api = form.value.changeType == 3 ? withdrawList(form.value) : recordList(form.value)
  336. let res = await api;
  337. list.value = res.rows;
  338. form.value.total = res.total;
  339. }
  340. const handlePageChange = (newPage: number) => {
  341. // list.value = []
  342. form.value.pageNum = page;
  343. getList()
  344. }
  345. // 获取用户信息
  346. const getInfo = async () => {
  347. let res = await getUserInfo();
  348. userInfo.value = res.user;
  349. }
  350. onMounted(() => {
  351. getInfo()
  352. getList()
  353. })
  354. </script>
  355. <style scoped lang="scss">
  356. .wallet-page {
  357. padding-bottom: 16px;
  358. .tabs {
  359. margin-bottom: 16px;
  360. .tab {
  361. cursor: pointer;
  362. color: #2D71FF;
  363. padding: 0 12px;
  364. line-height: 30px;
  365. font-size: 14px;
  366. background: #EAF0FF;
  367. border-radius: 4px;
  368. margin-right: 16px;
  369. }
  370. .active {
  371. color: #FFFFFF;
  372. background: linear-gradient(90deg, #0055FE 0%, #C832FA 100%);
  373. }
  374. }
  375. .wallet-list {
  376. gap: 16px;
  377. padding: 16px;
  378. .li {
  379. flex: 1;
  380. padding: 16px;
  381. border-radius: 16px;
  382. .wallet-list-li-left {
  383. div {
  384. color: #FFFFFF;
  385. font-size: 14px;
  386. line-height: 1;
  387. &:last-child {
  388. margin-top: 8px;
  389. font-size: 32px;
  390. font-weight: bold;
  391. }
  392. }
  393. }
  394. .wallet-list-li-right {
  395. .btn {
  396. cursor: pointer;
  397. margin-left: 8px;
  398. color: #2D71FF;
  399. font-size: 14px;
  400. padding: 0 20px;
  401. height: 40px;
  402. background: #FFFFFF;
  403. border-radius: 10px;
  404. img {
  405. width: 16px;
  406. height: 16px;
  407. margin-right: 4px;
  408. }
  409. &:hover {
  410. opacity: 0.7;
  411. }
  412. }
  413. }
  414. }
  415. }
  416. }
  417. .wallet-page-list {
  418. .li {
  419. display: flex;
  420. align-items: center;
  421. justify-content: space-between;
  422. padding: 16px;
  423. border-radius: 16px;
  424. background: #F5F7FA;
  425. margin-bottom: 16px;
  426. &:last-child {
  427. margin-bottom: 0;
  428. }
  429. .title {
  430. div {
  431. font-size: 16px;
  432. line-height: 1;
  433. &:last-child {
  434. margin-top: 8px;
  435. color: #666666;
  436. font-size: 14px;
  437. }
  438. }
  439. }
  440. }
  441. .price {
  442. font-size: 16px;
  443. font-weight: bold;
  444. color: #F52929;
  445. }
  446. .green {
  447. color: #1FB362;
  448. }
  449. .lis {
  450. padding: 16px;
  451. border-radius: 16px;
  452. background: #F5F7FA;
  453. margin-bottom: 16px;
  454. &:last-child {
  455. margin-bottom: 0;
  456. }
  457. }
  458. }
  459. .input {
  460. padding: 16px;
  461. background: #F5F7FA;
  462. border-radius: 16px;
  463. }
  464. .line {
  465. height: 16px;
  466. position: relative;
  467. img {
  468. top: 50%;
  469. width: 40px;
  470. height: 40px;
  471. left: 50%;
  472. z-index: 9;
  473. transform: translate(-50%, -50%);
  474. position: absolute;
  475. }
  476. }
  477. .inputStyle {
  478. :deep(.el-input__wrapper) {
  479. background-color: transparent;
  480. box-shadow: none !important;
  481. padding: 0;
  482. }
  483. :deep(.el-input__inner) {
  484. font-size: 28px;
  485. }
  486. :deep(.el-input-number__increase),
  487. :deep(.el-input-number__decrease) {
  488. display: none;
  489. }
  490. }
  491. </style>