283 lines
6.7 KiB
Vue
283 lines
6.7 KiB
Vue
<template>
|
||
<view class="dialog-conent">
|
||
<view class="gift-card-modal" >
|
||
<image class="bg-image" :src="card.cover" mode="aspectFit|aspectFill|widthFix" lazy-load="false"></image>
|
||
<view class="image-wrap" v-if="!card.isReceive">
|
||
<image class="pro-image" :src="card.giftProducts[0].productImage" mode="aspectFit|aspectFill|widthFix" lazy-load="false" @error="" @load="">
|
||
|
||
</image>
|
||
</view>
|
||
<view class="wrap-box">
|
||
|
||
</view>
|
||
<view class="auto-text-color" v-if="!card.isReceive">
|
||
{{ card.message || '礼笺轻启,礼藏心意' }}
|
||
</view>
|
||
|
||
</view>
|
||
<view class="btn-wrap">
|
||
<button v-if="!isReceive && card.giftProducts[0].isCurrentUser !== 1" class="share-btn v12-white-text v12-primary" @click="setAddress(0)">
|
||
填写地址并收下
|
||
</button>
|
||
<button v-if="card.canTransfer !== 0 && !isReceive && card.giftProducts[0].isCurrentUser !== 1" open-type="share" class="share-btn v12-white v12-primary-text v12-d-flex" >
|
||
点击转赠给好友
|
||
<u-icon :name="webUrl + '/icon/share.png'" ></u-icon>
|
||
</button>
|
||
</view>
|
||
<view v-if="!isReceive && card.giftProducts[0].isCurrentUser === 1" @click="toOrder" style="z-index: 10">
|
||
<view class="address-btn v12-white-text v12-primary">
|
||
您已领取礼包
|
||
</view>
|
||
<view class="v12-text-center v12-font-26 v12-primary-text v12-mt-3">查看礼包详情>></view>
|
||
</view>
|
||
<view v-if="isReceive && card.giftProducts[0].isCurrentUser === 0" @click="toHome" style="z-index: 10">
|
||
<view class="address-btn v12-white-text v12-primary">
|
||
礼包已被领取
|
||
</view>
|
||
<view class="v12-text-center v12-font-26 v12-primary-text v12-mt-3">去商城看看>></view>
|
||
</view>
|
||
<view class="tips">
|
||
<view class="tip-text v12-mr-1" @click="showTips">
|
||
未领取礼包,将于24小时后自动退回
|
||
<u-icon name="error-circle" color="#666" size="24rpx"></u-icon>
|
||
</view>
|
||
</view>
|
||
<giftTips ref="giftTips" :richText="giftNotice"></giftTips>
|
||
<AddressDialog ref="addressDialog" @save="getReceive"></AddressDialog>
|
||
<AddressList ref="AddressList" :addressList="address" @save="getReceive"></AddressList>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import { getGiftCardSendNotice, getGiftCardReceive } from '@/api/gift'
|
||
import { getAddressList } from '@/api/user'
|
||
import giftTips from './giftTips.vue'
|
||
import AddressDialog from './AddressDialog.vue'
|
||
import AddressList from './AddressList.vue'
|
||
export default {
|
||
name: 'GiftCard',
|
||
components: {
|
||
giftTips,
|
||
AddressDialog,
|
||
AddressList
|
||
},
|
||
props: {
|
||
// 组件属性
|
||
card: {
|
||
type: Object,
|
||
default: () => {}
|
||
},
|
||
addr: {
|
||
type: Object,
|
||
default: () => {}
|
||
}
|
||
},
|
||
data() {
|
||
return {
|
||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||
// 组件数据
|
||
giftNotice: '',
|
||
address: [],
|
||
order: ''
|
||
}
|
||
},
|
||
computed: {
|
||
isReceive() {
|
||
return this.card.recipientsNum === this.card.receiveNum
|
||
}
|
||
},
|
||
watch: {
|
||
addr: {
|
||
handler(newVal, oldVal) {
|
||
if (newVal && newVal.id) {
|
||
// this.address = newVal
|
||
this.setAddress(1)
|
||
}
|
||
},
|
||
deep: true
|
||
},
|
||
// 修改后的监听器
|
||
'card': {
|
||
handler(newVal) {
|
||
if (newVal.giftProducts && newVal.giftProducts[0] && newVal.giftProducts[0].isCurrentUser === 1) {
|
||
this.order = newVal.giftProducts[0].orderId
|
||
}
|
||
},
|
||
deep: true
|
||
}
|
||
},
|
||
methods: {
|
||
|
||
// 分享到微信好友
|
||
toShare() {
|
||
// 分享到微信好友
|
||
},
|
||
toOrder() {
|
||
this.$yrouter.push({
|
||
path: "/pages/order/OrderDetails/index",
|
||
query: {
|
||
id: this.order
|
||
}
|
||
});
|
||
},
|
||
toHome() {
|
||
uni.switchTab({
|
||
url: '/pages/home/index'
|
||
})
|
||
},
|
||
getReceive(e) {
|
||
uni.showLoading({
|
||
title: '领取中...',
|
||
mask: true
|
||
})
|
||
// 领取礼包
|
||
getGiftCardReceive({
|
||
code: this.card.code,
|
||
addressId: e
|
||
}).then(res => {
|
||
this.$refs.addressDialog.close()
|
||
this.$refs.AddressList.close()
|
||
this.order = res.data.orderId
|
||
this.$emit('receive', this.order)
|
||
}).finally(() => {
|
||
uni.hideLoading()
|
||
})
|
||
},
|
||
setAddress(flag) {
|
||
getAddressList().then(res => {
|
||
if (res.data.length === 0) {
|
||
this.$refs.addressDialog.open()
|
||
} else {
|
||
this.address = res.data
|
||
if(flag) return
|
||
this.$refs.AddressList.open()
|
||
}
|
||
})
|
||
},
|
||
async showTips() {
|
||
// 获取发礼提示
|
||
getGiftCardSendNotice().then(res => {
|
||
this.$refs.giftTips.showTips = true
|
||
this.giftNotice = res.data
|
||
})
|
||
|
||
},
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style scoped>
|
||
.dialog-conent{
|
||
height: 100vh;
|
||
display: flex;
|
||
flex-direction: column;
|
||
justify-content: space-evenly;
|
||
align-items: center
|
||
}
|
||
.btn-wrap{
|
||
position: relative;
|
||
display: flex;
|
||
justify-content: center;
|
||
align-content: center;
|
||
}
|
||
.bg-image{
|
||
width: 586rpx;
|
||
height: 704rpx;
|
||
position: absolute;
|
||
top: 0;
|
||
}
|
||
.tips{
|
||
display: flex;
|
||
align-items: center;
|
||
margin-top: 40rpx;
|
||
position: absolute;
|
||
bottom: 50rpx;
|
||
width: 100%;
|
||
}
|
||
.tip-text{
|
||
font-family: Source Han Sans SC;
|
||
font-weight: 500;
|
||
font-size: 24rpx;
|
||
color: #666;
|
||
opacity: 0.6;
|
||
width: 100%;
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: center;
|
||
text-align: center;
|
||
line-height: 36rpx;
|
||
}
|
||
.wrap-box{
|
||
width: 296rpx;
|
||
height: 296rpx;
|
||
}
|
||
.image-wrap{
|
||
width: 296rpx;
|
||
height: 296rpx;
|
||
border: 10rpx solid #FDF0D3;
|
||
border-radius: 30rpx;
|
||
position: absolute;
|
||
overflow: hidden;
|
||
top: -140rpx;
|
||
}
|
||
.pro-image{
|
||
width: 296rpx;
|
||
height: 296rpx;
|
||
/* border-radius: 30rpx; */
|
||
}
|
||
.auto-text-color {
|
||
color: #fff;
|
||
font-size: 26rpx;
|
||
opacity: 0.8;
|
||
margin-top: 150rpx;
|
||
width: 400rpx;
|
||
text-align: center;
|
||
}
|
||
.share-btn{
|
||
width: fit-content;
|
||
border-radius: 100rpx;
|
||
font-size: 24rpx;
|
||
margin-top: 40rpx;
|
||
z-index: 999;
|
||
align-items: center;
|
||
border: 1rpx solid #C52733 ;
|
||
margin-left: 10rpx;
|
||
font-weight: bold;
|
||
}
|
||
.share-btn::before{
|
||
border: none;
|
||
}
|
||
.share-btn::after{
|
||
border: none ;
|
||
}
|
||
.address-btn{
|
||
width: fit-content;
|
||
padding: 10rpx 30rpx;
|
||
border-radius: 100rpx;
|
||
font-size: 32rpx;
|
||
font-weight: bold;
|
||
/* margin-top: 40rpx; */
|
||
z-index: 999;
|
||
}
|
||
.gift-card-modal {
|
||
height: 704rpx;
|
||
justify-content: center;
|
||
z-index: 999;
|
||
margin-top: 100rpx;
|
||
border-radius: 16rpx;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: start;
|
||
position: relative;
|
||
}
|
||
|
||
.gift-card-content {
|
||
background-color: #fff;
|
||
padding: 20px;
|
||
border-radius: 10px;
|
||
width: 80%;
|
||
max-width: 300px;
|
||
}
|
||
</style>
|