消息推送

This commit is contained in:
仲么了
2023-09-13 16:40:03 +08:00
parent f8d8229cc1
commit f9bb466096
13 changed files with 204 additions and 154 deletions

View File

@@ -4,6 +4,9 @@ import {getImageUrl} from '@/common/api/basic'
export default {
onLaunch: function () {
// uni.onPushMessage((res) => {
// console.log("收到推送消息:",res) //监听推送消息
// })
console.log(window)
// this.connect()
console.log('App Launch')

View File

@@ -141,7 +141,7 @@ export function apiRebindPhone(params) {
}
// 角色升级
export function roleUpdate({ userId, referralCode }) {
export function roleUpdate({userId, referralCode}) {
return request({
url: '/user-boot/appRole/roleUpdate',
method: 'post',
@@ -207,15 +207,18 @@ export function apiUpdateUser(params) {
// 更新用户推送标识
export function apiUpdatePush(params) {
uni.getPushClientId((res) => {
let push_clientid = res.cid
request({
url: '/user-boot/appUser/updateDevCode',
data: {
devCode: push_clientid,
userId: uni.getStorageSync('userInfo').userIndex,
},
method: 'POST',
})
uni.getPushClientId({
success: (res) => {
let push_clientid = res.cid
console.log(push_clientid, 'push_clientid')
request({
url: '/user-boot/appUser/updateDevCode',
data: {
devCode: push_clientid,
userId: uni.getStorageSync('userInfo').userIndex,
},
method: 'POST',
})
}
})
}

View File

@@ -70,7 +70,7 @@
"push" : {
"unipush" : {
"version" : "2",
"offline" : false
"offline" : true
}
},
"share" : {}

View File

@@ -6,10 +6,10 @@
<view class="item item-title">名称</view>
<view class="item item-title">有效值(A)</view>
<view class="item item-title">THDI(%)</view>
<template v-for="(item, index) in renderData.电网">
<template v-for="(item, index) in renderData.电网电流">
<view class="item">{{ item.phase }}</view>
<view class="item">{{ item['Pq_RmsI(A)'] || '-' }}</view>
<view class="item">{{ item['Pq_ThdI(%)'] || '-'}}</view>
<view class="item">{{ item['Apf_RmsI_Sys(A)'] || '-' }}</view>
<view class="item">{{ item['Apf_ThdA_Sys(%)'] || '-' }}</view>
</template>
</view>
</view>
@@ -20,11 +20,11 @@
<view class="item item-title">电压(V)</view>
<view class="item item-title">频率(Hz)</view>
<view class="item item-title">THDU(%)</view>
<template v-for="(item, index) in renderData.电网">
<template v-for="(item, index) in renderData.电网电压">
<view class="item">{{ item.phase }}</view>
<view class="item">{{ item['Pq_RmsLU(V)'] || '-' }}</view>
<view class="item">{{ item['Pq_Freq(Hz)'] || '-' }}</view>
<view class="item">{{ item['Pq_ThdU(%)'] || '-' }}</view>
<view class="item">{{ item['Apf_PhV_Sys(V)'] || '-' }}</view>
<view class="item">{{ item['Apf_Freq(Hz)'] || '-' }}</view>
<view class="item">{{ item['Apf_ThdU(%)'] || '-' }}</view>
</template>
</view>
</view>
@@ -34,10 +34,10 @@
<view class="item item-title">名称</view>
<view class="item item-title">有效值(A)</view>
<view class="item item-title">THDI(%)</view>
<template v-for="(item, index) in renderData.负载">
<template v-for="(item, index) in renderData.负载电流">
<view class="item">{{ item.phase }}</view>
<view class="item">{{ item['Pq_RmsI(A)'] || '-' }}</view>
<view class="item">{{ item['Pq_ThdI(%)'] || '-' }}</view>
<view class="item">{{ item['Apf_RmsI_Load(A)'] || '-' }}</view>
<view class="item">{{ item['Apf_ThdA_Load(%)'] || '-' }}</view>
</template>
</view>
</view>
@@ -47,10 +47,10 @@
<view class="item item-title">名称</view>
<view class="item item-title">有效值(A)</view>
<view class="item item-title">负载率(%)</view>
<template v-for="(item, index) in renderData.输出侧">
<template v-for="(item, index) in renderData.补偿电流">
<view class="item">{{ item.phase }}</view>
<view class="item">{{ item['Apf_RmsI_Sys(A)'] || '-' }}</view>
<view class="item"></view>
<view class="item">{{ item['Apf_RmsI_TolOut(A)'] || '-' }}</view>
<view class="item">-</view>
</template>
</view>
</view>
@@ -61,9 +61,11 @@ export default {
data() {
return {
renderData: {
电网: {},
负载侧: {},
输出侧: {},
电网电流: [],
电网电压: [],
负载电流: [],
补偿电流: [],
未知:[]
},
}
},
@@ -78,36 +80,55 @@ export default {
watch: {
basicData: {
handler: function (newVal, oldVal) {
let arr = [
{
name: '电网侧',
linePostion: 'cb23b9ede3b652cd6da194fd7b318124',
},
{
name: '负载侧',
linePostion: '32624d4bb3a86f2b9a01bab272e50125',
},
{
name: '输出侧',
linePostion: '26eae70fb5ff1c090d2dc7c3a0743948',
},
]
this.basicData.forEach((item) => {
newVal.forEach(item => {
if (item.phase === 'avg') {
return
}
let index = arr.findIndex((item2) => {
return item2.linePostion === item.position
let key = ''
switch (item.statisticalName) {
case 'Apf_RmsI_Sys(A)':
key = '电网电流'
break
case 'Apf_ThdA_Sys(%)':
key = '电网电流'
break
case 'Apf_PhV_Sys(V)':
key = '电网电压'
break
case 'Apf_Freq(Hz)':
key = '电网电压'
break
case 'Apf_RmsI_Load(A)':
key = '负载电流'
break
case 'Apf_ThdA_Load(%)':
key = '负载电流'
break
case 'Apf_RmsI_TolOut(A)':
key = '补偿电流'
break
case 'Apf_PhV_Sys(V)':
key = '补偿电流'
break
case 'Apf_PhV_Sys(V)':
key = '补偿电流'
break
default:
key = '未知'
break
}
let index = this.renderData[key].findIndex((item2) => {
return item2.phase === item.phase
})
if (index > -1) {
if (this.renderData[arr[index]['name']][item.phase]) {
this.renderData[arr[index]['name']][item.phase][item.statisticalName] = item.statisticalData || '-'
} else {
this.renderData[arr[index]['name']][item.phase] = {
phase: item.phase,
[item.statisticalName]: item.statisticalData || '-',
}
}
this.renderData[key][index][item.statisticalName] = item.statisticalData || '-'
} else {
this.renderData[key].push({
phase: item.phase,
[item.statisticalName]: item.statisticalData || '-',
})
}
})
console.log(this.renderData)

View File

@@ -10,10 +10,10 @@
<view class="item item-title">功率因数</view>
<template v-for="(item, index) in renderData.电网侧">
<view class="item">{{ item.phase }}</view>
<view class="item">{{ item['Pq_P(W)'] || '-' }}</view>
<view class="item">{{ item['Pq_Q(var)'] || '-' }}</view>
<view class="item">{{ item['Pq_S(VA)'] || '-' }}</view>
<view class="item">{{ item['Pq_PF(null)'] || '-' }}</view>
<view class="item">{{ item['Apf_P_Sys(W)'] || '-' }}</view>
<view class="item">{{ item['Apf_Q_Sys(Var)'] || '-' }}</view>
<view class="item">{{ item['Apf_S_Sys(VA)'] || '-' }}</view>
<view class="item">{{ item['Apf_PF_Sys(null)'] || '-' }}</view>
</template>
</view>
</view>
@@ -25,12 +25,12 @@
<view class="item item-title">无功功率(kVar)</view>
<view class="item item-title">视在功率(kVA)</view>
<view class="item item-title">功率因数</view>
<template v-for="(item, index) in renderData.电网侧">
<template v-for="(item, index) in renderData.负载侧">
<view class="item">{{ item.phase }}</view>
<view class="item">{{ item['Pq_P(W)'] || '-' }}</view>
<view class="item">{{ item['Pq_Q(var)'] || '-' }}</view>
<view class="item">{{ item['Pq_S(VA)'] || '-' }}</view>
<view class="item">{{ item['Pq_PF(null)'] || '-' }}</view>
<view class="item">{{ item['Apf_P_Load(W)'] || '-' }}</view>
<view class="item">{{ item['Apf_Q_Load(Var)'] || '-' }}</view>
<view class="item">{{ item['Apf_S_Load(VA)'] || '-' }}</view>
<view class="item">{{ item['Apf_PF_Load(null)'] || '-' }}</view>
</template>
</view>
</view>
@@ -41,9 +41,9 @@ export default {
data() {
return {
renderData: {
电网侧: {},
负载侧: {},
输出侧: {},
电网侧: [],
负载侧: [],
未知: [],
},
}
},
@@ -58,36 +58,52 @@ export default {
watch: {
basicData: {
handler: function (newVal, oldVal) {
let arr = [
{
name: '电网侧',
linePostion: 'cb23b9ede3b652cd6da194fd7b318124',
},
{
name: '负载侧',
linePostion: '32624d4bb3a86f2b9a01bab272e50125',
},
{
name: '输出侧',
linePostion: '26eae70fb5ff1c090d2dc7c3a0743948',
},
]
this.basicData.forEach((item) => {
newVal.forEach(item => {
if (item.phase === 'avg') {
return
}
let index = arr.findIndex((item2) => {
return item2.linePostion === item.position
let key = ''
switch (item.statisticalName) {
case 'Apf_P_Sys(W)':
key = '电网侧'
break
case 'Apf_Q_Sys(Var)':
key = '电网侧'
break
case 'Apf_S_Sys(VA)':
key = '电网侧'
break
case 'Apf_PF_Sys(null)':
key = '电网侧'
break
case 'Apf_P_Load(W)':
key = '负载侧'
break
case 'Apf_Q_Load(Var)':
key = '负载侧'
break
case 'Apf_S_Load(VA)':
key = '负载侧'
break
case 'Apf_PF_Load(null)':
key = '负载侧'
break
default:
key = '未知'
break
}
let index = this.renderData[key].findIndex((item2) => {
return item2.phase === item.phase
})
if (index > -1) {
if (this.renderData[arr[index]['name']][item.phase]) {
this.renderData[arr[index]['name']][item.phase][item.statisticalName] = item.statisticalData || '-'
} else {
this.renderData[arr[index]['name']][item.phase] = {
phase: item.phase,
[item.statisticalName]: item.statisticalData || '-',
}
}
this.renderData[key][index][item.statisticalName] = item.statisticalData || '-'
} else {
this.renderData[key].push({
phase: item.phase,
[item.statisticalName]: item.statisticalData || '-',
})
}
})
console.log(this.renderData)
@@ -95,6 +111,7 @@ export default {
deep: true,
immediate: true,
},
},
methods: {},
}

View File

@@ -69,23 +69,24 @@ export default {
watch: {
basicData: {
handler: function (newVal, oldVal) {
console.log(this.basicData)
let basicData = JSON.parse(JSON.stringify(this.basicData))
let arr = [
{
name: '电网侧',
linePostion: 'cb23b9ede3b652cd6da194fd7b318124',
key: 'Apf_HarmI_Sys',
},
{
name: '负载侧',
linePostion: '32624d4bb3a86f2b9a01bab272e50125',
key: 'Apf_HarmI_Load',
},
]
basicData.forEach((item) => {
if (item.statisticalName.indexOf('Pq_HarmI_') === -1) {
if (item.statisticalName.indexOf('HarmI') === -1) {
return
}
let index = arr.findIndex((item2) => {
return item2.linePostion === item.position
return item.statisticalName.indexOf(item2.key) > -1
})
if (index > -1) {
if (this.renderData[arr[index]['name']][item.phase]) {
@@ -93,7 +94,6 @@ export default {
item.statisticalData || 0
} else {
this.renderData[arr[index]['name']][item.phase] = {
phase: item.phase,
[item.statisticalName]: item.statisticalData || 0,
}
}
@@ -110,10 +110,11 @@ export default {
let obj = JSON.parse(
JSON.stringify(this.renderData['电网侧'][Object.keys(this.renderData['电网侧'])[0]]),
)
delete obj['phase']
console.log(
Object.keys(obj).map((item) => {
return item.match(/Pq_HarmI_(\d+)/)[1]
// Apf_HarmI_Sys_36(A) 匹配36
return item.match(/\d+/)[0]
}),
)
console.log(
@@ -128,7 +129,8 @@ export default {
)
this.chartData = {
categories: Object.keys(obj).map((item) => {
return Number(item.match(/Pq_HarmI_(\d+)/)[1])
// Apf_HarmI_Sys_36(A) 匹配36
return Number(item.match(/\d+/)[0])
}),
series: [
{

View File

@@ -156,32 +156,7 @@ export default {
dictData: [],
isPrimaryUser: 0,
userInfo: {},
topolodyData: [
{
label: '电网侧',
linePostion: 'cb23b9ede3b652cd6da194fd7b318124',
lat: '',
lng: '',
showKey: ['Pq_ThdU(%)', 'Pq_ThdI(%)'], //要展示的指标key
value: [],// 展示的指标值
},
{
label: '负载侧',
linePostion: '32624d4bb3a86f2b9a01bab272e50125',
lat: '',
lng: '',
showKey: ['Pq_ThdU(%)', 'Pq_ThdI(%)'], //要展示的指标key
value: [],
},
{
label: '输出侧',
linePostion: '26eae70fb5ff1c090d2dc7c3a0743948',
lat: '',
lng: '',
showKey: ['Apf_ThdA_Load(%)', 'Apf_ThdA_Sys(%)'], //要展示的指标key
value: [],
},
],
topolodyData: [],
basicData: [],
IOData: [],
}
@@ -268,7 +243,7 @@ export default {
this.deviceInfo = res.data
this.downloadImg()
uni.setNavigationBarTitle({title: this.deviceInfo.devName || '设备详情'})
this.topolodyData.filter((item) => {
this.topolodyData = this.topolodyData.filter((item) => {
let index = this.deviceInfo.appsLineTopologyDiagramPO.findIndex((element) => {
element.label = element.name
item.label = element.name
@@ -283,6 +258,7 @@ export default {
return false
}
})
console.log(this.topolodyData)
if (this.client) {
this.loading = false
} else {
@@ -379,18 +355,19 @@ export default {
})
},
handlerData(data) {
this.basicData = data
this.topolodyData.forEach((element) => {
let arr = []
element.showKey.forEach((key) => {
data.forEach((item) => {
if (item.statisticalName === key && item.phase === 'avg' && element.linePostion === item.position) {
if (item.statisticalName === key && item.phase === 'avg' ) {
arr.push(key + ':' + item.statisticalData)
}
})
})
element.value = arr
})
this.basicData = data
console.log(this.topolodyData)
this.$forceUpdate()
},
},
@@ -434,6 +411,32 @@ export default {
text: '用户',
})
}
this.topolodyData = this.$util.getDictData('Line_Position').map(item => {
switch (item.name) {
case '电网侧':
item.showKey = ['Apf_ThdA_Sys(%)']
break
case '负载侧':
item.showKey = ['Apf_ThdA_Load(%)']
break
case '输出侧':
item.showKey = ['Apf_RmsI_TolOut(A)']
break
case 'PCC公共点':
item.showKey = []
break
default:
break
}
return {
label: item.name,
linePostion: item.id,
lat: '',
lng: '',
showKey: item.showKey, //要展示的指标key
value: [],
}
})
this.init()
},
}
@@ -455,6 +458,7 @@ export default {
position: relative;
width: 375px;
margin: 0 auto;
overflow: hidden;
image {
image-rendering: -moz-crisp-edges;

View File

@@ -0,0 +1,20 @@
'use strict';
const uniPush = uniCloud.getPushManager({appId: "__UNI__88BC25B"})
exports.main = async (event, context) => {
//event为客户端上传的参数
console.log('event : ', event)
let body = JSON.parse(event.body)
let res = await uniPush.sendMessage({
"push_clientid": body.push_clientid, //填写上一步在uni-app客户端获取到的客户端推送标识push_clientid
"title": body.title,
"content": body.content,
"payload": body.payload,
"force_notification": true,
"settings": {
"strategy": {
"default": 4
}
}
})
return res
};

View File

@@ -0,0 +1,7 @@
{
"name": "push",
"dependencies": {},
"extensions": {
"uni-cloud-push": {}
}
}

File diff suppressed because one or more lines are too long

View File

@@ -1,9 +0,0 @@
{
"name": "uni-config-center",
"version": "0.0.3",
"description": "配置中心",
"main": "index.js",
"keywords": [],
"author": "DCloud",
"license": "Apache-2.0"
}

File diff suppressed because one or more lines are too long

View File

@@ -1,16 +0,0 @@
{
"name": "uni-id-common",
"version": "1.0.14",
"description": "uni-id token生成、校验、刷新",
"main": "index.js",
"homepage": "https://uniapp.dcloud.io/uniCloud/uni-id-common.html",
"repository": {
"type": "git",
"url": "git+https://gitee.com/dcloud/uni-id-common.git"
},
"author": "DCloud",
"license": "Apache-2.0",
"dependencies": {
"uni-config-center": "file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
}
}