From 00187f02c39b0320fe214b0388fda101b52dca63 Mon Sep 17 00:00:00 2001 From: wangfukang <15630117759@163.com> Date: Wed, 4 Nov 2026 16:14:11 +0800 Subject: [PATCH] 1 --- App.vue | 335 ++++++++++++++++++++------------------ pages.json | 19 +++ pages/common/webview.vue | 25 +++ pages/login/login.css | 26 +++ pages/login/login.vue | 36 +++- pages/privacy/consent.vue | 152 +++++++++++++++++ 6 files changed, 433 insertions(+), 160 deletions(-) create mode 100644 pages/common/webview.vue create mode 100644 pages/privacy/consent.vue diff --git a/App.vue b/App.vue index 9733bd6..4db70db 100644 --- a/App.vue +++ b/App.vue @@ -31,8 +31,8 @@ // uni.$aegis = aegis // 首先需要通过 uni.requireNativePlugin("ModuleName") 获取 module // #ifdef APP-PLUS - var jpushModule = uni.requireNativePlugin("JG-JPush"); - var audioObj = uni.getBackgroundAudioManager(); + var jpushModule = null; + var audioObj = null; // #endif export default { @@ -64,185 +64,202 @@ registrationID: '', printData: [], // 打印任务队列,按顺序存储待打印的通知数据 isPrinting: false, // 标记当前是否正在打印,防止并发 + privacyInitialized: false, + initAfterPrivacyAgreement: null, }, onLaunch: function() { let context = this; - const baseUrl = getApp().globalData.mainurl - //这里是热更新的代码 - // #ifdef APP-PLUS - uni.request({ - url: baseUrl + '/setting/app-update/latest', - data: {}, - success: (res) => { - var data = res.data.result; - if (data.url) { - uni.downloadFile({ - url: data.url, - success: (downloadResult) => { - if (downloadResult.statusCode === 200) { - plus.runtime.install(downloadResult.tempFilePath, { - force: false - }, function() { - console.log('install success...'); - plus.runtime.restart(); - }, function(e) { - console.error('install fail...',e); - }); - } - } - }); - } - } - }); - // #endif this.globalData._i18n = this.$i18n //这是原型链上的$i18n this.globalData.$t = function(str) { let $i18n = context.globalData.$i18n //这里去拿global的i18n return context.$t(str) } this.getAreaSize() - // this.getRegistrationID() - // #ifdef APP-PLUS - if (jpushModule.setLoggerEnable) { - jpushModule.setLoggerEnable(true); - } - if (plus && plus.screen && plus.screen.lockOrientation) { - plus.screen.lockOrientation("portrait-primary"); - } - //监听 极光推送连接状态 - jpushModule.addConnectEventListener(result => { - console.log('JPush connect event:', JSON.stringify(result)); - let connectEnable = result.connectEnable - if (connectEnable == true) { - setTimeout(() => { - this.getRegistrationID(); - }, 1000); - } else { - - } - }); - jpushModule.addNotificationListener(result => { //极光推送的消息通知回调 - console.log('JPush notification event:', JSON.stringify(result)); - if (jpushModule.setBadge) { - jpushModule.setBadge(0); + this.globalData.initAfterPrivacyAgreement = () => this.initAfterPrivacyAgreement() + return this.initAfterPrivacyAgreement() + }, + computed: { + i18n() { + return this.$t('index') + }, + }, + methods: { + initAfterPrivacyAgreement() { + if (!uni.getStorageSync('privacyPolicyAgreed')) { + return } - if (plus && plus.runtime && plus.runtime.setBadgeNumber) { - plus.runtime.setBadgeNumber(0); + if (this.globalData.privacyInitialized) { + return } - let notificationEventType = result.notificationEventType - let woopId = result.extras && result.extras.dataType === 'woop' && result.extras.value; - const content = result.content || '' - //用户点击了通知消息 - if (result.notificationEventType === 'notificationOpened') { - const inAppExtras = this.getPushInAppExtras(result); - if (inAppExtras) { - this.handlePushClick(inAppExtras); + this.globalData.privacyInitialized = true + // #ifdef APP-PLUS + jpushModule = uni.requireNativePlugin("JG-JPush"); + audioObj = uni.getBackgroundAudioManager(); + // #endif + const baseUrl = getApp().globalData.mainurl + //这里是热更新的代码 + // #ifdef APP-PLUS + uni.request({ + url: baseUrl + '/setting/app-update/latest', + data: {}, + success: (res) => { + var data = res.data.result; + if (data.url) { + uni.downloadFile({ + url: data.url, + success: (downloadResult) => { + if (downloadResult.statusCode === 200) { + plus.runtime.install(downloadResult.tempFilePath, { + force: false + }, function() { + console.log('install success...'); + plus.runtime.restart(); + }, function(e) { + console.error('install fail...', e); + }); + } + } + }); + } } - + }); + // #endif + // this.getRegistrationID() + // #ifdef APP-PLUS + if (jpushModule.setLoggerEnable) { + jpushModule.setLoggerEnable(true); + } + if (plus && plus.screen && plus.screen.lockOrientation) { + plus.screen.lockOrientation("portrait-primary"); } - //用户收到了通知消息 - if (result.notificationEventType == 'notificationArrived') { - if (content.includes('订单出餐已超时')) { - this.onPlayAudio(2) - } else if (content.includes('您有一笔配送订单无人接单')) { - this.onPlayAudio(5) - } else if (content.includes('您有一笔新的指定配送单,请及时接单')) { - this.onPlayAudio(10) - } else if (content.includes('您有一笔配送中订单用户申请退款')) { - this.onPlayAudio(11) - } else if (content.includes('抢单大厅来新单啦') || content.includes('有新的中转配送单啦,请及时接单')) { - this.onPlayAudio(12) - } else if (content.includes('您有中转配送订单超时未送达中转点')) { - this.onPlayAudio(7) - } else if (content.includes('您有一笔订单用户申请售后,请尽快处理')) { - this.onPlayAudio(8) - } else if (content.includes('您有一个后台指派单,请及时查看')) { - this.onPlayAudio(13) - } else if (content.includes('您有一笔订单被改派')) { - this.onPlayAudio(14) + //监听 极光推送连接状态 + jpushModule.addConnectEventListener(result => { + console.log('JPush connect event:', JSON.stringify(result)); + let connectEnable = result.connectEnable + if (connectEnable == true) { + setTimeout(() => { + this.getRegistrationID(); + }, 1000); } else { - if (content.includes('您有一笔新的订单')) { - this.onPlayAudio(4) - } else if (content.includes('您有一笔新的到店订单')) { - this.onPlayAudio(3) - } else if (content.includes('您有一笔订单申请退款')) { - this.onPlayAudio(1) - } else if (content.includes('您有一笔商家自配送订单,请立即处理')) { - this.onPlayAudio(6) - } else if (content.includes('您有一笔预约订单可以出餐啦')) { - this.onPlayAudio(9) + + } + }); + jpushModule.addNotificationListener(result => { //极光推送的消息通知回调 + console.log('JPush notification event:', JSON.stringify(result)); + if (jpushModule.setBadge) { + jpushModule.setBadge(0); + } + if (plus && plus.runtime && plus.runtime.setBadgeNumber) { + plus.runtime.setBadgeNumber(0); + } + let notificationEventType = result.notificationEventType + let woopId = result.extras && result.extras.dataType === 'woop' && result.extras.value; + const content = result.content || '' + //用户点击了通知消息 + if (result.notificationEventType === 'notificationOpened') { + const inAppExtras = this.getPushInAppExtras(result); + if (inAppExtras) { + this.handlePushClick(inAppExtras); + } + + } + //用户收到了通知消息 + if (result.notificationEventType == 'notificationArrived') { + if (content.includes('订单出餐已超时')) { + this.onPlayAudio(2) + } else if (content.includes('您有一笔配送订单无人接单')) { + this.onPlayAudio(5) + } else if (content.includes('您有一笔新的指定配送单,请及时接单')) { + this.onPlayAudio(10) + } else if (content.includes('您有一笔配送中订单用户申请退款')) { + this.onPlayAudio(11) + } else if (content.includes('抢单大厅来新单啦') || content.includes('有新的中转配送单啦,请及时接单')) { + this.onPlayAudio(12) + } else if (content.includes('您有中转配送订单超时未送达中转点')) { + this.onPlayAudio(7) + } else if (content.includes('您有一笔订单用户申请售后,请尽快处理')) { + this.onPlayAudio(8) + } else if (content.includes('您有一个后台指派单,请及时查看')) { + this.onPlayAudio(13) + } else if (content.includes('您有一笔订单被改派')) { + this.onPlayAudio(14) + } else { + if (content.includes('您有一笔新的订单')) { + this.onPlayAudio(4) + } else if (content.includes('您有一笔新的到店订单')) { + this.onPlayAudio(3) + } else if (content.includes('您有一笔订单申请退款')) { + this.onPlayAudio(1) + } else if (content.includes('您有一笔商家自配送订单,请立即处理')) { + this.onPlayAudio(6) + } else if (content.includes('您有一笔预约订单可以出餐啦')) { + this.onPlayAudio(9) + } + this.enqueuePrintFromPush(result); } - this.enqueuePrintFromPush(result); } - } - }); - if (jpushModule.initJPushService) { - console.log('JPush init service'); - jpushModule.initJPushService(); - } - this.getNotificationEnabled(); - if (jpushModule.isPushStopped) { - jpushModule.isPushStopped(res => { - // code 0已停止推送 1未停止推送 - const { - code - } = res - }) - } - //#endif + }); + if (jpushModule.initJPushService) { + console.log('JPush init service'); + jpushModule.initJPushService(); + } + this.getNotificationEnabled(); + if (jpushModule.isPushStopped) { + jpushModule.isPushStopped(res => { + // code 0已停止推送 1未停止推送 + const { + code + } = res + }) + } + //#endif - // 将原生插件挂载在 uni 上 - // #ifdef APP-PLUS - // uni.$TUICalling = TUICalling; - // #endif - // 如果您已创建了 tim,请将 tim 实例挂载在 wx 上,且不可以修改 wx.$TIM(修改变量可能导致 TUICalling 组件无法正常使用), 完成 TUICalling 初始化, - // 如果您没有创建,可以不传 + // 将原生插件挂载在 uni 上 + // #ifdef APP-PLUS + // uni.$TUICalling = TUICalling; + // #endif + // 如果您已创建了 tim,请将 tim 实例挂载在 wx 上,且不可以修改 wx.$TIM(修改变量可能导致 TUICalling 组件无法正常使用), 完成 TUICalling 初始化, + // 如果您没有创建,可以不传 - // #ifdef APP-PLUS - // if (this.NB.isAndroidOrIOS() == 'iOS') { - // this.globalData.GaoDeAppKey = 'b1aadb7457eae6aa40a0c8ed58ae0456' - // } else { - // this.globalData.GaoDeAppKey = '43cff70e1deb9455185e2c8cf8363aec' - // } - if (this.NB.isAndroidOrIOS() == 'iOS') { - this.globalData.GaoDeAppKey = 'f32a7750d2a2c3d7459f85185c867c4f' - } else { - this.globalData.GaoDeAppKey = 'a88be362cab2d0f18608bedcc47ace9a' - } - this.globalData.GaoDeKey_amapkey = '97a3e0a8bf3f3ca77193b81c48d92ee2' - // #endif - // #ifdef MP-WEIXIN - this.globalData.GaoDeKey_amapkey = '52de86da47be2ea547c37dd382025a0c' - // #endif - if(uni.getStorageSync('peisongyuan')) return; - if (uni.getStorageSync('printingMethod') != 'cloud') { - this.autoConnectPrinter() - } - if (uni.getStorageSync('printingMethod') != 'cloud' && !uni.getStorageSync('bluetoothDeviceId')) { - uni.showModal({ - title: '提示', - content: '您还没有连接打印机,将无法为您打印小票!', - confirmText: '连接蓝牙', - cancelText: '暂不连接', - success: function(res) { - if (res.confirm) { - uni.navigateTo({ - url: '/pages/myCenter/setPrint' - }) + // #ifdef APP-PLUS + // if (this.NB.isAndroidOrIOS() == 'iOS') { + // this.globalData.GaoDeAppKey = 'b1aadb7457eae6aa40a0c8ed58ae0456' + // } else { + // this.globalData.GaoDeAppKey = '43cff70e1deb9455185e2c8cf8363aec' + // } + if (this.NB.isAndroidOrIOS() == 'iOS') { + this.globalData.GaoDeAppKey = 'f32a7750d2a2c3d7459f85185c867c4f' + } else { + this.globalData.GaoDeAppKey = 'a88be362cab2d0f18608bedcc47ace9a' + } + this.globalData.GaoDeKey_amapkey = '97a3e0a8bf3f3ca77193b81c48d92ee2' + // #endif + // #ifdef MP-WEIXIN + this.globalData.GaoDeKey_amapkey = '52de86da47be2ea547c37dd382025a0c' + // #endif + if (uni.getStorageSync('peisongyuan')) return; + if (uni.getStorageSync('printingMethod') != 'cloud') { + this.autoConnectPrinter() + } + if (uni.getStorageSync('printingMethod') != 'cloud' && !uni.getStorageSync('bluetoothDeviceId')) { + uni.showModal({ + title: '提示', + content: '您还没有连接打印机,将无法为您打印小票!', + confirmText: '连接蓝牙', + cancelText: '暂不连接', + success: function(res) { + if (res.confirm) { + uni.navigateTo({ + url: '/pages/myCenter/setPrint' + }) + } } - } - }); - } - }, - computed: { - i18n() { - return this.$t('index') + }); + } }, - }, - methods: { getPushInAppExtras(result) { if (!result) return ''; if (this.NB.isAndroidOrIOS() == 'iOS') { @@ -411,6 +428,7 @@ }, getRegistrationID() { //获取registerID + if (!jpushModule || !jpushModule.getRegistrationID) return; jpushModule.getRegistrationID(result => { let registerID = result && (result.registerID || result.registrationID) if (registerID) { @@ -428,6 +446,7 @@ }, false, 'POST', 'application/x-www-form-urlencoded').catch(() => {}); }, getNotificationEnabled() { + if (!jpushModule) return; if (uni.getSystemInfoSync().platform == "ios") { if (!jpushModule.requestNotificationAuthorization) { console.log('JPush requestNotificationAuthorization is unavailable'); diff --git a/pages.json b/pages.json index 43c814d..414628b 100644 --- a/pages.json +++ b/pages.json @@ -1,5 +1,15 @@ { "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages + { + "path": "pages/privacy/consent", + "style": { + "navigationBarTitleText": "", + "navigationStyle": "custom", + "app-plus": { + "bounce": "none" + } + } + }, { //首页 "path": "pages/index/index", "style": { @@ -55,6 +65,15 @@ } } }, + { + "path": "pages/common/webview", + "style": { + "navigationBarTitleText": "隐私政策", + "app-plus": { + "bounce": "none" + } + } + }, { //登录 "path": "pages/login/country", "style": { diff --git a/pages/common/webview.vue b/pages/common/webview.vue new file mode 100644 index 0000000..bf4fa7c --- /dev/null +++ b/pages/common/webview.vue @@ -0,0 +1,25 @@ + + + diff --git a/pages/login/login.css b/pages/login/login.css index a5f99b1..cffdeb2 100644 --- a/pages/login/login.css +++ b/pages/login/login.css @@ -144,3 +144,29 @@ page { font-size: 12px; color: #FF5725; } + +.privacy-agreement { + display: flex; + flex-direction: row; + align-items: center; + width: calc(100% - 40px); + margin: 8px 20px 0; + font-size: 12px; + color: #666; + line-height: 20px; +} + +.privacy-label { + display: flex; + flex-direction: row; + align-items: center; +} + +.privacy-checkbox { + transform: scale(0.7); + margin-right: 2px; +} + +.privacy-link { + color: #FF5725; +} diff --git a/pages/login/login.vue b/pages/login/login.vue index c602a3b..ae095bf 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -49,6 +49,15 @@ {{i18n.login.forgetPass}} --> + + + + + 《隐私政策》 +