绿满眶商城微信小程序-uniapp
xiangpei
2025-05-26 86cbf346204232ba9a4ffea6fbcb4d9d2b521916
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
 
<template>
  <view>
    <view class="-list">
      <view class="title">充值金额</view>
      <view class="content">
        <view class="price">
          <span> ¥</span>
          <u-input v-model="price" placeholder='金额' type="number" />
                    
        </view>
 
      </view>
    </view>
 
    <view class="submit" :class="{'light':flag}" @click="handlerRecharge">充值</view>
  </view>
</template>
<script>
import '@/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';
</style>