index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. <template>
  2. <view :style="colorStyle">
  3. <view class='cash-withdrawal'>
  4. <view class='nav acea-row' v-if="navList.length>1">
  5. <view v-for="(item,index) in navList" :key="index" class='item fontcolor' @click="swichNav(item.id)">
  6. <view class='line bg-color' :class='currentTab==item.id ? "on":""'></view>
  7. <view class='iconfont' :class='item.icon+" "+(currentTab==item.id ? "on":"")'></view>
  8. <view>{{item.name}}</view>
  9. </view>
  10. </view>
  11. <view class='wrapper'>
  12. <view :hidden='currentTab != 0' class='list'>
  13. <form @submit="subCash">
  14. <view class='item acea-row row-between-wrapper'>
  15. <view class='name'>持卡人</view>
  16. <view class='input'><input placeholder='请输入持卡人姓名' placeholder-class='placeholder'
  17. name="name" onKeypress="javascript:if(event.keyCode == 32)event.returnValue = false;"></input></view>
  18. </view>
  19. <view class='item acea-row row-between-wrapper'>
  20. <view class='name'>卡号</view>
  21. <view class='input'><input type='number' placeholder='请填写卡号' placeholder-class='placeholder'
  22. name="cardnum"></input></view>
  23. </view>
  24. <view class='item acea-row row-between-wrapper'>
  25. <view class='name'>银行</view>
  26. <view class='input'>
  27. <picker @change="bindPickerChange" :value="index" :range="array">
  28. <text class='Bank'>{{array[index]}}</text>
  29. <text class='iconfont icon-qiepian38'></text>
  30. </picker>
  31. </view>
  32. </view>
  33. <view class='item acea-row row-between-wrapper'>
  34. <view class='name'>类型</view>
  35. <view class='input'>
  36. <picker @change="typePickerChange" :value="index" :range="typeMoney" range-key="name">
  37. <text class='Bank'>{{typeMoney[typeIndex].name}}</text>
  38. <text class='iconfont icon-qiepian38'></text>
  39. </picker>
  40. </view>
  41. </view>
  42. <view class='item acea-row row-top row-between'>
  43. <view class='name'>凭证</view>
  44. <view class="input acea-row">
  45. <view class="picEwm" v-if="qrcodeUrPZ">
  46. <image :src="qrcodeUrPZ"></image>
  47. <text class='iconfont icon-guanbi1 fontcolor' @click='DelPicP'></text>
  48. </view>
  49. <view class='pictrue acea-row row-center-wrapper row-column' @click='uploadpic("P")'
  50. v-else>
  51. <text class='iconfont icon-icon25201'></text>
  52. <view>上传图片</view>
  53. </view>
  54. </view>
  55. </view>
  56. <view class='item acea-row row-between-wrapper'>
  57. <view class='name'>提取</view>
  58. <view class='input'><input v-model="allMoney" @input='inputNum' :maxlength="moneyMaxLeng" :placeholder='"最低提取金额:¥"+minPrice' placeholder-class='placeholder'
  59. name="money" type='digit'></input></view>
  60. </view>
  61. <view class='tip'>
  62. 当前可提取金额: <text
  63. class="price">¥{{userInfo.commissionCount}}</text>,冻结佣金:¥{{userInfo.broken_commission}}
  64. </view>
  65. <view class='tip'>
  66. 提取手续费: <text class="price">¥{{withdraw_fee}}</text>,实际到账:<text class="price">¥{{true_money}}</text>
  67. </view>
  68. <view class='tip'>
  69. 说明: 每笔佣金的冻结期为{{userInfo.broken_day}}天,到期后可提取
  70. </view>
  71. <button formType="submit" class='bnt bg-color'>提取</button>
  72. </form>
  73. </view>
  74. <view :hidden='currentTab != 1' class='list'>
  75. <form @submit="subCash">
  76. <view class='item acea-row row-between-wrapper' v-if="extract_wechat_type == 0">
  77. <view class='name'>账号</view>
  78. <view class='input'><input placeholder='请填写您的微信账号' placeholder-class='placeholder'
  79. name="name" onKeypress="javascript:if(event.keyCode == 32)event.returnValue = false;"></input></view>
  80. </view>
  81. <view class='item acea-row row-between-wrapper'>
  82. <view class='name'>提取</view>
  83. <view class='input'><input @input='inputNum' :maxlength="moneyMaxLeng" :placeholder='"最低提取金额:¥"+minPrice' placeholder-class='placeholder'
  84. name="money" type='digit'></input></view>
  85. </view>
  86. <view class='item acea-row row-top row-between' v-if="extract_wechat_type == 0">
  87. <view class='name'>收款码</view>
  88. <view class="input acea-row">
  89. <view class="picEwm" v-if="qrcodeUrlW">
  90. <image :src="qrcodeUrlW"></image>
  91. <text class='iconfont icon-guanbi1 fontcolor' @click='DelPicW'></text>
  92. </view>
  93. <view class='pictrue acea-row row-center-wrapper row-column' @click='uploadpic("W")'
  94. v-else>
  95. <text class='iconfont icon-icon25201'></text>
  96. <view>上传图片</view>
  97. </view>
  98. </view>
  99. </view>
  100. <view class='tip'>
  101. 当前可提取金额: <text
  102. class="price">¥{{userInfo.commissionCount}}</text>,冻结佣金:¥{{userInfo.broken_commission}}
  103. </view>
  104. <view class='tip'>
  105. 提取手续费: <text class="price">¥{{withdraw_fee}}</text>,实际到账:<text class="price">¥{{true_money}}</text>
  106. </view>
  107. <view class='tip'>
  108. 说明: 每笔佣金的冻结期为{{userInfo.broken_day}}天,到期后可提取
  109. </view>
  110. <button formType="submit" class='bnt bg-color'>提取</button>
  111. </form>
  112. </view>
  113. <view :hidden='currentTab != 2' class='list'>
  114. <form @submit="subCash">
  115. <view class='item acea-row row-between-wrapper'>
  116. <view class='name'>账号</view>
  117. <view class='input'><input placeholder='请填写您的支付宝账号' placeholder-class='placeholder'
  118. name="name" onKeypress="javascript:if(event.keyCode == 32)event.returnValue = false;"></input></view>
  119. </view>
  120. <view class='item acea-row row-between-wrapper'>
  121. <view class='name'>提取</view>
  122. <view class='input'><input @input='inputNum' :maxlength="moneyMaxLeng" :placeholder='"最低提取金额:¥"+minPrice' placeholder-class='placeholder'
  123. name="money" type='digit'></input></view>
  124. </view>
  125. <view class='item acea-row row-top row-between'>
  126. <view class='name'>收款码</view>
  127. <view class="input acea-row">
  128. <view class="picEwm" v-if="qrcodeUrlZ">
  129. <image :src="qrcodeUrlZ"></image>
  130. <text class='iconfont icon-guanbi1 fontcolor' @click='DelPicZ'></text>
  131. </view>
  132. <view class='pictrue acea-row row-center-wrapper row-column' @click='uploadpic("Z")'
  133. v-else>
  134. <text class='iconfont icon-icon25201'></text>
  135. <view>上传图片</view>
  136. </view>
  137. </view>
  138. </view>
  139. <view class='tip'>
  140. 当前可提取金额: <text
  141. class="price">¥{{userInfo.commissionCount}}</text>,冻结佣金:¥{{userInfo.broken_commission}}
  142. </view>
  143. <view class='tip'>
  144. 提取手续费: <text class="price">¥{{withdraw_fee}}</text>,实际到账:<text class="price">¥{{true_money}}</text>
  145. </view>
  146. <view class='tip'>
  147. 说明: 每笔佣金的冻结期为{{userInfo.broken_day}}天,到期后可提取
  148. </view>
  149. <button formType="submit" class='bnt bg-color'>提取</button>
  150. </form>
  151. </view>
  152. </view>
  153. </view>
  154. <!-- #ifdef MP -->
  155. <!-- <authorize v-if="isShowAuth" @authColse="authColse" @onLoadFun="onLoadFun"></authorize> -->
  156. <!-- #endif -->
  157. <home v-if="navigation"></home>
  158. </view>
  159. </template>
  160. <script>
  161. import {
  162. extractCash,
  163. extractBank,
  164. getUserInfo
  165. } from '@/api/user.js';
  166. import {
  167. toLogin
  168. } from '@/libs/login.js';
  169. import {
  170. calculator,
  171. } from '@/api/new.js';
  172. import {
  173. mapGetters
  174. } from "vuex";
  175. import colors from '@/mixins/color.js';
  176. import home from '@/components/home';
  177. export default {
  178. components: {
  179. home
  180. },
  181. mixins:[colors],
  182. data() {
  183. return {
  184. navList: [],
  185. currentTab: '',
  186. index: 0,
  187. array: [], //提取银行
  188. typeIndex:0,
  189. typeMoney: [{
  190. name:'个人',
  191. value:0
  192. },{
  193. name:'企业',
  194. value:1
  195. }], //提取银行
  196. minPrice: 0.00, //最低提取金额
  197. userInfo: [],
  198. isClone: false,
  199. isAuto: false, //没有授权的不会自动授权
  200. isShowAuth: false, //是否隐藏授权
  201. qrcodeUrlW: "",
  202. qrcodeUrlZ: "",
  203. qrcodeUrPZ: "",
  204. prevent: true, //避免重复提交成功多次
  205. moneyMaxLeng: 8,
  206. withdraw_fee: '0',
  207. true_money: 0,
  208. extract_wechat_type:0,
  209. allMoney:'',//保存当前提取金额
  210. };
  211. },
  212. computed: mapGetters(['isLogin']),
  213. watch: {
  214. isLogin: {
  215. handler: function(newV, oldV) {
  216. if (newV) {
  217. this.getUserInfo();
  218. this.getUserExtractBank();
  219. }
  220. },
  221. deep: true
  222. }
  223. },
  224. onLoad() {
  225. if (this.isLogin) {
  226. this.getUserInfo();
  227. this.getUserExtractBank();
  228. } else {
  229. toLogin()
  230. }
  231. },
  232. onShow() {
  233. uni.removeStorageSync('form_type_cart');
  234. },
  235. methods: {
  236. inputNum: async function(e) {
  237. let val = e.detail.value;
  238. let dot = val.indexOf('.');
  239. if(dot>-1){
  240. this.moneyMaxLeng = dot+3;
  241. }else{
  242. this.moneyMaxLeng = 8
  243. }
  244. try{
  245. let money = await calculator({money:val,user_type:this.typeMoney[this.typeIndex].value});
  246. this.withdraw_fee = money.data.fee;
  247. this.true_money = val - this.withdraw_fee;
  248. }catch(e){
  249. uni.showToast({
  250. title: e,
  251. icon:"error"
  252. });
  253. //TODO handle the exception
  254. }
  255. },
  256. // uploadpicW(){
  257. // this.uploadpic(this.qrcodeUrlW);
  258. // },
  259. // uploadpicZ(){
  260. // this.uploadpic(this.qrcodeUrlZ);
  261. // },
  262. /**
  263. * 上传文件
  264. *
  265. */
  266. uploadpic: function(type) {
  267. let that = this;
  268. uni.showModal({
  269. title: "相机权限申请",
  270. content: "是否允许访问相机及存储空间用于上传凭证?",
  271. success(res) {
  272. if (res.confirm) {
  273. that.$util.uploadImageOne('upload/image', function(res) {
  274. if (type === 'W') {
  275. that.qrcodeUrlW = res.data.url;
  276. } else if(type=="Z"){
  277. that.qrcodeUrlZ = res.data.url;
  278. }else if(type=="P"){
  279. that.qrcodeUrPZ = res.data.url;
  280. }
  281. });
  282. }
  283. }
  284. })
  285. },
  286. /**
  287. * 删除图片
  288. *
  289. */
  290. DelPicW: function() {
  291. this.qrcodeUrlW = "";
  292. },
  293. DelPicZ: function() {
  294. this.qrcodeUrlZ = "";
  295. },
  296. DelPicP: function() {
  297. this.qrcodeUrPZ = "";
  298. },
  299. onLoadFun: function() {
  300. this.getUserInfo();
  301. this.getUserExtractBank();
  302. this.isShowAuth = false;
  303. },
  304. // 授权关闭
  305. authColse: function(e) {
  306. this.isShowAuth = e
  307. },
  308. getUserExtractBank: function() {
  309. let that = this;
  310. extractBank().then(res => {
  311. let array = res.data.extractBank;
  312. array.unshift("请选择银行");
  313. that.$set(that, 'array', array);
  314. that.minPrice = res.data.minPrice;
  315. that.extract_wechat_type = res.data.extract_wechat_type;
  316. });
  317. },
  318. /**
  319. * 获取个人用户信息
  320. */
  321. getUserInfo: function() {
  322. let that = this;
  323. getUserInfo().then(res => {
  324. that.userInfo = res.data;
  325. if(res.data.user_extract_bank_status){
  326. this.navList.push(
  327. {
  328. 'name': '银行卡',
  329. 'icon': 'icon-yinhangqia',
  330. 'id': 0
  331. }
  332. )
  333. }
  334. if(res.data.user_extract_wechat_status){
  335. this.navList.push(
  336. {
  337. 'name': '微信',
  338. 'icon': 'icon-weixin2',
  339. 'id': 1
  340. }
  341. )
  342. }
  343. if(res.data.user_extract_alipay_status){
  344. this.navList.push(
  345. {
  346. 'name': '支付宝',
  347. 'icon': 'icon-icon34',
  348. 'id': 2
  349. }
  350. )
  351. }
  352. this.currentTab = this.navList[0].id;
  353. })
  354. },
  355. swichNav: function(current) {
  356. this.currentTab = current;
  357. },
  358. bindPickerChange: function(e) {
  359. this.index = e.detail.value;
  360. },
  361. typePickerChange(e){
  362. this.typeIndex = e.detail.value;
  363. this.inputNum({detail:{value:this.allMoney}});
  364. },
  365. subCash: function(e) {
  366. let that = this,
  367. value = e.detail.value;
  368. if(!that.qrcodeUrPZ){
  369. that.$util.Tips({
  370. title: '请上传凭证'
  371. })
  372. return
  373. }
  374. value.image = that.qrcodeUrPZ;
  375. if (that.currentTab == 0) { //银行卡
  376. if (value.name.length == 0) return that.$util.Tips({
  377. title: '请填写持卡人姓名'
  378. });
  379. if (value.cardnum.length == 0) return that.$util.Tips({
  380. title: '请填写卡号'
  381. });
  382. if (that.index == 0) return that.$util.Tips({
  383. title: "请选择银行"
  384. });
  385. value.extract_type = 'bank';
  386. value.bankname = that.array[that.index];
  387. } else if (that.currentTab == 1) { //微信
  388. value.extract_type = 'weixin';
  389. if(that.extract_wechat_type == 0){
  390. if (value.name.length == 0) return that.$util.Tips({
  391. title: '请填写微信号'
  392. });
  393. if (that.qrcodeUrlW == '') return that.$util.Tips({
  394. title: '请上传图片'
  395. });
  396. value.weixin = value.name;
  397. value.qrcode_url = that.qrcodeUrlW;
  398. }
  399. } else if (that.currentTab == 2) { //支付宝
  400. value.extract_type = 'alipay';
  401. if (value.name.length == 0) return that.$util.Tips({
  402. title: '请填写账号'
  403. });
  404. if (that.qrcodeUrlZ == '') return that.$util.Tips({
  405. title: '请上传图片'
  406. });
  407. value.alipay_code = value.name;
  408. value.qrcode_url = that.qrcodeUrlZ;
  409. }
  410. if (value.money.length == 0) return that.$util.Tips({
  411. title: '请填写提取金额'
  412. });
  413. if (Number(value.money) < Number(that.minPrice)) return that.$util.Tips({
  414. title: '提取金额不能低于:¥' + that.minPrice
  415. });
  416. if (that.prevent) {
  417. that.prevent = false
  418. } else {
  419. return
  420. }
  421. extractCash({
  422. ...value,
  423. user_type:that.typeMoney[that.typeIndex].value
  424. }).then(res => {
  425. //that.getUserInfo();
  426. return this.$util.Tips({
  427. title: res.msg,
  428. icon: 'success'
  429. }, {
  430. url: '/pages/users/user_spread_user/index',
  431. tab: 2
  432. });
  433. }).catch(err => {
  434. setTimeout(e => {
  435. this.prevent = true
  436. }, 1500)
  437. return this.$util.Tips({
  438. title: err
  439. });
  440. });
  441. }
  442. }
  443. }
  444. </script>
  445. <style lang="scss">
  446. page {
  447. background-color: #fff !important;
  448. }
  449. .fontcolor{
  450. color: var(--view-theme) !important;
  451. }
  452. .cash-withdrawal .nav {
  453. height: 130rpx;
  454. box-shadow: 0 10rpx 10rpx #f8f8f8;
  455. }
  456. .cash-withdrawal .nav .item {
  457. font-size: 26rpx;
  458. flex: 1;
  459. text-align: center;
  460. }
  461. .cash-withdrawal .nav .item~.item {
  462. border-left: 1px solid #f0f0f0;
  463. }
  464. .cash-withdrawal .nav .item .iconfont {
  465. width: 40rpx;
  466. height: 40rpx;
  467. border-radius: 50%;
  468. border: 2rpx solid var(--view-theme);
  469. text-align: center;
  470. line-height: 37rpx;
  471. margin: 0 auto 6rpx auto;
  472. font-size: 22rpx;
  473. box-sizing: border-box;
  474. }
  475. .cash-withdrawal .nav .item .iconfont.on {
  476. background-color: var(--view-theme);
  477. color: #fff;
  478. border-color: var(--view-theme);
  479. }
  480. .cash-withdrawal .nav .item .line {
  481. width: 2rpx;
  482. height: 20rpx;
  483. margin: 0 auto;
  484. transition: height 0.3s;
  485. }
  486. .cash-withdrawal .nav .item .line.on {
  487. height: 39rpx;
  488. }
  489. .cash-withdrawal .wrapper .list {
  490. padding: 0 30rpx;
  491. }
  492. .cash-withdrawal .wrapper .list .item {
  493. border-bottom: 1rpx solid #eee;
  494. min-height: 28rpx;
  495. font-size: 30rpx;
  496. color: #333;
  497. padding: 39rpx 0;
  498. }
  499. .cash-withdrawal .wrapper .list .item .name {
  500. width: 130rpx;
  501. }
  502. .cash-withdrawal .wrapper .list .item .input {
  503. width: 505rpx;
  504. }
  505. .cash-withdrawal .wrapper .list .item .input .placeholder {
  506. color: #bbb;
  507. }
  508. .cash-withdrawal .wrapper .list .item .picEwm,
  509. .cash-withdrawal .wrapper .list .item .pictrue {
  510. width: 140rpx;
  511. height: 140rpx;
  512. border-radius: 3rpx;
  513. position: relative;
  514. margin-right: 23rpx;
  515. }
  516. .cash-withdrawal .wrapper .list .item .picEwm image {
  517. width: 100%;
  518. height: 100%;
  519. border-radius: 3rpx;
  520. }
  521. .cash-withdrawal .wrapper .list .item .picEwm .icon-guanbi1 {
  522. position: absolute;
  523. right: -14rpx;
  524. top: -16rpx;
  525. font-size: 40rpx;
  526. }
  527. .cash-withdrawal .wrapper .list .item .pictrue {
  528. border: 1px solid rgba(221, 221, 221, 1);
  529. font-size: 22rpx;
  530. color: #BBBBBB;
  531. }
  532. .cash-withdrawal .wrapper .list .item .pictrue .icon-icon25201 {
  533. font-size: 47rpx;
  534. color: #DDDDDD;
  535. margin-bottom: 3px;
  536. }
  537. .cash-withdrawal .wrapper .list .tip {
  538. font-size: 26rpx;
  539. color: #999;
  540. margin-top: 25rpx;
  541. }
  542. .cash-withdrawal .wrapper .list .bnt {
  543. font-size: 32rpx;
  544. color: #fff;
  545. width: 690rpx;
  546. height: 90rpx;
  547. text-align: center;
  548. border-radius: 50rpx;
  549. line-height: 90rpx;
  550. margin: 64rpx auto;
  551. }
  552. .cash-withdrawal .wrapper .list .tip2 {
  553. font-size: 26rpx;
  554. color: #999;
  555. text-align: center;
  556. margin: 44rpx 0 20rpx 0;
  557. }
  558. .cash-withdrawal .wrapper .list .value {
  559. height: 135rpx;
  560. line-height: 135rpx;
  561. border-bottom: 1rpx solid #eee;
  562. width: 690rpx;
  563. margin: 0 auto;
  564. }
  565. .cash-withdrawal .wrapper .list .value input {
  566. font-size: 80rpx;
  567. color: #282828;
  568. height: 135rpx;
  569. text-align: center;
  570. }
  571. .cash-withdrawal .wrapper .list .value .placeholder2 {
  572. color: #bbb;
  573. }
  574. .price {
  575. color: var(--view-priceColor);
  576. }
  577. </style>