| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317 |
- <template>
- <view>
- <!--mine/wallet/wallet.wxml-->
- <view class="bodry mt20">
- <image src="/wallet/static/wallet/images/topbg.png" class="walletbg"></image>
- <view class="balance">
- <view class="mywallet ddflex">
- 我的余额(元)
- <view class="hy-code ddflex" @click="jumpUrl('/mine/payCode/payCode')">
- <image src="../static/wallet/images/hy_ma.png" class="hy-ma"></image>
- 会员码
- </view>
- </view>
- <view class="bottm dflex">
- <view class="money">
- <!-- ¥ -->
- <text class="num">{{ money.all ? money.all : '0' }}</text>
- </view>
- <view class="detailed" @tap="toDetailed">余额明细</view>
- </view>
- </view>
- <!-- <view class="dflex top">
- <label style="font-size:32rpx;font-weight:bold;">我的余额</label>
- <view style="font-size:32rpx">
- <text class="qian"
- style="font-size:52rpx;font-weight:bold;margin-right: 10rpx;">{{money.all?money.all:'0'}}</text>元
- <view class="dflex yueDetaile " @tap="toDetailed">余额明细<image src="/static/pages/images/more.png" role="img"
- class="more"></image>
- </view>
- </view>
- </view> -->
- <!-- 充值金额 -->
- <view class="recharge">
- <view :class="'dflex rechargeId' + (isInt ? ' on' : '')">
- <text>¥</text>
- <!-- <input placeholder="点击输入充值金额" placeholder-class="placeholder" v-model="pay" @input="amount"
- @focus="focus" @blur="onBlur" /> -->
- <input placeholder="点击输入充值金额" placeholder-class="placeholder" disabled="true" v-model="pay" type="digit" @click="open()" />
- </view>
- <view class="rechargeMoney" v-if="TabList && TabList.length > 0">快捷充值</view>
- <view class="rechargeul dflex" v-if="TabList && TabList.length > 0">
- <view v-for="(item, index) in TabList" :key="index" :class="'rechargeli ' + (item.active ? 'active' : '')" @tap="switchTab(item, index)">
- <view :class="'wealth ' + (item.active ? 'awealth' : '')">充{{ item.rechargeAmount }}元</view>
- <view :class="'give ' + (item.active ? 'awealth' : '')" v-if="item.donationAmount > 0">送{{ item.donationAmount }}元</view>
- </view>
- </view>
- </view>
- </view>
- <!-- <view class="kong"></view> -->
- <!-- <view class="chongzhi" v-if="hideKey" @tap="remainder">立即充值</view> -->
- <!-- <view class="card" @tap="goCard">激活卡充值</view> -->
- <!-- <view class="kong"></view> -->
- <cu-keyboard ref="cukeyboard" @change="change" @confirm="confirm" @hide="hide" confirmText="充值" confirmBgColor="background-color:#FD3A31"></cu-keyboard>
- </view>
- </template>
- <script>
- // mine/wallet/wallet.js
- const route = require('../../utils/route.js');
- const req = require('../../utils/request');
- const app = getApp();
- export default {
- data() {
- return {
- TabList: [],
- money: '',
- id: '',
- pay: '',
- active: false,
- isInt: false,
- hideKey: false
- };
- },
- components: {},
- props: {},
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- this.open();
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function() {
- this.extendNew();
- this.balance();
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function() {},
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function() {},
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function() {},
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function() {},
- methods: {
- change(e) {
- this.pay = e;
- console.log('数字改变', e);
- },
- open() {
- console.log('打开键盘');
- this.hideKey = false;
- this.$refs.cukeyboard.open();
- this.$refs.cukeyboard.value = this.pay;
- this.TabList.map(it => {
- it.active = false;
- return it;
- });
- this.$forceUpdate();
- },
- confirm(e) {
- if (!this.pay && this.pay <= 0) {
- req.msg('请输入充值金额');
- return;
- }
- this.hide();
- this.remainder();
- },
- hide() {
- this.hideKey = true;
- this.TabList.map(it => {
- it.active = false;
- return it;
- });
- this.$forceUpdate();
- console.log('关闭键盘');
- },
- // 查询用户余额
- extendNew() {
- route.extendNew({}, res => {
- this.setData({
- money: res
- });
- console.log(res);
- this.$forceUpdate();
- });
- },
- // 查询余额充值策略
- balance() {
- route.balance({}, res => {
- // res=res.map(it=>{
- // it.active=false
- // return it
- // })
- if (!res) {
- } else if (res.length > 0) {
- this.setData({
- TabList: res
- // ['TabList[0].active']: true,
- // id: res[0].id,
- // pay: res[0].rechargeAmount
- });
- }
- console.log(this.TabList);
- });
- },
- switchTab(item, index) {
- // let index = event.currentTarget.dataset.index;
- // let id = event.currentTarget.dataset.id;
- // let money = event.currentTarget.dataset.money;
- let def = this.TabList.findIndex(it => it.active || it.actives);
- let d = {};
- console.log(def, index);
- d['TabList[' + def + '].active'] = false;
- d['TabList[' + def + '].actives'] = false;
- d['TabList[' + index + '].active'] = true;
- d['pageList'] = []; // this.data.form.states=this.data.TabList[index].state.toString();
- // this.data.form.state = this.data.TabList[index].state;
- console.log(item);
- this.setData({
- id: item.id,
- active: false,
- pay: item.rechargeAmount
- });
- this.setData(d);
- },
- switchTab1() {
- let def = this.TabList.findIndex(it => it.active);
- let d = {};
- if (def == -1) return;
- d['TabList[' + def + '].active'] = false;
- d['TabList[' + 0 + '].actives'] = true;
- this.setData({
- active: true,
- id: ''
- });
- this.setData(d);
- },
- // 输入金额根据输入金额获取赠送多少金额
- amount(e) {
- console.log(e.detail.value);
- let money = e.detail.value;
- this.setData({
- pay: money,
- id: ''
- });
- },
- focus(e) {
- this.setData({
- pay: ''
- });
- this.isInt = true;
- let def = this.TabList.findIndex(it => it.active);
- let d = {};
- console.log(def);
- if (!e.detail.value) {
- } else {
- let money = e.detail.value;
- this.setData({
- pay: money
- });
- }
- if (def == -1) return;
- d['TabList[' + def + '].active'] = false;
- d['TabList[' + 0 + '].actives'] = true;
- console.log(e, '111111111111', e.detail.value);
- this.setData(d);
- this.setData({
- id: ''
- });
- },
- onBlur() {
- this.isInt = false;
- },
- //跳充值卡
- goCard() {
- app.globalData.navigateTo('wallet/rechargeCard/index');
- },
- // 余额充值
- remainder(id) {
- let that = this;
- let from = {};
- if (this.pay && this.pay > 0) {
- if(this.pay > 300000){
- return req.msg('输入的充值金额需小于30万元');
- }else{
- from.money = this.pay;
- }
- } else {
- return req.msg('输入的充值金额需大于0');
- }
- if (this.id) {
- from.rulesId = this.id;
- delete from.money;
- }
- route.remainder(from, data => {
- if (!data) {
- return req.msg('创建订单失败');
- } else {
- route.balancePay(data, '4', that.pay, res => {
- console.log('充值回调res==',res)
- if (res) {
- that.extendNew();
- that.active = false;
- if (that.TabList && that.TabList.length > 0) {
- that.TabList[0].active = true;
- that.id = that.TabList[0].id;
- that.pay = that.TabList[0].rechargeAmount;
- }else{
- that.pay = '';
- }
- }
- });
- }
- console.log(data);
- });
- },
- // 跳转余额明细
- toDetailed() {
- app.globalData.navigateTo('wallet/detailed/detailed');
- },
- onHide() {
- this.setData({
- active: false
- });
- },
- jumpUrl(url) {
- uni.navigateTo({
- url: url
- });
- }
- }
- };
- </script>
- <style>
- @import './index.css';
- </style>
|