wangfukang 5 days ago
parent
commit
00187f02c3
  1. 335
      App.vue
  2. 19
      pages.json
  3. 25
      pages/common/webview.vue
  4. 26
      pages/login/login.css
  5. 36
      pages/login/login.vue
  6. 152
      pages/privacy/consent.vue

335
App.vue

@ -31,8 +31,8 @@
// uni.$aegis = aegis // uni.$aegis = aegis
// 首先需要通过 uni.requireNativePlugin("ModuleName") 获取 module // 首先需要通过 uni.requireNativePlugin("ModuleName") 获取 module
// #ifdef APP-PLUS // #ifdef APP-PLUS
var jpushModule = uni.requireNativePlugin("JG-JPush"); var jpushModule = null;
var audioObj = uni.getBackgroundAudioManager(); var audioObj = null;
// #endif // #endif
export default { export default {
@ -64,185 +64,202 @@
registrationID: '', registrationID: '',
printData: [], // 打印任务队列,按顺序存储待打印的通知数据 printData: [], // 打印任务队列,按顺序存储待打印的通知数据
isPrinting: false, // 标记当前是否正在打印,防止并发 isPrinting: false, // 标记当前是否正在打印,防止并发
privacyInitialized: false,
initAfterPrivacyAgreement: null,
}, },
onLaunch: function() { onLaunch: function() {
let context = this; 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._i18n = this.$i18n //这是原型链上的$i18n
this.globalData.$t = function(str) { this.globalData.$t = function(str) {
let $i18n = context.globalData.$i18n //这里去拿global的i18n let $i18n = context.globalData.$i18n //这里去拿global的i18n
return context.$t(str) return context.$t(str)
} }
this.getAreaSize() this.getAreaSize()
// this.getRegistrationID() this.globalData.initAfterPrivacyAgreement = () => this.initAfterPrivacyAgreement()
// #ifdef APP-PLUS return this.initAfterPrivacyAgreement()
if (jpushModule.setLoggerEnable) { },
jpushModule.setLoggerEnable(true); computed: {
} i18n() {
if (plus && plus.screen && plus.screen.lockOrientation) { return this.$t('index')
plus.screen.lockOrientation("portrait-primary"); },
} },
//监听 极光推送连接状态 methods: {
jpushModule.addConnectEventListener(result => { initAfterPrivacyAgreement() {
console.log('JPush connect event:', JSON.stringify(result)); if (!uni.getStorageSync('privacyPolicyAgreed')) {
let connectEnable = result.connectEnable return
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);
} }
if (plus && plus.runtime && plus.runtime.setBadgeNumber) { if (this.globalData.privacyInitialized) {
plus.runtime.setBadgeNumber(0); return
} }
let notificationEventType = result.notificationEventType this.globalData.privacyInitialized = true
let woopId = result.extras && result.extras.dataType === 'woop' && result.extras.value; // #ifdef APP-PLUS
const content = result.content || '' jpushModule = uni.requireNativePlugin("JG-JPush");
//用户点击了通知消息 audioObj = uni.getBackgroundAudioManager();
if (result.notificationEventType === 'notificationOpened') { // #endif
const inAppExtras = this.getPushInAppExtras(result); const baseUrl = getApp().globalData.mainurl
if (inAppExtras) { //这里是热更新的代码
this.handlePushClick(inAppExtras); // #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') { jpushModule.addConnectEventListener(result => {
if (content.includes('订单出餐已超时')) { console.log('JPush connect event:', JSON.stringify(result));
this.onPlayAudio(2) let connectEnable = result.connectEnable
} else if (content.includes('您有一笔配送订单无人接单')) { if (connectEnable == true) {
this.onPlayAudio(5) setTimeout(() => {
} else if (content.includes('您有一笔新的指定配送单,请及时接单')) { this.getRegistrationID();
this.onPlayAudio(10) }, 1000);
} 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 { } else {
if (content.includes('您有一笔新的订单')) {
this.onPlayAudio(4) }
} else if (content.includes('您有一笔新的到店订单')) { });
this.onPlayAudio(3) jpushModule.addNotificationListener(result => { //极光推送的消息通知回调
} else if (content.includes('您有一笔订单申请退款')) { console.log('JPush notification event:', JSON.stringify(result));
this.onPlayAudio(1) if (jpushModule.setBadge) {
} else if (content.includes('您有一笔商家自配送订单,请立即处理')) { jpushModule.setBadge(0);
this.onPlayAudio(6) }
} else if (content.includes('您有一笔预约订单可以出餐啦')) { if (plus && plus.runtime && plus.runtime.setBadgeNumber) {
this.onPlayAudio(9) 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) { if (jpushModule.initJPushService) {
console.log('JPush init service'); console.log('JPush init service');
jpushModule.initJPushService(); jpushModule.initJPushService();
} }
this.getNotificationEnabled(); this.getNotificationEnabled();
if (jpushModule.isPushStopped) { if (jpushModule.isPushStopped) {
jpushModule.isPushStopped(res => { jpushModule.isPushStopped(res => {
// code 0已停止推送 1未停止推送 // code 0已停止推送 1未停止推送
const { const {
code code
} = res } = res
}) })
} }
//#endif //#endif
// 将原生插件挂载在 uni 上 // 将原生插件挂载在 uni 上
// #ifdef APP-PLUS // #ifdef APP-PLUS
// uni.$TUICalling = TUICalling; // uni.$TUICalling = TUICalling;
// #endif // #endif
// 如果您已创建了 tim,请将 tim 实例挂载在 wx 上,且不可以修改 wx.$TIM(修改变量可能导致 TUICalling 组件无法正常使用), 完成 TUICalling 初始化, // 如果您已创建了 tim,请将 tim 实例挂载在 wx 上,且不可以修改 wx.$TIM(修改变量可能导致 TUICalling 组件无法正常使用), 完成 TUICalling 初始化,
// 如果您没有创建,可以不传 // 如果您没有创建,可以不传
// #ifdef APP-PLUS // #ifdef APP-PLUS
// if (this.NB.isAndroidOrIOS() == 'iOS') { // if (this.NB.isAndroidOrIOS() == 'iOS') {
// this.globalData.GaoDeAppKey = 'b1aadb7457eae6aa40a0c8ed58ae0456' // this.globalData.GaoDeAppKey = 'b1aadb7457eae6aa40a0c8ed58ae0456'
// } else { // } else {
// this.globalData.GaoDeAppKey = '43cff70e1deb9455185e2c8cf8363aec' // this.globalData.GaoDeAppKey = '43cff70e1deb9455185e2c8cf8363aec'
// } // }
if (this.NB.isAndroidOrIOS() == 'iOS') { if (this.NB.isAndroidOrIOS() == 'iOS') {
this.globalData.GaoDeAppKey = 'f32a7750d2a2c3d7459f85185c867c4f' this.globalData.GaoDeAppKey = 'f32a7750d2a2c3d7459f85185c867c4f'
} else { } else {
this.globalData.GaoDeAppKey = 'a88be362cab2d0f18608bedcc47ace9a' this.globalData.GaoDeAppKey = 'a88be362cab2d0f18608bedcc47ace9a'
} }
this.globalData.GaoDeKey_amapkey = '97a3e0a8bf3f3ca77193b81c48d92ee2' this.globalData.GaoDeKey_amapkey = '97a3e0a8bf3f3ca77193b81c48d92ee2'
// #endif // #endif
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
this.globalData.GaoDeKey_amapkey = '52de86da47be2ea547c37dd382025a0c' this.globalData.GaoDeKey_amapkey = '52de86da47be2ea547c37dd382025a0c'
// #endif // #endif
if(uni.getStorageSync('peisongyuan')) return; if (uni.getStorageSync('peisongyuan')) return;
if (uni.getStorageSync('printingMethod') != 'cloud') { if (uni.getStorageSync('printingMethod') != 'cloud') {
this.autoConnectPrinter() this.autoConnectPrinter()
} }
if (uni.getStorageSync('printingMethod') != 'cloud' && !uni.getStorageSync('bluetoothDeviceId')) { if (uni.getStorageSync('printingMethod') != 'cloud' && !uni.getStorageSync('bluetoothDeviceId')) {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '您还没有连接打印机,将无法为您打印小票!', content: '您还没有连接打印机,将无法为您打印小票!',
confirmText: '连接蓝牙', confirmText: '连接蓝牙',
cancelText: '暂不连接', cancelText: '暂不连接',
success: function(res) { success: function(res) {
if (res.confirm) { if (res.confirm) {
uni.navigateTo({ uni.navigateTo({
url: '/pages/myCenter/setPrint' url: '/pages/myCenter/setPrint'
}) })
}
} }
} });
}); }
}
},
computed: {
i18n() {
return this.$t('index')
}, },
},
methods: {
getPushInAppExtras(result) { getPushInAppExtras(result) {
if (!result) return ''; if (!result) return '';
if (this.NB.isAndroidOrIOS() == 'iOS') { if (this.NB.isAndroidOrIOS() == 'iOS') {
@ -411,6 +428,7 @@
}, },
getRegistrationID() { //获取registerID getRegistrationID() { //获取registerID
if (!jpushModule || !jpushModule.getRegistrationID) return;
jpushModule.getRegistrationID(result => { jpushModule.getRegistrationID(result => {
let registerID = result && (result.registerID || result.registrationID) let registerID = result && (result.registerID || result.registrationID)
if (registerID) { if (registerID) {
@ -428,6 +446,7 @@
}, false, 'POST', 'application/x-www-form-urlencoded').catch(() => {}); }, false, 'POST', 'application/x-www-form-urlencoded').catch(() => {});
}, },
getNotificationEnabled() { getNotificationEnabled() {
if (!jpushModule) return;
if (uni.getSystemInfoSync().platform == "ios") { if (uni.getSystemInfoSync().platform == "ios") {
if (!jpushModule.requestNotificationAuthorization) { if (!jpushModule.requestNotificationAuthorization) {
console.log('JPush requestNotificationAuthorization is unavailable'); console.log('JPush requestNotificationAuthorization is unavailable');

19
pages.json

@ -1,5 +1,15 @@
{ {
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
"path": "pages/privacy/consent",
"style": {
"navigationBarTitleText": "",
"navigationStyle": "custom",
"app-plus": {
"bounce": "none"
}
}
},
{ //首页 { //首页
"path": "pages/index/index", "path": "pages/index/index",
"style": { "style": {
@ -55,6 +65,15 @@
} }
} }
}, },
{
"path": "pages/common/webview",
"style": {
"navigationBarTitleText": "隐私政策",
"app-plus": {
"bounce": "none"
}
}
},
{ //登录 { //登录
"path": "pages/login/country", "path": "pages/login/country",
"style": { "style": {

25
pages/common/webview.vue

@ -0,0 +1,25 @@
<template>
<web-view :src="url"></web-view>
</template>
<script>
const DEFAULT_URL = 'https://hbkuaishi.com/yinsi.html'
export default {
data() {
return {
url: DEFAULT_URL
}
},
onLoad(options) {
if (options && options.url) {
this.url = decodeURIComponent(options.url)
}
if (options && options.title) {
uni.setNavigationBarTitle({
title: decodeURIComponent(options.title)
})
}
}
}
</script>

26
pages/login/login.css

@ -144,3 +144,29 @@ page {
font-size: 12px; font-size: 12px;
color: #FF5725; 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;
}

36
pages/login/login.vue

@ -49,6 +49,15 @@
{{i18n.login.forgetPass}} {{i18n.login.forgetPass}}
</navigator> --> </navigator> -->
</view> </view>
<view class="privacy-agreement">
<checkbox-group @change="privacyAgreeChange">
<label class="privacy-label">
<checkbox class="privacy-checkbox" value="agree" :checked="agree" color="#FF5725" />
<text>我已阅读并同意</text>
</label>
</checkbox-group>
<text class="privacy-link" @click.stop="openPrivacyPolicy">《隐私政策》</text>
</view>
<button enabled="enabled" class="login-btn" style="border-radius: 50rpx; border: 0;" type="primary" <button enabled="enabled" class="login-btn" style="border-radius: 50rpx; border: 0;" type="primary"
@click="submit"> @click="submit">
{{i18n.login.login}} {{i18n.login.login}}
@ -90,7 +99,8 @@
canshowcode: false, canshowcode: false,
passwordFocus: false, passwordFocus: false,
codeFocus: false, codeFocus: false,
agree: true, agree: false,
privacyPolicyUrl: 'https://hbkuaishi.com/yinsi.html',
mobile: "", mobile: "",
password: "", password: "",
captchaId: '', captchaId: '',
@ -125,7 +135,6 @@
}, },
onLoad(option) { onLoad(option) {
this.top = getApp().globalData.top + 20 this.top = getApp().globalData.top + 20
this.getRegistrationID()
this.getCaptchaImg(); this.getCaptchaImg();
}, },
computed: { computed: {
@ -276,6 +285,15 @@
this.agree = true; this.agree = true;
} }
}, },
privacyAgreeChange(event) {
this.agree = event.detail.value.indexOf('agree') !== -1
},
openPrivacyPolicy() {
uni.navigateTo({
url: '/pages/common/webview?title=' + encodeURIComponent('隐私政策') + '&url=' +
encodeURIComponent(this.privacyPolicyUrl)
})
},
register() { register() {
uni.navigateTo({ uni.navigateTo({
url: "../reg/reg" url: "../reg/reg"
@ -421,6 +439,20 @@
this.$refs.popup.open(type) this.$refs.popup.open(type)
}, },
async submit() { async submit() {
if (!this.agree) {
uni.showModal({
title: '温馨提示',
content: '请先阅读《隐私政策》,并勾选同意后再登录。',
confirmText: '查看政策',
cancelText: '我知道了',
success: (res) => {
if (res.confirm) {
this.openPrivacyPolicy()
}
}
})
return
}
if (this.enabled && this.loginType) { if (this.enabled && this.loginType) {
uni.showToast({ uni.showToast({
title: '请输入手机号和验证码后登录', title: '请输入手机号和验证码后登录',

152
pages/privacy/consent.vue

@ -0,0 +1,152 @@
<template>
<view class="privacy-page">
<view class="privacy-card">
<view class="privacy-title">隐私政策提示</view>
<scroll-view class="privacy-content" scroll-y>
<text>
欢迎使用半径里商家端!我们非常重视您的个人信息和隐私保护。在您使用本应用前,请认真阅读
</text>
<text class="privacy-link" @click="openPrivacyPolicy">《隐私政策》</text>
<text>
,了解我们如何收集、使用、存储和保护您的个人信息,以及您享有的相关权利。点击“同意并进入”表示您已阅读并同意隐私政策内容。
</text>
</scroll-view>
<view class="privacy-actions">
<button class="privacy-button privacy-button-cancel" @click="reject">不同意</button>
<button class="privacy-button privacy-button-confirm" @click="agree">同意并进入</button>
</view>
</view>
</view>
</template>
<script>
const PRIVACY_POLICY_URL = 'https://hbkuaishi.com/yinsi.html'
export default {
onLoad() {
if (uni.getStorageSync('privacyPolicyAgreed')) {
this.goHome()
}
},
methods: {
openPrivacyPolicy() {
uni.navigateTo({
url: '/pages/common/webview?title=' + encodeURIComponent('隐私政策') + '&url=' +
encodeURIComponent(PRIVACY_POLICY_URL)
})
},
agree() {
uni.setStorageSync('privacyPolicyAgreed', true)
const app = getApp()
const appVm = app && (app.$vm || app)
if (appVm && appVm.initAfterPrivacyAgreement) {
appVm.initAfterPrivacyAgreement()
} else if (app && app.globalData && app.globalData.initAfterPrivacyAgreement) {
app.globalData.initAfterPrivacyAgreement()
}
this.goHome()
},
reject() {
uni.showModal({
title: '提示',
content: '需要同意《隐私政策》后才能继续使用本应用。',
confirmText: '查看政策',
cancelText: '退出应用',
success: (res) => {
if (res.confirm) {
this.openPrivacyPolicy()
} else {
this.quitApp()
}
}
})
},
quitApp() {
// #ifdef APP-PLUS
if (typeof plus !== 'undefined' && plus.runtime && plus.runtime.quit) {
plus.runtime.quit()
return
}
// #endif
uni.showToast({
title: '请同意隐私政策后继续使用',
icon: 'none'
})
},
goHome() {
uni.reLaunch({
url: '/pages/index/index'
})
}
}
}
</script>
<style>
page {
width: 100%;
height: 100%;
}
.privacy-page {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.45);
}
.privacy-card {
width: 620rpx;
padding: 40rpx 32rpx 32rpx;
border-radius: 20rpx;
background: #fff;
box-sizing: border-box;
}
.privacy-title {
color: #333;
font-size: 34rpx;
font-weight: 700;
text-align: center;
}
.privacy-content {
max-height: 420rpx;
margin-top: 28rpx;
color: #555;
font-size: 28rpx;
line-height: 46rpx;
}
.privacy-link {
color: #FF5725;
font-weight: 700;
}
.privacy-actions {
display: flex;
flex-direction: row;
margin-top: 36rpx;
}
.privacy-button {
flex: 1;
height: 78rpx;
border-radius: 39rpx;
font-size: 28rpx;
line-height: 78rpx;
}
.privacy-button-cancel {
margin-right: 20rpx;
color: #666;
background: #f2f2f2;
}
.privacy-button-confirm {
color: #fff;
background: #FF5725;
}
</style>
Loading…
Cancel
Save