首页修改

This commit is contained in:
仲么了
2023-08-23 16:22:08 +08:00
parent cc63cda4e7
commit 79d6771aad
34 changed files with 788 additions and 403 deletions

View File

@@ -1,24 +1,24 @@
<template>
<Cn-page :loading="loading" noPadding>
<view slot="body" class="canneng-index">
<!-- <uni-nav-bar
<uni-nav-bar
rightWidth="300rpx"
leftWidth="300rpx"
dark
:fixed="true"
status-bar
background-color="#376cf3"
color="#fff"
@clickRight="openDrawer"
background-color="#fff"
color="#111"
@clickRight="selectEngineering"
>
<template slot="left">
<text style="font-size: 32rpx; font-weight: 500">灿能物联</text>
</template>
<template slot="right">
<text class="hide-txt mr5" style="font-size: 28rpx">{{ select.engineeringName }}</text>
<uni-icons type="bottom" size="16" color="#fff"></uni-icons>
<uni-icons type="bottom" size="16" color="#111"></uni-icons>
</template>
</uni-nav-bar> -->
</uni-nav-bar>
<view class="index">
<!-- 运维 -->
<YunWei :devCount="devCount" v-if="userInfo.authorities === 'operation_manager'"/>
@@ -34,15 +34,6 @@
<Device ref="device" :store="store"/>
</template>
</view>
<uni-drawer ref="showRight" mode="right" :mask-click="false">
<view>
<uni-indexed-list
:options="engineeringListFilter"
:showSelect="false"
@click="closeDrawer"
></uni-indexed-list>
</view>
</uni-drawer>
</view>
</Cn-page>
</template>
@@ -56,7 +47,6 @@ import Device from './comp/device.vue'
import list from '../../common/js/list'
import {getDevCount} from '../../common/api/device.js'
import {queryEngineering} from '@/common/api/engineering.js'
import {pinyin} from 'pinyin-pro'
export default {
mixins: [list],
@@ -78,56 +68,24 @@ export default {
engineeringId: '',
},
engineeringList: [],
drawer: false,
navTabHeight: 0
}
},
computed: {
engineeringListFilter() {
let result = []
this.engineeringList.forEach((item) => {
let arr = pinyin(item.name[0], {toneType: 'none', type: 'array'})
let letter = arr[0][0].toUpperCase()
console.log(letter)
let index = result.findIndex((item) => item.letter === letter)
if (index === -1) {
result.push({
letter,
data: [item.name],
})
} else {
result[index].data.push(item.name)
}
})
return result
},
},
methods: {
onNavigationBarButtonTap(e) {
console.log(e)
// e的返回格式为json对象{"text":"测试","index":0}
this.drawer = !this.drawer
if (this.drawer) {
this.openDrawer()
} else {
this.closeDrawer()
}
selectEngineering() {
uni.navigateTo({
url: '/pages/home/selectEngineering',
})
},
async init() {
let engineering = uni.getStorageSync('engineering')
let res = await queryEngineering()
this.engineeringList = res.data
uni.setStorageSync('engineeringList', this.engineeringList)
if (this.engineeringList.length === 0) {
console.log('没有工程')
uni.removeStorageSync(this.$cacheKey.engineering)
this.projectList = []
// 修改buttons
// #ifdef APP-PLUS
var webView = this.$mp.page.$getAppWebview()
// 修改buttons
webView.setTitleNViewButtonStyle(0, {
text: '请先创建工程',
})
// #endif
} else {
if (!engineering) {
uni.setStorageSync('engineering', res.data[0])
@@ -144,15 +102,11 @@ export default {
}
}
this.store.params.engineerId = this.select.engineeringId
// #ifdef APP-PLUS
var webView = this.$mp.page.$getAppWebview()
// 修改buttons
webView.setTitleNViewButtonStyle(0, {
text: this.select.engineeringName,
})
// #endif
this.getDevCount()
this.$refs.device && this.$refs.device.init()
console.log(this.$refs.device, 'this.$refs.device')
this.$nextTick(() => {
this.$refs.device && this.$refs.device.init()
})
}
},
getDevCount() {
@@ -169,90 +123,18 @@ export default {
console.log(this.devCount);
})
},
closeDrawer(e) {
if (!e) {
// #ifdef APP-PLUS
var webView = this.$mp.page.$getAppWebview()
// 修改buttons
webView.setTitleNViewButtonStyle(0, {
text: this.select.engineeringName
? this.select.engineeringName.length > 7
? this.select.engineeringName.substring(0, 7) + '...'
: this.select.engineeringName
: '请选择工程',
select: true,
})
// #endif
this.$refs.showRight.close()
return
}
console.log(e)
this.engineeringList.forEach((item) => {
if (item.name === e.item.name) {
uni.setStorageSync('engineering', item)
this.select.engineeringName = item.name
this.select.engineeringId = item.id
this.store.params.engineerId = item.id
// #ifdef APP-PLUS
var webView = this.$mp.page.$getAppWebview()
// 修改buttons
webView.setTitleNViewButtonStyle(0, {
text:
this.select.engineeringName.length > 7
? this.select.engineeringName.substring(0, 7) + '...'
: this.select.engineeringName,
select: true,
})
// #endif
}
})
this.$refs.device.select.projectName = ''
this.$refs.device.select.projectNameIndex = 0
this.getDevCount()
this.$refs.device.init()
this.$refs.showRight.close()
},
send() {
uni.createPushMessage({
title: '灿能',
content: '灿能推送',
success: function (res) {
console.log('推送成功')
},
fail: function (res) {
console.log('推送失败')
},
})
},
loadingChange(e) {
this.loading = e
},
openDrawer(item) {
if (this.engineeringList.length === 0) {
uni.navigateTo({
url: '/pages/engineering/new',
})
return
} else if (this.engineeringList.length === 1) {
uni.showToast({
title: '暂无其他工程',
icon: 'none',
})
return
}
// #ifdef APP-PLUS
var webView = this.$mp.page.$getAppWebview()
// 修改buttons
webView.setTitleNViewButtonStyle(0, {
text: '取消',
select: false,
})
// #endif
this.$refs.showRight.open()
},
},
onLoad() {
this.store = this.DataSource('/cs-device-boot/EquipmentDelivery/queryEquipmentByProject')
// #ifdef APP-PLUS
setTimeout(() => {
// 获取nav高度
uni.createSelectorQuery().select('.uni-navbar').boundingClientRect((rect) => {
this.navTabHeight = rect.height
console.log('calc(100vh - ' + this.navTabHeight + ')')
}).exec()
}, 1000)
// #endif
},
onShow() {
this.userInfo = uni.getStorageSync(this.$cacheKey.userInfo)
@@ -271,6 +153,10 @@ export default {
}
</script>
<style lang="scss">
.popup-content {
background: #fff;
}
.index {
padding: 20rpx 0 0;
}