diff --git a/pages/index/index.js b/pages/index/index.js
index 7751d55..50176fc 100644
--- a/pages/index/index.js
+++ b/pages/index/index.js
@@ -1,4 +1,9 @@
//index.js
+
+const req = require('../../utils/request.js')
+const util = require('../../utils/util.js')
+
+const Case_List_URL = "/platform/app/case/getCases";
//获取应用实例
const app = getApp()
@@ -29,12 +34,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
- if (typeof this.getTabBar === 'function' &&
- this.getTabBar()) {
- this.getTabBar().setData({
- selected: 0
- })
- }
+
},
/**
@@ -72,3 +72,48 @@ Page({
}
})
+
+Component({
+ data: {
+ surveyorId:"c64a18707e974f91945e0e872b7f5b98",
+ CaseList:undefined
+ },
+ methods: {
+ onLoad: function (options) {
+ var that = this;
+ console.log("onLoad1");
+ const dataParams = {
+ "pageSize": 20, "pageNumber": 1 ,
+ surveyorId: that.data.surveyorId
+ };
+
+ req.getRequest(Case_List_URL, dataParams, function (res) {
+ wx.hideLoading();
+ // console.log(res)
+ if (res.data.code == 0) {
+ let cases=res.data.data.list;
+ for(let c in cases){
+ let date = util.formatTime(cases[c].updatetime,"date")
+ cases[c].updatetime = date
+ }
+ that.setData({
+ CaseList: res.data.data.list
+ });
+ }
+ }, function (res) {
+ wx.hideLoading();
+ console.log(res);
+ });
+ }
+ },
+ pageLifetimes: {
+ show() {
+ if (typeof this.getTabBar === 'function' &&
+ this.getTabBar()) {
+ this.getTabBar().setData({
+ selected: 0
+ })
+ }
+ }
+ },
+})
\ No newline at end of file
diff --git a/pages/index/index.wxml b/pages/index/index.wxml
index 9b54d7d..0a83053 100644
--- a/pages/index/index.wxml
+++ b/pages/index/index.wxml
@@ -40,21 +40,22 @@
最新归档案件
-
+
- 关于工程水质污染案件的调查
- 重点
+ {{item.name}}
+ 重点
+ 一般
- 案件地点:汉阳区张家湾街道201号
+ 案件地点:{{item.address}}
案件类型:环境保护类
- 勘查单位:武汉市人民检察院
+ 勘查单位:{{item.unitname}}
- 2020/05/06
+ {{item.updatetime}}
-
+
-
+
diff --git a/pages/work/work.js b/pages/work/work.js
index 616034d..9da8fa8 100644
--- a/pages/work/work.js
+++ b/pages/work/work.js
@@ -1,3 +1,7 @@
+const req = require('../../utils/request.js')
+const util = require('../../utils/util.js')
+
+const Case_List_URL = "/platform/app/case/getCases";
// pages/work/work.js
//获取应用实例
const app = getApp()
@@ -8,22 +12,15 @@ Page({
* 页面的初始数据
*/
data: {
- menuTapCurrent:0
- },
- // 点击按钮选项卡切换
- menuTap: function (e) {
- var current = e.currentTarget.dataset.current;//获取到绑定的数据
- //改变menuTapCurrent的值为当前选中的menu所绑定的数据
- this.setData({
- menuTapCurrent: current
- });
+
},
+
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
-
+
},
/**
@@ -37,12 +34,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
- if (typeof this.getTabBar === 'function' &&
- this.getTabBar()) {
- this.getTabBar().setData({
- selected: 1
- })
- }
+
},
/**
@@ -79,4 +71,61 @@ Page({
onShareAppMessage: function () {
}
+})
+Component({
+ data: {
+ menuTapCurrent:0,
+ surveyorId:"c64a18707e974f91945e0e872b7f5b98",
+ CaseList:undefined
+ },
+
+ methods: {
+ // 点击按钮选项卡切换
+ menuTap: function (e) {
+ var current = e.currentTarget.dataset.current;//获取到绑定的数据
+ //改变menuTapCurrent的值为当前选中的menu所绑定的数据
+ this.setData({
+ menuTapCurrent: current
+ });
+ var that = this;
+ that.getList();
+ },
+ onLoad: function (options) {
+ wx.showLoading({
+ title: '加载中...',
+ });
+ var that = this;
+ that.getList();
+ },
+ getList: function () {
+ var that = this;
+ const data = { "pageSize": 20, "pageNumber": 1 , surveyorId: that.data.surveyorId,status: that.data.menuTapCurrent+1};
+ req.getRequest(Case_List_URL, data, function (res) {
+ wx.hideLoading();
+ if (res.data.code == 0) {
+ let cases=res.data.data.list;
+ for(let c in cases){
+ let date = util.formatTime(cases[c].updatetime,"date")
+ cases[c].updatetime = date
+ }
+ that.setData({
+ CaseList: cases
+ });
+ }
+ }, function (res) {
+ wx.hideLoading();
+ console.log(res);
+ });
+ }
+ },
+ pageLifetimes: {
+ show() {
+ if (typeof this.getTabBar === 'function' &&
+ this.getTabBar()) {
+ this.getTabBar().setData({
+ selected: 1
+ })
+ }
+ }
+ },
})
\ No newline at end of file
diff --git a/pages/work/work.wxml b/pages/work/work.wxml
index 7fa188e..2c1acb2 100644
--- a/pages/work/work.wxml
+++ b/pages/work/work.wxml
@@ -4,7 +4,7 @@
-
- 关于工程水质污染案件的调查
- 重点
+
+ {{item.name}}
+ 重点
+ 一般
- 案件编号:鄂[备]202005061120
- 案件地点:汉阳区张家湾街道201号
+ 案件编号:{{item.num}}
+ 案件地点:{{item.address}}
案件类型:环境保护类
- 2020/05/06
-
-
- 关于化工厂不合格排放烟尘的调查
- 一般
-
- 案件编号:鄂[备]202005061120
- 案件地点:汉阳区张家湾街道201号
- 案件类型:环境保护类
-
- 2020/05/06
-
+ {{item.updatetime}}
+
-
-
- 关于工程水质污染案件的调查
- 重点
+
+
+ {{item.name}}
+ 重点
+ 一般
- 案件编号:鄂[备]202005061120
- 案件地点:汉阳区张家湾街道201号
+ 案件编号:{{item.num}}
+ 案件地点:{{item.address}}
案件类型:环境保护类
- 2020/05/06
-
+ {{item.updatetime}}
+
-
-
- 关于化工厂不合格排放烟尘的调查
- 一般
+
+
+ {{item.name}}
+ 重点
+ 一般
- 案件编号:鄂[备]202005061120
- 案件地点:汉阳区张家湾街道201号
+ 案件编号:{{item.num}}
+ 案件地点:{{item.address}}
案件类型:环境保护类
- 2020/05/06
-
+ {{item.updatetime}}
+
diff --git a/utils/request.js b/utils/request.js
new file mode 100644
index 0000000..6aee74e
--- /dev/null
+++ b/utils/request.js
@@ -0,0 +1,90 @@
+var apiHost = "http://127.0.0.1:8080/";
+// var apiHost = "http://192.168.1.112:8765";
+
+/**
+ * @param url:String require(必需) 请求地址相对路径
+ * @param data:Object 可选 请求数据
+ * @param success:Function 可选 成功回调函数
+ * @param fail:Function 可选 失败回调函数
+ */
+function getRequest(url, data, success, fail) {
+ wx.request({
+ url: apiHost + url,
+ method: 'GET',
+ data: data,
+ header: {
+ 'content-type': 'application/json' // 默认值
+ },
+ success: function (res) {
+ // console.log(res)
+ if (success && typeof success === "function") {
+ success(res);
+ }
+ },
+ fail: function (error) {
+ if (fail && typeof fail === "function") {
+ fail(error);
+ } else {
+ //console.log(error);
+ }
+ }
+ })
+}
+/**
+ * @param url:String require(必需) 请求地址相对路径
+ * @param data:Object 可选 请求数据
+ * @param success:Function 可选 成功回调函数
+ * @param fail:Function 可选 失败回调函数
+ */
+function postRequest(url, data, success, fail) {
+ wx.request({
+ url: apiHost + url,
+ method: 'POST',
+ data: data,
+ header: {
+ 'content-type': 'application/json' // 默认值
+ },
+ success: function (res) {
+ if (success && typeof success === "function") {
+ success(res);
+ }
+ },
+ fail: function (error) {
+ if (fail && typeof fail === "function") {
+ fail(error);
+ } else {
+ //console.log(error);
+ }
+ }
+ })
+}
+
+function putRequest(url, data, success, fail) {
+ wx.request({
+ url: apiHost + url,
+ method: 'PUT',
+ data: data,
+ header: {
+ 'content-type': 'application/json' // 默认值
+ },
+ success: function (res) {
+ if (success && typeof success === "function") {
+ success(res);
+ }
+ },
+ fail: function (error) {
+ if (fail && typeof fail === "function") {
+ fail(error);
+ } else {
+ //console.log(error);
+ }
+ }
+ })
+}
+
+
+module.exports = {
+ getRequest: getRequest,
+ postRequest: postRequest,
+ putRequest: putRequest
+}
\ No newline at end of file
diff --git a/utils/util.js b/utils/util.js
index dbadbb8..a320d74 100644
--- a/utils/util.js
+++ b/utils/util.js
@@ -1,12 +1,36 @@
-const formatTime = date => {
- const year = date.getFullYear()
- const month = date.getMonth() + 1
- const day = date.getDate()
- const hour = date.getHours()
- const minute = date.getMinutes()
- const second = date.getSeconds()
-
- return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
+// const formatTime = timeStr => {
+
+function formatTime(timeStr,format){
+ // var format = "date";
+ // console.log(format)
+ var twoNum = function twoNum(num) {
+ return ('0' + num).slice(-2);
+ };
+ var tArr = timeStr.split(/\D+/).map(Number);
+ var tArr = timeStr.split(/\D+/).map(Number);
+ switch (tArr.length) {
+ case 5:
+ tArr.push(0);break;
+ case 4:
+ tArr.push(0, 0);break;
+ case 3:
+ tArr.push(-8, 0, 0);break;
+ case 2:
+ tArr.push(1, -8, 0, 0);break;
+ case 1:
+ tArr.push(1, 1, -8, 0, 0);break;
+ default:
+ break;
+ }
+ var myDate = new Date(tArr[0], tArr[1] - 1, tArr[2], tArr[3] + 8, tArr[4], tArr[5]);
+ switch (format) {
+ case 'date':
+ return myDate.getFullYear() + '-' + twoNum(myDate.getMonth() + 1) + '-' + twoNum(myDate.getDate());
+ case 'full':
+ return myDate.getFullYear() + '-' + twoNum(myDate.getMonth() + 1) + '-' + twoNum(myDate.getDate()) + ' ' + twoNum(myDate.getHours()) + ':' + twoNum(myDate.getMinutes());
+ case 'DateObj':
+ return myDate;
+ }
}
const formatNumber = n => {