金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

372 lines
9.9 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <template>
  2. <view>
  3. <lf-nav title="提现" :showIcon="true" bgColor="#fff"></lf-nav>
  4. <view class="tabs">
  5. <view class="tab" v-for="(item, index) in tab_list" :key="index">
  6. <view class="name"
  7. :class="{'active-tab': current == index}"
  8. @click="switchTab(index)">{{ item }}
  9. </view>
  10. </view>
  11. </view>
  12. <view class="content">
  13. <!-- 店铺信息 -->
  14. <view class="card">
  15. <view class="lf-flex">
  16. <image class="shop-avatar" mode="widthFix" :src="brand.logo"></image>
  17. <view class="shop-name">{{ brand.name }}</view>
  18. </view>
  19. </view>
  20. <!-- 收款信息 - 提现到支付宝 -->
  21. <view class="card" v-if="current == 0">
  22. <view class="lf-font-28 lf-color-222">支付宝姓名</view>
  23. <view class="list">
  24. <view class="lf-flex">
  25. <input class="input" placeholder="请输入您的姓名" v-model="alipay_name" />
  26. </view>
  27. <view class="clear" v-if="alipay_name.length" @click="alipay_name = ''">
  28. <text class="lf-iconfont icon-cuo1"></text>
  29. </view>
  30. </view>
  31. <view class="lf-font-28 lf-color-222 lf-m-t-50">支付宝账号</view>
  32. <view class="list">
  33. <view class="lf-flex">
  34. <input class="input" placeholder="请输入支付宝账号" v-model="alipay_account" />
  35. </view>
  36. <view class="clear" v-if="alipay_account.length" @click="alipay_account = ''">
  37. <text class="lf-iconfont icon-cuo1"></text>
  38. </view>
  39. </view>
  40. </view>
  41. <!-- 收款信息 - 提现到银行卡 -->
  42. <view class="card" v-else-if="current == 1">
  43. <view class="lf-font-28 lf-color-222">银行名称</view>
  44. <view class="list">
  45. <view class="lf-flex">
  46. <input class="input" placeholder="请输入您的银行名称" v-model="bank_name" />
  47. </view>
  48. <view class="clear" v-if="bank_name.length" @click="bank_name = ''">
  49. <text class="lf-iconfont icon-cuo1"></text>
  50. </view>
  51. </view>
  52. <view class="lf-font-28 lf-color-222 lf-m-t-50">所属支行</view>
  53. <view class="list">
  54. <view class="lf-flex">
  55. <input class="input" placeholder="请输入银行卡所属支行" v-model="bank_sub_branch" />
  56. </view>
  57. <view class="clear" v-if="bank_sub_branch.length" @click="bank_sub_branch = ''">
  58. <text class="lf-iconfont icon-cuo1"></text>
  59. </view>
  60. </view>
  61. <view class="lf-font-28 lf-color-222 lf-m-t-50">银行卡号</view>
  62. <view class="list">
  63. <view class="lf-flex">
  64. <input class="input" placeholder="请输入银行卡号码" v-model="bank_number" />
  65. </view>
  66. <view class="clear" v-if="bank_number.length" @click="bank_number = ''">
  67. <text class="lf-iconfont icon-cuo1"></text>
  68. </view>
  69. </view>
  70. <view class="lf-font-28 lf-color-222 lf-m-t-50">开户名</view>
  71. <view class="list">
  72. <view class="lf-flex">
  73. <input class="input" placeholder="请输入银行卡开户名" v-model="bank_account_name" />
  74. </view>
  75. <view class="clear" v-if="bank_account_name.length" @click="bank_account_name = ''">
  76. <text class="lf-iconfont icon-cuo1"></text>
  77. </view>
  78. </view>
  79. </view>
  80. <!-- 提现金额 -->
  81. <view class="card">
  82. <view class="lf-font-28 lf-color-222">
  83. <text class="lf-m-r-10">提现金额</text>
  84. <text class="lf-font-24">(当前可用余额{{ balance }})</text>
  85. </view>
  86. <view class="list money-list">
  87. <view class="lf-flex">
  88. <view class="symbol"></view>
  89. <input class="input" type="number" v-model="money" />
  90. </view>
  91. <view class="clear" v-if="money.length" @click="money = ''">
  92. <text class="lf-iconfont icon-cuo1"></text>
  93. </view>
  94. </view>
  95. <view class="lf-font-28 lf-m-t-30" style="color: #F63434;" v-if="isMoney">输入金额超过可用余额</view>
  96. </view>
  97. <!-- 提现说明 -->
  98. <view class="card" v-if="remark.length">
  99. <view class="lf-font-28 lf-color-555 lf-m-b-20">提现说明</view>
  100. <view class="lf-font-28 lf-color-222">
  101. <view v-for="(item, index) in remark" :key="index">{{ item }}</view>
  102. </view>
  103. </view>
  104. <button class="confirm" hover-class="lf-opacity" @click="confirm">确认提现</button>
  105. </view>
  106. </view>
  107. </template>
  108. <script>
  109. export default {
  110. data(){
  111. return {
  112. tab_list: ['支付宝', '银行卡'],
  113. current: 0, // 支付宝0、银行卡1
  114. alipay_name: '', // 支付宝姓名
  115. alipay_account: '', // 支付宝账号
  116. bank_name: '', // 银行名称
  117. bank_sub_branch: '', // 银行卡所属支行
  118. bank_number: '', // 银行卡号
  119. bank_account_name: '', // 银行卡开户名
  120. money: '', // 提现金额
  121. token: '',
  122. remark: [], // 提现说明
  123. brand: {}, // 商家信息
  124. balance: 0, // 当前可用余额
  125. button_click: false
  126. }
  127. },
  128. computed: {
  129. isMoney(){
  130. return Number(this.money) > this.balance;
  131. }
  132. },
  133. onLoad(){
  134. let token = this.$cookieStorage.get('store_token');
  135. this.token = token;
  136. this.getApplyInfo();
  137. },
  138. methods: {
  139. // 提现申请信息获取
  140. getApplyInfo(){
  141. this.$http.get({
  142. api: 'api/supplier/apply_info',
  143. header: {
  144. token: this.token
  145. }
  146. }).then(res => {
  147. this.balance = res.data.data.balance;
  148. this.brand = res.data.data.brand;
  149. this.remark = res.data.data.remark;
  150. })
  151. },
  152. // 切换tab
  153. switchTab(index){
  154. this.current = index;
  155. },
  156. confirm(){
  157. if(this.current == 0){
  158. // 提现到支付宝
  159. if(!this.alipay_name) return this.$msg('请输入支付宝姓名');
  160. if(!this.alipay_account) return this.$msg('请输入支付宝账号');
  161. if(!this.money) return this.$msg('请输入提现金额');
  162. if(this.isMoney) return this.$msg('提现金额超出当前余额');
  163. if(this.money <= 0) return this.$msg('提现金额需大于0');
  164. this.launch('alipay');
  165. }else if(this.current == 1){
  166. // 提现到银行卡
  167. if(!this.bank_name) return this.$msg('请输入银行名称');
  168. if(!this.bank_sub_branch) return this.$msg('请输入银行卡所属支行');
  169. if(!this.bank_number) return this.$msg('请输入银行卡号');
  170. if(!this.bank_account_name) return this.$msg('请输入银行卡开户名');
  171. if(!this.money) return this.$msg('请输入提现金额');
  172. if(this.isMoney) return this.$msg('提现金额超出当前余额');
  173. if(this.money <= 0) return this.$msg('提现金额需大于0');
  174. this.launch('bankcard');
  175. }
  176. },
  177. launch(type_name){
  178. if(this.button_click) return;
  179. this.button_click = true;
  180. uni.showLoading({
  181. title: '正在提现中'
  182. })
  183. let par = {
  184. type: type_name,
  185. value: this.money
  186. };
  187. if(type_name == 'bankcard'){
  188. par.bank_name = this.bank_name;
  189. par.bank_branch = this.bank_sub_branch;
  190. par.bank_number = this.bank_number;
  191. par.bank_username = this.bank_account_name;
  192. }else if(type_name == 'alipay'){
  193. par.alipay_name = this.alipay_name;
  194. par.alipay_account = this.alipay_account;
  195. }
  196. this.$http.post({
  197. api: 'api/supplier/cash_apply',
  198. data: par,
  199. header: {
  200. token: this.token
  201. }
  202. }).then(res => {
  203. if(res.data.code == 200){
  204. if(type_name == 'bankcard'){
  205. this.bank_name = '';
  206. this.bank_sub_branch = '';
  207. this.bank_number = '';
  208. this.bank_account_name = '';
  209. }else if(type_name == 'alipay'){
  210. this.alipay_name = '';
  211. this.alipay_account = '';
  212. }
  213. this.money = '';
  214. this.$msg('提现成功', {icon: 'success', duration: 2500});
  215. this.getApplyInfo();
  216. }else{
  217. this.$msg('提现失败', {icon: 'error'});
  218. }
  219. this.button_click = false;
  220. uni.hideLoading();
  221. }).catch(err => {
  222. this.button_click = false;
  223. uni.hideLoading();
  224. });
  225. }
  226. }
  227. }
  228. </script>
  229. <style>
  230. page{
  231. background-color: #F8F8F8;
  232. }
  233. </style>
  234. <style lang="scss" scoped="scoped">
  235. .tabs{
  236. height: 80rpx;
  237. width: 750rpx;
  238. display: flex;
  239. border-bottom: 1rpx solid #e5e5e5;
  240. background-color: #FFFFFF;
  241. align-items: center;
  242. .tab{
  243. width: 50%;
  244. height: 100%;
  245. display: flex;
  246. justify-content: center;
  247. align-items: center;
  248. .name{
  249. width: max-content;
  250. height: 100%;
  251. font-size: 28rpx;
  252. color: #777777;
  253. display: flex;
  254. align-items: center;
  255. }
  256. .active-tab{
  257. color: #0D2E9A;
  258. font-weight: bold;
  259. position: relative;
  260. &::after{
  261. content: '';
  262. position: absolute;
  263. bottom: 0;
  264. left: calc(50% - 40rpx);
  265. width: 80rpx;
  266. height: 10rpx;
  267. background: #0D2E9A;
  268. border-radius: 8rpx 8rpx 0rpx 0rpx;
  269. }
  270. }
  271. }
  272. }
  273. .content{
  274. padding: 30rpx 32rpx;
  275. }
  276. .card{
  277. padding: 30rpx;
  278. box-sizing: border-box;
  279. width: 686rpx;
  280. height: max-content;
  281. background: #FFFFFF;
  282. border-radius: 20rpx;
  283. transition: all 1s;
  284. &:nth-child(n+2){
  285. margin-top: 30rpx;
  286. }
  287. .shop-avatar{
  288. width: 100rpx;
  289. height: 100rpx;
  290. border-radius: 50%;
  291. margin-right: 20rpx;
  292. }
  293. .shop-name{
  294. width: 502rpx;
  295. height: max-content;
  296. font-size: 36rpx;
  297. color: #222222;
  298. font-weight: bold;
  299. }
  300. .list{
  301. height: 90rpx;
  302. width: 100%;
  303. border-bottom: 1rpx solid #e5e5e5;
  304. display: flex;
  305. justify-content: space-between;
  306. align-items: center;
  307. margin-top: 10rpx;
  308. .input{
  309. width: 540rpx;
  310. height: 80rpx;
  311. font-size: 28rpx;
  312. }
  313. .input-code{
  314. width: 430rpx;
  315. }
  316. .clear{
  317. padding: 20rpx;
  318. }
  319. .code{
  320. min-width: 180rpx;
  321. max-width: 220rpx;
  322. height: 64rpx;
  323. padding: 0 4rpx;
  324. font-size: 24rpx;
  325. color: #15716E;
  326. display: flex;
  327. justify-content: center;
  328. align-items: center;
  329. border-radius: 32rpx;
  330. border: 2rpx solid #15716E;
  331. }
  332. .active-bg{
  333. background: #efefef;
  334. }
  335. .symbol{
  336. width: 30rpx;
  337. height: 90rpx;
  338. font-size: 36rpx;
  339. color: #222222;
  340. display: flex;
  341. align-items: flex-end;
  342. }
  343. }
  344. .money-list{
  345. height: 140rpx;
  346. .input{
  347. width: 500rpx;
  348. height: 130rpx;
  349. font-size: 72rpx;
  350. font-weight: bold;
  351. margin-left: 20rpx;
  352. }
  353. }
  354. }
  355. .confirm{
  356. width: 550rpx;
  357. height: 100rpx;
  358. background: #0D2E9A;
  359. border-radius: 50rpx;
  360. color: #FFFFFF;
  361. line-height: 100rpx;
  362. margin-top: 50rpx;
  363. font-size: 32rpx;
  364. }
  365. </style>