target.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <view :style="colorStyle">
  3. <view class='cash-withdrawal'>
  4. <view class='wrapper'>
  5. <view class='list'>
  6. <form @submit="subCash">
  7. <!-- <view class='item acea-row row-between-wrapper'>
  8. <view class='name'>持卡人</view>
  9. <view class='input'><input placeholder='请输入持卡人姓名' placeholder-class='placeholder'
  10. name="name"
  11. onKeypress="javascript:if(event.keyCode == 32)event.returnValue = false;"></input>
  12. </view>
  13. </view> -->
  14. <view class='item acea-row row-between-wrapper'>
  15. <view class='name'>用户ID</view>
  16. <view class='input'><input type='number' placeholder='请填写转账用户ID' placeholder-class='placeholder'
  17. name="uid"></input></view>
  18. </view>
  19. <!-- <view class='item acea-row row-between-wrapper'>
  20. <view class='name'>开户行</view>
  21. <view class='input'><input placeholder='请输入开户行名称' placeholder-class='placeholder'
  22. name="bankname"
  23. onKeypress="javascript:if(event.keyCode == 32)event.returnValue = false;"></input>
  24. </view>
  25. </view> -->
  26. <view class='item acea-row row-between-wrapper'>
  27. <view class='name'>转账佣金金额</view>
  28. <view class='input'><input v-model="allMoney" @input='inputNum' placeholder='需要转账的佣金金额' placeholder-class='placeholder' name="num"
  29. type='digit'></input></view>
  30. </view>
  31. <view class='tip'>
  32. 当前可转佣金:<text class="price">{{userInfo.commissionCount}}</text>
  33. <!-- 时价:<text class="price">{{stock_price}}</text> -->
  34. </view>
  35. <!-- <view class='tip'>
  36. 手续费:<text class="price">{{withdraw_fee}}%</text>实际到账:<text
  37. class="price">{{true_money}}</text>
  38. </view> -->
  39. <button formType="submit" class='bnt bg-color'>立即转换</button>
  40. </form>
  41. </view>
  42. </view>
  43. </view>
  44. <home v-if="navigation"></home>
  45. </view>
  46. </template>
  47. <script>
  48. import {
  49. energyExchange,
  50. // energyBank,
  51. getUserInfo
  52. } from '@/api/user.js';
  53. import {
  54. toLogin
  55. } from '@/libs/login.js';
  56. import {
  57. mapGetters
  58. } from "vuex";
  59. import colors from '@/mixins/color.js';
  60. import home from '@/components/home';
  61. import { userInfo } from 'os';
  62. export default {
  63. components: {
  64. home
  65. },
  66. mixins: [colors],
  67. data() {
  68. return {
  69. minPrice: 0.00, //最低提现金额
  70. userInfo: [],
  71. prevent: true, //避免重复提交成功多次
  72. moneyMaxLeng: 8,
  73. withdraw_fee: '0',
  74. true_money: 0,
  75. allMoney: '', //保存当前提现金额
  76. };
  77. },
  78. computed: mapGetters(['isLogin']),
  79. watch: {
  80. isLogin: {
  81. handler: function(newV, oldV) {
  82. if (newV) {
  83. this.getUserInfo();
  84. // this.getUserExtractBank();
  85. }
  86. },
  87. deep: true
  88. }
  89. },
  90. onLoad() {
  91. if (this.isLogin) {
  92. this.getUserInfo();
  93. // this.getUserExtractBank();
  94. } else {
  95. toLogin()
  96. }
  97. },
  98. methods: {
  99. inputNum: async function(e) {
  100. let val = e.detail.value;
  101. let dot = val.indexOf('.');
  102. if (dot > -1) {
  103. this.moneyMaxLeng = dot + 3;
  104. } else {
  105. this.moneyMaxLeng = 8
  106. }
  107. try {
  108. this.true_money = +((val - val*this.withdraw_fee/100)/this.stock_price).toFixed(2);
  109. // console.log(this.true_money,'this.true_money');
  110. } catch (e) {
  111. uni.showToast({
  112. title: e,
  113. icon: "error"
  114. });
  115. //TODO handle the exception
  116. }
  117. },
  118. // getUserExtractBank: function() {
  119. // let that = this;
  120. // energyBank().then(res => {
  121. // that.minPrice = res.data.minEnergy;
  122. // that.stock_price = res.data.stock_price;
  123. // that.withdraw_fee = res.data.exchange_fee;
  124. // });
  125. // },
  126. /**
  127. * 获取个人用户信息
  128. */
  129. getUserInfo: function() {
  130. let that = this;
  131. getUserInfo().then(res => {
  132. that.userInfo = res.data;
  133. })
  134. },
  135. subCash: function(e) {
  136. let that = this,
  137. value = e.detail.value;
  138. if (value.uid.length == 0) return that.$util.Tips({
  139. title: '请填写收款用户UID'
  140. });
  141. if (value.num.length == 0) return that.$util.Tips({
  142. title: '请填写转账金额'
  143. });
  144. if(value.num>this.userInfo.commissionCount){
  145. return that.$util.Tips({
  146. title: '转账佣金不可大于可转账佣金'
  147. });
  148. }
  149. energyExchange({
  150. ...value,
  151. }).then(res => {
  152. return this.$util.Tips({
  153. title: res.msg,
  154. icon: 'success'
  155. }, {
  156. url: '/pages/user/index',
  157. tab: 2
  158. });
  159. }).catch(err => {
  160. setTimeout(e => {
  161. this.prevent = true
  162. }, 1500)
  163. return this.$util.Tips({
  164. title: err
  165. });
  166. });
  167. }
  168. }
  169. }
  170. </script>
  171. <style lang="scss">
  172. page {
  173. background-color: #fff !important;
  174. }
  175. .fontcolor {
  176. color: var(--view-theme) !important;
  177. }
  178. .cash-withdrawal .nav {
  179. height: 130rpx;
  180. box-shadow: 0 10rpx 10rpx #f8f8f8;
  181. }
  182. .cash-withdrawal .nav .item {
  183. font-size: 26rpx;
  184. flex: 1;
  185. text-align: center;
  186. }
  187. .cash-withdrawal .nav .item~.item {
  188. border-left: 1px solid #f0f0f0;
  189. }
  190. .cash-withdrawal .nav .item .iconfont {
  191. width: 40rpx;
  192. height: 40rpx;
  193. border-radius: 50%;
  194. border: 2rpx solid var(--view-theme);
  195. text-align: center;
  196. line-height: 37rpx;
  197. margin: 0 auto 6rpx auto;
  198. font-size: 22rpx;
  199. box-sizing: border-box;
  200. }
  201. .cash-withdrawal .nav .item .iconfont.on {
  202. background-color: var(--view-theme);
  203. color: #fff;
  204. border-color: var(--view-theme);
  205. }
  206. .cash-withdrawal .nav .item .line {
  207. width: 2rpx;
  208. height: 20rpx;
  209. margin: 0 auto;
  210. transition: height 0.3s;
  211. }
  212. .cash-withdrawal .nav .item .line.on {
  213. height: 39rpx;
  214. }
  215. .cash-withdrawal .wrapper .list {
  216. padding: 0 30rpx;
  217. }
  218. .cash-withdrawal .wrapper .list .item {
  219. border-bottom: 1rpx solid #eee;
  220. min-height: 28rpx;
  221. font-size: 30rpx;
  222. color: #333;
  223. padding: 39rpx 0;
  224. }
  225. .cash-withdrawal .wrapper .list .item .name {
  226. width: 130rpx;
  227. }
  228. .cash-withdrawal .wrapper .list .item .input {
  229. width: 505rpx;
  230. }
  231. .cash-withdrawal .wrapper .list .item .input .placeholder {
  232. color: #bbb;
  233. }
  234. .cash-withdrawal .wrapper .list .item .picEwm,
  235. .cash-withdrawal .wrapper .list .item .pictrue {
  236. width: 140rpx;
  237. height: 140rpx;
  238. border-radius: 3rpx;
  239. position: relative;
  240. margin-right: 23rpx;
  241. }
  242. .cash-withdrawal .wrapper .list .item .picEwm image {
  243. width: 100%;
  244. height: 100%;
  245. border-radius: 3rpx;
  246. }
  247. .cash-withdrawal .wrapper .list .item .picEwm .icon-guanbi1 {
  248. position: absolute;
  249. right: -14rpx;
  250. top: -16rpx;
  251. font-size: 40rpx;
  252. }
  253. .cash-withdrawal .wrapper .list .item .pictrue {
  254. border: 1px solid rgba(221, 221, 221, 1);
  255. font-size: 22rpx;
  256. color: #BBBBBB;
  257. }
  258. .cash-withdrawal .wrapper .list .item .pictrue .icon-icon25201 {
  259. font-size: 47rpx;
  260. color: #DDDDDD;
  261. margin-bottom: 3px;
  262. }
  263. .cash-withdrawal .wrapper .list .tip {
  264. font-size: 26rpx;
  265. color: #999;
  266. margin-top: 25rpx;
  267. }
  268. .cash-withdrawal .wrapper .list .bnt {
  269. font-size: 32rpx;
  270. color: #fff;
  271. width: 690rpx;
  272. height: 90rpx;
  273. text-align: center;
  274. border-radius: 50rpx;
  275. line-height: 90rpx;
  276. margin: 64rpx auto;
  277. }
  278. .cash-withdrawal .wrapper .list .tip2 {
  279. font-size: 26rpx;
  280. color: #999;
  281. text-align: center;
  282. margin: 44rpx 0 20rpx 0;
  283. }
  284. .cash-withdrawal .wrapper .list .value {
  285. height: 135rpx;
  286. line-height: 135rpx;
  287. border-bottom: 1rpx solid #eee;
  288. width: 690rpx;
  289. margin: 0 auto;
  290. }
  291. .cash-withdrawal .wrapper .list .value input {
  292. font-size: 80rpx;
  293. color: #282828;
  294. height: 135rpx;
  295. text-align: center;
  296. }
  297. .cash-withdrawal .wrapper .list .value .placeholder2 {
  298. color: #bbb;
  299. }
  300. .price {
  301. color: var(--view-priceColor);
  302. margin-right: 20rpx;
  303. }
  304. </style>