wangfukang 2 weeks ago
parent
commit
00187f02c3
  1. 51
      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

51
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,9 +64,38 @@
registrationID: '', registrationID: '',
printData: [], // 打印任务队列,按顺序存储待打印的通知数据 printData: [], // 打印任务队列,按顺序存储待打印的通知数据
isPrinting: false, // 标记当前是否正在打印,防止并发 isPrinting: false, // 标记当前是否正在打印,防止并发
privacyInitialized: false,
initAfterPrivacyAgreement: null,
}, },
onLaunch: function() { onLaunch: function() {
let context = this; let context = this;
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.globalData.initAfterPrivacyAgreement = () => this.initAfterPrivacyAgreement()
return this.initAfterPrivacyAgreement()
},
computed: {
i18n() {
return this.$t('index')
},
},
methods: {
initAfterPrivacyAgreement() {
if (!uni.getStorageSync('privacyPolicyAgreed')) {
return
}
if (this.globalData.privacyInitialized) {
return
}
this.globalData.privacyInitialized = true
// #ifdef APP-PLUS
jpushModule = uni.requireNativePlugin("JG-JPush");
audioObj = uni.getBackgroundAudioManager();
// #endif
const baseUrl = getApp().globalData.mainurl const baseUrl = getApp().globalData.mainurl
//这里是热更新的代码 //这里是热更新的代码
// #ifdef APP-PLUS // #ifdef APP-PLUS
@ -86,7 +115,7 @@
console.log('install success...'); console.log('install success...');
plus.runtime.restart(); plus.runtime.restart();
}, function(e) { }, function(e) {
console.error('install fail...',e); console.error('install fail...', e);
}); });
} }
} }
@ -95,12 +124,6 @@
} }
}); });
// #endif // #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() // this.getRegistrationID()
// #ifdef APP-PLUS // #ifdef APP-PLUS
if (jpushModule.setLoggerEnable) { if (jpushModule.setLoggerEnable) {
@ -217,7 +240,7 @@
// #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()
} }
@ -237,12 +260,6 @@
}); });
} }
}, },
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