提交 6a0dd700 编写于 作者: DCloud_JSON's avatar DCloud_JSON

为迎合苹果App Store的规则,登陆与分享功能项显示之前自动检测是否安装了对应客户端。比如:设备未安装微信则不显示微信快捷登陆和微信分享选项。

上级 8772e133
## 1.0.15(2021-06-07)
为迎合苹果App Store的规则,登陆与分享功能项显示之前自动检测是否安装了对应客户端。比如:设备未安装微信则不显示微信快捷登陆和微信分享选项。
## 1.0.14(2021-06-07) ## 1.0.14(2021-06-07)
修改错误的表名称uni-verify为opendb-verify-codes 修改错误的表名称uni-verify为opendb-verify-codes
## 1.0.13(2021-06-04) ## 1.0.13(2021-06-04)
......
...@@ -39,9 +39,9 @@ ...@@ -39,9 +39,9 @@
} }
}, },
props: { props: {
agree:{ agree: {
type:Boolean, type: Boolean,
default(){ default () {
return false return false
} }
}, },
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
//去掉配置项中不存在的项 //去掉配置项中不存在的项
for (var i = 0; i < servicesList.length; i++) { for (var i = 0; i < servicesList.length; i++) {
if (!this.loginConfig.includes(servicesList[i].id)) { if (!this.loginConfig.includes(servicesList[i].id)) {
console.log('去掉配置项中不存在的项',servicesList[i].id); console.log('去掉配置项中不存在的项', servicesList[i].id);
servicesList.splice(i, 1) servicesList.splice(i, 1)
} }
} }
...@@ -119,15 +119,23 @@ ...@@ -119,15 +119,23 @@
oauthServices.forEach(({ oauthServices.forEach(({
id 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.servicesList.push({
...this.config[id], ...this.config[id],
id id
}) })
} }
}) })
// console.log(oauthServices); // console.log('oauthServices',oauthServices);
}, err => { }, err => {
uni.hideLoading() uni.hideLoading()
uni.showModal({ uni.showModal({
...@@ -171,13 +179,15 @@ ...@@ -171,13 +179,15 @@
} }
}, },
login_before(type, navigateBack = true) { login_before(type, navigateBack = true) {
if(!this.agree){ if (!this.agree) {
return uni.showToast({ return uni.showToast({
title: '你未同意隐私政策协议', title: '你未同意隐私政策协议',
icon: 'none' icon: 'none'
}); });
} }
uni.showLoading({mask:true}) uni.showLoading({
mask: true
})
// console.log(arguments); // console.log(arguments);
let oauthService = this.oauthServices.find((service) => service.id == type) let oauthService = this.oauthServices.find((service) => service.id == type)
// console.log(type); // console.log(type);
...@@ -195,10 +205,10 @@ ...@@ -195,10 +205,10 @@
}, },
err => { err => {
uni.hideLoading() uni.hideLoading()
console.log(err); console.log(err);
uni.showModal({ uni.showModal({
content: JSON.stringify(err), content: JSON.stringify(err),
showCancel: false showCancel: false
}); });
}) })
} }
...@@ -233,7 +243,7 @@ ...@@ -233,7 +243,7 @@
console.log(err); console.log(err);
if (type == 'univerify') { if (type == 'univerify') {
if (err.metadata&&err.metadata.error_data) { if (err.metadata && err.metadata.error_data) {
uni.showToast({ uni.showToast({
title: "一键登录:" + err.metadata.error_data, title: "一键登录:" + err.metadata.error_data,
icon: 'none' icon: 'none'
...@@ -249,33 +259,33 @@ ...@@ -249,33 +259,33 @@
uni.navigateBack() uni.navigateBack()
} }
break; break;
case 30006: case 30006:
uni.showModal({ uni.showModal({
title: "登录服务初始化错误", title: "登录服务初始化错误",
content: err.metadata.error_data, content: err.metadata.error_data,
showCancel: false, showCancel: false,
confirmText: '知道了', 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;
}
break; break;
default: case "30008":
console.log(9527,err); 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; break;
} }
} }
...@@ -283,31 +293,34 @@ ...@@ -283,31 +293,34 @@
}) })
}, },
login(params, type) { //联网验证登录 login(params, type) { //联网验证登录
console.log('type--', type);
console.log({ console.log({
params, params,
type type
}); });
uniCloud.callFunction({ uniCloud.callFunction({
name:'uni-id-cf', name: 'uni-id-cf',
data:{ data: {
action:'login_by_'+type, action: 'login_by_' + type,
params params
}, },
success: ({result}) => { success: ({
console.log(result); result
if (result.code === 0) { }) => {
if (type == 'univerify') { console.log(result);
uni.closeAuthView() if (result.code === 0) {
} if (type == 'univerify') {
uni.hideLoading() uni.closeAuthView()
loginSuccess(result) }
delete result.userInfo.token uni.hideLoading()
this.setUserInfo(result.userInfo) loginSuccess(result)
} delete result.userInfo.token
}, this.setUserInfo(result.userInfo)
complete: () => { }
uni.hideLoading() },
} complete: () => {
uni.hideLoading()
}
}) })
}, },
async getUserInfo(e) { async getUserInfo(e) {
...@@ -357,4 +370,4 @@ ...@@ -357,4 +370,4 @@
margin-top: 4px; margin-top: 4px;
font-size: 26rpx; font-size: 26rpx;
} }
</style> </style>
{ {
"id": "uni-starter", "id": "uni-starter",
"displayName": "uni-starter", "displayName": "uni-starter",
"version": "1.0.14", "version": "1.0.15",
"description": "云端一体应用快速开发模版", "description": "云端一体应用快速开发模版",
"keywords": [ "keywords": [
"uni-starter", "uni-starter",
......
<template> <template>
<view class="pagse"> <view class="pagse">
<!-- #ifndef H5 --> <!-- #ifndef H5 -->
<statusBar></statusBar> <statusBar></statusBar>
<!-- #endif --> <!-- #endif -->
<!-- 搜索功能 --> <!-- 搜索功能 -->
<uni-search-bar @click="searchClick" class="uni-search-box" v-model="keyword" ref="searchBar" radius="100" cancelButton="none" disabled/> <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" <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" :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 的页面布局 -->
<uni-list class="uni-list" :border="false" :bounce="true" :alwaysScrollableVertical="true" :style="{height:listHight}"> <uni-list class="uni-list" :border="false" :bounce="true" :alwaysScrollableVertical="true"
<uni-list-item :to="'./detail?id='+item._id+'&title='+item.title" :style="{height:listHight}">
v-for="(item,index) in data" :key="index"> <uni-list-item :to="'./detail?id='+item._id+'&title='+item.title" v-for="(item,index) in data"
:key="index">
<!-- 通过header插槽定义列表左侧图片 --> <!-- 通过header插槽定义列表左侧图片 -->
<template v-slot:header> <template v-slot:header>
<image class="avatar" :src="item.avatar" mode="aspectFill"></image> <image class="avatar" :src="item.avatar" mode="aspectFill"></image>
...@@ -21,26 +23,29 @@ ...@@ -21,26 +23,29 @@
<text class="title">{{ item.title }}</text> <text class="title">{{ item.title }}</text>
<view class="info"> <view class="info">
<text class="author">{{item.user_id[0].username}}</text> <text class="author">{{item.user_id[0].username}}</text>
<uni-dateformat class="last_modify_date" :date="item.last_modify_date" <uni-dateformat class="last_modify_date" :date="item.last_modify_date" format="yyyy-MM-dd"
format="yyyy-MM-dd" :threshold="[60000, 2592000000]" /> :threshold="[60000, 2592000000]" />
</view> </view>
</view> </view>
</uni-list-item> </uni-list-item>
<uni-list-item> <uni-list-item>
<template slot="body"> <template slot="body">
<uni-load-state @networkResume="refresh" :state="{data,pagination,hasMore, loading, error}"></uni-load-state> <uni-load-state @networkResume="refresh" :state="{data,pagination,hasMore, loading, error}">
</template> </uni-load-state>
</template>
</uni-list-item> </uni-list-item>
</uni-list> </uni-list>
</unicloud-db> </unicloud-db>
</view> </view>
</template> </template>
<script> <script>
var cdbRef, currentWebview; var cdbRef, currentWebview;
import statusBar from "@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar"; import statusBar from "@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar";
export default { export default {
components: { statusBar }, components: {
statusBar
},
data() { data() {
return { return {
where: "", where: "",
...@@ -48,72 +53,75 @@ ...@@ -48,72 +53,75 @@
refreshState: 0, refreshState: 0,
listHight: 0 listHight: 0
} }
},
watch: {
keyword(keyword, oldValue) {
if(keyword){
this.where = `/${keyword}/.test(title)`;
}else{
this.where = '';
}
}
}, },
onReady() { watch: {
// #ifdef APP-NVUE keyword(keyword, oldValue) {
this.listHight = uni.getSystemInfoSync().windowHeight - 96 + 'px' if (keyword) {
// #endif this.where = `/${keyword}/.test(title)`;
// #ifndef APP-NVUE } else {
this.listHight = 'auto' this.where = '';
}
}
},
onReady() {
// #ifdef APP-NVUE
this.listHight = uni.getSystemInfoSync().windowHeight - 96 + 'px'
// #endif
// #ifndef APP-NVUE
this.listHight = 'auto'
// #endif // #endif
cdbRef = this.$refs.udb cdbRef = this.$refs.udb
}, },
onShow() { onShow() {
this.keyword = getApp().globalData.searchText this.keyword = getApp().globalData.searchText
getApp().globalData.searchText = '' getApp().globalData.searchText = ''
if(this.keyword){ if (this.keyword) {
// #ifdef APP-PLUS // #ifdef APP-PLUS
if (!currentWebview) { if (!currentWebview) {
let pages = getCurrentPages(); let pages = getCurrentPages();
currentWebview = pages[pages.length - 1].$getAppWebview(); currentWebview = pages[pages.length - 1].$getAppWebview();
} }
// 设置 searchInput的 text // 设置 searchInput的 text
currentWebview.setTitleNViewSearchInputText(this.keyword) currentWebview.setTitleNViewSearchInputText(this.keyword)
// #endif // #endif
} }
}, },
methods: { methods: {
searchClick(e) { //点击搜索框 searchClick(e) { //点击搜索框
uni.hideKeyboard(); uni.hideKeyboard();
uni.navigateTo({ uni.navigateTo({
url: '/pages/list/search/search', url: '/pages/list/search/search',
animationType: 'fade-in' animationType: 'fade-in'
}); });
}, },
retry(){ retry() {
this.refresh() this.refresh()
}, },
refresh(){ refresh() {
cdbRef.loadData({ cdbRef.loadData({
clear: true clear: true
}, () => { }, () => {
uni.stopPullDownRefresh() uni.stopPullDownRefresh()
}) })
console.log('refresh'); console.log('refresh');
} }
}, },
onPullDownRefresh() { onPullDownRefresh() {
this.refresh() this.refresh()
}, },
onReachBottom() { onReachBottom() {
cdbRef.loadMore({clear: true}) cdbRef.loadMore({
clear: true
})
} }
} }
</script> </script>
<style scoped> <style scoped>
.pagse{ .pagse {
background-color: #FFFFFF; background-color: #FFFFFF;
} }
.avatar { .avatar {
width: 200rpx; width: 200rpx;
height: 200rpx; height: 200rpx;
...@@ -160,7 +168,8 @@ ...@@ -160,7 +168,8 @@
/* #ifndef APP-PLUS */ /* #ifndef APP-PLUS */
z-index: 9; z-index: 9;
/* #endif */ /* #endif */
} }
.show-refresh-tip { .show-refresh-tip {
transform: translateY(0); transform: translateY(0);
height: 40px; height: 40px;
...@@ -184,8 +193,10 @@ ...@@ -184,8 +193,10 @@
width: 750rpx; width: 750rpx;
text-align: center; text-align: center;
} }
.uni-list {}
.f1{ .uni-list {}
flex: 1;
.f1 {
flex: 1;
} }
</style> </style>
...@@ -67,9 +67,10 @@ ...@@ -67,9 +67,10 @@
onReady() { onReady() {
//#ifdef APP-PLUS //#ifdef APP-PLUS
if (univerify_first) { if (univerify_first) {
console.log('开始一键登录'); console.log('开始一键登录');
this.agree = true
setTimeout(() => { setTimeout(() => {
this.$refs.uniQuickLogin.login('univerify') this.$refs.uniQuickLogin.login_before('univerify')
}, 100) }, 100)
setTimeout(() => { setTimeout(() => {
currentWebview.setStyle({ currentWebview.setStyle({
......
...@@ -26,7 +26,7 @@ module.exports = { ...@@ -26,7 +26,7 @@ module.exports = {
"/pages/ucenter/userinfo/uploadCutImageToUnicloud", "/pages/ucenter/userinfo/uploadCutImageToUnicloud",
"/uni_modules/uni-feedback/pages/uni-feedback/add" "/uni_modules/uni-feedback/pages/uni-feedback/add"
], ],
"login": ["smsCode","univerify", "username", "weixin", "apple"], "login": ["univerify","smsCode", "username", "weixin", "apple"],
/* /*
根据数组的第0项,决定登录方式的第一优先级。 根据数组的第0项,决定登录方式的第一优先级。
未列举到的,或设备环境不支持的选项,将被隐藏。 未列举到的,或设备环境不支持的选项,将被隐藏。
......
...@@ -198,7 +198,7 @@ exports.main = async (event, context) => { ...@@ -198,7 +198,7 @@ exports.main = async (event, context) => {
await loginLog(res) await loginLog(res)
break; break;
case 'login_by_univerify': case 'login_by_univerify':
res = await uniID.loginByuniverify(params) res = await uniID.loginByUniverify(params)
await loginLog(res) await loginLog(res)
break; break;
case 'login_by_apple': case 'login_by_apple':
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
"license": "Apache-2.0" "license": "Apache-2.0"
}, },
"../../../uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id": { "../../../uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id": {
"version": "3.0.12", "version": "3.1.0",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"uni-config-center": "file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center" "uni-config-center": "file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
......
{ {
"id": "uni-id", "id": "uni-id",
"displayName": "uni-id", "displayName": "uni-id公共模块",
"version": "3.1.0", "version": "3.1.0",
"description": "简单、统一、可扩展的用户中心", "description": "简单、统一、可扩展的用户中心",
"keywords": [ "keywords": [
...@@ -21,10 +21,10 @@ ...@@ -21,10 +21,10 @@
], ],
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": 0
}, },
"sourcecode": { "sourcecode": {
"price": "0.00" "price": 0
} }
}, },
"contact": { "contact": {
......
{ {
"name": "uni-id", "name": "uni-id",
"version": "3.0.12", "version": "3.1.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"version": "3.0.12", "version": "3.1.0",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "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-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": { "../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center": {
"version": "0.0.2", "version": "0.0.2",
"license": "Apache-2.0" "license": "Apache-2.0"
}, },
"node_modules/uni-captcha": {
"resolved": "../../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha",
"link": true
},
"node_modules/uni-config-center": { "node_modules/uni-config-center": {
"resolved": "../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center", "resolved": "../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center",
"link": true "link": true
} }
}, },
"dependencies": { "dependencies": {
"uni-captcha": {
"version": "file:../../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha"
},
"uni-config-center": { "uni-config-center": {
"version": "file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center" "version": "file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
} }
......
{ {
"name": "uni-id", "name": "uni-id",
"version": "3.0.12", "version": "3.1.0",
"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,6 +11,7 @@ ...@@ -11,6 +11,7 @@
"author": "", "author": "",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "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-config-center": "file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
} }
} }
## 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.0.0(2021-04-28)
第1版发布 第1版发布
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
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) => { export default async (param,callback) => {
var menus = [] 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) let servicesList = services.map(e => e.id)
console.log(servicesList);
param.menus.forEach(item => { param.menus.forEach(item => {
if (servicesList.includes(item.share.provider) || typeof(item.share) == 'string') { if (servicesList.includes(item.share.provider) || typeof(item.share) == 'string') {
menus.push(item) menus.push(item)
...@@ -27,6 +28,11 @@ export default async (param,callback) => { ...@@ -27,6 +28,11 @@ export default async (param,callback) => {
}, },
fail: function(err) { fail: function(err) {
console.log("fail:" + JSON.stringify(err)); console.log("fail:" + JSON.stringify(err));
uni.showModal({
content: JSON.stringify(err),
showCancel: false,
confirmText:"知道了"
});
}, },
complete(e) { complete(e) {
uniImageMenu.hide() uniImageMenu.hide()
......
{ {
"id": "uni-share", "id": "uni-share",
"displayName": "uni-share", "displayName": "uni-share",
"version": "1.0.0", "version": "1.0.4",
"description": "底部弹出宫格图标式的分享菜单,可覆盖原生组件。", "description": "底部弹出宫格图标式的分享菜单,可覆盖原生组件。",
"keywords": [ "keywords": [
"分享菜单" "分享菜单"
......
#### 本功能基于[底部图标菜单](https://ext.dcloud.net.cn/plugin?id=4858)封装而成。 #### 本功能基于[底部图标菜单](https://ext.dcloud.net.cn/plugin?id=4858)封装而成。
### 示例代码 ### 示例代码
``` ```
uniShare({ <template>
content: { //公共的分享参数配置 类型(type)、链接(herf)、标题(title)、summary(描述)、imageUrl(缩略图) <button type="default" @click="uniShare">显示</button>
type: 0, </template>
href: 'https://uniapp.dcloud.io/', <script>
title: '标题', import uniShare from 'uni_modules/uni-share/js_sdk/uni-share.js';
summary: '描述', export default {
imageUrl: 'https://img-cdn-aliyun.dcloud.net.cn/stream/icon/__UNI__HelloUniApp.png' methods: {
}, uniShare() {
menus: [{ uniShare({
"img": "/static/app-plus/sharemenu/wechatfriend.png", content: { //公共的分享参数配置 类型(type)、链接(herf)、标题(title)、summary(描述)、imageUrl(缩略图)
"text": "微信好友", type: 0,
"share": { //当前项的分享参数配置。可覆盖公共的配置如下:分享到微信小程序,配置了type=5 href: 'https://uniapp.dcloud.io/',
"provider": "weixin", title: '标题',
"scene": "WXSceneSession" summary: '描述',
} imageUrl: 'https://img-cdn-aliyun.dcloud.net.cn/stream/icon/__UNI__HelloUniApp.png'
}, },
{ menus: [{
"img": "/static/app-plus/sharemenu/wechatmoments.png", "img": "/static/app-plus/sharemenu/wechatfriend.png",
"text": "微信朋友圈", "text": "微信好友",
"share": { "share": { //当前项的分享参数配置。可覆盖公共的配置如下:分享到微信小程序,配置了type=5
"provider": "weixin", "provider": "weixin",
"scene": "WXSenceTimeline" "scene": "WXSceneSession"
} }
}, },
{ {
"img": "/static/app-plus/sharemenu/mp_weixin.png", "img": "/static/app-plus/sharemenu/wechatmoments.png",
"text": "微信小程序", "text": "微信朋友圈",
"share": { "share": {
provider: "weixin", "provider": "weixin",
scene: "WXSceneSession", "scene": "WXSenceTimeline"
type: 5, }
miniProgram: { },
id: uniStarterConfig.mp.weixin.id, {
path: `/pages/list/detail?id=${_id}&title=${title}`, "img": "/static/app-plus/sharemenu/mp_weixin.png",
webUrl: uniStarterConfig.h5.url + "text": "微信小程序",
`/#/pages/list/detail?id=${_id}&title=${title}`, "share": {
type: 0 provider: "weixin",
}, scene: "WXSceneSession",
} type: 5,
}, miniProgram: {
{ id: '123',
"img": "/static/app-plus/sharemenu/weibo.png", path: '/pages/list/detail',
"text": "微博", webUrl: '/#/pages/list/detail',
"share": { type: 0
"provider": "sinaweibo" },
} }
}, },
{ {
"img": "/static/app-plus/sharemenu/qq.png", "img": "/static/app-plus/sharemenu/weibo.png",
"text": "QQ", "text": "微博",
"share": { "share": {
"provider": "qq" "provider": "sinaweibo"
} }
}, },
{ {
"img": "/static/app-plus/sharemenu/copyurl.png", "img": "/static/app-plus/sharemenu/qq.png",
"text": "复制", "text": "QQ",
"share": "copyurl" "share": {
}, "provider": "qq"
{ }
"img": "/static/app-plus/sharemenu/more.png", },
"text": "更多", {
"share": "shareSystem" "img": "/static/app-plus/sharemenu/copyurl.png",
} "text": "复制",
], "share": "copyurl"
cancelText: "取消分享", },
}, e => { //callback {
console.log(e); "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.
先完成此消息的编辑!
想要评论请 注册