管灌系统农户端微信小程序(嘉峪关应用)
zuoxiao
2024-05-30 7123295bac789011a9dad11938997721149a35ce
pages/openCard/openCard.js
@@ -11,57 +11,27 @@
  data: {
    intakeId: 0,
    allCardPoints: [{
        id: 511111111,
        balance: '30',
        state: 1
      },
      {
        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: [] // 所有虚拟卡
  },
  openValva(event) {
    const {
      item
    } = event.currentTarget.dataset; // 获取当前点击的 item
    if (item.state === 1) {
    if (item.inUse === 0) {
      // 在页面加载时显示加载动画
      wx.showLoading({
        title: '正在开泵请稍后...', // 加载提示文字
        mask: true // 是否显示透明蒙层,防止触摸穿透,默认为 false
      });
      this.postOpenValva();
      this.postOpenValva(item.vcId);
    }
  },
  //开泵通信
  postOpenValva() {
  postOpenValva(vcId) {
    const app = getApp();
    const data = {
      intakeId: this.data.intakeId, //取水口ID
      vcId: '2023122618460900006', //虚拟卡ID
      vcId: vcId, //虚拟卡ID
      userType: 2, //用户类型1-平台,2-App
      operator: app.globalData.sessionId //操作员
    };
@@ -69,7 +39,7 @@
      url: "comRes/receive",
      data: data
    }).then(response => {
      // 处理成功响应
      console.log('请求成功:', response);
      // 加载完成后隐藏加载动画
@@ -97,6 +67,7 @@
      intakeId
    })
    console.log('intakeId:' + this.data.intakeId);
    this. getCardList();
  },
  /**
@@ -146,5 +117,26 @@
   */
  onShareAppMessage() {
  },
  //获取虚拟卡列表
  getCardList(){
    get({url:'https://d4x9787456.vicp.fun/sell/virtual_card/get', data: {
      operator: getApp().globalData.sessionId
    }})
    .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);
    });
  }
})