diff --git a/App.vue b/App.vue
index 521672e..ad4ba44 100644
--- a/App.vue
+++ b/App.vue
@@ -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')
diff --git a/common/api/user.js b/common/api/user.js
index 98cdd4b..d896dfd 100644
--- a/common/api/user.js
+++ b/common/api/user.js
@@ -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',
+ })
+ }
})
}
diff --git a/manifest.json b/manifest.json
index b3576aa..4573388 100644
--- a/manifest.json
+++ b/manifest.json
@@ -70,7 +70,7 @@
"push" : {
"unipush" : {
"version" : "2",
- "offline" : false
+ "offline" : true
}
},
"share" : {}
diff --git a/pages/device/APF/comp/basic.vue b/pages/device/APF/comp/basic.vue
index 138888b..2ce9fe4 100644
--- a/pages/device/APF/comp/basic.vue
+++ b/pages/device/APF/comp/basic.vue
@@ -6,10 +6,10 @@
名称
有效值(A)
THDI(%)
-
+
{{ item.phase }}
- {{ item['Pq_RmsI(A)'] || '-' }}
- {{ item['Pq_ThdI(%)'] || '-'}}
+ {{ item['Apf_RmsI_Sys(A)'] || '-' }}
+ {{ item['Apf_ThdA_Sys(%)'] || '-' }}
@@ -20,11 +20,11 @@
电压(V)
频率(Hz)
THDU(%)
-
+
{{ item.phase }}
- {{ item['Pq_RmsLU(V)'] || '-' }}
- {{ item['Pq_Freq(Hz)'] || '-' }}
- {{ item['Pq_ThdU(%)'] || '-' }}
+ {{ item['Apf_PhV_Sys(V)'] || '-' }}
+ {{ item['Apf_Freq(Hz)'] || '-' }}
+ {{ item['Apf_ThdU(%)'] || '-' }}
@@ -34,10 +34,10 @@
名称
有效值(A)
THDI(%)
-
+
{{ item.phase }}
- {{ item['Pq_RmsI(A)'] || '-' }}
- {{ item['Pq_ThdI(%)'] || '-' }}
+ {{ item['Apf_RmsI_Load(A)'] || '-' }}
+ {{ item['Apf_ThdA_Load(%)'] || '-' }}
@@ -47,10 +47,10 @@
名称
有效值(A)
负载率(%)
-
+
{{ item.phase }}
- {{ item['Apf_RmsI_Sys(A)'] || '-' }}
-
+ {{ item['Apf_RmsI_TolOut(A)'] || '-' }}
+ -
@@ -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)
diff --git a/pages/device/APF/comp/power.vue b/pages/device/APF/comp/power.vue
index 933ea12..fd46d2a 100644
--- a/pages/device/APF/comp/power.vue
+++ b/pages/device/APF/comp/power.vue
@@ -10,10 +10,10 @@
功率因数
{{ item.phase }}
- {{ item['Pq_P(W)'] || '-' }}
- {{ item['Pq_Q(var)'] || '-' }}
- {{ item['Pq_S(VA)'] || '-' }}
- {{ item['Pq_PF(null)'] || '-' }}
+ {{ item['Apf_P_Sys(W)'] || '-' }}
+ {{ item['Apf_Q_Sys(Var)'] || '-' }}
+ {{ item['Apf_S_Sys(VA)'] || '-' }}
+ {{ item['Apf_PF_Sys(null)'] || '-' }}
@@ -25,12 +25,12 @@
无功功率(kVar)
视在功率(kVA)
功率因数
-
+
{{ item.phase }}
- {{ item['Pq_P(W)'] || '-' }}
- {{ item['Pq_Q(var)'] || '-' }}
- {{ item['Pq_S(VA)'] || '-' }}
- {{ item['Pq_PF(null)'] || '-' }}
+ {{ item['Apf_P_Load(W)'] || '-' }}
+ {{ item['Apf_Q_Load(Var)'] || '-' }}
+ {{ item['Apf_S_Load(VA)'] || '-' }}
+ {{ item['Apf_PF_Load(null)'] || '-' }}
@@ -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: {},
}
diff --git a/pages/device/APF/comp/xieBo.vue b/pages/device/APF/comp/xieBo.vue
index de3c49d..1426134 100644
--- a/pages/device/APF/comp/xieBo.vue
+++ b/pages/device/APF/comp/xieBo.vue
@@ -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: [
{
diff --git a/pages/device/APF/detail.vue b/pages/device/APF/detail.vue
index 915a38c..347aef9 100644
--- a/pages/device/APF/detail.vue
+++ b/pages/device/APF/detail.vue
@@ -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;
diff --git a/uniCloud-aliyun/cloudfunctions/push/index.js b/uniCloud-aliyun/cloudfunctions/push/index.js
new file mode 100644
index 0000000..025205d
--- /dev/null
+++ b/uniCloud-aliyun/cloudfunctions/push/index.js
@@ -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
+};
diff --git a/uniCloud-aliyun/cloudfunctions/push/package.json b/uniCloud-aliyun/cloudfunctions/push/package.json
new file mode 100644
index 0000000..a60c163
--- /dev/null
+++ b/uniCloud-aliyun/cloudfunctions/push/package.json
@@ -0,0 +1,7 @@
+{
+ "name": "push",
+ "dependencies": {},
+ "extensions": {
+ "uni-cloud-push": {}
+ }
+}
\ No newline at end of file
diff --git a/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/index.js b/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/index.js
deleted file mode 100644
index 00ba62f..0000000
--- a/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/index.js
+++ /dev/null
@@ -1 +0,0 @@
-"use strict";var t=require("fs"),r=require("path");function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=e(t),o=e(r),i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var u=function(t){var r={exports:{}};return t(r,r.exports),r.exports}((function(t,r){var e="__lodash_hash_undefined__",n=9007199254740991,o="[object Arguments]",u="[object Function]",c="[object Object]",a=/^\[object .+?Constructor\]$/,f=/^(?:0|[1-9]\d*)$/,s={};s["[object Float32Array]"]=s["[object Float64Array]"]=s["[object Int8Array]"]=s["[object Int16Array]"]=s["[object Int32Array]"]=s["[object Uint8Array]"]=s["[object Uint8ClampedArray]"]=s["[object Uint16Array]"]=s["[object Uint32Array]"]=!0,s[o]=s["[object Array]"]=s["[object ArrayBuffer]"]=s["[object Boolean]"]=s["[object DataView]"]=s["[object Date]"]=s["[object Error]"]=s[u]=s["[object Map]"]=s["[object Number]"]=s[c]=s["[object RegExp]"]=s["[object Set]"]=s["[object String]"]=s["[object WeakMap]"]=!1;var l="object"==typeof i&&i&&i.Object===Object&&i,h="object"==typeof self&&self&&self.Object===Object&&self,p=l||h||Function("return this")(),_=r&&!r.nodeType&&r,v=_&&t&&!t.nodeType&&t,d=v&&v.exports===_,y=d&&l.process,g=function(){try{var t=v&&v.require&&v.require("util").types;return t||y&&y.binding&&y.binding("util")}catch(t){}}(),b=g&&g.isTypedArray;function j(t,r,e){switch(e.length){case 0:return t.call(r);case 1:return t.call(r,e[0]);case 2:return t.call(r,e[0],e[1]);case 3:return t.call(r,e[0],e[1],e[2])}return t.apply(r,e)}var w,O,m,A=Array.prototype,z=Function.prototype,M=Object.prototype,x=p["__core-js_shared__"],C=z.toString,F=M.hasOwnProperty,U=(w=/[^.]+$/.exec(x&&x.keys&&x.keys.IE_PROTO||""))?"Symbol(src)_1."+w:"",S=M.toString,I=C.call(Object),P=RegExp("^"+C.call(F).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),T=d?p.Buffer:void 0,q=p.Symbol,E=p.Uint8Array,$=T?T.allocUnsafe:void 0,D=(O=Object.getPrototypeOf,m=Object,function(t){return O(m(t))}),k=Object.create,B=M.propertyIsEnumerable,N=A.splice,L=q?q.toStringTag:void 0,R=function(){try{var t=vt(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),G=T?T.isBuffer:void 0,V=Math.max,W=Date.now,H=vt(p,"Map"),J=vt(Object,"create"),K=function(){function t(){}return function(r){if(!xt(r))return{};if(k)return k(r);t.prototype=r;var e=new t;return t.prototype=void 0,e}}();function Q(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r-1},X.prototype.set=function(t,r){var e=this.__data__,n=nt(e,t);return n<0?(++this.size,e.push([t,r])):e[n][1]=r,this},Y.prototype.clear=function(){this.size=0,this.__data__={hash:new Q,map:new(H||X),string:new Q}},Y.prototype.delete=function(t){var r=_t(this,t).delete(t);return this.size-=r?1:0,r},Y.prototype.get=function(t){return _t(this,t).get(t)},Y.prototype.has=function(t){return _t(this,t).has(t)},Y.prototype.set=function(t,r){var e=_t(this,t),n=e.size;return e.set(t,r),this.size+=e.size==n?0:1,this},Z.prototype.clear=function(){this.__data__=new X,this.size=0},Z.prototype.delete=function(t){var r=this.__data__,e=r.delete(t);return this.size=r.size,e},Z.prototype.get=function(t){return this.__data__.get(t)},Z.prototype.has=function(t){return this.__data__.has(t)},Z.prototype.set=function(t,r){var e=this.__data__;if(e instanceof X){var n=e.__data__;if(!H||n.length<199)return n.push([t,r]),this.size=++e.size,this;e=this.__data__=new Y(n)}return e.set(t,r),this.size=e.size,this};var it,ut=function(t,r,e){for(var n=-1,o=Object(t),i=e(t),u=i.length;u--;){var c=i[it?u:++n];if(!1===r(o[c],c,o))break}return t};function ct(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":L&&L in Object(t)?function(t){var r=F.call(t,L),e=t[L];try{t[L]=void 0;var n=!0}catch(t){}var o=S.call(t);n&&(r?t[L]=e:delete t[L]);return o}(t):function(t){return S.call(t)}(t)}function at(t){return Ct(t)&&ct(t)==o}function ft(t){return!(!xt(t)||function(t){return!!U&&U in t}(t))&&(zt(t)?P:a).test(function(t){if(null!=t){try{return C.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function st(t){if(!xt(t))return function(t){var r=[];if(null!=t)for(var e in Object(t))r.push(e);return r}(t);var r=yt(t),e=[];for(var n in t)("constructor"!=n||!r&&F.call(t,n))&&e.push(n);return e}function lt(t,r,e,n,o){t!==r&&ut(r,(function(i,u){if(o||(o=new Z),xt(i))!function(t,r,e,n,o,i,u){var a=gt(t,e),f=gt(r,e),s=u.get(f);if(s)return void rt(t,e,s);var l=i?i(a,f,e+"",t,r,u):void 0,h=void 0===l;if(h){var p=Ot(f),_=!p&&At(f),v=!p&&!_&&Ft(f);l=f,p||_||v?Ot(a)?l=a:Ct(j=a)&&mt(j)?l=function(t,r){var e=-1,n=t.length;r||(r=Array(n));for(;++e-1&&t%1==0&&t0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}(pt);function jt(t,r){return t===r||t!=t&&r!=r}var wt=at(function(){return arguments}())?at:function(t){return Ct(t)&&F.call(t,"callee")&&!B.call(t,"callee")},Ot=Array.isArray;function mt(t){return null!=t&&Mt(t.length)&&!zt(t)}var At=G||function(){return!1};function zt(t){if(!xt(t))return!1;var r=ct(t);return r==u||"[object GeneratorFunction]"==r||"[object AsyncFunction]"==r||"[object Proxy]"==r}function Mt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=n}function xt(t){var r=typeof t;return null!=t&&("object"==r||"function"==r)}function Ct(t){return null!=t&&"object"==typeof t}var Ft=b?function(t){return function(r){return t(r)}}(b):function(t){return Ct(t)&&Mt(t.length)&&!!s[ct(t)]};function Ut(t){return mt(t)?tt(t,!0):st(t)}var St,It=(St=function(t,r,e){lt(t,r,e)},ht((function(t,r){var e=-1,n=r.length,o=n>1?r[n-1]:void 0,i=n>2?r[2]:void 0;for(o=St.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,r,e){if(!xt(e))return!1;var n=typeof r;return!!("number"==n?mt(e)&&dt(r,e.length):"string"==n&&r in e)&&jt(e[r],t)}(r[0],r[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++ec.call(t,r);class f{constructor({pluginId:t,defaultConfig:r={},customMerge:e,root:n}){this.pluginId=t,this.defaultConfig=r,this.pluginConfigPath=o.default.resolve(n||__dirname,t),this.customMerge=e,this._config=void 0}resolve(t){return o.default.resolve(this.pluginConfigPath,t)}hasFile(t){return n.default.existsSync(this.resolve(t))}requireFile(t){try{return require(this.resolve(t))}catch(t){if("MODULE_NOT_FOUND"===t.code)return;throw t}}_getUserConfig(){return this.requireFile("config.json")}config(t,r){if(!this._config){const t=this._getUserConfig();this._config=Array.isArray(t)?t:(this.customMerge||u)(this.defaultConfig,t)}let e=this._config;return t?function(t,r,e){if("number"==typeof r)return t[r];if("symbol"==typeof r)return a(t,r)?t[r]:e;const n="string"!=typeof(o=r)?o:o.split(".").reduce(((t,r)=>(r.split(/\[([^}]+)\]/g).forEach((r=>r&&t.push(r))),t)),[]);var o;let i=t;for(let t=0;tparseInt(e)):void 0}function o(e,t){const n=r(e),i=r(t);return n?i?function(e,t){const n=Math.max(e.length,t.length);for(let i=0;ir)return 1;if(ne)throw new Error("Config error, tokenExpiresThreshold should be less than tokenExpiresIn")}get customToken(){return this.uniId.interceptorMap.get("customToken")}isTokenInDb(e){return o(e,"1.0.10")>=0}async getUserRecord(){if(this.userRecord)return this.userRecord;const e=await C.doc(this.uid).get();if(this.userRecord=e.data[0],!this.userRecord)throw{errCode:n.ACCOUNT_NOT_EXISTS};switch(this.userRecord.status){case void 0:case 0:break;case 1:throw{errCode:n.ACCOUNT_BANNED};case 2:throw{errCode:n.ACCOUNT_AUDITING};case 3:throw{errCode:n.ACCOUNT_AUDIT_FAILED};case 4:throw{errCode:n.ACCOUNT_CLOSED}}if(this.oldTokenPayload){if(this.isTokenInDb(this.oldTokenPayload.uniIdVersion)){if(-1===(this.userRecord.token||[]).indexOf(this.oldToken))throw{errCode:n.CHECK_TOKEN_FAILED}}if(this.userRecord.valid_token_date&&this.userRecord.valid_token_date>1e3*this.oldTokenPayload.iat)throw{errCode:n.TOKEN_EXPIRED}}return this.userRecord}async updateUserRecord(e){await C.doc(this.uid).update(e)}async getUserPermission(){if(this.userPermission)return this.userPermission;const e=(await this.getUserRecord()).role||[];if(0===e.length)return this.userPermission={role:[],permission:[]},this.userPermission;if(e.includes("admin"))return this.userPermission={role:e,permission:[]},this.userPermission;const t=await m.where({role_id:_.in(e)}).get(),n=(i=t.data.reduce((e,t)=>(t.permission&&e.push(...t.permission),e),[]),Array.from(new Set(i)));var i;return this.userPermission={role:e,permission:n},this.userPermission}async _createToken({uid:e,role:t,permission:i}={}){if(!t||!i){const e=await this.getUserPermission();t=e.role,i=e.permission}let r={uid:e,role:t,permission:i};if(this.uniId.interceptorMap.has("customToken")){const n=this.uniId.interceptorMap.get("customToken");if("function"!=typeof n)throw new Error("Invalid custom token file");r=await n({uid:e,role:t,permission:i})}const o=Date.now(),{tokenSecret:s,tokenExpiresIn:c}=this.config,a=g({...r,uniIdVersion:"1.0.14"},s,{expiresIn:c}),u=await this.getUserRecord(),d=(u.token||[]).filter(e=>{try{const t=this._checkToken(e);if(u.valid_token_date&&u.valid_token_date>1e3*t.iat)return!1}catch(e){if(e.errCode===n.TOKEN_EXPIRED)return!1}return!0});return d.push(a),await this.updateUserRecord({last_login_ip:this.clientInfo.clientIP,last_login_date:o,token:d}),{token:a,tokenExpired:o+1e3*c}}async createToken({uid:e,role:t,permission:i}={}){if(!e)throw{errCode:n.PARAM_REQUIRED,errMsgValue:{param:"uid"}};this.uid=e;const{token:r,tokenExpired:o}=await this._createToken({uid:e,role:t,permission:i});return{errCode:0,token:r,tokenExpired:o}}async refreshToken({token:e}={}){if(!e)throw{errCode:n.PARAM_REQUIRED,errMsgValue:{param:"token"}};this.oldToken=e;const t=this._checkToken(e);this.uid=t.uid,this.oldTokenPayload=t;const{uid:i}=t,{role:r,permission:o}=await this.getUserPermission(),{token:s,tokenExpired:c}=await this._createToken({uid:i,role:r,permission:o});return{errCode:0,token:s,tokenExpired:c}}_checkToken(e){const{tokenSecret:t}=this.config;let i;try{i=k(e,t)}catch(e){if("TokenExpiredError"===e.name)throw{errCode:n.TOKEN_EXPIRED};throw{errCode:n.CHECK_TOKEN_FAILED}}return i}async checkToken(e,{autoRefresh:t=!0}={}){if(!e)throw{errCode:n.PARAM_REQUIRED,errMsgValue:{param:"token"}};this.oldToken=e;const i=this._checkToken(e);this.uid=i.uid,this.oldTokenPayload=i;const{tokenExpiresThreshold:r}=this.config,{uid:o,role:s,permission:c}=i,a={role:s,permission:c};if(!s&&!c){const{role:e,permission:t}=await this.getUserPermission();a.role=e,a.permission=t}if(!r||!t){const e={code:0,errCode:0,...i,...a};return delete e.uniIdVersion,e}const u=Date.now();let d={};1e3*i.exp-u<1e3*r&&(d=await this._createToken({uid:o}));const l={code:0,errCode:0,...i,...a,...d};return delete l.uniIdVersion,l}}var E=Object.freeze({__proto__:null,checkToken:async function(e,{autoRefresh:t=!0}={}){return new T({uniId:this}).checkToken(e,{autoRefresh:t})},createToken:async function({uid:e,role:t,permission:n}={}){return new T({uniId:this}).createToken({uid:e,role:t,permission:n})},refreshToken:async function({token:e}={}){return new T({uniId:this}).refreshToken({token:e})}});const w=require("uni-config-center")({pluginId:"uni-id"});class A{constructor({context:e,clientInfo:t,config:n}={}){this._clientInfo=e?function(e){return{appId:e.APPID,platform:e.PLATFORM,locale:e.LOCALE,clientIP:e.CLIENTIP,deviceId:e.DEVICEID}}(e):t,this.config=n||this._getOriginConfig(),this.interceptorMap=new Map,w.hasFile("custom-token.js")&&this.setInterceptor("customToken",require(w.resolve("custom-token.js"))),this._i18n=uniCloud.initI18n({locale:this._clientInfo.locale,fallbackLocale:"zh-Hans",messages:d})}setInterceptor(e,t){this.interceptorMap.set(e,t)}_t(...e){return this._i18n.t(...e)}_parseOriginConfig(e){return Array.isArray(e)?e:e[0]?Object.values(e):e}_getOriginConfig(){if(w.hasFile("config.json")){let e;try{e=w.config()}catch(e){throw new Error("Invalid uni-id config file\n"+e.message)}return this._parseOriginConfig(e)}try{return this._parseOriginConfig(require("uni-id/config.json"))}catch(e){throw new Error("Invalid uni-id config file")}}_getAppConfig(){const e=this._getOriginConfig();return Array.isArray(e)?e.find(e=>e.dcloudAppid===this._clientInfo.appId)||e.find(e=>e.isDefaultConfig):e}_getPlatformConfig(){const e=this._getAppConfig();if(!e)throw new Error(`Config for current app (${this._clientInfo.appId}) was not found, please check your config file or client appId`);let t;switch("app-plus"===this._clientInfo.platform&&(this._clientInfo.platform="app"),"h5"===this._clientInfo.platform&&(this._clientInfo.platform="web"),this._clientInfo.platform){case"web":t="h5";break;case"app":t="app-plus"}const n=[{tokenExpiresIn:7200,tokenExpiresThreshold:1200,passwordErrorLimit:6,passwordErrorRetryTime:3600},e];t&&e[t]&&n.push(e[t]),n.push(e[this._clientInfo.platform]);const i=Object.assign(...n);return["tokenSecret","tokenExpiresIn"].forEach(e=>{if(!i||!i[e])throw new Error(`Config parameter missing, ${e} is required`)}),i}_getConfig(){return this._getPlatformConfig()}}for(const e in E)A.prototype[e]=E[e];function y(e){const t=new A(e);return new Proxy(t,{get(e,t){if(t in e&&0!==t.indexOf("_")){if("function"==typeof e[t])return(n=e[t],function(){let e;try{e=n.apply(this,arguments)}catch(e){if(a(e))return c.call(this,e),e;throw e}return i(e)?e.then(e=>(a(e)&&c.call(this,e),e),e=>{if(a(e))return c.call(this,e),e;throw e}):(a(e)&&c.call(this,e),e)}).bind(e);if("context"!==t&&"config"!==t)return e[t]}var n}})}A.prototype.createInstance=y;const x={createInstance:y};module.exports=x;
diff --git a/uni_modules/uni-id-common/uniCloud/cloudfunctions/common/uni-id-common/package.json b/uni_modules/uni-id-common/uniCloud/cloudfunctions/common/uni-id-common/package.json
deleted file mode 100644
index ada62ae..0000000
--- a/uni_modules/uni-id-common/uniCloud/cloudfunctions/common/uni-id-common/package.json
+++ /dev/null
@@ -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"
- }
-}
\ No newline at end of file