| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471 |
- <template>
- <view class="content">
- <view class="now">
- <view>当前余额:</view>
- <view class="now-money">¥{{new_money}}</view>
- </view>
- <view class="main-jg"></view>
- <view class="add-wrapper">
- <view class="add-box">
- <view class="add-log">¥</view>
- <input type="text" v-model="money" placeholder="请输入充值金额" placeholder-class="place" @keyup="clearNoNum()"/>
- </view>
- <view class="jg" style="height: 1px; background-color: #E6E6E6;"></view>
- <view class="add-tags">
- <view class="tag" v-for="(item, index) in addTags" :key="item" @click="tagClick(index)"
- :class="{ action: check.id == item.id }">
- <view>{{ item.price*1 }}</view>
- <view class="tip">赠送:{{ item.gift_price*1 }}</view>
- </view>
- </view>
- </view>
- <view class="main-jg"></view>
- <!-- <view class="btn-wrapper">
- <view class="icon iconfont iconweixin1">
- <view>微信充值</view>
- </view>
- <view class="btn" @click="btnClick" :class="{'actiont': isSect}">
- <image src="../../static/user/btncz.png" mode="" :class="{'action':!isSect}"></image>
- </view>
- </view> -->
- <view class="btn-wrapper">
- <view class="icon iconfont iconweixin1 iconweixin2">
- <view>汇付充值</view>
- </view>
- <view class="btn" @click="btnClick('huifu')" :class="{'actiont': payType == 'huifu'}">
- <image src="../../../static/user/btncz.png" mode="" :class="{'action':payType !== 'huifu'}"></image>
- </view>
- </view>
- <view class="btn-wrapper">
- <view class="icon iconfont iconweixin1">
- <view>微信充值</view>
- </view>
- <view class="btn" @click="btnClick('weixin')" :class="{'actiont': payType == 'weixin'}">
- <image src="../../../static/user/btncz.png" mode="" :class="{'action':payType !== 'weixin'}"></image>
- </view>
- </view>
- <!-- <view class="row-box">
- <view class="title">充值金额</view>
- <view class="row">
- <text class="tit">¥</text>
- <input class="input" type="number" v-model="money" placeholder="请输入充值金额" placeholder-class="placeholder" />
- </view>
- </view> -->
- <button class="add-btn up" :class="{ 'active-bg': payLoding }"
- @click="!payLoding ? confirm() : ''">立即充值</button>
- </view>
- </template>
- <script>
- // #ifdef H5
- import * as weichatObj from '@/plugin/jweixin-module/index.js';
- // #endif
- import {
- getMoneyStyle
- } from '@/utils/rocessor.js';
- // #ifdef H5
- import {
- rechargeWechat,
- userBalance
- } from '@/api/wallet.js';
- // #endif
- // #ifdef MP
- import {
- rechargeRoutine,
- userBalance
- } from '@/api/wallet.js';
- // #endif
- import {
- mapState
- } from 'vuex';
- import {
- orderData,
- getUserInfo,
- getRechangeList,
- goChange
- } from '@/api/user.js';
- export default {
- filters: {
- getMoneyStyle
- },
- data() {
- return {
- check: {id: 0},
- type: 'weixin',
- money: '', //充值金额
- payLoding: false, //是否加载中
- addTags: [],
- currentIndex: 0,
- addMoney: 0,
- isSect: false, //是否选择微信充值
- new_money: 0,
- authCode: '',
- payType: ''
- };
- },
- onLoad(options) {
- this.getRechangeList()
- },
- computed: {
- // #ifdef H5
- // ...mapState(['weichatObj'])
- // #endif
- },
- methods: {
- getRechangeList() {
- getRechangeList().then(res => {
- this.addTags = res.data
- })
- },
- // 跳转
- navTo(url) {
- uni.navigateTo({
- url: url
- });
- },
- // 切换选中对象
- tabRadio(e) {
- this.type = e;
- },
- // 提交
- confirm() {
- if (this.money == 0) {
- return this.$msg('请输入充值金额');
- }
- // if(!this.isSect) {
- // return this.$msg('请选择支付方式');
- // }
- let obj = this;
- goChange({
- rechar_id: obj.check && obj.check.id ? obj.check.id : '',
- price: obj.money,
- type: 0, //0 普通充值 1 佣金转余额
- // #ifdef APP
- from: 'app',
- // #endif
- // #ifdef MP | H5
- from: 'weixin',
- // #endif
- staffinfo: '',
- pay_type: obj.payType
- })
- .then(e => {
- uni.showToast({
- title: '充值成功',
- duration: 2000,
- position: 'top'
- });
- setTimeout(() => {
- uni.navigateBack()
- }, 1500)
- obj.payLoding = false;
- })
- .catch(e => {
- obj.payLoding = false;
- });
- },
- tagClick(index) {
- this.currentIndex = index;
- this.money = this.addTags[index].price;
- this.check = this.addTags[index]
- },
- clearNoNum() {
- this.money = this.money.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3');
- console.log(this.money)
- const fi = this.addTags.find(item => item.price*1 == this.money )
- if(fi && fi.id) {
- this.check = fi
- }else {
- this.check = {id: 0}
- }
- console.log(fi)
- },
- btnClick(type) {
- // this.isSect = !this.isSect
- this.payType = type
- },
- }
- };
- </script>
- <style lang="scss">
- page {
- height: 100%;
- background-color: #fff;
- }
- .add-btn {
- &.modified {
- color: $base-color;
- }
- &.up {
- background-color: $base-color;
- color: #fff;
- }
- display: flex;
- align-items: center;
- justify-content: center;
- width: 604rpx;
- height: 90rpx;
- margin: 0 auto;
- margin-top: 30rpx;
- font-size: $font-lg;
- border-radius: 10rpx;
- // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
- }
- .row-box {
- margin-top: 30rpx;
- padding: 20rpx 30rpx;
- background: #fff;
- .title {
- font-size: $font-base + 2rpx;
- color: $font-color-dark;
- }
- .row {
- display: flex;
- align-items: center;
- position: relative;
- height: 80rpx;
- .tit {
- flex-shrink: 0;
- width: 40rpx;
- font-size: 30rpx;
- color: $font-color-dark;
- }
- .input {
- flex: 1;
- font-size: 30rpx;
- color: $font-color-dark;
- }
- .iconlocation {
- font-size: 36rpx;
- color: $font-color-light;
- }
- .buttom {
- color: $font-color;
- font-size: $font-base;
- }
- }
- }
- .list {
- padding-left: 30rpx;
- margin-top: 30rpx;
- background-color: #ffffff;
- .box {
- display: flex;
- align-items: center;
- width: 100%;
- height: 120rpx;
- border-bottom: 1px solid $border-color-light;
- .icon {
- font-size: 48rpx;
- padding-right: 20rpx;
- }
- .iconweixin1 {
- color: #18bf16;
- }
- .iconzhifubao {
- color: #08aaec;
- }
- .title-box {
- flex-grow: 1;
- text-align: left;
- .title {
- font-size: $font-base + 2rpx;
- color: $font-color-base;
- }
- .node {
- font-size: $font-sm;
- color: $font-color-light;
- }
- }
- }
- }
- ::v-deep .uni-radio-input {
- width: 45rpx;
- height: 45rpx;
- }
- .active-bg {
- background-color: $color-gray !important;
- }
- .now {
- width: 100%;
- height: 86rpx;
- padding: 0 26rpx 0 47rpx;
- display: flex;
- justify-content: space-between;
- line-height: 86rpx;
- background-color: #fff;
- // margin-bottom: 21rpx;
- view {
- font-size: 28rpx;
- font-weight: 500;
- color: #333333;
- }
- .now-money {
- font-size: 32rpx;
- font-weight: bold;
- color: $base-color;
- }
- }
- .add-wrapper {
- width: 750rpx;
- padding-left: 30rpx;
- background: #ffffff;
- display: flex;
- flex-direction: column;
- align-items: center;
- // margin-bottom: 22rpx;
- .add-box {
- width: 100%;
- height: 103rpx;
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- padding: 0 39rpx 0 10rpx;
- align-items: center;
- .add-log {
- font-size: 37rpx;
- font-weight: bold;
- }
- input {
- width: 218rpx;
- height: 30rpx;
- font-size: 32rpx;
- font-weight: 500;
- color: #000;
- line-height: 40px;
- text-align: right;
- .place {
- color: #bfbfbf;
- }
- }
- }
- .jg {
- width: 100%;
- }
- .add-tags {
- padding-top: 47rpx;
- padding-bottom: 17rpx;
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
- // justify-content: space-between;
- .tag {
- width: 210rpx;
- height: 140rpx;
- background-color: #f0f0f0;
- border-radius: 4rpx;
- margin: 0 30rpx 30rpx 0;
- text-align: center;
- font-size: 32rpx;
- font-weight: bold;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- .tip {
- font-weight: 500;
- font-size: 24rpx;
-
- }
- }
- .action {
- color: #fff;
- background-color: $base-color;
- }
- }
- }
- .btn-wrapper {
- padding: 40rpx 32rpx 40rpx 40rpx;
- // height: 183rpx;
- display: flex;
- justify-content: space-between;
- background-color: #fff;
- .iconweixin1 {
- color: #18bf16;
- font-size: 48rpx;
- display: flex;
- view {
- // display: inline-block;
- height: 48rpx;
- text-align: 48rpx;
- padding-left: 20rpx;
- // padding-top: 10rpx;
- color: #000000;
- font-size: 30rpx;
- }
- }
- .iconweixin2 {
- color: #fe8e2e;
- }
- .btn {
- width: 36rpx;
- height: 36rpx;
- border: 4rpx #3f3f3f solid;
- border-radius: 8rpx 8rpx;
- image {
- // display: none;
- width: 100%;
- height: 100%;
- }
- .action {
- display: none;
- }
- }
- .actiont {
- border: none;
- }
- }
- .main-jg {
- width: 100%;
- height: 21rpx;
- background-color: #f8f6f6;
- }
- .iconweixin {
- color: #36cb59;
- }
- </style>
|