This commit is contained in:
caiyx 2024-12-04 16:36:57 +08:00
commit 022aaa9109
5 changed files with 120 additions and 70 deletions

View File

@ -1,4 +1,5 @@
<script>
export default {
data() {
return {
@ -8,7 +9,7 @@ export default {
},
methods: {
// APP
isFirstOpen(){
isFirstOpen() {
let isFirstOpen = uni.getStorageSync('isFirstOpen')
if (!isFirstOpen) {
uni.setStorageSync('isFirstOpen', true)
@ -17,6 +18,7 @@ export default {
return false
},
networkStatusChange(res) {
console.log(res)
if (res.isConnected) {
//
if (this.isFirstOpen()) {
@ -50,6 +52,8 @@ export default {
}
},
onLaunch: function () {
console.log('onLaunch')
},
onShow: function () {
uni.onNetworkStatusChange(this.networkStatusChange);
@ -63,7 +67,7 @@ export default {
}
}
})
},
onHide: function () {
uni.offNetworkStatusChange(this.networkStatusChange)

View File

@ -2,8 +2,8 @@
"name" : "oa考勤系统",
"appid" : "__UNI__4796942",
"description" : "",
"versionName" : "2.1.6",
"versionCode" : 216,
"versionName" : "2.1.7",
"versionCode" : 217,
"transformPx" : false,
/* 5+App */
"app-plus" : {
@ -26,7 +26,8 @@
"Maps" : {},
"LivePusher" : {},
"Push" : {},
"Barcode" : {}
"Barcode" : {},
"Share" : {}
},
/* */
"distribute" : {
@ -74,8 +75,8 @@
"ad" : {},
"share" : {
"weixin" : {
"appid" : "",
"UniversalLinks" : ""
"appid" : "wx3a0f78634d074b23",
"UniversalLinks" : "https://warehouse.szjixun.cn/oa_backend/static/aretree/"
}
},
"push" : {

View File

@ -1,76 +1,121 @@
<template>
<!-- <web-view class="webview" @message="webLoad" style="flex: 1;" :src="config.h5Url"></web-view> -->
<web-view class="webview" @message="webLoad" style="flex: 1;" :src="config.h5Url"></web-view>
</template>
<script setup>
import { ref } from 'vue'
import { onExit, onShow, onLoad } from "@dcloudio/uni-app";
import { onExit, onShow } from "@dcloudio/uni-app";
import config from "../../config"
onShow(() => {
const { statusBarHeight } = uni.getSystemInfoSync()
const wv1 = plus.webview.getWebviewById("custom-webview");
let wv = null;
if (wv1) {
wv = wv1;
} else {
wv = plus.webview.create(config.h5Url, "custom-webview", {
top: statusBarHeight,
bottom: 0,
});
}
const currentPages = getCurrentPages()
const currentWebview = currentPages[currentPages.length - 1].$getAppWebview()
currentWebview.append(wv)
// const { statusBarHeight } = uni.getSystemInfoSync()
// const wv1 = plus.webview.getWebviewById("custom-webview");
// let wv = null;
// if (wv1) {
// wv = wv1;
// } else {
// wv = plus.webview.create(config.h5Url, "custom-webview", {
// top: statusBarHeight,
// bottom: 0,
// });
// }
// const currentPages = getCurrentPages()
// const currentWebview = currentPages[currentPages.length - 1].$getAppWebview()
// currentWebview.append(wv)
})
//
import { Communication } from '../../utils/communication.js';
const commun = new Communication()
import {
registerRequestPermissionTipsListener,
unregisterRequestPermissionTipsListener,
setRequestPermissionTips
} from "@/uni_modules/uni-registerRequestPermissionTips"
const PermissionTips = {
"android.permission.READ_PHONE_STATE": "<h4 style=\"font-size:40px;\">正在读取网络状态权限</h4><font color=#cccccc>通讯录权限不会获取任何信息,请注意通讯录权限不会获取任何信息,请注意通讯录权限不会获取任何信息,请注意</font>",
"android.permission.CAMERA": "<h4 style=\"font-size:40px;\">正在访问相机权限</h4><font color=#cccccc>需要扫描二维码或拍照,是否允许打开相机?</font>",
"android.permission.WRITE_EXTERNAL_STORAGE": "<h4 style=\"font-size:40px;\">正在读取相册权限</h4><font color=#cccccc>我们需要获取访问您设备相册的权限,以便您能够选择并上传图片或视频到我们的应用中。</font>"
}
onExit(() => {
unregisterRequestPermissionTipsListener()
})
const brand = uni.getSystemInfoSync().deviceBrand
setRequestPermissionTips(PermissionTips)
registerRequestPermissionTipsListener({
onRequest: (e) => {
console.log('onRequest', e)
},
onConfirm: (e) => {
commun.sendToH5('permission-application', { action: 'open-permission', data: e });
},
onComplete: (e) => {
commun.sendToH5('permission-application', { action: 'close-permission', data: e });
//
if (brand.toLowerCase() === "huawei") {
const tips = {}
let hasDeniedPermission = false
for (let k in PermissionTips) {
if (e[k] !== "denied") {
tips[k] = PermissionTips[k]
} else {
hasDeniedPermission = true
}
}
setRequestPermissionTips(tips) //
if (hasDeniedPermission)
uni.showModal({
content: "权限已经被拒绝,请前往设置中开启"
})
const share = () => {
uni.getProvider({
service: "share",
success: (res) => {
console.log(res)
}
}
})
})
uni.share({
provider: 'weixin',
scene: "WXSceneSession",
type: 5,// 5
imageUrl: 'https://th.bing.com/th?id=ORMS.41c34644e7e67f95a14620e77064b5d9&pid=Wdp&w=268&h=140&qlt=90&c=1&rs=1&dpr=1&p=0', //
title: '分享的标题',
miniProgram: {
id: "gh_97094c34debd",
path: "/pages/index/index",
type: 0,
webUrl: '/#/pages/list/detail',
},
success: function (res) {
console.log("success:" + JSON.stringify(res));
},
fail: function (err) {
console.log("fail:" + JSON.stringify(err));
}
});
}
const shareH5 = () => {
uni.share({
provider: 'weixin',
scene: "WXSceneSession",
type: 0,// 5
imageUrl: 'https://th.bing.com/th?id=ORMS.41c34644e7e67f95a14620e77064b5d9&pid=Wdp&w=268&h=140&qlt=90&c=1&rs=1&dpr=1&p=0', //
title: '分享的标题',
href: 'https://www.baidu.com/',
success: function (res) {
console.log("success:" + JSON.stringify(res));
},
fail: function (err) {
console.log("fail:" + JSON.stringify(err));
}
});
}
// import {
// registerRequestPermissionTipsListener,
// unregisterRequestPermissionTipsListener,
// setRequestPermissionTips
// } from "@/uni_modules/uni-registerRequestPermissionTips"
// const PermissionTips = {
// "android.permission.READ_PHONE_STATE": "<h4 style=\"font-size:40px;\"></h4><font color=#cccccc></font>",
// "android.permission.CAMERA": "<h4 style=\"font-size:40px;\">访</h4><font color=#cccccc></font>",
// "android.permission.WRITE_EXTERNAL_STORAGE": "<h4 style=\"font-size:40px;\"></h4><font color=#cccccc>访便</font>"
// }
// onExit(() => {
// unregisterRequestPermissionTipsListener()
// })
// const brand = uni.getSystemInfoSync().deviceBrand
// setRequestPermissionTips(PermissionTips)
// registerRequestPermissionTipsListener({
// onRequest: (e) => {
// console.log('onRequest', e)
// },
// onConfirm: (e) => {
// commun.sendToH5('permission-application', { action: 'open-permission', data: e });
// },
// onComplete: (e) => {
// commun.sendToH5('permission-application', { action: 'close-permission', data: e });
// //
// if (brand.toLowerCase() === "huawei") {
// const tips = {}
// let hasDeniedPermission = false
// for (let k in PermissionTips) {
// if (e[k] !== "denied") {
// tips[k] = PermissionTips[k]
// } else {
// hasDeniedPermission = true
// }
// }
// setRequestPermissionTips(tips) //
// if (hasDeniedPermission)
// uni.showModal({
// content: ""
// })
// }
// }
// })
function initializeWebView() {
const currentWebview = getCurrentPages().pop().$getAppWebview()
commun.setWebView(currentWebview.children()[0])