index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. <template>
  2. <view :style="colorStyle">
  3. <!-- #ifdef MP -->
  4. <view class="accountTitle">
  5. <view :style="{height:getHeight.barTop+'px'}"></view>
  6. <view class="sysTitle acea-row row-center-wrapper" :style="{height:getHeight.barHeight+'px'}">
  7. <view>账户充值</view>
  8. <text class="iconfont icon-ic_leftarrow" @click="goarrow"></text>
  9. </view>
  10. </view>
  11. <view :style="{height:(getHeight.barTop+getHeight.barHeight)+'px'}"></view>
  12. <!-- #endif -->
  13. <form @submit="submitSub">
  14. <view class="paymentCon">
  15. <view class="payment-top">
  16. <span class="name">我的余额</span>
  17. <view class="money">{{ userinfo.now_money || 0 }}</view>
  18. <view class="pictrue">
  19. <image src="../static/chongzhi.png"></image>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="payment">
  24. <view class="nav acea-row row-between-wrapper" v-if="balanceStatus">
  25. <view class="item" :class="(active==index && index==0)?'on on1':(active==index && index==1)?'on on2':index!=1?'on3':''" v-for="(item,index) in navRecharge" :key="index" @click="navRecharges(index)">
  26. {{item}}
  27. </view>
  28. </view>
  29. <view class='tip picList' v-if='!active' >
  30. <view class="pic-box pic-box-color acea-row row-center-wrapper row-column" :class="activePic == index ? 'pic-box-color-active' : ''"
  31. v-for="(item, index) in picList" :key="index" @click="picCharge(index, item)" v-if="item.price">
  32. <view>
  33. <view class="pic-number-pic">¥<text class="money">{{ item.price }}</text></view>
  34. <view class="pic-number">赠送{{ item.give_money }}元</view>
  35. <view class="label" v-if="parseInt(item.is_welfare)">充值福利</view>
  36. </view>
  37. </view>
  38. <view class="pic-box pic-box-color acea-row row-center-wrapper" :class="activePic == picList.length ? 'pic-box-color-active' : ''"
  39. @click="picCharge(picList.length)">
  40. <input type="digit" :placeholder="activePic == picList.length?'':'自定义'" v-model="money" class="pic-box-money" placeholder-class="placeholders" />
  41. </view>
  42. </view>
  43. <view class="tip" v-else>
  44. <view class="title">转入佣金</view>
  45. <view class='input acea-row row-middle'><text>¥</text><input @input='inputNum' :maxlength="moneyMaxLeng" placeholder="请输入转入佣金金额" type='digit' placeholder-class='placeholder' v-model="number" name="number"></input></view>
  46. <view class="tips-title acea-row row-between-wrapper">
  47. <view>当前可转入佣金<text class='font-num'>{{userinfo.commissionCount || 0}}</text>元,冻结佣金<text class='font-num'>{{userinfo.broken_commission}}</text>元</view>
  48. <view class="font-num" @click="allChange">全部转入</view>
  49. </view>
  50. </view>
  51. <view class="tips-box">
  52. <view class="tips">充值说明</view>
  53. <view class="tips-samll acea-row row-top row-between" v-for="item in rechargeAttention" :key="item">
  54. <view class="drop"></view>
  55. <view class="info">{{ item }}</view>
  56. </view>
  57. </view>
  58. <button class='but bg-color' formType="submit" > {{active ? '立即转入': '立即充值' }}</button>
  59. </view>
  60. </form>
  61. <!-- 确认框 -->
  62. <tuiModal
  63. :show="showModal"
  64. title="温馨提示"
  65. content="转入余额后无法再次转出,确认是否转入余额"
  66. :maskClosable="false"
  67. @click="handleClick"></tuiModal>
  68. </view>
  69. </template>
  70. <script>
  71. import {
  72. getUserInfo,
  73. rechargeAPi,
  74. getRechargeApi,
  75. memberCardCreate
  76. } from '@/api/user.js';
  77. import tuiModal from "@/components/tui-modal/index.vue"
  78. import {toLogin} from '@/libs/login.js';
  79. import {orderOfflinePayType} from '@/api/order.js';
  80. import {mapGetters} from "vuex";
  81. import colors from "@/mixins/color";
  82. import {openPaySubscribe} from '@/utils/SubscribeMessage.js';
  83. export default {
  84. components: {
  85. tuiModal
  86. },
  87. mixins:[colors],
  88. data() {
  89. let that = this;
  90. return {
  91. // #ifdef MP
  92. getHeight: this.$util.getWXStatusHeight(),
  93. // #endif
  94. now_money: 0,
  95. navRecharge: ['账户充值', '佣金转入'],
  96. active: 0,
  97. number: '',
  98. userinfo: {},
  99. placeholder: "0.00",
  100. from: '',
  101. isAuto: false, //没有授权的不会自动授权
  102. isShowAuth: false, //是否隐藏授权
  103. picList: [],
  104. activePic: 0,
  105. money: "",
  106. numberPic:'',
  107. rechar_id:0,
  108. password: '',
  109. goodsList: [],
  110. pay_order_id: '',
  111. payType: '',
  112. totalPrice: '0',
  113. formContent: '',
  114. // #ifdef H5
  115. isWeixin: this.$wechat.isWeixin(),
  116. // #endif
  117. type: '',
  118. rechargeAttention:[],
  119. moneyMaxLeng:8,
  120. showModal: false,
  121. balanceStatus:0
  122. };
  123. },
  124. computed: mapGetters(['isLogin']),
  125. watch:{
  126. isLogin:{
  127. handler:function(newV,oldV){
  128. if(newV){
  129. //#ifndef MP
  130. this.getUserInfo();
  131. this.getRecharge();
  132. //#endif
  133. }
  134. },
  135. deep:true
  136. }
  137. },
  138. onLoad(options) {
  139. if (this.isLogin) {
  140. this.getUserInfo();
  141. this.getRecharge();
  142. } else {
  143. toLogin();
  144. }
  145. },
  146. onShow() {
  147. uni.removeStorageSync('form_type_cart');
  148. },
  149. methods: {
  150. allChange(){
  151. this.number = this.userinfo.commissionCount;
  152. },
  153. goarrow(){
  154. let pages = getCurrentPages();
  155. let prevPage = pages[pages.length - 2];
  156. if(prevPage){
  157. uni.navigateBack()
  158. }else{
  159. uni.reLaunch({
  160. url: '/pages/index/index'
  161. })
  162. }
  163. },
  164. inputNum: function(e) {
  165. let val = e.detail.value;
  166. let dot = val.indexOf('.');
  167. if(dot>-1){
  168. this.moneyMaxLeng = dot+3;
  169. }else{
  170. this.moneyMaxLeng = 8
  171. }
  172. },
  173. /**
  174. * 选择金额
  175. */
  176. picCharge(idx, item) {
  177. this.activePic = idx;
  178. if (item === undefined) {
  179. this.rechar_id = 0;
  180. this.numberPic = "";
  181. } else {
  182. this.money = "";
  183. this.rechar_id = item.id;
  184. this.numberPic = item.price;
  185. }
  186. },
  187. /**
  188. * 充值额度选择
  189. */
  190. getRecharge() {
  191. getRechargeApi().then(res => {
  192. this.picList = res.data.recharge_quota;
  193. if (this.picList[0]) {
  194. this.rechar_id = this.picList[0].id;
  195. this.numberPic = this.picList[0].price;
  196. }
  197. this.rechargeAttention = res.data.recharge_attention || [];
  198. this.balanceStatus = res.data.user_extract_balance_status;
  199. }).catch(res => {
  200. this.$util.Tips({
  201. title: res
  202. })
  203. });
  204. },
  205. navRecharges: function(index) {
  206. this.active = index;
  207. },
  208. getUserInfo: function() {
  209. let that = this;
  210. getUserInfo().then(res => {
  211. that.$set(that, 'userinfo', res.data);
  212. })
  213. },
  214. handleClick(e){
  215. let index = e.index;
  216. if(index == 1){
  217. let data = {
  218. price: this.number,
  219. type: 1,
  220. // #ifdef H5
  221. from: this.$wechat.isWeixin() ? "weixin" : "weixinh5",
  222. // #endif
  223. // #ifdef MP
  224. from: 'routine',
  225. // #endif
  226. };
  227. rechargeAPi(data).then(res=>{
  228. this.$util.Tips({
  229. title: res.msg
  230. }, {
  231. url: "/pages/users/user_money/index"
  232. })
  233. }).catch(err => {
  234. return this.$util.Tips({
  235. title: err
  236. })
  237. });
  238. }
  239. this.showModal = false;
  240. },
  241. submitSub: function(e) {
  242. let that = this
  243. let value = e.detail.value.number;
  244. // 转入余额
  245. if (that.active) {
  246. if (parseFloat(value) < 0 || parseFloat(value) == NaN || value == undefined || value == "") {
  247. return that.$util.Tips({
  248. title: '请输入金额'
  249. });
  250. }
  251. this.showModal = true;
  252. } else {
  253. let data = {
  254. price: this.numberPic ? this.numberPic : this.money,
  255. rechar_id: this.rechar_id,
  256. type: 0,
  257. // #ifdef H5
  258. from: this.$wechat.isWeixin() ? "weixin" : "weixinh5",
  259. // #endif
  260. // #ifdef MP
  261. from: 'routine',
  262. // #endif
  263. };
  264. rechargeAPi(data).then(res=>{
  265. uni.reLaunch({
  266. url: `/pages/goods/cashier/index?order_id=${res.data.order_id}&from_type=recharge`
  267. })
  268. }).catch(err => {
  269. return this.$util.Tips({
  270. title: err
  271. })
  272. });
  273. // this.totalPrice = this.rechar_id == 0 ? parseFloat(this.money) : parseFloat(this.numberPic);
  274. }
  275. }
  276. }
  277. }
  278. </script>
  279. <style lang="scss">
  280. .bgcolor{
  281. background-color: var(--view-theme)
  282. }
  283. .accountTitle{
  284. background-color: var(--view-minorColorT);
  285. position: fixed;
  286. left:0;
  287. top:0;
  288. width: 100%;
  289. z-index: 99;
  290. .sysTitle{
  291. width: 100%;
  292. position: relative;
  293. font-weight: 500;
  294. color: #333333;
  295. font-size: 30rpx;
  296. .iconfont{
  297. position: absolute;
  298. font-size: 36rpx;
  299. left:11rpx;
  300. width: 60rpx;
  301. }
  302. }
  303. }
  304. .payment {
  305. position: relative;
  306. width: 710rpx;
  307. background-color: #fff;
  308. border-radius: 32rpx;
  309. margin: -176rpx auto 0 auto;
  310. padding-bottom: 64rpx;
  311. }
  312. .payment .nav {
  313. height: 96rpx;
  314. line-height: 96rpx;
  315. background-color: #f5f5f5;
  316. border-radius: 32rpx 32rpx 0 0;
  317. }
  318. .payment .nav .item {
  319. font-size: 30rpx;
  320. color: #333;
  321. width: 280rpx;
  322. text-align: center;
  323. padding-right: 40rpx;
  324. position: relative;
  325. &.on1{
  326. padding-right: 62rpx;
  327. background-image: url('../static/titleLeft.png');
  328. &::after{
  329. margin-left: 150rpx;
  330. }
  331. }
  332. &.on2{
  333. padding-left: 62rpx;
  334. background-image: url('../static/titleRight.png');
  335. &::after{
  336. margin-left: 192rpx;
  337. }
  338. }
  339. &.on3{
  340. padding-left: 62rpx;
  341. }
  342. }
  343. .payment .nav .item.on {
  344. font-weight: bold;
  345. width: 407rpx;
  346. height: 96rpx;
  347. background-repeat: no-repeat;
  348. background-size: 100% 100%;
  349. text-align: center;
  350. &::after{
  351. width: 38rpx;
  352. height: 30rpx;
  353. border: 2px solid var(--view-theme);
  354. border-left: 2px solid transparent !important;
  355. border-top: 2px solid transparent !important;
  356. border-right: 2px solid transparent !important;
  357. border-radius: 50%;
  358. position: absolute;
  359. content: ' ';
  360. left: 0;
  361. bottom: 10rpx;
  362. }
  363. }
  364. .payment .input {
  365. margin: 32rpx auto 0 auto;
  366. font-size: 56rpx;
  367. color: #333333;
  368. background: #F5F5F5;
  369. border-radius: 16rpx;
  370. height: 114rpx;
  371. }
  372. .payment .input text {
  373. padding-left: 26rpx;
  374. font-weight: 600;
  375. }
  376. .payment .input input {
  377. width: 520rpx;
  378. height: 94rpx;
  379. font-size: 60rpx;
  380. margin-left: 24rpx;
  381. font-family: 'SemiBold';
  382. }
  383. .payment .input .placeholder {
  384. font-weight: 400;
  385. color: #DDDDDD;
  386. height: 100%;
  387. line-height: 94rpx;
  388. font-size: 32rpx;
  389. }
  390. .payment .tip {
  391. font-size: 26rpx;
  392. color: #888888;
  393. padding: 30rpx 33rpx 0 33rpx;
  394. .title{
  395. font-weight: 400;
  396. color: #333333;
  397. font-size: 28rpx;
  398. }
  399. }
  400. .payment .but {
  401. color: #fff;
  402. font-size: 28rpx;
  403. width: 646rpx;
  404. height: 88rpx;
  405. border-radius: 50rpx;
  406. margin: 150rpx auto 0 auto;
  407. line-height: 88rpx;
  408. font-weight: 500;
  409. background: linear-gradient(90deg, var(--view-theme) 0%, var(--view-gradient) 100%);
  410. }
  411. .paymentCon{
  412. background: linear-gradient(180deg, var(--view-minorColorT) 0%, #f5f5f5 100%);
  413. padding-top: 32rpx;
  414. }
  415. .payment-top {
  416. width: 710rpx;
  417. height: 396rpx;
  418. background: linear-gradient(90deg, var(--view-theme) 0%, var(--view-gradient) 100%);
  419. margin: 0 auto;
  420. border-radius: 32rpx 32rpx 0 0;
  421. padding: 56rpx 60rpx;
  422. box-sizing: border-box;
  423. position: relative;
  424. .name {
  425. font-size: 28rpx;
  426. color: rgba(255, 255, 255, 0.8);
  427. }
  428. .money {
  429. font-size: 68rpx;
  430. color: #fff;
  431. font-family: 'SemiBold';
  432. margin-top: 16rpx;
  433. }
  434. .pictrue{
  435. width: 186rpx;
  436. height: 186rpx;
  437. position: absolute;
  438. right: 60rpx;
  439. top: 66rpx;
  440. image{
  441. width: 100%;
  442. height: 100%;
  443. }
  444. }
  445. }
  446. .picList {
  447. display: flex;
  448. flex-wrap: wrap;
  449. .pic-box {
  450. width: 204rpx;
  451. height: 144rpx;
  452. border-radius: 20rpx;
  453. padding: 28rpx 0 26rpx 0;
  454. margin: 16rpx 16rpx 0 0;
  455. box-sizing: border-box;
  456. position: relative;
  457. &:nth-child(3n) {
  458. margin-right: 0;
  459. }
  460. .label{
  461. position: absolute;
  462. left:-2rpx;
  463. top:-18rpx;
  464. width: 118rpx;
  465. height: 40rpx;
  466. background: linear-gradient(270deg, #FAAD14 0%, #FF7D00 100%);
  467. border-radius: 16rpx 0 16rpx 0;
  468. color: #fff;
  469. font-size: 22rpx;
  470. text-align: center;
  471. line-height: 40rpx;
  472. }
  473. }
  474. .pic-box-color {
  475. background-color: #F5F5F5;
  476. color: #333;
  477. border: 1px solid #F5F5F5;
  478. }
  479. .pic-number {
  480. font-size: 24rpx;
  481. font-weight: 400;
  482. color: #999999;
  483. margin-top: 6rpx;
  484. }
  485. .pic-number-pic {
  486. font-size: 36rpx;
  487. font-weight: 500;
  488. width: 100%;
  489. text-align: center;
  490. .money{
  491. margin-left: 10rpx;
  492. }
  493. }
  494. .pic-box-money{
  495. height: 70rpx;
  496. font-size: 32rpx;
  497. text-align: center;
  498. font-weight: 500;
  499. line-height: 70rpx;
  500. }
  501. .placeholders{
  502. color: #333333;
  503. }
  504. .pic-box-color-active {
  505. background-color: var(--view-minorColorT) !important;
  506. color: var(--view-theme) !important;
  507. border: 1px solid var(--view-theme);
  508. .pic-number,.placeholders{
  509. color: var(--view-theme) !important;
  510. }
  511. }
  512. }
  513. .tips-box{
  514. margin-top: 48rpx;
  515. width: 100%;
  516. padding: 0 32rpx;
  517. box-sizing: border-box;
  518. .tips {
  519. font-size: 32rpx;
  520. color: #333333;
  521. font-weight: 600;
  522. margin-bottom: 24rpx;
  523. }
  524. .tips-samll {
  525. font-size: 24rpx;
  526. color: #999;
  527. margin-bottom: 20rpx;
  528. .drop{
  529. width: 10rpx;
  530. height: 10rpx;
  531. background-color: var(--view-theme);
  532. border-radius: 50%;
  533. margin-top: 12rpx;
  534. }
  535. .info{
  536. width: 620rpx;
  537. }
  538. }
  539. .tip-box {
  540. margin-top: 30rpx;
  541. }
  542. }
  543. .tips-title{
  544. margin-top: 32rpx;
  545. font-size: 26rpx;
  546. color: #333;
  547. }
  548. </style>