Commit cf8cfbed820e0d10049b5832e32ac41213c91cd5
1 parent
6843e3d2
首页案件列表,办理页面案件列表
Showing
6 changed files
with
277 additions
and
75 deletions
pages/index/index.js
| 1 | 1 | //index.js |
| 2 | + | |
| 3 | +const req = require('../../utils/request.js') | |
| 4 | +const util = require('../../utils/util.js') | |
| 5 | + | |
| 6 | +const Case_List_URL = "/platform/app/case/getCases"; | |
| 2 | 7 | //获取应用实例 |
| 3 | 8 | const app = getApp() |
| 4 | 9 | |
| ... | ... | @@ -29,12 +34,7 @@ Page({ |
| 29 | 34 | * 生命周期函数--监听页面显示 |
| 30 | 35 | */ |
| 31 | 36 | onShow: function () { |
| 32 | - if (typeof this.getTabBar === 'function' && | |
| 33 | - this.getTabBar()) { | |
| 34 | - this.getTabBar().setData({ | |
| 35 | - selected: 0 | |
| 36 | - }) | |
| 37 | - } | |
| 37 | + | |
| 38 | 38 | }, |
| 39 | 39 | |
| 40 | 40 | /** |
| ... | ... | @@ -72,3 +72,48 @@ Page({ |
| 72 | 72 | |
| 73 | 73 | } |
| 74 | 74 | }) |
| 75 | + | |
| 76 | +Component({ | |
| 77 | + data: { | |
| 78 | + surveyorId:"c64a18707e974f91945e0e872b7f5b98", | |
| 79 | + CaseList:undefined | |
| 80 | + }, | |
| 81 | + methods: { | |
| 82 | + onLoad: function (options) { | |
| 83 | + var that = this; | |
| 84 | + console.log("onLoad1"); | |
| 85 | + const dataParams = { | |
| 86 | + "pageSize": 20, "pageNumber": 1 , | |
| 87 | + surveyorId: that.data.surveyorId | |
| 88 | + }; | |
| 89 | + | |
| 90 | + req.getRequest(Case_List_URL, dataParams, function (res) { | |
| 91 | + wx.hideLoading(); | |
| 92 | + // console.log(res) | |
| 93 | + if (res.data.code == 0) { | |
| 94 | + let cases=res.data.data.list; | |
| 95 | + for(let c in cases){ | |
| 96 | + let date = util.formatTime(cases[c].updatetime,"date") | |
| 97 | + cases[c].updatetime = date | |
| 98 | + } | |
| 99 | + that.setData({ | |
| 100 | + CaseList: res.data.data.list | |
| 101 | + }); | |
| 102 | + } | |
| 103 | + }, function (res) { | |
| 104 | + wx.hideLoading(); | |
| 105 | + console.log(res); | |
| 106 | + }); | |
| 107 | + } | |
| 108 | + }, | |
| 109 | + pageLifetimes: { | |
| 110 | + show() { | |
| 111 | + if (typeof this.getTabBar === 'function' && | |
| 112 | + this.getTabBar()) { | |
| 113 | + this.getTabBar().setData({ | |
| 114 | + selected: 0 | |
| 115 | + }) | |
| 116 | + } | |
| 117 | + } | |
| 118 | + }, | |
| 119 | +}) | |
| 75 | 120 | \ No newline at end of file | ... | ... |
pages/index/index.wxml
| ... | ... | @@ -40,21 +40,22 @@ |
| 40 | 40 | <text>最新归档案件</text> |
| 41 | 41 | </view> |
| 42 | 42 | <!-- 案件1 --> |
| 43 | - <navigator class="case" hover-class="none" url=""> | |
| 43 | + <view class="case" hover-class="none" wx:for="{{CaseList}}" wx:key="{{item.id}}" wx:for-item="item" data-case-class-id="{{item.id}}" bindtap="toCaseInfo"> | |
| 44 | 44 | <view class="caseinfo"> |
| 45 | - <view class="title">关于工程水质污染案件的调查</view> | |
| 46 | - <text class="level danger">重点</text> | |
| 45 | + <view class="title">{{item.name}}</view> | |
| 46 | + <text class="level danger" wx:if="item.level==2">重点</text> | |
| 47 | + <text class="level warning" wx:if="item.level==1">一般</text> | |
| 47 | 48 | <view class="subinfo"> |
| 48 | - <view>案件地点:汉阳区张家湾街道201号</view> | |
| 49 | + <view>案件地点:{{item.address}}</view> | |
| 49 | 50 | <view>案件类型:环境保护类</view> |
| 50 | - <view>勘查单位:武汉市人民检察院</view> | |
| 51 | + <view>勘查单位:{{item.unitname}}</view> | |
| 51 | 52 | </view> |
| 52 | - <view class="time">2020/05/06</view> | |
| 53 | + <view class="time">{{item.updatetime}}</view> | |
| 53 | 54 | </view> |
| 54 | - </navigator> | |
| 55 | + </view> | |
| 55 | 56 | <!-- 案件1 --> |
| 56 | 57 | <!-- 案件2 --> |
| 57 | - <navigator class="case" hover-class="none" url=""> | |
| 58 | + <!-- <navigator class="case" hover-class="none" url=""> | |
| 58 | 59 | <view class="caseinfo"> |
| 59 | 60 | <view class="title">关于化工厂不合格排放烟尘的案件</view> |
| 60 | 61 | <text class="level warning">一般</text> |
| ... | ... | @@ -65,7 +66,7 @@ |
| 65 | 66 | </view> |
| 66 | 67 | <view class="time">2020/05/05</view> |
| 67 | 68 | </view> |
| 68 | - </navigator> | |
| 69 | + </navigator> --> | |
| 69 | 70 | <!-- 案件2 --> |
| 70 | 71 | <!-- 最新归档案件 --> |
| 71 | 72 | </view> | ... | ... |
pages/work/work.js
| 1 | +const req = require('../../utils/request.js') | |
| 2 | +const util = require('../../utils/util.js') | |
| 3 | + | |
| 4 | +const Case_List_URL = "/platform/app/case/getCases"; | |
| 1 | 5 | // pages/work/work.js |
| 2 | 6 | //获取应用实例 |
| 3 | 7 | const app = getApp() |
| ... | ... | @@ -8,22 +12,15 @@ Page({ |
| 8 | 12 | * 页面的初始数据 |
| 9 | 13 | */ |
| 10 | 14 | data: { |
| 11 | - menuTapCurrent:0 | |
| 12 | - }, | |
| 13 | - // 点击按钮选项卡切换 | |
| 14 | - menuTap: function (e) { | |
| 15 | - var current = e.currentTarget.dataset.current;//获取到绑定的数据 | |
| 16 | - //改变menuTapCurrent的值为当前选中的menu所绑定的数据 | |
| 17 | - this.setData({ | |
| 18 | - menuTapCurrent: current | |
| 19 | - }); | |
| 15 | + | |
| 20 | 16 | }, |
| 21 | 17 | |
| 18 | + | |
| 22 | 19 | /** |
| 23 | 20 | * 生命周期函数--监听页面加载 |
| 24 | 21 | */ |
| 25 | 22 | onLoad: function (options) { |
| 26 | - | |
| 23 | + | |
| 27 | 24 | }, |
| 28 | 25 | |
| 29 | 26 | /** |
| ... | ... | @@ -37,12 +34,7 @@ Page({ |
| 37 | 34 | * 生命周期函数--监听页面显示 |
| 38 | 35 | */ |
| 39 | 36 | onShow: function () { |
| 40 | - if (typeof this.getTabBar === 'function' && | |
| 41 | - this.getTabBar()) { | |
| 42 | - this.getTabBar().setData({ | |
| 43 | - selected: 1 | |
| 44 | - }) | |
| 45 | - } | |
| 37 | + | |
| 46 | 38 | }, |
| 47 | 39 | |
| 48 | 40 | /** |
| ... | ... | @@ -79,4 +71,61 @@ Page({ |
| 79 | 71 | onShareAppMessage: function () { |
| 80 | 72 | |
| 81 | 73 | } |
| 74 | +}) | |
| 75 | +Component({ | |
| 76 | + data: { | |
| 77 | + menuTapCurrent:0, | |
| 78 | + surveyorId:"c64a18707e974f91945e0e872b7f5b98", | |
| 79 | + CaseList:undefined | |
| 80 | + }, | |
| 81 | + | |
| 82 | + methods: { | |
| 83 | + // 点击按钮选项卡切换 | |
| 84 | + menuTap: function (e) { | |
| 85 | + var current = e.currentTarget.dataset.current;//获取到绑定的数据 | |
| 86 | + //改变menuTapCurrent的值为当前选中的menu所绑定的数据 | |
| 87 | + this.setData({ | |
| 88 | + menuTapCurrent: current | |
| 89 | + }); | |
| 90 | + var that = this; | |
| 91 | + that.getList(); | |
| 92 | + }, | |
| 93 | + onLoad: function (options) { | |
| 94 | + wx.showLoading({ | |
| 95 | + title: '加载中...', | |
| 96 | + }); | |
| 97 | + var that = this; | |
| 98 | + that.getList(); | |
| 99 | + }, | |
| 100 | + getList: function () { | |
| 101 | + var that = this; | |
| 102 | + const data = { "pageSize": 20, "pageNumber": 1 , surveyorId: that.data.surveyorId,status: that.data.menuTapCurrent+1}; | |
| 103 | + req.getRequest(Case_List_URL, data, function (res) { | |
| 104 | + wx.hideLoading(); | |
| 105 | + if (res.data.code == 0) { | |
| 106 | + let cases=res.data.data.list; | |
| 107 | + for(let c in cases){ | |
| 108 | + let date = util.formatTime(cases[c].updatetime,"date") | |
| 109 | + cases[c].updatetime = date | |
| 110 | + } | |
| 111 | + that.setData({ | |
| 112 | + CaseList: cases | |
| 113 | + }); | |
| 114 | + } | |
| 115 | + }, function (res) { | |
| 116 | + wx.hideLoading(); | |
| 117 | + console.log(res); | |
| 118 | + }); | |
| 119 | + } | |
| 120 | + }, | |
| 121 | + pageLifetimes: { | |
| 122 | + show() { | |
| 123 | + if (typeof this.getTabBar === 'function' && | |
| 124 | + this.getTabBar()) { | |
| 125 | + this.getTabBar().setData({ | |
| 126 | + selected: 1 | |
| 127 | + }) | |
| 128 | + } | |
| 129 | + } | |
| 130 | + }, | |
| 82 | 131 | }) |
| 83 | 132 | \ No newline at end of file | ... | ... |
pages/work/work.wxml
| ... | ... | @@ -4,7 +4,7 @@ |
| 4 | 4 | <scroll-view class="tab"> |
| 5 | 5 | <view class='tab-item {{menuTapCurrent=="0"?"active":""}}' data-current="0" catchtap="menuTap"> |
| 6 | 6 | <image class="tabicon" src='../../images/tabicon1.png'></image> |
| 7 | - <view>执行中</view> | |
| 7 | + <view>待执行</view> | |
| 8 | 8 | </view> |
| 9 | 9 | <view class='tab-item {{menuTapCurrent=="1"?"active":""}}' data-current="1" catchtap="menuTap"> |
| 10 | 10 | <image class="tabicon" src='../../images/tabicon2.png'></image> |
| ... | ... | @@ -12,60 +12,53 @@ |
| 12 | 12 | </view> |
| 13 | 13 | <view class='tab-item {{menuTapCurrent=="2"?"active":""}}' data-current="2" catchtap="menuTap"> |
| 14 | 14 | <image class="tabicon" src='../../images/tabicon3.png'></image> |
| 15 | - <view>已执行</view> | |
| 15 | + <view>已完成</view> | |
| 16 | 16 | </view> |
| 17 | 17 | </scroll-view > |
| 18 | 18 | <!-- tab --> |
| 19 | 19 | <!-- 执行中 --> |
| 20 | 20 | <view class="content" hidden="{{menuTapCurrent!='0'}}"> |
| 21 | - <navigator class="case" url=""> | |
| 22 | - <view class="title">关于工程水质污染案件的调查</view> | |
| 23 | - <text class="level danger">重点</text> | |
| 21 | + <view class="case" wx:for="{{CaseList}}" wx:key="{{item.id}}" wx:for-item="item" data-case-class-id="{{item.id}}" bindtap="toCaseInfo"> | |
| 22 | + <view class="title">{{item.name}}</view> | |
| 23 | + <text class="level danger" wx:if="item.level==2">重点</text> | |
| 24 | + <text class="level warning" wx:if="item.level==1">一般</text> | |
| 24 | 25 | <view class="subinfo"> |
| 25 | - <view>案件编号:鄂[备]202005061120</view> | |
| 26 | - <view>案件地点:汉阳区张家湾街道201号</view> | |
| 26 | + <view>案件编号:{{item.num}}</view> | |
| 27 | + <view>案件地点:{{item.address}}</view> | |
| 27 | 28 | <view>案件类型:环境保护类</view> |
| 28 | 29 | </view> |
| 29 | - <view class="time">2020/05/06</view> | |
| 30 | - </navigator> | |
| 31 | - <navigator class="case" url=""> | |
| 32 | - <view class="title">关于化工厂不合格排放烟尘的调查</view> | |
| 33 | - <text class="level warning">一般</text> | |
| 34 | - <view class="subinfo"> | |
| 35 | - <view>案件编号:鄂[备]202005061120</view> | |
| 36 | - <view>案件地点:汉阳区张家湾街道201号</view> | |
| 37 | - <view>案件类型:环境保护类</view> | |
| 38 | - </view> | |
| 39 | - <view class="time">2020/05/06</view> | |
| 40 | - </navigator> | |
| 30 | + <view class="time">{{item.updatetime}}</view> | |
| 31 | + </view> | |
| 41 | 32 | </view> |
| 42 | 33 | <!-- 执行中 --> |
| 43 | 34 | <!-- 待上传 --> |
| 44 | - <view class="content" hidden="{{menuTapCurrent!='1'}}"> | |
| 45 | - <navigator class="case" url=""> | |
| 46 | - <view class="title">关于工程水质污染案件的调查</view> | |
| 47 | - <text class="level danger">重点</text> | |
| 35 | + <view class="content" hidden="{{menuTapCurrent!='0'}}"> | |
| 36 | + <view class="case" wx:for="{{CaseList}}" wx:key="{{item.id}}" wx:for-item="item" data-case-class-id="{{item.id}}" bindtap="toCaseInfo"> | |
| 37 | + <view class="title">{{item.name}}</view> | |
| 38 | + <text class="level danger" wx:if="item.level==2">重点</text> | |
| 39 | + <text class="level warning" wx:if="item.level==1">一般</text> | |
| 48 | 40 | <view class="subinfo"> |
| 49 | - <view>案件编号:鄂[备]202005061120</view> | |
| 50 | - <view>案件地点:汉阳区张家湾街道201号</view> | |
| 41 | + <view>案件编号:{{item.num}}</view> | |
| 42 | + <view>案件地点:{{item.address}}</view> | |
| 51 | 43 | <view>案件类型:环境保护类</view> |
| 52 | 44 | </view> |
| 53 | - <view class="time">2020/05/06</view> | |
| 54 | - </navigator> | |
| 45 | + <view class="time">{{item.updatetime}}</view> | |
| 46 | + </view> | |
| 55 | 47 | </view> |
| 56 | 48 | <!-- 待上传 --> |
| 57 | 49 | <!-- 已执行 --> |
| 58 | - <view class="content" hidden="{{menuTapCurrent!='2'}}"> | |
| 59 | - <navigator class="case" url=""> | |
| 60 | - <view class="title">关于化工厂不合格排放烟尘的调查</view> | |
| 61 | - <text class="level warning">一般</text> | |
| 50 | + <view class="content" hidden="{{menuTapCurrent!='0'}}"> | |
| 51 | + <view class="case" wx:for="{{CaseList}}" wx:key="{{item.id}}" wx:for-item="item" data-case-class-id="{{item.id}}" bindtap="toCaseInfo"> | |
| 52 | + <view class="title">{{item.name}}</view> | |
| 53 | + <text class="level danger" wx:if="item.level==2">重点</text> | |
| 54 | + <text class="level warning" wx:if="item.level==1">一般</text> | |
| 62 | 55 | <view class="subinfo"> |
| 63 | - <view>案件编号:鄂[备]202005061120</view> | |
| 64 | - <view>案件地点:汉阳区张家湾街道201号</view> | |
| 56 | + <view>案件编号:{{item.num}}</view> | |
| 57 | + <view>案件地点:{{item.address}}</view> | |
| 65 | 58 | <view>案件类型:环境保护类</view> |
| 66 | 59 | </view> |
| 67 | - <view class="time">2020/05/06</view> | |
| 68 | - </navigator> | |
| 60 | + <view class="time">{{item.updatetime}}</view> | |
| 61 | + </view> | |
| 69 | 62 | </view> |
| 70 | 63 | <!-- 已执行 --> |
| 71 | 64 | </view> | ... | ... |
utils/request.js
0 → 100644
| 1 | +var apiHost = "http://127.0.0.1:8080/"; | |
| 2 | +// var apiHost = "http://192.168.1.112:8765"; | |
| 3 | + | |
| 4 | +/** | |
| 5 | + * @param url:String require(必需) 请求地址相对路径 | |
| 6 | + * @param data:Object 可选 请求数据 | |
| 7 | + * @param success:Function 可选 成功回调函数 | |
| 8 | + * @param fail:Function 可选 失败回调函数 | |
| 9 | + */ | |
| 10 | +function getRequest(url, data, success, fail) { | |
| 11 | + wx.request({ | |
| 12 | + url: apiHost + url, | |
| 13 | + method: 'GET', | |
| 14 | + data: data, | |
| 15 | + header: { | |
| 16 | + 'content-type': 'application/json' // 默认值 | |
| 17 | + }, | |
| 18 | + success: function (res) { | |
| 19 | + // console.log(res) | |
| 20 | + if (success && typeof success === "function") { | |
| 21 | + success(res); | |
| 22 | + } | |
| 23 | + }, | |
| 24 | + fail: function (error) { | |
| 25 | + if (fail && typeof fail === "function") { | |
| 26 | + fail(error); | |
| 27 | + } else { | |
| 28 | + //console.log(error); | |
| 29 | + } | |
| 30 | + } | |
| 31 | + }) | |
| 32 | +} | |
| 33 | +/** | |
| 34 | + * @param url:String require(必需) 请求地址相对路径 | |
| 35 | + * @param data:Object 可选 请求数据 | |
| 36 | + * @param success:Function 可选 成功回调函数 | |
| 37 | + * @param fail:Function 可选 失败回调函数 | |
| 38 | + */ | |
| 39 | +function postRequest(url, data, success, fail) { | |
| 40 | + wx.request({ | |
| 41 | + url: apiHost + url, | |
| 42 | + method: 'POST', | |
| 43 | + data: data, | |
| 44 | + header: { | |
| 45 | + 'content-type': 'application/json' // 默认值 | |
| 46 | + }, | |
| 47 | + success: function (res) { | |
| 48 | + if (success && typeof success === "function") { | |
| 49 | + success(res); | |
| 50 | + } | |
| 51 | + }, | |
| 52 | + fail: function (error) { | |
| 53 | + if (fail && typeof fail === "function") { | |
| 54 | + fail(error); | |
| 55 | + } else { | |
| 56 | + //console.log(error); | |
| 57 | + } | |
| 58 | + } | |
| 59 | + }) | |
| 60 | +} | |
| 61 | + | |
| 62 | +function putRequest(url, data, success, fail) { | |
| 63 | + wx.request({ | |
| 64 | + url: apiHost + url, | |
| 65 | + method: 'PUT', | |
| 66 | + data: data, | |
| 67 | + header: { | |
| 68 | + 'content-type': 'application/json' // 默认值 | |
| 69 | + }, | |
| 70 | + success: function (res) { | |
| 71 | + if (success && typeof success === "function") { | |
| 72 | + success(res); | |
| 73 | + } | |
| 74 | + }, | |
| 75 | + fail: function (error) { | |
| 76 | + if (fail && typeof fail === "function") { | |
| 77 | + fail(error); | |
| 78 | + } else { | |
| 79 | + //console.log(error); | |
| 80 | + } | |
| 81 | + } | |
| 82 | + }) | |
| 83 | +} | |
| 84 | + | |
| 85 | + | |
| 86 | +module.exports = { | |
| 87 | + getRequest: getRequest, | |
| 88 | + postRequest: postRequest, | |
| 89 | + putRequest: putRequest | |
| 90 | +} | |
| 0 | 91 | \ No newline at end of file | ... | ... |
utils/util.js
| 1 | -const formatTime = date => { | |
| 2 | - const year = date.getFullYear() | |
| 3 | - const month = date.getMonth() + 1 | |
| 4 | - const day = date.getDate() | |
| 5 | - const hour = date.getHours() | |
| 6 | - const minute = date.getMinutes() | |
| 7 | - const second = date.getSeconds() | |
| 8 | - | |
| 9 | - return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':') | |
| 1 | +// const formatTime = timeStr => { | |
| 2 | + | |
| 3 | +function formatTime(timeStr,format){ | |
| 4 | + // var format = "date"; | |
| 5 | + // console.log(format) | |
| 6 | + var twoNum = function twoNum(num) { | |
| 7 | + return ('0' + num).slice(-2); | |
| 8 | + }; | |
| 9 | + var tArr = timeStr.split(/\D+/).map(Number); | |
| 10 | + var tArr = timeStr.split(/\D+/).map(Number); | |
| 11 | + switch (tArr.length) { | |
| 12 | + case 5: | |
| 13 | + tArr.push(0);break; | |
| 14 | + case 4: | |
| 15 | + tArr.push(0, 0);break; | |
| 16 | + case 3: | |
| 17 | + tArr.push(-8, 0, 0);break; | |
| 18 | + case 2: | |
| 19 | + tArr.push(1, -8, 0, 0);break; | |
| 20 | + case 1: | |
| 21 | + tArr.push(1, 1, -8, 0, 0);break; | |
| 22 | + default: | |
| 23 | + break; | |
| 24 | + } | |
| 25 | + var myDate = new Date(tArr[0], tArr[1] - 1, tArr[2], tArr[3] + 8, tArr[4], tArr[5]); | |
| 26 | + switch (format) { | |
| 27 | + case 'date': | |
| 28 | + return myDate.getFullYear() + '-' + twoNum(myDate.getMonth() + 1) + '-' + twoNum(myDate.getDate()); | |
| 29 | + case 'full': | |
| 30 | + return myDate.getFullYear() + '-' + twoNum(myDate.getMonth() + 1) + '-' + twoNum(myDate.getDate()) + ' ' + twoNum(myDate.getHours()) + ':' + twoNum(myDate.getMinutes()); | |
| 31 | + case 'DateObj': | |
| 32 | + return myDate; | |
| 33 | + } | |
| 10 | 34 | } |
| 11 | 35 | |
| 12 | 36 | const formatNumber = n => { | ... | ... |