Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
一个会的不多的人
uni-starter
提交
6a0dd700
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,发现更多精彩内容 >>
提交
6a0dd700
编写于
6月 07, 2021
作者:
DCloud_JSON
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
为迎合苹果App Store的规则,登陆与分享功能项显示之前自动检测是否安装了对应客户端。比如:设备未安装微信则不显示微信快捷登陆和微信分享选项。
上级
8772e133
变更
17
展开全部
隐藏空白更改
内联
并排
Showing
17 changed file
with
448 addition
and
213 deletion
+448
-213
changelog.md
changelog.md
+2
-0
components/uni-quick-login/uni-quick-login.vue
components/uni-quick-login/uni-quick-login.vue
+75
-62
package.json
package.json
+1
-1
pages/list/list.nvue
pages/list/list.nvue
+76
-65
pages/ucenter/login-page/index/index.vue
pages/ucenter/login-page/index/index.vue
+3
-2
uni-starter.config.js
uni-starter.config.js
+1
-1
uniCloud-aliyun/cloudfunctions/uni-id-cf/index.js
uniCloud-aliyun/cloudfunctions/uni-id-cf/index.js
+1
-1
uniCloud-aliyun/cloudfunctions/uni-id-cf/package-lock.json
uniCloud-aliyun/cloudfunctions/uni-id-cf/package-lock.json
+1
-1
uni_modules/uni-id/package.json
uni_modules/uni-id/package.json
+3
-3
uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id/index.js
...les/uni-id/uniCloud/cloudfunctions/common/uni-id/index.js
+1
-1
uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id/package-lock.json
...d/uniCloud/cloudfunctions/common/uni-id/package-lock.json
+14
-2
uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id/package.json
...uni-id/uniCloud/cloudfunctions/common/uni-id/package.json
+2
-1
uni_modules/uni-share/changelog.md
uni_modules/uni-share/changelog.md
+6
-0
uni_modules/uni-share/js_sdk/uni-image-menu.js
uni_modules/uni-share/js_sdk/uni-image-menu.js
+171
-0
uni_modules/uni-share/js_sdk/uni-share.js
uni_modules/uni-share/js_sdk/uni-share.js
+9
-3
uni_modules/uni-share/package.json
uni_modules/uni-share/package.json
+1
-1
uni_modules/uni-share/readme.md
uni_modules/uni-share/readme.md
+81
-69
未找到文件。
changelog.md
浏览文件 @
6a0dd700
## 1.0.15(2021-06-07)
为迎合苹果App Store的规则,登陆与分享功能项显示之前自动检测是否安装了对应客户端。比如:设备未安装微信则不显示微信快捷登陆和微信分享选项。
## 1.0.14(2021-06-07)
修改错误的表名称uni-verify为opendb-verify-codes
## 1.0.13(2021-06-04)
...
...
components/uni-quick-login/uni-quick-login.vue
浏览文件 @
6a0dd700
...
...
@@ -39,9 +39,9 @@
}
},
props
:
{
agree
:{
type
:
Boolean
,
default
()
{
agree
:
{
type
:
Boolean
,
default
()
{
return
false
}
},
...
...
@@ -105,7 +105,7 @@
//去掉配置项中不存在的项
for
(
var
i
=
0
;
i
<
servicesList
.
length
;
i
++
)
{
if
(
!
this
.
loginConfig
.
includes
(
servicesList
[
i
].
id
))
{
console
.
log
(
'
去掉配置项中不存在的项
'
,
servicesList
[
i
].
id
);
console
.
log
(
'
去掉配置项中不存在的项
'
,
servicesList
[
i
].
id
);
servicesList
.
splice
(
i
,
1
)
}
}
...
...
@@ -119,15 +119,23 @@
oauthServices
.
forEach
(({
id
})
=>
{
// console.log(9527,id);
if
(
this
.
config
[
id
].
isChecked
&&
this
.
loginConfig
.
includes
(
id
))
{
if
(
this
.
config
[
id
].
isChecked
&&
this
.
loginConfig
.
includes
(
id
))
{
if
(
id
==
'
weixin
'
)
{
if
(
~
plus
.
runtime
.
isApplicationExist
({
pname
:
'
com.tencent.mm
'
,
action
:
'
weixin://
'
}))
{
// console.log("微信应用未安装");
return
}
}
this
.
servicesList
.
push
({
...
this
.
config
[
id
],
id
})
}
})
// console.log(oauthServices);
// console.log(
'oauthServices',
oauthServices);
},
err
=>
{
uni
.
hideLoading
()
uni
.
showModal
({
...
...
@@ -171,13 +179,15 @@
}
},
login_before
(
type
,
navigateBack
=
true
)
{
if
(
!
this
.
agree
)
{
if
(
!
this
.
agree
)
{
return
uni
.
showToast
({
title
:
'
你未同意隐私政策协议
'
,
icon
:
'
none
'
});
}
uni
.
showLoading
({
mask
:
true
})
uni
.
showLoading
({
mask
:
true
})
// console.log(arguments);
let
oauthService
=
this
.
oauthServices
.
find
((
service
)
=>
service
.
id
==
type
)
// console.log(type);
...
...
@@ -195,10 +205,10 @@
},
err
=>
{
uni
.
hideLoading
()
console
.
log
(
err
);
uni
.
showModal
({
content
:
JSON
.
stringify
(
err
),
showCancel
:
false
console
.
log
(
err
);
uni
.
showModal
({
content
:
JSON
.
stringify
(
err
),
showCancel
:
false
});
})
}
...
...
@@ -233,7 +243,7 @@
console
.
log
(
err
);
if
(
type
==
'
univerify
'
)
{
if
(
err
.
metadata
&&
err
.
metadata
.
error_data
)
{
if
(
err
.
metadata
&&
err
.
metadata
.
error_data
)
{
uni
.
showToast
({
title
:
"
一键登录:
"
+
err
.
metadata
.
error_data
,
icon
:
'
none
'
...
...
@@ -249,33 +259,33 @@
uni
.
navigateBack
()
}
break
;
case
30006
:
uni
.
showModal
({
title
:
"
登录服务初始化错误
"
,
content
:
err
.
metadata
.
error_data
,
showCancel
:
false
,
confirmText
:
'
知道了
'
,
});
break
;
case
"
30008
"
:
uni
.
showToast
({
title
:
'
点击了第三方登陆
'
,
icon
:
'
none
'
});
switch
(
err
.
index
){
case
0
:
this
.
login_before
(
'
weixin
'
,
false
)
break
;
case
1
:
this
.
login_before
(
'
apple
'
,
false
)
break
;
default
:
break
;
}
case
30006
:
uni
.
showModal
({
title
:
"
登录服务初始化错误
"
,
content
:
err
.
metadata
.
error_data
,
showCancel
:
false
,
confirmText
:
'
知道了
'
,
});
break
;
default
:
console
.
log
(
9527
,
err
);
case
"
30008
"
:
uni
.
showToast
({
title
:
'
点击了第三方登陆
'
,
icon
:
'
none
'
});
switch
(
err
.
index
)
{
case
0
:
this
.
login_before
(
'
weixin
'
,
false
)
break
;
case
1
:
this
.
login_before
(
'
apple
'
,
false
)
break
;
default
:
break
;
}
break
;
default
:
console
.
log
(
9527
,
err
);
break
;
}
}
...
...
@@ -283,31 +293,34 @@
})
},
login
(
params
,
type
)
{
//联网验证登录
console
.
log
(
'
type--
'
,
type
);
console
.
log
({
params
,
type
});
uniCloud
.
callFunction
({
name
:
'
uni-id-cf
'
,
data
:{
action
:
'
login_by_
'
+
type
,
params
},
success
:
({
result
})
=>
{
console
.
log
(
result
);
if
(
result
.
code
===
0
)
{
if
(
type
==
'
univerify
'
)
{
uni
.
closeAuthView
()
}
uni
.
hideLoading
()
loginSuccess
(
result
)
delete
result
.
userInfo
.
token
this
.
setUserInfo
(
result
.
userInfo
)
}
},
complete
:
()
=>
{
uni
.
hideLoading
()
}
uniCloud
.
callFunction
({
name
:
'
uni-id-cf
'
,
data
:
{
action
:
'
login_by_
'
+
type
,
params
},
success
:
({
result
})
=>
{
console
.
log
(
result
);
if
(
result
.
code
===
0
)
{
if
(
type
==
'
univerify
'
)
{
uni
.
closeAuthView
()
}
uni
.
hideLoading
()
loginSuccess
(
result
)
delete
result
.
userInfo
.
token
this
.
setUserInfo
(
result
.
userInfo
)
}
},
complete
:
()
=>
{
uni
.
hideLoading
()
}
})
},
async
getUserInfo
(
e
)
{
...
...
@@ -357,4 +370,4 @@
margin-top
:
4px
;
font-size
:
26
rpx
;
}
</
style
>
</
style
>
package.json
浏览文件 @
6a0dd700
{
"id"
:
"uni-starter"
,
"displayName"
:
"uni-starter"
,
"version"
:
"1.0.1
4
"
,
"version"
:
"1.0.1
5
"
,
"description"
:
"云端一体应用快速开发模版"
,
"keywords"
:
[
"uni-starter"
,
...
...
pages/list/list.nvue
浏览文件 @
6a0dd700
<template>
<view class="pagse">
<!-- #ifndef H5 -->
<statusBar></statusBar>
<!-- #endif -->
<!-- 搜索功能 -->
<uni-search-bar @click="searchClick" class="uni-search-box" v-model="keyword" ref="searchBar" radius="100" cancelButton="none" disabled/>
<view class="pagse">
<!-- #ifndef H5 -->
<statusBar></statusBar>
<!-- #endif -->
<!-- 搜索功能 -->
<uni-search-bar @click="searchClick" class="uni-search-box" v-model="keyword" ref="searchBar" radius="100"
cancelButton="none" disabled />
<unicloud-db ref='udb' v-slot:default="{data,pagination,hasMore, loading, error, options}" @error="onqueryerror"
:where="where" collection="opendb-news-articles,uni-id-users" :page-size="10"
field="avatar,title,last_modify_date,user_id.username">
field="avatar,title,last_modify_date,user_id.username">
<!-- 基于 uni-list 的页面布局 -->
<uni-list class="uni-list" :border="false" :bounce="true" :alwaysScrollableVertical="true" :style="{height:listHight}">
<uni-list-item :to="'./detail?id='+item._id+'&title='+item.title"
v-for="(item,index) in data" :key="index">
<uni-list class="uni-list" :border="false" :bounce="true" :alwaysScrollableVertical="true"
:style="{height:listHight}">
<uni-list-item :to="'./detail?id='+item._id+'&title='+item.title" v-for="(item,index) in data"
:key="index">
<!-- 通过header插槽定义列表左侧图片 -->
<template v-slot:header>
<image class="avatar" :src="item.avatar" mode="aspectFill"></image>
...
...
@@ -21,26 +23,29 @@
<text class="title">{{ item.title }}</text>
<view class="info">
<text class="author">{{item.user_id[0].username}}</text>
<uni-dateformat class="last_modify_date" :date="item.last_modify_date"
format="yyyy-MM-dd"
:threshold="[60000, 2592000000]" />
<uni-dateformat class="last_modify_date" :date="item.last_modify_date"
format="yyyy-MM-dd"
:threshold="[60000, 2592000000]" />
</view>
</view>
</uni-list-item>
<uni-list-item>
<template slot="body">
<uni-load-state @networkResume="refresh" :state="{data,pagination,hasMore, loading, error}"></uni-load-state>
</template>
<uni-list-item>
<template slot="body">
<uni-load-state @networkResume="refresh" :state="{data,pagination,hasMore, loading, error}">
</uni-load-state>
</template>
</uni-list-item>
</uni-list>
</uni-list>
</unicloud-db>
</view>
</template>
<script>
var cdbRef, currentWebview;
var cdbRef, currentWebview;
import statusBar from "@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar";
export default {
components: { statusBar },
export default {
components: {
statusBar
},
data() {
return {
where: "",
...
...
@@ -48,72 +53,75 @@
refreshState: 0,
listHight: 0
}
},
watch: {
keyword(keyword, oldValue) {
if(keyword){
this.where = `/${keyword}/.test(title)`;
}else{
this.where = '';
}
}
},
onReady() {
// #ifdef APP-NVUE
this.listHight = uni.getSystemInfoSync().windowHeight - 96 + 'px'
// #endif
// #ifndef APP-NVUE
this.listHight = 'auto'
watch: {
keyword(keyword, oldValue) {
if (keyword) {
this.where = `/${keyword}/.test(title)`;
} else {
this.where = '';
}
}
},
onReady() {
// #ifdef APP-NVUE
this.listHight = uni.getSystemInfoSync().windowHeight - 96 + 'px'
// #endif
// #ifndef APP-NVUE
this.listHight = 'auto'
// #endif
cdbRef = this.$refs.udb
cdbRef = this.$refs.udb
},
onShow() {
this.keyword = getApp().globalData.searchText
getApp().globalData.searchText = ''
if
(this.keyword){
// #ifdef APP-PLUS
if (!currentWebview) {
let pages = getCurrentPages();
currentWebview = pages[pages.length - 1].$getAppWebview();
}
// 设置 searchInput的 text
currentWebview.setTitleNViewSearchInputText(this.keyword)
// #endif
if
(this.keyword) {
// #ifdef APP-PLUS
if (!currentWebview) {
let pages = getCurrentPages();
currentWebview = pages[pages.length - 1].$getAppWebview();
}
// 设置 searchInput的 text
currentWebview.setTitleNViewSearchInputText(this.keyword)
// #endif
}
},
methods: {
searchClick(e) { //点击搜索框
searchClick(e) { //点击搜索框
uni.hideKeyboard();
uni.navigateTo({
url: '/pages/list/search/search',
animationType: 'fade-in'
});
},
retry()
{
this.refresh()
},
refresh()
{
cdbRef.loadData({
clear: true
}, () => {
uni.stopPullDownRefresh()
})
console.log('refresh');
},
retry()
{
this.refresh()
},
refresh()
{
cdbRef.loadData({
clear: true
}, () => {
uni.stopPullDownRefresh()
})
console.log('refresh');
}
},
onPullDownRefresh() {
this.refresh()
},
onReachBottom() {
cdbRef.loadMore({clear: true})
cdbRef.loadMore({
clear: true
})
}
}
</script>
<style scoped>
.pagse
{
background-color: #FFFFFF;
<style scoped>
.pagse
{
background-color: #FFFFFF;
}
.avatar {
width: 200rpx;
height: 200rpx;
...
...
@@ -160,7 +168,8 @@
/* #ifndef APP-PLUS */
z-index: 9;
/* #endif */
}
}
.show-refresh-tip {
transform: translateY(0);
height: 40px;
...
...
@@ -184,8 +193,10 @@
width: 750rpx;
text-align: center;
}
.uni-list {}
.f1{
flex: 1;
.uni-list {}
.f1 {
flex: 1;
}
</style>
pages/ucenter/login-page/index/index.vue
浏览文件 @
6a0dd700
...
...
@@ -67,9 +67,10 @@
onReady
()
{
//#ifdef APP-PLUS
if
(
univerify_first
)
{
console
.
log
(
'
开始一键登录
'
);
console
.
log
(
'
开始一键登录
'
);
this
.
agree
=
true
setTimeout
(()
=>
{
this
.
$refs
.
uniQuickLogin
.
login
(
'
univerify
'
)
this
.
$refs
.
uniQuickLogin
.
login
_before
(
'
univerify
'
)
},
100
)
setTimeout
(()
=>
{
currentWebview
.
setStyle
({
...
...
uni-starter.config.js
浏览文件 @
6a0dd700
...
...
@@ -26,7 +26,7 @@ module.exports = {
"
/pages/ucenter/userinfo/uploadCutImageToUnicloud
"
,
"
/uni_modules/uni-feedback/pages/uni-feedback/add
"
],
"
login
"
:
[
"
smsCode
"
,
"
univerify
"
,
"
username
"
,
"
weixin
"
,
"
apple
"
],
"
login
"
:
[
"
univerify
"
,
"
smsCode
"
,
"
username
"
,
"
weixin
"
,
"
apple
"
],
/*
根据数组的第0项,决定登录方式的第一优先级。
未列举到的,或设备环境不支持的选项,将被隐藏。
...
...
uniCloud-aliyun/cloudfunctions/uni-id-cf/index.js
浏览文件 @
6a0dd700
...
...
@@ -198,7 +198,7 @@ exports.main = async (event, context) => {
await
loginLog
(
res
)
break
;
case
'
login_by_univerify
'
:
res
=
await
uniID
.
loginBy
u
niverify
(
params
)
res
=
await
uniID
.
loginBy
U
niverify
(
params
)
await
loginLog
(
res
)
break
;
case
'
login_by_apple
'
:
...
...
uniCloud-aliyun/cloudfunctions/uni-id-cf/package-lock.json
浏览文件 @
6a0dd700
...
...
@@ -22,7 +22,7 @@
"license"
:
"Apache-2.0"
},
"../../../uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id"
:
{
"version"
:
"3.
0.12
"
,
"version"
:
"3.
1.0
"
,
"license"
:
"Apache-2.0"
,
"dependencies"
:
{
"uni-config-center"
:
"file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
...
...
uni_modules/uni-id/package.json
浏览文件 @
6a0dd700
{
"id"
:
"uni-id"
,
"displayName"
:
"uni-id"
,
"displayName"
:
"uni-id
公共模块
"
,
"version"
:
"3.1.0"
,
"description"
:
"简单、统一、可扩展的用户中心"
,
"keywords"
:
[
...
...
@@ -21,10 +21,10 @@
],
"sale"
:
{
"regular"
:
{
"price"
:
"0.00"
"price"
:
0
},
"sourcecode"
:
{
"price"
:
"0.00"
"price"
:
0
}
},
"contact"
:
{
...
...
uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id/index.js
浏览文件 @
6a0dd700
此差异已折叠。
点击以展开。
uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id/package-lock.json
浏览文件 @
6a0dd700
{
"name"
:
"uni-id"
,
"version"
:
"3.
0.12
"
,
"version"
:
"3.
1.0
"
,
"lockfileVersion"
:
2
,
"requires"
:
true
,
"packages"
:
{
""
:
{
"version"
:
"3.
0.12
"
,
"version"
:
"3.
1.0
"
,
"license"
:
"Apache-2.0"
,
"dependencies"
:
{
"uni-captcha"
:
"file:../../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha"
,
"uni-config-center"
:
"file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
}
},
"../../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha"
:
{
"version"
:
"0.1.0"
,
"license"
:
"Apache-2.0"
},
"../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
:
{
"version"
:
"0.0.2"
,
"license"
:
"Apache-2.0"
},
"node_modules/uni-captcha"
:
{
"resolved"
:
"../../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha"
,
"link"
:
true
},
"node_modules/uni-config-center"
:
{
"resolved"
:
"../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
,
"link"
:
true
}
},
"dependencies"
:
{
"uni-captcha"
:
{
"version"
:
"file:../../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha"
},
"uni-config-center"
:
{
"version"
:
"file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
}
...
...
uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id/package.json
浏览文件 @
6a0dd700
{
"name"
:
"uni-id"
,
"version"
:
"3.
0.12
"
,
"version"
:
"3.
1.0
"
,
"description"
:
"uni-id for uniCloud"
,
"main"
:
"index.js"
,
"homepage"
:
"https://uniapp.dcloud.io/uniCloud/uni-id"
,
...
...
@@ -11,6 +11,7 @@
"author"
:
""
,
"license"
:
"Apache-2.0"
,
"dependencies"
:
{
"uni-captcha"
:
"file:../../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha"
,
"uni-config-center"
:
"file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
}
}
uni_modules/uni-share/changelog.md
浏览文件 @
6a0dd700
## 1.0.4(2021-06-07)
为符合苹果应用市场的审核,只显示存在对应的分享客户端的选项。如:配置包含微信分享,但是用户手机上并没有安装微信,就不显示微信分享。
## 1.0.2(2021-05-06)
修复错误的提示:“打包时未添加oauth模块”
## 1.0.1(2021-04-30)
新增完整示例
## 1.0.0(2021-04-28)
第1版发布
uni_modules/uni-share/js_sdk/uni-image-menu.js
0 → 100644
浏览文件 @
6a0dd700
var
nvMask
,
nvImageMenu
;
export
default
{
show
({
list
,
cancelText
},
callback
){
if
(
!
list
){
list
=
[{
"
img
"
:
"
https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-dc-site/9a952c80-6080-11eb-a16f-5b3e54966275.png
"
,
"
text
"
:
"
图标文字
"
}]
}
if
(
list
.
length
>
8
){
return
uni
.
showToast
({
title
:
'
目前版本最多支持8个图标
'
,
icon
:
'
none
'
});
}
//以下为计算菜单的nview绘制布局,为固定算法,使用者无关关心
var
screenWidth
=
plus
.
screen
.
resolutionWidth
//以360px宽度屏幕为例,上下左右边距及2排按钮边距留25像素,图标宽度55像素,同行图标间的间距在360宽的屏幕是30px,但需要动态计算,以此原则计算4列图标分别的left位置
//图标下的按钮文字距离图标5像素,文字大小12像素
//底部取消按钮高度固定为44px
//TODO 未处理横屏和pad,这些情况6个图标应该一排即可
var
margin
=
20
,
iconWidth
=
60
,
icontextSpace
=
5
,
textHeight
=
12
var
left1
=
margin
/
360
*
screenWidth
var
iconSpace
=
(
screenWidth
-
(
left1
*
2
)
-
(
iconWidth
*
4
))
/
3
//屏幕宽度减去左右留白间距,再减去4个图标的宽度,就是3个同行图标的间距
if
(
iconSpace
<=
5
)
{
//屏幕过窄时,缩小边距和图标大小,再算一次
margin
=
15
iconWidth
=
40
left1
=
margin
/
360
*
screenWidth
iconSpace
=
(
screenWidth
-
(
left1
*
2
)
-
(
iconWidth
*
4
))
/
3
//屏幕宽度减去左右留白间距,再减去4个图标的宽度,就是3个同行图标的间距
}
var
left2
=
left1
+
iconWidth
+
iconSpace
var
left3
=
left1
+
(
iconWidth
+
iconSpace
)
*
2
var
left4
=
left1
+
(
iconWidth
+
iconSpace
)
*
3
var
top1
=
left1
var
top2
=
top1
+
iconWidth
+
icontextSpace
+
textHeight
+
left1
nvMask
=
new
plus
.
nativeObj
.
View
(
"
nvMask
"
,
{
//先创建遮罩层
top
:
'
0px
'
,
left
:
'
0px
'
,
height
:
'
100%
'
,
width
:
'
100%
'
,
backgroundColor
:
'
rgba(0,0,0,0.2)
'
});
nvMask
.
addEventListener
(
"
click
"
,
function
()
{
//处理遮罩层点击
nvMask
.
hide
();
nvImageMenu
.
hide
();
})
nvImageMenu
=
new
plus
.
nativeObj
.
View
(
"
nvImageMenu
"
,
{
//创建底部图标菜单
bottom
:
'
0px
'
,
left
:
'
0px
'
,
height
:
(
iconWidth
+
textHeight
+
2
*
margin
)
*
Math
.
ceil
(
list
.
length
/
4
)
+
44
+
'
px
'
,
//'264px',
width
:
'
100%
'
,
backgroundColor
:
'
rgb(255,255,255)
'
});
let
myList
=
[]
list
.
forEach
((
item
,
i
)
=>
{
myList
.
push
({
tag
:
'
img
'
,
src
:
item
.
img
,
position
:
{
top
:
eval
(
'
top
'
+
(
parseInt
(
i
/
4
)
+
1
)),
left
:
eval
(
'
left
'
+
(
1
+
i
%
4
)),
width
:
iconWidth
,
height
:
iconWidth
}
})
myList
.
push
({
tag
:
'
font
'
,
text
:
item
.
text
,
textStyles
:
{
size
:
textHeight
},
position
:
{
top
:
eval
(
'
top
'
+
(
parseInt
(
i
/
4
)
+
1
))
+
iconWidth
+
icontextSpace
,
left
:
eval
(
'
left
'
+
(
1
+
i
%
4
)),
width
:
iconWidth
,
height
:
textHeight
}
})
})
//绘制底部图标菜单的内容
nvImageMenu
.
draw
([
{
tag
:
'
rect
'
,
//菜单顶部的分割灰线
color
:
'
#e7e7e7
'
,
position
:
{
top
:
'
0px
'
,
height
:
'
1px
'
}
},
{
tag
:
'
font
'
,
text
:
cancelText
,
//底部取消按钮的文字
textStyles
:
{
size
:
'
14px
'
},
position
:
{
bottom
:
'
0px
'
,
height
:
'
44px
'
}
},
{
tag
:
'
rect
'
,
//底部取消按钮的顶部边线
color
:
'
#e7e7e7
'
,
position
:
{
bottom
:
'
45px
'
,
height
:
'
1px
'
}
},
...
myList
])
nvMask
.
show
()
nvImageMenu
.
show
()
//5+应支持从底部向上弹出的动画
nvImageMenu
.
addEventListener
(
"
click
"
,
e
=>
{
//处理底部图标菜单的点击事件,根据点击位置触发不同的逻辑
// console.log("click menu"+JSON.stringify(e));
if
(
e
.
screenY
>
plus
.
screen
.
resolutionHeight
-
44
)
{
//点击了底部取消按钮
nvMask
.
hide
();
nvImageMenu
.
hide
();
}
else
if
(
e
.
clientX
<
5
||
e
.
clientX
>
screenWidth
-
5
||
e
.
clientY
<
5
)
{
//屏幕左右边缘5像素及菜单顶部5像素不处理点击
}
else
{
//点击了图标按钮
var
iClickIndex
=
-
1
//点击的图标按钮序号,第一个图标按钮的index为0
var
iRow
=
e
.
clientY
<
(
top2
-
(
left1
/
2
))
?
0
:
1
var
iCol
=
-
1
if
(
e
.
clientX
<
(
left2
-
(
iconSpace
/
2
)))
{
iCol
=
0
}
else
if
(
e
.
clientX
<
(
left3
-
(
iconSpace
/
2
)))
{
iCol
=
1
}
else
if
(
e
.
clientX
<
(
left4
-
(
iconSpace
/
2
)))
{
iCol
=
2
}
else
{
iCol
=
3
}
if
(
iRow
==
0
)
{
iClickIndex
=
iCol
}
else
{
iClickIndex
=
iCol
+
4
}
// console.log("点击按钮的序号: " + iClickIndex);
// if (iClickIndex >= 0 && iClickIndex <= 5) { //处理具体的点击逻辑,此处也可以自行定义逻辑。如果增减了按钮,此处也需要跟着修改
// }
callback
(
iClickIndex
)
this
.
hide
()
}
})
/* nvImageMenu.addEventListener("touchstart", function(e) {
if (e.screenY > (plus.screen.resolutionHeight - 44)) {
//TODO 这里可以处理按下背景变灰的效果
}
})
nvImageMenu.addEventListener("touchmove", function(e) {
//TODO 这里可以处理按下背景变灰的效果
if (e.screenY > plus.screen.resolutionHeight - 44) {}
})
nvImageMenu.addEventListener("touchend", function(e) {
//TODO 这里可以处理释放背景恢复的效果
})
*/
},
hide
(){
nvMask
.
hide
()
nvImageMenu
.
hide
()
}
}
\ No newline at end of file
uni_modules/uni-share/js_sdk/uni-share.js
浏览文件 @
6a0dd700
import
uniImageMenu
from
'
uni_modules/uni-image-menu/js_sdk
/uni-image-menu.js
'
;
import
uniImageMenu
from
'
.
/uni-image-menu.js
'
;
export
default
async
(
param
,
callback
)
=>
{
var
menus
=
[]
plus
.
oauth
.
getServices
(
services
=>
{
//只显示有服务的项目
plus
.
share
.
getServices
(
services
=>
{
//只显示有服务的项目
services
=
services
.
filter
(
item
=>
item
.
nativeClient
)
// console.log("servicesList",services);
let
servicesList
=
services
.
map
(
e
=>
e
.
id
)
console
.
log
(
servicesList
);
param
.
menus
.
forEach
(
item
=>
{
if
(
servicesList
.
includes
(
item
.
share
.
provider
)
||
typeof
(
item
.
share
)
==
'
string
'
)
{
menus
.
push
(
item
)
...
...
@@ -27,6 +28,11 @@ export default async (param,callback) => {
},
fail
:
function
(
err
)
{
console
.
log
(
"
fail:
"
+
JSON
.
stringify
(
err
));
uni
.
showModal
({
content
:
JSON
.
stringify
(
err
),
showCancel
:
false
,
confirmText
:
"
知道了
"
});
},
complete
(
e
)
{
uniImageMenu
.
hide
()
...
...
uni_modules/uni-share/package.json
浏览文件 @
6a0dd700
{
"id"
:
"uni-share"
,
"displayName"
:
"uni-share"
,
"version"
:
"1.0.
0
"
,
"version"
:
"1.0.
4
"
,
"description"
:
"底部弹出宫格图标式的分享菜单,可覆盖原生组件。"
,
"keywords"
:
[
"分享菜单"
...
...
uni_modules/uni-share/readme.md
浏览文件 @
6a0dd700
#### 本功能基于[底部图标菜单](https://ext.dcloud.net.cn/plugin?id=4858)封装而成。
### 示例代码
```
uniShare({
content: { //公共的分享参数配置 类型(type)、链接(herf)、标题(title)、summary(描述)、imageUrl(缩略图)
type: 0,
href: 'https://uniapp.dcloud.io/',
title: '标题',
summary: '描述',
imageUrl: 'https://img-cdn-aliyun.dcloud.net.cn/stream/icon/__UNI__HelloUniApp.png'
},
menus: [{
"img": "/static/app-plus/sharemenu/wechatfriend.png",
"text": "微信好友",
"share": { //当前项的分享参数配置。可覆盖公共的配置如下:分享到微信小程序,配置了type=5
"provider": "weixin",
"scene": "WXSceneSession"
}
},
{
"img": "/static/app-plus/sharemenu/wechatmoments.png",
"text": "微信朋友圈",
"share": {
"provider": "weixin",
"scene": "WXSenceTimeline"
}
},
{
"img": "/static/app-plus/sharemenu/mp_weixin.png",
"text": "微信小程序",
"share": {
provider: "weixin",
scene: "WXSceneSession",
type: 5,
miniProgram: {
id: uniStarterConfig.mp.weixin.id,
path: `/pages/list/detail?id=${_id}&title=${title}`,
webUrl: uniStarterConfig.h5.url +
`/#/pages/list/detail?id=${_id}&title=${title}`,
type: 0
},
}
},
{
"img": "/static/app-plus/sharemenu/weibo.png",
"text": "微博",
"share": {
"provider": "sinaweibo"
}
},
{
"img": "/static/app-plus/sharemenu/qq.png",
"text": "QQ",
"share": {
"provider": "qq"
}
},
{
"img": "/static/app-plus/sharemenu/copyurl.png",
"text": "复制",
"share": "copyurl"
},
{
"img": "/static/app-plus/sharemenu/more.png",
"text": "更多",
"share": "shareSystem"
}
],
cancelText: "取消分享",
}, e => { //callback
console.log(e);
})
<template>
<button type="default" @click="uniShare">显示</button>
</template>
<script>
import uniShare from 'uni_modules/uni-share/js_sdk/uni-share.js';
export default {
methods: {
uniShare() {
uniShare({
content: { //公共的分享参数配置 类型(type)、链接(herf)、标题(title)、summary(描述)、imageUrl(缩略图)
type: 0,
href: 'https://uniapp.dcloud.io/',
title: '标题',
summary: '描述',
imageUrl: 'https://img-cdn-aliyun.dcloud.net.cn/stream/icon/__UNI__HelloUniApp.png'
},
menus: [{
"img": "/static/app-plus/sharemenu/wechatfriend.png",
"text": "微信好友",
"share": { //当前项的分享参数配置。可覆盖公共的配置如下:分享到微信小程序,配置了type=5
"provider": "weixin",
"scene": "WXSceneSession"
}
},
{
"img": "/static/app-plus/sharemenu/wechatmoments.png",
"text": "微信朋友圈",
"share": {
"provider": "weixin",
"scene": "WXSenceTimeline"
}
},
{
"img": "/static/app-plus/sharemenu/mp_weixin.png",
"text": "微信小程序",
"share": {
provider: "weixin",
scene: "WXSceneSession",
type: 5,
miniProgram: {
id: '123',
path: '/pages/list/detail',
webUrl: '/#/pages/list/detail',
type: 0
},
}
},
{
"img": "/static/app-plus/sharemenu/weibo.png",
"text": "微博",
"share": {
"provider": "sinaweibo"
}
},
{
"img": "/static/app-plus/sharemenu/qq.png",
"text": "QQ",
"share": {
"provider": "qq"
}
},
{
"img": "/static/app-plus/sharemenu/copyurl.png",
"text": "复制",
"share": "copyurl"
},
{
"img": "/static/app-plus/sharemenu/more.png",
"text": "更多",
"share": "shareSystem"
}
],
cancelText: "取消分享",
}, e => { //callback
console.log(e);
})
}
}
}
</script>
```
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录