增加违章举报功能

This commit is contained in:
caoqianming 2021-05-09 21:14:28 +08:00
parent 1e02b5276e
commit 1df3d82c15
21 changed files with 817 additions and 52 deletions

25
app.js
View File

@ -7,6 +7,10 @@ App({
}, },
mplogin: function () { mplogin: function () {
var that = this; var that = this;
wx.showLoading({
title: '账号自动登录中...',
icon:'none'
})
wx.login({ wx.login({
success: res => { success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId // 发送 res.code 到后台换取 openId, sessionKey, unionId
@ -37,12 +41,12 @@ App({
// that.callback() //执行定义的回调函数 // that.callback() //执行定义的回调函数
// } // }
/**** KEY PART START ****/ /**** KEY PART START ****/
var pages = getCurrentPages() // get all current pages // var pages = getCurrentPages() // get all current pages
var currentPage = pages[pages.length - 1] // Get current loading page // var currentPage = pages[pages.length - 1] // Get current loading page
if (currentPage.callback){ // if (currentPage.callback){
currentPage.callback(); // Callback // currentPage.callback(); // Callback
that.oncallback = false; // Callback called // that.oncallback = false; // Callback called
} // }
/**** KEY PART END ****/ /**** KEY PART END ****/
@ -60,7 +64,16 @@ App({
} }
} }
}); });
wx.hideLoading()
wx.reLaunch({
url: '/pages/main/main',
})
} else { } else {
wx.showToast({
title: '未绑定账号,请手动登录',
icon:'none'
})
wx.hideLoading()
that.globalData.userInfo.mpopenid = res.data.mpopenid that.globalData.userInfo.mpopenid = res.data.mpopenid
wx.reLaunch({ wx.reLaunch({
url: '/pages/bind/binduser?mpopenid=' + res.data.mpopenid, url: '/pages/bind/binduser?mpopenid=' + res.data.mpopenid,

View File

@ -1,5 +1,6 @@
{ {
"pages": [ "pages": [
"pages/bind/binduser",
"pages/main/main", "pages/main/main",
"pages/index/index", "pages/index/index",
"pages/logs/logs", "pages/logs/logs",
@ -14,7 +15,6 @@
"pages/todo/todo", "pages/todo/todo",
"pages/trouble/troubletodo", "pages/trouble/troubletodo",
"pages/trouble/accesstrouble", "pages/trouble/accesstrouble",
"pages/bind/binduser",
"pages/observe/addobserve", "pages/observe/addobserve",
"pages/observe/observe", "pages/observe/observe",
"pages/observe/observedetail", "pages/observe/observedetail",
@ -88,7 +88,10 @@
"pages/dickey/treeselect", "pages/dickey/treeselect",
"pages/troublefollow/index", "pages/troublefollow/index",
"pages/troublefollow/handle", "pages/troublefollow/handle",
"pages/troublefollow/detail" "pages/troublefollow/detail",
"pages/offence/index",
"pages/offence/add",
"pages/offence/detail"
], ],
"window": { "window": {
"backgroundTextStyle": "light", "backgroundTextStyle": "light",

View File

@ -11,6 +11,8 @@ Page({
yhqy__name:e.detail.name, yhqy__name:e.detail.name,
missqy:e.detail.id, missqy:e.detail.id,
missqy__name:e.detail.name, missqy__name:e.detail.name,
offenceqy:e.detail.id,
offenceqy__name:e.detail.name,
zyqy__name:e.detail.name, zyqy__name:e.detail.name,
zyqy:e.detail.id, zyqy:e.detail.id,
jyqy:e.detail.id, jyqy:e.detail.id,

View File

@ -42,9 +42,9 @@ Page({
openid:null openid:null
} //重置globaldata和session } //重置globaldata和session
getApp().mplogin() getApp().mplogin()
wx.switchTab({ // wx.switchTab({
url: '/pages/main/main', // url: '/pages/main/main',
}) // })
}else{ }else{
wx.showModal({ wx.showModal({
content: '账户或密码不正确!', content: '账户或密码不正确!',

1
pages/images/offence.svg Normal file
View File

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1620546022476" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1543" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16"><defs><style type="text/css"></style></defs><path d="M255.9 726.5h496.8c11.5 0 21.2-8.7 22.3-20.2 0.9-8.6 1.3-17.3 1.3-25.8V555.9c0-145.2-118.2-263.4-263.4-263.4h-17.1c-145.2 0-263.4 118.2-263.4 263.4v124.6c0 8.5 0.4 17.1 1.3 25.8 1 11.5 10.7 20.2 22.2 20.2z m21.2-170.6c0-120.5 98.1-218.6 218.6-218.6h17.1c120.5 0 218.6 98.1 218.6 218.6v125.8H277.1V555.9zM755.2 776.5H261.5c-12.4 0-22.4 10-22.4 22.4s10 22.4 22.4 22.4h493.8c12.4 0 22.4-10 22.4-22.4s-10.1-22.4-22.5-22.4zM315.4 301.1c4.4 4.8 10.4 7.2 16.5 7.2 5.4 0 10.9-2 15.2-5.9 9.1-8.4 9.7-22.5 1.3-31.6L295.3 213c-8.4-9.1-22.5-9.7-31.7-1.3-9.1 8.4-9.7 22.5-1.3 31.6l53.1 57.8zM682.8 308.4c6 0 12.1-2.4 16.5-7.2l53.1-57.8c8.4-9.1 7.8-23.3-1.3-31.6s-23.3-7.8-31.7 1.3l-53.1 57.8c-8.4 9.1-7.8 23.3 1.3 31.6 4.3 3.9 9.8 5.9 15.2 5.9zM505.4 262.8h0.8c12.4-0.4 22-10.8 21.6-23.2l-2.7-78.4c-0.4-12.4-10.5-22.1-23.2-21.6-12.4 0.4-22 10.8-21.6 23.2l2.7 78.4c0.4 12.1 10.4 21.6 22.4 21.6z" fill="#4D5DA8" p-id="1544"></path><path d="M363.1 508.8c2.6 1 5.3 1.5 7.9 1.5 9 0 17.5-5.5 21-14.4 0.7-1.9 18.6-46.5 69.8-56.2 12.2-2.3 20.1-14 17.8-26.2-2.3-12.2-14.1-20.2-26.2-17.8-76.6 14.5-102.4 81.6-103.4 84.5-4.3 11.4 1.6 24.2 13.1 28.6zM825.1 839.2H197.9c-12.3 0-22.4 10.1-22.4 22.4s10.1 22.4 22.4 22.4h627.2c12.3 0 22.4-10.1 22.4-22.4s-10-22.4-22.4-22.4zM932.7 839.2h-44.8c-12.3 0-22.4 10.1-22.4 22.4s10.1 22.4 22.4 22.4h44.8c12.3 0 22.4-10.1 22.4-22.4s-10.1-22.4-22.4-22.4zM135.2 839.2H90.4C78 839.2 68 849.3 68 861.6S78 884 90.4 884h44.8c12.3 0 22.4-10.1 22.4-22.4s-10.1-22.4-22.4-22.4z" fill="#4D5DA8" p-id="1545"></path></svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -95,13 +95,13 @@ Page({
*/ */
onShow: function () { onShow: function () {
var that = this var that = this
if ((getApp().globalData.sessionId != null) && (getApp().globalData.sessionId.indexOf('sessionid') != -1)) {
that.getNew() that.getNew()
} // if ((getApp().globalData.sessionId != null) && (getApp().globalData.sessionId.indexOf('sessionid') != -1)) {
else { // that.getNew()
getApp().mplogin() // }
} // else {
// getApp().mplogin()
// }
if (getApp().globalData.userInfo.companyid == 2681) { if (getApp().globalData.userInfo.companyid == 2681) {
this.setData({ this.setData({
isGjjt: true, isGjjt: true,

View File

@ -37,6 +37,13 @@
<view class="weui-badge" style="position: absolute;top: 1em;right: 1em;" wx:if="{{yhgznum!=0}}">{{yhgznum}}</view> <view class="weui-badge" style="position: absolute;top: 1em;right: 1em;" wx:if="{{yhgznum!=0}}">{{yhgznum}}</view>
</navigator> </navigator>
<navigator url="/pages/offence/index" class="weui-grid" hover-class="weui-grid_active">
<image class="weui-grid__icon" src="../images/offence.svg" />
<view class="weui-grid__label">违章举报</view>
<!-- <view class="weui-badge" style="position: absolute;top: 1em;right: 1em;" wx:if="{{yhgznum!=0}}">{{yhgznum}}</view> -->
</navigator>
</view>
<view class="weui-grids">
<navigator url="/pages/observe/observe" class="weui-grid" hover-class="weui-grid_active"> <navigator url="/pages/observe/observe" class="weui-grid" hover-class="weui-grid_active">
<image class="weui-grid__icon" src="../images/watch.png" /> <image class="weui-grid__icon" src="../images/watch.png" />
<view class="weui-grid__label">行为观察</view> <view class="weui-grid__label">行为观察</view>
@ -52,10 +59,16 @@
<view class="weui-badge" style="position: absolute;top: 1em;right: 1em;" wx:if="{{jytodonum!=0}}">{{jytodonum}}</view> <view class="weui-badge" style="position: absolute;top: 1em;right: 1em;" wx:if="{{jytodonum!=0}}">{{jytodonum}}</view>
<view class="weui-grid__label">合理化建议</view> <view class="weui-grid__label">合理化建议</view>
</navigator> </navigator>
<navigator url="/pages/operation/operation" class="weui-grid" hover-class="weui-grid_active"> </view>
<image class="weui-grid__icon" src="../images/operation.png" /> <view class="weui-grids">
<view class="weui-grid__label">作业许可</view> <navigator url="/pages/public/public" class="weui-grid" hover-class="weui-grid_active">
<view class="weui-badge" style="position: absolute;top: 1em;right: 1em;" wx:if="{{zytodonum!=0}}">{{zytodonum}}</view> <image class="weui-grid__icon" src="../images/public.png" />
<view class="weui-grid__label">公告</view>
</navigator>
<navigator url="/pages/notice/notice" class="weui-grid" hover-class="weui-grid_active">
<image class="weui-grid__icon" src="../images/send.png" />
<view class="weui-grid__label">通知</view>
<view class="weui-badge" style="position: absolute;top: 1em;right: 1em;" wx:if="{{noread!=0}}">{{noread}}</view>
</navigator> </navigator>
<navigator url="/pages/risktask/index" class="weui-grid" hover-class="weui-grid_active"> <navigator url="/pages/risktask/index" class="weui-grid" hover-class="weui-grid_active">
<image class="weui-grid__icon" src="../images/task.png" /> <image class="weui-grid__icon" src="../images/task.png" />
@ -68,8 +81,12 @@
</navigator> </navigator>
</view> </view>
<view class="weui-cells__title"></view>
<view class="weui-grids"> <view class="weui-grids">
<navigator url="/pages/operation/operation" class="weui-grid" hover-class="weui-grid_active">
<image class="weui-grid__icon" src="../images/operation.png" />
<view class="weui-grid__label">作业许可</view>
<view class="weui-badge" style="position: absolute;top: 1em;right: 1em;" wx:if="{{zytodonum!=0}}">{{zytodonum}}</view>
</navigator>
<view url="/pages/inspect/index" class="weui-grid" hover-class="weui-grid_active" bindtap='tapinspect'> <view url="/pages/inspect/index" class="weui-grid" hover-class="weui-grid_active" bindtap='tapinspect'>
<image class="weui-grid__icon" src="../images/inspect.png" /> <image class="weui-grid__icon" src="../images/inspect.png" />
<view class="weui-grid__label">设备巡检</view> <view class="weui-grid__label">设备巡检</view>
@ -88,7 +105,6 @@
</view> </view>
</view> --> </view> -->
<view class="weui-cells__title"></view>
<view class="weui-grids"> <view class="weui-grids">
<navigator url="/pages/data/index" class="weui-grid" hover-class="weui-grid_active"> <navigator url="/pages/data/index" class="weui-grid" hover-class="weui-grid_active">
<image class="weui-grid__icon" src="../images/data.png" /> <image class="weui-grid__icon" src="../images/data.png" />
@ -108,19 +124,14 @@
<view class="weui-grid__label">线下培训</view> <view class="weui-grid__label">线下培训</view>
<view class="weui-badge" style="position: absolute;top: 1em;right: 1em;" wx:if="{{dqdnum!=0}}">{{dqdnum}}</view> <view class="weui-badge" style="position: absolute;top: 1em;right: 1em;" wx:if="{{dqdnum!=0}}">{{dqdnum}}</view>
</navigator> </navigator>
<navigator url="/pages/public/public" class="weui-grid" hover-class="weui-grid_active">
<image class="weui-grid__icon" src="../images/public.png" />
<view class="weui-grid__label">公告</view>
</navigator>
<navigator url="/pages/notice/notice" class="weui-grid" hover-class="weui-grid_active">
<image class="weui-grid__icon" src="../images/send.png" />
<view class="weui-grid__label">通知</view>
<view class="weui-badge" style="position: absolute;top: 1em;right: 1em;" wx:if="{{noread!=0}}">{{noread}}</view>
</navigator>
<view class="weui-grid" hover-class="weui-grid_active" bindtap='tapexercise' wx:if="{{!isGjjt}}"> <view class="weui-grid" hover-class="weui-grid_active" bindtap='tapexercise' wx:if="{{!isGjjt}}">
<image class="weui-grid__icon" src="../images/exercise.png" /> <image class="weui-grid__icon" src="../images/exercise.png" />
<view class="weui-grid__label">模拟练习</view> <view class="weui-grid__label">模拟练习</view>
</view> </view>
</view>
<view class="weui-grids">
</view> </view>
<!-- <view class="layout_horizontal"> <!-- <view class="layout_horizontal">
<view style="width:480rpx;background-color:orange"> <view style="width:480rpx;background-color:orange">

View File

@ -25,3 +25,11 @@ overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
} }
.weui-grids {
border-top:none;
}
.weui-grid {
width: 25%;
border-right:none;
border-bottom:none;
}

250
pages/offence/add.js Normal file
View File

@ -0,0 +1,250 @@
const api = require("../../utils/request.js");
var dateTimePicker = require('../../utils/dateTimePicker.js');
Page({
/**
* 页面的初始数据
*/
data: {
offencetype:'公司员工',
offencetime: '',
offenceqy:'',
offenceplace: '',
offenceimg: [],
offencepost:"",
offencedept:"",
offenceparter:"",
typeIndex:0,
typeArray:['公司员工', '外协人员']
},
bindtypeChange: function (e) {
this.setData({
typeIndex: e.detail.value,
})
this.data.offencetype = this.data.typeArray[e.detail.value]
},
bindoffenceplaceInput: function (e) {
this.data.offenceplace = e.detail.value
},
binddescriptionInput: function (e) {
this.data.description = e.detail.value
},
bindoffencepostInput: function (e) {
this.data.offencepost = e.detail.value
},
bindoffencedeptInput: function (e) {
this.data.offencedept = e.detail.value
},
bindoffenceparterInput: function (e) {
this.data.offenceparter = e.detail.value
},
submit: function () {
var that = this
if (that.data.offenceplace == '') {
that.Tap1('请输入发生具体地点!')
} else if (that.data.description == '') {
that.Tap1('请输入简要描述!')
} else if (that.data.offencedept == '') {
that.Tap1('请输入车间!')
} else if (that.data.offencepost == '') {
that.Tap1('请输入岗位!')
}else {
that.upimg(0, that.data.offenceimg.length)
}
},
Tap1: function (x) {
wx.showModal({
title: "系统提示",
content: x,
showCancel: false,
confirmText: "确定"
})
},
//上传图片
upimg: function (x, y) {
var that = this
if (x < y) {
wx.showLoading({
title: '上传现场图片' + (x + 1) + '....',
})
wx.uploadFile({
header: {
'content-type': 'application/json', // 默认值
'Cookie': getApp().globalData.sessionId,
},
url: getApp().globalData.serverUrl + 'upfile',
filePath: that.data.offenceimg[x],
name: 'upfile',
success(res) {
var obj = JSON.parse(res.data);
that.data.offenceimg[x] = obj['filepath']
x = x + 1
if (x < y) {
that.upimg(x, y)
}
else {
that.addoffence()
}
}
})
} else {
that.addoffence()
}
},
addoffence: function () {
var wzdata = {
type: this.data.offencetype,
happentime: this.data.offencetime,
area:this.data.offenceqy,
place: this.data.offenceplace,
description: this.data.description,
imgs: this.data.offenceimg,
post: this.data.offencepost,
dept: this.data.offencedept,
parter: this.data.offenceparter
}
api.request('api/offence/?a=add', 'POST', wzdata).then(res => {
wx.navigateBack({
delta: 0,
})
}
)
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// 获取完整的年月日 时分秒,以及默认显示的数组
var obj1 = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
var dateTimeArray1 = obj1.dateTimeArray
var dateTime1 = obj1.dateTime
var time = dateTimeArray1[0][dateTime1[0]] + '-' + dateTimeArray1[1][dateTime1[1]] + '-' + dateTimeArray1[2][dateTime1[2]] + ' ' + dateTimeArray1[3][dateTime1[3]] + ':' + dateTimeArray1[4][dateTime1[4]]
this.setData({
dateTimeArray1: obj1.dateTimeArray,
dateTime1: obj1.dateTime,
});
this.data.offencetime = time
//拉取地图权限
if (getApp().globalData.userInfo.perms.indexOf(30) != -1) {
this.setData({
mapright: true
})
} else {
this.setData({
mapright: false
})
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
changeDateTime1(e) {
var dateTimeArray1 = this.data.dateTimeArray1
var dateTime1 = this.data.dateTime1
var time = dateTimeArray1[0][dateTime1[0]] + '-' + dateTimeArray1[1][dateTime1[1]] + '-' + dateTimeArray1[2][dateTime1[2]] + ' ' + dateTimeArray1[3][dateTime1[3]] + ':' + dateTimeArray1[4][dateTime1[4]]
//console.log(time)
this.data.offencetime = time
this.setData({
dateTime1: e.detail.value,
});
},
changeDateTimeColumn1(e) {
var arr = this.data.dateTime1,
dateArr = this.data.dateTimeArray1;
arr[e.detail.column] = e.detail.value;
dateArr[2] = dateTimePicker.getMonthDay(dateArr[0][arr[0]], dateArr[1][arr[1]]);
this.setData({
dateTimeArray1: dateArr,
dateTime1: arr
});
},
chooseImage: function () {
var that = this
wx.chooseImage({
count: 9,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: function (res) {
that.setData({
offenceimg: that.data.offenceimg.concat(res.tempFilePaths)
})
}
})
},
previewImage: function (e) {
var current = e.target.dataset.src
wx.previewImage({
current: current,
urls: this.data.offenceimg
})
},
deleteImage: function (e) {
var that = this;
var offenceimg = that.data.offenceimg;
var index = e.currentTarget.dataset.index; //获取当前长按图片下标
wx.showModal({
title: '系统提醒',
content: '确定要删除此图片吗?',
success: function (res) {
if (res.confirm) {
offenceimg.splice(index, 1);
} else if (res.cancel) {
return false;
}
that.setData({
offenceimg: offenceimg
});
}
})
},
})

10
pages/offence/add.json Normal file
View File

@ -0,0 +1,10 @@
{
"navigationBarTitleText": "新增违章",
"usingComponents": {
"mp-cells": "weui-miniprogram/cells/cells",
"mp-cell": "weui-miniprogram/cell/cell",
"mp-checkbox": "weui-miniprogram/checkbox/checkbox",
"mp-checkbox-group": "weui-miniprogram/checkbox-group/checkbox-group",
"mp-form": "weui-miniprogram/form/form"
}
}

110
pages/offence/add.wxml Normal file
View File

@ -0,0 +1,110 @@
<view class="page">
<view class="page__bd">
<view class="weui-toptips weui-toptips_warn" wx:if="{{showTopTips}}">错误提示</view>
<view class="weui-cells__title">违章信息</view>
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell weui-cell_select">
<view class="weui-cell__hd weui-cell__hd_in-select-after">
<view class="weui-label">发生时间</view>
</view>
<view class="weui-cell__bd">
<picker mode="multiSelector" value="{{dateTime1}}" bindchange="changeDateTime1" bindcolumnchange="changeDateTimeColumn1" range="{{dateTimeArray1}}">
<view class="weui-select">
{{dateTimeArray1[0][dateTime1[0]]}}-{{dateTimeArray1[1][dateTime1[1]]}}-{{dateTimeArray1[2][dateTime1[2]]}} {{dateTimeArray1[3][dateTime1[3]]}}:{{dateTimeArray1[4][dateTime1[4]]}}
</view>
</picker>
</view>
</view>
<view class="weui-cell weui-cell_select">
<view class="weui-cell__hd weui-cell__hd_in-select-after">
<view class="weui-label">人员类型</view>
</view>
<view class="weui-cell__bd">
<picker bindchange="bindtypeChange" value="{{typeIndex}}" range="{{typeArray}}">
<view class="weui-select">{{typeArray[typeIndex]}}</view>
</picker>
</view>
</view>
<view class="weui-cell weui-cell_select">
<view class="weui-cell__hd weui-cell__hd_in-select-after">
<view class="weui-label">所在区域</view>
</view>
<view class="weui-cell__bd">
<navigator url="/pages/area/tree">
<view class="weui-select">
{{offenceqy__name}}
</view>
</navigator>
</view>
</view>
<view class="weui-cell weui-cell_select">
<view class="weui-cell__hd weui-cell__hd_in-select-after">
<view class="weui-label">车间</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" placeholder="请输入车间" bindinput="bindoffencedeptInput" />
</view>
</view>
<view class="weui-cell weui-cell_select">
<view class="weui-cell__hd weui-cell__hd_in-select-after">
<view class="weui-label">岗位</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" placeholder="请输入岗位" bindinput="bindoffencepostInput" />
</view>
</view>
<view class="weui-cell weui-cell_select">
<view class="weui-cell__hd weui-cell__hd_in-select-after">
<view class="weui-label">当事人</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" placeholder="可输入被举报人姓名" bindinput="bindoffenceparterInput" />
</view>
</view>
<view class="weui-cell weui-cell_select">
<view class="weui-cell__hd weui-cell__hd_in-select-after">
<view class="weui-label">具体地点</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" placeholder="请输入具体地点" bindinput="bindoffenceplaceInput" />
</view>
</view>
</view>
<view class="weui-cells__title">简要描述</view>
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell">
<view class="weui-cell__bd">
<textarea class="weui-textarea" placeholder="请输入描述" style="height: 4.6em" bindinput="binddescriptionInput" maxlength="-1" />
</view>
</view>
</view>
<view class="weui-cells__title">现场图片(如有)</view>
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell">
<view class="weui-cell__bd weui-cell_primary">
<view class="weui-uploader">
<view class="weui-uploader__bd">
<view class="weui-uploader__files">
<block wx:for="{{offenceimg}}" wx:for-item="image" wx:key="unique">
<view class="weui-uploader__file">
<image class="weui-uploader__img" src="{{image}}" data-src="{{image}}" data-index="{{index}}" bindtap="previewImage" bindlongpress="deleteImage" data-index="{{index}}"></image>
</view>
</block>
</view>
<view class="weui-uploader__input-box">
<view class="weui-uploader__input" bindtap="chooseImage"></view>
</view>
</view>
</view>
</view>
</view>
</view>
<view class="btn-area">
<button class="weui-btn" type="primary" bindtap="submit">提交</button>
</view>
</view>
</view>

3
pages/offence/add.wxss Normal file
View File

@ -0,0 +1,3 @@
.btn-area{
margin:5px
}

110
pages/offence/detail.js Normal file
View File

@ -0,0 +1,110 @@
var util = require('../../utils/util.js')
const api = require("../../utils/request.js");
Page({
/**
* 页面的初始数据
*/
data: {
serverUrl: getApp().globalData.serverUrl
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.data.id = options.id
this.getWzdetail(options.id);
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
// var pages = getCurrentPages()
// var prePage = pages[pages.length-2]
// if(prePage.data.wslist){
// for(var i=0;i<prePage.data.wslist;i++){
// if(prePage.data.wslist[i].offenceid == this.data.offenceid){
// }
// }
// }
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
offenceimgPreview: function (e) {
var current = e.target.dataset.src
wx.previewImage({
current: current,
urls: this.data.imgs
})
},
getWzdetail: function (offenceid) {
wx.showLoading({
title: '加载中',
}),
wx.request({
url: this.data.serverUrl + 'api/offence?a=detail&id=' + offenceid,
header: {
'content-type': 'application/json', // 默认值
'Cookie': getApp().globalData.sessionId,
},
data: {
},
success: res => {
wx.hideLoading();
if (res.statusCode === 200) {
var data = res.data
for (var i = 0; i < data.imgs.length; i++) {
data.imgs[i] = this.data.serverUrl + data.imgs[i];
}
// if (data.offencetime != '') { data.offencetime = util.formatTime(new Date(data.offencetime)) }
// if (data.submittime != '') { data.submittime = util.formatTime(new Date(data.submittime)) }
this.setData(data)
}
}
});
},
})

View File

@ -0,0 +1,5 @@
{
"navigationBarTitleText": "违章信息",
"enablePullDownRefresh": true,
"onReachBottomDistance": 50
}

77
pages/offence/detail.wxml Normal file
View File

@ -0,0 +1,77 @@
<view class="weui-cells__title">
违章概况</view>
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell weui-cell_access">
<view class="weui-cell__bd weui-cell_primary">
<view>发现时间</view>
</view>
<view class="weui-cell__ft">
{{happentime}}
</view>
</view>
<view class="weui-cell weui-cell_access">
<view class="weui-cell__bd weui-cell_primary">
<view>人员类型</view>
</view>
<view class="weui-cell__ft">
{{type}}
</view>
</view>
<view class="weui-cell weui-cell_access">
<view class="weui-cell__bd weui-cell_primary">
<view>车间</view>
</view>
<view class="weui-cell__ft">
{{dept}}
</view>
</view>
<view class="weui-cell weui-cell_access">
<view class="weui-cell__bd weui-cell_primary">
<view>岗位</view>
</view>
<view class="weui-cell__ft">
{{post}}
</view>
</view>
<view class="weui-cell weui-cell_access">
<view class="weui-cell__bd weui-cell_primary">
<view>当事人</view>
</view>
<view class="weui-cell__ft">
{{parter}}
</view>
</view>
<view class="weui-cell weui-cell_access">
<view class="weui-cell__bd weui-cell_primary">
<view>具体地点</view>
</view>
<view class="weui-cell__ft">
{{place}}
</view>
</view>
</view>
<view class="weui-cells__title">详细内容</view>
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell weui-cell_access">
<view class="weui-cell__bd weui-cell_primary">
<view>简要描述</view>
<view class="weui-cell__ft">
{{description}}
</view>
</view>
</view>
<view class="weui-cell weui-cell_access">
<view class="weui-cell__bd weui-cell_primary">
<view>现场图片</view>
<view class="weui-uploader__files">
<block wx:for="{{imgs}}" wx:for-item="image" wx:key="unique">
<view class="weui-uploader__file">
<image class="weui-uploader__img" src="{{image}}" data-src="{{image}}" bindtap="missimgPreview"></image>
</view>
</block>
</view>
</view>
</view>
</view>

View File

@ -0,0 +1 @@
/* pages/offence/detail.wxss */

107
pages/offence/index.js Normal file
View File

@ -0,0 +1,107 @@
const api = require("../../utils/request.js");
Page({
/**
* 页面的初始数据
*/
data: {
page:1,
serverUrl: getApp().globalData.serverUrl,
wzlist:[]
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
var that = this;
that.onPullDownRefresh();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
/**
* 页面上拉触底事件的处理函数
*/
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
onPullDownRefresh: function () {
var that = this;
that.getwzlist(1);
wx.stopPullDownRefresh();
this.data.page = 1;
},
onReachBottom: function () {
//上拉分页,将页码加1然后调用分页函数
this.data.page = this.data.page + 1;
this.getwzlist();
},
getwzlist: function (page) {
var that = this;
if (page != 1) { page = that.data.page }
api.request('api/offence/?a=listall', 'GET').then(res => {
if (res.rows.length == 0) {
if (page == 1) {
this.setData({
total: 0,
wzlist: []
})
}
else {
wx.showModal({
content: "已经到底啦!",
showCancel: false,
confirmText: "确定",
})
}
} else {
let list
if (page == 1) {
list = res.rows
} else {
list = this.data.wzlist.concat(res.rows)
}
this.setData({
total: res.total,
wzlist: list
})
}
})
},
})

5
pages/offence/index.json Normal file
View File

@ -0,0 +1,5 @@
{
"navigationBarTitleText": "违章举报",
"enablePullDownRefresh": true,
"onReachBottomDistance": 50
}

25
pages/offence/index.wxml Normal file
View File

@ -0,0 +1,25 @@
<wxs src="../../wxs/subutil.wxs" module="tools" />
<view class="head">共{{total}}条违章信息</view>
<view class="weui-cells weui-cells_after-title">
<block wx:for="{{wzlist}}" wx:key="unique">
<navigator url="detail?id={{item.id}}" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
<view class="weui-media-box__title">{{tools.sub(item.description)}}</view>
<view class="weui-media-box__desc">{{item.type}} {{item.dept}} {{item.post}} {{item.area__name}}</view>
<view class="weui-media-box__desc">提交时间:{{item.createtime}}</view>
</view>
<view class="weui-panel__ft weui-cell__ft_in-access">
<!-- <view class="weui-media-box__title" wx:if="{{item.read == 0}}" style="background-color:orange">未读</view>
<view class="weui-media-box__title" wx:else style="background-color:green;color:white">已读</view>
<view class="weui-media-box__desc" wx:if="{{item.read == 1}}">{{item.readtime}}</view> -->
</view>
</navigator>
</block>
</view>
<view style="position:fixed; bottom:0;width:100%;">
<navigator url="/pages/offence/add" hover-class="navigator-hover">
<button class="weui-btn" type="primary">举报</button>
</navigator>
</view>

15
pages/offence/index.wxss Normal file
View File

@ -0,0 +1,15 @@
/* pages/offence/index.wxss */
.weui-btn{
width:auto;
margin: 5px;
}
.container {
background-color: #fff;
color: #939393;
}
.head{
color:#fff;
background-color: cornflowerblue;
text-align: center;
}

View File

@ -10,26 +10,35 @@ function request(url, method, data) {
'Cookie': getApp().globalData.sessionId, 'Cookie': getApp().globalData.sessionId,
}, },
success: (res => { success: (res => {
if (res.data.code == 1) { if(res.statusCode >= 500){
resolve(res.data);
}else if(res.data.code == -1){
getApp().onLaunch()
wx.switchTab({
url: '/pages/main/main',
})
}
else {
var msg = ''
if(res.data){
msg = res.data
}
wx.showToast({ wx.showToast({
title: msg, title: '服务器错误',
icon: 'none', icon: 'none'
duration: 1000
}) })
}else{
resolve(res.data);
} }
// if (res.data.code == 1) {
// resolve(res.data);
// }else if(res.data.code == -1){
// getApp().onLaunch()
// wx.switchTab({
// url: '/pages/main/main',
// })
// }
// else {
// var msg = ''
// if(res.data){
// msg = res.data
// }
// wx.showToast({
// title: msg,
// icon: 'none',
// duration: 1000
// })
// }
}), }),
fail: (res => { fail: (res => {
wx.showToast({ wx.showToast({