brokerage_tx.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <view>
  3. <uni-nav-bar :border="false" statusBar left-icon="left" @clickLeft="utils.navigateBack()" @clickRight="tapOpenAdd" fixed title="兑换">
  4. <view style="color: #ef4034;" slot="right">
  5. 兑换记录
  6. </view>
  7. </uni-nav-bar>
  8. <view class="exchange-top">
  9. <view class="exchange-bot">
  10. <view class="eb-win-pop" v-if="bank.length > 0">
  11. <view class="eb-top fx-r" @tap="tapChck(index)" v-for="(item,index) in bank">
  12. <view class="ebt-right fx-g1">
  13. <view>{{ item.bank_name }}({{bankVal(item.payment)}})</view>
  14. </view>
  15. <view class="select">
  16. <image v-if="navIndex == index " src="/static/img/radio_buttons_btn.png"></image>
  17. <image v-else src="/static/img/radio_buttons.png"></image>
  18. </view>
  19. </view>
  20. </view>
  21. <view v-else>
  22. <view class="bank-add" @tap="tapAddBank">请添加银行卡</view>
  23. </view>
  24. </view>
  25. <view class="topinfo fx-h fx-bc fx-ac" style="margin-top: 10px;">
  26. <view class="count">{{ money || 0 }}</view>
  27. <view class="text">当前可提(贷款)</view>
  28. </view>
  29. <view class="txinput">
  30. <view class="label">提现金额</view>
  31. <u--input
  32. :placeholder="placeholder"
  33. border="surround"
  34. type="number"
  35. v-model="num"
  36. clearable
  37. ></u--input>
  38. <view class="tx-iall">
  39. <view class="etb-right" v-if="isInteger" @click="num = ( parseInt(( ((money -freeze) < 0 ? 0 : (money -freeze)) / 100) * 100) )">
  40. <text>全部</text>
  41. </view>
  42. <view class="etb-right" v-else @click="num = (money - freeze)">
  43. <text>全部</text>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="tip">
  48. <view class="input-item fx-r">
  49. <view class="label">当前兑换</view>
  50. <view class="fx-g1"></view>
  51. <view class="money">{{ ( isNaN(num) || num == '' ) ? '0.00' : utils.returnFloat(num) }}</view>
  52. </view>
  53. <view class="input-item fx-r">
  54. <view class="label">手续费</view>
  55. <view class="fx-g1"></view>
  56. <view class="money">{{ utils.removeTrailingZeros(tx) }}%</view>
  57. </view>
  58. <view class="input-item fx-r">
  59. <view class="label">预计扣除</view>
  60. <view class="fx-g1"></view>
  61. <view class="money">{{ dkMoney() }}</view>
  62. </view>
  63. <view class="input-item fx-r">
  64. <view class="label">到账金额</view>
  65. <view class="fx-g1"></view>
  66. <view class="money">{{ getMoney() }}</view>
  67. </view>
  68. </view>
  69. </view>
  70. <view class="exchange-btn select" v-if="isSure" @click="tapSubmit()">
  71. <text>立即兑换</text>
  72. </view>
  73. <view v-else class="exchange-btn2">{{ txCount > 0 ? ('已兑换' + txCount + '次' ) : '暂无兑换' }}</view>
  74. <PayDialog ref="payDialog" @getPassword="getPassword"></PayDialog>
  75. <view class="popwin fx-h fx-bc fx-ac" v-if="isPop">
  76. <view class="bg"></view>
  77. <view class="body fx-h fx-bc fx-ac">
  78. <view class="tips">
  79. <view class="title">温馨提醒</view>
  80. <view class="h1" v-if="max_money > 0">单笔兑换最高额度不能超过{{ utils.removeTrailingZeros(max_money) }}贷款。</view>
  81. <view class="h1" v-if="min_money > 0">单笔兑换最小额度不能低于{{ utils.removeTrailingZeros(min_money) }}贷款。</view>
  82. <view class="h1">兑换手续费{{ utils.removeTrailingZeros(tx) }}%</view>
  83. <view class="h1">每次只能发起兑换一次,兑换成功之后才能发起第二次。</view>
  84. <view class="h1"> {{ content }}</view>
  85. </view>
  86. <view class="btn" @tap="isPop = false">我已知晓</view>
  87. </view>
  88. </view>
  89. </view>
  90. </template>
  91. <script>
  92. import {mapState,mapMutations} from 'vuex';
  93. import PayDialog from "@/components/ui-pay/payDialog.vue";
  94. export default {
  95. computed: mapState(['user']),
  96. components:{
  97. PayDialog
  98. },
  99. data() {
  100. return {
  101. data : {},
  102. min_money : 0,//进行最小金额 (0 无限)
  103. max_money : 0,//提现最大金额 (0 无限)
  104. tx:"0", //提现比例
  105. isPop:true,
  106. placeholder:"",
  107. title:"",
  108. content : "",
  109. money : 0,
  110. freeze:0,
  111. num:"",
  112. txCount : 0,
  113. navIndex:0,
  114. isSure:true,
  115. isInteger:false,
  116. unit:"scale",
  117. bank:[],
  118. form:{
  119. name : "",
  120. account : "",
  121. opening : ""
  122. }
  123. }
  124. },
  125. onLoad(options) {},
  126. onShow() {
  127. uni.showLoading({ title: '获取数据中..' });
  128. this
  129. .request
  130. .post("userBrokerageExchange",{type:this.type})
  131. .then(res=>{
  132. uni.hideLoading();
  133. if(res.code == 200) {
  134. this.content = res.data.text;//提现内容
  135. this.min_money = res.data.min_money;//提现最小金额
  136. this.max_money = res.data.max_money;//提现最大金额
  137. this.money = res.data.money;
  138. this.freeze = res.data.freeze;
  139. this.isSure = res.data.isTx;
  140. this.txCount = res.data.count;
  141. this.tx = res.data.tx;
  142. this.isInteger = res.data.is_integer == 1 ? true : false;
  143. this.placeholder = `还剩余${res.data.money}${this.title}`;
  144. this.unit = res.data.unit;
  145. }
  146. })
  147. .catch(err=>{
  148. uni.hideLoading();
  149. uni.showModal({title: '系统提示',content: '加载失败,返回在尝试',showCancel: false});
  150. });
  151. this
  152. .request
  153. .post("getBank")
  154. .then(res=>{
  155. if(res.code == 200) {
  156. this.bank = res.data
  157. } else {
  158. this.utils.Tip(res.msg);
  159. }
  160. })
  161. .catch(err=>{
  162. this.utils.Tip(res.msg);
  163. });
  164. },
  165. methods: {
  166. tapChck:function(index){
  167. this.navIndex = index;
  168. },
  169. dkMoney:function(){
  170. if(isNaN(this.num) || this.num == '') {
  171. return "0.00";
  172. }
  173. let v = this.utils.returnFloat(parseFloat(this.num) * (this.tx / 100));
  174. return v;
  175. },
  176. /**
  177. * 获取金额
  178. */
  179. getMoney:function(){
  180. if(isNaN(this.num) || this.num == '') {
  181. return "0.00";
  182. }
  183. let v = parseFloat(this.num) * (this.tx / 100);
  184. return this.utils.returnFloat(parseFloat(this.num) - v);
  185. },
  186. tapOpenAdd:function(){
  187. uni.navigateTo({url:"brokerage_tx_log?type=" + this.type});
  188. },
  189. /**
  190. * 银行卡
  191. */
  192. tapAddBank:function(){
  193. uni.navigateTo({
  194. url:"../bank/bank"
  195. });
  196. },
  197. /**
  198. * 提交数据
  199. */
  200. tapSubmit:function(){
  201. if(this.num == '' || this.num == 0) {
  202. return this.utils.Tip("请输入兑换额度");
  203. }
  204. if( (this.min_money - 1) > this.num) {
  205. return this.utils.Tip("兑换额度不能少于:" + this.min_money);
  206. }
  207. if(parseFloat(this.num) > this.max_money ) {
  208. return this.utils.Tip("兑换额度不能大于:" + this.utils.removeTrailingZeros(this.max_money));
  209. }
  210. if( this.bank.length <= 0) {
  211. return this.utils.Tip("请添加银行卡在操作");
  212. }
  213. //this.getPassword({password:1234});
  214. this.$refs['payDialog'].show();
  215. },
  216. /**
  217. * 密码
  218. */
  219. getPassword:function(res){
  220. var password = res.password;
  221. var formData = {...this.form,
  222. num:this.num,
  223. bankId:this.bank[this.navIndex].id,
  224. type : this.type,
  225. password : password
  226. };
  227. this.$refs['payDialog'].hideFun();
  228. this.utils.loadIng("提交中..");
  229. this
  230. .request
  231. .post("userSubBrokerage",formData)
  232. .then(res=>{
  233. uni.hideLoading();
  234. if(res.code == 200) {
  235. this.utils.Tip(res.msg);
  236. setTimeout(function(){ uni.navigateBack();},1000);
  237. }else{
  238. this.utils.Tip(res.msg);
  239. this.$refs['payDialog'].cleanNum();
  240. }
  241. }).catch(function(){
  242. uni.hideLoading();
  243. this.utils.Tip("网络错误,请稍后尝试");
  244. });
  245. },
  246. tapBZfb:function(id){
  247. uni.navigateTo({
  248. url:"/pages/user/bank/bank_edit?id=" + id
  249. })
  250. },
  251. bankVal:function(str){
  252. var reg = /^(\d{4})\d+(\d{4})$/;
  253. str = str.replace(reg, "$1 **** **** $2");
  254. return str;
  255. },
  256. bankZfbVal:function(str){
  257. console.log(str);
  258. var reg = /^(\d{4})\d+(\d{4})$/;
  259. str = str.replace(reg, "$1****$2");
  260. return str;
  261. }
  262. }
  263. }
  264. </script>
  265. <style lang="scss">
  266. page{background:#f5f5f5}
  267. .exchange-top{padding:10px;}
  268. .et-top{color:#2d2438;font-size:12px;margin-bottom: 20px;}
  269. /**银行卡**/
  270. .exchange-bot{width:100%;margin-top:10px;background-color:#fff;border-radius: 10px;}
  271. .etb-right{margin-left:auto;color:#2d2438;font-size:16px;color: #ef4034;}
  272. .eb-top{padding:10px 15px;height:50px;display:flex;align-items:center;border-bottom:1px #f5f5f5 solid}
  273. .eb-top .pvg image{width: 15px;height: 15px;}
  274. .eb-top .select image{width: 20px;height: 20px;}
  275. .bank-add{color:#ef4034;font-size: 14px;text-align: center;padding: 20px 0;}
  276. /**提现金额**/
  277. .txinput{margin-top:10px;background-color:#fff;border-radius: 10px;padding: 10px;}
  278. .txinput .label{font-size: 14px;margin-bottom: 10px;}
  279. .tx-iall{margin-top: 10px;}
  280. .tx-iall .etb-right{font-size:14px;}
  281. /**提示框**/
  282. .tip{margin-top:10px;background-color:#fff;border-radius: 10px;padding: 10px;}
  283. .tips{position: relative;background: #FDF6EC;padding: 8px 10px;border-radius: 6px;margin-bottom: 10px;}
  284. .tips .title{font-size: 14px;color: #f9ae3d;font-size: 14px;font-weight: bold;}
  285. .tips .h1{font-size: 12px;padding: 2px 0;color: #f9ae3d;}
  286. .input-item{padding: 2px 0;}
  287. .input-item .label{font-size: 14px;color: #000;}
  288. .input-item .money{color: #ef4034;font-size: 14px;}
  289. /**弹出框 **/
  290. .popwin{position:fixed;width: 100%;height: 100%;top: 0;left: 0;z-index: 88;}
  291. .popwin .bg{background: rgba(0, 0, 0, 0.5);height: 100%;width: 100%;position: absolute;left: 0;top: 0;}
  292. .popwin .body{padding: 20px;width: 80%;background: #fff;position: relative;border-radius: 8px;}
  293. .max-he{height: 60vh;}
  294. .popwin .btn{margin-top: 6px;border-radius: 4px;background: #ef4034;font-size:14px;color: #fff;width: 100px;text-align: center;padding: 6px 2px;}
  295. .popwin .btn.no{background: #f1f1f1;color: #ccc}
  296. .exchange-btn{width:90%;height:40px;text-align:center;line-height:40px;margin:30px auto;background:#ef4034;color:#fff;border-radius:100px;font-size:16px}
  297. .exchange-btn2{width:90%;height:40px;text-align:center;line-height:40px;margin:30px auto;background:#ccc;color:#fff;border-radius:100px;font-size:16px}
  298. .topinfo{
  299. background: #fff;
  300. padding: 40rpx 0;
  301. .count{
  302. background-size: 100%;
  303. font-size: 24px;
  304. color: #303133;
  305. font-weight: 700;
  306. background-repeat: no-repeat;
  307. background-position: 50%;
  308. }
  309. .text{
  310. color: #909399;
  311. font-size: 18px;
  312. }
  313. }
  314. </style>