|
135 | 135 | methods: {
|
136 | 136 | async share(e) {
|
137 | 137 | console.log('分享通道:'+ e.id +'; 分享类型:' + this.shareType);
|
138 |
| - |
| 138 | +
|
139 | 139 | if(!this.shareText && (this.shareType === 1 || this.shareType === 0)){
|
140 | 140 | uni.showModal({
|
141 | 141 | content:'分享内容不能为空',
|
142 | 142 | showCancel:false
|
143 | 143 | })
|
144 | 144 | return;
|
145 | 145 | }
|
146 |
| - |
| 146 | +
|
147 | 147 | if(!this.image && (this.shareType === 2 || this.shareType === 0)){
|
148 | 148 | uni.showModal({
|
149 | 149 | content:'分享图片不能为空',
|
150 | 150 | showCancel:false
|
151 | 151 | })
|
152 | 152 | return;
|
153 | 153 | }
|
154 |
| - |
| 154 | +
|
155 | 155 | let shareOPtions = {
|
156 | 156 | provider: e.id,
|
157 |
| - scene: e.type && e.type === 'WXSceneTimeline' ? 'WXSceneTimeline' : 'WXSceneSession', //WXSceneSession”分享到聊天界面,“WXSceneTimeline”分享到朋友圈,“WXSceneFavorite”分享到微信收藏 |
| 157 | + scene: e.type && e.type === 'WXSceneTimeline' ? 'WXSceneTimeline' : 'WXSceneSession', //WXSceneSession”分享到聊天界面,“WXSceneTimeline”分享到朋友圈,“WXSceneFavorite”分享到微信收藏 |
158 | 158 | type: this.shareType,
|
159 | 159 | success: (e) => {
|
160 | 160 | console.log('success', e);
|
|
174 | 174 | console.log('分享操作结束!')
|
175 | 175 | }
|
176 | 176 | }
|
177 |
| - |
| 177 | +
|
178 | 178 | switch (this.shareType){
|
179 | 179 | case 0:
|
180 | 180 | shareOPtions.summary = this.shareText;
|
|
189 | 189 | shareOPtions.imageUrl = this.image;
|
190 | 190 | break;
|
191 | 191 | case 5:
|
192 |
| - shareOPtions.imageUrl = this.image ? this.image : 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b6304f00-5168-11eb-bd01-97bc1429a9ff.png' |
| 192 | + shareOPtions.imageUrl = this.image ? this.image : 'https://web-ext-storage.dcloud.net.cn/hello-uni-app/share.png' |
193 | 193 | shareOPtions.title = '欢迎体验uniapp';
|
194 | 194 | shareOPtions.miniProgram = {
|
195 | 195 | id:'gh_33446d7f7a26',
|
|
201 | 201 | default:
|
202 | 202 | break;
|
203 | 203 | }
|
204 |
| - |
205 |
| - if(shareOPtions.type === 0 && plus.os.name === 'iOS'){//如果是图文分享,且是ios平台,则压缩图片 |
| 204 | +
|
| 205 | + if(shareOPtions.type === 0 && plus.os.name === 'iOS'){//如果是图文分享,且是ios平台,则压缩图片 |
206 | 206 | shareOPtions.imageUrl = await this.compress();
|
207 | 207 | }
|
208 | 208 | if(shareOPtions.type === 1 && shareOPtions.provider === 'qq'){//如果是分享文字到qq,则必须加上href和title
|
|
253 | 253 | console.log('after' + localPath);
|
254 | 254 | // 压缩size
|
255 | 255 | plus.io.resolveLocalFileSystemURL(localPath, (entry) => {
|
256 |
| - entry.file((file) => {// 可通过entry对象操作图片 |
| 256 | + entry.file((file) => {// 可通过entry对象操作图片 |
257 | 257 | console.log('getFile:' + JSON.stringify(file));
|
258 | 258 | if(file.size > 20480) {// 压缩后size 大于20Kb
|
259 | 259 | plus.zip.compressImage({
|
|
0 commit comments