Files
xdd-uniapp-new/pkg_user/views/giftList.vue
T

596 lines
15 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 class="gift-page">
<view class="cate-wrap">
<view class="cate-list">
<view
v-for="(item, index) in cateList"
:key="index"
:class="cateIndex === index ? 'curr' : ''"
class="cate-item"
@click="cateItemClickHanlde(item, index)"
>
{{ item.name }}
</view>
</view>
</view>
<view class="list-wrap">
<block v-if="isLoad">
<view v-if="cateIndex === 0" class="list-body">
<block v-if="sendList.length > 0">
<view
v-for="(item, index) in sendList"
:key="index"
class="gift-item"
>
<view
v-for="(cart, cartIndex) in item.giftInfo"
:key="cartIndex"
class="gift-body"
@click="giftItemClickHanlde(item)"
>
<view class="gift-img">
<image
:src="cart.productInfo.image"
class="img"
mode="widthFix"
/>
</view>
<view class="gift-good-info">
<view class="name more-t">
{{ cart.productInfo.storeName }}
</view>
<view v-if="cart.productInfo.attrInfo" class="attr-txt">
<view class="txt">{{ cart.productInfo.attrInfo.sku }}</view>
</view>
<view class="price-wrap">
<view class="price">
<text class="prefix"></text>{{ item.payPrice }}
</view>
<view class="num">已领取{{cart.receiveNum}}/{{ cart.cartNum }}</view>
</view>
</view>
</view>
<view class="gift-bottom">
<view class="gift-txt">
赠言{{ item.message || '' }}
</view>
<!-- 状态 0-待领取 1-已全部领取 2-已失效 -->
<button v-if="item.status === 0" @click="tuikuan(item)" class="btn1">退款</button>
<button
v-if="item.status === -1"
class="btn"
@click="goBuy(item)"
>
待付款
<image
:src="webUrl + '/icon/icon-gift-share.png'"
class="icon"
mode="widthFix"
/>
</button>
<button
v-if="item.status === 0"
open-type="share"
class="btn"
@click="shareGift(item)"
>
送给朋友
<image
:src="webUrl + '/icon/icon-gift-share.png'"
class="icon"
mode="widthFix"
/>
</button>
<view
v-if="item.status === 1"
class="btn"
>
已全部领取
</view>
<view
v-if="item.status === 2"
class="btn btn-grey"
>
已过期
</view>
<view
v-if="item.status === 9"
class="btn btn-grey"
>
已取消
</view>
</view>
</view>
</block>
<view v-if="sendList.length === 0" class="noCart">
<view class="pictrue">
<image :src="webUrl + '/20240102232734472795.png'"/>
</view>
</view>
</view>
<view v-if="cateIndex === 1" class="list-body">
<block v-if="receiveList.length > 0">
<view
v-for="(item, index) in receiveList"
:key="index"
class="gift-item"
>
<view
v-for="(cart, cartIndex) in item.giftInfos"
:key="cartIndex"
class="gift-body"
@click="giftItemClickHanlde(item)"
>
<view class="gift-img">
<image
:src="cart.productInfo.image"
class="img"
mode="widthFix"
/>
</view>
<view class="gift-good-info">
<view class="name more-t">
{{ cart.productInfo.storeName }}
</view>
<view v-if="cart.productInfo.attrInfo" class="attr-txt">
<view class="txt">{{ cart.productInfo.attrInfo.sku }}</view>
</view>
<view class="price-wrap">
<view class="price">
<text class="prefix"></text>{{ cart.productInfo.attrInfo.price }}
</view>
</view>
</view>
</view>
<view class="gift-bottom">
<view class="gift-txt">
赠言{{ item.message || '' }}
</view>
<view
:class="{
'btn-grey': [-2, 3].includes(+item._status._type)
}"
class="btn"
>
{{ getStatus(item) }}
</view>
</view>
</view>
</block>
<view v-if="receiveList.length === 0" class="noCart">
<view class="pictrue">
<image :src="webUrl + '/20240102232734472795.png'"/>
</view>
</view>
</view>
</block>
<goo-skeleton
v-else
:show-avatar="false"
/>
</view>
<view class="page-bottom">
<image
:src="webUrl + '/icon/icon-send-gift-notice-btn.png'"
class="icon"
mode="widthFix"
@click="showTips"
/>
</view>
<gift-tips
ref="giftTips"
:richText="giftNotice"
/>
<Payment v-model="pay" :types="payType" @checked="toPay" :balance="userInfo.nowMoney"></Payment>
<passkeyborad
:money="orderInfo.payPrice"
showMoney
:show="isShowPayPwdPop"
ref='payPwdPop'
@close="pwdPopClose"
@finish="pwdPopFinish"
></passkeyborad>
</view>
</template>
<script>
import passkeyborad from '@/components/yzc-paykeyboard/yzc-paykeyboard'
import {cancelOrderHandle, payOrderHandle, takeOrderHandle, yuePayOrderHandle, delOrderHandle} from "@/libs/order";
import Payment from "@/components/Payment";
import {
giftCardReceiveList,
giftCardSendList,
giftNotice,
refund
} from '@/api/giftList'
import {mapGetters} from "vuex";
import giftTips from '@/pkg_user/views/gift/components/giftTips.vue'
export default {
name: 'GiftLisPage',
components: {
giftTips,
passkeyborad,
Payment
},
data() {
return {
pay: false,
payType: ["yue", "weixin"],
webUrl: this.$VUE_APP_RESOURCES_URL,
giftNotice: '',
cateIndex: 0,
cateList: [
{
name: '送出的',
status: 1
},
{
name: '收到的',
status: 2
}
],
isLoad: false,
from: this.$deviceType,
sendList: [],
receiveList: [],
giftItem: {},
orderInfo: {},
isShowPayPwdPop: false,
}
},
computed: mapGetters(["userInfo"]),
created() {
giftNotice().then(res => {
this.giftNotice = res.data
})
this.getGiftCardSendList()
},
onShareAppMessage() {
return {
title: this.giftItem.message || '礼笺轻启,礼藏心意',
path: `/pkg_user/views/gift/receive?code=${this.giftItem.code}`,
imageUrl: this.giftItem.templateInfo.image
}
},
methods: {
tuikuan(item) {
uni.showModal({
title: '提示',
content: '是否确定退款?',
success: (res) => {
if (res.confirm) {
uni.showLoading({
title: '退款中...',
mask: true
})
refund({
id: item.id
}).then(qRes => {
if (qRes.success) {
this.getGiftCardSendList()
}
}).finally(() => {
uni.hideLoading()
})
}
}
})
},
pwdPopFinish(payPwd) {
this.payPassword = payPwd;
this.toYuePay(payPwd);
this.isShowPayPwdPop = false;
},
toYuePay(payPwd) {
//网络请求
yuePayOrderHandle(this.orderInfo.orderId, "yue", this.from, payPwd).then(res => {
console.log(res);
this.getGiftCardSendList()
this.payPassword = "";
})
},
pwdPopClose() {
this.isShowPayPwdPop = false;
},
wechatPay(type) {
payOrderHandle(this.orderInfo.orderId, type, this.from).then(res => {
console.log(res);
this.getGiftCardSendList()
})
},
goBuy(order) {
this.pay = true
this.orderInfo = order
},
toPay(type) {
//余额支付需要输入支付密码
if (type == "yue") {
this.isShowPayPwdPop = true;
return;
} else {
this.wechatPay(type);
}
},
shareGift(item) {
this.giftItem = item
},
cateItemClickHanlde(item, index) {
if (this.cateIndex === index || !this.isLoad) return
this.cateIndex = index
if (this.cateIndex === 0) {
this.getGiftCardSendList()
}
if (this.cateIndex === 1) {
this.getGiftCardReceiveList()
}
},
getGiftCardReceiveList() {
this.isLoad = false
giftCardReceiveList({
page: 1,
limit: 999
}).then(res => {
const { success, data } = res
if (success) {
this.receiveList = data || []
}
}).catch(err => {
console.log(err)
}).finally(() => {
this.isLoad = true
})
},
getGiftCardSendList() {
this.isLoad = false
giftCardSendList({
page: 1,
limit: 999
}).then(res => {
const { success, data } = res
if (success) {
this.sendList = data || []
}
}).catch(err => {
console.log(err)
}).finally(() => {
this.isLoad = true
})
},
getStatus(order) {
const type = Number(order._status._type)
let status = ''
switch (type) {
case 0:
status = '待付款'
break
case 1:
status = '礼包待发货'
break
case 2:
status = '礼包待收货'
break
case 3:
status = '礼包已收货'
break
case 4:
status = '已完成'
break
case -1:
status = '退款中'
break
case -2:
status = '已退回'
break
case -3:
status = '退款失败'
break
case 9:
status = '已取消'
break
default:
break
}
return status
},
showTips() {
this.$refs.giftTips.showTips = true
},
giftItemClickHanlde(item) {
if (this.cateIndex === 0) return
this.$yrouter.push({
path: '/pages/order/OrderDetails/index',
query: {
id: item.orderId
}
})
}
}
}
</script>
<style lang="less" scoped>
.gift-page {
position: relative;
min-height: 100vh;
padding: 20rpx 20rpx 0 20rpx;
box-sizing: border-box;
background-color: #F6F6F6;
.cate-wrap {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 9;
padding: 20rpx 32rpx;
background-color: #F6F6F6;
.cate-list {
display: flex;
align-items: center;
height: 64rpx;
border-radius: 32rpx;
background-color: #fff;
.cate-item {
flex: 1;
height: 64rpx;
border-radius: 32rpx;
line-height: 64rpx;
text-align: center;
font-size: 30rpx;
color: #333;
background-color: #fff;
&.curr {
font-weight: bold;
color: #fff;
background-color: #C41617;
}
}
}
}
.list-wrap {
position: relative;
z-index: 2;
padding: 84rpx 0 80rpx 0;
.gift-item {
padding: 16rpx;
margin: 0 0 24rpx;
border-radius: 16rpx;
background-color: #ffff;
.gift-body {
display: flex;
align-items: center;
justify-content: space-between;
.gift-img {
.img {
display: block;
width: 200rpx;
height: 200rpx;
border-radius: 16rpx;
}
}
.gift-good-info {
display: flex;
flex-direction: column;
justify-content: space-between;
width: calc(100% - 212rpx);
height: 200rpx;
.name {
font-weight: bold;
font-size: 28rpx;
color: #333;
line-height: 44rpx;
}
.attr-txt {
display: flex;
.txt {
height: 42rpx;
padding: 0 12rpx;
border-radius: 24rpx;
border: 1px solid #999;
line-height: 42rpx;
color: #333;
font-size: 24rpx;
}
}
.price-wrap {
display: flex;
align-items: center;
justify-content: space-between;
.price {
color: #C52733;
font-size: 30rpx;
font-weight: bold;
.prefix {
font-weight: normal;
font-size: 22rpx;
}
}
.num {
font-size: 24rpx;
color: #666;
}
}
}
}
.gift-bottom {
display: flex;
align-items: center;
justify-content: space-between;
padding: 24rpx 0 0 0;
margin: 24rpx 0 0 0;
border-top: 1rpx solid #D2D2D2;
.gift-txt {
flex: 1;
font-size: 26rpx;
color: #666;
}
.btn {
display: flex;
align-items: center;
height: 46rpx;
padding: 0 12rpx;
margin: 0 0 0 24rpx;
border-radius: 100rpx;
color: #fff;
line-height: 46rpx;
font-size: 26rpx;
background-color: #C52733;
.icon {
display: block;
width: 20rpx;
height: 20rpx;
}
&.btn-grey {
color: #fff;
background-color: #C7C7C7;
}
}
}
}
}
.page-bottom {
position: fixed;
bottom: 0;
left: 0;
right: 0;
z-index: 9;
display: flex;
align-items: center;
justify-content: center;
height: 80rpx;
background-color: #F6F6F6;
.icon {
display: block;
width: 140rpx;
}
}
}
.noCart {
margin-top: 0.17 * 100rpx;
padding-top: 0.1 * 100rpx;
.pictrue {
width: 408rpx;
height: 414rpx;
overflow: hidden;
margin: 0.7 * 100rpx auto 0.5 * 100rpx auto;
image {
display: block;
width: 408rpx;
height: 414rpx;
}
}
}
.btn1{
background-color: #fff;
color: #333;
border-radius: 100rpx;
border: 1px solid #333;
font-weight: bold;
height: 46rpx;
padding: 0 12rpx;
margin: 0 0 0 24rpx;
line-height: 40rpx;
font-size: 26rpx;
}
</style>