配置push2.0并测试;修改样式、二维码保存

This commit is contained in:
zhouyanli
2026-05-30 16:37:43 +08:00
parent 7c8a4aba26
commit fbe07e21a6
5 changed files with 152 additions and 47 deletions

View File

@@ -1,17 +1,48 @@
<script> <script setup>
export default { import { onLaunch } from '@dcloudio/uni-app'
onLaunch: function() {
// console.log('App Launch')
},
onShow: function() {
// console.log('App Show')
},
onHide: function() {
console.log('App Hide')
},
// 应用启动时执行
onLaunch(() => {
console.log('App 启动')
// #ifdef APP-PLUS
// 只有 App 平台才获取 CID
getPushCID()
// #endif
})
// 获取 uniPush 2.0 CID
function getPushCID() {
uni.getPushClientId({
success: (res) => {
console.log('推送初始化成功')
console.log('CID =', res.cid)
// 存起来备用
uni.setStorageSync('push_cid', res.cid)
// 弹出CID给你看
// uni.showModal({
// title: '你的CID',
// content: res.cid
// })
},
fail: (err) => {
console.error('获取推送 CID 失败', err)
} }
})
}
// export default {
// on
// onShow: function() {
// // console.log('App Show')
// },
// onHide: function() {
// console.log('App Hide')
// },
// }
</script> </script>
<style lang="scss"> <style lang="scss">

View File

@@ -1,9 +1,9 @@
{ {
"name" : "花开物业用户端app", "name" : "花开物业",
"appid" : "__UNI__29C3D60", "appid" : "__UNI__29C3D60",
"description" : "物业用户端app", "description" : "物业用户端app",
"versionName" : "1.0.1", "versionName" : "1.0.1",
"versionCode" : "102", "versionCode" : "103",
"transformPx" : false, "transformPx" : false,
/* 5+App */ /* 5+App */
"app-plus" : { "app-plus" : {
@@ -22,6 +22,7 @@
"Maps" : {}, "Maps" : {},
"Camera" : {}, "Camera" : {},
"Contacts" : {}, "Contacts" : {},
"Gallery" : {},
"Push" : {} "Push" : {}
}, },
/* */ /* */
@@ -51,7 +52,11 @@
}, },
/* ios */ /* ios */
"ios" : { "ios" : {
"dSYMs" : false "dSYMs" : false,
"privacyDescription" : {
"NSPhotoLibraryUsageDescription" : "需要访问您的相册,用于选择图片上传",
"NSPhotoLibraryAddUsageDescription" : "保存二维码图片到相册"
}
}, },
/* SDK */ /* SDK */
"sdkConfigs" : { "sdkConfigs" : {
@@ -71,13 +76,17 @@
"unipush" : { "unipush" : {
"version" : "2", "version" : "2",
"offline" : true, "offline" : true,
"hms" : {}, "icons" : {
"oppo" : {}, "small" : {
"vivo" : {}, "mdpi" : "D:/图片文档/logo-app.png"
"mi" : {}, }
"meizu" : {}, }
"honor" : {}, }
"fcm" : {} },
"share" : {
"weixin" : {
"appid" : "",
"UniversalLinks" : ""
} }
} }
} }
@@ -114,5 +123,10 @@
"uniStatistics" : { "uniStatistics" : {
"enable" : false "enable" : false
}, },
"vueVersion" : "3" "vueVersion" : "3",
"app-harmony" : {
"distribute" : {
"bundleName" : "com.chengkong.property.owner"
}
}
} }

View File

@@ -210,13 +210,19 @@ page {
} }
.code-btn { .code-btn {
font-size: 24rpx; position: absolute;
right: 10rpx;
top: 13%;
transform: translateY(-50%);
width: 200rpx;
height: 66rpx;
line-height: 66rpx;
background-color: #2F77FD;
color: #fff; color: #fff;
background: #2F77FD; border-radius: 35rpx;
border: none; font-size: 28rpx;
padding: 0; padding: 0;
line-height: 88rpx; margin: 0;
width: 100px;
} }
.code-btn[disabled] { .code-btn[disabled] {

View File

@@ -17,7 +17,7 @@
</view> </view>
<view class="btn-wrap"> <view class="btn-wrap">
<button class="send-btn" open-type="share" :image-url="qrcodeUrl">发送给好友</button> <button class="send-btn" @click="saveToAlbum">保存图片到相册</button>
</view> </view>
</view> </view>
</template> </template>
@@ -41,22 +41,71 @@ onLoad((option) => {
} }
}); });
// 分享给好友 // 保存图片到相册
// const sendToFriend = () => { const saveToAlbum = () => {
// if (!qrcodeImage.value) { if (!qrcodeUrl.value) {
// uni.showToast({ title: '二维码生成中...', icon: 'none' }); uni.showToast({ title: '二维码加载中...', icon: 'none' });
// return; return;
// } }
// uni.share({ uni.showLoading({ title: '保存中...', mask: true });
// provider: 'weixin',
// type: 0, const doSave = (filePath) => {
// title: '访客通行二维码', uni.saveImageToPhotosAlbum({
// imageUrl: qrcodeImage.value, filePath,
// success: () => uni.showToast({ title: '分享成功' }), success: () => {
// fail: () => uni.showToast({ title: '分享失败', icon: 'none' }) uni.hideLoading();
// }); uni.showToast({ title: '保存成功', icon: 'success' });
// }; },
fail: (err) => {
uni.hideLoading();
console.log('保存失败', err);
const errMsg = (err.errMsg || err.message || '').toLowerCase();
const isAuthError = errMsg.includes('auth') ||
errMsg.includes('deny') ||
errMsg.includes('permission') ||
errMsg.includes('拒绝') ||
err.errCode === '1' ||
err.errCode === 1;
if (isAuthError) {
uni.showModal({
title: '提示',
content: '保存图片需要相册权限,请在设置中开启',
confirmText: '去设置',
success: (res) => {
if (res.confirm) uni.openSetting();
}
});
} else {
uni.showToast({ title: '保存失败', icon: 'none' });
}
}
});
};
if (qrcodeUrl.value.startsWith('http')) {
uni.downloadFile({
url: qrcodeUrl.value,
success: (res) => {
if (res.statusCode === 200) {
doSave(res.tempFilePath);
} else {
uni.hideLoading();
uni.showToast({ title: '图片下载成功', icon: 'none' });
}
},
fail: (err) => {
uni.hideLoading();
console.log('下载失败', err);
uni.showToast({ title: '图片下载失败', icon: 'none' });
}
});
} else {
doSave(qrcodeUrl.value);
}
};
</script> </script>
<style scoped> <style scoped>

View File

@@ -467,7 +467,7 @@
} }
.label { .label {
width: 205rpx; width: 225rpx;
font-size: 32rpx; font-size: 32rpx;
color: #333; color: #333;
} }
@@ -563,7 +563,6 @@
.gender-list { .gender-list {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 20rpx;
} }
.address-item, .address-item,
@@ -573,6 +572,12 @@
border-radius: 8rpx; border-radius: 8rpx;
text-align: center; text-align: center;
font-size: 30rpx; font-size: 30rpx;
margin-bottom: 20rpx;
}
.address-item:last-child,
.gender-item:last-child {
margin-bottom: 0;
} }
.address-item.active, .address-item.active,