推送,分享

This commit is contained in:
scout 2024-12-11 15:31:56 +08:00
parent c2168272de
commit 446498b893
7 changed files with 67 additions and 40 deletions

BIN
files/pushicon/18.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
files/pushicon/24.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

BIN
files/pushicon/36.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

BIN
files/pushicon/48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
files/pushicon/72.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -2,8 +2,8 @@
"name" : "oa考勤系统",
"appid" : "__UNI__4796942",
"description" : "",
"versionName" : "2.1.7",
"versionCode" : 217,
"versionName" : "2.2.0",
"versionCode" : 220,
"transformPx" : false,
/* 5+App */
"app-plus" : {
@ -82,7 +82,20 @@
"push" : {
"unipush" : {
"offline" : true,
"version" : "2"
"oppo" : {},
"vivo" : {},
"mi" : {},
"honor" : {},
"version" : "2",
"icons" : {
"small" : {
"ldpi" : "unpackage/pushicon/18.png",
"mdpi" : "unpackage/pushicon/24.png",
"hdpi" : "unpackage/pushicon/36.png",
"xhdpi" : "unpackage/pushicon/48.png",
"xxhdpi" : "unpackage/pushicon/72.png"
}
}
}
},
"maps" : {}

View File

@ -2,7 +2,7 @@
<web-view class="webview" @message="webLoad" style="flex: 1;" :src="config.h5Url"></web-view>
</template>
<script setup>
import { ref } from 'vue'
import { ref, onMounted } from 'vue'
import { onExit, onShow } from "@dcloudio/uni-app";
import config from "../../config"
onShow(() => {
@ -17,43 +17,15 @@ onShow(() => {
// bottom: 0,
// });
// }
// const currentPages = getCurrentPages()
// const currentWebview = currentPages[currentPages.length - 1].$getAppWebview()
// currentWebview.append(wv)
// var pages = getCurrentPages();
// var page = pages[pages.length - 1];
// var currentWebview = page.$getAppWebview();
})
//
import { Communication } from '../../utils/communication.js';
const commun = new Communication()
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',
@ -116,12 +88,17 @@ const shareH5 = () => {
// }
// }
// })
const webLoad = (e) => {
const message = e.detail.data?.[0] || '';
commun.handleMessage(message);
};
function initializeWebView() {
const currentWebview = getCurrentPages().pop().$getAppWebview()
commun.setWebView(currentWebview.children()[0])
}
//load-complete
commun.registerHandler('load-complete', () => {
initializeWebView()
const { statusBarHeight } = uni.getSystemInfoSync()
commun.webViewObj.setStyle({
@ -130,6 +107,7 @@ commun.registerHandler('load-complete', () => {
})
})
commun.registerHandler('getLocation', (data) => {
uni.getLocation({
type: 'gcj02',
@ -142,10 +120,46 @@ commun.registerHandler('getLocation', (data) => {
},
})
})
const webLoad = (e) => {
const message = e.detail.data?.[0] || '';
commun.handleMessage(message);
};
commun.registerHandler('goCard', async (data) => {
await getCard(data.phone)
})
//
async function getCard(phone) {
uni.request({
url: 'https://blockchain.szjixun.cn/api/e_card/info-phone',
method: 'POST',
data: {
phone: phone
},
success: (res) => {
const resData = res.data.data
uni.share({
provider: 'weixin',
scene: "WXSceneSession",
type: 5,// 5
imageUrl: 'https://e-cdn.fontree.cn/fonchain-main/prod/image/139/avatar/ababc42c-7654-47f8-b22b-29dc589c71f0.png', //
title: `${resData.name}的电子名片`,
miniProgram: {
id: "gh_97094c34debd",
path: `/pages/mine/index?uid=${resData.uid}&userType=${resData.userType}`,
type: 0,
webUrl: `/pages/mine/index?uid=${resData.uid}&userType=${resData.userType}`,
},
success: function (res) {
console.log("success:" + JSON.stringify(res));
},
fail: function (err) {
console.log("fail:" + JSON.stringify(err));
}
});
},
fail: (err) => {
console.log('getCard', err)
}
})
}
</script>
<style></style>