1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
| import uniImageMenu from './uni-image-menu.js';
| export default async (param,callback) => {
| var menus = []
| plus.share.getServices(services => { //只显示有服务的项目
| services = services.filter(item=>item.nativeClient)
| // console.log("servicesList",services);
| let servicesList = services.map(e => e.id)
| param.menus.forEach(item => {
| if (servicesList.includes(item.share.provider) || typeof(item.share) == 'string') {
| menus.push(item)
| }
| })
| // console.log(menus);
| uniImageMenu.show({list:menus,cancelText:param.cancelText}, e => {
| if (typeof(menus[e]['share']) == 'string') {
| switch (menus[e]['share']){
| case "copyurl":
| copyurl()
| break;
| case "shareSystem":
| shareSystem()
| break;
| default:
| console.error('未知事件名称:'+menus[e]['share']);
| break;
| }
| } else {
| console.log(123456,{
| ...param.content,
| ...menus[e].share,
| });
| uni.share({
| ...param.content,
| ...menus[e].share,
| success: function(res) {
| console.log("success:" + JSON.stringify(res));
| },
| fail: function(err) {
| console.log("fail:" + JSON.stringify(err));
| uni.showModal({
| content: JSON.stringify(err),
| showCancel: false,
| confirmText:"知道了"
| });
| },
| complete(e) {
| uniImageMenu.hide()
| callback(e)
| }
| })
| }
| })
|
| }, err => {
| uni.showModal({
| title: '获取服务供应商失败:' + JSON.stringify(err),
| showCancel: false,
| confirmText: '知道了'
| });
| console.error('获取服务供应商失败:' + JSON.stringify(err));
| })
|
| function copyurl() {
| uni.setClipboardData({
| data: param.content.href,
| success: function () {
| console.log('success');
| uni.hideToast()//关闭自带的toast
| uni.showToast({
| title: '复制成功',
| icon: 'none'
| });
| },
| fail: (err) => {
| uni.showModal({
| content: JSON.stringify(err),
| showCancel: false
| });
| }
| });
| }
| // 使用系统分享发送分享消息
| function shareSystem() {
| plus.share.sendWithSystem({
| type: 'text',
| content: param.content.title + param.content.summary || '',
| href: param.content.href,
| }, function(e) {
| console.log('分享成功');
| callback(e)
| }, function(e) {
| console.log('分享失败:' + JSON.stringify(e));
| callback(e)
| });
| }
| }
|
|