Files
ysdH5/pages/car/index.vue
2023-06-21 17:19:58 +08:00

910 lines
31 KiB
Vue
Raw Permalink 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>
<!-- 立即购买 -->
<view class="newrightsBtn" @tap="submitOrder">
<view class="rightsBtn-text">
<view class="rightsBtn-text-num">{{ dataInfo.num }}件商品 </view>
<view>实付<text>{{ dataInfo.amount }}</text></view>
</view>
<button :disabled="disabled">立即购买</button>
</view>
<view style="padding-bottom: 100px">
<view class="cont">
<view class="contBack">
<image class="classBack" src="https://lifetest.ysd-bs.com/storage/materials/2021/08/09/class_back_02.png"
mode="scaleToFill"></image>
<view class="classCircle"></view>
<view class="rightsCont" v-if="dataInfo.detail">
<scroll-view scroll-x class="welfareCont-top" scroll-with-animation>
<view class="welfareCont-list-img" v-for="(item, index) in dataInfo.detail.logos" :key="index">
<image :src="item" mode="aspectFill"></image>
</view>
</scroll-view>
<view class="nowrap rightsCont-btn">
{{ dataInfo.detail.title }}
</view>
</view>
</view>
</view>
<view class="rightsNumber">
<image class="rightsGoods-img" :src="dataInfo.detail.goods_cover" mode="aspectFill"></image>
<view class="rightsGoods">
<view class="nowrap rightsGoods-text">
{{ dataInfo.detail.title }}
</view>
<view class="rightsGoods-price">
<view class="rightsGoods-number"><text></text>{{ dataInfo.detail.price }}</view>
<view class="rightsAdd">
<!-- @tap="goodsNumber(remove)" -->
<view class="rightsAdd-btn rightsAdd-remove" :class="{active : num != 1}">-</view>
<input class="rightsAdd-input" :value="dataInfo.num" type="number" disabled></input>
<view class="rightsAdd-btn rightsAdd-plus">+</view>
<!-- @tap="goodsNumber(plus)" -->
</view>
</view>
</view>
</view>
<view class="rightsList" style="padding: 0 0 2rpx" v-if="dataInfo.detail.attribute">
<view class="rightsLabel">
<view class="rightsLabel-left">{{ dataInfo.detail.attribute.form_type }}</view>
<view class="rightsLabel-right rightsLabel-red">-{{ dataInfo.score }}</view>
</view>
<view class="rightsLabel">
<view class="rightsLabel-left">{{dataInfo.detail.attribute.form_pay}}</view>
<view class="rightsLabel-right">{{ dataInfo.amount }}</view>
</view>
</view>
<!-- 规格 -->
<view class="rightsList" v-if="dataInfo.detail.type == 'physical'">
<view class="rightsLabel">
<view class="rightsLabel-left">提交方式</view>
<view class="rightsLabel-right rightsLabel-range">
<picker :range="plat.platformCp" :range-key="'name'" @change="platBind">
<view class="tabs-text">
{{ plat.platformCp[plat.platIndex].name }}
</view>
</picker>
<image class="rightsLabel-row" src="/static/icon/rightsArrow.png"></image>
</view>
</view>
<view class="rightsLabel rightsLabel-address" v-if="plat.platformCp[plat.platIndex].name == '快递'">
<image class="rightsLabel-icon" src="https://card.ysd-bs.com/storage/materials/2021/09/01/new_rightsAddress.png"></image>
<block v-if="dataInfo.detail.address != ''">
<view class="rightsLabel-right" @tap="addressTap">
<view class="rightsLabel-address-text">
<view class="rightsLabel-address-name">{{ dataInfo.detail.address.name }}<view class="rightsLabel-address-tel">{{ dataInfo.detail.mobile }}</view></view>
<text class="nowrap">{{ dataInfo.detail.address.all_address }}</text>
</view>
<image class="rightsLabel-row" src="/static/icon/rightsArrow.png"></image>
</view>
</block>
<block v-else>
<navigator class="rightsLabel-right" hover-class="none" url="/pages/address_form/address_form?type=Add">
<view class="rightsLabel-address-text" style="line-height: 90rpx;">
添加收货地址
</view>
<image class="rightsLabel-row" src="/static/icon/rightsArrow.png"></image>
</navigator>
</block>
</view>
<view class="rightsLabel" v-if="plat.platformCp[plat.platIndex].name == '快递'">
<view class="rightsLabel-left">快递运费</view>
<view class="rightsLabel-right rightsLabel-freight">{{ dataInfo.freight }}</view>
</view>
</view>
<!-- 支付方式 -->
<!-- <view class="rightsList" style="padding: 0 0 2rpx">
<view class="radioList" style="padding: 30rpx">
<radio-group @change="payBind">
<view class="payContList-label">
<view class="payContList-label-name">
<image class="payContList-label-img" src="/static/img/wx.jpg"></image>
微信支付
</view>
<radio class="radio" value="0" checked></radio>
</view>
<view class="payContList-label">
<view class="payContList-label-name">
<image class="payContList-label-img" src="/static/img/wqb.jpg"></image>
沃钱包支付
</view>
<radio class="radio" value="1"></radio>
</view>
</radio-group>
</view>
</view> -->
<!-- 购买须知 -->
<view class="notice">
<view class="noticeTitle" @tap="noticeTap">
<view class="noticeTitle-flex">
<image class="noticeTitle-img" src="/static/icon/notice_icon.png"></image>
购买前请仔细阅读使用须知内容介绍
</view>
<image class="noticeTitle-row" :class="{active : dataInfo.noticeShow}" src="/static/icon/rightsArrow.png"></image>
</view>
<view class="noticeText" :class="{active : dataInfo.noticeShow}">
<view class="noticeText-top">购买须知</view>
<view class="noticeText-cont">
<rich-text :nodes="dataInfo.remark"></rich-text>
</view>
<view class="noticeText-top">内容介绍</view>
<view class="noticeText-cont">
<rich-text :nodes="dataInfo.content"></rich-text>
</view>
</view>
</view>
</view>
<!-- 选择收货地址 -->
<view class="addressBack" :class="{ active : address.addressShow }" @tap="addressHide"></view>
<view class="addressCont" :class="{ active : address.addressShow }">
<view class="addressCont-title uni-border-bottom">
<view class="addressCont-left">请选择收货地址</view>
<view class="addressCont-right" @tap="addSelect">新增收货地址</view>
</view>
<scroll-view class="header-classify" scroll-y="true">
<view class="addressCont-list uni-border-bottom" v-for="(item, index) in address.allAddress" :key="index"
@tap="selectAddress(item.id, item)">
<view class="addressCont-top">
<view class="addressCont-name">{{ item.name }}</view>
<view class="addressCont-tel">{{ item.mobile }}</view>
</view>
<view class="addressCont-text">
{{ item.all_address }}
</view>
<view class="address-tool-icon">选择地址</view>
</view>
</scroll-view>
</view>
</view>
</template>
<script>
import { washcarBuy, washcarCreate } from '@/apis/interfaces/rights'
export default {
data() {
return {
dataInfo : {
rightId : '', // 权益id
detail : '', // 权益详情
welfareId : '', // 活动id
amount : '', // 总金额
moreAmount : '', // 产品金额
num : 1, // 购买的数量
score : '', // 应付总积分
freight : '', // 运费
welfareType : '', // 权益类型
content : '', // 内容介绍
remark : '', // 使用须知
noticeShow : false, // 须知显示状态
},
address : {
addefault : '', // 默认地址
allAddress : [], // 收货地址列表
addressShow : false // 收货地址显示
},
plat : {
platIndex : 0, // 选择提交方式下标
isdeliver : -1, // 快递还是自提参数
platformCp : [] // 选择提交数组
},
pay : {
payWayIndex : 0,
payWay : [
{value: 0, name: "微信支付"},
{value: 1, name: "沃钱包支付"}
]
},
disabled : false // 下单按钮状态
}
},
onLoad(options) {
this.dataInfo.rightId = options.right_id,
this.dataInfo.welfareId = options.welfare_id
// 获取卡券列表
this.couponInfo()
},
methods:{
// 卡券列表
couponInfo() {
washcarBuy({
welfare_id : this.dataInfo.welfareId,
right_id : this.dataInfo.rightId,
qty : this.dataInfo.num,
address_id : this.address.addefault.id,
is_deliver : this.plat.isdeliver
}).then(res=>{
let obj = res.detail.express
let defGet = res.detail.def_get
let arr = new Array
arr = Object.keys(obj).map(val=>{
return { ...obj[val], ...{key: val} }
})
if(this.plat.isdeliver == -1){
if(res.detail.type == 'physical') this.plat.isdeliver = res.detail.def_get
if(res.detail.type == 'virtual') this.plat.isdeliver = 1
}
this.dataInfo.detail = res.detail
this.dataInfo.num = res.qty
this.dataInfo.freight = res.freight
this.dataInfo.amount = res.total
this.dataInfo.moreAmount = res.amount
this.dataInfo.score = res.score
this.dataInfo.welfareType = res.type
this.dataInfo.remark = res.detail.remark.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;"')
this.dataInfo.content = res.detail.content.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;"')
this.plat.platformCp = arr
this.address.addefault = res.address
this.address.allAddress = res.all_address
}).catch(err=>{
if(!err.login){
uni.showModal({
title : '用户登录已过期',
content : '请重新登录',
showCancel : false,
success : res => {
if (res.confirm) {
uni.redirectTo({
url: '/pages/auth/login'
})
}
}
})
}
})
},
// 收货地址弹出
addressTap() {
this.address.addressShow = !this.address.addressShow
},
// 选择收货地址
selectAddress(selectid, selectItem){
let new_addressId = selectid,
addressId = this.address.addefault.id
if (new_addressId != addressId) this.address.addefault = selectItem
this.address.addressShow = false
// 获取卡券列表
this.couponInfo()
},
// 商品数量加减
goodsNumber(type){
if(this.dataInfo.welfareType == 'welfare') {
uni.showToast({
title : '抱歉,只能购买一张',
icon : 'none'
})
return
}
let num = this.dataInfo.num
if (type == 'plus'){
num ++;
}else{
if (num > 1){
num --;
}else{
uni.showToast({
title : '商品数量不能小于1',
icon : 'none'
})
}
}
this.dataInfo.num = num
// 获取详情
this.couponInfo()
},
// 支付选择
payBind(e) {
this.pay.payWayIndex = e.detail.value
},
// 选择提交方式
platBind(e) {
this.plat.platIndex = e.detail.value
this.plat.isdeliver = this.plat.platformCp[e.detail.value].value
// 获取详情
this.couponInfo()
},
// 支付提交
submitOrder() {
if(this.plat.isdeliver.length == 0) {
this.isdeliver = this.dataInfo.detail.def_get
}
let new_rightId = this.dataInfo.rightId,
new_welfareId = this.dataInfo.welfareId,
new_addressId = this.address.addefault.id,
new_isDeliver = this.plat.isdeliver,
new_qty = this.dataInfo.num
washcarCreate({
welfare_id: new_welfareId,
right_id: new_rightId,
address_id: new_addressId,
is_deliver: new_isDeliver,
qty: new_qty
}).then(res=>{
// 跳转收银台
uni.navigateTo({
url: "/pages/cashier/index?tradeNo=" + res.trade_no + "&price=" + this.dataInfo.amount + "&deliver=" + this.plat.isdeliver + "&activity_type=" + res.type + "&type=default"
})
}).catch(err => {});
}
}
}
</script>
<style lang="scss" scoped>
/* 重要提示 */
.rightsPoint {
position: fixed;
left: 0;
bottom: 160rpx;
background: #eeeeee;
z-index: 9;
width: 100%;
padding: 20rpx 20rpx 10rpx;
box-sizing: border-box;
.rightsPoint-cont {
width: 100%;
background: #eeeeee;
border-radius: 10rpx;
position: relative;
max-height: 50vh;
overflow-y: scroll;
.rightsPoint-top {
font-size: 28rpx;
display: flex;
padding: 0 20rpx 20rpx;
box-sizing: border-box;
font-weight: 600;
image {
width: 36rpx;
height: 36rpx;
margin-right: 10rpx;
}
}
.rightsPoint-text {
padding: 0 20rpx;
box-sizing: border-box;
font-size: 24rpx;
line-height: 44rpx;
height: 90rpx;
transition: height 25s;
overflow: hidden;
&.active {
height: auto;
transition: 2s;
}
}
.pointMore {
text-align: center;
width: 100%;
background: #eeeeee;
height: 80rpx;
line-height: 82rpx;
position: relative;
margin-top: 10rpx;
&::after {
position: absolute;
content: '';
left: 0;
top: 0;
width: 100%;
height: 2rpx;
background: #f2ecde;
}
text {
font-size: 28rpx;
color: #c38e00;
animation: dong 1.8s infinite;
display: inline-block;
}
image {
width: 30rpx;
height: 30rpx;
margin-left: 4rpx;
vertical-align: -4rpx;
animation: dong 1.8s infinite;
}
@keyframes dong {
0% {
transform: translate(0px, 0px);
}
50% {
transform: translate(0px, -6rpx);
}
100% {
transform: translate(0px, 0px);
}
}
&::after {
position: absolute;
content: '';
left: 0;
top: 0;
width: 100%;
height: 2rpx;
background: #f2ecde;
}
}
}
}
// 数量
.rightsNumber {
background-color: #ffffff;
position: relative;
padding: 30rpx 40rpx;
box-sizing: border-box;
margin-bottom: 30rpx;
.rightsGoods-img {
width: 200rpx;
height: 200rpx;
border-radius: 10rpx;
}
.rightsGoods {
position: absolute;
left: 0;
top: 0;
width: 100%;
padding: 80rpx 40rpx 0 270rpx;
box-sizing: border-box;
.rightsGoods-text {
margin-bottom: 40rpx;
font-weight: 600;
}
.rightsGoods-price {
display: flex;
.rightsGoods-number {
flex: 1;
font-size: 34rpx;
text {
font-size: 28rpx;
}
}
.rightsAdd {
display: flex;
.rightsAdd-btn {
border-radius: 4rpx;
text-align: center;
width: 50rpx;
height: 50rpx;
line-height: 45rpx;
font-size: 40rpx;
font-weight: 600;
}
.rightsAdd-remove {
background: #f8f8f8;
color: #d9d9d9;
}
.rightsAdd-remove.active,
.rightsAdd-plus {
background: #e8e4e5;
color: #6b6768;
}
.rightsAdd-input {
width: 100rpx;
text-align: center;
font-size: 28rpx;
line-height: 50rpx;
}
}
}
}
}
// 卡券权益内容
.cont {
width: 100%;
overflow: hidden;
}
.contBack {
position: relative;
width: 200%;
height: 340rpx;
left: -50%;
text-align: center;
background: #000000;
border-radius: 0 0 100% 100%;
overflow: hidden;
&::before {
position: absolute;
border-radius: 50%;
content: '';
z-index: 1;
background-color: rgba(255,255,255,.1);
right: 20%;
top: 55%;
width: 300rpx;
height: 300rpx;
}
.classBack {
position: absolute;
left: 28%;
right: 30%;
width: 44%;
top: 40rpx;
}
.classCircle {
position: relative;
&::before {
position: absolute;
border-radius: 50%;
content: '';
z-index: 1;
background-color: rgba(255,255,255,.1);
left: 20%;
top: -20rpx;
width: 260rpx;
height: 260rpx;
}
}
.rightsCont {
position: absolute;
z-index: 3;
left: calc(28% - 2rpx);
right: calc(30% - 2rpx);
width: calc(44% + 4rpx);
top: 50rpx;
.rightsCont-tips {
color: #fff;
}
.welfareCont-top {
white-space: nowrap;
flex-direction: row;
align-items: center;
justify-content: space-around;
width: 100%;
padding: 0 10rpx;
box-sizing: border-box;
margin: 50rpx 0 20rpx;
.welfareCont-list-img {
border-radius: 50%;
width: 120rpx;
height: 120rpx;
display: inline-block;
margin: 0 15rpx;
overflow: hidden;
image {
width: 100%;
height: 100%;
}
}
}
.rightsCont-btn {
background: rgba(255, 255, 0255, .4);
width: 100%;
line-height: 70rpx;
font-size: 40rpx;
font-weight: 600;
color: #000000;
padding: 0 20rpx;
box-sizing: border-box;
}
}
}
// 规格权益
.rightsList,
.notice,
.detailsStore {
background: white;
box-sizing: border-box;
}
.rightsLabel,
.rightsLabel-pay {
display: flex;
padding: 20rpx 30rpx;
box-sizing: border-box;
color: #6f7880;
font-size: 30rpx;
.rightsLabel-left {
flex: 1;
color: #747d86;
}
.rightsLabel-right {
display: flex;
font-size: 28rpx;
font-weight: 700;
&.rightsLabel-red{
color: #ff5b5d;
}
&.rightsLabel-score {
font-size: 34rpx;
color: #000000;
}
}
.rightsLabel-range {
display: flex;
color: #000;
font-weight: 600;
}
.rightsLabel-row {
width: 38rpx;
height: 38rpx;
margin: 2rpx 0 0 6rpx;
}
}
// 购买须知
.notice {
background: white;
padding: 20rpx;
box-sizing: border-box;
margin-top: 30rpx;
.noticeTitle {
display: flex;
.noticeTitle-flex {
flex: 1;
display: flex;
font-size: 30rpx;
line-height: 46rpx;
.noticeTitle-img {
width: 46rpx;
height: 46rpx;
margin-right: 20rpx;
}
}
.noticeTitle-row {
width: 46rpx;
height: 46rpx;
&.active {
transform: rotate(90deg);
}
}
}
.noticeText {
font-size: 26rpx;
height: 0;
overflow: hidden;
&.active {
height: auto;
}
.noticeText-top {
margin: 30rpx 0 10rpx;
font-weight: 600;
}
.noticeText-cont {
line-height: 60rpx;
}
}
}
// 购买按钮
.rightsBtn {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 100rpx;
z-index: 9;
background: #fff;
button,
text {
display: block;
margin: 12rpx 30rpx;
width: calc(100% - 60rpx) !important;
height: 74rpx !important;
line-height: 74rpx !important;
padding: 0;
background: #eacf88;
text-align: center;
border-radius: 60rpx;
font-size: 30rpx;
}
}
.newrightsBtn {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 160rpx;
z-index: 9;
background: #fff;
padding: 30rpx;
box-sizing: border-box;
display: flex;
.rightsBtn-text {
flex: 1;
font-weight: 600;
font-size: 30rpx;
.rightsBtn-text-num {
font-size: 30rpx;
margin-bottom: 10rpx;
}
text {
font-size: 38rpx;
color: #fe2d55;
}
}
button {
width: 280rpx !important;
background-color: #000000;
color: #ffffff;
border-radius: 80rpx;
height: 100rpx;
line-height: 100rpx;
padding: 0;
margin: 0;
}
}
// 收货地址新增样式
.rightsLabel-address {
display: flex;
position: relative;
margin: 10rpx 0;
padding: 25rpx 40rpx;
}
.rightsLabel-address::after,
.rightsLabel-address::before {
position: absolute;
content: '';
left: 30rpx;
width: calc(100% - 60rpx);
height: 2rpx;
background-color: #bfbfbf;
}
.rightsLabel-address::after {
top: 0;
}
.rightsLabel-address::before {
bottom: 0;
}
.rightsLabel-address text {
display: inline-block;
width: calc(100% - 46rpx);
}
.rightsLabel-address .rightsLabel-right {
width: calc(100% - 90rpx);
margin-left: 20rpx;
color: #000000;
}
.rightsLabel-address-text {
flex: 1;
}
.rightsLabel-address .rightsLabel-row {
margin-top: 30rpx;
}
.rightsLabel .rightsLabel-icon {
width: 70rpx;
height: 70rpx;
margin-top: 14rpx;
}
.rightsLabel-address-name {
display: flex;
font-size: 32rpx;
margin-bottom: 10rpx;
}
.rightsLabel-address-tel {
padding-left: 30rpx;
color: #959595;
}
// 选择收货地址
.addressBack {
position: fixed;
left: 0;
bottom: 0;
background: rgba(0, 0, 0, .4);
z-index: 10;
width: 100%;
height: 100%;
display: none;
&.active {
display: block;
}
}
.addressCont {
position: fixed;
left: 0;
bottom: -1000%;
transition: .2s;
background: #fff;
z-index: 11;
width: 100%;
&.active {
bottom: 0;
}
.addressCont-title {
height: 90rpx;
line-height: 90rpx;
display: flex;
padding: 0 30rpx;
box-sizing: border-box;
font-size: 28rpx;
font-weight: 600;
position: relative;
&::after {
position: absolute;
content: '';
top: 0;
left: 0;
width: 100%;
height: 2rpx;
background: #f3f3f3;
}
.addressCont-left {
flex: 1;
}
.addressCont-right {
color: #309ded;
}
}
.header-classify {
white-space: nowrap;
box-sizing: border-box;
height: 600rpx;
.addressCont-list {
padding: 30rpx 20rpx;
box-sizing: border-box;
font-size: 30rpx;
overflow: hidden;
position: relative;
&::after {
position: absolute;
content: '';
left: 0;
bottom: 0;
width: 100%;
height: 2rpx;
background: #f3f3f3;
}
.addressCont-top {
display: flex;
margin-bottom: 10rpx;
.addressCont-name {
font-weight: 600;
}
}
.addressCont-text {
color: #666;
width: calc(100% - 160rpx);
}
.address-tool-icon {
width: 120rpx;
height: 54rpx;
line-height: 54rpx;
border-radius: 4rpx;
text-align: center;
color: #fff;
position: absolute;
top: 45rpx;
right: 10rpx;
background: #dfae2e;
transform: scale(.9, .9);
font-size: 24rpx;
}
}
}
}
</style>