提交 cf5db1bb 编写于 作者: M mahaifeng

[opentype]删掉多余示例代码

上级 425161ed
let page;
describe('open-type', () => {
if (!isAndroid()) {
// TODO: web 端暂不支持测试
it('web', async () => {
expect(1).toBe(1)
})
return
}
beforeAll(async () => {
page = await program.reLaunch('/pages/component/open-type/open-type')
await page.waitFor(600);
});
it('opentype-test', async () => {
if (!isAndroid()) {
return
}
const opentype = await page.$('#opentype')
await opentype.tap()
let isAgreeRes = await getData('isAgreeRes')
expect(isAgreeRes).toBe(true)
})
function isAndroid() {
if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW ===
'true') {
expect(1).toBe(1)
return false
}
if (process.env.uniTestPlatformInfo.toLocaleLowerCase().startsWith('ios')) {
expect(1).toBe(1)
return false
}
return true
}
function getData(key = '') {
return new Promise(async (resolve, reject) => {
const data = await page.data()
resolve(key ? data[key] : data)
})
}
});
<template>
<!-- #ifdef APP -->
<scroll-view style="flex:1">
<!-- #endif -->
<button id="opentype" style="margin: 12px;" type="primary"
open-type="agreePrivacyAuthorization">agreePrivacyAuthorization</button>
<button style="margin: 12px;" type="warn" @click="reset">resetPrivacyAuthorization</button>
<text style="margin: 12px; color:red; font-size: 18px;">当前隐私政策状态:{{ state }}</text>
<text style="margin: 12px; color:darkred; font-size: 16px;">true = 已同意隐私协议; false = 未同意隐私协议</text>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
export default {
data() {
return {
isAgreeRes: false,
log: "",
number: 0,
state: false
}
},
unmounted() {
console.log('unmounted', this.number)
uni.offPrivacyAuthorizationChange(this.number)
},
onLoad() {
uni.getPrivacySetting({
success: (res) => {
this.state = !res.needAuthorization
}
})
this.number = uni.onPrivacyAuthorizationChange((callback) => {
this.isAgreeRes = !callback.needAuthorization
this.state = this.isAgreeRes
uni.showToast({
title: 'isPrivacyAgree:' + this.isAgreeRes
})
})
},
methods: {
reset() {
uni.resetPrivacyAuthorization()
}
}
}
</script>
<style>
</style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册