176 lines
4.1 KiB
Vue
176 lines
4.1 KiB
Vue
<template>
|
||
<view v-if="!loading">
|
||
<GiftCard
|
||
v-if="showGift"
|
||
:card="giftCard"
|
||
:isTravelGroup="isTravelGroup"
|
||
:addr="giftChooseAddress"
|
||
@receive="onReceive($event)" />
|
||
<view v-else>
|
||
<view class="no-img-wrap" v-if="isExpire">
|
||
<view class="wrap-box" >
|
||
<image :src="webUrl + '/icon/no-gift.png'" mode="widthFix"></image>
|
||
<view class="v12-font-28 v12-dark1-text v12-mt-8">礼包超过24小时未领取,订单已取消</view>
|
||
<view @click="toHome" class="v12-font-28 v12-primary-text v12-primary-border go-btn">去商城看看</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import GiftCard from './components/GiftCard.vue'
|
||
import { getGiftCardDetail, fetchSojoumGroupBuyGiftDetail } from '@/api/gift'
|
||
export default {
|
||
components: {
|
||
GiftCard
|
||
},
|
||
data() {
|
||
return {
|
||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||
giftCard: {},
|
||
giftChooseAddress: {},
|
||
loading: false,
|
||
isTravelGroup: false,
|
||
isExpire: false
|
||
}
|
||
},
|
||
onLoad(opts) {
|
||
this.isTravelGroup = opts.isTravelGroup === '1'
|
||
if(opts.isTravelGroup === '1') {
|
||
this.getSojoumGroupBuyGiftDetail(opts.code)
|
||
} else {
|
||
this.getGiftCard(opts.code)
|
||
}
|
||
},
|
||
computed: {
|
||
showGift() {
|
||
return !this.giftCard.isExpire || !!this.giftCard.isUserReceive
|
||
}
|
||
},
|
||
onShow() {
|
||
this.giftChooseAddress = uni.getStorageSync('giftChooseAddress') || {}
|
||
},
|
||
onShareAppMessage() {
|
||
uni.updateShareMenu({
|
||
isPrivateMessage: true,
|
||
withShareTicket: true
|
||
})
|
||
return {
|
||
title: '礼笺轻启,礼藏心意',
|
||
path: `/pkg_user/views/gift/receive?code=${this.giftCard.code}&isTravelGroup=${this.isTravelGroup ? 1 : 0}`,
|
||
imageUrl: this.giftCard.image
|
||
}
|
||
},
|
||
methods: {
|
||
onReceive(code) {
|
||
if(this.isTravelGroup) {
|
||
this.getSojoumGroupBuyGiftDetail(code)
|
||
} else {
|
||
this.getGiftCard(code)
|
||
}
|
||
},
|
||
/**
|
||
* 获取旅居团购礼品卡订单详情
|
||
*/
|
||
getSojoumGroupBuyGiftDetail(code) {
|
||
this.loading = true
|
||
uni.showLoading({
|
||
title: '加载中...',
|
||
mask: true
|
||
})
|
||
fetchSojoumGroupBuyGiftDetail({
|
||
code: code
|
||
}).then(res => {
|
||
this.giftCard = res.data || {}
|
||
this.isExpire = this.giftCard.isExpire === 1
|
||
if(this.isTravelGroup && res.data.isUserReceive === 1) {
|
||
const obj = {
|
||
...res.data,
|
||
travelGroupOrderInfo: {
|
||
travelGroupProduct: res.data.travelGroupProduct || {}
|
||
}
|
||
}
|
||
uni.reLaunch({ url: '/pkg_user/views/gift/receiveDone?obj=' + JSON.stringify(obj) })
|
||
} else {
|
||
this.loading = false
|
||
}
|
||
uni.hideLoading()
|
||
}).finally(() => {
|
||
})
|
||
},
|
||
|
||
|
||
/**
|
||
* 跳转首页
|
||
*/
|
||
|
||
toHome() {
|
||
uni.switchTab({
|
||
url: '/pages/home/index'
|
||
})
|
||
},
|
||
getGiftCard(code) {
|
||
this.loading = true
|
||
uni.showLoading({
|
||
title: '加载中...',
|
||
mask: true
|
||
})
|
||
getGiftCardDetail({
|
||
code: code
|
||
}).then(res => {
|
||
this.giftCard = res.data || {}
|
||
this.loading = false
|
||
this.isExpire = this.giftCard.isExpire === 1
|
||
if(this.giftCard.canTransfer === 0 ) {
|
||
uni.hideShareMenu()
|
||
return
|
||
}
|
||
}).catch(err => {
|
||
this.giftCard = {
|
||
canTransfer: 0,
|
||
isReceive: true
|
||
}
|
||
}).finally(() => {
|
||
uni.hideLoading()
|
||
})
|
||
},
|
||
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="less" scoped>
|
||
.wrap-box{
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
margin-bottom: 400rpx;
|
||
}
|
||
.go-btn{
|
||
border-radius: 200rpx;
|
||
padding: 8rpx 20rpx;
|
||
font-weight: bold;
|
||
margin-top: 60rpx;
|
||
width: fit-content;
|
||
}
|
||
.no-img-wrap{
|
||
height: 100vh;
|
||
display: flex;
|
||
align-items: center;
|
||
flex-direction: column;
|
||
justify-content: center;
|
||
}
|
||
.no-img-wrap image{
|
||
width: 280rpx;
|
||
height: 280rpx;
|
||
}
|
||
.top-card{
|
||
width: 710rpx;
|
||
height: 280rpx;
|
||
background: #fff;
|
||
border-radius: 16rpx;
|
||
}
|
||
|
||
|
||
</style> |