管灌系统农户端微信小程序(嘉峪关应用)
zuoxiao
2025-03-06 91751b1b9b16c0044e16ad80c237b7275a409046
pages/rechargeCard/rechargeCard.js
@@ -1,54 +1,19 @@
// pages/rechargeCard/rechargeCard.js
const {
  get,
  post
} = require('../../api/request.js');
Page({
  /**
   * 页面的初始数据
   */
  data: {
    confirmBtn: { content: '确认', variant: 'base' },
    currentTab: 0, // 当前显示的表格,默认为第一个表格
    allCardPoints: [{
      id: 511111111,
      balance: '30000',
      state: 1
    },{
      id: 411111111,
      balance: '30',
      state: 0
    },{
      id: 411111111,
      balance: '30',
      state: 0
    },{
      id: 411111111,
      balance: '30',
      state: 0
    },
    {
      id: 411111111,
      balance: '30',
      state: 0
    },
    {
      id: 31111111111,
      balance: '30',
      state: 1
    },
    {
      id: 2,
      balance: '30',
      state: 1
    },
    {
      id: 1,
      balance: '30',
      state: 1
    },
    {
      id: 0,
      balance: '30',
      state: 1
    },
  ]
    allCardPoints: [],
    allWaterPoints:[],
    showDialog:false
  },
 // 切换 Tabs
 switchTab: function (e) {
@@ -61,7 +26,8 @@
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getCardList();
    this.getWaterCardList();
  },
  /**
@@ -111,6 +77,59 @@
   */
  onShareAppMessage() {
  },//获取虚拟卡列表
  getCardList(){
    get({url:'https://d4x9787456.vicp.fun/sell/virtual_card/get', data: {
      operator: getApp().globalData.operator
    }})
    .then((data) => {
      if(data.success&&data.code==="0001"){
        this.setData({
          allCardPoints:  data.content
        });
      }else{
        wx.showToast({
          title: data.msg,
        })
      }
      console.log('Failed to add item:');
    })
    .catch((error) => {
      console.error('Failed to add item:', error);
    });
  },
  getWaterCardList(){
    get({url:'https://d4x9787456.vicp.fun/sell/virtual_card/get', data: {
      operator: getApp().globalData.operator
    }})
    .then((data) => {
      if(data.success&&data.code==="0001"){
        this.setData({
          allWaterPoints:  data.content
        });
      }else{
        wx.showToast({
          title: data.msg,
        })
      }
      console.log('Failed to add item:');
    })
    .catch((error) => {
      console.error('Failed to add item:', error);
    });
  },
  rechargeCard(item){
    wx.navigateTo({
      url: '/pages/rechargeMoney/rechargMoney' // 首页的路径,根据实际情况填写
    });
  },
  ruinCard(){
  },
  closeDialog(){
    this.setData({
      showDialog:false
    })
  }