account.vue 8.8 KB

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