draw.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <template>
  2. <v-page>
  3. <v-header>
  4. <template #title>
  5. <view>
  6. <span class="color-theme-1 m-r-xs">{{ coin }}</span>
  7. {{ $t("assets.b6") }}
  8. </view>
  9. </template>
  10. </v-header>
  11. <view class="layout-main p-x-lg">
  12. <view class="coin p-md d-flex justify-between bg-panel-3 rounded-md m-y-md box-shadow">
  13. <view class="fn-lg color-light">{{ coin }}</view>
  14. <view>
  15. <!-- <van-icon name="arrow" /> -->
  16. </view>
  17. </view>
  18. <view class="form bg-panel-3 rounded-md p-x-md box-shadow">
  19. <view class="d-flex justify-between align-center p-y-xs border-b" v-if="coin == 'USDT'">
  20. <span class="color-light">{{ $t("assets.b6") }}</span>
  21. <view class="group d-flex fn-12 color-light">
  22. <!-- <view size="mini" @click="changeRechargeType(2)" :class="rechargeType == 2 ? 'bg-gradient-green' : 'bg-gray-7'" class="rounded-md color-plain m-r-sm p-x-sm p-y-xs">ERC20</view>
  23. <view size="mini" @click="changeRechargeType(1)" class="rounded-md color-plain p-x-sm m-r-sm p-y-xs" :class="rechargeType == 1 ? 'bg-gradient-green' : 'bg-gray-7'">OMNI</view>
  24. --><view size="mini" @click="changeRechargeType(3)" :class="rechargeType == 3 ? 'bg-gradient-green' : 'bg-gray-7'" class="rounded-md color-plain p-x-sm p-y-xs">TRC20</view>
  25. </view>
  26. </view>
  27. <view class="d-flex justify-between align-center p-y-xs">
  28. <span class="color-light">{{ $t("assets.b8") }}</span>
  29. <v-input v-model="form.address" class="flex-fill fn-right color-light" :placeholder="$t('assets.b9')">
  30. <template #right>
  31. <v-link tag="span" :to="{path:'/pages/assets/address-list',query:{
  32. from:'draw'
  33. }}" class="color-light fn-22">
  34. <van-icon class="m-r-xs" name="orders-o" />
  35. </v-link>
  36. </template>
  37. </v-input>
  38. </view>
  39. </view>
  40. <view class="form bg-panel-3 rounded-md p-x-md m-y-md box-shadow">
  41. <view class="d-flex align-center p-y-xs justify-between">
  42. <span class="color-light">{{ $t("assets.c0") }}</span>
  43. <span>{{ $t("assets.c1") }}:{{ withdrawFee.usable_balance }}
  44. {{ coin }}</span>
  45. </view>
  46. <view class="d-flex align-end p-y-xs justify-between">
  47. <v-input type="number" v-model="form.amount" :min="withdrawFee.withdrawal_min" :max="withdrawFee.withdrawal_max" class="w-8/12 color-light" :placeholder="$t('assets.c2')"></v-input>
  48. <view class="d-flex align-end">
  49. <span class="unit flex-shrink">{{ coin }}</span>
  50. <view class="all color-theme-1 m-l-md flex-shrink" @click="form.amount = withdrawFee.usable_balance">{{ $t("assets.c3") }}</view>
  51. </view>
  52. </view>
  53. <view class="d-flex align-center p-y-xs justify-between">
  54. <span>{{ $t("assets.c4") }}:</span>
  55. <span class="color-light">{{ withdrawFee.withdrawal_fee }}</span>
  56. </view>
  57. </view>
  58. <view class="form rounded-md p-x-md p-y-md m-y-md">
  59. <v-button class="w-max m-y-md rounded-md" block type="blue" @click="toDraw" ref="btn">{{ $t("assets.b6") }}</v-button>
  60. <ul class="bg-panel-1 p-xs fn-md rounded-md m-y-xs line-height-2">
  61. <li>·{{ $t("assets.c5") }}</li>
  62. <li>·{{ $t("assets.c6") }}</li>
  63. <li>·{{ $t("assets.c7") }}</li>
  64. </ul>
  65. </view>
  66. <view class="rounded-md m-b-lg" v-if="list.length">
  67. <view class="title d-flex justify-between p-x-md p-y-xs align-center color-light">
  68. <span class="fn-lg">{{ $t("assets.c8") }}</span>
  69. </view>
  70. <view class="p-x-md">
  71. <table class="w-max">
  72. <thead class="p-x-md">
  73. <tr class="fn-sm p-x-md">
  74. <th class="p-b-md fn-left p-l-md">{{ $t("assets.c9") }}</th>
  75. <th class="p-b-md fn-left">{{ $t("assets.d0") }}</th>
  76. <th class="p-b-md fn-right p-r-md">{{ $t("assets.c0") }}</th>
  77. <th class="p-b-md fn-right p-r-md">{{$t('exchange.g3')}}</th>
  78. </tr>
  79. </thead>
  80. <tbody>
  81. <tr class="color-light trChange p-x-md rounded-md" v-for="item in list" :key="item.id">
  82. <td class="p-y-xs p-l-md rounded-tl-sm rounded-bl-sm fn-sm">
  83. {{ $date(item.created_at)}}
  84. </td>
  85. <td>
  86. <view>{{item.status_text}}</view>
  87. </td>
  88. <td>
  89. {{ item.amount }}
  90. <span class="color-default">({{ item.coin_name }})</span>
  91. </td>
  92. <td class="fn-right p-r-md rounded-tr-sm rounded-br-sm">
  93. <v-button size="mini" v-if="item.status==0" type="danger" @click="cancelWithdraw(item)">{{$t('exchange.g4')}}</v-button>
  94. </td>
  95. </tr>
  96. <tr v-if="loadMore">
  97. <td colspan="3" class="fn-center p-xs link-active" @click="more">
  98. {{ $t("assets.d4") }}
  99. </td>
  100. </tr>
  101. </tbody>
  102. </table>
  103. </view>
  104. </view>
  105. </view>
  106. <coin-list ref="coinList" v-model="coin" @close="coinListShow = false" v-show="coinListShow" />
  107. <van-popup :show="secondaryShow" @close="secondaryShow=false" closeable close-on-popstate position="bottom" custom-style="height:40%">
  108. <van-tabs class="m-t-lg p-t-lg" v-if="secondaryShow" :sticky="false" :active="form.code_type" @change="changeTab">
  109. <van-tab title="Google" v-if="withdrawFee.google_status==1" :name="3">
  110. <v-input class="border h-40 m-y-md m-x-lg p-x-md" type="number" :placeholder="$t('common.code')" v-model="form.code"></v-input>
  111. </van-tab>
  112. <van-tab :title="$t('login.a8')" v-if="withdrawFee.phone_status==1" :name="1">
  113. <v-input class="border h-40 m-y-md m-x-lg p-x-md" type="number" :placeholder="$t('common.code')" v-model="form.code">
  114. <template #right>
  115. <v-code type="green-plain" url="/user/getCode" :data="{type:1}" ref="mobileCode"></v-code>
  116. </template>
  117. </v-input>
  118. </van-tab>
  119. <van-tab :title="$t('login.a9')" v-if="withdrawFee.email_status==1" :name="2">
  120. <v-input class="border h-40 m-y-md m-x-lg p-x-md" type="number" :placeholder="$t('common.code')" v-model="form.code">
  121. <template #right>
  122. <v-code type="green-plain" url="/user/getCode" :data="{type:2}" ref="emailCode"></v-code>
  123. </template>
  124. </v-input>
  125. <view class="m-md"></view>
  126. </van-tab>
  127. </van-tabs>
  128. <view class="m-md">
  129. <v-button type="blue" block class="w-max rounded-md" @click="draw">{{$t('common.confirm')}}</v-button>
  130. </view>
  131. </van-popup>
  132. <van-toast id="van-toast" />
  133. </v-page>
  134. </template>
  135. <script>
  136. import coinList from "./coin-list";
  137. import Wallet from "@/api/wallet";
  138. import formData from "@/utils/class/date";
  139. export default {
  140. components: {
  141. coinList,
  142. },
  143. data() {
  144. return {
  145. coinListShow: false,
  146. coin: "",
  147. rechargeType: 3,
  148. form: {
  149. coin_id: "",
  150. amount: "",
  151. address: "",
  152. addressType: "",
  153. code_type: 1,
  154. code: ''
  155. },
  156. withdrawFee: {},
  157. list: [],
  158. page: 1,
  159. loadMore: true,
  160. secondaryShow:false
  161. };
  162. },
  163. computed: {
  164. activeCoin() {
  165. if (!this.coin) return {};
  166. return this.$refs.coinList.coinList.find(
  167. (item) => item.coin_name == this.coin
  168. );
  169. },
  170. },
  171. watch: {
  172. coin(n) {
  173. if (n) {
  174. this.form.address = "";
  175. if (this.coin != "USDT") {
  176. this.rechargeType = 1;
  177. }
  178. this.withdrawalBalance();
  179. }
  180. },
  181. },
  182. filters: {
  183. parseTime(val) {
  184. let time = formData.parseTime(val)
  185. return time;
  186. },
  187. },
  188. mounted() {
  189. uni.$on('selectAddress', (e) => {
  190. this.form.address = e
  191. })
  192. },
  193. methods: {
  194. changeRechargeType(idx) {
  195. this.rechargeType = idx;
  196. this.withdrawalBalance();
  197. },
  198. // 获取提币地址
  199. withdrawalBalance() {
  200. let data = {
  201. coin_name: this.coin,
  202. };
  203. Wallet.withdrawalBalance(data).then((res) => {
  204. this.withdrawFee = res.data;
  205. });
  206. },
  207. // 发起提币
  208. toDraw() {
  209. let data = this.withdrawFee
  210. if(!this.form.address){
  211. return this.$toast(this.$t('assets.b9'))
  212. }
  213. if(!this.form.amount){
  214. return this.$toast(this.$t('assets.c2'))
  215. }
  216. if (data.withdraw_switch == 1) {
  217. this.secondaryShow = true
  218. if (data.google_status == 1) {
  219. this.form.code_type = 3;
  220. } else if (data.phone_status == 1) {
  221. this.form.code_type = 1;
  222. this.$nextTick(() => {
  223. this.$refs.mobileCode.send();
  224. });
  225. } else if (data.email_status == 1) {
  226. this.form.code_type = 2;
  227. this.$nextTick(() => {
  228. this.$refs.emailCode.send();
  229. });
  230. }
  231. } else {
  232. this.draw()
  233. }
  234. },
  235. draw() {
  236. this.form.addressType = this.rechargeType;
  237. this.form.coin_id = this.activeCoin.coin_id;
  238. Wallet.withdraw(this.form, { btn: this.$refs.btn })
  239. .then(() => {
  240. this.$toast.success(this.$t("assets.d5") + "!");
  241. this.$back();
  242. })
  243. .catch(() => { });
  244. },
  245. reset() {
  246. this.loadMore = true;
  247. this.page = 1;
  248. this.getWithdrawRecords();
  249. },
  250. more() {
  251. this.page++;
  252. this.getWithdrawRecords();
  253. },
  254. // 获取提币记录
  255. getWithdrawRecords() {
  256. let data = {
  257. page: this.page,
  258. };
  259. Wallet.withdrawalRecord(data).then((res) => {
  260. if (res.data.current_page == 1) this.list = [];
  261. this.list = [...this.list, ...res.data.data];
  262. if (res.data.data.length < res.data.per_page) this.loadMore = false;
  263. });
  264. },
  265. // 撤销订单
  266. cancelWithdraw(item) {
  267. Wallet.cancelWithdraw({ withdraw_id: item.id }).then(() => {
  268. this.$toast(this.$t('exchange.g6'))
  269. this.reset();
  270. })
  271. },
  272. changeTab(ev) {
  273. this.form.code_type = ev.detail.name
  274. },
  275. },
  276. created() {
  277. this.getWithdrawRecords();
  278. },
  279. };
  280. </script>
  281. <style lang="scss" scoped>
  282. .trChange:nth-child(2n-1) {
  283. box-shadow: $shadow;
  284. border-radius: $border-radius-xs;
  285. td {
  286. background: $panel-3;
  287. padding-top: $padding-sm;
  288. padding-bottom: $padding-sm;
  289. }
  290. }
  291. </style>