管灌系统农户端微信小程序(嘉峪关应用)
zuoxiao
2024-05-30 910c37c43eceb27888b90631c868caa08f7eafcc
pages/openCard/openCard.js
@@ -1,10 +1,16 @@
// pages/openCard/openCard.js
// 开卡选择虚拟卡
const {
  get,
  post
} = require('../../api/request.js');
Page({
  /**
   * 页面的初始数据
   */
  data: {
    intakeId: 0,
    allCardPoints: [{
        id: 511111111,
        balance: '30',
@@ -47,23 +53,50 @@
        title: '正在开泵请稍后...', // 加载提示文字
        mask: true // 是否显示透明蒙层,防止触摸穿透,默认为 false
      });
      // 模拟加载数据
      setTimeout(() => {
        // 加载完成后隐藏加载动画
        wx.hideLoading();
        //完成后回到首页
        wx.reLaunch({
          url: '/pages/home/home?param=true' // 首页的路径,根据实际情况填写
        });
      }, 2000); // 延时 2 秒模拟加载数据
      this.postOpenValva();
    }
  },
  //开泵通信
  postOpenValva() {
    const app = getApp();
    const data = {
      intakeId: this.data.intakeId, //取水口ID
      vcId: '2023122618460900006', //虚拟卡ID
      userType: 2, //用户类型1-平台,2-App
      operator: app.globalData.sessionId //操作员
    };
    post({
      url: "comRes/receive",
      data: data
    }).then(response => {
      // 处理成功响应
      console.log('请求成功:', response);
      // 加载完成后隐藏加载动画
      wx.hideLoading();
      //完成后回到首页
      wx.reLaunch({
        url: '/pages/home/home?param=true' // 首页的路径,根据实际情况填写
      });
    }).catch(error => {
      // 加载完成后隐藏加载动画
      wx.hideLoading();
      // 处理错误响应
      console.error('请求失败:', error);
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    const {
      intakeId
    } = options;
    this.setData({
      intakeId
    })
    console.log('intakeId:' + this.data.intakeId);
  },
  /**