Merge branch 'master' of http://gitea.bugtc.com/zhouyanli/property-manager-side
This commit is contained in:
@@ -19,7 +19,8 @@
|
|||||||
"modules": {
|
"modules": {
|
||||||
"Geolocation": {},
|
"Geolocation": {},
|
||||||
"Camera": {},
|
"Camera": {},
|
||||||
"Push" : {}
|
"Push": {},
|
||||||
|
"Bluetooth": {}
|
||||||
},
|
},
|
||||||
"distribute": {
|
"distribute": {
|
||||||
"android": {
|
"android": {
|
||||||
@@ -44,11 +45,13 @@
|
|||||||
"ios": {
|
"ios": {
|
||||||
"dSYMs": false,
|
"dSYMs": false,
|
||||||
"privacyDescription": {
|
"privacyDescription": {
|
||||||
"NSPhotoLibraryUsageDescription" : "需要访问相册选择图片",
|
"NSPhotoLibraryUsageDescription": "需要访问手机相册,选取本地巡检记录照片、业主报修故障图、水电表二维码用于上传工单与巡检台账,仅读取当前业务所需图片,不会获取相册内其他无关照片。",
|
||||||
"NSPhotoLibraryAddUsageDescription" : "需要保存图片到相册",
|
"NSPhotoLibraryAddUsageDescription": "需要相册写入权限,保存巡检凭证、报修工单至手机相册,方便线下核对查看,图片仅本地存储,不会上传至无关服务器。",
|
||||||
"NSCameraUsageDescription" : "需要使用摄像头进行扫码/拍照",
|
"NSCameraUsageDescription": "本应用需要使用相机,用于管家现场巡检拍摄点位记录、处理业主报修拍摄故障照片,扫描水电表二维码抄表,拍摄影像仅用于小区物业工单与巡检业务存档,不会私自留存、对外分享。",
|
||||||
"NSLocationWhenInUseUsageDescription": "需要获取位置信息",
|
"NSLocationWhenInUseUsageDescription": "需要获取位置信息",
|
||||||
"NSLocationAlwaysAndWhenInUseUsageDescription" : "需要获取位置信息"
|
"NSLocationAlwaysAndWhenInUseUsageDescription": "需要获取位置信息",
|
||||||
|
"NSBluetoothPeripheralUsageDescription": "需要蓝牙权限连接小区智能门禁,实现蓝牙一键开门通行,仅用于小区门禁解锁业务,不采集蓝牙设备信息。",
|
||||||
|
"NSBluetoothAlwaysUsageDescription": "本应用需要蓝牙权限,用于扫描、连接小区蓝牙门禁设备实现一键开门,仅和本小区门禁硬件建立通信,不会扫描、连接无关蓝牙设备。"
|
||||||
},
|
},
|
||||||
"urltypes": [
|
"urltypes": [
|
||||||
{
|
{
|
||||||
@@ -134,25 +137,15 @@
|
|||||||
"app-harmony": {
|
"app-harmony": {
|
||||||
"distribute": {
|
"distribute": {
|
||||||
"bundleName": "com.chengkong.property.butler",
|
"bundleName": "com.chengkong.property.butler",
|
||||||
"modules" : {},
|
|
||||||
"signingConfigs": {
|
"signingConfigs": {
|
||||||
"default" : {
|
|
||||||
"certpath" : "C:/Users/admin/Desktop/AppStore/new_harmony/tiaoshi/nova13.cer",
|
|
||||||
"keyAlias" : "wuye_release",
|
|
||||||
"keyPassword" : "0000001A8C18CC0FA3EBE5081E8DE6C9AEBEA1289363F6AC420000893BFAC38FEEB094668676D0ABB00E",
|
|
||||||
"profile" : "C:/Users/admin/Desktop/AppStore/new_harmony/tiaoshi/nova13Debug.p7b",
|
|
||||||
"signAlg" : "SHA256withECDSA",
|
|
||||||
"storeFile" : "C:/Users/admin/Desktop/AppStore/new_harmony/huakaiwuye.p12",
|
|
||||||
"storePassword" : "0000001AF9096259B0A80FCF665963A7FA17EDDE959235C54631703996F852FB37603260821370B29540"
|
|
||||||
},
|
|
||||||
"release": {
|
"release": {
|
||||||
"certpath" : "C:/Users/admin/Desktop/AppStore/new_harmony/新花开物业正式.cer",
|
"certpath": "D:/物业app-ios-harmony-证书/new_harmony/新花开物业正式.cer",
|
||||||
"keyAlias": "wuye_release",
|
"keyAlias": "wuye_release",
|
||||||
"keyPassword" : "0000001A0370B3EB3ED7D19121CA44E8AB8A2F769371A3FC6F7D474BB4F5634C9BE04CD68C9D8FB97388",
|
"keyPassword": "0000001A29DE91ED98E83E4AA715BEF3F0939FE80AD47D2CF45EFF04C4566953153352E9CDF554E10C12",
|
||||||
"profile" : "C:/Users/admin/Desktop/AppStore/new_harmony/tiaoshi/nova13-yuRelease.p7b",
|
"profile": "D:/物业app-ios-harmony-证书/new_harmony/guanjia_profileRelease.p7b",
|
||||||
"signAlg": "SHA256withECDSA",
|
"signAlg": "SHA256withECDSA",
|
||||||
"storeFile" : "C:/Users/admin/Desktop/AppStore/new_harmony/huakaiwuye.p12",
|
"storeFile": "D:/物业app-ios-harmony-证书/new_harmony/huakaiwuye.p12",
|
||||||
"storePassword" : "0000001A650B133ED667142597C77169A0D17FA01684927EA18FA5C41D5824BD04D279361D1AE600DC07"
|
"storePassword": "0000001A67FD9009C459E134A62BF21903B8C48B1FA0F0C7E320F98C0C8F3132692D86D09FB1A54B39DD"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,7 +178,7 @@
|
|||||||
}
|
}
|
||||||
uni.showLoading({ title: '登录中...', mask: true });
|
uni.showLoading({ title: '登录中...', mask: true });
|
||||||
const push_cid = uni.getStorageSync('push_cid')
|
const push_cid = uni.getStorageSync('push_cid')
|
||||||
// console.log('cid',push_cid)
|
// console.log('登录cid',push_cid)
|
||||||
let params = {
|
let params = {
|
||||||
username:phoneNumber.value,
|
username:phoneNumber.value,
|
||||||
password:password.value,
|
password:password.value,
|
||||||
|
|||||||
@@ -1,14 +1,144 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const uniPush = uniCloud.getPushManager({
|
|
||||||
appId: "__UNI__5F224F3"
|
|
||||||
})
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送云函数
|
||||||
|
* 支持单推(cid)和群推(cids)
|
||||||
|
*/
|
||||||
exports.main = async (event, context) => {
|
exports.main = async (event, context) => {
|
||||||
const res = await uniPush.sendMessage({
|
// HTTP 触发器接收的参数在 event.body 中(JSON 字符串),需要解析
|
||||||
push_clientid: event.cid,
|
let requestData;
|
||||||
title: "通知标题",
|
|
||||||
content: "通知内容",
|
if (event.body && typeof event.body === 'string') {
|
||||||
force_notification: true
|
try {
|
||||||
})
|
requestData = JSON.parse(event.body);
|
||||||
return res
|
console.log('成功解析 event.body');
|
||||||
|
} catch (e) {
|
||||||
|
console.error('JSON 解析失败:', e.message);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: {
|
||||||
|
code: 'ParseError',
|
||||||
|
message: '请求体 JSON 格式错误'
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} else if (event.body && typeof event.body === 'object') {
|
||||||
|
// 某些情况下 body 可能已经是对象
|
||||||
|
requestData = event.body;
|
||||||
|
console.log('使用 event.body 对象');
|
||||||
|
} else {
|
||||||
|
// 兼容直接传递参数的情况(非 HTTP 触发器调用或测试环境)
|
||||||
|
requestData = event;
|
||||||
|
console.log('使用 event 对象(兼容模式)');
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('请求数据:', JSON.stringify(requestData));
|
||||||
|
|
||||||
|
// 从解析后的数据中解构参数
|
||||||
|
const { appId, cids, cid, title, content, payload, request_id } = requestData;
|
||||||
|
|
||||||
|
// 参数校验
|
||||||
|
if (!appId || typeof appId !== 'string') {
|
||||||
|
console.error('appId 无效:', appId, '类型:', typeof appId);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: {
|
||||||
|
code: 'ParameterError',
|
||||||
|
message: '缺少必填参数:appId,且必须为字符串'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// 统一推送目标:cid 优先,其次 cids
|
||||||
|
const clientIds = cid ? [cid] : cids;
|
||||||
|
if (!clientIds || (Array.isArray(clientIds) && clientIds.length === 0)) {
|
||||||
|
console.error('clientIds 无效:', clientIds);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: {
|
||||||
|
code: 'ParameterError',
|
||||||
|
message: '缺少必填参数:cids 或 cid'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!title || typeof title !== 'string') {
|
||||||
|
console.error('title 无效:', title);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: {
|
||||||
|
code: 'ParameterError',
|
||||||
|
message: '缺少必填参数:title,且必须为字符串'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!content || typeof content !== 'string') {
|
||||||
|
console.error('content 无效');
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: {
|
||||||
|
code: 'ParameterError',
|
||||||
|
message: '缺少必填参数:content,且必须为字符串'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送推送
|
||||||
|
try {
|
||||||
|
console.log('初始化推送管理器,appId:', appId);
|
||||||
|
const uniPush = uniCloud.getPushManager({ appId });
|
||||||
|
|
||||||
|
const sendMessageParams = {
|
||||||
|
push_clientid: Array.isArray(clientIds) ? clientIds : [clientIds],
|
||||||
|
title,
|
||||||
|
content,
|
||||||
|
force_notification: true // 离线厂商推送必填
|
||||||
|
};
|
||||||
|
|
||||||
|
// 自定义 payload(仅当为有效对象时添加)
|
||||||
|
if (
|
||||||
|
payload &&
|
||||||
|
typeof payload === 'object' &&
|
||||||
|
!Array.isArray(payload) &&
|
||||||
|
Object.keys(payload).length > 0
|
||||||
|
) {
|
||||||
|
sendMessageParams.payload = payload;
|
||||||
|
console.log('添加自定义 payload');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 可选的 requestId
|
||||||
|
if (request_id) {
|
||||||
|
sendMessageParams.request_id = request_id;
|
||||||
|
console.log('添加 request_id:', request_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('准备发送推送,参数:', JSON.stringify(sendMessageParams));
|
||||||
|
|
||||||
|
const res = await uniPush.sendMessage(sendMessageParams);
|
||||||
|
|
||||||
|
console.log('推送成功,结果:', JSON.stringify(res));
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
data: res
|
||||||
|
};
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
// 记录完整错误信息到云函数日志,便于排查
|
||||||
|
console.error('push-send 推送失败:', JSON.stringify({
|
||||||
|
message: error.message,
|
||||||
|
errMsg: error.errMsg,
|
||||||
|
code: error.code,
|
||||||
|
stack: error.stack
|
||||||
|
}));
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: {
|
||||||
|
code: error.code || 'PushError',
|
||||||
|
message: error.errMsg || error.message || '推送失败,请稍后重试'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "push-send-butler",
|
"name": "push-send",
|
||||||
|
"cloudfunction-config": {
|
||||||
|
"path": "/push-send",
|
||||||
|
"timeout": 60
|
||||||
|
},
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"extensions": {
|
"extensions": {
|
||||||
"uni-cloud-jql": {},
|
|
||||||
"uni-cloud-push": {}
|
"uni-cloud-push": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user