投屏pc端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

397 lines
11 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. <template>
  2. <div class="global-width">
  3. <div class="container">
  4. <!--当前位置-->
  5. <div class="hc-breadcrumb">
  6. <span class="hc-color4" @click="goBack">{{$route.params.type == 1 ? $t('币币账户') : $t('法币账户')}}</span>
  7. <i class="hc-breadcrumb-icon"></i>
  8. <span class="margin0">{{$t('划转')}}</span>
  9. </div>
  10. <div class="hc-breadcrumb second-position">
  11. <span class="hc-color1">
  12. <img src="../../assets/images/icon-money.png" />{{transferCoin}} {{$t('划转')}}
  13. </span>
  14. </div>
  15. <div class="recharge-warp">
  16. <div class="withdrawmoney-box">
  17. <div class="form-box">
  18. <div class="form-group">
  19. <label class="form-label">{{$t('选择划转币种')}}</label>
  20. <div class="form-control">
  21. <div class="hc-form-warp" @click="showCoin = !showCoin" v-if="transferCoin">
  22. <img class="hc-select-img" :src="'data:img/jpg;base64,' + transferCoinImg" v-if="transferCoinImg">
  23. <span class="hc-select-span1">{{transferCoin}}</span>
  24. <span class="hc-form-down-icon">
  25. <i class="fa-caret-down"></i>
  26. </span>
  27. </div>
  28. <div class="hc-form-warp" @click="showCoin = !showCoin" v-else>
  29. <span class="hc-select-span1">{{$t('选择划转币种')}}</span>
  30. <span class="hc-form-down-icon">
  31. <i class="fa-caret-down"></i>
  32. </span>
  33. </div>
  34. <!-- 选择币种弹框 -->
  35. <div class="choose-currencies" v-if="showCoin">
  36. <div class="hc-select-options" v-for="item of allCoinList" :key="item.id" @click="chooseCoin(item)">
  37. <img class="hc-select-img" :src="'data:img/jpg;base64,' + item.image" v-if="item.image">
  38. <span class="hc-select-span1">{{item.id}}</span>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. <div class="form-group">
  44. <label class="form-label">
  45. {{$t('划转方向')}}
  46. </label>
  47. <div class="address-form-div2">
  48. <div class="form-control">
  49. <el-input class="text-input" v-model="transferFrom" type="text" readonly>
  50. </el-input>
  51. </div>
  52. </div>
  53. <div class="address-form-div4" @click="changeType">
  54. <img src="../../assets/images/trade/icon-equal.png">
  55. </div>
  56. <div class="address-form-div2">
  57. <div class="form-control">
  58. <el-input class="text-input" v-model="transferTo" type="text" readonly>
  59. </el-input>
  60. </div>
  61. </div>
  62. </div>
  63. <div class="form-group">
  64. <label class="form-label">
  65. {{$t('划转数量')}}
  66. <span class="hc-color3">( {{$t('可用')}}:{{account}} )</span>
  67. </label>
  68. <div class="form-control">
  69. <el-input class="text-input" :placeholder="$t('请输入划转数量')" v-model="amount" type="text" clearable autocomplete="off" @keyup.enter.native="submit">
  70. </el-input>
  71. </div>
  72. </div>
  73. <div class="form-group">
  74. <div class="address-form-div2">
  75. <label class="form-label">{{$t('到账数量')}}</label>
  76. <div class="form-control">
  77. <input type="text" class="text-input" :value="summary" readonly>
  78. </div>
  79. </div>
  80. <div class="address-form-div3">
  81. <label class="form-label">{{$t('支付密码')}}</label>
  82. <div class="form-control">
  83. <el-input class="text-input" :placeholder="$t('请输入支付密码')" v-model="password" type="password" clearable autocomplete="off" @keyup.enter.native="submit">
  84. </el-input>
  85. </div>
  86. </div>
  87. </div>
  88. <div class="form-group">
  89. <el-button class="form-submit-btn" type="primary" :loading="true" v-if="loading">{{$t('提交中...')}}</el-button>
  90. <el-button class="form-submit-btn" type="primary" @click="submit" v-else>{{$t('确认划转')}}</el-button>
  91. </div>
  92. </div>
  93. </div>
  94. <div class="address-line"></div>
  95. <div class="recharge-reminder">
  96. <div class="recharge-r-top">
  97. <i class="fa-exclamation"></i>
  98. <span>{{$t('温馨提示')}}</span>
  99. </div>
  100. <p>{{$t('1. 最小划转数量为:')}}{{minVolumn}}{{transferCoin}}{{$t(',最大划转数量为:')}}{{maxVolumn}}{{transferCoin}}</p>
  101. <p>{{$t('2. 请务必确认电脑及浏览器安全,防止信息被篡改或泄露。')}}</p>
  102. </div>
  103. <div class="address-line"></div>
  104. <div class="address-bot">
  105. <div class="address-div1">
  106. <div class="address-div2">{{$t('划转记录')}}</div>
  107. <!-- <span class="hc-breadcrumb-r">{{$t('查看更多')}}</span> -->
  108. </div>
  109. <table class="table">
  110. <thead>
  111. <tr>
  112. <th>
  113. <div class="cell">{{$t('时间')}}</div>
  114. </th>
  115. <th>
  116. <div class="cell">{{$t('币种')}}</div>
  117. </th>
  118. <th>
  119. <div class="cell">{{$t('数量')}}</div>
  120. </th>
  121. <th>
  122. <div class="cell">{{$t('类型')}}</div>
  123. </th>
  124. <th>
  125. <div class="cell">{{$t('备注')}}</div>
  126. </th>
  127. </tr>
  128. </thead>
  129. <tbody>
  130. <tr v-for="item of recordsList" :key="item.id">
  131. <td>
  132. <div class="cell">{{item.createDatetime | dateFormat('YYYY-MM-DD hh:mm:ss')}}</div>
  133. </td>
  134. <td>
  135. <div class="cell">{{item.coinId}}</div>
  136. </td>
  137. <td>
  138. <div class="cell">{{item.amount}}</div>
  139. </td>
  140. <td>
  141. <div class="cell">{{$t('划转')}}</div>
  142. </td>
  143. <td>
  144. <div class="cell">{{item.remark}}</div>
  145. </td>
  146. </tr>
  147. </tbody>
  148. </table>
  149. <no-content :isText="$t('暂无数据')" :isContent="isContent"></no-content>
  150. <el-pagination class="list-pages" background layout="prev, pager, next" v-show="!isContent" :page-count="pageTotal" :current-page="currentPage" @next-click="pagesChange" @prev-click="pagesChange" @current-change="pagesChange"></el-pagination>
  151. </div>
  152. </div>
  153. </div>
  154. </div>
  155. </template>
  156. <script>
  157. import { mapState } from 'vuex'
  158. import noContent from '@/components/no_content'
  159. export default {
  160. name: 'withdraw',
  161. components: {
  162. noContent,
  163. },
  164. data() {
  165. return {
  166. transferCoin: '', //划转币种
  167. showCoin: false, //选择币种弹窗
  168. assetsCaseCode: 'COIN_TO_COIN', //划转转出
  169. targetAssetsCaseCode: 'F_COIN', //划转转入
  170. amount: '', //划转数量
  171. password: '', //支付密码
  172. account: 0, //余额
  173. fee: 0, //提币手续费
  174. minFee: 0, //最低手续费
  175. minVolumn: 0, //最小提币数量
  176. maxVolumn: 0, //最大提币数量
  177. loading: false,
  178. recordsList: [], //划转记录
  179. isContent: false,
  180. pageTotal: 0, //总页数
  181. currentPage: 1, //默认当前页
  182. }
  183. },
  184. computed: {
  185. ...mapState('trend', ['allCoinList']),
  186. transferCoinImg() { //币种的图片
  187. let img;
  188. this.allCoinList.forEach(item => {
  189. if (item.id == this.transferCoin) {
  190. img = item.image;
  191. }
  192. })
  193. return img;
  194. },
  195. transferFrom() {
  196. let text;
  197. text = this.assetsCaseCode == 'COIN_TO_COIN' ? this.$t('币币账户') : this.$t('法币账户');
  198. return text;
  199. },
  200. transferTo() {
  201. let text;
  202. text = this.targetAssetsCaseCode == 'COIN_TO_COIN' ? this.$t('币币账户') : this.$t('法币账户');
  203. return text;
  204. },
  205. summary() { //实际扣除数量
  206. let value = 0;
  207. let remainder = this.common.accAdd(1, this.fee);
  208. if(this.amount > 0) {
  209. if(this.common.accMul(this.fee, this.amount) < this.minFee) { //最低手续费
  210. value = this.common.accAdd(this.amount, this.minFee).toFixed(8);
  211. } else {
  212. value = this.common.accMul(this.amount, remainder).toFixed(8);
  213. }
  214. }
  215. return value;
  216. }
  217. },
  218. methods: {
  219. getTransferInfo() { //获取提币信息
  220. this.getAxios('/api/user/coin/list')
  221. .then(data => {
  222. data.data.forEach(item => {
  223. if(item.id == this.transferCoin) {
  224. this.fee = item.changeCaseFee;
  225. this.minFee = item.changeCaseMinFee;
  226. this.minVolumn = item.changeCaseMinLimit;
  227. this.maxVolumn = item.changeCaseMaxLimit;
  228. }
  229. })
  230. })
  231. },
  232. getBalance() { //获取余额
  233. this.getAxios('/api/user/assets/list?type=' + this.assetsCaseCode)
  234. .then(data => {
  235. let list = data.data;
  236. list.forEach(item => {
  237. if(item.coinId == this.transferCoin) {
  238. this.account = item.normalAmount;
  239. }
  240. })
  241. })
  242. },
  243. getRecords(pages) { //获取提币记录
  244. let params = {
  245. data: {
  246. assetsType: 'A_I_T_NORMAL',
  247. dealCode: 'assets_transfer',
  248. //caseCode: this.listType == 1 ? 'COIN_TO_COIN' : 'F_COIN',
  249. },
  250. limit: 10,
  251. page: pages
  252. }
  253. this.currentPage = pages;
  254. this.postAxios('/api/user/assets/flow/page', params)
  255. .then(data => {
  256. this.pageTotal = data.data.pages;
  257. if (data.data.total == 0) {
  258. this.isContent = true;
  259. } else {
  260. this.isContent = false;
  261. }
  262. this.recordsList = [];
  263. data.data.records.forEach(item => {
  264. this.recordsList.push(item);
  265. })
  266. })
  267. },
  268. pagesChange(pages) {
  269. this.getRecords(pages);
  270. },
  271. chooseCoin(item) { //选择币种
  272. this.transferCoin = item.id;
  273. this.showCoin = false;
  274. this.getTransferInfo();
  275. this.getBalance();
  276. this.getRecords(1);
  277. },
  278. changeType() { //账户切换
  279. if(this.assetsCaseCode == 'COIN_TO_COIN') {
  280. this.assetsCaseCode = 'F_COIN';
  281. this.targetAssetsCaseCode = 'COIN_TO_COIN';
  282. } else {
  283. this.assetsCaseCode = 'COIN_TO_COIN';
  284. this.targetAssetsCaseCode = 'F_COIN';
  285. }
  286. this.getBalance();
  287. },
  288. submit() {
  289. if(this.loading) {
  290. return;
  291. }
  292. if(!this.amount) {
  293. this.$message.error(this.$t('请输入划转数量!'));
  294. return;
  295. }
  296. // if(this.amount < this.minVolumn) {
  297. // this.$message.error(this.$t('划转数量不能小于最小划转数量') + this.minVolumn + this.transferCoin);
  298. // return;
  299. // }
  300. // if(this.amount > this.maxVolumn) {
  301. // this.$message.error(this.$t('划转数量不能大于最大划转数量') + this.maxVolumn + this.transferCoin);
  302. // return;
  303. // }
  304. if(!this.password) {
  305. this.$message.error(this.$t('请输入支付密码!'));
  306. return;
  307. }
  308. this.loading = true;
  309. let params = {
  310. coinId: this.transferCoin,
  311. amount: this.amount,
  312. assetsCaseCode: this.assetsCaseCode,
  313. targetAssetsCaseCode: this.targetAssetsCaseCode,
  314. payPassword: this.password
  315. }
  316. this.putAxios('/api/user/assets/transfer', params)
  317. .then(() => {
  318. this.$message.success(this.$t('划转提交成功!'));
  319. this.loading = false;
  320. this.getRecords(1);
  321. this.getBalance();
  322. this.clearData();
  323. })
  324. .catch(() => {
  325. this.loading = false;
  326. })
  327. },
  328. clearData() {
  329. this.amount = '';
  330. this.password = '';
  331. },
  332. goBack() {
  333. if(this.$route.params.type == 1) {
  334. this.$router.push('/assets/coincoin');
  335. } else {
  336. this.$router.push('/assets/currency');
  337. }
  338. },
  339. },
  340. created() {
  341. this.transferCoin = this.$route.params.id;
  342. if(this.$route.params.type == 2) {
  343. this.assetsCaseCode = 'F_COIN';
  344. this.targetAssetsCaseCode = 'COIN_TO_COIN';
  345. }
  346. this.getTransferInfo();
  347. this.getBalance();
  348. this.getRecords(1);
  349. }
  350. }
  351. </script>
  352. <style scoped>
  353. .address-form-div4 {
  354. width: 32px;
  355. display: inline-block;
  356. margin: 0 9px;
  357. }
  358. </style>