commit 303ad947b6a15ddaf1fc722b2360bfb0c6c70ad7 Author: caoqianming Date: Thu Apr 11 15:37:20 2019 +0800 Initial Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10fa70b --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +# Windows +[Dd]esktop.ini +Thumbs.db +$RECYCLE.BIN/ + +# macOS +.DS_Store +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes + +# Node.js +node_modules/ diff --git a/app.js b/app.js new file mode 100644 index 0000000..c08a124 --- /dev/null +++ b/app.js @@ -0,0 +1,102 @@ +//app.js +App({ + onLaunch: function () { + // 展示本地存储能力 + //var logs = wx.getStorageSync('logs') || [] + //logs.unshift(Date.now()) + //wx.setStorageSync('logs', logs) + // wx.checkSession({ + // success() { + // //session_key 未过期,并且在本生命周期一直有效 + // console.log(wx.getStorageSync("sessionid")) + // }, + // fail() { + // // session_key 已经失效,需要重新执行登录流程 + // // 登录 + // } + // }) + this.mplogin(); + }, + mplogin: function () { + var that = this; + wx.login({ + success: res => { + // 发送 res.code 到后台换取 openId, sessionKey, unionId + wx.request({ + url: that.globalData.serverUrl + 'mplogin', + data: { + code: res.code + }, + method: 'POST', + header: { + 'content-type': 'application/json' + }, + success: function (res) { + if (res.data.code == 1) { + //console.log(res.header["Set-Cookie"]) + //console.log(res) + wx.setStorageSync('userid', res.data.userid) + wx.setStorageSync('username', res.data.username) + wx.setStorageSync('sessionid', res.header["Set-Cookie"]) + wx.setStorageSync('mpopenid', res.data.mpopenid) + if (that.callback) { //这个函数名字和你定义的一样即可 + that.callback() //执行定义的回调函数 + } + //获取是否是安全员 + wx.request({ + url: that.globalData.serverUrl + 'api/user?a=checkaqy', + header: { + 'content-type': 'application/json', // 默认值 + 'Cookie': wx.getStorageSync("sessionid"), + }, + data: {}, + success: res => { + if (res.data.code == 1) { + //console.log(res.data) + that.globalData.isaqy = 1 + } + console.log(that.globalData.isaqy) + } + }); + // //获取隐患待办数目 + // wx.request({ + // url: that.globalData.serverUrl + 'troublehandle?a=todonum', + // header: { + // 'content-type': 'application/json', // 默认值 + // 'Cookie': wx.getStorageSync("sessionid"), + // }, + // data: {}, + // success: res => { + // if (res.statusCode === 200) { + // //console.log(res.data) + // that.globalData.yhtodonum = res.data.todonum + // if (that.globalData.yhtodonum > 0) { + // wx.setTabBarBadge({ + // index: 1, + // text: '新' + // }) + // } + // } + // } + // }); + } else { + wx.setStorageSync('mpopenid', res.data.mpopenid) + wx.reLaunch({ + url: '/pages/bind/binduser?mpopenid=' + res.data.mpopenid, + }) + } + }, + }) + } + }) + }, + globalData: { + userInfo: null, + //serverUrl: 'https://safeyun.ctcshe.com/', + serverUrl:'http://127.0.0.1:8000/', + //serverUrl: 'http://192.168.0.102:8000/', + //serverUrl:'http://10.7.100.250:8000/', + isaqy: 0 + }, + +}) \ No newline at end of file diff --git a/app.json b/app.json new file mode 100644 index 0000000..1d6df9f --- /dev/null +++ b/app.json @@ -0,0 +1,69 @@ +{ + "pages": [ + "pages/main/main", + "pages/index/index", + "pages/logs/logs", + "pages/trouble/trouble", + "pages/train/train", + "pages/drill/drill", + "pages/trouble/addtrouble", + "pages/trouble/troubledetail", + "pages/trouble/addtroublezg", + "pages/trouble/addtroublezp", + "pages/parttree/index", + "pages/todo/todo", + "pages/trouble/troubletodo", + "pages/trouble/accesstrouble", + "pages/bind/binduser", + "pages/observe/addobserve", + "pages/observe/observe", + "pages/observe/observedetail", + "pages/miss/miss", + "pages/miss/missdetail", + "pages/miss/addmiss", + "pages/user/userdetail", + "pages/socert/socert", + "pages/socert/socertdetail", + "pages/suggest/suggest", + "pages/suggest/add", + "pages/suggest/detail", + "pages/notice/notice", + "pages/notice/detail", + "pages/public/public", + "pages/public/detail", + "pages/operation/operation", + "pages/operation/operationcheck", + "pages/operation/operationdetail", + "pages/footer/footer", + "pages/userSelect/userSelect", + "components/footer/footer", + "pages/operation/operationadd", + "pages/train/add" + ], + "window": { + "backgroundTextStyle": "light", + "navigationBarBackgroundColor": "#fff", + "navigationBarTitleText": "安全预警lite", + "navigationBarTextStyle": "black" + }, + "tabBar": { + "color": "#7A7E83", + "selectedColor": "#3cc51f", + "borderStyle": "black", + "backgroundColor": "#ffffff", + "list": [ + { + "pagePath": "pages/main/main", + "text": "主页", + "iconPath": "image/home.png", + "selectedIconPath": "image/homec.png" + }, + { + "pagePath": "pages/index/index", + "text": "个人中心", + "iconPath": "image/me.png", + "selectedIconPath": "image/mec.png" + } + ] + } +} \ No newline at end of file diff --git a/app.wxss b/app.wxss new file mode 100644 index 0000000..58026a6 --- /dev/null +++ b/app.wxss @@ -0,0 +1,36 @@ +/**app.wxss**/ +@import 'weui.wxss'; +@import "/wxParse/wxParse.wxss"; +page{ + background-color: #F8F8F8; + font-size: 16px; + font-family: -apple-system-font,Helvetica Neue,Helvetica,sans-serif; +} +.page__hd { + padding: 40px; +} +.page__bd { + padding-bottom: 40px; +} +.page__bd_spacing { + padding-left: 15px; + padding-right: 15px; +} + +.page__ft{ + padding-bottom: 10px; + text-align: center; +} + +.page__title { + text-align: left; + font-size: 20px; + font-weight: 400; +} + +.page__desc { + margin-top: 5px; + color: #888888; + text-align: left; + font-size: 14px; +} \ No newline at end of file diff --git a/components/footer/footer.js b/components/footer/footer.js new file mode 100644 index 0000000..2052a81 --- /dev/null +++ b/components/footer/footer.js @@ -0,0 +1,33 @@ +Component({ + /** + * 组件的属性列表 + */ + properties: { + list: { type: Array } + }, + /** + * 组件的初始数据 + */ + data: {}, + /** + * 组件的方法列表 + */ + methods: { + delete(res) { + console.log(res) + let index = res.currentTarget.id + let list = this.data.list + list.splice(index, 1) + this.setData({ list: list }) + this.triggerEvent( + "delete", + { + selectList: list }) + }, /** + * 点击确定按钮 + */ + confirm() { + this.triggerEvent("submit", "") + } + } +}) \ No newline at end of file diff --git a/components/footer/footer.json b/components/footer/footer.json new file mode 100644 index 0000000..e8cfaaf --- /dev/null +++ b/components/footer/footer.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/components/footer/footer.wxml b/components/footer/footer.wxml new file mode 100644 index 0000000..2d21345 --- /dev/null +++ b/components/footer/footer.wxml @@ -0,0 +1,6 @@ + + + + {{item.name}} + + 确定 \ No newline at end of file diff --git a/components/footer/footer.wxss b/components/footer/footer.wxss new file mode 100644 index 0000000..95a6ba4 --- /dev/null +++ b/components/footer/footer.wxss @@ -0,0 +1,39 @@ +.container { + width: 100%; + height: 100rpx; + display: flex; + flex-direction: row; + padding: 20rpx; + box-sizing: border-box; + background-color: #fff; + align-items: center; + overflow-x: hidden; + white-space: nowrap; + border-top: 2rpx solid rgba(7, 17, 27, 0.1); +} + +.scroll-wrapper { + flex: 1; + overflow-x: hidden; + white-space: nowrap; +} + +.scroll { + width: 100%; +} + +.text { + font-size: 32rpx; + color: #333; + padding: 40rpx 20rpx; + margin-right: 10rpx; + background-color: #f5f5f5; +} + +.btn { + padding: 10rpx 20rpx; + background-color: rgb(26, 173, 25); + border-radius: 10rpx; + font-size: 32rpx; + color: #fff; +} diff --git a/components/path-view/index.js b/components/path-view/index.js new file mode 100644 index 0000000..39c9126 --- /dev/null +++ b/components/path-view/index.js @@ -0,0 +1,242 @@ +// components/path-view/index.js +import toTree from './toTree'; +Component({ + properties: { + value: { + type: Array, + value: [], + observer() { + this.initView(); + } + }, + // 非树形数据,仅在value无传参时生效 + unnormalizedValue: { + type: Array, + value: [], + observer() { + this.initView(); + } + }, + fatherKey: { + type: String, + value: 'pid' + }, + selfKey: { + type: String, + value: 'id' + }, + rootValue: { + type: null, + value: null + }, + pathMode: { + type: String, + value: 'mode1' + }, + firstFloorTxt: { + type: String, + value: '顶级' + }, + btnTxt: { + type: String, + value: '选择' + }, + contentKey: { + type: String, + value: 'name' + }, + // 保持位置 + // 如果开启,数据动态更新后,会保持和更新前父元素对应的界面一致 + // 这里是通过记录下更新前的父元素的唯一标识符:id(或是selfKey中设定的键对应的值),在更新后找回显示出来 + // 所以就算更新后路径变了(父元素本来在第四层,变成了第二层之类),仍然能显示父元素的相应界面 + keepLoc: { + type: Boolean, + value: false + } + }, + data: { + outValue: [], + currentPath: [], + // 判断当前是否已正在执行修改路径的方法 + isChange: false, + // 映射value值,存放树形数据 + normalValue: [], + currentFatherId: null + }, + methods: { + initView() { + if (this.properties.keepLoc) { + if (this.data.outValue.length > 0) { + // 记录下当前界面元素的父节点id + let fatherId = this.properties.fatherKey; + this.setData({ + currentFatherId: this.data.outValue[0][fatherId] || null + }); + } + } + // 优先使用value + if (this.properties.value.length > 0) { + this.setData({ + normalValue: this.properties.value + }); + } else { + // 将unnormalizedValue标准化 + this.setData({ + normalValue: this.normalizeValue() + }); + } + + if (this.properties.keepLoc && this.data.currentFatherId !== null) { + // 得到父元素的位置 + let fatherNodeLocation = this.searchLocById(this.data.currentFatherId); + // 父元素的位置即是我们希望得到的当前路径 + let currentPath = fatherNodeLocation; + this.switchPath(currentPath); + } else { + // 设置初始的输出值 + this.setData({ + outValue: this.data.normalValue, + currentPath: [] + }); + } + }, + tapItem(e) { + // 如果正在执行修改路径的方法 + if (this.data.isChange) { + return; + } + this.setData({ + isChange: true + }); + // 获取当前点击的索引 + const currentIndex = e.currentTarget.dataset.index; + const currentText = e.currentTarget.dataset.text; + // 如果当前点击的标签还有下一级,就将路径改变 + if (this.data.outValue[currentIndex].children) { + // 添加索引如路径 + this.setData({ + currentPath: [ + ...this.data.currentPath, + { text: currentText, index: currentIndex } + ] + }); + this.selPath(); + } + this.setData({ + isChange: false + }); + }, + // 选择路径 + // pathsIndex 是 paths 的索引 + selPath(pathsIndex = this.data.currentPath.length - 1) { + // 判断是否在第一级 + if (this.data.currentPath.length === 0) { + return; + } + // 根据路径修改 outValue + let tmpValue = this.data.normalValue; + // 如果 pathsIndex 是 -1 就应该要回到第一级 + if (pathsIndex === -1) { + this.setData({ + currentPath: [], + outValue: tmpValue + }); + return; + } + for (let i = 0; i <= pathsIndex; i++) { + let item = this.data.currentPath[i].index; + tmpValue = tmpValue[item]['children']; + } + // 更新 outValue , currentPath + let endIndex = pathsIndex + 1; + this.setData({ + outValue: tmpValue, + currentPath: this.data.currentPath.slice(0, endIndex) + }); + }, + toPath(e) { + // 如果正在执行修改路径的方法 + if (this.data.isChange) { + return; + } + this.setData({ + isChange: true + }); + // 获取当前点击的索引 + const index = + e.currentTarget.dataset.index != undefined + ? e.currentTarget.dataset.index + : this.data.currentPath.length - 1; + this.selPath(index - 1); + this.setData({ + isChange: false + }); + }, + tapBtn(e) { + this.triggerEvent('tapBtn', e.currentTarget.dataset.item); + }, + // 将非标准值标准化 + normalizeValue() { + return toTree({ + value: this.properties.unnormalizedValue, + fatherKey: this.properties.fatherKey, + selfKey: this.properties.selfKey, + rootValue: + this.properties.rootValue === null + ? undefined + : this.properties.rootValue + }); + }, + // 通过唯一标识符找到元素的所在位置 + // 这里特意用了loc(location)表示位置而不是path,二者的区别是loc还包括了元素自身,而path不包括元素自身 + // 如树形数据[{id:1,name:'1'}],id:1的位置是[1],而它的路径是[] + searchLocById(id) { + if (id == null) { + return null; + } + let tree = JSON.parse(JSON.stringify(this.data.normalValue)); + for (let i = 0; i < tree.length; i++) { + tree[i].__location = [i]; + if (id === tree[i][this.properties.selfKey]) { + return tree[i].__location; + } + } + var stark = []; + stark = stark.concat(tree); + while (stark.length) { + var temp = stark.shift(); + if (temp.children) { + for (let j = 0; j < temp.children.length; j++) { + temp.children[j].__location = [...temp.__location, j]; + if (id === temp.children[j][this.properties.selfKey]) { + return temp.children[j].__location; + } + } + // 当前节点有子节点时,将子节点放到当前的栈的前面 + stark = temp.children.concat(stark); + } + } + // 如果找不到对应id的位置 + return null; + }, + // 直接跳转到指定路径 + switchPath(pathArr = []) { + let tmpValue = JSON.parse(JSON.stringify(this.data.normalValue)); + let currentPath = []; + for (let i = 0; i < pathArr.length; i++) { + let index = pathArr[i]; + let text = tmpValue[index][this.properties.contentKey]; + tmpValue = tmpValue[index]['children']; + currentPath.push({ + text, + index + }); + } + // 更新 outValue , currentPath + this.setData({ + outValue: tmpValue, + currentPath + }); + } + } +}); diff --git a/components/path-view/index.json b/components/path-view/index.json new file mode 100644 index 0000000..a834f67 --- /dev/null +++ b/components/path-view/index.json @@ -0,0 +1,4 @@ +{ + "component": true, +"usingComponents": {} +} \ No newline at end of file diff --git a/components/path-view/index.wxml b/components/path-view/index.wxml new file mode 100644 index 0000000..784ed26 --- /dev/null +++ b/components/path-view/index.wxml @@ -0,0 +1,45 @@ + + + + + 返回上级 + {{firstFloorTxt}} + {{item.text}} + + + + + 返回上级 + {{item.text}} + + + + + {{item[contentKey]}} + (进入下一级) + {{btnTxt}} + + + \ No newline at end of file diff --git a/components/path-view/index.wxss b/components/path-view/index.wxss new file mode 100644 index 0000000..9649566 --- /dev/null +++ b/components/path-view/index.wxss @@ -0,0 +1,56 @@ +/* components/path-view/path-view.wxss */ +.path { + display: flex; + padding: 0 0 0 10px; +} +.path { + min-height: 30px; + + flex-wrap: wrap; +} +.path .btn { + margin-right: 20px; + margin-bottom: 10px; + padding: 0 5px; + height: 20px; + border-radius: 2px; + background: #4b0; + color: #fff; + font-size: 10px; + line-height: 20px; +} +.list-view { + width: 100%; +} +.list-view-item { + position: relative; + display: flex; + flex-direction: row; + box-sizing: border-box; + margin-top: -1px; + width: 100%; + height: 40px; + border: 1px solid #e5e5e5; + border-radius: 3px; +} +.list-view-item .title { + padding-left: 20rpx; + font-size: 14px; + line-height: 40px; +} +.list-view-item .tip { + font-size: 10px; + line-height: 40px; +} +.list-view-item .btn { + position: absolute; + top: 7px; + right: 20rpx; + padding: 0 5px; + height: 25px; + border-radius: 3px; + background: #4b0; + color: #fff; + font-size: 14px; + line-height: 25px; +} \ No newline at end of file diff --git a/components/path-view/toTree.js b/components/path-view/toTree.js new file mode 100644 index 0000000..2ed2680 --- /dev/null +++ b/components/path-view/toTree.js @@ -0,0 +1,34 @@ +export default function toTree({ + value = [], + fatherKey = 'pid', + selfKey = 'id', + childrenKey = 'children', + rootValue = undefined +} = {}) { + // 复制对象 + value = JSON.parse(JSON.stringify(value)); + for (let i = 0; i < value.length; i++) { + let itemI = value[i]; + if (itemI[fatherKey] === rootValue) { + continue; + } + for (let j = 0; j < value.length; j++) { + if (i === j) { + continue; + } + let itemJ = value[j]; + if (itemI[fatherKey] === itemJ[selfKey]) { + if ( + !itemJ[childrenKey] || + Object.prototype.toString.call(itemJ[childrenKey]) !== + '[object Array]' + ) { + itemJ[childrenKey] = []; + } + itemJ[childrenKey].push(itemI); + break; + } + } + } + return value.filter(item => item[fatherKey] === rootValue); +} diff --git a/image/home.png b/image/home.png new file mode 100644 index 0000000..3315b13 Binary files /dev/null and b/image/home.png differ diff --git a/image/homec.png b/image/homec.png new file mode 100644 index 0000000..46444aa Binary files /dev/null and b/image/homec.png differ diff --git a/image/me.png b/image/me.png new file mode 100644 index 0000000..70ba057 Binary files /dev/null and b/image/me.png differ diff --git a/image/mec.png b/image/mec.png new file mode 100644 index 0000000..f9df4d0 Binary files /dev/null and b/image/mec.png differ diff --git a/image/todo.png b/image/todo.png new file mode 100644 index 0000000..9a39097 Binary files /dev/null and b/image/todo.png differ diff --git a/image/todoc.png b/image/todoc.png new file mode 100644 index 0000000..62d13ac Binary files /dev/null and b/image/todoc.png differ diff --git a/pages/bind/binduser.js b/pages/bind/binduser.js new file mode 100644 index 0000000..bcd75a2 --- /dev/null +++ b/pages/bind/binduser.js @@ -0,0 +1,102 @@ +// pages/bind/binduser.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + bindusernameInput: function (e) { + this.data.username = e.detail.value + }, + bindpasswordInput: function (e) { + this.data.password = e.detail.value + }, + denglu: function(){ + var that=this + wx.request({ + url: getApp().globalData.serverUrl + 'bindmp', + header: { + 'content-type': 'application/x-www-form-urlencoded', // + }, + method: 'POST', + data:that.data, + success: res => { + if (res.statusCode === 200) { + if (res.data.code == 1) { + wx.showToast({}) + getApp().onLaunch() + wx.switchTab({ + url: '/pages/main/main', + }) + }else{ + wx.showModal({ + content: '账户或密码不正确!', + showCancel: false, + confirmText: "确定" + }) + } + } + } + }); + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + this.setData({ + mpopenid:wx.getStorageSync('mpopenid') + }) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/pages/bind/binduser.json b/pages/bind/binduser.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/pages/bind/binduser.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/pages/bind/binduser.wxml b/pages/bind/binduser.wxml new file mode 100644 index 0000000..9b66b3f --- /dev/null +++ b/pages/bind/binduser.wxml @@ -0,0 +1,23 @@ + + + 登陆安全预警lite小程序 + 首次使用需要绑定账号 + 请输入预警系统账号密码 + + + 登陆 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pages/bind/binduser.wxss b/pages/bind/binduser.wxss new file mode 100644 index 0000000..9424940 --- /dev/null +++ b/pages/bind/binduser.wxss @@ -0,0 +1,5 @@ +/* pages/bind/binduser.wxss */ +.weui-btn{ + width:auto; + margin: 5px; +} \ No newline at end of file diff --git a/pages/drill/drill.js b/pages/drill/drill.js new file mode 100644 index 0000000..e4b238b --- /dev/null +++ b/pages/drill/drill.js @@ -0,0 +1,66 @@ +// pages/drill/drill.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/pages/drill/drill.json b/pages/drill/drill.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/pages/drill/drill.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/pages/drill/drill.wxml b/pages/drill/drill.wxml new file mode 100644 index 0000000..07b5388 --- /dev/null +++ b/pages/drill/drill.wxml @@ -0,0 +1,2 @@ + +pages/drill/drill.wxml diff --git a/pages/drill/drill.wxss b/pages/drill/drill.wxss new file mode 100644 index 0000000..fab7d81 --- /dev/null +++ b/pages/drill/drill.wxss @@ -0,0 +1 @@ +/* pages/drill/drill.wxss */ \ No newline at end of file diff --git a/pages/footer/footer.js b/pages/footer/footer.js new file mode 100644 index 0000000..6419193 --- /dev/null +++ b/pages/footer/footer.js @@ -0,0 +1,66 @@ +// pages/footer/footer.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/pages/footer/footer.json b/pages/footer/footer.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/footer/footer.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/footer/footer.wxml b/pages/footer/footer.wxml new file mode 100644 index 0000000..fd00b98 --- /dev/null +++ b/pages/footer/footer.wxml @@ -0,0 +1,2 @@ + +pages/footer/footer.wxml diff --git a/pages/footer/footer.wxss b/pages/footer/footer.wxss new file mode 100644 index 0000000..557c47a --- /dev/null +++ b/pages/footer/footer.wxss @@ -0,0 +1 @@ +/* pages/footer/footer.wxss */ \ No newline at end of file diff --git a/pages/images/accident.png b/pages/images/accident.png new file mode 100644 index 0000000..63bc751 Binary files /dev/null and b/pages/images/accident.png differ diff --git a/pages/images/base64.js b/pages/images/base64.js new file mode 100644 index 0000000..97e51d0 --- /dev/null +++ b/pages/images/base64.js @@ -0,0 +1,4 @@ +module.exports = { + icon20: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC4AAAAuCAMAAABgZ9sFAAAAVFBMVEXx8fHMzMzr6+vn5+fv7+/t7e3d3d2+vr7W1tbHx8eysrKdnZ3p6enk5OTR0dG7u7u3t7ejo6PY2Njh4eHf39/T09PExMSvr6+goKCqqqqnp6e4uLgcLY/OAAAAnklEQVRIx+3RSRLDIAxE0QYhAbGZPNu5/z0zrXHiqiz5W72FqhqtVuuXAl3iOV7iPV/iSsAqZa9BS7YOmMXnNNX4TWGxRMn3R6SxRNgy0bzXOW8EBO8SAClsPdB3psqlvG+Lw7ONXg/pTld52BjgSSkA3PV2OOemjIDcZQWgVvONw60q7sIpR38EnHPSMDQ4MjDjLPozhAkGrVbr/z0ANjAF4AcbXmYAAAAASUVORK5CYII=", + icon60: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAeFBMVEUAwAD///+U5ZTc9twOww7G8MYwzDCH4YcfyR9x23Hw+/DY9dhm2WZG0kbT9NP0/PTL8sux7LFe115T1VM+zz7i+OIXxhes6qxr2mvA8MCe6J6M4oz6/frr+us5zjn2/fa67rqB4IF13XWn6ad83nxa1loqyirn+eccHxx4AAAC/klEQVRo3u2W2ZKiQBBF8wpCNSCyLwri7v//4bRIFVXoTBBB+DAReV5sG6lTXDITiGEYhmEYhmEYhmEYhmEY5v9i5fsZGRx9PyGDne8f6K9cfd+mKXe1yNG/0CcqYE86AkBMBh66f20deBc7wA/1WFiTwvSEpBMA2JJOBsSLxe/4QEEaJRrASP8EVF8Q74GbmevKg0saa0B8QbwBdjRyADYxIhqxAZ++IKYtciPXLQVG+imw+oo4Bu56rjEJ4GYsvPmKOAB+xlz7L5aevqUXuePWVhvWJ4eWiwUQ67mK51qPj4dFDMlRLBZTqF3SDvmr4BwtkECu5gHWPkmDfQh02WLxXuvbvC8ku8F57GsI5e0CmUwLz1kq3kD17R1In5816rGvQ5VMk5FEtIiWislTffuDpl/k/PzscdQsv8r9qWq4LRWX6tQYtTxvI3XyrwdyQxChXioOngH3dLgOFjk0all56XRi/wDFQrGQU3Os5t0wJu1GNtNKHdPqYaGYQuRDfbfDf26AGLYSyGS3ZAK4S8XuoAlxGSdYMKwqZKM9XJMtyqXi7HX/CiAZS6d8bSVUz5J36mEMFDTlAFQzxOT1dzLRljjB6+++ejFqka+mXIe6F59mw22OuOw1F4T6lg/9VjL1rLDoI9Xzl1MSYDNHnPQnt3D1EE7PrXjye/3pVpr1Z45hMUdcACc5NVQI0bOdS1WA0wuz73e7/5TNqBPhQXPEFGJNV2zNqWI7QKBd2Gn6AiBko02zuAOXeWIXjV0jNqdKegaE/kJQ6Bfs4aju04lMLkA2T5wBSYPKDGF3RKhFYEa6A1L1LG2yacmsaZ6YPOSAMKNsO+N5dNTfkc5Aqe26uxHpx7ZirvgCwJpWq/lmX1hA7LyabQ34tt5RiJKXSwQ+0KU0V5xg+hZrd4Bn1n4EID+WkQdgLfRNtvil9SPfwy+WQ7PFBWQz6dGWZBLkeJFXZGCfLUjCgGgqXo5TuSu3cugdcTv/HjqnBTEMwzAMwzAMwzAMwzAMw/zf/AFbXiOA6frlMAAAAABJRU5ErkJggg==" +}; \ No newline at end of file diff --git a/pages/images/icon_footer.png b/pages/images/icon_footer.png new file mode 100644 index 0000000..8e65c75 Binary files /dev/null and b/pages/images/icon_footer.png differ diff --git a/pages/images/icon_footer_link.png b/pages/images/icon_footer_link.png new file mode 100644 index 0000000..8e65c75 Binary files /dev/null and b/pages/images/icon_footer_link.png differ diff --git a/pages/images/icon_intro.png b/pages/images/icon_intro.png new file mode 100644 index 0000000..d2bf4a5 Binary files /dev/null and b/pages/images/icon_intro.png differ diff --git a/pages/images/icon_nav_feedback.png b/pages/images/icon_nav_feedback.png new file mode 100644 index 0000000..8c03743 Binary files /dev/null and b/pages/images/icon_nav_feedback.png differ diff --git a/pages/images/icon_nav_form.png b/pages/images/icon_nav_form.png new file mode 100644 index 0000000..9d2addb Binary files /dev/null and b/pages/images/icon_nav_form.png differ diff --git a/pages/images/icon_nav_nav.png b/pages/images/icon_nav_nav.png new file mode 100644 index 0000000..b4fe0f6 Binary files /dev/null and b/pages/images/icon_nav_nav.png differ diff --git a/pages/images/icon_nav_search.png b/pages/images/icon_nav_search.png new file mode 100644 index 0000000..6efea86 Binary files /dev/null and b/pages/images/icon_nav_search.png differ diff --git a/pages/images/icon_nav_special.png b/pages/images/icon_nav_special.png new file mode 100644 index 0000000..7c46cf9 Binary files /dev/null and b/pages/images/icon_nav_special.png differ diff --git a/pages/images/icon_nav_widget.png b/pages/images/icon_nav_widget.png new file mode 100644 index 0000000..1d07c1f Binary files /dev/null and b/pages/images/icon_nav_widget.png differ diff --git a/pages/images/icon_nav_z-index.png b/pages/images/icon_nav_z-index.png new file mode 100644 index 0000000..f32f620 Binary files /dev/null and b/pages/images/icon_nav_z-index.png differ diff --git a/pages/images/icon_tabbar.png b/pages/images/icon_tabbar.png new file mode 100644 index 0000000..20b30ab Binary files /dev/null and b/pages/images/icon_tabbar.png differ diff --git a/pages/images/logo.png b/pages/images/logo.png new file mode 100644 index 0000000..0810604 Binary files /dev/null and b/pages/images/logo.png differ diff --git a/pages/images/man.png b/pages/images/man.png new file mode 100644 index 0000000..d29f4d9 Binary files /dev/null and b/pages/images/man.png differ diff --git a/pages/images/miss.png b/pages/images/miss.png new file mode 100644 index 0000000..ed9b0cc Binary files /dev/null and b/pages/images/miss.png differ diff --git a/pages/images/operation.png b/pages/images/operation.png new file mode 100644 index 0000000..6525376 Binary files /dev/null and b/pages/images/operation.png differ diff --git a/pages/images/part.png b/pages/images/part.png new file mode 100644 index 0000000..9471d2a Binary files /dev/null and b/pages/images/part.png differ diff --git a/pages/images/pic_160.png b/pages/images/pic_160.png new file mode 100644 index 0000000..ba94170 Binary files /dev/null and b/pages/images/pic_160.png differ diff --git a/pages/images/pic_article.png b/pages/images/pic_article.png new file mode 100644 index 0000000..c240812 Binary files /dev/null and b/pages/images/pic_article.png differ diff --git a/pages/images/public.png b/pages/images/public.png new file mode 100644 index 0000000..1b2d11f Binary files /dev/null and b/pages/images/public.png differ diff --git a/pages/images/send.png b/pages/images/send.png new file mode 100644 index 0000000..084410d Binary files /dev/null and b/pages/images/send.png differ diff --git a/pages/images/socert.png b/pages/images/socert.png new file mode 100644 index 0000000..ad0b7b5 Binary files /dev/null and b/pages/images/socert.png differ diff --git a/pages/images/suggest.png b/pages/images/suggest.png new file mode 100644 index 0000000..ba9a4bf Binary files /dev/null and b/pages/images/suggest.png differ diff --git a/pages/images/suggest1.png b/pages/images/suggest1.png new file mode 100644 index 0000000..7149e8f Binary files /dev/null and b/pages/images/suggest1.png differ diff --git a/pages/images/test.png b/pages/images/test.png new file mode 100644 index 0000000..e4003c8 Binary files /dev/null and b/pages/images/test.png differ diff --git a/pages/images/train.png b/pages/images/train.png new file mode 100644 index 0000000..cb37e51 Binary files /dev/null and b/pages/images/train.png differ diff --git a/pages/images/trouble.png b/pages/images/trouble.png new file mode 100644 index 0000000..0d52149 Binary files /dev/null and b/pages/images/trouble.png differ diff --git a/pages/images/troubleb.png b/pages/images/troubleb.png new file mode 100644 index 0000000..e5dae53 Binary files /dev/null and b/pages/images/troubleb.png differ diff --git a/pages/images/troublec.png b/pages/images/troublec.png new file mode 100644 index 0000000..ffdf216 Binary files /dev/null and b/pages/images/troublec.png differ diff --git a/pages/images/vcode.jpg b/pages/images/vcode.jpg new file mode 100644 index 0000000..de54b38 Binary files /dev/null and b/pages/images/vcode.jpg differ diff --git a/pages/images/watch.png b/pages/images/watch.png new file mode 100644 index 0000000..fcf0c16 Binary files /dev/null and b/pages/images/watch.png differ diff --git a/pages/index/index.js b/pages/index/index.js new file mode 100644 index 0000000..1f868c1 --- /dev/null +++ b/pages/index/index.js @@ -0,0 +1,25 @@ +//index.js +//获取应用实例 +const app = getApp() + +Page({ + data: { + }, + //事件处理函数 + bindViewTap: function() { + wx.navigateTo({ + url: '../logs/logs' + }) + }, + onLoad: function () { + this.getName(); + }, + getName: function(){ + var username = wx.getStorageSync('username') + var userid = wx.getStorageSync('userid') + this.setData({ + username: username, + userid: userid, + }) + }, +}) diff --git a/pages/index/index.json b/pages/index/index.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/pages/index/index.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/pages/index/index.wxml b/pages/index/index.wxml new file mode 100644 index 0000000..7b3817c --- /dev/null +++ b/pages/index/index.wxml @@ -0,0 +1,34 @@ + + + + + + + + + + + 平台账号: {{username}} + + 昵称: (点击进入个人信息管理) + + + + + + 资料管理 + + + + + + + 我的特种作业证书 + + + + + + + + \ No newline at end of file diff --git a/pages/index/index.wxss b/pages/index/index.wxss new file mode 100644 index 0000000..ef6e13f --- /dev/null +++ b/pages/index/index.wxss @@ -0,0 +1,5 @@ + +.weui-btn{ + width:auto; + margin: 5px; +} \ No newline at end of file diff --git a/pages/logs/logs.js b/pages/logs/logs.js new file mode 100644 index 0000000..b2b967d --- /dev/null +++ b/pages/logs/logs.js @@ -0,0 +1,15 @@ +//logs.js +const util = require('../../utils/util.js') + +Page({ + data: { + logs: [] + }, + onLoad: function () { + this.setData({ + logs: (wx.getStorageSync('logs') || []).map(log => { + return util.formatTime(new Date(log)) + }) + }) + } +}) diff --git a/pages/logs/logs.json b/pages/logs/logs.json new file mode 100644 index 0000000..28379bc --- /dev/null +++ b/pages/logs/logs.json @@ -0,0 +1,3 @@ +{ + "navigationBarTitleText": "查看启动日志" +} \ No newline at end of file diff --git a/pages/logs/logs.wxml b/pages/logs/logs.wxml new file mode 100644 index 0000000..b5a85ac --- /dev/null +++ b/pages/logs/logs.wxml @@ -0,0 +1,6 @@ + + + + {{index + 1}}. {{log}} + + diff --git a/pages/logs/logs.wxss b/pages/logs/logs.wxss new file mode 100644 index 0000000..94d4b88 --- /dev/null +++ b/pages/logs/logs.wxss @@ -0,0 +1,8 @@ +.log-list { + display: flex; + flex-direction: column; + padding: 40rpx; +} +.log-item { + margin: 10rpx; +} diff --git a/pages/main/main.js b/pages/main/main.js new file mode 100644 index 0000000..704b2b0 --- /dev/null +++ b/pages/main/main.js @@ -0,0 +1,159 @@ +// pages/main/main.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + var that = this + //获取待阅读通知数目 + if(wx.getStorageSync("sessionid")){ + this.getnoread() + this.getyhtodonum() + this.getzytodonum() + this.getpxqdnum() + }else{ + getApp().callback = () => { + this.getnoread() + this.getyhtodonum() + this.getzytodonum() + this.getpxqdnum() + }; + } + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + getnoread: function(){ + wx.request({ + url: getApp().globalData.serverUrl + 'api/notice?a=noreadnum', + header: { + 'content-type': 'application/json', // 默认值 + 'Cookie': wx.getStorageSync("sessionid"), + }, + data: {}, + success: res => { + if (res.statusCode === 200) { + //console.log(res.data) + this.setData({ + noread: res.data.noread, + }) + } + } + }); + }, + getyhtodonum:function(){ + var that = this + //获取隐患待办数目 + wx.request({ + url: getApp().globalData.serverUrl + 'troublehandle?a=todonum', + header: { + 'content-type': 'application/json', // 默认值 + 'Cookie': wx.getStorageSync("sessionid"), + }, + data: {}, + success: res => { + if (res.statusCode === 200) { + //console.log(res.data) + this.setData({ + yhtodonum: res.data.todonum, + }) + } + } + }); + }, + getzytodonum: function () { + var that = this + //获取作业待办数目 + wx.request({ + url: getApp().globalData.serverUrl + 'api/operation?a=todonum', + header: { + 'content-type': 'application/json', // 默认值 + 'Cookie': wx.getStorageSync("sessionid"), + }, + data: {}, + success: res => { + if (res.statusCode === 200) { + //console.log(res.data) + this.setData({ + zytodonum: res.data.todonum, + }) + } + } + }); + }, + getpxqdnum:function(){ + var that = this + //获取待签到培训 + wx.request({ + url: getApp().globalData.serverUrl + 'pxhandle?a=dqdnum', + header: { + 'content-type': 'application/json', // 默认值 + 'Cookie': wx.getStorageSync("sessionid"), + }, + data: {}, + success: res => { + if (res.statusCode === 200) { + //console.log(res.data) + this.setData({ + dqdnum: res.data.dqdnum, + }) + } + } + }); + } +}) \ No newline at end of file diff --git a/pages/main/main.json b/pages/main/main.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/pages/main/main.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/pages/main/main.wxml b/pages/main/main.wxml new file mode 100644 index 0000000..6a03d8f --- /dev/null +++ b/pages/main/main.wxml @@ -0,0 +1,51 @@ + + + 数据采集 + + + + 事故隐患 + {{yhtodonum}} + + + + 行为观察 + + + + 未遂事件 + + + + 合理化建议 + + + + 作业许可 + {{zytodonum}} + + + 学习园地 + + + + 公告 + + + + 通知 + + {{noread}} + + + + 线下培训 + {{dqdnum}} + + + + 即将上线.. + + + + \ No newline at end of file diff --git a/pages/main/main.wxss b/pages/main/main.wxss new file mode 100644 index 0000000..ecc2274 --- /dev/null +++ b/pages/main/main.wxss @@ -0,0 +1 @@ +/* pages/main/main.wxss */ \ No newline at end of file diff --git a/pages/miss/addmiss.js b/pages/miss/addmiss.js new file mode 100644 index 0000000..67c6078 --- /dev/null +++ b/pages/miss/addmiss.js @@ -0,0 +1,227 @@ +// pages/miss/addmiss.js +var dateTimePicker = require('../../utils/dateTimePicker.js'); +Page({ + + /** + * 页面的初始数据 + */ + data: { + misstime: '', + missplace: '', + missimg: [], + }, + bindmissplaceInput: function (e) { + this.data.missplace = e.detail.value + }, + binddescriptionInput: function (e) { + this.data.description = e.detail.value + }, + bindpreventInput: function (e) { + this.data.prevent = e.detail.value + }, + bindlessonInput: function (e) { + this.data.lesson = e.detail.value + }, + submit: function () { + var that = this + if (that.data.missplace == '') { + that.Tap1('请输入发生地点!') + } else if (that.data.description == '') { + that.Tap1('请输入简要描述!') + } else { + that.upimg(0, that.data.missimg.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': wx.getStorageSync("sessionid"), + }, + url: getApp().globalData.serverUrl + 'upfile', + filePath: that.data.missimg[x], + name: 'upfile', + success(res) { + var obj = JSON.parse(res.data); + that.data.missimg[x] = obj['filepath'] + x = x + 1 + if (x < y) { + that.upimg(x, y) + } + else { + that.addobserve() + } + } + }) + } else { + that.addobserve() + } + }, + addobserve: function () { + var wsdata = { + misstime: this.data.misstime, + missplace: this.data.missplace, + description: this.data.description, + missimg: this.data.missimg, + prevent: this.data.prevent, + lesson: this.data.lesson, + } + //console.log(wsdata.unsafe) + wx.request({ + url: getApp().globalData.serverUrl + 'api/miss?a=add', + header: { + 'content-type': 'application/json', // + 'Cookie': wx.getStorageSync("sessionid"), + }, + method: 'POST', + data: wsdata, + success: res => { + if (res.statusCode === 200) { + wx.hideLoading(); + wx.navigateBack() + } + } + }); + }, + /** + * 生命周期函数--监听页面加载 + */ + 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.misstime = time + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + 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.misstime = 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({ + missimg: that.data.missimg.concat(res.tempFilePaths) + }) + } + }) + }, + previewImage: function (e) { + var current = e.target.dataset.src + wx.previewImage({ + current: current, + urls: this.data.missimg + }) + }, + deleteImage: function (e) { + var that = this; + var missimg = that.data.missimg; + var index = e.currentTarget.dataset.index; //获取当前长按图片下标 + wx.showModal({ + title: '系统提醒', + content: '确定要删除此图片吗?', + success: function (res) { + if (res.confirm) { + missimg.splice(index, 1); + } else if (res.cancel) { + return false; + } + that.setData({ + missimg: missimg + }); + } + }) + }, + +}) \ No newline at end of file diff --git a/pages/miss/addmiss.json b/pages/miss/addmiss.json new file mode 100644 index 0000000..ed605dd --- /dev/null +++ b/pages/miss/addmiss.json @@ -0,0 +1,3 @@ +{ + "navigationBarTitleText": "新增事件" +} \ No newline at end of file diff --git a/pages/miss/addmiss.wxml b/pages/miss/addmiss.wxml new file mode 100644 index 0000000..f892a20 --- /dev/null +++ b/pages/miss/addmiss.wxml @@ -0,0 +1,81 @@ + + + 错误提示 + + + 事件信息 + + + + 发生时间 + + + + + {{dateTimeArray1[0][dateTime1[0]]}}-{{dateTimeArray1[1][dateTime1[1]]}}-{{dateTimeArray1[2][dateTime1[2]]}} {{dateTimeArray1[3][dateTime1[3]]}}:{{dateTimeArray1[4][dateTime1[4]]}} + + + + + + + 发生地点 + + + + + + + 现场图片(如有) + + + + + + + + + + + + + + + + + + + + +简要描述 + + + +