推送 云函数 一键登录

This commit is contained in:
haomingming 2025-09-30 16:42:25 +08:00
parent 570e47698c
commit 65b2d269c5
11 changed files with 203 additions and 48 deletions

19
App.vue
View File

@ -53,11 +53,28 @@ export default {
uni.onPushMessage((res)=>{
console.log("收到推送消息:", res)
uni.showModal({
uni.showModal({
title: res.data.title,
content: res.type,
showCancel: false
});
if(res.type === 'click' ){
}else{
uni.createPushMessage({
title: res.data.title,
content: res.data.content,
payload: res.data.payload,
delay: 1,
success: (res) => {
console.log("创建推送消息成功", res)
}
})
}
})
/** 设置语言 此处为了方便demo切换语言将其存到本地实际需根据业务情况设置*/

View File

@ -2,8 +2,8 @@
"name" : "肝胆相照专家端",
"appid" : "__UNI__89F511F",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "100",
"versionName" : "4.1.5",
"versionCode" : 415,
"transformPx" : false,
"app-plus" : {
/* 5+App */
@ -59,7 +59,8 @@
"appid" : "wxbf3658f5e674667c",
"appsecret" : "c4505a04a9910c65efea8e11ffc93f92",
"UniversalLinks" : "https://doc.igandan.com/gdxzExpert/"
}
},
"univerify" : {}
},
"payment" : {
"weixin" : {

View File

@ -85,6 +85,13 @@
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path" : "pages/univerify/univerify",
"style" :
{
"navigationBarTitleText" : ""
}
}
],

View File

@ -777,7 +777,6 @@ const switchPushPermissions = () => {
width: 120rpx;
height: 120rpx;
border-radius: 10rpx;
}
.user-info-content {
@ -785,6 +784,7 @@ const switchPushPermissions = () => {
flex-direction: column;
align-items: flex-start;
gap: 10rpx;
margin-left: 10rpx;
.username {
color: $white;

View File

@ -0,0 +1,105 @@
<template>
<view>
</view>
</template>
<script setup>
import { ref, reactive, onMounted } from 'vue';
import { onShow, onLoad } from "@dcloudio/uni-app";
//
onLoad(() => {
console.log('登录页面加载完成');
// #ifdef APP
console.log('一键登录');
uni.login({
provider: 'univerify',
univerifyStyle: {
"fullScreen": true, // false
"backgroundColor": "#ffffff", // #ffffff
"backgroundImage": "", // ""
"icon": {
"path": "static/xxx.png", // logo App logo
"width": "60px", // 60px
"height": "60px" // 60px
},
"closeIcon": {
"path": "static/xxx.png", // logo
"width": "60px", // 60px (HBuilderX 4.0+ iOS)
"height": "60px" // 60px (HBuilderX 4.0+ iOS)
},
"phoneNum": {
"color": "#202020" // #202020
},
"slogan": {
"color": "#BBBBBB" // slogan #BBBBBB
},
"authButton": {
"normalColor": "#3479f5", // #3479f5
"highlightColor": "#2861c5", // #2861c5ios
"disabledColor": "#73aaf5", // #73aaf5ios
"textColor": "#ffffff", // #ffffff
"title": "本机号码一键登录", //
"borderRadius": "24px" // "24px"
},
"otherLoginButton": {
"visible": true, // true
"normalColor": "", //
"highlightColor": "", //
"textColor": "#656565", // #656565
"title": "其他登录方式", //
"borderColor": "", // iOS
"borderRadius": "0px" // "24px"
},
"privacyTerms": {
"defaultCheckBoxState": true, // true
"isCenterHint": false, // : false (3.7.13+ )
"uncheckedImage": "", // 24x24px(3.2.0+ )
"checkedImage": "", // 24x24px(3.2.0+ )
"checkBoxSize": 12, //
"textColor": "#BBBBBB", // #BBBBBB
"termsColor": "#5496E3", // #5496E3
"prefix": "我已阅读并同意", //
"suffix": "并使用本机号码登录", // 使
"privacyItems": [ // 2urltitle.
{
"url": "https://", //
"title": "用户服务协议" //
}
]
},
"buttons": { // 3.1.14+
"iconWidth": "45px", // 45px
"list": [{
"provider": "apple",
"iconPath": "/static/apple.png" //
},
{
"provider": "weixin",
"iconPath": "/static/wechat.png" //
}
]
}
},
success(res) { //
console.log(res.authResult); // {openid:'',access_token:' token'}
},
fail(res) { //
console.log(res.errCode)
console.log(res.errMsg)
}
})
// #endif
});
//
onShow(() => {
console.log('登录页面显示');
});
</script>
<style>
</style>

View File

@ -138,25 +138,6 @@
}
console.log('一键登录');
uni.showLoading({
title: '登录中2...'
});
//
setTimeout(() => {
uni.hideLoading();
uni.showToast({
title: '登录成功',
icon: 'none'
});
//
setTimeout(() => {
uni.switchTab({
url: '/pages/index/index'
});
}, 1500);
}, 2000);
};
//
@ -342,6 +323,42 @@
//
onLoad(() => {
console.log('登录页面加载完成');
// #ifdef APP
uni.getProvider({
service: 'oauth',
success: function (res) {
console.log(res.provider)// ['qq', 'univerify']
if(res.provider.indexOf('univerify') !== -1){
uni.preLogin({
provider: 'univerify',
success(){ //
//
uni.redirectTo({
url: '/pages/univerify/univerify'
});
},
fail(res){ //
//
//
console.log(res.errCode)
console.log(res.errMsg)
uni.redirectTo({
url: '/pages_app/smsLogin/smsLogin'
});
}
})
}else{
uni.redirectTo({
url: '/pages_app/smsLogin/smsLogin'
});
}
}
});
// #endif
});
//

View File

@ -0,0 +1,8 @@
'use strict';
exports.main = async (event, context) => {
//event为客户端上传的参数
console.log('event : ', event)
//返回数据给客户端
return event
};

View File

@ -0,0 +1,7 @@
{
"name": "univerify",
"dependencies": {},
"extensions": {
"uni-cloud-verify": {}
}
}

View File

@ -3,7 +3,7 @@
const uniPush = uniCloud.getPushManager({appId:"__UNI__89F511F"}) //注意这里需要传入你的应用appId
exports.main = async (event, context) => {
return await uniPush.sendMessage({
"push_clientid": "a297ac02dc531b7d43ff539f3163efcb", //填写上一步在uni-app客户端获取到的客户端推送标识push_clientid
"push_clientid": "58614bcaadae8a6998d166a21e61772f", //填写上一步在uni-app客户端获取到的客户端推送标识push_clientid
"force_notification":true, //填写true客户端就会对在线消息自动创建“通知栏消息”。
"title": "通知栏显示的标题",
"content": "通知栏显示的内容",
@ -13,28 +13,6 @@ exports.main = async (event, context) => {
},
"payload": {
"text":"体验一下uni-push2.0"
},
"category": {
//HarmonyOS NEXT系统纯血鸿蒙、非安卓鸿蒙的消息分类要给鸿蒙设备推送时才必传
"harmony":"MARKETING"
},
"options":{
"HW": {
// 值为int 类型。1 表示华为测试消息华为每个应用每日可发送该测试消息500条。此 target_user_type 参数请勿发布至线上。
"/message/android/target_user_type":1
} ,
"HO": {
//值为int 类型。1 表示测试推送不填默认为0。荣耀每个应用每日可发送该测试消息1000条。此测试参数请勿发布至线上。
"/android/targetUserType": 1
} ,
"VV": {
//值为int 类型。0 表示正式推送1 表示测试推送不填默认为0。此 pushMode 参数请勿发布至线上。
"/pushMode":1
} ,
"XM": {
//新小米消息分类下私信公信id都必须要传否则请求小米厂商接口会被拦截
"/extra.channel_id": "填写小米平台申请的渠道id"
}
}
},
})
};

View File

@ -0,0 +1,8 @@
'use strict';
exports.main = async (event, context) => {
//event为客户端上传的参数
console.log('event : ', event)
//返回数据给客户端
return event
};

View File

@ -0,0 +1,7 @@
{
"name": "univerify",
"dependencies": {},
"extensions": {
"uni-cloud-verify": {}
}
}