Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
萌新之路
uni-starter
提交
4aaf02d4
U
uni-starter
项目概览
萌新之路
/
uni-starter
与 Fork 源项目一致
Fork自
DCloud / uni-starter
通知
1
Star
1
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4aaf02d4
编写于
4月 15, 2021
作者:
L
linju
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
123
上级
add0dedc
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
540 addition
and
84 deletion
+540
-84
App.vue
App.vue
+19
-1
common/appInit.js
common/appInit.js
+94
-23
js_sdk/wa-permission/permission.js
js_sdk/wa-permission/permission.js
+272
-0
pages.json
pages.json
+1
-1
pages/test/test.vue
pages/test/test.vue
+151
-57
pages/ucenter/ucenter.vue
pages/ucenter/ucenter.vue
+3
-2
未找到文件。
App.vue
浏览文件 @
4aaf02d4
...
...
@@ -7,7 +7,25 @@
},
onLaunch
:
function
()
{
console
.
log
(
'
App Launch
'
)
initApp
();
initApp
();
// #ifdef APP-PLUS
plus
.
oauth
.
getServices
(
oauthServices
=>
{
oauthServices
.
forEach
(({
_id
},
item
)
=>
{
if
(
_id
==
'
provider
'
){
uni
.
preLogin
({
provider
:
item
,
complete
:
e
=>
{
console
.
log
(
e
);
}
})
}
})
uni
.
preloadPage
({
url
:
"
/uni_modules/uni-login-page/pages/index/index
"
});
},
err
=>
{
console
.
error
(
'
获取服务供应商失败:
'
+
JSON
.
stringify
(
err
));
})
// #endif
},
onShow
:
function
()
{
console
.
log
(
'
App Show
'
)
...
...
common/appInit.js
浏览文件 @
4aaf02d4
import
checkUpdate
from
'
@/uni_modules/uni-upgrade-center-app/utils/check-update
'
;
export
default
function
(){
import
checkUpdate
from
'
@/uni_modules/uni-upgrade-center-app/utils/check-update
'
;
export
default
function
()
{
// 初始化appVersion
initAppVersion
();
// 检查更新
checkUpdate
();
//自定义路由拦截
// setRouter()
// 初始化appVersion
initAppVersion
();
// 检查更新
// checkUpdate();
//提示网络变化
eventListenerNetwork
()
}
/**
* // 初始化appVersion
*/
function
initAppVersion
()
{
// #ifdef APP-PLUS
let
appid
=
plus
.
runtime
.
appid
;
plus
.
runtime
.
getProperty
(
appid
,
(
wgtInfo
)
=>
{
wgtInfo
.
version
let
appVersion
=
plus
.
runtime
;
getApp
({
allowDefault
:
true
}).
appVersion
=
{
appid
,
version
:
appVersion
,
wgtVersion
:
wgtInfo
,
finall
:
appVersion
.
versionCode
>
wgtInfo
.
versionCode
?
appVersion
:
wgtInfo
}
});
// #endif
}
//用于拦截路由
function
setRouter
()
{
let
before_action
=
e
=>
{
let
res
=
true
//需要登陆的页面
let
needLoginUrls
=
[
'
/pages/grid/grid
'
]
let
token
=
uni
.
getStorageSync
(
'
uni-id-token
'
)
if
(
needLoginUrls
.
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
'
})
}
/**
* // 初始化appVersion
*/
function
initAppVersion
(){
// #ifdef APP-PLUS
let
appid
=
plus
.
runtime
.
appid
;
plus
.
runtime
.
getProperty
(
appid
,(
wgtInfo
)
=>
{
wgtInfo
.
version
let
appVersion
=
plus
.
runtime
;
getApp
({
allowDefault
:
true
}).
appVersion
=
{
appid
,
version
:
appVersion
,
wgtVersion
:
wgtInfo
,
finall
:
appVersion
.
versionCode
>
wgtInfo
.
versionCode
?
appVersion
:
wgtInfo
}
// 设备网络状态变化事件
function
eventListenerNetwork
()
{
uni
.
onNetworkStatusChange
(
function
(
res
)
{
console
.
log
(
res
.
isConnected
);
console
.
log
(
res
.
networkType
);
if
(
!
res
.
isConnected
)
{
uni
.
showModal
({
content
:
"
你未打开网络连接
"
,
confirmText
:
"
前往打开
"
,
complete
:
(
e
)
=>
{
console
.
log
(
e
);
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
);
}
}
});
}
});
// #endif
}
\ No newline at end of file
js_sdk/wa-permission/permission.js
0 → 100644
浏览文件 @
4aaf02d4
/**
* 本模块封装了Android、iOS的应用权限判断、打开应用权限设置界面、以及位置系统服务是否开启
*/
var
isIos
// #ifdef APP-PLUS
isIos
=
(
plus
.
os
.
name
==
"
iOS
"
)
// #endif
// 判断推送权限是否开启
function
judgeIosPermissionPush
()
{
var
result
=
false
;
var
UIApplication
=
plus
.
ios
.
import
(
"
UIApplication
"
);
var
app
=
UIApplication
.
sharedApplication
();
var
enabledTypes
=
0
;
if
(
app
.
currentUserNotificationSettings
)
{
var
settings
=
app
.
currentUserNotificationSettings
();
enabledTypes
=
settings
.
plusGetAttribute
(
"
types
"
);
console
.
log
(
"
enabledTypes1:
"
+
enabledTypes
);
if
(
enabledTypes
==
0
)
{
console
.
log
(
"
推送权限没有开启
"
);
}
else
{
result
=
true
;
console
.
log
(
"
已经开启推送功能!
"
)
}
plus
.
ios
.
deleteObject
(
settings
);
}
else
{
enabledTypes
=
app
.
enabledRemoteNotificationTypes
();
if
(
enabledTypes
==
0
)
{
console
.
log
(
"
推送权限没有开启!
"
);
}
else
{
result
=
true
;
console
.
log
(
"
已经开启推送功能!
"
)
}
console
.
log
(
"
enabledTypes2:
"
+
enabledTypes
);
}
plus
.
ios
.
deleteObject
(
app
);
plus
.
ios
.
deleteObject
(
UIApplication
);
return
result
;
}
// 判断定位权限是否开启
function
judgeIosPermissionLocation
()
{
var
result
=
false
;
var
cllocationManger
=
plus
.
ios
.
import
(
"
CLLocationManager
"
);
var
status
=
cllocationManger
.
authorizationStatus
();
result
=
(
status
!=
2
)
console
.
log
(
"
定位权限开启:
"
+
result
);
// 以下代码判断了手机设备的定位是否关闭,推荐另行使用方法 checkSystemEnableLocation
/* var enable = cllocationManger.locationServicesEnabled();
var status = cllocationManger.authorizationStatus();
console.log("enable:" + enable);
console.log("status:" + status);
if (enable && status != 2) {
result = true;
console.log("手机定位服务已开启且已授予定位权限");
} else {
console.log("手机系统的定位没有打开或未给予定位权限");
} */
plus
.
ios
.
deleteObject
(
cllocationManger
);
return
result
;
}
// 判断麦克风权限是否开启
function
judgeIosPermissionRecord
()
{
var
result
=
false
;
var
avaudiosession
=
plus
.
ios
.
import
(
"
AVAudioSession
"
);
var
avaudio
=
avaudiosession
.
sharedInstance
();
var
permissionStatus
=
avaudio
.
recordPermission
();
console
.
log
(
"
permissionStatus:
"
+
permissionStatus
);
if
(
permissionStatus
==
1684369017
||
permissionStatus
==
1970168948
)
{
console
.
log
(
"
麦克风权限没有开启
"
);
}
else
{
result
=
true
;
console
.
log
(
"
麦克风权限已经开启
"
);
}
plus
.
ios
.
deleteObject
(
avaudiosession
);
return
result
;
}
// 判断相机权限是否开启
function
judgeIosPermissionCamera
()
{
var
result
=
false
;
var
AVCaptureDevice
=
plus
.
ios
.
import
(
"
AVCaptureDevice
"
);
var
authStatus
=
AVCaptureDevice
.
authorizationStatusForMediaType
(
'
vide
'
);
console
.
log
(
"
authStatus:
"
+
authStatus
);
if
(
authStatus
==
3
)
{
result
=
true
;
console
.
log
(
"
相机权限已经开启
"
);
}
else
{
console
.
log
(
"
相机权限没有开启
"
);
}
plus
.
ios
.
deleteObject
(
AVCaptureDevice
);
return
result
;
}
// 判断相册权限是否开启
function
judgeIosPermissionPhotoLibrary
()
{
var
result
=
false
;
var
PHPhotoLibrary
=
plus
.
ios
.
import
(
"
PHPhotoLibrary
"
);
var
authStatus
=
PHPhotoLibrary
.
authorizationStatus
();
console
.
log
(
"
authStatus:
"
+
authStatus
);
if
(
authStatus
==
3
)
{
result
=
true
;
console
.
log
(
"
相册权限已经开启
"
);
}
else
{
console
.
log
(
"
相册权限没有开启
"
);
}
plus
.
ios
.
deleteObject
(
PHPhotoLibrary
);
return
result
;
}
// 判断通讯录权限是否开启
function
judgeIosPermissionContact
()
{
var
result
=
false
;
var
CNContactStore
=
plus
.
ios
.
import
(
"
CNContactStore
"
);
var
cnAuthStatus
=
CNContactStore
.
authorizationStatusForEntityType
(
0
);
if
(
cnAuthStatus
==
3
)
{
result
=
true
;
console
.
log
(
"
通讯录权限已经开启
"
);
}
else
{
console
.
log
(
"
通讯录权限没有开启
"
);
}
plus
.
ios
.
deleteObject
(
CNContactStore
);
return
result
;
}
// 判断日历权限是否开启
function
judgeIosPermissionCalendar
()
{
var
result
=
false
;
var
EKEventStore
=
plus
.
ios
.
import
(
"
EKEventStore
"
);
var
ekAuthStatus
=
EKEventStore
.
authorizationStatusForEntityType
(
0
);
if
(
ekAuthStatus
==
3
)
{
result
=
true
;
console
.
log
(
"
日历权限已经开启
"
);
}
else
{
console
.
log
(
"
日历权限没有开启
"
);
}
plus
.
ios
.
deleteObject
(
EKEventStore
);
return
result
;
}
// 判断备忘录权限是否开启
function
judgeIosPermissionMemo
()
{
var
result
=
false
;
var
EKEventStore
=
plus
.
ios
.
import
(
"
EKEventStore
"
);
var
ekAuthStatus
=
EKEventStore
.
authorizationStatusForEntityType
(
1
);
if
(
ekAuthStatus
==
3
)
{
result
=
true
;
console
.
log
(
"
备忘录权限已经开启
"
);
}
else
{
console
.
log
(
"
备忘录权限没有开启
"
);
}
plus
.
ios
.
deleteObject
(
EKEventStore
);
return
result
;
}
// Android权限查询
function
requestAndroidPermission
(
permissionID
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
plus
.
android
.
requestPermissions
(
[
permissionID
],
// 理论上支持多个权限同时查询,但实际上本函数封装只处理了一个权限的情况。有需要的可自行扩展封装
function
(
resultObj
)
{
var
result
=
0
;
for
(
var
i
=
0
;
i
<
resultObj
.
granted
.
length
;
i
++
)
{
var
grantedPermission
=
resultObj
.
granted
[
i
];
console
.
log
(
'
已获取的权限:
'
+
grantedPermission
);
result
=
1
}
for
(
var
i
=
0
;
i
<
resultObj
.
deniedPresent
.
length
;
i
++
)
{
var
deniedPresentPermission
=
resultObj
.
deniedPresent
[
i
];
console
.
log
(
'
拒绝本次申请的权限:
'
+
deniedPresentPermission
);
result
=
0
}
for
(
var
i
=
0
;
i
<
resultObj
.
deniedAlways
.
length
;
i
++
)
{
var
deniedAlwaysPermission
=
resultObj
.
deniedAlways
[
i
];
console
.
log
(
'
永久拒绝申请的权限:
'
+
deniedAlwaysPermission
);
result
=
-
1
}
resolve
(
result
);
// 若所需权限被拒绝,则打开APP设置界面,可以在APP设置界面打开相应权限
// if (result != 1) {
// gotoAppPermissionSetting()
// }
},
function
(
error
)
{
console
.
log
(
'
申请权限错误:
'
+
error
.
code
+
"
=
"
+
error
.
message
);
resolve
({
code
:
error
.
code
,
message
:
error
.
message
});
}
);
});
}
// 使用一个方法,根据参数判断权限
function
judgeIosPermission
(
permissionID
)
{
if
(
permissionID
==
"
location
"
)
{
return
judgeIosPermissionLocation
()
}
else
if
(
permissionID
==
"
camera
"
)
{
return
judgeIosPermissionCamera
()
}
else
if
(
permissionID
==
"
photoLibrary
"
)
{
return
judgeIosPermissionPhotoLibrary
()
}
else
if
(
permissionID
==
"
record
"
)
{
return
judgeIosPermissionRecord
()
}
else
if
(
permissionID
==
"
push
"
)
{
return
judgeIosPermissionPush
()
}
else
if
(
permissionID
==
"
contact
"
)
{
return
judgeIosPermissionContact
()
}
else
if
(
permissionID
==
"
calendar
"
)
{
return
judgeIosPermissionCalendar
()
}
else
if
(
permissionID
==
"
memo
"
)
{
return
judgeIosPermissionMemo
()
}
return
false
;
}
// 跳转到**应用**的权限页面
function
gotoAppPermissionSetting
()
{
if
(
isIos
)
{
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
);
}
}
// 检查系统的设备服务是否开启
// var checkSystemEnableLocation = async function () {
function
checkSystemEnableLocation
()
{
if
(
isIos
)
{
var
result
=
false
;
var
cllocationManger
=
plus
.
ios
.
import
(
"
CLLocationManager
"
);
var
result
=
cllocationManger
.
locationServicesEnabled
();
console
.
log
(
"
系统定位开启:
"
+
result
);
plus
.
ios
.
deleteObject
(
cllocationManger
);
return
result
;
}
else
{
var
context
=
plus
.
android
.
importClass
(
"
android.content.Context
"
);
var
locationManager
=
plus
.
android
.
importClass
(
"
android.location.LocationManager
"
);
var
main
=
plus
.
android
.
runtimeMainActivity
();
var
mainSvr
=
main
.
getSystemService
(
context
.
LOCATION_SERVICE
);
var
result
=
mainSvr
.
isProviderEnabled
(
locationManager
.
GPS_PROVIDER
);
console
.
log
(
"
系统定位开启:
"
+
result
);
return
result
}
}
module
.
exports
=
{
judgeIosPermission
:
judgeIosPermission
,
requestAndroidPermission
:
requestAndroidPermission
,
checkSystemEnableLocation
:
checkSystemEnableLocation
,
gotoAppPermissionSetting
:
gotoAppPermissionSetting
}
pages.json
浏览文件 @
4aaf02d4
...
...
@@ -213,7 +213,7 @@
"path"
:
"pages/test/test"
}
],
"current"
:
1
"current"
:
0
},
"tabBar"
:
{
"color"
:
"#7A7E83"
,
...
...
pages/test/test.vue
浏览文件 @
4aaf02d4
<
template
>
<view>
test
<button
type=
"default"
@
click=
"openMoblie"
>
打开移动网络
</button>
<!--
<button
type=
"default"
@
click=
"fn1"
>
1
</button>
<button
type=
"default"
@
click=
"fn2"
>
2
</button>
-->
</view>
</
template
>
<
script
>
export
default
{
data
()
{
return
{
}
},
onLoad
()
{
// 设备网络状态变化事件
uni
.
onNetworkStatusChange
(
function
(
res
)
{
console
.
log
(
res
.
isConnected
);
console
.
log
(
res
.
networkType
);
if
(
!
res
.
isConnected
){
uni
.
showModal
({
content
:
"
你未打开网络连接
"
,
confirmText
:
"
前往打开
"
,
complete
:
(
e
)
=>
{
console
.
log
(
e
);
if
(
uni
.
getSystemInfoSync
().
platform
==
"
ios
"
)
{
}
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
);
<
template
>
<view>
<!--
<button
type=
"default"
@
click=
"openSystemSetting('ACTION_BLUETOOTH_SETTINGS')"
>
设置蓝牙
</button>
<button
type=
"default"
@
click=
"openSystemSetting('ACTION_LOCALE_SETTINGS')"
>
设置语言
</button>
<button
type=
"default"
@
click=
"openSystemSetting('ACTION_LOCATION_SOURCE_SETTINGS')"
>
设置gps
</button>
<button
type=
"default"
@
click=
"openSystemSetting('ACTION_WIFI_SETTINGS')"
>
设置wifi
</button>
<button
type=
"default"
@
click=
"openSystemSetting('ACTION_DATA_ROAMING_SETTINGS')"
>
数据网络
</button>
<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>
</view>
</
template
>
<
script
>
import
permision
from
'
@/js_sdk/wa-permission/permission.js
'
;
export
default
{
data
()
{
return
{
}
},
onLoad
()
{
/*
当某个权限调用失败
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
:
{
openWifi
(){
var
main
=
plus
.
android
.
runtimeMainActivity
();
var
Intent
=
plus
.
android
.
importClass
(
"
android.content.Intent
"
);
var
mIntent
=
new
Intent
(
'
android.settings.WIFI_SETTINGS
'
);
main
.
startActivity
(
mIntent
);
},
fn1
(){
let
res
=
this
.
request
(
'
user-center/login_by_
'
).
then
(
e
=>
{
console
.
log
(
'
then--1
'
,
e
);
openCamera
(){
uni
.
chooseImage
({
sourceType
:
[
"
camera
"
],
complete
:
(
e
)
=>
{
console
.
log
(
e
);
}
})
},
fn2
(){
this
.
request
(
'
user-center/login_by_
'
,{},
e
=>
{
console
.
log
(
'
222
'
,
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
)
}
}
})
}
}
}
</
script
>
<
style
>
},
iosSetting
()
{
plus
.
runtime
.
launchApplication
({
action
:
'
App-Prefs:root=WIFI
'
},
function
(
e
)
{
//console.log(JSON.stringify(e));
});
//WIFI
},
openSystemSetting
(
type
)
{
var
main
=
plus
.
android
.
runtimeMainActivity
();
//获取activity
var
Intent
=
plus
.
android
.
importClass
(
'
android.content.Intent
'
);
var
Settings
=
plus
.
android
.
importClass
(
'
android.provider.Settings
'
);
var
intent
=
new
Intent
(
Settings
[
type
]);
//可设置表中所有Action字段
main
.
startActivity
(
intent
);
},
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
);
}
},
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
>
<
style
>
</
style
>
pages/ucenter/ucenter.vue
浏览文件 @
4aaf02d4
...
...
@@ -2,8 +2,9 @@
<view
class=
"center"
>
<view
class=
"userInfo"
@
click=
"goLogin"
:hover-class=
"!login ? 'logo-hover' : ''"
>
<image
class=
"logo-img"
:src=
"login ? (userInfo.avatar || avatarUrl) :avatarUrl"
></image>
<view
class=
"logo-title"
>
<text
class=
"uer-name"
>
Hi,
{{
login
?
userInfo
.
username
:
'
您未登录
'
}}
</text>
<view
class=
"logo-title"
>
{{
JSON
.
stringify
(
userInfo
)
}}
<text
class=
"uer-name"
>
{{
login
?
userInfo
.
nickname
||
userInfo
.
mobile
:
'
您未登录
'
}}
</text>
<text
class=
"go-login-navigat-arrow navigat-arrow"
v-if=
"!login"
>

</text>
</view>
</view>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录