小程序端添加 删除今日填表
This commit is contained in:
		@@ -170,7 +170,7 @@ Page({
 | 
			
		||||
 | 
			
		||||
  updateTime() {
 | 
			
		||||
    let timestamp = Date.now()
 | 
			
		||||
    this.setData({
 | 
			
		||||
    this && this.setData({
 | 
			
		||||
      "formData.timestamp": timestamp,
 | 
			
		||||
      "formData.time": utils.formatTime(new Date(timestamp))
 | 
			
		||||
    })
 | 
			
		||||
@@ -312,5 +312,80 @@ Page({
 | 
			
		||||
    wx.navigateTo({
 | 
			
		||||
      url: "/pages/residents/reportHistory"
 | 
			
		||||
    })
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  // 删除今日填表
 | 
			
		||||
  withdrawReport() {
 | 
			
		||||
    wx.showLoading({
 | 
			
		||||
      title: '加载中'
 | 
			
		||||
    })
 | 
			
		||||
    var that = this;
 | 
			
		||||
    that.setData({
 | 
			
		||||
      isSubmitting: true,
 | 
			
		||||
    })
 | 
			
		||||
    wx.request({
 | 
			
		||||
      url: `${app.globalData.baseUrl}/access/report/withdraw`,
 | 
			
		||||
      method: "POST",
 | 
			
		||||
      header: {
 | 
			
		||||
        "Content-Type": "application/x-www-form-urlencoded" //用于post
 | 
			
		||||
      },
 | 
			
		||||
      data: {
 | 
			
		||||
        userId: this.data.userInfo.id
 | 
			
		||||
      },
 | 
			
		||||
      success: function (d) {
 | 
			
		||||
        console.log("begin success")
 | 
			
		||||
        wx.hideLoading()
 | 
			
		||||
        let result = d.data;
 | 
			
		||||
        if (result.success) {
 | 
			
		||||
          // 填报完成
 | 
			
		||||
          that.setData({
 | 
			
		||||
            isFilled: false,
 | 
			
		||||
            filledMsg: "",
 | 
			
		||||
            "formData.address": '',
 | 
			
		||||
          })
 | 
			
		||||
          console.log("result.data", result.data);
 | 
			
		||||
          wx.showToast({
 | 
			
		||||
            title: "删除成功",
 | 
			
		||||
            icon: 'success',
 | 
			
		||||
            duration: 2000,
 | 
			
		||||
          })
 | 
			
		||||
          // wx.showModal({
 | 
			
		||||
          //   title: '删除成功',
 | 
			
		||||
          //   content: '',
 | 
			
		||||
          //   showCancel: false,
 | 
			
		||||
          //   complete: (res) => {
 | 
			
		||||
          //   }
 | 
			
		||||
          // })
 | 
			
		||||
        } else {
 | 
			
		||||
          wx.showToast({
 | 
			
		||||
            title: result.msg || "出错啦",
 | 
			
		||||
            icon: 'error',
 | 
			
		||||
            duration: 2000
 | 
			
		||||
          })
 | 
			
		||||
        }
 | 
			
		||||
        that.isShow = ''
 | 
			
		||||
        console.log("end success")
 | 
			
		||||
      },
 | 
			
		||||
      fail: function () {
 | 
			
		||||
        console.log("begin fail")
 | 
			
		||||
        wx.hideLoading()
 | 
			
		||||
        wx.showToast({
 | 
			
		||||
          title: "请求失败",
 | 
			
		||||
          icon: 'error',
 | 
			
		||||
          duration: 2000
 | 
			
		||||
        })
 | 
			
		||||
        console.log("end fail")
 | 
			
		||||
      },
 | 
			
		||||
      complete: function () {
 | 
			
		||||
        that.setData({
 | 
			
		||||
          isSubmitting: false,
 | 
			
		||||
        })
 | 
			
		||||
        console.log("begin complete")
 | 
			
		||||
        if (typeof (callback) === "function")
 | 
			
		||||
          callback();
 | 
			
		||||
        wx.hideNavigationBarLoading();
 | 
			
		||||
        console.log("end complete")
 | 
			
		||||
      }
 | 
			
		||||
    })
 | 
			
		||||
  }
 | 
			
		||||
})
 | 
			
		||||
 
 | 
			
		||||
@@ -55,5 +55,6 @@
 | 
			
		||||
    <!--  -->
 | 
			
		||||
    <view style="margin: 40px 0;">{{ filledMsg }}</view>
 | 
			
		||||
    <button class="controlBtn" size="mini" type="none" bindtap="myreport">历史填报</button>
 | 
			
		||||
    <button class="controlBtn" size="mini" type="warn" bindtap="withdrawReport" disabled="{{isSubmitting}}">删除今日填报</button>
 | 
			
		||||
  </view>
 | 
			
		||||
</view>
 | 
			
		||||
@@ -1,33 +1,33 @@
 | 
			
		||||
/* pages/residents/reportHistory.wxss */
 | 
			
		||||
.item {
 | 
			
		||||
  /* background-color: #dedede; */
 | 
			
		||||
  border-radius: 8px;
 | 
			
		||||
  margin: 12px 20px;
 | 
			
		||||
  padding: 18px;
 | 
			
		||||
  display: grid;
 | 
			
		||||
  grid-template-columns: 1fr auto;
 | 
			
		||||
  place-items: center;
 | 
			
		||||
  color: white;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.item.normal {
 | 
			
		||||
  background-color: green;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.item.abnormal {
 | 
			
		||||
  background-color: red;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.record_time {
 | 
			
		||||
  font-size: 17px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.record_address {
 | 
			
		||||
  font-size: 15px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.statusText {
 | 
			
		||||
  font-size: large;
 | 
			
		||||
  font-weight: bold;
 | 
			
		||||
  padding: 0 20px;
 | 
			
		||||
}
 | 
			
		||||
/* pages/residents/reportHistory.wxss */
 | 
			
		||||
.item {
 | 
			
		||||
  /* background-color: #dedede; */
 | 
			
		||||
  border-radius: 8px;
 | 
			
		||||
  margin: 12px 20px;
 | 
			
		||||
  padding: 18px;
 | 
			
		||||
  display: grid;
 | 
			
		||||
  grid-template-columns: 1fr auto;
 | 
			
		||||
  place-items: center left;
 | 
			
		||||
  color: white;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.item.normal {
 | 
			
		||||
  background-color: green;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.item.abnormal {
 | 
			
		||||
  background-color: red;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.record_time {
 | 
			
		||||
  font-size: 17px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.record_address {
 | 
			
		||||
  font-size: 15px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.statusText {
 | 
			
		||||
  font-size: large;
 | 
			
		||||
  font-weight: bold;
 | 
			
		||||
  padding: 0 20px;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user