api接口baseUrl通过全局变量引入;代码格式化
This commit is contained in:
		@@ -1,36 +1,35 @@
 | 
			
		||||
const app = getApp()
 | 
			
		||||
const baseUrl = app.globalData.baseUrl
 | 
			
		||||
// console.log("baseUrl", baseUrl)
 | 
			
		||||
 | 
			
		||||
Page({
 | 
			
		||||
 
 | 
			
		||||
  data:{
 | 
			
		||||
   
 | 
			
		||||
      tableInfo: {},
 | 
			
		||||
      count:''
 | 
			
		||||
  data: {
 | 
			
		||||
    tableInfo: {},
 | 
			
		||||
    count: ''
 | 
			
		||||
  },
 | 
			
		||||
   
 | 
			
		||||
   
 | 
			
		||||
 | 
			
		||||
  onReady: function () {
 | 
			
		||||
      // 生命周期函数--监听页面初次渲染完成
 | 
			
		||||
      var that = this;
 | 
			
		||||
      wx.request({
 | 
			
		||||
        url: 'http://127.0.0.1:8080/report/myReport',
 | 
			
		||||
        data: {
 | 
			
		||||
          id:wx.getStorageSync('id')
 | 
			
		||||
        },
 | 
			
		||||
        success: function (d) {
 | 
			
		||||
          let item = [];
 | 
			
		||||
          for (const iterator of d.data.data) {
 | 
			
		||||
            let item1 = [iterator.name,iterator.time,iterator.normal,iterator.address];
 | 
			
		||||
            item.push(item1)
 | 
			
		||||
          }
 | 
			
		||||
          that.setData({
 | 
			
		||||
            tableInfo:{
 | 
			
		||||
              title:["姓名","填报时间","体温状况","位置"],
 | 
			
		||||
              contentItem: item,
 | 
			
		||||
            },
 | 
			
		||||
            count: d.data.data.length
 | 
			
		||||
          })
 | 
			
		||||
    // 生命周期函数--监听页面初次渲染完成
 | 
			
		||||
    var that = this;
 | 
			
		||||
    wx.request({
 | 
			
		||||
      url: `${baseUrl}/report/myReport`,
 | 
			
		||||
      data: {
 | 
			
		||||
        id: wx.getStorageSync('id')
 | 
			
		||||
      },
 | 
			
		||||
      success: function (d) {
 | 
			
		||||
        let item = [];
 | 
			
		||||
        for (const iterator of d.data.data) {
 | 
			
		||||
          let item1 = [iterator.name, iterator.time, iterator.normal, iterator.address];
 | 
			
		||||
          item.push(item1)
 | 
			
		||||
        }
 | 
			
		||||
      })
 | 
			
		||||
      
 | 
			
		||||
    },
 | 
			
		||||
   
 | 
			
		||||
  })
 | 
			
		||||
        that.setData({
 | 
			
		||||
          tableInfo: {
 | 
			
		||||
            title: ["姓名", "填报时间", "体温状况", "位置"],
 | 
			
		||||
            contentItem: item,
 | 
			
		||||
          },
 | 
			
		||||
          count: d.data.data.length
 | 
			
		||||
        })
 | 
			
		||||
      }
 | 
			
		||||
    })
 | 
			
		||||
  },
 | 
			
		||||
})
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,6 @@
 | 
			
		||||
// pages/report/report.js
 | 
			
		||||
const app = getApp()
 | 
			
		||||
const baseUrl = app.globalData.baseUrl
 | 
			
		||||
// console.log("baseUrl", baseUrl)
 | 
			
		||||
 | 
			
		||||
var util = require('../../utils/util')
 | 
			
		||||
Page({
 | 
			
		||||
@@ -6,30 +8,44 @@ Page({
 | 
			
		||||
   * 页面的初始数据
 | 
			
		||||
   */
 | 
			
		||||
  data: {
 | 
			
		||||
    id:'',
 | 
			
		||||
    id: '',
 | 
			
		||||
    address: '',
 | 
			
		||||
    time: '',
 | 
			
		||||
    radio1: [{value:'正常',checked: 'true'},{value:'发热'}],
 | 
			
		||||
    radio2:[{value:'无需隔离',checked:'true'},{value:'居家隔离'},{value:'集中隔离'},{value:'入院隔离'}],
 | 
			
		||||
    normal:'正常',
 | 
			
		||||
    isolation:'无需隔离',
 | 
			
		||||
    radio1: [{
 | 
			
		||||
      value: '正常',
 | 
			
		||||
      checked: 'true'
 | 
			
		||||
    }, {
 | 
			
		||||
      value: '发热'
 | 
			
		||||
    }],
 | 
			
		||||
    radio2: [{
 | 
			
		||||
      value: '无需隔离',
 | 
			
		||||
      checked: 'true'
 | 
			
		||||
    }, {
 | 
			
		||||
      value: '居家隔离'
 | 
			
		||||
    }, {
 | 
			
		||||
      value: '集中隔离'
 | 
			
		||||
    }, {
 | 
			
		||||
      value: '入院隔离'
 | 
			
		||||
    }],
 | 
			
		||||
    normal: '正常',
 | 
			
		||||
    isolation: '无需隔离',
 | 
			
		||||
    name: '',
 | 
			
		||||
    stuId: '',
 | 
			
		||||
    yes_noon_temp:36.2,
 | 
			
		||||
    yes_night_temp:36.4,
 | 
			
		||||
    today_morning_temp:36.2
 | 
			
		||||
    yes_noon_temp: 36.2,
 | 
			
		||||
    yes_night_temp: 36.4,
 | 
			
		||||
    today_morning_temp: 36.2
 | 
			
		||||
  },
 | 
			
		||||
  radioChange1: function(e) {
 | 
			
		||||
  radioChange1: function (e) {
 | 
			
		||||
    this.setData({
 | 
			
		||||
      normal:e.detail.value
 | 
			
		||||
      normal: e.detail.value
 | 
			
		||||
    })
 | 
			
		||||
  },
 | 
			
		||||
  radioChange2: function(e) {
 | 
			
		||||
  radioChange2: function (e) {
 | 
			
		||||
    this.setData({
 | 
			
		||||
      isolation:e.detail.value
 | 
			
		||||
      isolation: e.detail.value
 | 
			
		||||
    })
 | 
			
		||||
  },
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  chooseLocation: function () {
 | 
			
		||||
    var that = this;
 | 
			
		||||
    wx.getSetting({
 | 
			
		||||
@@ -37,7 +53,7 @@ Page({
 | 
			
		||||
        if (!res.authSetting['scope.userLocation']) {
 | 
			
		||||
          wx.authorize({
 | 
			
		||||
            scope: 'scope.userLocationBackground',
 | 
			
		||||
            success(){
 | 
			
		||||
            success() {
 | 
			
		||||
              that.location();
 | 
			
		||||
            }
 | 
			
		||||
          })
 | 
			
		||||
@@ -48,7 +64,7 @@ Page({
 | 
			
		||||
    })
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  location:function () {
 | 
			
		||||
  location: function () {
 | 
			
		||||
    var that = this;
 | 
			
		||||
    wx.chooseLocation({
 | 
			
		||||
      success: function (res) {
 | 
			
		||||
@@ -65,7 +81,7 @@ Page({
 | 
			
		||||
    })
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  myreport:function () {
 | 
			
		||||
  myreport: function () {
 | 
			
		||||
    wx.navigateTo({
 | 
			
		||||
      url: './myreport'
 | 
			
		||||
    })
 | 
			
		||||
@@ -73,39 +89,39 @@ Page({
 | 
			
		||||
 | 
			
		||||
  report: function () {
 | 
			
		||||
    var that = this
 | 
			
		||||
    if(this.data.address==''){
 | 
			
		||||
    if (this.data.address == '') {
 | 
			
		||||
      wx.showToast({
 | 
			
		||||
        title: '请先选择地址',
 | 
			
		||||
        icon: 'none',
 | 
			
		||||
        duration: 2000
 | 
			
		||||
      })
 | 
			
		||||
    }else{
 | 
			
		||||
    } else {
 | 
			
		||||
      wx.request({
 | 
			
		||||
        url: 'http://127.0.0.1:8080/report/doReport',
 | 
			
		||||
        url: `${baseUrl}/report/doReport`,
 | 
			
		||||
        data: {
 | 
			
		||||
          user_id:this.data.id,
 | 
			
		||||
          name:this.data.name,
 | 
			
		||||
          user_id: this.data.id,
 | 
			
		||||
          name: this.data.name,
 | 
			
		||||
          address: this.data.address,
 | 
			
		||||
          time: this.data.time,
 | 
			
		||||
          normal:this.data.normal,
 | 
			
		||||
          yes_noon_temp:this.data.yes_noon_temp,
 | 
			
		||||
          yes_night_temp:this.data.yes_night_temp,
 | 
			
		||||
          today_morning_temp:this.data.today_morning_temp,
 | 
			
		||||
          isolation:this.data.isolation
 | 
			
		||||
          normal: this.data.normal,
 | 
			
		||||
          yes_noon_temp: this.data.yes_noon_temp,
 | 
			
		||||
          yes_night_temp: this.data.yes_night_temp,
 | 
			
		||||
          today_morning_temp: this.data.today_morning_temp,
 | 
			
		||||
          isolation: this.data.isolation
 | 
			
		||||
        },
 | 
			
		||||
        success: function (d) {
 | 
			
		||||
          
 | 
			
		||||
 | 
			
		||||
          if (d.data == "填报成功") {
 | 
			
		||||
            wx.showToast({
 | 
			
		||||
              title: d.data,
 | 
			
		||||
              icon: 'success',
 | 
			
		||||
              success: function () {
 | 
			
		||||
                if(that.data.normal != "发热" && that.data.isolation == "无需隔离"){
 | 
			
		||||
                  wx.setStorageSync("state",that.formatDate(new Date()))
 | 
			
		||||
                }else{
 | 
			
		||||
                  wx.setStorageSync("state","1999-01-01")
 | 
			
		||||
                if (that.data.normal != "发热" && that.data.isolation == "无需隔离") {
 | 
			
		||||
                  wx.setStorageSync("state", that.formatDate(new Date()))
 | 
			
		||||
                } else {
 | 
			
		||||
                  wx.setStorageSync("state", "1999-01-01")
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
              }
 | 
			
		||||
            })
 | 
			
		||||
          } else {
 | 
			
		||||
@@ -119,16 +135,16 @@ Page({
 | 
			
		||||
      })
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  formatDate: function(date) {
 | 
			
		||||
  formatDate: function (date) {
 | 
			
		||||
    let year = date.getFullYear()
 | 
			
		||||
    let month = date.getMonth() + 1
 | 
			
		||||
    month = month.toString()
 | 
			
		||||
    month[1] ? month=month :month='0' + month
 | 
			
		||||
    month[1] ? month = month : month = '0' + month
 | 
			
		||||
    let day = date.getDate()
 | 
			
		||||
    day = day.toString()
 | 
			
		||||
    day[1] ? day=day : day='0' + day
 | 
			
		||||
    return year+"-"+month+"-"+day
 | 
			
		||||
   },
 | 
			
		||||
    day[1] ? day = day : day = '0' + day
 | 
			
		||||
    return year + "-" + month + "-" + day
 | 
			
		||||
  },
 | 
			
		||||
  /**
 | 
			
		||||
   * 生命周期函数--监听页面加载
 | 
			
		||||
   */
 | 
			
		||||
@@ -152,7 +168,7 @@ Page({
 | 
			
		||||
      time: TIME,
 | 
			
		||||
      name: wx.getStorageSync('name'),
 | 
			
		||||
      stuId: wx.getStorageSync('stuId'),
 | 
			
		||||
      id:wx.getStorageSync('id')
 | 
			
		||||
      id: wx.getStorageSync('id')
 | 
			
		||||
    });
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
@@ -190,4 +206,4 @@ Page({
 | 
			
		||||
  onShareAppMessage: function () {
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
})
 | 
			
		||||
})
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user