UNPKG

minix-template

Version:

minix template

277 lines (275 loc) 8.07 kB
/* * @Description: * @Autor: tangsj * @Date: 2022-05-12 19:08:11 * @LastEditTime: 2022-05-23 16:37:35 */ import router from '@system.router' import prompt from '@system.prompt' export default { data: { shareList:[ { name:'checkInstalledThirdPlatform', // url:'pages/base/canlUse/index', describe:'是否安装第三方平台,QQ,微信,微博' }, { name:'inviteFamily', // url:'pages/base/log/index', describe:'邀请家庭' }, { name:'openShare', // url:'pages/base/canlUse/index', describe:'打开系统的分享' }, { name:'shareCustomPanel', // url:'pages/base/log/index', describe:'自定义分享' }, { name:'shareMsg', // url:'pages/base/log/index', describe:'分享功能,直接触发分享(微信,QQ,微博等' }, { name:'sharePeerToPeer', // url:'pages/base/canlUse/index', describe:'点对点分享到第三方平台' }, { name:'showSharePanel', // url:'pages/base/canlUse/index', describe:'打开分享界面(Promise返回),微信,朋友圈,qq或者更多' } ] }, goRouter(url){ router.push({ uri: url, }) }, /** * @description: 是否安装第三方平台,QQ,微信,微博 * @param {*} * @return {*} */ checkInstalledThirdPlatform(){ const params = { platform: 'weibo', //"wx"微信,"qq","weibo"微博 testFlight: 'iOS仅有', } this.$app.$def.bridge.checkInstalledThirdPlatform(params).then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 邀请家庭 * @param {*} * @return {*} */ inviteFamily(){ const params = { title: 'invite', webpageUrl: 'www.baidu.com', userName: 'iwander', path: '', hdImageData: '', withShareTicket: '' } this.$app.$def.bridge.inviteFamily(params).then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 打开系统的分享 * @param {*} * @return {*} */ openShare(){ const params = { title: '1111', // (android) content: '2222', // (android)} } this.$app.$def.bridge.openShare(params).then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 自定义分享 * @param {*} * @return {*} */ shareCustomPanel(){ const params = { types: ['wx'], //分享类型数组,wx表示微信分享,qq表示qq分享,sms表示短信分享,weibo表示新浪微博,qzone表示QQ空间,wxTimeline表示微信朋友圈, extendList: ['copy'], //(^6.3.0)3种扩展类型 "copy","openBrowser","refresh",6.7.0扩展 ”QRCode","report","imgSaveAs" title: 'baidu', //分享的标题 desc: 'baidu_home_page', //分享的文本内容 imgUrl: 'wwww.baidu.com', //分享的图片链接 imgBase64: 'xxxxxx', //分享的图片base64 link: 'www.hao123.com', //分享的跳转链接 weiboDesc: 'xxxxx', // (^6.3.0)分享到微博的描述,为空时取desc,字段可以不传 liteInfo: { //(^6.3.0) 小程序的分享信息,不为空时表示以小程序的形式分享到微信好友,不需要以小程序形式此字段可以不传 webpageUrl: 'xxxxxx', //H5链接,无法以小程序形式分享时,默认以H5链接形式分享 path: 'xxxxxx', //分享的跳转小程序链接 userName: 'gh_bf92931b2bd6', //小程序ID title: 'xxxxxx', //分享的引导语 imgUrl: 'xxxx', //分享的封面图链接,图片大小不超过128K }, imgPopupUrl: 'xxxxxx', //分享弹窗中显示的图片链接 imgPopupBase64: 'xxxxxx', //分享弹窗中显示的图片base64,有imgPopupUrl优先显示imgPopupUrl type: 'web' } this.$app.$def.bridge.shareCustomPanel(params).then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description:分享功能,直接触发分享 * @param {*} * @return {*} */ shareMsg(){ const params = { type: 'wx', //分享类型,wx表示微信分享,qq表示qq分享,sms表示短信分享,weibo表示新浪微博,qzone表示QQ空间,wxTimeline表示微信朋友圈 title: 'title1', //分享的标题 desc: 'desc1', //分享的文本内容 imgUrl:'http://baidu.com/pic', //分享的图片链接 link: 'http://baidu.com', //分享的跳转链接 msgType: 'web' } this.$app.$def.bridge.shareMsg(params).then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 点对点分享到第三方平台 * @param {*} * @return {*} */ sharePeerToPeer(){ const params={ platformType: 'wx', //默认微信会话,'wx'微信会话,'wxTimeline'微信朋友圈,'qq','qzone'qq空间,'weibo'微博 title: 'hello', //标题 desc: '真好玩呢嗷嗷', //描述 imgUrl:'https://www.smartmidea.net/activity/202011/bigMember/img/introduce.040999a9.png', //头像 link: 'https://mp.weixin.qq.com/s/5aFIUj8KU2VJLhYso0QaKQ', //分享链接 } this.$app.$def.bridge.sharePeerToPeer(params).then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, /** * @description: 打开分享界面(Promise返回),微信,朋友圈,qq或者更多 * @param {*} * @return {*} */ showSharePanel(){ const params={ itle: 'hello world', // 分享标题 desc: 'i love this world', // 分享描述 link: '', // 分享链接 imgUrl: '', // 分享图标 pic: '', // 分享图标 安卓特有 v8.1 dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空 customShareList: [ { label: '抖音', // '自定义分享按钮名字,', iconUrl: 'https://midea-images.mideav.com/meiju/yunMute0.png', tag: 'douyin', }, ], //自定义扩展分享按钮, shareBlackList: [], //黑名单列表,在黑名单内不显示,取值有wx,wxTimeLine,qq,qzone,weibo } this.$app.$def.bridge.showSharePanel(params).then((res)=>{ prompt.showToast({ message: res, duration: 200, }) }).catch((err)=>{ prompt.showToast({ message: '接口调用失败', duration: 200, }) }) }, testBridge(name){ switch(name){ case 'checkInstalledThirdPlatform': this.checkInstalledThirdPlatform() break; case 'inviteFamily': this.inviteFamily() break; case 'openShare': this.openShare() break; case 'shareCustomPanel': this.shareCustomPanel() break; case 'shareMsg': this.shareMsg() break; case 'sharePeerToPeer': this.sharePeerToPeer() break; case 'showSharePanel': this.showSharePanel() break; default: break; } } }