Task:礼品赠送/送礼、分享。收礼
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<view class="mask">
|
||||
<view class="gift-card-modal" >
|
||||
<image class="bg-image" :src="card.cover" mode="aspectFit|aspectFill|widthFix" lazy-load="false"></image>
|
||||
<view class="image-wrap">
|
||||
<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>
|
||||
@@ -10,16 +10,28 @@
|
||||
<view class="wrap-box">
|
||||
|
||||
</view>
|
||||
<view class="auto-text-color">
|
||||
<view class="auto-text-color" v-if="!card.isReceive">
|
||||
{{ card.message || '礼笺轻启,礼藏心意' }}
|
||||
</view>
|
||||
<view v-if="isReceive && !card.isReceive" @click="toOrder" style="z-index: 89999">
|
||||
<view class="address-btn v12-white v12-primary-text">
|
||||
您已领取礼包
|
||||
</view>
|
||||
<view class="v12-text-center v12-font-26 v12-white-text v12-mt-3">查看礼包详情>></view>
|
||||
</view>
|
||||
<view v-if="card.isReceive" @click="toHome" style="z-index: 89999">
|
||||
<view class="address-btn v12-white v12-primary-text">
|
||||
礼包已被领取
|
||||
</view>
|
||||
<view class="v12-text-center v12-font-26 v12-white-text v12-mt-3">去商城看看>></view>
|
||||
</view>
|
||||
<!-- 弹窗内容 -->
|
||||
<view class="address-btn v12-white v12-primary-text" @click="setAddress">
|
||||
<view v-if="!isReceive && !card.isReceive" class="address-btn v12-white v12-primary-text" @click="setAddress">
|
||||
填写地址并收下
|
||||
</view>
|
||||
<view class="share-btn v12-white v12-primary-text" v-if="card.canTransfer !== 0">
|
||||
<button open-type="share" class="share-btn v12-white v12-primary-text" v-if="card.canTransfer !== 0 && !isReceive">
|
||||
点击转增给好友
|
||||
</view>
|
||||
</button>
|
||||
<view class="tips">
|
||||
<view class="tip-text v12-mr-1">
|
||||
未领取礼包,将于24小时后自动
|
||||
@@ -28,36 +40,107 @@
|
||||
</view>
|
||||
</view>
|
||||
<giftTips ref="giftTips" :richText="giftNotice"></giftTips>
|
||||
<AddressDialog ref="addressDialog" ></AddressDialog>
|
||||
<AddressDialog ref="addressDialog" @save="getReceive"></AddressDialog>
|
||||
<AddressList ref="AddressList" :addressList="address" @save="getReceive"></AddressList>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getGiftCardSendNotice } from '@/api/gift'
|
||||
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
|
||||
AddressDialog,
|
||||
AddressList
|
||||
},
|
||||
props: {
|
||||
// 组件属性
|
||||
card: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
},
|
||||
addr: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 组件数据
|
||||
giftNotice: ''
|
||||
giftNotice: '',
|
||||
isReceive: false,
|
||||
address: {},
|
||||
order: ''
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
addr: {
|
||||
handler(newVal, oldVal) {
|
||||
if (newVal && newVal.id) {
|
||||
this.address = newVal
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
title: '送朋友',
|
||||
path: `/pkg_user/views/gift/receive?code=${this.card.code}`,
|
||||
imageUrl: this.card.image
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 分享到微信好友
|
||||
toShare() {
|
||||
// 分享到微信好友
|
||||
},
|
||||
toOrder() {
|
||||
this.$yrouter.push({
|
||||
path: "/pages/order/OrderDetails/index",
|
||||
query: {
|
||||
id: this.order
|
||||
}
|
||||
});
|
||||
},
|
||||
toHome() {
|
||||
console.log('??');
|
||||
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.isReceive = true
|
||||
}).finally(() => {
|
||||
uni.hideLoading()
|
||||
})
|
||||
},
|
||||
setAddress() {
|
||||
this.$refs.addressDialog.open()
|
||||
getAddressList().then(res => {
|
||||
if (res.data.length === 0) {
|
||||
this.$refs.addressDialog.open()
|
||||
} else {
|
||||
this.address = res.data.filter(item => item.isDefault === 1).length === 0 ? res.data[0] : res.data.filter(item => item.isDefault === 1)[0]
|
||||
this.$refs.AddressList.open()
|
||||
}
|
||||
})
|
||||
},
|
||||
async showTips() {
|
||||
// 获取发礼提示
|
||||
@@ -113,11 +196,11 @@ export default {
|
||||
.auto-text-color {
|
||||
color: #fff;
|
||||
font-size: 24rpx;
|
||||
opacity: 0.9;
|
||||
opacity: 0.8;
|
||||
margin-top: 50rpx;
|
||||
}
|
||||
.share-btn{
|
||||
width: fit-content;
|
||||
padding: 15rpx 30rpx;
|
||||
border-radius: 100rpx;
|
||||
font-size: 24rpx;
|
||||
margin-top: 40rpx;
|
||||
@@ -140,7 +223,7 @@ export default {
|
||||
bottom: 0;
|
||||
width: 586rpx;
|
||||
height: 704rpx;
|
||||
background-color: #C52733;
|
||||
/* background-color: #C52733; */
|
||||
justify-content: center;
|
||||
z-index: 999;
|
||||
margin: auto;
|
||||
|
||||
Reference in New Issue
Block a user