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

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

{ {
"router":{ "router":{
"needLogin":[ "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 // #ifdef APP-PLUS
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'; 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'; import callCheckVersion from '@/uni_modules/uni-upgrade-center-app/utils/call-check-version';
...@@ -8,11 +9,50 @@ export default function() { ...@@ -8,11 +9,50 @@ export default function() {
initAppVersion(); 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() 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 * // 初始化appVersion
...@@ -46,41 +86,6 @@ function initAppVersion() { ...@@ -46,41 +86,6 @@ function initAppVersion() {
checkUpdate(); checkUpdate();
// #endif // #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 () { function eventListenerNetwork () {
...@@ -109,4 +114,31 @@ 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 @@ ...@@ -7,7 +7,7 @@
*/ */
const debug = true;//开启后,会alert错误信息 const debug = true;//开启后,会alert错误信息
export default function request(name,params,callback=false,{showLoading=false,loadText='',fail=()=>{}}={}){ export default function request(name,params,callback=false,{showLoading=false,loadText='',fail=()=>{}}={}){
console.log('request'); // console.log('request');
showLoading||loadText? uni.showLoading({title:loadText}):''; showLoading||loadText? uni.showLoading({title:loadText}):'';
let routers = name.split('/'); let routers = name.split('/');
...@@ -16,7 +16,7 @@ export default function request(name,params,callback=false,{showLoading=false,lo ...@@ -16,7 +16,7 @@ export default function request(name,params,callback=false,{showLoading=false,lo
name = routers[0] name = routers[0]
action = routers[1] action = routers[1]
} }
// console.log({name,data: {action,params}}) console.log({name,data: {action,params}})
return new Promise((resolve,reject)=>{ return new Promise((resolve,reject)=>{
uniCloud.callFunction({name,data: {action,params}, uniCloud.callFunction({name,data: {action,params},
success(e){ success(e){
......
...@@ -18,27 +18,32 @@ ...@@ -18,27 +18,32 @@
}, },
/* 模块配置 */ /* 模块配置 */
"modules" : { "modules" : {
"OAuth" : {} "OAuth" : {},
"Fingerprint" : {},
"Share" : {},
"Push" : {}
}, },
/* 应用发布信息 */ /* 应用发布信息 */
"distribute" : { "distribute" : {
/* android打包配置 */ /* android打包配置 */
"android" : { "android" : {
"permissions" : [ "permissions" : [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>", "<uses-feature android:name=\"android.hardware.camera\"/>",
"<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.autofocus\"/>", "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>", "<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.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.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.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.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>" "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
] ]
}, },
...@@ -54,7 +59,17 @@ ...@@ -54,7 +59,17 @@
"UniversalLinks" : "" "UniversalLinks" : ""
} }
}, },
"ad" : {} "ad" : {},
"share" : {
"weixin" : {
"appid" : "wxffdd8fa6ec4ef2a0",
"UniversalLinks" : ""
}
},
"geolocation" : {},
"push" : {
"unipush" : {}
}
} }
} }
}, },
......
...@@ -188,15 +188,24 @@ ...@@ -188,15 +188,24 @@
} }
} }
,{ ,{
"path" : "pages/test/test", "path" : "pages/test/test",
"style" : "style" :
{ {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
} }
,{
"path" : "pages/common/webview/webview",
"style" :
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
], ],
"globalStyle": { "globalStyle": {
"navigationBarTextStyle": "black", "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> <template>
<view class="about"> <view class="aboutus">
<view class="content"> <view class="logo">
<view class="qrcode"> <image class="logoImg" src="@/static/logo.png"></image>
<image src="https://img.cdn.aliyun.dcloud.net.cn/guide/uniapp/app_download.png" @longtap="save"></image> <text class="tip appName">{{aboutus.appName}}</text>
<text class="tip">扫码体验uni-app</text> <text class="tip" style="font-size:24upx;">Version {{version}}</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> </view>
<!-- #ifdef APP-PLUS --> <view class="copyright">
<view class="version"> <text class="agreement" @click="navigateTo(aboutus.agreement.privacy,'用户服务协议')">《用户服务协议》</text>
当前版本:{{version}} <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> </view>
<!-- #endif -->
</view> </view>
</template> </template>
<script> <script>
import baseappConfig from '@/baseapp.config.json';
export default { export default {
data() {
return {
providerList: [],
version: ''
}
},
onLoad() { onLoad() {
// #ifdef APP-PLUS // #ifdef APP-PLUS
this.version = plus.runtime.version; 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));
}
});
// #endif // #endif
}, },
methods: { data() {
// #ifdef APP-PLUS return {
save() { version:"V1.0.0",
uni.showActionSheet({ year:"2020",
itemList: ['保存图片到相册'], aboutus:{}
success: () => { };
plus.gallery.save('https://img.cdn.aliyun.dcloud.net.cn/guide/uniapp/app_download.png', function() { },
uni.showToast({ created() {
title: '保存成功', this.aboutus = baseappConfig.aboutus
icon: 'none' this.year = (new Date).getFullYear()
}); },
}, function() { methods:{
uni.showToast({ navigateTo(url,title){
title: '保存失败,请重试!', uni.navigateTo({
icon: 'none' 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> </script>
<style lang="scss" scoped>
<style> .aboutus {
page, width: 750upx;
view { flex-direction: column;
display: flex; }
} .logo {
width: 750upx;
page { position: fixed;
min-height: 100%; left:0;
background-color: #FFFFFF; top:100px;
} flex-direction: column;
justify-content: center;
image { align-items: center;
width: 360rpx; }
height: 360rpx; .logoImg{
} margin-bottom: 10upx;
width:160upx;
.about { height:160upx;
flex-direction: column; border-radius: 15px;
flex: 1; }
} .appName{
margin-top: 20px;
.content { margin-bottom:5px;
flex: 1; font-size:42rpx;
padding: 30rpx; font-weight: 500;
flex-direction: column; }
justify-content: center; .copyright {
} width: 750upx;
font-size:32rpx;
.qrcode { flex-direction: column;
display: flex; justify-content: center;
align-items: center; align-items: center;
flex-direction: column; bottom:20px;
} left: 0;
position: fixed;
.qrcode .tip { }
margin-top: 20rpx; .agreement {
} color:#2285ff;
font-size:26rpx;
.desc { }
margin-top: 30rpx; .hint {
display: block; color:#999999;
} font-size:26rpx;
}
.code { </style>
color: #e96900; \ No newline at end of file
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>
...@@ -104,8 +104,6 @@ ...@@ -104,8 +104,6 @@
width: 150rpx; width: 150rpx;
height: 150rpx; height: 150rpx;
border-radius: 75rpx; border-radius: 75rpx;
border: #F8F8F8 solid 1px;
border-width: 1rpx;
border-color: #999999;
} }
</style> </style>
...@@ -2,12 +2,15 @@ ...@@ -2,12 +2,15 @@
<view class="content"> <view class="content">
<!-- 功能列表 --> <!-- 功能列表 -->
<uni-list 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" :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> </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> </view>
</template> </template>
...@@ -68,22 +71,24 @@ ...@@ -68,22 +71,24 @@
logout: 'user/logout' logout: 'user/logout'
}), }),
toEdit(){ toEdit(){
uni.navigateTo({ uni.navigateTo({
url: '../edit/edit' url: '/pages/ucenter/edit/edit'
}); });
}, },
changePwd(){ changePwd(){
if(this.userInfo){ uni.navigateTo({
uni.navigateTo({ url:'/uni_modules/uni-login-page/pages/index/pwd-retrieve?phoneNumber='+ (this.userInfo.phone||'') +'&phoneArea=+86'
url:'/uni_modules/uni-login-page/pages/index/pwd-retrieve?phoneNumber='+ (this.userInfo.phone||'') +'&phoneArea=+86' });
}); // if(this.userInfo){
} else { // uni.navigateTo({
uni.showToast({ // url:'/uni_modules/uni-login-page/pages/index/pwd-retrieve?phoneNumber='+ (this.userInfo.phone||'') +'&phoneArea=+86'
title: '请先登录', // });
icon: 'none' // } else {
}); // uni.showToast({
} // title: '请先登录',
// icon: 'none'
// });
// }
}, },
checkPush(){ checkPush(){
// 手机端获取推送是否开启 // 手机端获取推送是否开启
...@@ -186,21 +191,26 @@ ...@@ -186,21 +191,26 @@
}) })
}, },
clickLogout() { clickLogout() {
if(this.userInfo){
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '是否退出登录', content: '是否退出登录',
cancelText: '取消', cancelText: '取消',
confirmText: '确定', confirmText: '确定',
success: res => { success: res => {
if(res.confirm){ if(res.confirm){
this.logout(); this.logout();
uni.navigateBack(); uni.navigateBack();
} }
}, },
fail: () => {}, fail: () => {},
complete: () => {} complete: () => {}
}); });
}else{
uni.navigateTo({
url: '/uni_modules/uni-login-page/pages/index/index'
});
}
}, },
itemClick(item) { itemClick(item) {
if (!item.to && item.event) { if (!item.to && item.event) {
...@@ -252,11 +262,12 @@ ...@@ -252,11 +262,12 @@
border: none; border: none;
/* #endif */ /* #endif */
border-width: 0; border-width: 0;
border-radius: 0; border-radius: 0;
background-color: #007AFF;
} }
.bottom-back-text { .bottom-back-text {
font-size: 40rpx; font-size: 40rpx;
color: #DD524D; color: #FFFFFF;
} }
</style> </style>
<template> <template>
<view class="center"> <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> <image class="logo-img" :src="login ? (userInfo.avatar || avatarUrl) :avatarUrl"></image>
<view class="logo-title"> <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> <text class="go-login-navigat-arrow navigat-arrow" v-if="!login">&#xe65e;</text>
</view> </view>
</view> </navigator>
<uni-grid class="grid" :column="5" :showBorder="false" :square="true"> <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-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> <uni-icons class="icon" color="#5d5e64" :type="icon" size="28"></uni-icons>
...@@ -180,9 +180,9 @@ ...@@ -180,9 +180,9 @@
align-items: center; align-items: center;
} }
.logo-hover { /* .logo-hover {
opacity: 0.8; opacity: 0.8;
} } */
.logo-img { .logo-img {
width: 150rpx; width: 150rpx;
......
## 3.0.12(2021-04-13)
- 调整bindTokenToDevice默认值为false
## 3.0.11(2021-04-12) ## 3.0.11(2021-04-12)
- 修复3.0.7版本引出的多个用户访问时可能出现30201报错的Bug - 修复3.0.7版本引出的多个用户访问时可能出现30201报错的Bug
## 3.0.10(2021-04-08) ## 3.0.10(2021-04-08)
......
{ {
"id": "uni-id", "id": "uni-id",
"displayName": "uni-id", "displayName": "uni-id",
"version": "3.0.11", "version": "3.0.12",
"description": "简单、统一、可扩展的用户中心", "description": "简单、统一、可扩展的用户中心",
"keywords": [ "keywords": [
"uniid", "uniid",
......
{ {
"name": "uni-id", "name": "uni-id",
"version": "3.0.11", "version": "3.0.12",
"description": "uni-id for uniCloud", "description": "uni-id for uniCloud",
"main": "index.js", "main": "index.js",
"homepage": "https://uniapp.dcloud.io/uniCloud/uni-id", "homepage": "https://uniapp.dcloud.io/uniCloud/uni-id",
......
...@@ -11,7 +11,7 @@ exports.main = async (event, context) => { ...@@ -11,7 +11,7 @@ exports.main = async (event, context) => {
context context
}) })
//event为客户端上传的参数 //event为客户端上传的参数
console.log('event : ' + event) console.log('event : ' + JSON.stringify(event))
let params = event.params || {} let params = event.params || {}
//防止黑客恶意破解登陆,连续登陆失败一定次数后,需要用户提供验证码 //防止黑客恶意破解登陆,连续登陆失败一定次数后,需要用户提供验证码
...@@ -107,6 +107,11 @@ exports.main = async (event, context) => { ...@@ -107,6 +107,11 @@ exports.main = async (event, context) => {
break; break;
case 'login_by_weixin': case 'login_by_weixin':
res = await uniID.loginByWeixin(params); res = await uniID.loginByWeixin(params);
await uniID.updateUser({
uid: params.uid,
username:"微信用户"
});
res.userInfo.username = "微信用户"
loginLog(res) loginLog(res)
break; break;
case 'login_by_univerify': case 'login_by_univerify':
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册