绿满眶商城微信小程序-uniapp
peng
2025-08-08 8a2d6949a4525f90e0e75f2f3f83c13b8830a758
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
 
<template>
  <view>
    <view class="-list">
      <view class="title">充值金额</view>
      <view class="content">
        <view class="price">
          <span> ¥</span>
          <input v-model="price" style="height: 120rpx;" placeholder='金额' type="number" />
                    
        </view>
 
      </view>
    </view>
 
    <view class="submit" :class="{'light':flag}" @click="handlerRecharge">充值</view>
  </view>
</template>
<script>
import '@/components/uview-components/uview-ui'
import { recharge } from "@/api/members";
export default {
  data() {
    return {
      price: 0,
      flag: true,
    };
  },
  watch: {
    price(val) {
      val <= 0 ? (this.flag = true) : (this.flag = false);
    },
  },
  mounted() {},
  methods: {
    // 充值
    async handlerRecharge() {
      if (this.price > 0) {
       
        let res = await recharge({ price: this.price });
        if (res.data.success) {
          uni.navigateTo({
            url: `/pages/cart/payment/payOrder?orderType=RECHARGE&recharge_sn=${res.data.result.rechargeSn}`,
          });
        }
      }
    },
  },
};
</script>
<style lang="scss" scoped>
@import './style.scss';
.price{
    width: 60%;
    margin: 20rpx 0;
    font-size: 40rpx;
    display: flex;
    align-items: center;
    justify-content: center;
}
</style>