Feat:分享接口对接&&换一换接口对接
This commit is contained in:
@@ -262,5 +262,9 @@ export function watchTownActive(data) {
|
||||
return request.post("/ancientTown/activity/view", data, {login: true})
|
||||
}
|
||||
|
||||
export function shareTown(id) {
|
||||
return request.get("/ancientTown/poster/" + id, {login: true})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
+22
-6
@@ -100,8 +100,12 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="body" v-else>
|
||||
<view>
|
||||
<view class="v12-justify-between v12-align-center">
|
||||
<text class="v12-font-bold" v-if="currType.carousel">推荐</text>
|
||||
<view class="v12-dark1-text v12-font-28 v12-align-center" @click="handleRefresh">
|
||||
<u-icon name="reload"></u-icon>
|
||||
换一换
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="isLoad">
|
||||
<view v-if="hotelList.length > 0">
|
||||
@@ -159,7 +163,7 @@ export default {
|
||||
name: '',
|
||||
page: 1,
|
||||
typeList: [],
|
||||
typeIndex: -1,
|
||||
typeIndex: 0,
|
||||
// 当前选中的类型
|
||||
currType: {},
|
||||
cityName: '',
|
||||
@@ -168,7 +172,8 @@ export default {
|
||||
pageKeyId: Object.freeze('findFunIndex'),
|
||||
isNext: false,
|
||||
townConfig: {},
|
||||
townList: []
|
||||
townList: [],
|
||||
randomSeed: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -220,6 +225,10 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleRefresh() {
|
||||
uni.showLoading()
|
||||
this.fetchList(1, this.randomSeed)
|
||||
},
|
||||
toTown(town) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/town/index?id=${town.id}`
|
||||
@@ -266,7 +275,7 @@ export default {
|
||||
this.hotelList = []
|
||||
this.fetchList()
|
||||
},
|
||||
fetchList() {
|
||||
fetchList(random = 0, randomSeed) {
|
||||
if(this.typeIndex === -1) {
|
||||
const params = {
|
||||
cityName: this.name,
|
||||
@@ -281,15 +290,21 @@ export default {
|
||||
const param = {
|
||||
page: this.page,
|
||||
type: this.typeList[this.typeIndex].id,
|
||||
cityName: this.cityName
|
||||
cityName: this.cityName,
|
||||
random: random,
|
||||
randomSeed: randomSeed
|
||||
}
|
||||
const name = this.name.trim()
|
||||
if (name.length > 0) {
|
||||
param.name = name
|
||||
}
|
||||
getHotelList(param).then(res => {
|
||||
const { success, data } = res
|
||||
const { success, data, msg } = res
|
||||
if (success) {
|
||||
if(random === 1) {
|
||||
this.randomSeed = msg
|
||||
this.hotelList = []
|
||||
}
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const cover = data[i].cover
|
||||
data[i].hide = true
|
||||
@@ -310,6 +325,7 @@ export default {
|
||||
}
|
||||
}).finally(() => {
|
||||
this.isLoad = true
|
||||
uni.hideLoading()
|
||||
})
|
||||
},
|
||||
typeBannerItemClick(item) {
|
||||
|
||||
@@ -32,11 +32,20 @@
|
||||
>
|
||||
<view v-if="items.length > 0" class="v12-d-grid-columns-2 v12-gap-10">
|
||||
<view v-for="(item, index) in items" :key="index" class="store-card" @click="toStore(item.hotelId)">
|
||||
<view>
|
||||
<view class="cover-box">
|
||||
<image class="town-cover" :src="item.cover" mode="aspectFit|aspectFill|widthFix"></image>
|
||||
<view class="name-box">
|
||||
<image
|
||||
:src="webUrl + '/home/icon-location.png'"
|
||||
class="icon"
|
||||
/>
|
||||
<view class="one-t">
|
||||
{{ item.cityName }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="v12-pa-2 card-bottom">
|
||||
<view class="v12-dark-text v12-font-bold v12-font-30 v12-py-1 more-t">{{ item.hotelName }}</view>
|
||||
<view class="v12-dark-text v12-font-bold v12-font-30 more-t v12-pb-1 v12-mb-2">{{ item.content }}</view>
|
||||
<view class="v12-align-center">
|
||||
<view class="avtor">
|
||||
<image class="avtor" :src="item.logo" mode="scaleToFill"></image>
|
||||
@@ -120,6 +129,47 @@ export default {
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.icon {
|
||||
display: block;
|
||||
width: 28rpx;
|
||||
height: 28rpx;
|
||||
margin: 0 10rpx 0 0;
|
||||
}
|
||||
.name-box{
|
||||
color: #fff;
|
||||
position: absolute;
|
||||
left: 20rpx;
|
||||
bottom: 20rpx;
|
||||
font-size: 28rpx;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 5;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
height: 60rpx;
|
||||
padding: 0 16rpx 16rpx 16rpx;
|
||||
border-radius: 0rpx 0rpx 16rpx 16rpx;
|
||||
box-sizing: border-box;
|
||||
font-size: 24rpx;
|
||||
line-height: 28rpx;
|
||||
color: #fff;
|
||||
background: linear-gradient(180deg, rgba(0,0,0,0) 0%, #000000 100%);
|
||||
.icon {
|
||||
display: block;
|
||||
width: 28rpx;
|
||||
height: 28rpx;
|
||||
margin: 0 10rpx 0 0;
|
||||
}
|
||||
.one-t{
|
||||
width: 240rpx !important;
|
||||
}
|
||||
}
|
||||
.cover-box{
|
||||
position: relative;
|
||||
height: 316rpx;
|
||||
}
|
||||
.img-nodata {
|
||||
position: relative;
|
||||
top: 0;
|
||||
|
||||
+114
-2
@@ -21,7 +21,7 @@
|
||||
4A
|
||||
</text>
|
||||
</view>
|
||||
<view class="shareBtn"><u-icon name="share-square" color="#C52733"></u-icon>分享给好友</view>
|
||||
<view class="shareBtn" @click="shareImg"><u-icon name="share-square" color="#C52733"></u-icon>分享给好友</view>
|
||||
<u-line dashed></u-line>
|
||||
<view v-if="townInfo.intro" class="v12-pa-3 intro-content">
|
||||
<u-read-more :toggle="true" showHeight="200">
|
||||
@@ -47,11 +47,35 @@
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<!-- 分享 -->
|
||||
<u-popup
|
||||
:show="showShare"
|
||||
mode="center"
|
||||
bgColor="transparent"
|
||||
>
|
||||
<view class="box-share">
|
||||
<view class="box-img">
|
||||
<image
|
||||
:src="webUrl + '/20230608112219219303.png'"
|
||||
class="icon"
|
||||
@click="closeShare"
|
||||
/>
|
||||
<image :src="posterUrl" class="main-img" mode="widthFix" />
|
||||
</view>
|
||||
<image
|
||||
:src="webUrl + '/20230608112210135038.png'"
|
||||
mode="widthFix"
|
||||
class="btn"
|
||||
@click="saveImg"
|
||||
/>
|
||||
</view>
|
||||
</u-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getAncientTownInfo, getAncientTownActive } from "@/api/inn.js"
|
||||
import { getAncientTownInfo, getAncientTownActive, shareTown } from "@/api/inn.js"
|
||||
import {getUrlParam} from '@/utils/common.js'
|
||||
import culture from './components/culture.vue'
|
||||
import information from './components/information.vue'
|
||||
import service from './components/service.vue'
|
||||
@@ -65,7 +89,10 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
showShare: false,
|
||||
townInfo: {},
|
||||
posterUrl: '',
|
||||
activeties: [],
|
||||
id: '',
|
||||
actived: 1,
|
||||
@@ -79,10 +106,94 @@ export default {
|
||||
},
|
||||
onLoad(opts) {
|
||||
this.id = opts.id
|
||||
const obj = uni.getEnterOptionsSync()
|
||||
if(opts.scene || obj.query.scene) {
|
||||
const query = opts ? decodeURIComponent(opts.scene) : decodeURIComponent(obj.query.scene)
|
||||
this.id = getUrlParam(query, 'id') || null
|
||||
}
|
||||
this.getInfo()
|
||||
this.getActive()
|
||||
},
|
||||
methods: {
|
||||
shareImg() {
|
||||
uni.showLoading()
|
||||
shareTown(this.id).then(res => {
|
||||
this.posterUrl = res.data
|
||||
this.showShare = !this.showShare
|
||||
}).finally(() => {
|
||||
uni.hideLoading()
|
||||
})
|
||||
},
|
||||
closeShare() {
|
||||
this.showShare = false
|
||||
},
|
||||
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"
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
getInfo() {
|
||||
uni.showLoading()
|
||||
getAncientTownInfo(this.id).then(res => {
|
||||
@@ -107,6 +218,7 @@ export default {
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
@import "@/assets/css/store.less";
|
||||
.shareBtn{
|
||||
width: fit-content;
|
||||
padding: 5rpx 15rpx;
|
||||
|
||||
Reference in New Issue
Block a user