Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
言程序plus
uni-starter
提交
8673038e
U
uni-starter
项目概览
言程序plus
/
uni-starter
与 Fork 源项目一致
Fork自
DCloud / uni-starter
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-starter
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
8673038e
编写于
4月 21, 2021
作者:
芊
芊里
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://gitee.com/dcloud/base-app
上级
92ce7994
019f116e
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
306 addition
and
371 deletion
+306
-371
common/appInit.js
common/appInit.js
+191
-124
manifest.json
manifest.json
+1
-1
pages.json
pages.json
+24
-11
pages/list/list.vue
pages/list/list.vue
+1
-0
pages/list/networkErr/networkErr.nvue
pages/list/networkErr/networkErr.nvue
+81
-0
pages/test/test.vue
pages/test/test.vue
+8
-172
template.h5.html
template.h5.html
+0
-63
未找到文件。
common/appInit.js
浏览文件 @
8673038e
...
...
@@ -8,12 +8,17 @@ export default function() {
initAppVersion
();
//自定义路由拦截
const
{
"
router
"
:{
needLogin
,
login
}}
=
baseappConfig
//需要登陆的页面
const
{
"
router
"
:
{
needLogin
,
login
}
}
=
baseappConfig
//需要登陆的页面
//uni.addInterceptor的写法
let
list
=
[
"
navigateTo
"
,
"
redirectTo
"
,
"
reLaunch
"
,
"
switchTab
"
];
list
.
forEach
(
item
=>
{
uni
.
addInterceptor
(
item
,
{
invoke
(
e
)
{
// 调用前拦截
list
.
forEach
(
item
=>
{
uni
.
addInterceptor
(
item
,
{
invoke
(
e
)
{
// 调用前拦截
//console.log(e);
const
token
=
uni
.
getStorageSync
(
'
uni_id_token
'
)
// console.log(token);
...
...
@@ -21,50 +26,71 @@ export default function() {
//拦截强制登陆页面
if
(
needLogin
.
includes
(
url
)
&&
token
==
''
)
{
console
.
log
(
'
该页面需要登陆,即将跳转到login页面
'
);
uni
.
showToast
({
title
:
'
该页面需要登陆,即将跳转到login页面
'
,
icon
:
'
none
'
})
uni
.
showToast
({
title
:
'
该页面需要登陆,即将跳转到login页面
'
,
icon
:
'
none
'
})
uni
.
navigateTo
({
url
:
"
/uni_modules/uni-login-page/pages/index/index
"
url
:
"
/uni_modules/uni-login-page/pages/index/index
"
})
return
false
}
//控制登陆优先级
if
(
url
==
'
/uni_modules/uni-login-page/pages/index/index
'
){
if
(
url
==
'
/uni_modules/uni-login-page/pages/index/index
'
)
{
//一键登录(univerify)、密码登陆(username)、快捷登录&验证码登陆(!univerify&password)
if
(
login
[
0
]
==
'
univerify
'
){
if
(
login
[
0
]
==
'
univerify
'
)
{
// console.log(e.url,url);
if
(
e
.
url
==
url
){
e
.
url
+=
'
?
'
}
if
(
e
.
url
==
url
)
{
e
.
url
+=
'
?
'
}
e
.
url
+=
"
univerify_first=true
"
}
else
if
(
login
[
0
]
==
'
username
'
){
}
else
if
(
login
[
0
]
==
'
username
'
)
{
e
.
url
=
"
/uni_modules/uni-login-page/pages/pwd-login/pwd-login
"
}
else
{
}
else
{
//默认即是
}
}
return
true
},
success
(){
// 成功回调拦截
},
fail
(
err
){
// 失败回调拦截
fail
(
err
)
{
// 失败回调拦截
console
.
log
(
err
);
},
complete
(
e
){
// 完成回调拦截
//console.log(e);
},
returnValue
(){
// 返回结果拦截
})
})
//当应用无访问摄像头/相册权限,引导跳到设置界面
uni
.
addInterceptor
(
'
chooseImage
'
,
{
fail
(
e
)
{
// 失败回调拦截
console
.
log
(
e
);
if
(
e
.
errCode
===
11
&&
uni
.
getSystemInfoSync
().
platform
==
"
android
"
||
e
.
errCode
===
2
&&
uni
.
getSystemInfoSync
().
platform
==
"
ios
"
){
uni
.
showModal
({
title
:
"
无法访问摄像头
"
,
content
:
"
当前无摄像头访问权限,建议前往设置
"
,
confirmText
:
"
前往设置
"
,
success
(
e
)
{
if
(
e
.
confirm
)
{
openAppPermissionSetting
()
}
}
});
}
if
(
e
.
errCode
===
12
&&
uni
.
getSystemInfoSync
().
platform
==
"
android
"
){
uni
.
showModal
({
title
:
"
无法访问相册
"
,
content
:
"
当前无系统相册访问权限,建议前往设置
"
,
confirmText
:
"
前往设置
"
,
success
(
e
)
{
if
(
e
.
confirm
)
{
openAppPermissionSetting
()
}
}
});
}
}
})
// 移除拦截器API removeInterceptor('request')
})
//提示网络变化
eventListenerNetwork
()
/*
当某个权限调用失败
1.先检测手机的该模块是否打开
2.检测当前应用是否被授权了该模块对应的权限
提示,并点击跳转到设置
*/
}
/**
* // 初始化appVersion
...
...
@@ -80,12 +106,12 @@ function initAppVersion() {
}).
appVersion
=
{
...
currentVersion
,
appid
,
hasNew
:
false
hasNew
:
false
}
// 检查更新小红点
callCheckVersion
().
then
(
res
=>
{
console
.
log
(
'
检查是否有可以更新的版本
'
,
res
);
if
(
res
.
result
.
code
>
0
){
callCheckVersion
().
then
(
res
=>
{
console
.
log
(
'
检查是否有可以更新的版本
'
,
res
);
if
(
res
.
result
.
code
>
0
)
{
// 有新版本
getApp
({
allowDefault
:
true
...
...
@@ -93,14 +119,13 @@ function initAppVersion() {
}
})
});
// 检查更新
checkUpdate
();
// #endif
}
// 设备网络状态变化事件
function
eventListenerNetwork
()
{
function
eventListenerNetwork
()
{
uni
.
onNetworkStatusChange
(
function
(
res
)
{
console
.
log
(
res
.
isConnected
);
console
.
log
(
res
.
networkType
);
...
...
@@ -127,3 +152,45 @@ function eventListenerNetwork () {
}
});
}
function
openAppPermissionSetting
(){
// 跳转到**应用**的权限页面
if
(
uni
.
getSystemInfoSync
().
platform
==
"
ios
"
)
{
var
UIApplication
=
plus
.
ios
.
import
(
"
UIApplication
"
);
var
application2
=
UIApplication
.
sharedApplication
();
var
NSURL2
=
plus
.
ios
.
import
(
"
NSURL
"
);
// var setting2 = NSURL2.URLWithString("prefs:root=LOCATION_SERVICES");
var
setting2
=
NSURL2
.
URLWithString
(
"
app-settings:
"
);
application2
.
openURL
(
setting2
);
plus
.
ios
.
deleteObject
(
setting2
);
plus
.
ios
.
deleteObject
(
NSURL2
);
plus
.
ios
.
deleteObject
(
application2
);
}
else
{
// console.log(plus.device.vendor);
var
Intent
=
plus
.
android
.
importClass
(
"
android.content.Intent
"
);
var
Settings
=
plus
.
android
.
importClass
(
"
android.provider.Settings
"
);
var
Uri
=
plus
.
android
.
importClass
(
"
android.net.Uri
"
);
var
mainActivity
=
plus
.
android
.
runtimeMainActivity
();
var
intent
=
new
Intent
();
intent
.
setAction
(
Settings
.
ACTION_APPLICATION_DETAILS_SETTINGS
);
var
uri
=
Uri
.
fromParts
(
"
package
"
,
mainActivity
.
getPackageName
(),
null
);
intent
.
setData
(
uri
);
mainActivity
.
startActivity
(
intent
);
}
}
/*
uni.addInterceptor(item, {
invoke(e) { // 调用前拦截
},
success() { // 成功回调拦截
},
fail(err) { // 失败回调拦截
console.log(err);
},
complete(e) { // 完成回调拦截
//console.log(e);
},
returnValue() { // 返回结果拦截
}
}) // 移除拦截器API removeInterceptor('request')
*/
\ No newline at end of file
manifest.json
浏览文件 @
8673038e
...
...
@@ -101,6 +101,6 @@
"enable"
:
false
},
"h5"
:
{
"template"
:
"
template.h5.html
"
"template"
:
""
}
}
pages.json
浏览文件 @
8673038e
...
...
@@ -5,9 +5,23 @@
//#ifndef
MP
"navigationStyle"
:
"custom"
,
//#endif
"enablePullDownRefresh"
:
true
"enablePullDownRefresh"
:
true
,
"app-plus"
:{
"subNVues"
:[
{
"id"
:
"networkErr"
,
"path"
:
"pages/list/networkErr/networkErr"
,
"style"
:{
"height"
:
"0"
,
"width"
:
"100%"
,
"background"
:
"transparent"
}
},
{
}
]
}
}
},
{
"path"
:
"pages/list/news-list"
,
"style"
:
{
//#ifndef
MP
...
...
@@ -226,7 +240,6 @@
"path"
:
"pages/ucenter/settings/settings"
}
],
"current"
:
0
},
"tabBar"
:
{
...
...
pages/list/list.vue
浏览文件 @
8673038e
...
...
@@ -20,6 +20,7 @@
},
onLoad
()
{
checkIsAgree
();
uni
.
getSubNVueById
(
'
networkErr
'
).
show
()
},
onShow
(
options
)
{
this
.
searchText
=
getApp
().
globalData
.
searchText
;
...
...
pages/list/networkErr/networkErr.nvue
0 → 100644
浏览文件 @
8673038e
<template>
<view class="box" :style="{'padding-top':statusBarHeight}">
<text class="networkErr">网络连接不可用</text>
<text @click="toSet">去设置</text>
</view>
</template>
<script>
export default {
data() {
return {
statusBarHeight:0
}
},
mounted() {
this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
const getCurrentSubNVue = uni.getCurrentSubNVue();
getCurrentSubNVue.setStyle({
"height":this.statusBarHeight+60+'px'
})
uni.getNetworkType({
success:res=>{
console.log(res);
if(res.networkType!='none'){
getCurrentSubNVue.hide()
}else{
getCurrentSubNVue.show()
}
}
});
uni.onNetworkStatusChange(res=> {
console.log(res.isConnected);
console.log(res.networkType);
if(res.networkType!='none'){
uni.showToast({
title:'当前网络类型:'+res.networkType,
icon:'none',
duration:3000
})
if(this.old=='none'){
this.$parent.reLink();
}
getCurrentSubNVue.hide()
}else{
getCurrentSubNVue.show()
uni.showToast({
title:'网络类型:'+res.networkType,
icon:'none',
duration:3000
})
}
});
},
methods: {
toSet(){
if (uni.getSystemInfoSync().platform == "ios") {
plus.runtime.launchApplication({
action: 'App-Prefs:root=WIFI'
}, function(e) {
console.log(JSON.stringify(e));
});
} else {
var main = plus.android.runtimeMainActivity();
var Intent = plus.android.importClass("android.content.Intent");
var mIntent = new Intent('android.settings.DATA_ROAMING_SETTINGS');
main.startActivity(mIntent);
}
}
},
}
</script>
<style lang="scss" scoped>
.box{
background-color: #DD524D;
height:100%;
flex: 1;
}
</style>
pages/test/test.vue
浏览文件 @
8673038e
...
...
@@ -8,186 +8,32 @@
<text>
应用相关权限
</text>
<button
type=
"default"
@
click=
"openAppPermissionSetting"
>
打开
</button>
<button
type=
"default"
@
click=
"iosSetting"
>
iosSetting
</button>
-->
<!--
<button
type=
"default"
@
click=
"openCamera"
>
打开相机
</button>
-->
<!--
<button
type=
"default"
@
click=
"openGridPage"
>
打开一个需要登陆的页面
</button>
-->
<button
type=
"default"
@
click=
"showShare"
>
打开分享
</button>
<!--
<uni-bottom-menu
ref=
"bottomMenu"
@
clickItem=
"clickItem"
:list=
"menus"
></uni-bottom-menu>
-->
<button
type=
"default"
@
click=
"openCamera"
>
打开相机
</button>
</view>
</
template
>
<
script
>
// import permision from '@/js_sdk/wa-permission/permission.js';
import
uniShare
from
'
uni_modules/uni-share/js_sdk/uni-share.js
'
;
export
default
{
data
()
{
return
{
}
},
onLoad
()
{
/*
// uni.addInterceptor('showToast',{
// invoke(e){// 调用前拦截
// console.log(e)
// e.title = "645"
// },
// success(e){// 成功回调拦截
// console.log(e)
// },
// fail(e){// 失败回调拦截
// console.log(e)
// },
// complete(e){
// console.log(e)
// },
// returnValue(e){// 返回结果拦截
// console.log(e)
// }
// })
// return
//
// 当某个权限调用失败
// 1.先检测手机的该模块是否打开
// 2.检测当前应用是否被授权了该模块对应的权限
// 提示,并点击跳转到设置
//
// this.changeAction('chooseImage', {
// after_action: e => {
// console.log('changeAction', e);
// if(e.errCode === 11){
// uni.showModal({
// content: '无权限',
// confirmText:"前往设置",
// success(e) {
// if(e.confirm){
// permision.gotoAppPermissionSetting()
// }
// }
// });
// }
// }
// })
// this.changeAction(["navigateTo", "redirectTo", "reLaunch", "switchTab"], {
// before_action: e => {
// let needLoginUrls = ['/pages/grid/grid']//需要登陆的页面
// let token = uni.getStorageSync('uni-id-token')
// if (needLoginUrls.includes(e.url) && token == '') {
// console.log('该页面需要登陆,即将跳转到login页面');
// uni.showToast({title:'该页面需要登陆,即将跳转到login页面',icon:'none'})
// return false
// }
// return true
// }
// })
*/
},
methods
:
{
showShare
(){
uniShare
({
menus
:[
{
"
img
"
:
"
/static/sharemenu/wechatfriend.png
"
,
"
text
"
:
"
微信好友
"
,
"
share
"
:
{
"
provider
"
:
"
weixin
"
,
"
scene
"
:
"
WXSceneSession
"
}
},
{
"
img
"
:
"
/static/sharemenu/wechatmoments.png
"
,
"
text
"
:
"
微信朋友圈
"
,
"
share
"
:
{
"
provider
"
:
"
weixin
"
,
"
scene
"
:
"
WXSceneSession
"
}
},
{
"
img
"
:
"
/static/sharemenu/weibo.png
"
,
"
text
"
:
"
微博
"
,
"
share
"
:
{
"
provider
"
:
"
sinaweibo
"
}
},
{
"
img
"
:
"
/static/sharemenu/qq.png
"
,
"
text
"
:
"
QQ
"
,
"
share
"
:
{
"
provider
"
:
"
qq
"
}
},
{
"
img
"
:
"
/static/sharemenu/copyurl.png
"
,
"
text
"
:
"
复制
"
,
"
share
"
:
"
copyurl
"
},
{
"
img
"
:
"
/static/sharemenu/more.png
"
,
"
text
"
:
"
更多
"
,
"
share
"
:
"
shareSystem
"
}
],
content
:{
type
:
0
,
href
:
"
https://uniapp.dcloud.io/api/plugins/share?id=share
"
,
title
:
"
主标题
"
,
summary
:
"
分享内容的摘要
"
,
imageUrl
:
"
https://uniapp.dcloud.io/api/plugins/share?id=share
"
,
},
cancelText
:
"
取消分享
"
,
},
e
=>
{
//callback
console
.
log
(
e
);
})
},
clickItem
(
e
){
console
.
log
(
e
);
uni
.
showToast
({
title
:
e
});
},
openCamera
(){
uni
.
chooseImage
({
sourceType
:
[
"
camera
"
],
sourceType
:
[
"
camera
"
,
"
album
"
],
complete
:
(
e
)
=>
{
console
.
log
(
e
);
}
})
},
openGridPage
(){
uni
.
redirectTo
({
url
:
'
/pages/grid/grid
'
})
},
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
)
}
}
})
},
iosSetting
()
{
plus
.
runtime
.
launchApplication
({
action
:
'
App-Prefs:root=WIFI
'
...
...
@@ -227,16 +73,6 @@
mainActivity
.
startActivity
(
intent
);
}
},
fn1
()
{
let
res
=
this
.
request
(
'
user-center/login_by_
'
).
then
(
e
=>
{
console
.
log
(
'
then--1
'
,
e
);
})
},
fn2
()
{
this
.
request
(
'
user-center/login_by_
'
,
{},
e
=>
{
console
.
log
(
'
222
'
,
e
);
})
}
}
}
</
script
>
...
...
template.h5.html
已删除
100644 → 0
浏览文件 @
92ce7994
<!DOCTYPE html>
<html
lang=
"zh-CN"
>
<head>
<meta
charset=
"utf-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
>
<title>
<
%=
htmlWebpackPlugin.options.title
%
>
</title>
<!-- 正式发布的时候使用,开发期间不启用。↓ -->
<!-- <script src="/h5/touch-emulator.js"></script>
<script>
TouchEmulator();
if (document.documentElement.clientWidth > 1024) {
window.location.href = '/h5/pcguide.html#'+location.pathname+location.search;
}
</script>
<style>
::-webkit-scrollbar{
display: none;
}
</style>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?";// 百度统计key
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script> -->
<!-- 正式发布的时候使用,开发期间不启用。↑ -->
<script>
// document.addEventListener('DOMContentLoaded', function() {
// document.documentElement.style.fontSize = document.documentElement.clientWidth / 20 + 'px'
// })
</script>
<link
rel=
"stylesheet"
href=
"<%= BASE_URL %>static/index.<%= VUE_APP_INDEX_CSS_HASH %>.css"
/>
<style
type=
"text/css"
>
#openApp
{
position
:
fixed
;
top
:
0
;
left
:
0
;
right
:
0
;
z-index
:
999
;
}
</style>
</head>
<body>
<!-- 该文件为 H5 平台的模板 HTML,并非应用入口。 -->
<!-- 请勿在此文件编写页面代码或直接运行此文件。 -->
<!-- 详见文档:https://uniapp.dcloud.io/collocation/manifest?id=h5-template -->
<noscript>
<strong>
Please enable JavaScript to continue.
</strong>
</noscript>
<div
style=
"margin-top: 100px;"
id=
"app"
></div>
<!-- built files will be auto injected -->
<script>
/*BAIDU_STAT*/
</script>
</body>
</html>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录