Feat:管家分享

This commit is contained in:
linxi
2025-11-12 17:08:18 +08:00
parent 349b3a3baa
commit a2805ca58e
3 changed files with 155 additions and 2 deletions
+8
View File
@@ -249,3 +249,11 @@ limit int 每页条数
export function getJiaLouNewsList(params) {
return request.get('/travel/news', params, {login: true})
}
/**
* 分享管家
*/
export function getShareHousekeeper(id) {
return request.get('/travel/steward/poster/' + id, {login: true})
}
+128
View File
@@ -0,0 +1,128 @@
<template>
<u-popup
:show="showShare"
mode="center"
bgColor="transparent"
closeable
@close="closeShare"
>
<view class="box-share">
<view class="box-img">
<image :src="posterUrl" class="main-img" mode="widthFix" />
</view>
<image
:src="webUrl + '/20230608112210135038.png'"
mode="widthFix"
class="btn"
@click="saveImg"
/>
</view>
</u-popup>
</template>
<script>
export default {
data() {
return {
webUrl: this.$VUE_APP_RESOURCES_URL,
posterUrl: '',
showShare: false
}
},
methods: {
closeShare() {
this.showShare = false
},
showView(url) {
this.posterUrl = url
this.showShare = true
},
saveImg() {
const _this = this
uni.getSetting({
success: getRes => {
if (getRes.authSetting["scope.writePhotosAlbum"]) {
_this.downloadImage()
} else {
uni.authorize({
scope: "scope.writePhotosAlbum",
success: () => {
_this.downloadImage()
},
fail: () => {
uni.openSetting({
success: openRes => {
console.log(typeof openRes, openRes)
},
fail: () => {
uni.showToast({
title: "请在设置中打开对应权限",
icon: "none"
})
}
})
}
})
}
},
fail: (err) => {
console.log(err, 2)
}
})
},
downloadImage() {
const _this = this
const randomID = () => Math.random().toString(36).substring(2)
uni.downloadFile({
url: this.posterUrl, // 网络图片的地址
filePath: wx.env.USER_DATA_PATH + "/share_" + randomID() + ".png", // 指定的本地文件路径
success: downRes => {
uni.saveImageToPhotosAlbum({
filePath: downRes.filePath, // 临时文件地址
success: function () {
uni.showToast({
title: "保存成功",
icon: "success",
success() {
_this.showShare = false
}
})
},
fail: function (err) {
uni.showToast({
title: err,
icon: "none"
})
}
})
},
fail: function (err) {
uni.showToast({
title: err.errMsg,
icon: "error"
})
}
})
}
}
}
</script>
<style lang="less" scoped>
.box-share {
width: 600rpx;
border-radius: 20rpx;
overflow: hidden;
}
.box-img {
display: flex;
align-items: center;
justify-content: center;
}
.btn {
width: 100%;
height: 80rpx;
line-height: 80rpx;
margin-top: 40rpx;
}
</style>
+19 -2
View File
@@ -29,7 +29,7 @@
<view class="gg-item-title v12-font-28">旅居管家</view>
<view>{{record.name}}</view>
</view>
<view class="share-btn">
<view class="share-btn" @click="shareHousekeeper">
<view class="share-icon v12-primary">
<image :src="webUrl + '/home/share.png'" class="share-icon-image v12-primary" mode="aspectFill" />
</view>
@@ -70,12 +70,18 @@
</view>
</view>
</view>
<sharePopup ref="sharePopup" />
</view>
</template>
<script>
import { getShareHousekeeper } from '@/api/qianxian.js'
import sharePopup from '@/components/sharePopup.vue'
export default {
name: 'HousekeeperDetail',
components: {
sharePopup
},
data() {
return {
webUrl: this.$VUE_APP_RESOURCES_URL,
@@ -90,7 +96,18 @@ export default {
},
methods: {
shareHousekeeper() {
uni.showLoading()
getShareHousekeeper(this.record.id).then(res => {
uni.hideLoading()
if(res.status === 200) {
// uni.previewImage({
// urls: [res.data],
// })
this.$refs.sharePopup.showView(res.data)
}
})
}
}
}
</script>