fix
13404089107
2025-07-28 2e90f57e7d28d6a949247ef39b487d3e75b56683
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<template>
  <view class="content">
    <view class="header-card" v-if="!loading.page">
      <view class="header-card-title">总饮水币</view>
      <view class="header-card-number">{{userInfo.ysb}}</view>
      <view class="header-card-illustrate" @click="$navTo('/pages/user/setup/documentDisplay?t=16&title=充值说明')">
        <image class="illustrate-icon" src="/static/icon/icon_info_circle.png_white.png" mode="widthFix"></image>
        <text class="illustrate-text">充值说明</text>
      </view>
    </view>
    <view class="cell">
      <view class="cell-item" v-for="(item,index) of list" :key="index">
        <view class="cell-item-info">{{item.gold}}金币</view>
        <button class="button cell-item-num" @click="topupHandle(item)">¥{{item.money}}</button>
      </view>
    </view>
    <u-loading-page :loading="loading.page"></u-loading-page>
  </view>
</template>
 
<script>
  export default {
    data() {
      return {
        loading:{
          page:true
        },
        userInfo:{},
        list:[],
        page:1
      };
    },
    onLoad() {
      this.init()
    },
    methods:{
      init(){
        this.$apis.user.getUserInfo().then(res=>{
          this.userInfo = res.data
        })
        this.$apis.user.getRechargeList({pageNum:this.page,pageSize:10,type:2}).then(res=>{
          this.list = res.data
          this.loading.page = false
        })
      },
      async topupHandle(e){
        this.$loading()
        try {
          let { data } = await this.$apis.user.recharge({id:e.id})
          uni.login({
            provider: 'weixin',
            success: (e) => {
              this.$apis.user.getPayInfoWx({type:3,OrderNum:data.order,code:e.code}).then(res=>{
                uni.requestPayment({
                  ...res.data,
                  success:ev=>{
                    this.$toast('支付成功')
                    this.init()
                  },
                  fail:err=>{
                    console.log(err);
                    if(err.errMsg == 'requestPayment:fail cancel'){
                      this.$toast('取消支付')
                    }else{
                      this.$toast('支付失败')
                    }
                  },
                  complete:()=>{
                    uni.hideLoading()
                  }
                })
              }).catch(e=>{
                uni.hideLoading()
              })
            }
          })
          
        } catch (error) {
          uni.hideLoading()
        }
        
      }
    }
  }
</script>
 
<style lang="scss">
.content{
  padding: 28rpx;
  .header-card{
    margin: 0 auto;
    width: 694rpx;
    height: 260rpx;
    background: #FF2729;
    border-radius: 20rpx;
    // box-shadow: 4rpx 4rpx 12rpx rgba(0, 0, 0, 0.05);
    padding: 19rpx;
    display: flex;
    flex-direction: column;
    .header-card-title{
      font-size: 27rpx;
      color: #FFFFFF;
      line-height: 27rpx;
      text-align: left;
      font-style: normal;
    }
    .header-card-number{
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 58rpx;
      color: #FFFFFF;
      line-height: 58rpx;
    }
    .header-card-illustrate{
      display: flex;
      align-items: center;
      justify-content: center;
      margin-bottom: 12rpx;
      .illustrate-icon{
        width: 27rpx;
      }
      .illustrate-text{
        padding-left: 16rpx;
        font-size: 24rpx;
        color: #FFFFFF;
        line-height: 24rpx;
      }
    }
  }
  .cell{
    margin-top: 10rpx;
    .cell-item{
      height: 100rpx;
      display: flex;
      align-items: center;
      border-bottom: 2rpx solid rgba(217, 217, 217, 0.4);
      .cell-item-info{
        flex: 1;
        font-size: 31rpx;
        color: #000000;
        line-height: 42rpx;
      }
      .cell-item-num{
        font-size: 27rpx;
        color: #FF2729;
        line-height: 27rpx;
        width: 160rpx;
        height: 58rpx;
        border-radius: 29rpx;
        border: 2rpx solid #FB282A;
        display: flex;
        align-items: center;
        justify-content: center;
      }
    }
  }
}
</style>