管灌系统农户端微信小程序(嘉峪关应用)
zuoxiao
2024-07-04 c6ad105d1b743bcfd8aa6ee2781d39039f319a87
添加tag
9个文件已修改
119 ■■■■ 已修改文件
api/request.js 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app.js 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app.json 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/home/home.js 40 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/home/home.wxml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/home/home.wxss 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/waterIntake/waterIntake.js 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/waterIntake/waterIntake.wxml 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/waterIntake/waterIntake.wxss 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/request.js
@@ -31,11 +31,12 @@
    data,
    ignoreToken,
    form,
    isShowLoding
    isShowLoding,
    timeout,
    header
  } = _options
  const app = getApp()
  // 设置请求头
  let header = {}
  if (form) {
    header = {
      'content-type': 'application/x-www-form-urlencoded'
@@ -45,11 +46,16 @@
      'content-type': 'application/json' //自定义请求头信息
    }
  }
  if (!timeout) {
    timeout = 60000
  }
  if (!ignoreToken) {
    // 从全局变量中获取token
    let token = app.globalData.token
    header.Authorization = `Bearer ${token}`
  }
  header.tag = app.globalData.tag;
  return new Promise((resolve, reject) => {
    console.log("url:" + BASEURL + url);
    if (isShowLoding) {
@@ -69,6 +75,7 @@
      data,
      header,
      method,
      timeout: timeout,
      success: (res) => {
        let {
          statusCode: code
@@ -101,7 +108,6 @@
        if (isShowLoding) {
          wx.hideLoading(); // 隐藏加载动画
        }
        // showToast(err.errMsg)
        reject(err)
      }
app.js
@@ -15,6 +15,7 @@
  },
  globalData: {
    sessionId:'2024052821300200006',
    tag:'ym',
    userInfo: null,
    userId:"",
    userCode:"",
app.json
@@ -25,4 +25,6 @@
  "componentFramework": "glass-easel",
  "sitemapLocation": "sitemap.json",
  "lazyCodeLoading": "requiredComponents"
}
pages/home/home.js
@@ -20,7 +20,12 @@
    scrollViewHeight: 0,
    listData: [],
    isRefreshing: false,
    isWXRefreshing: false
    isWXRefreshing: false,
    errorData: '', //错误内容
    showErrorDialog: false,
    confirmBtn: {
      content: '确认'
    },
  },
  openValve: function (e) {
@@ -213,7 +218,8 @@
    post({
      url: "wx/valve/close_wx",
      data: data,
      isShowLoding: false
      isShowLoding: false,
      timeout: 185000
    }).then(response => {
      // 处理成功响应
@@ -228,13 +234,10 @@
      })
    }).catch(error => {
      wx.hideLoading();
      if (error.code === "1002") {
        wx.showToast({
          title: '关阀失败',
          icon: 'error',
          duration: 3000 // 提示的持续时间,单位毫秒
        })
      }
      this.setData({
        showErrorDialog: true,
        errorData: error.msg
      })
      // 处理错误响应
      console.error('请求失败:', error);
@@ -261,6 +264,12 @@
      // 错误回调
      this.setData({
        isRefreshing: false, // 将triggered属性设置为false,表示下拉刷新已完成
        isWXRefreshing: false, // 将triggered属性设置为false,表示下拉刷新已完成
      })
      wx.showToast({
        title: err.msg,
        icon: 'error',
        duration: 3000
      })
    });
  },
@@ -278,7 +287,7 @@
  getUserDataBySession() {
    const app = getApp();
    const params = {
      url: 'sell/client/simple_info',
      url: 'wx/client/simple_info',
      data: {
        sessionId: app.globalData.sessionId
      }
@@ -290,7 +299,11 @@
      })
    }).catch(err => {
      // 错误回调
      wx.showToast({
        title: err.msg,
        icon: 'error',
        duration: 3000
      })
    })
  },
  maskPhoneNumber(phoneNumber) {
@@ -300,6 +313,11 @@
    // 使用正则表达式替换中间四位数字为星号
    const maskedPhoneNumber = phoneNumber.replace(/^(\d{3})\d{4}(\d{4})$/, "$1****$2");
    return maskedPhoneNumber;
  },
  closeDialog() {
    this.setData({
      showErrorDialog:false
    })
  }
pages/home/home.wxml
@@ -64,6 +64,6 @@
      <text class="noMore-text">没有开泵记录</text>
    </view>
  </scroll-view>
  <t-dialog class="t-dialog" visible="{{showConfirm}}" content="确认关闭{{waterIntakeName}}吗?" confirm-btn="{{ { content: '确认', variant: 'base', theme: 'danger' } }}" close-on-overlay-click="false" cancel-btn="取消"  bind:confirm="confirmDialog" bind:cancel="closeDialog" />
  <t-dialog class="dialog" visible="{{showConfirm}}" content="确认关闭{{waterIntakeName}}吗?" confirm-btn="{{ { content: '确认', variant: 'base', theme: 'danger' } }}" close-on-overlay-click="false" cancel-btn="取消"  bind:confirm="confirmDialog" bind:cancel="closeDialog" />
  <t-dialog class="error-dialog"  title="关阀错误" visible="{{showErrorDialog}}" content="{{errorData}}" confirm-btn="{{ confirmBtn }}" bind:confirm="closeDialog" />
</view>
pages/home/home.wxss
@@ -281,7 +281,7 @@
  margin-left: 20rpx;
}
.t-dialog {
.dialog {
  --td-dialog-content-font-size: 40rpx;
  --td-dialog-content-line-height: 50rpx
}
@@ -315,4 +315,9 @@
  width: 100%;
  margin-top: 2rpx;
  /* background-color: #e0e0e0; */
}
.error-dialog{
  --td-dialog-title-color:red;
  --td-dialog-title-font-size:40rpx;
}
pages/waterIntake/waterIntake.js
@@ -13,7 +13,12 @@
    isRefreshing_common: false,
    showConfirm: false,
    waterIntakeName: "",
    choseItem: null
    choseItem: null,
    errorData: '', //错误内容
    showErrorDialog: false,
    confirmBtn: {
      content: '确认'
    },
  },
  // 切换 Tabs
@@ -67,7 +72,8 @@
    };
    post({
      url: "wx/valve/open_wx",
      data: data
      data: data,
      timeout: 180000
    }).then(response => {
      // 处理成功响应
@@ -84,13 +90,12 @@
      wx.hideLoading();
      // 处理错误响应
      console.error('请求失败:', error);
      if (error.code === "1002") {
        wx.showToast({
          title: '开阀失败',
          icon: 'error',
          duration: 3000 // 提示的持续时间,单位毫秒
        })
      }
      this.setData({
        showErrorDialog: true,
        errorData: error.msg
      })
    });
  },
@@ -151,7 +156,7 @@
   */
  getallWaterPoints: function (intakeNum) {
    let params = {
      url: 'project/intake/all_intakes'
      url: 'wx/intake/all_intakes'
    };
    if (intakeNum) {
      params.data = {
@@ -178,13 +183,18 @@
        this.setData({
          isRefreshing_all: false
        });
        wx.showToast({
          title: error.msg,
          icon: 'error',
          duration: 3000 // 提示的持续时间,单位毫秒
        })
        console.error('Failed to add item:', error);
      });
  },
  //获取常用取水口
  getcommonWaterPoints() {
    get({
        url: 'project/intake/used_intakes',
        url: 'wx/intake/used_intakes',
        data: {
          operator: getApp().globalData.sessionId
        }
@@ -209,7 +219,7 @@
          isRefreshing_common: false
        });
        wx.showToast({
          title: error.code,
          title: error.msg,
          icon: 'error',
          duration: 3000 // 提示的持续时间,单位毫秒
        })
@@ -227,7 +237,7 @@
  },
  confirmDialog() {
    this.setData({
      showConfirm:false
      showConfirm: false
    })
    this.postOpenValva(this.data.choseItem.intakeId);
  },
@@ -235,6 +245,10 @@
    this.setData({
      showConfirm: false
    })
  },
  closeErrorDialog() {
    this.setData({
      showErrorDialog: false
    })
  }
})
pages/waterIntake/waterIntake.wxml
@@ -51,5 +51,7 @@
    </scroll-view>
  </view>
  <t-dialog class="t-dialog" visible="{{showConfirm}}" content="确认打开{{choseItem.intakeNum}}吗?" confirm-btn="{{ { content: '确认', variant: 'base', theme: 'danger' } }}" close-on-overlay-click="false" cancel-btn="取消"  bind:confirm="confirmDialog" bind:cancel="closeDialog" />
  <t-dialog class="dialog" visible="{{showConfirm}}" content="确认打开{{choseItem.intakeNum}}吗?" confirm-btn="{{ { content: '确认', variant: 'base', theme: 'danger' } }}" close-on-overlay-click="false" cancel-btn="取消"  bind:confirm="confirmDialog" bind:cancel="closeDialog" />
  <t-dialog class="error-dialog"  title="开阀错误" visible="{{showErrorDialog}}" content="{{errorData}}" confirm-btn="{{ confirmBtn }}" bind:confirm="closeErrorDialog" />
</view>
pages/waterIntake/waterIntake.wxss
@@ -135,7 +135,12 @@
  flex-direction: column;
  padding-bottom: 10rpx; /* 增加底部填充 */
}
.t-dialog{
.dialog{
  --td-dialog-content-font-size:40rpx;
  --td-dialog-content-line-height:50rpx
}
.error-dialog{
  --td-dialog-title-color:red;
  --td-dialog-title-font-size:45rpx;
}