withdraw.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. <template>
  2. <view class="apply-box">
  3. <Navbar title="提出" background-color="#fff" color="#333"></Navbar>
  4. <view class="container">
  5. <view class="withdraw">
  6. <!-- <view class="service-charge">
  7. {{charges || ""}}
  8. </view> -->
  9. <view class="title">请输入金额(元)每日可提1次,每次最低100。</view>
  10. <view class="num">
  11. <!-- <image :src="static ? static + 'diamonds.png' : ''" class="img" mode="widthFix"></image> -->
  12. <input type="number" class="input" placeholder="点击输入" v-model="num">
  13. </view>
  14. <view class="total">
  15. <view class="left">
  16. 可提出金额:{{balance}}元
  17. </view>
  18. <view class="right" @click="handleAll">
  19. 全部
  20. </view>
  21. </view>
  22. </view>
  23. <view class="type">
  24. <view class="left">收款账户</view>
  25. <view class="right" @click="handleSelect">
  26. {{currentType ? typeMap[currentType] : '未选择'}}
  27. <IconText :code="`\ue84a`" color="#999" class="icon" :size="12"></IconText>
  28. </view>
  29. </view>
  30. <!-- <view class="code" v-if="currentType === 1 || currentType === 2">
  31. <view class="top">
  32. 收款人姓名<view class="text" @click="toCode">{{name || '未录入'}}
  33. <Icon :code="`\ue75d`" color="#999" class="icon" :size="12"></Icon>
  34. </view>
  35. </view>
  36. <image v-if="codePic" :src="codePic" class="img" mode="widthFix"></image>
  37. <view class="empty-img" v-else>
  38. </view>
  39. </view>
  40. <view class="card" v-if="currentType === 3">
  41. <view class="add" @click="toCard" v-if="!datumInfo.bank_card">
  42. <Icon :code="`\ue64e`" color="#333" class="icon" :size="40"></Icon>
  43. 添加提现银行卡
  44. </view>
  45. <view class="card-info" v-else>
  46. <view class="top">
  47. <text>{{datumInfo.bank}}</text>
  48. <text>{{datumInfo.bank_card | cardFormat}}</text>
  49. </view>
  50. <view class="bottom">
  51. <view class="update" @click="updateCard">
  52. <Icon :code="`\ue6c3`" color="#333" class="icon" :size="40"></Icon>
  53. 更换
  54. </view>
  55. </view>
  56. </view>
  57. </view> -->
  58. <!-- <view class="record" @click="toRecord">
  59. 寄售记录
  60. </view> -->
  61. </view>
  62. <view class="bottom-btn-box">
  63. <view class="bottom-btn" @click="handleWithdraw">确认提交</view>
  64. </view>
  65. <uni-popup ref="type" type="center">
  66. <view class="select-type">
  67. <view class="title">
  68. 选择寄售方式
  69. </view>
  70. <view class="type-list">
  71. <view class="item" v-for="item in typeList" :key="item.value" @click="changeType(item.value)">
  72. {{item.label}}
  73. <!-- <view class="" v-if="item.value === type"> -->
  74. <Icon :code="`\ue754`" :color="item.value === type ? '#FFDE4C' : '#DEDEDE'" class="icon"
  75. :size="16"></Icon>
  76. <!-- </view> -->
  77. </view>
  78. </view>
  79. <view class="btn-box" @click="confirmSelect">
  80. 确定
  81. </view>
  82. </view>
  83. </uni-popup>
  84. <Password ref="password" @finish="passwordFinish"></Password>
  85. </view>
  86. </template>
  87. <script lang="ts">
  88. import {
  89. Component,
  90. Prop,
  91. Vue
  92. } from 'vue-property-decorator';
  93. import {
  94. OSS_STATIC
  95. } from '@/common/constants';
  96. import {
  97. namespace,
  98. } from 'vuex-class';
  99. import {
  100. types
  101. } from '@/common/store';
  102. const baseModule = namespace('base');
  103. @Component({
  104. filters: {
  105. cardFormat(val: any) {
  106. if (!+val) return '****';
  107. let format = val.substring(val.length - 4);
  108. return '****' + format;
  109. }
  110. }
  111. })
  112. export default class Apply extends Vue {
  113. @baseModule.Mutation(types.SET_USERINFO) setUserInfo: any;
  114. @baseModule.Getter('_userInfo') userInfo: any;
  115. static: string = OSS_STATIC;
  116. num: any = null;
  117. type: any = null;
  118. codePic: string = "";
  119. name: string = "";
  120. datumInfo: any = {};
  121. currentType: any = null;
  122. charges: any = 0;
  123. typeList: any = [{
  124. label: '微信收款',
  125. value: 1,
  126. },
  127. {
  128. label: '支付宝收款',
  129. value: 2,
  130. },
  131. {
  132. label: '银行卡收款',
  133. value: 3,
  134. }
  135. ];
  136. typeMap: any = {
  137. 1: '微信收款',
  138. 2: '支付宝收款',
  139. 3: '银行卡收款'
  140. };
  141. balance: any = null;
  142. onLoad() {
  143. uni.setNavigationBarColor({
  144. frontColor: '#000000', //文字颜色
  145. backgroundColor: '#000000' //底部背景色
  146. });
  147. }
  148. onShow() {
  149. this.currentType = +uni.getStorageSync('currentType') || null;
  150. this.getUserInfo();
  151. this.getBalance();
  152. }
  153. getUserInfo() {
  154. uni.showLoading({
  155. title: '加载中',
  156. });
  157. this.$http.get({
  158. url: this.$api.getUserInfo,
  159. data: {}
  160. }).then((res: any) => {
  161. uni.hideLoading();
  162. this.setUserInfo({
  163. ...res,
  164. ...res.info
  165. });
  166. })
  167. }
  168. getBalance() {
  169. uni.showLoading({
  170. title: '加载中',
  171. });
  172. this.$http.get({
  173. url: this.$api.getBalance,
  174. data: {}
  175. }).then((res: any) => {
  176. this.balance = res.balance;
  177. this.setInfo(this.type);
  178. uni.hideLoading();
  179. })
  180. }
  181. handleAll() {
  182. this.num = this.balance;
  183. }
  184. changeType(type: any) {
  185. this.type = type;
  186. }
  187. setInfo(type: any) {
  188. if (type === 1) {
  189. this.name = this.datumInfo.wx_name;
  190. this.codePic = this.datumInfo.wx_pic;
  191. } else if (type === 2) {
  192. this.name = this.datumInfo.zfb_name;
  193. this.codePic = this.datumInfo.zfb_pic;
  194. } else {
  195. this.name = "";
  196. this.codePic = "";
  197. }
  198. }
  199. confirmSelect() {
  200. this.currentType = this.type;
  201. this.setInfo(this.currentType);
  202. (this.$refs.type as any).close();
  203. }
  204. handleSelect() {
  205. // this.type = this.currentType;
  206. // (this.$refs.type as any).open('bottom');
  207. this.$Router.push({
  208. path: '/packages/user/fund/withdraw-type',
  209. })
  210. }
  211. handleWithdraw() {
  212. if (!this.num) {
  213. uni.showToast({
  214. icon: 'none',
  215. title: '请填写金额'
  216. })
  217. return;
  218. }
  219. if (!this.currentType) {
  220. uni.showToast({
  221. icon: 'none',
  222. title: '请先选择方式'
  223. })
  224. return;
  225. }
  226. (this.$refs.password as any).open();
  227. }
  228. passwordFinish(val: any) {
  229. this.withDraw(val);
  230. }
  231. withDraw(safe: any) {
  232. uni.showLoading({
  233. title: '加载中',
  234. });
  235. this.$http.post({
  236. url: this.$api.withdraw,
  237. data: {
  238. balance: +this.num,
  239. way: this.currentType,
  240. safe: safe,
  241. }
  242. }).then(() => {
  243. uni.hideLoading();
  244. uni.showToast({
  245. icon: 'none',
  246. title: '申请成功'
  247. });
  248. })
  249. }
  250. toRecord() {
  251. this.$Router.push({
  252. path: '/pages/withdraw/record',
  253. })
  254. }
  255. toCard() {
  256. this.$Router.push({
  257. path: '/pages/withdraw/card',
  258. })
  259. }
  260. updateCard() {
  261. this.$Router.push({
  262. path: '/pages/withdraw/card',
  263. query: {
  264. card: this.datumInfo.bank_card,
  265. bank: this.datumInfo.bank,
  266. name: this.datumInfo.bank_name
  267. }
  268. })
  269. }
  270. toCode() {
  271. this.$Router.push({
  272. path: '/pages/withdraw/code',
  273. query: {
  274. type: this.currentType,
  275. name: this.name,
  276. pic: this.codePic
  277. }
  278. })
  279. }
  280. }
  281. </script>
  282. <style lang="scss" scoped>
  283. .apply-box {
  284. background: #F8F8F8;
  285. min-height: 100vh;
  286. padding-bottom: vw(80);
  287. box-sizing: border-box;
  288. .container {
  289. width: 100%;
  290. padding: 0 vw(10);
  291. @include flex-y();
  292. box-sizing: border-box;
  293. }
  294. .withdraw {
  295. width: 100%;
  296. background: #fff;
  297. margin-top: vw(10);
  298. border-radius: vw(10);
  299. overflow: hidden;
  300. .service-charge{
  301. height: vw(24);
  302. @include flex-x(center);
  303. background: linear-gradient(115.71deg, rgba(219, 230, 252, 1) 0%, rgba(250, 237, 250, 1) 100%);
  304. @include word-vw(12, #F07F90);
  305. }
  306. .title {
  307. height: vw(40);
  308. line-height: vw(40);
  309. padding: 0 vw(14);
  310. @include word-vw(12, #333);
  311. }
  312. .num {
  313. height: vw(80);
  314. border-top: vw(1) solid #F8F8F8;
  315. border-bottom: vw(1) solid #F8F8F8;
  316. @include flex-x(flex-start, center);
  317. padding: 0 vw(8);
  318. .img {
  319. width: vw(32);
  320. }
  321. .input {
  322. font-size: vw(20);
  323. margin-left: vw(20);
  324. }
  325. }
  326. .total {
  327. height: vw(40);
  328. line-height: vw(40);
  329. padding: 0 vw(14);
  330. @include flex-x(space-between);
  331. .left {
  332. @include word-vw(13, #B0ACAC);
  333. }
  334. .right {
  335. @include word-vw(13, #FA6C28);
  336. }
  337. }
  338. }
  339. .type {
  340. height: vw(64);
  341. width: 100%;
  342. margin-top: vw(10);
  343. background: #fff;
  344. border-radius: vw(5);
  345. padding: 0 vw(14);
  346. box-sizing: border-box;
  347. @include flex-x(space-between);
  348. .left {
  349. @include word-vw(16, #333);
  350. font-weight: 600;
  351. }
  352. .right {
  353. @include word-vw(16, #999);
  354. @include flex-x();
  355. .icon {
  356. margin-left: vw(3);
  357. }
  358. }
  359. }
  360. .code {
  361. width: 100%;
  362. height: vw(280);
  363. background: #fff;
  364. @include flex-y(center);
  365. margin-top: vw(1);
  366. .top {
  367. @include word-vw(14, #333);
  368. @include flex-x();
  369. .text {
  370. @include word-vw(14, #999);
  371. margin-left: vw(8);
  372. @include flex-x();
  373. .icon {
  374. margin-left: vw(1);
  375. }
  376. }
  377. }
  378. .img {
  379. width: vw(148);
  380. height: vw(148);
  381. margin-top: vw(24);
  382. }
  383. .empty-img {
  384. width: vw(148);
  385. height: vw(148);
  386. margin-top: vw(24);
  387. background: #E8E8E8;
  388. }
  389. }
  390. .card {
  391. width: 100%;
  392. height: vw(180);
  393. background: linear-gradient(115.71deg, rgba(219, 230, 252, 1) 0%, rgba(250, 237, 250, 1) 100%);
  394. border-radius: vw(8);
  395. margin-top: vw(10);
  396. @include flex-x(center);
  397. .add {
  398. @include word-vw(14, #333);
  399. @include flex-y();
  400. .icon {
  401. margin-bottom: vw(8);
  402. }
  403. }
  404. .card-info {
  405. height: 100%;
  406. width: 100%;
  407. padding: vw(12) vw(24);
  408. box-sizing: border-box;
  409. @include flex-y(space-between);
  410. .top {
  411. width: 100%;
  412. @include flex-x(space-between);
  413. }
  414. .bottom {
  415. width: 100%;
  416. @include flex-x(flex-end);
  417. .update {
  418. @include flex-y(space-between);
  419. .icon {
  420. margin-bottom: vw(8);
  421. }
  422. }
  423. }
  424. }
  425. }
  426. .record {
  427. width: 100%;
  428. text-align: center;
  429. @include word-vw(12, #807E7E);
  430. margin-top: vw(20);
  431. text-decoration: underline;
  432. }
  433. .bottom-btn-box {
  434. height: vw(70);
  435. width: 100%;
  436. background: #fff;
  437. @include flex-x(center);
  438. position: fixed;
  439. bottom: 0;
  440. .bottom-btn {
  441. width: vw(335);
  442. height: vw(50);
  443. background: $btn-color;
  444. border-radius: vw(10);
  445. @include word-vw(16, #fff);
  446. @include flex-x(center);
  447. }
  448. }
  449. }
  450. .select-type {
  451. height: vw(280);
  452. background: #fff;
  453. border-top-left-radius: vw(10);
  454. border-top-right-radius: vw(10);
  455. @include flex-y();
  456. .title {
  457. height: vw(54);
  458. line-height: vw(54);
  459. text-align: center;
  460. @include word-vw(14, #999);
  461. }
  462. .type-list {
  463. flex: 1;
  464. width: 100%;
  465. @include flex-y(center);
  466. .item {
  467. height: vw(48);
  468. width: 100%;
  469. padding: 0 vw(24);
  470. box-sizing: border-box;
  471. @include flex-x(space-between);
  472. }
  473. }
  474. .btn-box {
  475. width: 100%;
  476. height: vw(56);
  477. @include flex-x(center);
  478. border-top: vw(1) solid #DEDEDE;
  479. }
  480. }
  481. </style>