Files
xdd-uniapp-new/pkg_user/views/gift/receive.vue
T

165 lines
3.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view v-if="!loading">
<GiftCard
v-if="!giftCard.isExpire"
:card="giftCard"
:isTravelGroup="isTravelGroup"
:addr="giftChooseAddress"
@receive="onReceive($event)" />
<view v-else>
<view class="no-img-wrap">
<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
}
},
onLoad(opts) {
this.isTravelGroup = opts.isTravelGroup === '1'
if(opts.isTravelGroup === '1') {
this.getSojoumGroupBuyGiftDetail(opts.code)
} else {
this.getGiftCard(opts.code)
}
},
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) {
uni.showLoading({
title: '加载中...',
mask: true
})
fetchSojoumGroupBuyGiftDetail({
code: code
}).then(res => {
this.giftCard = res.data || {}
if(this.isTravelGroup && res.data.isUserReceive === 1) {
const obj = {
...res.data,
travelGroupOrderInfo: {
travelGroupProduct: res.data.travelGroupProduct || {}
}
}
uni.navigateTo({ url: '/pkg_user/views/gift/receiveDone?obj=' + JSON.stringify(obj) })
}
uni.hideLoading()
})
},
/**
* 跳转首页
*/
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
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>