|
@ -26,14 +26,15 @@ |
|
|
</view> |
|
|
</view> |
|
|
<!-- 底部按钮 --> |
|
|
<!-- 底部按钮 --> |
|
|
<view class="bottom-btns-modal"> |
|
|
<view class="bottom-btns-modal"> |
|
|
<button class="btn gray">分享给好友</button> |
|
|
|
|
|
<button class="btn green">保存到本地</button> |
|
|
|
|
|
|
|
|
<button class="btn gray" open-type="share">分享给好友</button> |
|
|
|
|
|
<button class="btn green" @tap="saveToAlbum">保存到本地</button> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import pullRefreshMixin from '@/pages/mixins/pullRefreshMixin.js' |
|
|
import pullRefreshMixin from '@/pages/mixins/pullRefreshMixin.js' |
|
|
|
|
|
import config from '@/api/config.js' |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
mixins: [pullRefreshMixin], |
|
|
mixins: [pullRefreshMixin], |
|
@ -58,6 +59,23 @@ |
|
|
// 可能要等待获取到数据 |
|
|
// 可能要等待获取到数据 |
|
|
this.getQrcode() |
|
|
this.getQrcode() |
|
|
}, |
|
|
}, |
|
|
|
|
|
// 微信小程序分享配置 |
|
|
|
|
|
// #ifdef MP-WEIXIN |
|
|
|
|
|
onShareAppMessage() { |
|
|
|
|
|
return { |
|
|
|
|
|
title: `${this.userInfo.name}邀请您一起参与旧衣回收`, |
|
|
|
|
|
path: `/pages/component/home?shareId=${this.inviteCode}`, |
|
|
|
|
|
imageUrl: this.qrcodeUrl || '/static/share-default.png' |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
onShareTimeline() { |
|
|
|
|
|
return { |
|
|
|
|
|
title: `${this.userInfo.name}邀请您一起参与旧衣回收,环保从我做起!`, |
|
|
|
|
|
query: `shareId=${this.inviteCode}`, |
|
|
|
|
|
imageUrl: this.qrcodeUrl || '/static/share-default.png' |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
// #endif |
|
|
methods: { |
|
|
methods: { |
|
|
async onRefresh() { |
|
|
async onRefresh() { |
|
|
// 模拟刷新数据 |
|
|
// 模拟刷新数据 |
|
@ -87,6 +105,65 @@ |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 保存到手机相册 |
|
|
|
|
|
saveToAlbum() { |
|
|
|
|
|
if (!this.qrcodeUrl) { |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: '二维码还未加载完成', |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
}) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 先授权相册权限 |
|
|
|
|
|
uni.getSetting({ |
|
|
|
|
|
success: (res) => { |
|
|
|
|
|
if (!res.authSetting['scope.writePhotosAlbum']) { |
|
|
|
|
|
// 没有权限,申请权限 |
|
|
|
|
|
uni.authorize({ |
|
|
|
|
|
scope: 'scope.writePhotosAlbum', |
|
|
|
|
|
success: () => { |
|
|
|
|
|
this.doSaveImage() |
|
|
|
|
|
}, |
|
|
|
|
|
fail: () => { |
|
|
|
|
|
// 权限被拒绝,引导用户手动开启 |
|
|
|
|
|
uni.showModal({ |
|
|
|
|
|
title: '提示', |
|
|
|
|
|
content: '需要您授权保存相册权限', |
|
|
|
|
|
showCancel: false, |
|
|
|
|
|
success: () => { |
|
|
|
|
|
uni.openSetting() |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
// 已有权限,直接保存 |
|
|
|
|
|
this.doSaveImage() |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
// 执行保存图片 |
|
|
|
|
|
doSaveImage() { |
|
|
|
|
|
uni.saveImageToPhotosAlbum({ |
|
|
|
|
|
filePath: this.qrcodeUrl, |
|
|
|
|
|
success: () => { |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: '保存成功', |
|
|
|
|
|
icon: 'success' |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
fail: (err) => { |
|
|
|
|
|
console.log('保存失败', err) |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: '保存失败', |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|