cash.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. <template>
  2. <app-layout>
  3. <view class="info">
  4. <view class="last">账户剩余金额:{{money}}元</view>
  5. <view class="last-info">
  6. <view v-if="config.cash_max_day > -1">
  7. <view v-if="config.surplusCash > 0">今日剩余{{custom_setting.words.cash_money.name}}<span class="surplus">{{config.surplusCash?config.surplusCash:config.cash_max_day}}元</span></view>
  8. <view v-else>今日{{custom_setting.words.cash_money.name}}已用尽</view>
  9. </view>
  10. <view v-else>今日{{custom_setting.words.cash_money.name}}无限制</view>
  11. <view @click="visible = !visible">
  12. <button class="show-tip">规则</button>
  13. </view>
  14. </view>
  15. </view>
  16. <view>
  17. <view class="info input-money main-between cross-center">
  18. <view class="input">
  19. <input v-model="moneyInput" type="digit" placeholder-style="color:#cdcdcd"
  20. :placeholder="'请输入' + custom_setting.words.cash_money.name"/>
  21. <view class="price" style="color: #F84469;">¥</view>
  22. </view>
  23. <view @click="getMoney" class="all">全部</view>
  24. </view>
  25. <view class="about" v-if="config.min_money > 0 && config.cash_service_charge > 0">
  26. <view v-if="config.min_money > 0">{{custom_setting.words.cash_money.name}}不能小于{{config.min_money}}元
  27. </view>
  28. <view v-if="config.cash_service_charge > 0">
  29. {{custom_setting.words.cash.name}}需要加收{{config.cash_service_charge}}%手续费
  30. </view>
  31. </view>
  32. <view class="dir-left-nowrap cross-center cash-type" @click="cashTypeModel = true">
  33. <view class="box-grow-1">{{custom_setting.words.cash_type.name}}</view>
  34. <view class="box-grow-0">{{cashName}}</view>
  35. <image class="box-grow-0 arrow-image" src="/static/image/icon/arrow-right.png"></image>
  36. </view>
  37. <view class="cash-info" v-if="mark_num === 1 || mark_num === 2 || mark_num === 3">
  38. <view class="info content">
  39. <view class="enter" v-if="mark_num === 3">开户人</view>
  40. <view class="enter" v-else>姓名</view>
  41. <input placeholder-style="color:#cdcdcd" class="info-input" v-model="name" placeholder="请输入正确的姓名"/>
  42. </view>
  43. <view class="info content" v-if="mark_num === 3">
  44. <view class="enter">开户行</view>
  45. <input placeholder-style="color:#cdcdcd" class="info-input" v-model="bank_name"
  46. placeholder="请输入正确的银行名称"/>
  47. </view>
  48. <view class="info content">
  49. <view class="enter">帐号</view>
  50. <input placeholder-style="color:#cdcdcd" class="info-input" v-model="mobile" v-if="mark_num === 1"
  51. placeholder="请输入正确的微信帐号"/>
  52. <input placeholder-style="color:#cdcdcd" class="info-input" v-model="mobile"
  53. v-else-if="mark_num === 2"
  54. placeholder="请输入正确的支付宝帐号"/>
  55. <input placeholder-style="color:#cdcdcd" class="info-input" v-model="mobile"
  56. v-else-if="mark_num === 3"
  57. type="number" placeholder="请输入正确的银行卡帐号"/>
  58. </view>
  59. </view>
  60. <view class="submit">
  61. <button @click="subscribe" style="background-color: #F84469;">提交申请</button>
  62. </view>
  63. </view>
  64. <app-cash-model
  65. :title="custom_setting.words.cash_type.name"
  66. :is-auto="pay_type.auto"
  67. :is-wx="pay_type.wechat"
  68. :is-alipay="pay_type.alipay"
  69. :is-bank="pay_type.bank"
  70. :is-balance="pay_type.balance"
  71. :pay-type="cashType"
  72. @change="payTypeChange"
  73. v-model="cashTypeModel"
  74. ></app-cash-model>
  75. <view class="bg" v-if="visible">
  76. <view class="dialog">
  77. <view class="dialog-title">提示</view>
  78. <view class="dialog-msg">
  79. 今日剩余{{custom_setting.words.cash_money.name}}=平台每日可{{custom_setting.words.cash_money.name}}-今日所有用户{{custom_setting.words.cash_money.name}}
  80. </view>
  81. <view class="dialog-btn main-center">
  82. <view class="dialog-submit" @click="visible= false">我知道了</view>
  83. </view>
  84. </view>
  85. </view>
  86. </app-layout>
  87. </template>
  88. <script>
  89. import {mapState} from "vuex";
  90. import appCashModel from "../../../components/page-component/app-cash-model/app-cash-model";
  91. export default {
  92. data() {
  93. return {
  94. visible: false,
  95. mark_num: -1,
  96. money: 0,
  97. name: '',
  98. bank_name: '',
  99. mobile: '',
  100. moneyInput: '',
  101. pay_type: {
  102. auto: false,
  103. alipay: false,
  104. wechat: false,
  105. bank: false,
  106. balance: false,
  107. },
  108. config: [],
  109. template_message: [],
  110. cashTypeModel: false,
  111. cashType: '',
  112. loading: false,
  113. }
  114. },
  115. components: {appCashModel,},
  116. computed: {
  117. ...mapState({
  118. mall: state => state.mallConfig.mall,
  119. custom_setting: state => state.mallConfig.share_setting_custom,
  120. share_setting: state => state.mallConfig.share_setting,
  121. }),
  122. cashName() {
  123. switch (this.cashType) {
  124. case 'auto':
  125. // #ifdef MP-WEIXIN
  126. return '微信零钱';
  127. // #endif
  128. // #ifdef MP-ALIPAY
  129. return '支付宝余额';
  130. // #endif
  131. // #ifndef MP-WEIXIN || MP-ALIPAY
  132. return '自动';
  133. // #endif
  134. case 'wx':
  135. return '微信线下打款';
  136. case 'alipay':
  137. return '支付宝线下打款';
  138. case 'bank':
  139. return '银联线下打款';
  140. case 'balance':
  141. return '商城余额';
  142. default:
  143. return;
  144. break;
  145. }
  146. },
  147. },
  148. methods: {
  149. getMoney() {
  150. let money = this.config.surplusCash ? this.config.surplusCash : this.config.cash_max_day;
  151. if (+money < +this.money && +money > -1) {
  152. this.moneyInput = +money;
  153. } else {
  154. this.moneyInput = +this.money;
  155. }
  156. },
  157. payTypeChange(value) {
  158. this.cashType = value;
  159. switch (value) {
  160. case 'auto':
  161. this.mark_num = 0;
  162. break;
  163. case 'wx':
  164. this.mark_num = 1;
  165. break;
  166. case 'alipay':
  167. this.mark_num = 2;
  168. break;
  169. case 'bank':
  170. this.mark_num = 3;
  171. break;
  172. case 'balance':
  173. this.mark_num = 4;
  174. break;
  175. default:
  176. this.mark_num = -1;
  177. break;
  178. }
  179. },
  180. subscribe() {
  181. if (this.mark_num === -1) {
  182. uni.showToast({title: '请选择提现方式', icon: 'none'});
  183. return;
  184. }
  185. if(this.loading) {
  186. return false
  187. }
  188. this.loading = true;
  189. this.$subscribe(this.template_message).then(res => {
  190. this.submit();
  191. }).catch(res => {
  192. this.submit();
  193. });
  194. },
  195. submit() {
  196. let that = this;
  197. let para = {
  198. price: that.moneyInput,
  199. type: 'auto',
  200. };
  201. uni.showLoading({
  202. title: '申请中'
  203. })
  204. if (that.mark_num === 4) {
  205. para.type = 'balance';
  206. } else if (that.mark_num === 0) {
  207. para.type = 'auto';
  208. } else {
  209. para.name = that.name;
  210. para.mobile = that.mobile;
  211. switch (that.mark_num) {
  212. case 1:
  213. para.type = 'wechat';
  214. break;
  215. case 2:
  216. para.type = 'alipay';
  217. break;
  218. case 3:
  219. para.type = 'bank';
  220. para.bank_name = that.bank_name;
  221. break;
  222. }
  223. }
  224. that.$request({
  225. url: that.$api.share.cash,
  226. data: para,
  227. method: 'post',
  228. }).then(response=>{
  229. this.loading = false;
  230. uni.hideLoading();
  231. if(response.code === 0) {
  232. uni.showToast({
  233. title: response.msg,
  234. duration: 1000
  235. });
  236. setTimeout(() => {
  237. uni.redirectTo({
  238. url: '/pages/share/cash-detail/cash-detail'
  239. });
  240. }, 1000);
  241. }else {
  242. uni.showToast({
  243. title: response.msg,
  244. icon: 'none',
  245. duration: 1000
  246. });
  247. }
  248. }).catch(() => {
  249. this.loading = false;
  250. uni.hideLoading();
  251. });
  252. },
  253. setting() {
  254. let that = this;
  255. that.$request({
  256. url: that.$api.share.setting,
  257. }).then(response=>{
  258. that.$hideLoading();
  259. if(response.code === 0) {
  260. that.config = response.msg.config;
  261. that.template_message = response.msg.template_message
  262. for (let i = 0; i < that.config.pay_type.length; i++) {
  263. switch (that.config.pay_type[i]) {
  264. case 'auto':
  265. that.pay_type.auto = true;
  266. break;
  267. case 'alipay':
  268. that.pay_type.alipay = true;
  269. break;
  270. case 'wechat':
  271. that.pay_type.wechat = true;
  272. break;
  273. case 'balance':
  274. that.pay_type.balance = true;
  275. break;
  276. case 'bank':
  277. that.pay_type.bank = true;
  278. break;
  279. }
  280. }
  281. }else {
  282. uni.showToast({
  283. title: response.msg,
  284. icon: 'none',
  285. duration: 1000
  286. });
  287. }
  288. }).catch(() => {
  289. that.$hideLoading();
  290. });
  291. },
  292. },
  293. onLoad(options) {
  294. let that = this;
  295. if (options.money > 0) {
  296. that.money = options.money;
  297. }
  298. that.setting();
  299. uni.setNavigationBarTitle({
  300. title: that.custom_setting.menus.cash.name,
  301. });
  302. }
  303. }
  304. </script>
  305. <style scoped lang="scss">
  306. .cash-type {
  307. height: #{120rpx};
  308. background: white;
  309. color: #353535;
  310. font-size: #{32rpx};
  311. padding: 0 #{24rpx};
  312. margin-top: #{24rpx};
  313. .arrow-image {
  314. width: #{12rpx};
  315. height: #{24rpx};
  316. display: block;
  317. margin-left: #{12rpx};
  318. }
  319. }
  320. .surplus {
  321. margin: 0 #{5rpx};
  322. }
  323. .button-space {
  324. height: #{120rpx};
  325. }
  326. .cash-info {
  327. margin-top: #{20rpx};
  328. margin-bottom: #{120rpx};
  329. }
  330. .cash-info .info.content:last-of-type {
  331. border-bottom: 0;
  332. }
  333. .info.cash-type {
  334. margin-bottom: #{20rpx};
  335. padding: #{32rpx} 0;
  336. border-bottom: 0;
  337. }
  338. .info {
  339. background-color: #fff;
  340. padding: #{32rpx} #{24rpx};
  341. border-bottom: #{1rpx} solid #e2e2e2;
  342. color: #353535;
  343. }
  344. .info.input-money {
  345. border-bottom: 0;
  346. width: 100%;
  347. }
  348. .last {
  349. font-size: #{40rpx};
  350. margin-bottom: #{15rpx};
  351. }
  352. .last-info {
  353. font-size: #{24rpx};
  354. color: #666;
  355. height: #{44rpx};
  356. }
  357. .last-info view {
  358. float: left;
  359. height: #{44rpx};
  360. line-height: #{44rpx};
  361. }
  362. .last-info .show-tip {
  363. display: inline-block;
  364. background-color: #fff;
  365. font-size: #{24rpx};
  366. padding: 0 #{12rpx};
  367. height: #{44rpx};
  368. line-height: #{44rpx};
  369. border-radius: #{22rpx};
  370. border: #{1rpx} solid #F84469;
  371. color: #F84469;
  372. margin-left: #{5rpx};
  373. }
  374. .last-info button::after {
  375. border: 0;
  376. }
  377. .price {
  378. height: #{80rpx};
  379. line-height: #{80rpx};
  380. font-size: #{46rpx};
  381. position: absolute;
  382. left: 0;
  383. top: 0;
  384. color: #ff4544;
  385. }
  386. .all {
  387. color: #666;
  388. }
  389. .input {
  390. font-size: #{36rpx};
  391. height: #{80rpx};
  392. line-height: #{80rpx};
  393. width: 70%;
  394. padding-left: #{50rpx};
  395. position: relative;
  396. }
  397. .input input {
  398. height: #{80rpx};
  399. line-height: #{80rpx};
  400. }
  401. .about {
  402. font-size: #{24rpx};
  403. padding: #{32rpx} #{24rpx} #{32rpx - 24rpx} #{24rpx};
  404. color: #666;
  405. }
  406. .icon {
  407. height: #{40rpx};
  408. width: #{40rpx};
  409. margin-right: #{16rpx};
  410. display: flex;
  411. justify-content: center;
  412. }
  413. .mode-item {
  414. width: #{200rpx};
  415. border: #{1rpx} solid #999;
  416. text-align: center;
  417. padding: 0 #{24rpx};
  418. height: #{66rpx};
  419. line-height: #{66rpx};
  420. border-radius: #{33rpx};
  421. display: flex;
  422. align-items: center;
  423. margin: #{10rpx} #{24rpx};
  424. font-size: #{30rpx};
  425. position: relative;
  426. }
  427. .mode-title {
  428. margin-bottom: #{25rpx};
  429. padding-left: #{24rpx};
  430. font-size: #{34rpx};
  431. }
  432. .enter {
  433. color: #353535;
  434. float: left;
  435. width: #{100rpx};
  436. height: #{56rpx};
  437. line-height: #{56rpx};
  438. font-size: #{32rpx};
  439. }
  440. .content {
  441. height: #{120rpx};
  442. }
  443. .info-input {
  444. font-size: #{32rpx};
  445. height: #{56rpx};
  446. padding: 0 #{32rpx};
  447. }
  448. .on-active {
  449. height: #{32rpx};
  450. width: #{32rpx};
  451. position: absolute;
  452. right: 0;
  453. bottom: 0;
  454. }
  455. .submit {
  456. margin-top: #{40rpx};
  457. }
  458. .submit button {
  459. height: #{80rpx};
  460. border-radius: #{40rpx};
  461. line-height: #{80rpx};
  462. width: 90%;
  463. margin: 0 auto;
  464. color: #fff;
  465. font-size: 16px;
  466. background-color: #ff4544;
  467. }
  468. .bg {
  469. position: fixed;
  470. top: 0;
  471. left: 0;
  472. height: 100%;
  473. width: 100%;
  474. background-color: rgba(0, 0, 0, .3);
  475. z-index: 10;
  476. }
  477. .dialog {
  478. position: fixed;
  479. top: #{400rpx};
  480. left: 0;
  481. right: 0;
  482. height: #{330rpx};
  483. width: #{640rpx};
  484. margin: 0 auto;
  485. z-index: 21;
  486. background-color: #fff;
  487. border-radius: #{20rpx};
  488. text-align: center;
  489. font-size: #{30rpx};
  490. }
  491. .dialog-title {
  492. margin: #{40rpx} auto #{35rpx};
  493. }
  494. .dialog-msg {
  495. margin: #{48rpx};
  496. margin-top: 0;
  497. }
  498. .dialog-btn {
  499. height: #{88rpx};
  500. width: #{640rpx};
  501. border-top: #{1rpx} solid #e2e2e2;
  502. line-height: #{88rpx};
  503. position: absolute;
  504. bottom: 0;
  505. left: 0;
  506. }
  507. .dialog-close,.dialog-submit {
  508. width: 100%;
  509. }
  510. .line {
  511. height: #{44rpx};
  512. margin-top: #{22rpx};
  513. width: #{1rpx};
  514. background-color: #e2e2e2;
  515. }
  516. .dialog-submit {
  517. color: #ff4544;
  518. }
  519. </style>