account.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <template>
  2. <view class="content">
  3. <uni-notice-bar single="true" text="每月25~28号可提现上月结算收益"></uni-notice-bar>
  4. <view class="withdrawal-money">
  5. <view class="icon">{{ money }}</view>
  6. <text class="text">可提现金额</text>
  7. </view>
  8. <view class="navbar">
  9. <view v-for="(item, index) in navList" :key="index" class="nav-item"
  10. :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  11. </view>
  12. <swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
  13. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  14. <view class="row b-b">
  15. <text class="tit">姓名</text>
  16. <input class="input" v-model="tabItem.orderList.name" type="text" placeholder="提款人姓名"
  17. placeholder-class="placeholder" />
  18. </view>
  19. <view class="row b-b" v-if="tabIndex==0">
  20. <text class="tit">账号</text>
  21. <input class="input" v-model="tabItem.orderList.code" type="text" placeholder="请输入账号"
  22. placeholder-class="placeholder" />
  23. </view>
  24. <view class="row b-b" v-if="tabIndex==1">
  25. <text class="tit">银行卡号</text>
  26. <input class="input" v-model="tabItem.orderList.code" type="text" placeholder="请输入银行卡号"
  27. placeholder-class="placeholder" />
  28. </view>
  29. <view class="row b-b" v-if="tabIndex==2">
  30. <text class="tit">微信号</text>
  31. <input class="input" v-model="tabItem.orderList.code" type="text" placeholder="请输入微信号"
  32. placeholder-class="placeholder" />
  33. </view>
  34. <view class="row b-b" v-if="tabIndex == 1">
  35. <text class="tit">所属银行</text>
  36. <input class="input" v-model="tabItem.orderList.bankName" type="text" placeholder="请输入所属银行"
  37. placeholder-class="placeholder" />
  38. </view>
  39. <view class="row b-b">
  40. <text class="tit">电话号码</text>
  41. <input class="input" v-model="tabItem.orderList.phone" type="text" placeholder="请输入电话号码"
  42. placeholder-class="placeholder" />
  43. </view>
  44. <view class="row-box">
  45. <view class="title">提现金额</view>
  46. <view class="row">
  47. <text class="tit">¥</text>
  48. <input class="input" type="number" v-model="withdrawal" :placeholder="'提现金额不得少于'+minPrice+'元'"
  49. placeholder-class="placeholder" />
  50. <view class="buttom" @click="withdrawalAll">全部提现</view>
  51. </view>
  52. </view>
  53. </swiper-item>
  54. </swiper>
  55. <button class="add-btn up" @click="confirm">提交申请</button>
  56. </view>
  57. </template>
  58. <script>
  59. import {
  60. aliInfo,
  61. bankInfo,
  62. setAliInfo,
  63. setBankInfo,
  64. extractBank,
  65. extractCash
  66. } from '@/api/wallet.js';
  67. import {
  68. getMoneyStyle
  69. } from '@/utils/rocessor.js';
  70. import uniNoticeBar from '@/components/uni-notice-bar/uni-notice-bar.vue';
  71. export default {
  72. filters: {
  73. getMoneyStyle
  74. },
  75. components: {
  76. uniNoticeBar
  77. },
  78. data() {
  79. return {
  80. type: 'alipay', //提现方式
  81. withdrawal: '', //提现金额
  82. minPrice: '', //最少提现金额
  83. money: '0.00', //可提现金额
  84. freeze: '0.0', //冻结金额
  85. tabCurrentIndex: 0,
  86. navList: [{
  87. state: 0,
  88. text: '支付宝',
  89. loadingType: 'more',
  90. orderList: {
  91. name: '',
  92. code: '',
  93. id: '',
  94. phone: ''
  95. }
  96. },
  97. {
  98. state: 1,
  99. text: '银行卡',
  100. loadingType: 'more',
  101. orderList: {
  102. name: '',
  103. code: '',
  104. bankName: '',
  105. id: '',
  106. phone: ''
  107. }
  108. },
  109. {
  110. state: 2,
  111. text: '微信',
  112. loadingType: 'more',
  113. orderList: {
  114. name: '',
  115. code: '',
  116. id: ''
  117. }
  118. }
  119. ]
  120. };
  121. },
  122. onLoad(options) {
  123. this.loadData();
  124. },
  125. watch: {
  126. tabCurrentIndex(newValue, oldValue) {
  127. console.log(newValue);
  128. if (newValue == 0) {
  129. this.type = 'alipay'
  130. }
  131. if (newValue == 1) {
  132. this.type = 'bank'
  133. }
  134. if (newValue == 2) {
  135. this.type = 'weixin'
  136. }
  137. console.log(this.type);
  138. }
  139. },
  140. methods: {
  141. // 加载余额信息
  142. async loadData() {
  143. extractBank({}).then(({
  144. data
  145. }) => {
  146. console.log('data.broken_commission', data.broken_commission);
  147. this.money = parseFloat(data.brokerage_price);
  148. this.minPrice = data.minPrice;
  149. this.freeze = data.incommissionCount;
  150. });
  151. },
  152. //swiper 切换
  153. changeTab(e) {
  154. this.tabCurrentIndex = e.target.current;
  155. },
  156. //顶部tab点击
  157. tabClick(index) {
  158. this.tabCurrentIndex = index;
  159. },
  160. // 全部提现
  161. withdrawalAll() {
  162. console.log('点击全部提现');
  163. this.withdrawal = parseInt(this.money / 100) * 100
  164. },
  165. // 提交保存
  166. confirm() {
  167. let obj = this;
  168. if (obj.withdrawal % 100 !== 0) {
  169. this.$api.msg('提现金额不得少于100元');
  170. return
  171. } else {
  172. // 获取当前选中的对象
  173. let arr = obj.navList[obj.tabCurrentIndex].orderList;
  174. let data = {
  175. extract_type: this.type, //bank -银行卡 alipay-支付宝 weixin-微信
  176. money: this.withdrawal, //金额
  177. money_type: 0, //0佣金1余额
  178. name: arr.name,
  179. phone: arr.phone
  180. };
  181. // 判断是否为支付宝
  182. if (obj.tabCurrentIndex == 0) {
  183. if (arr.code == '') {
  184. this.$api.msg('必须填写支付宝账号');
  185. return;
  186. }
  187. data.alipay_code = arr.code;
  188. }
  189. // 判断是否为银行卡
  190. if (obj.tabCurrentIndex == 1) {
  191. if (arr.code == '') {
  192. this.$api.msg('必须填写银行卡账号');
  193. return;
  194. }
  195. if (arr.bankName == '') {
  196. this.$api.msg('必须填写所属银行');
  197. return;
  198. }
  199. data.bankname = arr.bankName;
  200. data.cardnum = arr.code;
  201. }
  202. // 判断是否微信
  203. if (obj.tabCurrentIndex == 2) {
  204. if (arr.code == '') {
  205. this.$api.msg('必须填写微信账号');
  206. return;
  207. }
  208. data.weixin = arr.code;
  209. }
  210. if (arr.name == '') {
  211. this.$api.msg('必须填写姓名');
  212. return;
  213. }
  214. if (arr.phone == '') {
  215. this.$api.msg('必须填写电话号码');
  216. return;
  217. }
  218. if (this.withdrawal < this.minPrice) {
  219. this.$api.msg('提现金额必须大于' + this.minPrice);
  220. return;
  221. }
  222. uni.showModal({
  223. title: '提示',
  224. content: '请仔细查看银行卡号和支付宝账号无误并与本人名称一致,商家会在1-3个工作日转账至您本人账户',
  225. success: function(res) {
  226. if (res.confirm) {
  227. console.log('用户点击确定');
  228. extractCash(data)
  229. .then(e => {
  230. uni.showToast({
  231. title: '提交成功',
  232. duration: 2000,
  233. position: 'top'
  234. });
  235. uni.navigateTo({
  236. url: '/pages/award/award'
  237. });
  238. })
  239. .catch(e => {
  240. console.log();
  241. });
  242. } else if (res.cancel) {
  243. console.log('用户点击取消');
  244. }
  245. },
  246. fail: function(err) {
  247. console.log(err)
  248. }
  249. });
  250. }
  251. },
  252. /* 保存银行卡详细 */
  253. setBankInfo(obj) {
  254. setBankInfo(obj)
  255. .then(e => {
  256. uni.showToast({
  257. title: '修改成功',
  258. duration: 2000,
  259. position: 'top'
  260. });
  261. this.$api.prePage().dataUp();
  262. })
  263. .catch(e => {
  264. console.log(e);
  265. });
  266. },
  267. // 修改支付宝信息
  268. setAliInfo(obj) {
  269. setAliInfo(obj)
  270. .then(e => {
  271. uni.showToast({
  272. title: '修改成功',
  273. duration: 2000,
  274. position: 'top'
  275. });
  276. this.$api.prePage().dataUp();
  277. })
  278. .catch(e => {
  279. console.log(e);
  280. });
  281. }
  282. }
  283. };
  284. </script>
  285. <style lang="scss">
  286. .row {
  287. display: flex;
  288. align-items: center;
  289. position: relative;
  290. padding: 0 30rpx;
  291. height: 110rpx;
  292. background: #fff;
  293. .tit {
  294. flex-shrink: 0;
  295. width: 130rpx;
  296. font-size: 30rpx;
  297. color: $font-color-dark;
  298. }
  299. .input {
  300. flex: 1;
  301. font-size: 30rpx;
  302. color: $font-color-dark;
  303. }
  304. .iconlocation {
  305. font-size: 36rpx;
  306. color: $font-color-light;
  307. }
  308. }
  309. page,
  310. .content {
  311. background: $page-color-base;
  312. height: 100%;
  313. }
  314. .withdrawal-money {
  315. text-align: center;
  316. padding: 20rpx 0;
  317. background: #fff;
  318. margin: 20rpx 0;
  319. .icon {
  320. background-size: 100%;
  321. font-size: 42rpx;
  322. color: $font-color-dark;
  323. font-weight: bold;
  324. background-repeat: no-repeat;
  325. background-position: center;
  326. }
  327. .text {
  328. font-size: 28rpx;
  329. color: #666666;
  330. }
  331. }
  332. .swiper-box {
  333. height: 750rpx;
  334. }
  335. .navbar {
  336. display: flex;
  337. height: 40px;
  338. padding: 0 5px;
  339. background: #fff;
  340. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  341. position: relative;
  342. z-index: 10;
  343. .nav-item {
  344. flex: 1;
  345. display: flex;
  346. justify-content: center;
  347. align-items: center;
  348. height: 100%;
  349. font-size: 15px;
  350. color: $font-color-dark;
  351. position: relative;
  352. &.current {
  353. color: #FF0000;
  354. &:after {
  355. content: '';
  356. position: absolute;
  357. left: 50%;
  358. bottom: 0;
  359. transform: translateX(-50%);
  360. width: 44px;
  361. height: 0;
  362. border-bottom: 2px solid #fc2a3f;
  363. }
  364. }
  365. }
  366. }
  367. .add-btn {
  368. &.up {
  369. background-color: $base-color;
  370. color: #fff;
  371. }
  372. display: flex;
  373. align-items: center;
  374. justify-content: center;
  375. width: 690rpx;
  376. height: 80rpx;
  377. margin: 0 auto;
  378. margin-top: 30rpx;
  379. font-size: $font-lg;
  380. border-radius: 10rpx;
  381. background: linear-gradient(0deg, rgba(250, 39, 64, 1), rgba(254, 85, 68, 1));
  382. border-radius: 40px;
  383. // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  384. }
  385. .row-box {
  386. margin-top: 30rpx;
  387. padding: 20rpx 30rpx;
  388. background: #fff;
  389. .title {
  390. font-size: $font-base + 2rpx;
  391. color: $font-color-dark;
  392. }
  393. .row {
  394. display: flex;
  395. align-items: center;
  396. position: relative;
  397. height: 80rpx;
  398. .tit {
  399. flex-shrink: 0;
  400. width: 40rpx;
  401. font-size: 30rpx;
  402. color: $font-color-dark;
  403. }
  404. .input {
  405. flex: 1;
  406. font-size: 30rpx;
  407. color: $font-color-dark;
  408. }
  409. .iconlocation {
  410. font-size: 36rpx;
  411. color: $font-color-light;
  412. }
  413. .buttom {
  414. color: #FF0000;
  415. // bgccolor: pink;
  416. font-size: $font-base;
  417. }
  418. }
  419. }
  420. </style>