@ -0,0 +1,150 @@ |
|||
'use strict'; |
|||
const moment = require('moment') |
|||
|
|||
function getDeviceList(opts) { |
|||
return async function (ctx, next) { |
|||
|
|||
const models = ctx.fs.dc.models; |
|||
const { page, limit, name } = ctx.query; |
|||
const Op = ctx.fs.dc.ORM.Op; |
|||
let errMsg = { message: '获取设备失败' } |
|||
try { |
|||
let searchWhere = {} |
|||
let option = { |
|||
where: searchWhere, |
|||
order: [["id", "desc"]], |
|||
include: [{ model: models.PointDevice }] |
|||
} |
|||
|
|||
if (name) { |
|||
searchWhere.name = { $like: `%${name}%` }; |
|||
} |
|||
|
|||
option.where = searchWhere |
|||
let limit_ = limit || 10; |
|||
let page_ = page || 1; |
|||
let offset = (page_ - 1) * limit_; |
|||
if (limit && page) { |
|||
option.limit = limit_ |
|||
option.offset = offset |
|||
} |
|||
|
|||
const res = await models.Device.findAndCount(option); |
|||
ctx.status = 200; |
|||
ctx.body = res; |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = errMsg |
|||
} |
|||
} |
|||
} |
|||
|
|||
// 新增设备
|
|||
function addDevice(opts) { |
|||
let message = '新建设备失败' |
|||
return async function (ctx, next) { |
|||
|
|||
const models = ctx.fs.dc.models; |
|||
try { |
|||
if (Array.isArray(ctx.request.body)) { |
|||
const names = ctx.request.body.map(s => s.name) |
|||
const checkName = await models.Device.findOne({ where: { name: { $in: names } } }); |
|||
if (checkName) { |
|||
message = checkName.name + '名称已存在' |
|||
throw new Error(message) |
|||
} else { |
|||
await models.Device.bulkCreate(ctx.request.body) |
|||
ctx.status = 204; |
|||
ctx.body = { message: '批量导入设备成功' } |
|||
} |
|||
|
|||
} else { |
|||
const { name } = ctx.request.body |
|||
const checkName = await models.Device.findOne({ where: { name } }); |
|||
if (checkName) { |
|||
message = '该设备名称已存在' |
|||
throw new Error(message) |
|||
} else { |
|||
let rslt = ctx.request.body; |
|||
await models.Device.create(Object.assign({}, rslt)) |
|||
ctx.status = 204; |
|||
ctx.body = { message: '新建设备成功' } |
|||
} |
|||
} |
|||
|
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { message: message } |
|||
} |
|||
} |
|||
} |
|||
|
|||
// 修改设备
|
|||
function editDevice(opts) { |
|||
let message = '新建设备失败' |
|||
return async function (ctx, next) { |
|||
|
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { id } = ctx.params; |
|||
const body = ctx.request.body; |
|||
|
|||
const { name } = ctx.request.body; |
|||
|
|||
const checkName = await models.Device.findOne({ where: { id: { $not: id }, name } }); |
|||
if (checkName) { |
|||
message = '该设备名称已存在' |
|||
throw new Error(message) |
|||
} else { |
|||
await models.Device.update( |
|||
body, |
|||
{ where: { id: id, } } |
|||
) |
|||
ctx.status = 204; |
|||
ctx.body = { message: '修改设备成功' } |
|||
} |
|||
|
|||
|
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { message: message } |
|||
} |
|||
} |
|||
} |
|||
|
|||
// 删除设备
|
|||
function deleteDevice(opts) { |
|||
return async function (ctx, next) { |
|||
|
|||
try { |
|||
const models = ctx.fs.dc.models; |
|||
const { id } = ctx.params; |
|||
if (id) { |
|||
await models.Device.destroy({ |
|||
where: { |
|||
id: { $in: id.split(',') } |
|||
} |
|||
}) |
|||
ctx.status = 204; |
|||
ctx.body = { message: '删除设备成功' } |
|||
} else { |
|||
throw new Error('参数异常!') |
|||
} |
|||
|
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { message: '删除设备失败' } |
|||
} |
|||
} |
|||
} |
|||
|
|||
module.exports = { |
|||
getDeviceList, |
|||
addDevice, |
|||
editDevice, |
|||
deleteDevice |
|||
} |
@ -0,0 +1,23 @@ |
|||
'use strict'; |
|||
|
|||
const device = require('../../controllers/device/index'); |
|||
|
|||
module.exports = function (app, router, opts, AuthCode) { |
|||
|
|||
app.fs.api.logAttr['POST/device'] = { content: '增加设备信息', visible: true }; |
|||
router.post('/device', device.addDevice(opts)) |
|||
|
|||
// 修改设备信息
|
|||
app.fs.api.logAttr['PUT/device/:id'] = { content: '修改设备信息', visible: true }; |
|||
router.put('/device/:id', device.editDevice(opts)) |
|||
|
|||
// 删除设备信息
|
|||
app.fs.api.logAttr['DEL/device/:id'] = { content: '删除设备信息', visible: true }; |
|||
router.del('/device/:id', device.deleteDevice(opts)) |
|||
|
|||
// 获取设备信息列表
|
|||
app.fs.api.logAttr['GET/device'] = { content: '获取设备信息列表', visible: true }; |
|||
router.get('/device', device.getDeviceList(opts)); |
|||
|
|||
|
|||
}; |
@ -1,19 +1,53 @@ |
|||
/**app.wxss**/ |
|||
.page { |
|||
/* vant 全局CSS变量 */ |
|||
/* DropdownMenu */ |
|||
--dropdown-menu-background-color: transparent; |
|||
--dropdown-menu-box-shadow: none; |
|||
--dropdown-menu-title-active-text-color: #1684FF; |
|||
--dropdown-menu-option-active-color: #1684FF; |
|||
/* vant 全局CSS变量 */ |
|||
/* DropdownMenu */ |
|||
--dropdown-menu-background-color: transparent; |
|||
--dropdown-menu-box-shadow: none; |
|||
--dropdown-menu-title-active-text-color: #1684FF; |
|||
--dropdown-menu-option-active-color: #1684FF; |
|||
} |
|||
|
|||
.container { |
|||
height: 100%; |
|||
display: flex; |
|||
flex-direction: column; |
|||
align-items: center; |
|||
justify-content: space-between; |
|||
padding: 200rpx 0; |
|||
box-sizing: border-box; |
|||
height: 100%; |
|||
display: flex; |
|||
flex-direction: column; |
|||
align-items: center; |
|||
justify-content: space-between; |
|||
padding: 200rpx 0; |
|||
box-sizing: border-box; |
|||
} |
|||
|
|||
/* 弹性布局 */ |
|||
.flex { |
|||
display: flex; |
|||
justify-content: center; |
|||
align-items: center; |
|||
} |
|||
|
|||
.flex-start { |
|||
justify-content: flex-start; |
|||
} |
|||
|
|||
.flex-col { |
|||
flex-direction: column; |
|||
} |
|||
|
|||
.flex-between { |
|||
justify-content: space-between; |
|||
} |
|||
|
|||
.flex-evenly { |
|||
justify-content: space-evenly; |
|||
} |
|||
|
|||
.flex-wrap { |
|||
flex-wrap: wrap; |
|||
} |
|||
|
|||
/* 字体省略号 */ |
|||
.text--- { |
|||
overflow: hidden; |
|||
text-overflow: ellipsis; |
|||
white-space: nowrap; |
|||
} |
@ -0,0 +1,32 @@ |
|||
Component({ |
|||
data: { |
|||
selected: 0, |
|||
color: "#7A7E83", |
|||
selectedColor: "#1070E8", |
|||
list: [] |
|||
}, |
|||
attached () { |
|||
let userRole = wx.getStorageSync('userRole'); |
|||
// 0 表示普通用户 1表示管理员
|
|||
console.log('userRole', userRole); |
|||
if (userRole && userRole.includes('管理')) { |
|||
this.setData({ |
|||
list: getApp().globalData.managerList |
|||
}) |
|||
} else { |
|||
this.setData({ |
|||
list: getApp().globalData.inspecterList |
|||
}) |
|||
} |
|||
}, |
|||
methods: { |
|||
switchTab (e) { |
|||
const data = e.currentTarget.dataset |
|||
const url = data.path |
|||
// this.setData({
|
|||
// selected: data.index
|
|||
// })
|
|||
wx.switchTab({ url }) |
|||
} |
|||
} |
|||
}) |
@ -0,0 +1,3 @@ |
|||
{ |
|||
"component": true |
|||
} |
@ -0,0 +1,8 @@ |
|||
<!-- miniprogram/custom-tab-bar/index.wxml --> |
|||
<view class="tab-bar"> |
|||
<view class="tab-bar-border"></view> |
|||
<view wx:for="{{list}}" wx:key="index" class="tab-bar-item" data-path="{{item.pagePath}}" data-index="{{index}}" bindtap="switchTab"> |
|||
<image src="{{selected === index ? item.selectedIconPath : item.iconPath}}"></image> |
|||
<view style="color: {{selected === index ? selectedColor : color}}">{{item.text}}</view> |
|||
</view> |
|||
</view> |
@ -0,0 +1,38 @@ |
|||
.tab-bar { |
|||
position: fixed; |
|||
bottom: 0; |
|||
left: 0; |
|||
right: 0; |
|||
height: 48px; |
|||
background: white; |
|||
display: flex; |
|||
padding-bottom: env(safe-area-inset-bottom); |
|||
} |
|||
|
|||
.tab-bar-border { |
|||
background-color: rgba(0, 0, 0, 0.33); |
|||
position: absolute; |
|||
left: 0; |
|||
top: 0; |
|||
width: 100%; |
|||
height: 1px; |
|||
transform: scaleY(0.5); |
|||
} |
|||
|
|||
.tab-bar-item { |
|||
flex: 1; |
|||
text-align: center; |
|||
display: flex; |
|||
justify-content: center; |
|||
align-items: center; |
|||
flex-direction: column; |
|||
} |
|||
|
|||
.tab-bar-item image { |
|||
width: 27px; |
|||
height: 27px; |
|||
} |
|||
|
|||
.tab-bar-item view { |
|||
font-size: 10px; |
|||
} |
After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 517 B |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 21 KiB |
@ -0,0 +1,284 @@ |
|||
import WxCanvas from './wx-canvas'; |
|||
import * as echarts from './echarts'; |
|||
|
|||
let ctx; |
|||
|
|||
function compareVersion(v1, v2) { |
|||
v1 = v1.split('.') |
|||
v2 = v2.split('.') |
|||
const len = Math.max(v1.length, v2.length) |
|||
|
|||
while (v1.length < len) { |
|||
v1.push('0') |
|||
} |
|||
while (v2.length < len) { |
|||
v2.push('0') |
|||
} |
|||
|
|||
for (let i = 0; i < len; i++) { |
|||
const num1 = parseInt(v1[i]) |
|||
const num2 = parseInt(v2[i]) |
|||
|
|||
if (num1 > num2) { |
|||
return 1 |
|||
} else if (num1 < num2) { |
|||
return -1 |
|||
} |
|||
} |
|||
return 0 |
|||
} |
|||
|
|||
Component({ |
|||
properties: { |
|||
canvasId: { |
|||
type: String, |
|||
value: 'ec-canvas' |
|||
}, |
|||
|
|||
ec: { |
|||
type: Object |
|||
}, |
|||
|
|||
forceUseOldCanvas: { |
|||
type: Boolean, |
|||
value: false |
|||
} |
|||
}, |
|||
|
|||
data: { |
|||
isUseNewCanvas: false |
|||
}, |
|||
|
|||
ready: function () { |
|||
// Disable prograssive because drawImage doesn't support DOM as parameter
|
|||
// See https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.drawImage.html
|
|||
echarts.registerPreprocessor(option => { |
|||
if (option && option.series) { |
|||
if (option.series.length > 0) { |
|||
option.series.forEach(series => { |
|||
series.progressive = 0; |
|||
}); |
|||
} |
|||
else if (typeof option.series === 'object') { |
|||
option.series.progressive = 0; |
|||
} |
|||
} |
|||
}); |
|||
|
|||
if (!this.data.ec) { |
|||
console.warn('组件需绑定 ec 变量,例:<ec-canvas id="mychart-dom-bar" ' |
|||
+ 'canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas>'); |
|||
return; |
|||
} |
|||
|
|||
if (!this.data.ec.lazyLoad) { |
|||
this.init(); |
|||
} |
|||
}, |
|||
|
|||
methods: { |
|||
init: function (callback) { |
|||
const version = wx.getSystemInfoSync().SDKVersion |
|||
|
|||
const canUseNewCanvas = compareVersion(version, '2.9.0') >= 0; |
|||
const forceUseOldCanvas = this.data.forceUseOldCanvas; |
|||
const isUseNewCanvas = canUseNewCanvas && !forceUseOldCanvas; |
|||
this.setData({ isUseNewCanvas }); |
|||
|
|||
if (forceUseOldCanvas && canUseNewCanvas) { |
|||
console.warn('开发者强制使用旧canvas,建议关闭'); |
|||
} |
|||
|
|||
if (isUseNewCanvas) { |
|||
// console.log('微信基础库版本大于2.9.0,开始使用<canvas type="2d"/>');
|
|||
// 2.9.0 可以使用 <canvas type="2d"></canvas>
|
|||
this.initByNewWay(callback); |
|||
} else { |
|||
const isValid = compareVersion(version, '1.9.91') >= 0 |
|||
if (!isValid) { |
|||
console.error('微信基础库版本过低,需大于等于 1.9.91。' |
|||
+ '参见:https://github.com/ecomfe/echarts-for-weixin' |
|||
+ '#%E5%BE%AE%E4%BF%A1%E7%89%88%E6%9C%AC%E8%A6%81%E6%B1%82'); |
|||
return; |
|||
} else { |
|||
console.warn('建议将微信基础库调整大于等于2.9.0版本。升级后绘图将有更好性能'); |
|||
this.initByOldWay(callback); |
|||
} |
|||
} |
|||
}, |
|||
|
|||
initByOldWay(callback) { |
|||
// 1.9.91 <= version < 2.9.0:原来的方式初始化
|
|||
ctx = wx.createCanvasContext(this.data.canvasId, this); |
|||
const canvas = new WxCanvas(ctx, this.data.canvasId, false); |
|||
|
|||
if (echarts.setPlatformAPI) { |
|||
echarts.setPlatformAPI({ |
|||
createCanvas: () => canvas, |
|||
}); |
|||
} else { |
|||
echarts.setCanvasCreator(() => canvas); |
|||
}; |
|||
// const canvasDpr = wx.getSystemInfoSync().pixelRatio // 微信旧的canvas不能传入dpr
|
|||
const canvasDpr = 1 |
|||
var query = wx.createSelectorQuery().in(this); |
|||
query.select('.ec-canvas').boundingClientRect(res => { |
|||
if (typeof callback === 'function') { |
|||
this.chart = callback(canvas, res.width, res.height, canvasDpr); |
|||
} |
|||
else if (this.data.ec && typeof this.data.ec.onInit === 'function') { |
|||
this.chart = this.data.ec.onInit(canvas, res.width, res.height, canvasDpr); |
|||
} |
|||
else { |
|||
this.triggerEvent('init', { |
|||
canvas: canvas, |
|||
width: res.width, |
|||
height: res.height, |
|||
canvasDpr: canvasDpr // 增加了dpr,可方便外面echarts.init
|
|||
}); |
|||
} |
|||
}).exec(); |
|||
}, |
|||
|
|||
initByNewWay(callback) { |
|||
// version >= 2.9.0:使用新的方式初始化
|
|||
const query = wx.createSelectorQuery().in(this) |
|||
query |
|||
.select('.ec-canvas') |
|||
.fields({ node: true, size: true }) |
|||
.exec(res => { |
|||
const canvasNode = res[0].node |
|||
this.canvasNode = canvasNode |
|||
|
|||
const canvasDpr = wx.getSystemInfoSync().pixelRatio |
|||
const canvasWidth = res[0].width |
|||
const canvasHeight = res[0].height |
|||
|
|||
const ctx = canvasNode.getContext('2d') |
|||
|
|||
const canvas = new WxCanvas(ctx, this.data.canvasId, true, canvasNode) |
|||
if (echarts.setPlatformAPI) { |
|||
echarts.setPlatformAPI({ |
|||
createCanvas: () => canvas, |
|||
loadImage: (src, onload, onerror) => { |
|||
if (canvasNode.createImage) { |
|||
const image = canvasNode.createImage(); |
|||
image.onload = onload; |
|||
image.onerror = onerror; |
|||
image.src = src; |
|||
return image; |
|||
} |
|||
console.error('加载图片依赖 `Canvas.createImage()` API,要求小程序基础库版本在 2.7.0 及以上。'); |
|||
// PENDING fallback?
|
|||
} |
|||
}) |
|||
} else { |
|||
echarts.setCanvasCreator(() => canvas) |
|||
} |
|||
|
|||
if (typeof callback === 'function') { |
|||
this.chart = callback(canvas, canvasWidth, canvasHeight, canvasDpr) |
|||
} else if (this.data.ec && typeof this.data.ec.onInit === 'function') { |
|||
this.chart = this.data.ec.onInit(canvas, canvasWidth, canvasHeight, canvasDpr) |
|||
} else { |
|||
this.triggerEvent('init', { |
|||
canvas: canvas, |
|||
width: canvasWidth, |
|||
height: canvasHeight, |
|||
dpr: canvasDpr |
|||
}) |
|||
} |
|||
}) |
|||
}, |
|||
canvasToTempFilePath(opt) { |
|||
if (this.data.isUseNewCanvas) { |
|||
// 新版
|
|||
const query = wx.createSelectorQuery().in(this) |
|||
query |
|||
.select('.ec-canvas') |
|||
.fields({ node: true, size: true }) |
|||
.exec(res => { |
|||
const canvasNode = res[0].node |
|||
opt.canvas = canvasNode |
|||
wx.canvasToTempFilePath(opt) |
|||
}) |
|||
} else { |
|||
// 旧的
|
|||
if (!opt.canvasId) { |
|||
opt.canvasId = this.data.canvasId; |
|||
} |
|||
ctx.draw(true, () => { |
|||
wx.canvasToTempFilePath(opt, this); |
|||
}); |
|||
} |
|||
}, |
|||
|
|||
touchStart(e) { |
|||
if (this.chart && e.touches.length > 0) { |
|||
var touch = e.touches[0]; |
|||
var handler = this.chart.getZr().handler; |
|||
handler.dispatch('mousedown', { |
|||
zrX: touch.x, |
|||
zrY: touch.y, |
|||
preventDefault: () => {}, |
|||
stopImmediatePropagation: () => {}, |
|||
stopPropagation: () => {} |
|||
}); |
|||
handler.dispatch('mousemove', { |
|||
zrX: touch.x, |
|||
zrY: touch.y, |
|||
preventDefault: () => {}, |
|||
stopImmediatePropagation: () => {}, |
|||
stopPropagation: () => {} |
|||
}); |
|||
handler.processGesture(wrapTouch(e), 'start'); |
|||
} |
|||
}, |
|||
|
|||
touchMove(e) { |
|||
if (this.chart && e.touches.length > 0) { |
|||
var touch = e.touches[0]; |
|||
var handler = this.chart.getZr().handler; |
|||
handler.dispatch('mousemove', { |
|||
zrX: touch.x, |
|||
zrY: touch.y, |
|||
preventDefault: () => {}, |
|||
stopImmediatePropagation: () => {}, |
|||
stopPropagation: () => {} |
|||
}); |
|||
handler.processGesture(wrapTouch(e), 'change'); |
|||
} |
|||
}, |
|||
|
|||
touchEnd(e) { |
|||
if (this.chart) { |
|||
const touch = e.changedTouches ? e.changedTouches[0] : {}; |
|||
var handler = this.chart.getZr().handler; |
|||
handler.dispatch('mouseup', { |
|||
zrX: touch.x, |
|||
zrY: touch.y, |
|||
preventDefault: () => {}, |
|||
stopImmediatePropagation: () => {}, |
|||
stopPropagation: () => {} |
|||
}); |
|||
handler.dispatch('click', { |
|||
zrX: touch.x, |
|||
zrY: touch.y, |
|||
preventDefault: () => {}, |
|||
stopImmediatePropagation: () => {}, |
|||
stopPropagation: () => {} |
|||
}); |
|||
handler.processGesture(wrapTouch(e), 'end'); |
|||
} |
|||
} |
|||
} |
|||
}); |
|||
|
|||
function wrapTouch(event) { |
|||
for (let i = 0; i < event.touches.length; ++i) { |
|||
const touch = event.touches[i]; |
|||
touch.offsetX = touch.x; |
|||
touch.offsetY = touch.y; |
|||
} |
|||
return event; |
|||
} |
@ -1,3 +1,4 @@ |
|||
{ |
|||
"component": true, |
|||
"usingComponents": {} |
|||
} |
@ -0,0 +1,4 @@ |
|||
<!-- 新的:接口对其了H5 --> |
|||
<canvas wx:if="{{isUseNewCanvas}}" type="2d" class="ec-canvas" canvas-id="{{ canvasId }}" bindinit="init" bindtouchstart="{{ ec.disableTouch ? '' : 'touchStart' }}" bindtouchmove="{{ ec.disableTouch ? '' : 'touchMove' }}" bindtouchend="{{ ec.disableTouch ? '' : 'touchEnd' }}"></canvas> |
|||
<!-- 旧的 --> |
|||
<canvas wx:else class="ec-canvas" canvas-id="{{ canvasId }}" bindinit="init" bindtouchstart="{{ ec.disableTouch ? '' : 'touchStart' }}" bindtouchmove="{{ ec.disableTouch ? '' : 'touchMove' }}" bindtouchend="{{ ec.disableTouch ? '' : 'touchEnd' }}"></canvas> |
@ -0,0 +1,4 @@ |
|||
.ec-canvas { |
|||
width: 100%; |
|||
height: 100%; |
|||
} |
@ -0,0 +1,111 @@ |
|||
export default class WxCanvas { |
|||
constructor(ctx, canvasId, isNew, canvasNode) { |
|||
this.ctx = ctx; |
|||
this.canvasId = canvasId; |
|||
this.chart = null; |
|||
this.isNew = isNew |
|||
if (isNew) { |
|||
this.canvasNode = canvasNode; |
|||
} |
|||
else { |
|||
this._initStyle(ctx); |
|||
} |
|||
|
|||
// this._initCanvas(zrender, ctx);
|
|||
|
|||
this._initEvent(); |
|||
} |
|||
|
|||
getContext(contextType) { |
|||
if (contextType === '2d') { |
|||
return this.ctx; |
|||
} |
|||
} |
|||
|
|||
// canvasToTempFilePath(opt) {
|
|||
// if (!opt.canvasId) {
|
|||
// opt.canvasId = this.canvasId;
|
|||
// }
|
|||
// return wx.canvasToTempFilePath(opt, this);
|
|||
// }
|
|||
|
|||
setChart(chart) { |
|||
this.chart = chart; |
|||
} |
|||
|
|||
addEventListener() { |
|||
// noop
|
|||
} |
|||
|
|||
attachEvent() { |
|||
// noop
|
|||
} |
|||
|
|||
detachEvent() { |
|||
// noop
|
|||
} |
|||
|
|||
_initCanvas(zrender, ctx) { |
|||
zrender.util.getContext = function () { |
|||
return ctx; |
|||
}; |
|||
|
|||
zrender.util.$override('measureText', function (text, font) { |
|||
ctx.font = font || '12px sans-serif'; |
|||
return ctx.measureText(text); |
|||
}); |
|||
} |
|||
|
|||
_initStyle(ctx) { |
|||
ctx.createRadialGradient = () => { |
|||
return ctx.createCircularGradient(arguments); |
|||
}; |
|||
} |
|||
|
|||
_initEvent() { |
|||
this.event = {}; |
|||
const eventNames = [{ |
|||
wxName: 'touchStart', |
|||
ecName: 'mousedown' |
|||
}, { |
|||
wxName: 'touchMove', |
|||
ecName: 'mousemove' |
|||
}, { |
|||
wxName: 'touchEnd', |
|||
ecName: 'mouseup' |
|||
}, { |
|||
wxName: 'touchEnd', |
|||
ecName: 'click' |
|||
}]; |
|||
eventNames.forEach(name => { |
|||
this.event[name.wxName] = e => { |
|||
const touch = e.touches[0]; |
|||
this.chart.getZr().handler.dispatch(name.ecName, { |
|||
zrX: name.wxName === 'tap' ? touch.clientX : touch.x, |
|||
zrY: name.wxName === 'tap' ? touch.clientY : touch.y, |
|||
preventDefault: () => {}, |
|||
stopImmediatePropagation: () => {}, |
|||
stopPropagation: () => {} |
|||
}); |
|||
}; |
|||
}); |
|||
} |
|||
|
|||
set width(w) { |
|||
if (this.canvasNode) this.canvasNode.width = w |
|||
} |
|||
set height(h) { |
|||
if (this.canvasNode) this.canvasNode.height = h |
|||
} |
|||
|
|||
get width() { |
|||
if (this.canvasNode) |
|||
return this.canvasNode.width |
|||
return 0 |
|||
} |
|||
get height() { |
|||
if (this.canvasNode) |
|||
return this.canvasNode.height |
|||
return 0 |
|||
} |
|||
} |
@ -1,2 +0,0 @@ |
|||
<!--package/homePage/homePage.wxml--> |
|||
<text>package/homePage/homePage.wxml</text> |
@ -1 +0,0 @@ |
|||
/* package/homePage/homePage.wxss */ |
@ -1,4 +1,4 @@ |
|||
// package/homePage/homePage.js
|
|||
// package/riskManagement/riskCalendar/riskCalendar.js
|
|||
Page({ |
|||
|
|||
/** |
@ -0,0 +1,9 @@ |
|||
{ |
|||
"navigationBarBackgroundColor": "#1979ff", |
|||
"navigationBarTextStyle": "white", |
|||
"navigationBarTitleText": "故障日历", |
|||
"enablePullDownRefresh": false, |
|||
"usingComponents": { |
|||
"ec-canvas": "../../components/ec-canvas/ec-canvas" |
|||
} |
|||
} |
@ -0,0 +1,2 @@ |
|||
<!--package/riskManagement/riskCalendar/riskCalendar.wxml--> |
|||
<text>package/riskManagement/riskCalendar/riskCalendar.wxml</text> |
@ -0,0 +1 @@ |
|||
/* package/riskManagement/riskCalendar/riskCalendar.wxss */ |
@ -0,0 +1,126 @@ |
|||
// package/riskManagement/riskManagement.js
|
|||
import * as echarts from '../components/ec-canvas/echarts'; |
|||
|
|||
function setOption(chart, data) { |
|||
const option = { |
|||
grid: { |
|||
top: '5%', |
|||
left: '3%', |
|||
right: '4%', |
|||
bottom: '3%', |
|||
containLabel: true |
|||
}, |
|||
xAxis: { |
|||
type: 'category', |
|||
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] |
|||
}, |
|||
yAxis: { |
|||
type: 'value' |
|||
}, |
|||
series: [ |
|||
{ |
|||
data: data, |
|||
type: 'line' |
|||
} |
|||
] |
|||
}; |
|||
chart.setOption(option); |
|||
} |
|||
|
|||
Page({ |
|||
|
|||
/** |
|||
* 页面的初始数据 |
|||
*/ |
|||
data: { |
|||
ec: { |
|||
// onInit: initChart,
|
|||
lazyLoad: true, // 将 lazyLoad 设为 true 后,需要手动初始化图表
|
|||
}, |
|||
isLoaded: false, |
|||
list: [1,2,3] |
|||
}, |
|||
|
|||
// 初始化图表
|
|||
initChart: function (data) { |
|||
this.ecComponent.init((canvas, width, height, dpr) => { |
|||
// 获取组件的 canvas、width、height 后的回调函数
|
|||
// 在这里初始化图表
|
|||
const chart = echarts.init(canvas, null, { |
|||
width: width, |
|||
height: height, |
|||
devicePixelRatio: dpr // new
|
|||
}); |
|||
setOption(chart, data); |
|||
|
|||
// 将图表实例绑定到 this 上,可以在其他成员函数中访问
|
|||
this.chart = chart; |
|||
|
|||
this.setData({ |
|||
isLoaded: true, |
|||
}); |
|||
|
|||
// 注意这里一定要返回 chart 实例,否则会影响事件处理等
|
|||
return chart; |
|||
}); |
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面加载 |
|||
*/ |
|||
onLoad(options) { |
|||
// 请求数据
|
|||
setTimeout(() => { |
|||
this.initChart([250, 300, 100, 147, 260, 123, 311]) |
|||
}, 1000) |
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面初次渲染完成 |
|||
*/ |
|||
onReady() { |
|||
this.ecComponent = this.selectComponent('#risk-trend-chart'); |
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面显示 |
|||
*/ |
|||
onShow() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面隐藏 |
|||
*/ |
|||
onHide() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面卸载 |
|||
*/ |
|||
onUnload() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面相关事件处理函数--监听用户下拉动作 |
|||
*/ |
|||
onPullDownRefresh() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面上拉触底事件的处理函数 |
|||
*/ |
|||
onReachBottom() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 用户点击右上角分享 |
|||
*/ |
|||
onShareAppMessage() { |
|||
|
|||
} |
|||
}) |
@ -0,0 +1,9 @@ |
|||
{ |
|||
"navigationBarBackgroundColor": "#006BE3", |
|||
"navigationBarTextStyle": "white", |
|||
"navigationBarTitleText": "故障风险管理", |
|||
"enablePullDownRefresh": false, |
|||
"usingComponents": { |
|||
"ec-canvas": "../components/ec-canvas/ec-canvas" |
|||
} |
|||
} |
@ -0,0 +1,41 @@ |
|||
<!-- package / riskManagement / riskManagement.wxml --> |
|||
<view class="risk-management"> |
|||
<view class="icon"><text class="icon-text">故障统计</text></view> |
|||
|
|||
<view class="flex flex-between"> |
|||
<view class="title-item flex flex-col"> |
|||
<view>本月上报风险</view> |
|||
<view><text class="title-num">{{86}}</text><text class="title-unit">个</text></view> |
|||
</view> |
|||
<view class="title-item flex flex-col"> |
|||
<view>故障风险管理</view> |
|||
<view><text class="title-num">{{300}}</text><text class="title-unit">个</text></view> |
|||
</view> |
|||
</view> |
|||
|
|||
<view class="card"> |
|||
<view class="flex flex-start"> |
|||
<!-- <image src="" class="card-img" /> --> |
|||
<view class="card-img" style="background: blue;"></view> |
|||
<view class="card-title">历史风险趋势</view> |
|||
</view> |
|||
<view class="chart"> |
|||
<ec-canvas id="risk-trend-chart" canvas-id="risk-trend-chart" ec="{{ ec }}"></ec-canvas> |
|||
</view> |
|||
</view> |
|||
|
|||
<view class="card"> |
|||
<view class="flex flex-between"> |
|||
<!-- <image src="" class="card-img" /> --> |
|||
<view class="flex"> |
|||
<view class="card-img" style="background: blue;"></view> |
|||
<view class="card-title">故障排行榜</view> |
|||
</view> |
|||
<view class="card-link">查看详情 ></view> |
|||
</view> |
|||
<view>【故障次数统计】</view> |
|||
<view class="list" wx:for="{{list}}"> |
|||
<view class="list-title">设备{{item}}</view> |
|||
</view> |
|||
</view> |
|||
</view> |
@ -0,0 +1,76 @@ |
|||
/* package/riskManagement/riskManagement.wxss */ |
|||
.risk-management { |
|||
height: 100vh; |
|||
background-image: linear-gradient(179deg, #006BE3 0%, #4E87FF 16%, #4e87ff00 93%); |
|||
padding: 0 15px; |
|||
} |
|||
|
|||
.icon { |
|||
width: 61px; |
|||
height: 31.86px; |
|||
background-image: linear-gradient(0deg, #EAF2FF 5%, #2578F0 100%); |
|||
box-shadow: 0 3px 4px 1px #bfdbfa4f; |
|||
} |
|||
|
|||
.icon-text { |
|||
width: 48px; |
|||
height: 17px; |
|||
font-family: PingFangSC-Medium; |
|||
font-weight: 500; |
|||
font-size: 12px; |
|||
color: #FFFFFF; |
|||
} |
|||
|
|||
.title-item { |
|||
width: 150px; |
|||
color: #ffffffd9; |
|||
} |
|||
|
|||
.title-num { |
|||
font-size: 20px; |
|||
color: #FFFFFF; |
|||
} |
|||
|
|||
.title-unit { |
|||
font-size: 10px; |
|||
color: #FFFFFE; |
|||
margin-left: 10px; |
|||
} |
|||
|
|||
.card { |
|||
background: #FFFFFF; |
|||
box-shadow: 2px 2px 11px 0 #00000008, 0 0 4px 0 #00000012; |
|||
border-radius: 4px; |
|||
padding: 12px; |
|||
margin-top: 12px; |
|||
} |
|||
|
|||
.card-img { |
|||
width: 18px; |
|||
height: 18px; |
|||
margin-right: 13px; |
|||
} |
|||
|
|||
.card-title { |
|||
font-weight: 500; |
|||
font-size: 16px; |
|||
color: #383A3B; |
|||
} |
|||
|
|||
.card-link { |
|||
font-weight: 500; |
|||
font-size: 14px; |
|||
color: #1684FF; |
|||
} |
|||
|
|||
.chart { |
|||
width: 100%; |
|||
height: 195px; |
|||
margin-top: 20px; |
|||
} |
|||
|
|||
.list { |
|||
margin-top: 10px; |
|||
padding: 10px 7px; |
|||
background-color: #F1F7FF; |
|||
} |
@ -0,0 +1,242 @@ |
|||
// package/subSystem/subSystem.js
|
|||
import * as echarts from '../components/ec-canvas/echarts'; |
|||
import { |
|||
getSubSystemPatrolAbout |
|||
} from "../../utils/getApiUrl"; |
|||
import { |
|||
Request |
|||
} from "../../common"; |
|||
const moment = require("../../utils/moment"); |
|||
|
|||
|
|||
|
|||
Page({ |
|||
initECharts(option) { |
|||
this.ecComponent.init((canvas, width, height, dpr) => { |
|||
const chart = echarts.init(canvas, null, { |
|||
width: width, |
|||
height: height, |
|||
devicePixelRatio: dpr, |
|||
}); |
|||
// 设置图表的配置
|
|||
chart.setOption(option); |
|||
|
|||
// 将 ECharts 实例保存在数据中
|
|||
this.chart = chart; |
|||
|
|||
// 返回 ECharts 实例
|
|||
return chart; |
|||
}); |
|||
}, |
|||
/** |
|||
* 页面的初始数据 |
|||
*/ |
|||
data: { |
|||
ec: { |
|||
// lazyLoad: true, // 延迟加载 ECharts
|
|||
}, |
|||
date: '', |
|||
show: true, |
|||
currentPatrolCount: 0, //当月巡检次数
|
|||
currentRepairCount: 0, //当月维修次数
|
|||
level1Count: 0, //轻微
|
|||
level2Count: 0, //中度
|
|||
level3Count: 0, //严重
|
|||
selectedDate: new Date(), // 设置默认选中的日期为当前日期
|
|||
formatter(day) { |
|||
|
|||
return day; |
|||
}, |
|||
|
|||
}, |
|||
|
|||
onDisplay() { |
|||
this.setData({ |
|||
show: true |
|||
}); |
|||
}, |
|||
onClose() { |
|||
this.setData({ |
|||
show: false |
|||
}); |
|||
}, |
|||
|
|||
onConfirm(event) { |
|||
this.setData({ |
|||
show: false, |
|||
date: this.formatDate(event.detail), |
|||
}); |
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面加载 |
|||
*/ |
|||
onLoad: function (options) { |
|||
const {windowHeight}=wx.getSystemInfoSync() |
|||
const pageHeight=windowHeight - 48 |
|||
const that=this |
|||
wx.showLoading({ |
|||
title: '加载中' |
|||
}) |
|||
// const that = this;
|
|||
wx.setNavigationBarTitle({ |
|||
title: options.key, |
|||
}); |
|||
//加载初始化数据
|
|||
that.getSubSystemPatrolAbout(options) |
|||
//初始化图表的配置项
|
|||
// 其他渲染逻辑
|
|||
// 创建一个 Date 对象来获取当前日期
|
|||
const currentDate = new Date(); |
|||
// 获取当前年份
|
|||
const currentYear = currentDate.getFullYear(); |
|||
// 获取当前月份(注意,月份是从 0 到 11 表示,所以需要加 1)
|
|||
const currentMonth = currentDate.getMonth() + 1; |
|||
// 获取当前月份的第一天和最后一天
|
|||
const nextMonth = new Date().getMonth() + 1; |
|||
const firstDay = new Date().setDate(1); |
|||
const lastDay = new Date().setMonth(nextMonth, 1) - 86400000; |
|||
// 更新数据,将年份和月份传递给 WXML 页面
|
|||
that.setData({ |
|||
currentYear: currentYear, |
|||
currentMonth: currentMonth, |
|||
lastDay: lastDay, |
|||
firstDay: firstDay, |
|||
pageHeight:pageHeight+'px' |
|||
}); |
|||
|
|||
|
|||
wx.hideLoading() |
|||
|
|||
}, |
|||
//过滤轻微,中度,重度的巡检个数
|
|||
filterLevelCount:function(list,level){ |
|||
return list?.filter(i => { |
|||
const content = i?.points?.inspectContent |
|||
if (content) { |
|||
for (let key in content) { |
|||
if (content.hasOwnProperty(key)) { |
|||
const subObject = content[key]; |
|||
return subObject.level===level |
|||
} |
|||
} |
|||
} |
|||
})?.length |
|||
}, |
|||
getSubSystemPatrolAbout: function (options) { |
|||
let that = this; |
|||
//当月开始时间
|
|||
const STime = moment().startOf('month').format('YYYY-MM-DD') |
|||
//当月结束时间
|
|||
const ETime = moment().endOf('month').format('YYYY-MM-DD') |
|||
//子系统关键字
|
|||
let keywords = options.key |
|||
// keywords = '管廊'
|
|||
const query = { |
|||
STime, |
|||
ETime, |
|||
keywords |
|||
} |
|||
Request.get(getSubSystemPatrolAbout(query)).then(res => { |
|||
if (res) { |
|||
//巡查内容
|
|||
that.setData({ |
|||
currentRepairCount: res?.filter(i => i?.patrolRecordIssueHandles[0]?.yanshoushijian && parseInt(moment(i?.patrolRecordIssueHandles[0]?.yanshoushijian).format('YYYYMMDD')) === parseInt(moment().format('YYYYMMDD'))).length || 0, |
|||
currentPatrolCount: res.length, |
|||
level1Count: that.filterLevelCount(res,'轻微')||0, |
|||
level2Count: that.filterLevelCount(res,'中度')||0, |
|||
level3Count: that.filterLevelCount(res,'严重')||0, |
|||
formatter:function(e){ |
|||
res?.map(i=>{ |
|||
if(moment(i.inspectionTime).format('YYYY-MM-DD')==moment(e.date).format('YYYY-MM-DD')){ |
|||
if( i.patrolRecordIssueHandles.length==0){ |
|||
e.bottomInfo = '.';e.className = 'greenClass' |
|||
}else if( i.patrolRecordIssueHandles.length&& i?.patrolRecordIssueHandles[0]?.yanshoushijian && parseInt(moment(i?.patrolRecordIssueHandles[0]?.yanshoushijian).format('YYYYMMDD')) === parseInt(moment().format('YYYYMMDD'))){ |
|||
e.bottomInfo = '.';e.className = 'yellowClass' |
|||
} |
|||
} |
|||
}) |
|||
return e |
|||
} |
|||
}) |
|||
that.ecComponent = that.selectComponent('#mychart-dom-pie'); |
|||
console.log('that.level1Count',this.data.level2Count) |
|||
var option = { |
|||
backgroundColor: "#ffffff", |
|||
legend: { |
|||
bottom: 10, |
|||
left: 'center', |
|||
}, |
|||
series: [{ |
|||
label: { |
|||
normal: { |
|||
fontSize: 14 |
|||
} |
|||
}, |
|||
type: 'pie', |
|||
center: ['50%', '50%'], |
|||
radius: ['20%', '40%'], |
|||
data:[ {name:'轻微',value:that.data.level1Count}, |
|||
{name:'中度',value:that.data.level2Count}, |
|||
{name:'重度',value:that.data.level3Count}] |
|||
}] |
|||
}; |
|||
that.initECharts(option); |
|||
|
|||
wx.hideLoading() |
|||
} else { |
|||
wx.hideLoading(); |
|||
} |
|||
}) |
|||
}, |
|||
/** |
|||
* 生命周期函数--监听页面初次渲染完成 |
|||
*/ |
|||
|
|||
onReady() { |
|||
|
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面显示 |
|||
*/ |
|||
onShow() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面隐藏 |
|||
*/ |
|||
onHide() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面卸载 |
|||
*/ |
|||
onUnload() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面相关事件处理函数--监听用户下拉动作 |
|||
*/ |
|||
onPullDownRefresh() { |
|||
getSubSystemPatrolAbout() |
|||
}, |
|||
|
|||
/** |
|||
* 页面上拉触底事件的处理函数 |
|||
*/ |
|||
onReachBottom() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 用户点击右上角分享 |
|||
*/ |
|||
onShareAppMessage() { |
|||
|
|||
} |
|||
}) |
@ -0,0 +1,8 @@ |
|||
{ |
|||
|
|||
"usingComponents": { |
|||
"ec-canvas": "../components/ec-canvas/ec-canvas", |
|||
"van-calendar": "@vant/weapp/calendar/index" |
|||
|
|||
} |
|||
} |
@ -0,0 +1,35 @@ |
|||
<!--package/subSystem/subSystem.wxml--> |
|||
<!--总览图--> |
|||
<view style="display: flex;justify-content: space-around;margin-bottom: 10px; padding-top: 10px; background-image: linear-gradient(179deg, #006BE3 0%, #4E87FF 16%, #4e87ff00 93%);"> |
|||
<view> |
|||
<view>本月巡检次数</view> |
|||
<view class="number">{{currentPatrolCount}}</view> |
|||
</view> |
|||
<view> |
|||
<view>本月维修次数</view> |
|||
<view class="number">{{currentRepairCount}}</view> |
|||
</view> |
|||
</view> |
|||
<!--饼图--> |
|||
<view class="card" > |
|||
<ec-canvas id="mychart-dom-pie" canvas-id="mychart-pie" ec="{{ ec }}"></ec-canvas> |
|||
</view> |
|||
<!--巡检日历--> |
|||
<view class="card heightStyle"> |
|||
<view class="header"> |
|||
<view class="xunjian">巡检日历</view> |
|||
<view class="yearMonth">{{currentYear+'年'+currentMonth+'月'}}</view> |
|||
</view> |
|||
<van-calendar |
|||
max-date="{{lastDay}}" |
|||
v-model="selectedDate" |
|||
readonly |
|||
show-title="{{false}}" |
|||
show-subtitle="{{false}}" |
|||
poppable="{{ false }}" |
|||
show-confirm="{{ false }}" |
|||
default-date="{{selectedDate}}" |
|||
formatter="{{formatter}}" |
|||
color="#0000FF" |
|||
class="calendar" /> |
|||
</view> |
@ -0,0 +1,70 @@ |
|||
/* package/subSystem/subSystem.wxss */ |
|||
.number{ |
|||
width: 40px; |
|||
height: 26px; |
|||
font-family: D-DINExp; |
|||
font-weight: DINExp; |
|||
font-size: 24px; |
|||
color: #FFFFFF; |
|||
letter-spacing: 0; |
|||
} |
|||
|
|||
.card { |
|||
font-family: PingFangSC-Medium; |
|||
font-weight: 500; |
|||
font-size: 16px; |
|||
color: #333333; |
|||
background-color: #fff; |
|||
border: 1px solid #ddd; |
|||
border-radius: 8px; |
|||
/* padding: 10px 10px; */ |
|||
margin: 5px 5px; |
|||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); |
|||
/* width: 300px; */ |
|||
height: 300px; |
|||
} |
|||
.heightStyle{ |
|||
height: auto; |
|||
} |
|||
|
|||
.xunjian{ |
|||
width: 64px; |
|||
height: 22px; |
|||
font-family: PingFangSC-Medium; |
|||
font-weight: 500; |
|||
font-size: 16px; |
|||
color: #000000d9; |
|||
letter-spacing: 0; |
|||
} |
|||
.yearMonth{ |
|||
width: 85px; |
|||
height: 20px; |
|||
font-family: PingFangSC-Medium; |
|||
font-weight: 500; |
|||
font-size: 14px; |
|||
color: #1684FF; |
|||
letter-spacing: 0; |
|||
text-align: right; |
|||
} |
|||
.header{ |
|||
display: flex; |
|||
justify-content: space-around; |
|||
margin-bottom: 10px; |
|||
margin-top:10px; |
|||
} |
|||
|
|||
.yellowClass .van-calendar__bottom-info{ |
|||
font-size: 50px; |
|||
color:yellow; |
|||
|
|||
} |
|||
.greenClass .van-calendar__bottom-info{ |
|||
font-size: 50px; |
|||
color:green; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
@ -1,66 +1,179 @@ |
|||
// pages/home/home.js
|
|||
Page({ |
|||
|
|||
/** |
|||
* 页面的初始数据 |
|||
*/ |
|||
data: { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面加载 |
|||
*/ |
|||
onLoad(options) { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面初次渲染完成 |
|||
*/ |
|||
onReady() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面显示 |
|||
*/ |
|||
onShow() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面隐藏 |
|||
*/ |
|||
onHide() { |
|||
import { getPatrolRecord } from "../../utils/getApiUrl"; |
|||
import { Request } from "../../common"; |
|||
const moment = require("../../utils/moment"); |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面卸载 |
|||
*/ |
|||
onUnload() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面相关事件处理函数--监听用户下拉动作 |
|||
*/ |
|||
onPullDownRefresh() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面上拉触底事件的处理函数 |
|||
*/ |
|||
onReachBottom() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 用户点击右上角分享 |
|||
*/ |
|||
onShareAppMessage() { |
|||
|
|||
} |
|||
Page({ |
|||
jumpToSubSystem (options) { |
|||
const key = options.currentTarget.dataset.key; |
|||
wx.navigateTo({ |
|||
url: `/package/subSystem/subSystem?key=${key}`, |
|||
}) |
|||
}, |
|||
/** |
|||
* 页面的初始数据 |
|||
*/ |
|||
data: { |
|||
sevenDaysCount:0,//过去七天的巡检次数
|
|||
sevenDaysQuestionCount:0,//过去七天发现问题个数
|
|||
sevenDaysHandleCount:0,//过去七天问题解决个数
|
|||
allCount:0,//总的巡检次数
|
|||
allQuestionCount:0,//总的发现问题个数
|
|||
allHandleCount:0,//总的问题解决个数
|
|||
todayRecord: [], // 今日巡检记录
|
|||
markers: [], |
|||
pageHeight:0,//屏幕高度
|
|||
isShowCallout: false, |
|||
itemList:[{ |
|||
picPath:'/images/conduct.png', |
|||
itemName:'指挥中心' |
|||
}, |
|||
{ |
|||
picPath:'/images/waterSupply.png', |
|||
itemName:'给水仓' |
|||
}, |
|||
{ |
|||
picPath:'/images/pipeGallery.png', |
|||
itemName:'管廊本体' |
|||
}, |
|||
{ |
|||
picPath:'/images/elevator.png', |
|||
itemName:'电梯系统' |
|||
}, |
|||
{ |
|||
picPath:'/images/power.png', |
|||
itemName:'供配电系统' |
|||
}, |
|||
{ |
|||
picPath:'/images/gas.png', |
|||
itemName:'燃气仓' |
|||
}, |
|||
{ |
|||
picPath:'/images/security.png', |
|||
itemName:'安防系统' |
|||
}, |
|||
{ |
|||
picPath:'/images/highTension.png', |
|||
itemName:'高压电力仓' |
|||
}, |
|||
{ |
|||
picPath:'/images/electricalStorageRoom.png', |
|||
itemName:'电气仓' |
|||
}, |
|||
{ |
|||
picPath:'/images/lightningProtection.png', |
|||
itemName:'防雷与接地' |
|||
} |
|||
|
|||
], |
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面加载 |
|||
*/ |
|||
onLoad (options) { |
|||
const userInfo=wx.getStorageSync('userInfo'); |
|||
const {windowHeight}=wx.getSystemInfoSync() |
|||
const pageHeight=windowHeight - 48 |
|||
const promiseArr = []; |
|||
const that = this; |
|||
var data = { |
|||
"datas": [ |
|||
{ |
|||
"id": 1, |
|||
"imgurl": "/images/avatar.png" |
|||
}, |
|||
{ |
|||
"id": 2, |
|||
"imgurl": "/images/card_bg.png" |
|||
} |
|||
] |
|||
}; |
|||
wx.showLoading({ title: '加载中' }) |
|||
promiseArr.push(Request.get(getPatrolRecord('all', moment('1970-1-1').format('YYYY-MM-DD') + ' 00:00:00', moment('2099-12-31').format('YYYY-MM-DD') + ' 23:59:59', 'null', 'null'))); |
|||
Promise.all(promiseArr).then(res => { |
|||
wx.hideLoading() |
|||
//与自己相关的所有巡检记录
|
|||
const list=res[0]?.filter(item=>item?.points?.user.id===userInfo.id)||[] |
|||
//过去七天的所有巡检记录
|
|||
const sevenDaysList=list?.filter(item=> |
|||
{ |
|||
const recordDate = moment(date, 'YYYY-MM-DD'); // 解析日期
|
|||
const daysDifference = moment().diff(recordDate, 'days'); // 计算日期差
|
|||
// 返回近七天内的记录
|
|||
return daysDifference >= 0 && daysDifference < 7; |
|||
} |
|||
)||[] |
|||
that.setData({ |
|||
allCount:list.length || 0, |
|||
allQuestionCount:list?.filter(i=>i.patrolRecordIssueHandles>0)?.length || 0, |
|||
allHandleCount:list?.filter(i => i?.patrolRecordIssueHandles[0]?.yanshoushijian && parseInt(moment(i?.patrolRecordIssueHandles[0]?.yanshoushijian).format('YYYYMMDD')) === parseInt(moment().format('YYYYMMDD'))).length || 0, |
|||
sevenDaysCount:sevenDaysList.length||0, |
|||
sevenDaysQuestionCount:sevenDaysList?.filter(i=>i.patrolRecordIssueHandles>0)?.length || 0, |
|||
sevenDaysHandleCount:sevenDaysList?.filter(i => i?.patrolRecordIssueHandles[0]?.yanshoushijian && parseInt(moment(i?.patrolRecordIssueHandles[0]?.yanshoushijian).format('YYYYMMDD')) === parseInt(moment().format('YYYYMMDD'))).length || 0, |
|||
pageHeight:pageHeight+'px', |
|||
swiperData:data.datas |
|||
}) |
|||
}) |
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面初次渲染完成 |
|||
*/ |
|||
onReady () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面显示 |
|||
*/ |
|||
onShow () { |
|||
const userInfo = wx.getStorageSync('userInfo'); |
|||
if (!userInfo || !userInfo.id) { |
|||
wx.reLaunch({ |
|||
url: '/pages/login/login' |
|||
}); |
|||
} else { |
|||
if (typeof this.getTabBar === 'function' && this.getTabBar()) { |
|||
this.getTabBar().setData({ |
|||
selected: 0 |
|||
}) |
|||
} |
|||
} |
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面隐藏 |
|||
*/ |
|||
onHide () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面卸载 |
|||
*/ |
|||
onUnload () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面相关事件处理函数--监听用户下拉动作 |
|||
*/ |
|||
onPullDownRefresh () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面上拉触底事件的处理函数 |
|||
*/ |
|||
onReachBottom () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 用户点击右上角分享 |
|||
*/ |
|||
onShareAppMessage () { |
|||
|
|||
} |
|||
}) |
@ -1,5 +1,58 @@ |
|||
<!--pages/home/home.wxml--> |
|||
<view> |
|||
<image src="/images/email.svg" /> |
|||
</view> |
|||
<text>pages/home/home.wxml</text> |
|||
<view style="height:{{pageHeight}} ; overflow: auto;"> |
|||
<!--轮播图--> |
|||
<view class="card"> |
|||
<swiper class="home-swiper" indicator-dots="true" autoplay="{{true}}" interval="{{2000}}" duration="{{500}}"> |
|||
<block wx:for-items="{{swiperData}}"> |
|||
<swiper-item> |
|||
<image src="{{item.imgurl}}" class="slide-image" /> |
|||
</swiper-item> |
|||
</block> |
|||
</swiper> |
|||
</view> |
|||
<!--子系统列表--> |
|||
<view class="list card" style="display: flex; flex-wrap: wrap;"> |
|||
<view style="min-width: 25%; margin: 10px 0px;text-align: center;" wx:for="{{itemList}}" wx:for-item="item" wx:key="*this" data-key="{{item.itemName}}" bindtap="jumpToSubSystem"> |
|||
<image src="{{item.picPath}}" style="width: 29.97px;height: 28.93px;" /> |
|||
<view>{{item.itemName}}</view> |
|||
</view> |
|||
</view> |
|||
<!--最近7天统计--> |
|||
<view class="card"> |
|||
最近7天统计 |
|||
<view style="background-image:url('/images/sevenDays.png');width: 100%; height: 99px; background-repeat: no-repeat;display: flex"> |
|||
<view> |
|||
<image src="/images/check.png" style="width:36px;height:36px;margin:40px 10px 20px 10px" /> |
|||
</view> |
|||
<view style="margin:40px 10px 20px 10px"> |
|||
<view>巡检次数</view> |
|||
<view>{{sevenDaysCount}}次</view> |
|||
</view> |
|||
</view> |
|||
<view style="display: flex; justify-content: space-around;"> |
|||
<view style="margin:10px 0px;">发现问题个数</view> |
|||
<view style="margin:10px 0px;">{{sevenDaysQuestionCount}}个</view> |
|||
<view style="margin:10px 0px;">问题处理个数</view> |
|||
<view style="margin:10px 0px;">{{sevenDaysHandleCount}}个</view> |
|||
</view> |
|||
</view> |
|||
<!--总巡巡检统计--> |
|||
<view class="card"> |
|||
总巡巡检统计 |
|||
<view style="background-image:url('/images/xunjian.png');width: 100%; height: 99px; background-repeat: no-repeat;display: flex;"> |
|||
<view> |
|||
<image src="/images/check.png" style="width:36px;height:36px;margin:40px 10px 20px 10px" /> |
|||
</view> |
|||
<view style="margin:40px 10px 20px 10px"> |
|||
<view>巡检次数</view> |
|||
<view>{{allCount}}次</view> |
|||
</view> |
|||
</view> |
|||
<view style="display: flex; justify-content: space-around;"> |
|||
<view style="margin:10px 0px;">发现问题个数</view> |
|||
<view style="margin:10px 0px;">{{allQuestionCount}}个</view> |
|||
<view style="margin:10px 0px;">问题处理个数</view> |
|||
<view style="margin:10px 0px;">{{allHandleCount}}个</view> |
|||
</view> |
|||
</view> |
|||
</view> |
@ -1 +1,25 @@ |
|||
/* pages/home/home.wxss */ |
|||
/* pages/home/home.wxss */ |
|||
.list { |
|||
font-family: PingFangSC-Regular; |
|||
font-weight: 400; |
|||
font-size: 12px; |
|||
color: #333333; |
|||
letter-spacing: 0; |
|||
} |
|||
.card { |
|||
background-color: #fff; |
|||
border: 1px solid #ddd; |
|||
border-radius: 8px; |
|||
/* padding: 10px; */ |
|||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); |
|||
margin: 10px; |
|||
} |
|||
.home-swiper { |
|||
width: 95%; |
|||
/* height: 360rpx; */ |
|||
} |
|||
|
|||
/* .slide-image { |
|||
width: 100%; |
|||
height: 100%; |
|||
} */ |
@ -1,175 +1,176 @@ |
|||
/* pages/myInfo/myInfo.wxss */ |
|||
|
|||
page { |
|||
background-color: #F7F7FA; |
|||
background-color: #F7F7FA; |
|||
} |
|||
|
|||
.over-ellipsis { |
|||
text-overflow: ellipsis; |
|||
overflow: hidden; |
|||
word-break: break-all; |
|||
white-space: nowrap; |
|||
text-overflow: ellipsis; |
|||
overflow: hidden; |
|||
word-break: break-all; |
|||
white-space: nowrap; |
|||
} |
|||
|
|||
.bg { |
|||
position: absolute; |
|||
left: -25%; |
|||
width: 150%; |
|||
height: 145px; |
|||
background-color: #1979ff; |
|||
border-bottom-left-radius: 100%; |
|||
border-bottom-right-radius: 100%; |
|||
background-image: linear-gradient(0deg, #4E87FF, #1979ff 100%); |
|||
z-index: -1; |
|||
position: absolute; |
|||
left: -25%; |
|||
width: 150%; |
|||
height: 145px; |
|||
background-color: #1979ff; |
|||
border-bottom-left-radius: 100%; |
|||
border-bottom-right-radius: 100%; |
|||
background-image: linear-gradient(0deg, #4E87FF, #1979ff 100%); |
|||
z-index: -1; |
|||
} |
|||
|
|||
/* 容器 */ |
|||
.box { |
|||
padding: 30rpx; |
|||
font-family: 'PingFang SC-Medium'; |
|||
padding-top: 42rpx; |
|||
padding: 30rpx; |
|||
font-family: 'PingFang SC-Medium'; |
|||
} |
|||
|
|||
.header-item-container { |
|||
width: 100%; |
|||
height: 165px; |
|||
border-radius: 10rpx; |
|||
background-size: 100% 165px; |
|||
width: 100%; |
|||
height: 165px; |
|||
border-radius: 10rpx; |
|||
background-size: 100% 165px; |
|||
} |
|||
|
|||
.info-box { |
|||
width: 100%; |
|||
height: 127px; |
|||
display: flex; |
|||
justify-content: space-between; |
|||
width: 100%; |
|||
height: 127px; |
|||
display: flex; |
|||
justify-content: space-between; |
|||
} |
|||
|
|||
.avatar { |
|||
width: 54px; |
|||
min-width: 54px; |
|||
height: 54px; |
|||
padding: 16px; |
|||
margin-bottom: 30px; |
|||
width: 54px; |
|||
min-width: 54px; |
|||
height: 54px; |
|||
padding: 16px; |
|||
margin-bottom: 30px; |
|||
} |
|||
|
|||
.info { |
|||
height: 100%; |
|||
min-width: 55%; |
|||
max-width: 60%; |
|||
display: flex; |
|||
flex-direction: column; |
|||
justify-content: space-evenly; |
|||
height: 100%; |
|||
min-width: 55%; |
|||
max-width: 60%; |
|||
display: flex; |
|||
flex-direction: column; |
|||
justify-content: space-evenly; |
|||
} |
|||
|
|||
.userName { |
|||
font-size: 36rpx; |
|||
font-weight: 600; |
|||
font-size: 36rpx; |
|||
font-weight: 600; |
|||
} |
|||
|
|||
.contact { |
|||
display: flex; |
|||
align-items: center; |
|||
min-width: 190px; |
|||
display: flex; |
|||
align-items: center; |
|||
min-width: 190px; |
|||
} |
|||
|
|||
.contact .icon { |
|||
width: 20px; |
|||
min-width: 20px; |
|||
height: 20px; |
|||
width: 20px; |
|||
min-width: 20px; |
|||
height: 20px; |
|||
} |
|||
|
|||
.contact .text { |
|||
min-width: 170px; |
|||
margin-left: 8px; |
|||
font-size: 14px; |
|||
color: #00000080; |
|||
min-width: 170px; |
|||
margin-left: 8px; |
|||
font-size: 14px; |
|||
color: #00000080; |
|||
} |
|||
|
|||
.post { |
|||
border: 1px solid #006BE3; |
|||
border-radius: 100px 0 0 100px; |
|||
min-width: 30px; |
|||
max-width: 60px; |
|||
height: 25px; |
|||
line-height: 25px; |
|||
color: #006BE3; |
|||
font-size: 14px; |
|||
padding: 0 7px; |
|||
margin-top: 20px; |
|||
border: 1px solid #006BE3; |
|||
border-radius: 100px 0 0 100px; |
|||
min-width: 30px; |
|||
max-width: 60px; |
|||
height: 25px; |
|||
line-height: 25px; |
|||
color: #006BE3; |
|||
font-size: 14px; |
|||
padding: 0 7px; |
|||
margin-top: 20px; |
|||
} |
|||
|
|||
.dept-box { |
|||
height: 36px; |
|||
display: flex; |
|||
align-items: center; |
|||
justify-content: flex-end; |
|||
height: 36px; |
|||
display: flex; |
|||
align-items: center; |
|||
justify-content: flex-end; |
|||
} |
|||
|
|||
.dept-box .dept { |
|||
font-size: 14px; |
|||
color: #FFFFFF; |
|||
margin-right: 10px; |
|||
font-size: 14px; |
|||
color: #FFFFFF; |
|||
margin-right: 10px; |
|||
} |
|||
|
|||
.company { |
|||
font-size: 28rpx; |
|||
font-family: "PingFang SC"; |
|||
color: rgb(138, 138, 138); |
|||
margin-top: 14rpx; |
|||
font-size: 28rpx; |
|||
font-family: "PingFang SC"; |
|||
color: rgb(138, 138, 138); |
|||
margin-top: 14rpx; |
|||
} |
|||
|
|||
.body-container { |
|||
width: 100%; |
|||
background: rgb(255, 255, 255); |
|||
border-radius: 10rpx; |
|||
flex-direction: column; |
|||
display: flex; |
|||
margin-top: 30rpx; |
|||
margin-bottom: 30rpx; |
|||
width: 100%; |
|||
background: rgb(255, 255, 255); |
|||
border-radius: 10rpx; |
|||
flex-direction: column; |
|||
display: flex; |
|||
margin-top: 30rpx; |
|||
margin-bottom: 30rpx; |
|||
} |
|||
|
|||
.body-item { |
|||
height: 110rpx; |
|||
flex-direction: row; |
|||
display: flex; |
|||
justify-content: space-between; |
|||
align-items: center; |
|||
padding: 0 30rpx; |
|||
border-bottom: 1px solid #EFEFF4; |
|||
height: 110rpx; |
|||
flex-direction: row; |
|||
display: flex; |
|||
justify-content: space-between; |
|||
align-items: center; |
|||
padding: 0 30rpx; |
|||
border-bottom: 1px solid #EFEFF4; |
|||
} |
|||
|
|||
.body-info { |
|||
font-size: 32rpx; |
|||
font-family: "PingFang SC"; |
|||
font-weight: 600; |
|||
font-size: 32rpx; |
|||
font-family: "PingFang SC"; |
|||
font-weight: 600; |
|||
} |
|||
|
|||
.body-number { |
|||
font-size: 30rpx; |
|||
font-family: "PingFang SC"; |
|||
color: rgb(138, 138, 138); |
|||
font-size: 30rpx; |
|||
font-family: "PingFang SC"; |
|||
color: rgb(138, 138, 138); |
|||
} |
|||
|
|||
.foot-container { |
|||
position: absolute; |
|||
bottom: 50px; |
|||
width: 90%; |
|||
height: 42px; |
|||
border: 1px solid #006BE3; |
|||
border-radius: 24px; |
|||
position: absolute; |
|||
bottom: 140px; |
|||
width: 90%; |
|||
height: 42px; |
|||
border: 1px solid #006BE3; |
|||
border-radius: 24px; |
|||
} |
|||
|
|||
.foot-item { |
|||
font-weight: 600; |
|||
font-size: 16px; |
|||
color: #006BE3; |
|||
text-align: center; |
|||
line-height: 42px; |
|||
font-weight: 600; |
|||
font-size: 16px; |
|||
color: #006BE3; |
|||
text-align: center; |
|||
line-height: 42px; |
|||
} |
|||
|
|||
.right { |
|||
width: 32rpx; |
|||
height: 32rpx; |
|||
display: block; |
|||
float: right; |
|||
margin: 38rpx 40rpx; |
|||
width: 32rpx; |
|||
height: 32rpx; |
|||
display: block; |
|||
float: right; |
|||
margin: 38rpx 40rpx; |
|||
} |
@ -1,85 +1,89 @@ |
|||
// pages/overview/overview.js
|
|||
Page({ |
|||
|
|||
/** |
|||
* 页面的初始数据 |
|||
*/ |
|||
data: { |
|||
|
|||
}, |
|||
|
|||
// 巡检
|
|||
bindPolling() { |
|||
wx.navigateTo({ |
|||
url: '/package/polling/polling', |
|||
}) |
|||
}, |
|||
|
|||
bindTroubleshooting() { |
|||
wx.navigateTo({ |
|||
url: '/package/troubleshooting/index', |
|||
}) |
|||
}, |
|||
|
|||
bindInspectionReport() { |
|||
wx.navigateTo({ |
|||
url: '/package/inspectionReport/inspectionReport', |
|||
}) |
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面加载 |
|||
*/ |
|||
onLoad(options) { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面初次渲染完成 |
|||
*/ |
|||
onReady() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面显示 |
|||
*/ |
|||
onShow() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面隐藏 |
|||
*/ |
|||
onHide() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面卸载 |
|||
*/ |
|||
onUnload() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面相关事件处理函数--监听用户下拉动作 |
|||
*/ |
|||
onPullDownRefresh() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面上拉触底事件的处理函数 |
|||
*/ |
|||
onReachBottom() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 用户点击右上角分享 |
|||
*/ |
|||
onShareAppMessage() { |
|||
|
|||
} |
|||
/** |
|||
* 页面的初始数据 |
|||
*/ |
|||
data: { |
|||
|
|||
}, |
|||
|
|||
// 巡检
|
|||
bindPolling () { |
|||
wx.navigateTo({ |
|||
url: '/package/polling/polling', |
|||
}) |
|||
}, |
|||
|
|||
bindTroubleshooting () { |
|||
wx.navigateTo({ |
|||
url: '/package/troubleshooting/index', |
|||
}) |
|||
}, |
|||
|
|||
bindInspectionReport () { |
|||
wx.navigateTo({ |
|||
url: '/package/inspectionReport/inspectionReport', |
|||
}) |
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面加载 |
|||
*/ |
|||
onLoad (options) { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面初次渲染完成 |
|||
*/ |
|||
onReady () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面显示 |
|||
*/ |
|||
onShow () { |
|||
if (typeof this.getTabBar === 'function' && this.getTabBar()) { |
|||
this.getTabBar().setData({ |
|||
selected: 1 |
|||
}) |
|||
} |
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面隐藏 |
|||
*/ |
|||
onHide () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面卸载 |
|||
*/ |
|||
onUnload () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面相关事件处理函数--监听用户下拉动作 |
|||
*/ |
|||
onPullDownRefresh () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面上拉触底事件的处理函数 |
|||
*/ |
|||
onReachBottom () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 用户点击右上角分享 |
|||
*/ |
|||
onShareAppMessage () { |
|||
|
|||
} |
|||
}) |
@ -0,0 +1,107 @@ |
|||
// pages/workbench/workbench.js
|
|||
Page({ |
|||
|
|||
/** |
|||
* 页面的初始数据 |
|||
*/ |
|||
data: { |
|||
itemList: [ |
|||
{ |
|||
iconPath: '/images/workbench/report.png', |
|||
text: '故障及风险管理', |
|||
page: '/package/riskManagement/riskManagement' |
|||
}, |
|||
{ |
|||
iconPath: '/images/workbench/report.png', |
|||
text: '设备大数据图谱', |
|||
page: '/package/riskManagement/riskCalendar/riskCalendar' |
|||
}, |
|||
{ |
|||
iconPath: '/images/workbench/report.png', |
|||
text: '智能诊断', |
|||
page: '/package/riskManagement/riskManagement' |
|||
}, |
|||
{ |
|||
iconPath: '/images/workbench/expert_systems.png', |
|||
text: '专家系统', |
|||
page: '/package/riskManagement/riskManagement' |
|||
}, |
|||
{ |
|||
iconPath: '/images/workbench/report.png', |
|||
text: '巡检报告', |
|||
page: '/package/riskManagement/riskManagement' |
|||
}, |
|||
{ |
|||
iconPath: '/images/workbench/issues.png', |
|||
text: '发现问题', |
|||
page: '/package/riskManagement/riskManagement' |
|||
}, |
|||
] |
|||
}, |
|||
|
|||
navigator(e) { |
|||
wx.navigateTo({ |
|||
url: e.currentTarget.dataset.page, |
|||
}) |
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面加载 |
|||
*/ |
|||
onLoad(options) { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面初次渲染完成 |
|||
*/ |
|||
onReady() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面显示 |
|||
*/ |
|||
onShow() { |
|||
if (typeof this.getTabBar === 'function' && this.getTabBar()) { |
|||
this.getTabBar().setData({ |
|||
selected: 1 |
|||
}) |
|||
} |
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面隐藏 |
|||
*/ |
|||
onHide() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面卸载 |
|||
*/ |
|||
onUnload() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面相关事件处理函数--监听用户下拉动作 |
|||
*/ |
|||
onPullDownRefresh() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面上拉触底事件的处理函数 |
|||
*/ |
|||
onReachBottom() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 用户点击右上角分享 |
|||
*/ |
|||
onShareAppMessage() { |
|||
|
|||
} |
|||
}) |
@ -0,0 +1,6 @@ |
|||
{ |
|||
"navigationBarBackgroundColor": "#1979ff", |
|||
"navigationBarTextStyle": "white", |
|||
"navigationBarTitleText": "控制台", |
|||
"enablePullDownRefresh": false |
|||
} |
@ -0,0 +1,9 @@ |
|||
<!-- pages/workbench/workbench.wxml --> |
|||
<view class="workbench-page"> |
|||
<view class="workbench"> |
|||
<view class="workbench-item" wx:for="{{itemList}}" data-page="{{item.page}}" bindtap="navigator"> |
|||
<image src="{{item.iconPath}}" class="item-img" /> |
|||
<View class="item-text">{{item.text}}</View> |
|||
</view> |
|||
</view> |
|||
</view> |
@ -0,0 +1,33 @@ |
|||
/* pages/workbench/workbench.wxss */ |
|||
.workbench-page { |
|||
width: 100vw; |
|||
height: 100vh; |
|||
background-color: #EDF1F8; |
|||
} |
|||
|
|||
.workbench { |
|||
display: flex; |
|||
flex-wrap: wrap; |
|||
justify-content: space-evenly; |
|||
align-items: flex-start; |
|||
} |
|||
|
|||
.workbench-item { |
|||
width: 166px; |
|||
height: 138px; |
|||
background: #FFFFFF; |
|||
border-radius: 8px; |
|||
margin-top: 12px; |
|||
} |
|||
|
|||
.item-img { |
|||
width: 40px; |
|||
height: 40px; |
|||
margin: 16px 0px 44px 12px; |
|||
} |
|||
|
|||
.item-text { |
|||
font-size: 16px; |
|||
color: #333333; |
|||
margin-left: 12px; |
|||
} |