cash.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  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" :style="{color:getTheme.color,border: `1rpx solid ${getTheme.color}` }">规则</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">¥</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="https://shop.9026.com/web/statics/image/mall/static/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 :style="{'background': getTheme.background_gradient_btn,'color':getTheme.main_text}" @click="subscribe" >提交申请</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,mapGetters} 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. ...mapGetters('mallConfig', {
  123. getTheme: 'getTheme'
  124. }),
  125. cashName() {
  126. switch (this.cashType) {
  127. case 'auto':
  128. // #ifdef MP-WEIXIN
  129. return '微信零钱';
  130. // #endif
  131. // #ifdef MP-ALIPAY
  132. return '支付宝余额';
  133. // #endif
  134. // #ifndef MP-WEIXIN || MP-ALIPAY
  135. return '自动';
  136. // #endif
  137. case 'wx':
  138. return '微信线下打款';
  139. case 'alipay':
  140. return '支付宝线下打款';
  141. case 'bank':
  142. return '银联线下打款';
  143. case 'balance':
  144. return '商城余额';
  145. default:
  146. return;
  147. break;
  148. }
  149. },
  150. },
  151. methods: {
  152. getMoney() {
  153. let money = this.config.surplusCash ? this.config.surplusCash : this.config.cash_max_day;
  154. if (+money < +this.money && +money > -1) {
  155. this.moneyInput = +money;
  156. } else {
  157. this.moneyInput = +this.money;
  158. }
  159. },
  160. payTypeChange(value) {
  161. this.cashType = value;
  162. switch (value) {
  163. case 'auto':
  164. this.mark_num = 0;
  165. break;
  166. case 'wx':
  167. this.mark_num = 1;
  168. break;
  169. case 'alipay':
  170. this.mark_num = 2;
  171. break;
  172. case 'bank':
  173. this.mark_num = 3;
  174. break;
  175. case 'balance':
  176. this.mark_num = 4;
  177. break;
  178. default:
  179. this.mark_num = -1;
  180. break;
  181. }
  182. },
  183. subscribe() {
  184. if (this.mark_num === -1) {
  185. uni.showToast({title: '请选择提现方式', icon: 'none'});
  186. return;
  187. }
  188. if(this.loading) {
  189. return false
  190. }
  191. this.loading = true;
  192. this.$subscribe(this.template_message).then(res => {
  193. this.submit();
  194. }).catch(res => {
  195. this.submit();
  196. });
  197. },
  198. submit() {
  199. let that = this;
  200. let para = {
  201. price: that.moneyInput,
  202. type: 'auto',
  203. };
  204. uni.showLoading({
  205. title: '申请中'
  206. })
  207. if (that.mark_num === 4) {
  208. para.type = 'balance';
  209. } else if (that.mark_num === 0) {
  210. para.type = 'auto';
  211. } else {
  212. para.name = that.name;
  213. para.mobile = that.mobile;
  214. switch (that.mark_num) {
  215. case 1:
  216. para.type = 'wechat';
  217. break;
  218. case 2:
  219. para.type = 'alipay';
  220. break;
  221. case 3:
  222. para.type = 'bank';
  223. para.bank_name = that.bank_name;
  224. break;
  225. }
  226. }
  227. that.$request({
  228. url: that.$api.share.cash,
  229. data: para,
  230. method: 'post',
  231. }).then(response=>{
  232. this.loading = false;
  233. uni.hideLoading();
  234. if(response.code === 0) {
  235. uni.showToast({
  236. title: response.msg,
  237. duration: 1000
  238. });
  239. setTimeout(() => {
  240. uni.redirectTo({
  241. url: '/pages/share/cash-detail/cash-detail'
  242. });
  243. }, 1000);
  244. }else {
  245. uni.showToast({
  246. title: response.msg,
  247. icon: 'none',
  248. duration: 1000
  249. });
  250. }
  251. }).catch(() => {
  252. this.loading = false;
  253. uni.hideLoading();
  254. });
  255. },
  256. setting() {
  257. let that = this;
  258. that.$request({
  259. url: that.$api.share.setting,
  260. }).then(response=>{
  261. that.$hideLoading();
  262. if(response.code === 0) {
  263. that.config = response.msg.config;
  264. that.template_message = response.msg.template_message
  265. for (let i = 0; i < that.config.pay_type.length; i++) {
  266. switch (that.config.pay_type[i]) {
  267. case 'auto':
  268. that.pay_type.auto = true;
  269. break;
  270. case 'alipay':
  271. that.pay_type.alipay = true;
  272. break;
  273. case 'wechat':
  274. that.pay_type.wechat = true;
  275. break;
  276. case 'balance':
  277. that.pay_type.balance = true;
  278. break;
  279. case 'bank':
  280. that.pay_type.bank = true;
  281. break;
  282. }
  283. }
  284. }else {
  285. uni.showToast({
  286. title: response.msg,
  287. icon: 'none',
  288. duration: 1000
  289. });
  290. }
  291. }).catch(() => {
  292. that.$hideLoading();
  293. });
  294. },
  295. },
  296. onLoad(options) { this.$commonLoad.onload(options);
  297. let that = this;
  298. if (options.money > 0) {
  299. that.money = options.money;
  300. }
  301. that.setting();
  302. uni.setNavigationBarTitle({
  303. title: that.custom_setting.menus.cash.name,
  304. });
  305. }
  306. }
  307. </script>
  308. <style scoped lang="scss">
  309. .cash-type {
  310. height: #{120rpx};
  311. background: white;
  312. color: #353535;
  313. font-size: #{32rpx};
  314. padding: 0 #{24rpx};
  315. margin-top: #{24rpx};
  316. .arrow-image {
  317. width: #{12rpx};
  318. height: #{24rpx};
  319. display: block;
  320. margin-left: #{12rpx};
  321. }
  322. }
  323. .surplus {
  324. margin: 0 #{5rpx};
  325. }
  326. .button-space {
  327. height: #{120rpx};
  328. }
  329. .cash-info {
  330. margin-top: #{20rpx};
  331. margin-bottom: #{120rpx};
  332. }
  333. .cash-info .info.content:last-of-type {
  334. border-bottom: 0;
  335. }
  336. .info.cash-type {
  337. margin-bottom: #{20rpx};
  338. padding: #{32rpx} 0;
  339. border-bottom: 0;
  340. }
  341. .info {
  342. background-color: #fff;
  343. padding: #{32rpx} #{24rpx};
  344. border-bottom: #{1rpx} solid #e2e2e2;
  345. color: #353535;
  346. }
  347. .info.input-money {
  348. border-bottom: 0;
  349. width: 100%;
  350. }
  351. .last {
  352. font-size: #{40rpx};
  353. margin-bottom: #{15rpx};
  354. }
  355. .last-info {
  356. font-size: #{24rpx};
  357. color: #666;
  358. height: #{44rpx};
  359. }
  360. .last-info view {
  361. float: left;
  362. height: #{44rpx};
  363. line-height: #{44rpx};
  364. }
  365. .last-info .show-tip {
  366. display: inline-block;
  367. background-color: #fff;
  368. font-size: #{24rpx};
  369. padding: 0 #{12rpx};
  370. height: #{44rpx};
  371. line-height: #{44rpx};
  372. border-radius: #{22rpx};
  373. border: #{1rpx} solid #ff4544;
  374. color: #ff4544;
  375. margin-left: #{5rpx};
  376. }
  377. .last-info button::after {
  378. border: 0;
  379. }
  380. .price {
  381. height: #{80rpx};
  382. line-height: #{80rpx};
  383. font-size: #{46rpx};
  384. position: absolute;
  385. left: 0;
  386. top: 0;
  387. color: #ff4544;
  388. }
  389. .all {
  390. color: #666;
  391. }
  392. .input {
  393. font-size: #{36rpx};
  394. height: #{80rpx};
  395. line-height: #{80rpx};
  396. width: 70%;
  397. padding-left: #{50rpx};
  398. position: relative;
  399. }
  400. .input input {
  401. height: #{80rpx};
  402. line-height: #{80rpx};
  403. }
  404. .about {
  405. font-size: #{24rpx};
  406. padding: #{32rpx} #{24rpx} #{32rpx - 24rpx} #{24rpx};
  407. color: #666;
  408. }
  409. .icon {
  410. height: #{40rpx};
  411. width: #{40rpx};
  412. margin-right: #{16rpx};
  413. display: flex;
  414. justify-content: center;
  415. }
  416. .mode-item {
  417. width: #{200rpx};
  418. border: #{1rpx} solid #999;
  419. text-align: center;
  420. padding: 0 #{24rpx};
  421. height: #{66rpx};
  422. line-height: #{66rpx};
  423. border-radius: #{33rpx};
  424. display: flex;
  425. align-items: center;
  426. margin: #{10rpx} #{24rpx};
  427. font-size: #{30rpx};
  428. position: relative;
  429. }
  430. .mode-title {
  431. margin-bottom: #{25rpx};
  432. padding-left: #{24rpx};
  433. font-size: #{34rpx};
  434. }
  435. .enter {
  436. color: #353535;
  437. float: left;
  438. width: #{100rpx};
  439. height: #{56rpx};
  440. line-height: #{56rpx};
  441. font-size: #{32rpx};
  442. }
  443. .content {
  444. height: #{120rpx};
  445. }
  446. .info-input {
  447. font-size: #{32rpx};
  448. height: #{56rpx};
  449. padding: 0 #{32rpx};
  450. }
  451. .on-active {
  452. height: #{32rpx};
  453. width: #{32rpx};
  454. position: absolute;
  455. right: 0;
  456. bottom: 0;
  457. }
  458. .submit {
  459. margin-top: #{40rpx};
  460. }
  461. .submit button {
  462. height: #{80rpx};
  463. border-radius: #{40rpx};
  464. line-height: #{80rpx};
  465. width: 90%;
  466. margin: 0 auto;
  467. color: #fff;
  468. font-size: 16px;
  469. background-color: #ff4544;
  470. }
  471. .bg {
  472. position: fixed;
  473. top: 0;
  474. left: 0;
  475. height: 100%;
  476. width: 100%;
  477. background-color: rgba(0, 0, 0, .3);
  478. z-index: 10;
  479. }
  480. .dialog {
  481. position: fixed;
  482. top: #{400rpx};
  483. left: 0;
  484. right: 0;
  485. height: #{330rpx};
  486. width: #{640rpx};
  487. margin: 0 auto;
  488. z-index: 21;
  489. background-color: #fff;
  490. border-radius: #{20rpx};
  491. text-align: center;
  492. font-size: #{30rpx};
  493. }
  494. .dialog-title {
  495. margin: #{40rpx} auto #{35rpx};
  496. }
  497. .dialog-msg {
  498. margin: #{48rpx};
  499. margin-top: 0;
  500. }
  501. .dialog-btn {
  502. height: #{88rpx};
  503. width: #{640rpx};
  504. border-top: #{1rpx} solid #e2e2e2;
  505. line-height: #{88rpx};
  506. position: absolute;
  507. bottom: 0;
  508. left: 0;
  509. }
  510. .dialog-close,.dialog-submit {
  511. width: 100%;
  512. }
  513. .line {
  514. height: #{44rpx};
  515. margin-top: #{22rpx};
  516. width: #{1rpx};
  517. background-color: #e2e2e2;
  518. }
  519. .dialog-submit {
  520. color: #ff4544;
  521. }
  522. </style>