配置push2.0并测试;修改样式、二维码保存
This commit is contained in:
@@ -1,17 +1,48 @@
|
||||
<script>
|
||||
export default {
|
||||
onLaunch: function() {
|
||||
// console.log('App Launch')
|
||||
},
|
||||
onShow: function() {
|
||||
// console.log('App Show')
|
||||
},
|
||||
onHide: function() {
|
||||
console.log('App Hide')
|
||||
},
|
||||
<script setup>
|
||||
import { onLaunch } from '@dcloudio/uni-app'
|
||||
|
||||
// 应用启动时执行
|
||||
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>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"name" : "花开物业用户端app",
|
||||
"name" : "花开物业",
|
||||
"appid" : "__UNI__29C3D60",
|
||||
"description" : "物业用户端app",
|
||||
"versionName" : "1.0.1",
|
||||
"versionCode" : "102",
|
||||
"versionCode" : "103",
|
||||
"transformPx" : false,
|
||||
/* 5+App特有相关 */
|
||||
"app-plus" : {
|
||||
@@ -22,6 +22,7 @@
|
||||
"Maps" : {},
|
||||
"Camera" : {},
|
||||
"Contacts" : {},
|
||||
"Gallery" : {},
|
||||
"Push" : {}
|
||||
},
|
||||
/* 应用发布信息 */
|
||||
@@ -51,7 +52,11 @@
|
||||
},
|
||||
/* ios打包配置 */
|
||||
"ios" : {
|
||||
"dSYMs" : false
|
||||
"dSYMs" : false,
|
||||
"privacyDescription" : {
|
||||
"NSPhotoLibraryUsageDescription" : "需要访问您的相册,用于选择图片上传",
|
||||
"NSPhotoLibraryAddUsageDescription" : "保存二维码图片到相册"
|
||||
}
|
||||
},
|
||||
/* SDK配置 */
|
||||
"sdkConfigs" : {
|
||||
@@ -71,13 +76,17 @@
|
||||
"unipush" : {
|
||||
"version" : "2",
|
||||
"offline" : true,
|
||||
"hms" : {},
|
||||
"oppo" : {},
|
||||
"vivo" : {},
|
||||
"mi" : {},
|
||||
"meizu" : {},
|
||||
"honor" : {},
|
||||
"fcm" : {}
|
||||
"icons" : {
|
||||
"small" : {
|
||||
"mdpi" : "D:/图片文档/logo-app.png"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"share" : {
|
||||
"weixin" : {
|
||||
"appid" : "",
|
||||
"UniversalLinks" : ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,5 +123,10 @@
|
||||
"uniStatistics" : {
|
||||
"enable" : false
|
||||
},
|
||||
"vueVersion" : "3"
|
||||
"vueVersion" : "3",
|
||||
"app-harmony" : {
|
||||
"distribute" : {
|
||||
"bundleName" : "com.chengkong.property.owner"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,13 +210,19 @@ page {
|
||||
}
|
||||
|
||||
.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;
|
||||
background: #2F77FD;
|
||||
border: none;
|
||||
border-radius: 35rpx;
|
||||
font-size: 28rpx;
|
||||
padding: 0;
|
||||
line-height: 88rpx;
|
||||
width: 100px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.code-btn[disabled] {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
</view>
|
||||
|
||||
<view class="btn-wrap">
|
||||
<button class="send-btn" open-type="share" :image-url="qrcodeUrl">发送给好友</button>
|
||||
<button class="send-btn" @click="saveToAlbum">保存图片到相册</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -41,22 +41,71 @@ onLoad((option) => {
|
||||
}
|
||||
});
|
||||
|
||||
// 分享给好友
|
||||
// const sendToFriend = () => {
|
||||
// if (!qrcodeImage.value) {
|
||||
// uni.showToast({ title: '二维码生成中...', icon: 'none' });
|
||||
// return;
|
||||
// }
|
||||
// 保存图片到相册
|
||||
const saveToAlbum = () => {
|
||||
if (!qrcodeUrl.value) {
|
||||
uni.showToast({ title: '二维码加载中...', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
// uni.share({
|
||||
// provider: 'weixin',
|
||||
// type: 0,
|
||||
// title: '访客通行二维码',
|
||||
// imageUrl: qrcodeImage.value,
|
||||
// success: () => uni.showToast({ title: '分享成功' }),
|
||||
// fail: () => uni.showToast({ title: '分享失败', icon: 'none' })
|
||||
// });
|
||||
// };
|
||||
uni.showLoading({ title: '保存中...', mask: true });
|
||||
|
||||
const doSave = (filePath) => {
|
||||
uni.saveImageToPhotosAlbum({
|
||||
filePath,
|
||||
success: () => {
|
||||
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>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -467,7 +467,7 @@
|
||||
}
|
||||
|
||||
.label {
|
||||
width: 205rpx;
|
||||
width: 225rpx;
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
}
|
||||
@@ -563,7 +563,6 @@
|
||||
.gender-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.address-item,
|
||||
@@ -573,6 +572,12 @@
|
||||
border-radius: 8rpx;
|
||||
text-align: center;
|
||||
font-size: 30rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.address-item:last-child,
|
||||
.gender-item:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.address-item.active,
|
||||
|
||||
Reference in New Issue
Block a user