提交 1fa90363 编写于 作者: 芊里

Merge branch 'master' of https://gitee.com/dcloud/base-app

{
"router":{
"needLogin":[
"/pages/grid/grid"
"/pages/ucenter/edit/edit",
"/uni_modules/uni-login-page/pages/index/pwd-retrieve"
]
},
"aboutus":{
"appName":"base-app",
"company":"数字天堂(北京)网络技术有限公司",
"slogan":"为开发而生",
"agreement":{
"privacy":"https://uniapp.dcloud.io/",
"business":"https://uniapp.dcloud.io/"
}
}
}
\ No newline at end of file
import baseappConfig from '@/baseapp.config.json';
// #ifdef APP-PLUS
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
import callCheckVersion from '@/uni_modules/uni-upgrade-center-app/utils/call-check-version';
......@@ -8,11 +9,50 @@ export default function() {
initAppVersion();
//自定义路由拦截
setRouter()
const {"router":{needLogin}} = baseappConfig //需要登陆的页面
changeAction(["navigateTo", "redirectTo", "reLaunch", "switchTab"], {
before_action: e => {
let token = uni.getStorageSync('uni-id-token')
if (needLogin.includes(e.url) && token == '') {
console.log('该页面需要登陆,即将跳转到login页面');
uni.showToast({title:'该页面需要登陆,即将跳转到login页面',icon:'none'})
uni.redirectTo({
url:"/uni_modules/uni-login-page/pages/index/index"
})
return false
}
return true
}
})
//提示网络变化
eventListenerNetwork()
/*
当某个权限调用失败
1.先检测手机的该模块是否打开
2.检测当前应用是否被授权了该模块对应的权限
提示,并点击跳转到设置
*/
// #ifndef H5
// changeAction('chooseImage', {
// after_action: e => {
// console.log('changeAction', e);
// if(e.errCode === 11){
// uni.showModal({
// content: '无权限',
// confirmText:"前往设置",
// success(e) {
// if(e.confirm){
// permision.gotoAppPermissionSetting()
// }
// }
// });
// }
// }
// })
// #endif
}
/**
* // 初始化appVersion
......@@ -46,41 +86,6 @@ function initAppVersion() {
checkUpdate();
// #endif
}
//用于拦截路由
import baseappConfig from '@/baseapp.config.json';
console.log('baseappConfig',baseappConfig);
const {"router":{needLogin}} = baseappConfig //需要登陆的页面
function setRouter() {
let before_action = e => {
let res = true
let token = uni.getStorageSync('uni-id-token')
if (needLogin.includes(e.url) && token == '') {
res = false
console.log('该页面需要登陆,即将跳转到login页面');
}
return res
}
let before_after = e => {
console.log('跳转之后');
}
let actions = ["navigateTo", "redirectTo", "reLaunch", "switchTab"]
actions.forEach(action => {
let old_action = uni[action]
uni[action] = e => {
//console.log(e);
if (before_action(e)) {
old_action(e)
before_after(e)
}
}
})
uni.reLaunch({
url: '/pages/grid/grid'
})
}
// 设备网络状态变化事件
function eventListenerNetwork () {
......@@ -109,4 +114,31 @@ function eventListenerNetwork () {
});
}
});
}
function changeAction(actions, {before_action,after_action}) {
if(typeof actions == 'string'){
actions = [actions]
}
if (!before_action) {
before_action = () => true
}
actions.forEach(action=>{
let old_action = uni[action]
uni[action] = e => {
if (before_action(e)) {
console.log(after_action);
if (after_action) {
var compose = function(f, g) {
return function(x) {
return f(x,g(x));
};
};
e.complete = compose(e.complete,after_action)
}
old_action(e)
}
}
})
}
\ No newline at end of file
......@@ -7,7 +7,7 @@
*/
const debug = true;//开启后,会alert错误信息
export default function request(name,params,callback=false,{showLoading=false,loadText='',fail=()=>{}}={}){
console.log('request');
// console.log('request');
showLoading||loadText? uni.showLoading({title:loadText}):'';
let routers = name.split('/');
......@@ -16,7 +16,7 @@ export default function request(name,params,callback=false,{showLoading=false,lo
name = routers[0]
action = routers[1]
}
// console.log({name,data: {action,params}})
console.log({name,data: {action,params}})
return new Promise((resolve,reject)=>{
uniCloud.callFunction({name,data: {action,params},
success(e){
......
......@@ -18,27 +18,32 @@
},
/* 模块配置 */
"modules" : {
"OAuth" : {}
"OAuth" : {},
"Fingerprint" : {},
"Share" : {},
"Push" : {}
},
/* 应用发布信息 */
"distribute" : {
/* android打包配置 */
"android" : {
"permissions" : [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.USE_FINGERPRINT\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
......@@ -54,7 +59,17 @@
"UniversalLinks" : ""
}
},
"ad" : {}
"ad" : {},
"share" : {
"weixin" : {
"appid" : "wxffdd8fa6ec4ef2a0",
"UniversalLinks" : ""
}
},
"geolocation" : {},
"push" : {
"unipush" : {}
}
}
}
},
......
......@@ -188,15 +188,24 @@
}
}
,{
"path" : "pages/test/test",
"style" :
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
,{
"path" : "pages/test/test",
"style" :
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
,{
"path" : "pages/common/webview/webview",
"style" :
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
......
<template>
<view>
<web-view :src="url"></web-view>
</view>
</template>
<script>
export default {
onLoad({url,title}) {
console.log(url,title);
this.url = url;
if(title){
uni.setNavigationBarTitle({title});
}
},
data() {
return {
url:null
};
}
}
</script>
<style lang="scss">
</style>
<template>
<view class="about">
<view class="content">
<view class="qrcode">
<image src="https://img.cdn.aliyun.dcloud.net.cn/guide/uniapp/app_download.png" @longtap="save"></image>
<text class="tip">扫码体验uni-app</text>
</view>
<view class="desc">
<text class="code">uni-app</text>
是一个使用 <text class="code">Vue.js</text> 开发跨平台应用的前端框架。
</view>
<view class="source">
<view class="title">本示例源码获取方式:</view>
<view class="source-list">
<view class="source-cell">
<text space="nbsp">1. </text>
<text>下载 HBuilderX,新建 uni-app 项目时选择 <text class="code">Hello uni-app</text> 模板。</text>
</view>
<view class="source-cell">
<text space="nbsp">2. </text>
<u-link class="link" :href="'https://github.com/dcloudio/hello-uniapp'" :text="'https://github.com/dcloudio/hello-uniapp'"></u-link>
</view>
</view>
</view>
<!-- #ifdef APP-PLUS -->
<button type="primary" @click="share">分享</button>
<!-- #endif -->
<view class="aboutus">
<view class="logo">
<image class="logoImg" src="@/static/logo.png"></image>
<text class="tip appName">{{aboutus.appName}}</text>
<text class="tip" style="font-size:24upx;">Version {{version}}</text>
</view>
<!-- #ifdef APP-PLUS -->
<view class="version">
当前版本:{{version}}
<view class="copyright">
<text class="agreement" @click="navigateTo(aboutus.agreement.privacy,'用户服务协议')">《用户服务协议》</text>
<text class="hint"></text>
<text class="agreement" @click="navigateTo(aboutus.agreement.business,'隐私政策')">《隐私政策》</text>
<text class="hint">Copyright © {{year}}</text>
<text class="hint">{{aboutus.company}}</text>
</view>
<!-- #endif -->
</view>
</template>
<script>
import baseappConfig from '@/baseapp.config.json';
export default {
data() {
return {
providerList: [],
version: ''
}
},
onLoad() {
// #ifdef APP-PLUS
this.version = plus.runtime.version;
uni.getProvider({
service: 'share',
success: (result) => {
const data = [];
for (let i = 0; i < result.provider.length; i++) {
switch (result.provider[i]) {
case 'weixin':
data.push({
name: '分享到微信好友',
id: 'weixin'
});
data.push({
name: '分享到微信朋友圈',
id: 'weixin',
type: 'WXSenceTimeline'
});
break;
case 'qq':
data.push({
name: '分享到QQ',
id: 'qq'
});
break;
default:
break;
}
}
this.providerList = data;
},
fail: (error) => {
console.log('获取分享通道失败' + JSON.stringify(error));
}
});
this.version = plus.runtime.version
// #endif
},
methods: {
// #ifdef APP-PLUS
save() {
uni.showActionSheet({
itemList: ['保存图片到相册'],
success: () => {
plus.gallery.save('https://img.cdn.aliyun.dcloud.net.cn/guide/uniapp/app_download.png', function() {
uni.showToast({
title: '保存成功',
icon: 'none'
});
}, function() {
uni.showToast({
title: '保存失败,请重试!',
icon: 'none'
});
});
}
data() {
return {
version:"V1.0.0",
year:"2020",
aboutus:{}
};
},
created() {
this.aboutus = baseappConfig.aboutus
this.year = (new Date).getFullYear()
},
methods:{
navigateTo(url,title){
uni.navigateTo({
url: '/pages/common/webview/webview?url='+url+'&title='+title,
success: res => {},
fail: () => {},
complete: () => {}
});
},
share(e) {
if (this.providerList.length === 0) {
uni.showModal({
title: '当前环境无分享渠道!',
showCancel: false
});
return;
}
let itemList = this.providerList.map(function(value) {
return value.name;
})
uni.showActionSheet({
itemList: itemList,
success: (res) => {
let provider = this.providerList[res.tapIndex].id;
uni.share({
provider: provider,
scene: this.providerList[res.tapIndex].type && this.providerList[res.tapIndex].type === 'WXSenceTimeline' ?
'WXSenceTimeline' : "WXSceneSession",
type: (provider === "qq") ? 1 : 0,
title: '欢迎体验uni-app',
summary: 'uni-app 是一个使用 Vue.js 开发跨平台应用的前端框架',
imageUrl: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b09e38e0-5168-11eb-b680-7980c8a877b8.jpg',
href: "https://m3w.cn/uniapp",
success: (res) => {
console.log("success:" + JSON.stringify(res));
},
fail: (e) => {
uni.showModal({
content: e.errMsg,
showCancel: false
})
}
});
}
})
}
// #endif
}
}
</script>
<style>
page,
view {
display: flex;
}
page {
min-height: 100%;
background-color: #FFFFFF;
}
image {
width: 360rpx;
height: 360rpx;
}
.about {
flex-direction: column;
flex: 1;
}
.content {
flex: 1;
padding: 30rpx;
flex-direction: column;
justify-content: center;
}
.qrcode {
display: flex;
align-items: center;
flex-direction: column;
}
.qrcode .tip {
margin-top: 20rpx;
}
.desc {
margin-top: 30rpx;
display: block;
}
.code {
color: #e96900;
background-color: #f8f8f8;
/* #ifndef APP-NVUE */
display: inline-block;
/* #endif */
}
button {
width: 100%;
margin-top: 40rpx;
}
.version {
height: 80rpx;
line-height: 80rpx;
justify-content: center;
color: #ccc;
text-align: center;
}
.source {
margin-top: 30rpx;
flex-direction: column;
}
.source-list {
flex-direction: column;
}
.link {
color: #007AFF;
}
</style>
<style lang="scss" scoped>
.aboutus {
width: 750upx;
flex-direction: column;
}
.logo {
width: 750upx;
position: fixed;
left:0;
top:100px;
flex-direction: column;
justify-content: center;
align-items: center;
}
.logoImg{
margin-bottom: 10upx;
width:160upx;
height:160upx;
border-radius: 15px;
}
.appName{
margin-top: 20px;
margin-bottom:5px;
font-size:42rpx;
font-weight: 500;
}
.copyright {
width: 750upx;
font-size:32rpx;
flex-direction: column;
justify-content: center;
align-items: center;
bottom:20px;
left: 0;
position: fixed;
}
.agreement {
color:#2285ff;
font-size:26rpx;
}
.hint {
color:#999999;
font-size:26rpx;
}
</style>
\ No newline at end of file
......@@ -104,8 +104,6 @@
width: 150rpx;
height: 150rpx;
border-radius: 75rpx;
border-width: 1rpx;
border-color: #999999;
border: #F8F8F8 solid 1px;
}
</style>
......@@ -2,12 +2,15 @@
<view class="content">
<!-- 功能列表 -->
<uni-list class="content">
<uni-list-item v-for="(item,index) in agreeList" :key="index" :title="item.title" :to="item.to"
<uni-list-item v-for="(item,index) in agreeList" :key="index" :title="item.title"
:clickable="true" @click="itemClick(item)" :showSwitch="item.showSwitch" :switchChecked="item.isChecked"
:link="item.to"></uni-list-item>
:link="!item.showSwitch"></uni-list-item>
</uni-list>
<!-- 退出按钮 -->
<button class="bottom-back" @click="clickLogout"><text class="bottom-back-text">退出登录</text></button>
<!-- 退出按钮 -->
<button class="bottom-back" @click="clickLogout">
<text class="bottom-back-text" v-if="userInfo">退出登录</text>
<text class="bottom-back-text" v-else>登录</text>
</button>
</view>
</template>
......@@ -68,22 +71,24 @@
logout: 'user/logout'
}),
toEdit(){
uni.navigateTo({
url: '../edit/edit'
url: '/pages/ucenter/edit/edit'
});
},
changePwd(){
if(this.userInfo){
uni.navigateTo({
url:'/uni_modules/uni-login-page/pages/index/pwd-retrieve?phoneNumber='+ (this.userInfo.phone||'') +'&phoneArea=+86'
});
} else {
uni.showToast({
title: '请先登录',
icon: 'none'
});
}
uni.navigateTo({
url:'/uni_modules/uni-login-page/pages/index/pwd-retrieve?phoneNumber='+ (this.userInfo.phone||'') +'&phoneArea=+86'
});
// if(this.userInfo){
// uni.navigateTo({
// url:'/uni_modules/uni-login-page/pages/index/pwd-retrieve?phoneNumber='+ (this.userInfo.phone||'') +'&phoneArea=+86'
// });
// } else {
// uni.showToast({
// title: '请先登录',
// icon: 'none'
// });
// }
},
checkPush(){
// 手机端获取推送是否开启
......@@ -186,21 +191,26 @@
})
},
clickLogout() {
uni.showModal({
title: '提示',
content: '是否退出登录',
cancelText: '取消',
confirmText: '确定',
success: res => {
if(res.confirm){
this.logout();
uni.navigateBack();
}
},
fail: () => {},
complete: () => {}
});
if(this.userInfo){
uni.showModal({
title: '提示',
content: '是否退出登录',
cancelText: '取消',
confirmText: '确定',
success: res => {
if(res.confirm){
this.logout();
uni.navigateBack();
}
},
fail: () => {},
complete: () => {}
});
}else{
uni.navigateTo({
url: '/uni_modules/uni-login-page/pages/index/index'
});
}
},
itemClick(item) {
if (!item.to && item.event) {
......@@ -252,11 +262,12 @@
border: none;
/* #endif */
border-width: 0;
border-radius: 0;
border-radius: 0;
background-color: #007AFF;
}
.bottom-back-text {
font-size: 40rpx;
color: #DD524D;
color: #FFFFFF;
}
</style>
<template>
<view class="center">
<view class="userInfo" @click="goLogin" :hover-class="!login ? 'logo-hover' : ''">
<navigator url="/pages/ucenter/settings/settings" class="userInfo">
<image class="logo-img" :src="login ? (userInfo.avatar || avatarUrl) :avatarUrl"></image>
<view class="logo-title">
<text class="uer-name">{{login ? userInfo.nickname||userInfo.mobile : '未登录'}}</text>
<text class="uer-name">{{login ? userInfo.username||userInfo.mobile : '未登录'}}</text>
<text class="go-login-navigat-arrow navigat-arrow" v-if="!login">&#xe65e;</text>
</view>
</view>
</navigator>
<uni-grid class="grid" :column="5" :showBorder="false" :square="true">
<uni-grid-item class="item" v-for="({text,icon},index) in gridList" @click.native="tapGrid(index)">
<uni-icons class="icon" color="#5d5e64" :type="icon" size="28"></uni-icons>
......@@ -180,9 +180,9 @@
align-items: center;
}
.logo-hover {
/* .logo-hover {
opacity: 0.8;
}
} */
.logo-img {
width: 150rpx;
......
## 3.0.12(2021-04-13)
- 调整bindTokenToDevice默认值为false
## 3.0.11(2021-04-12)
- 修复3.0.7版本引出的多个用户访问时可能出现30201报错的Bug
## 3.0.10(2021-04-08)
......
{
"id": "uni-id",
"displayName": "uni-id",
"version": "3.0.11",
"version": "3.0.12",
"description": "简单、统一、可扩展的用户中心",
"keywords": [
"uniid",
......
{
"name": "uni-id",
"version": "3.0.11",
"version": "3.0.12",
"description": "uni-id for uniCloud",
"main": "index.js",
"homepage": "https://uniapp.dcloud.io/uniCloud/uni-id",
......
......@@ -11,7 +11,7 @@ exports.main = async (event, context) => {
context
})
//event为客户端上传的参数
console.log('event : ' + event)
console.log('event : ' + JSON.stringify(event))
let params = event.params || {}
//防止黑客恶意破解登陆,连续登陆失败一定次数后,需要用户提供验证码
......@@ -107,6 +107,11 @@ exports.main = async (event, context) => {
break;
case 'login_by_weixin':
res = await uniID.loginByWeixin(params);
await uniID.updateUser({
uid: params.uid,
username:"微信用户"
});
res.userInfo.username = "微信用户"
loginLog(res)
break;
case 'login_by_univerify':
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册