oil-station/gasStation-uni/pagesHome/goodsDetails/goodsDetails.vue

230 lines
4.7 KiB
Vue

<template>
<view class="content">
<view class="container">
<view class="my-header">
<view class="my-icons" @click="goback"> <uni-icons type="left" size="16"></uni-icons> </view>
<view class="my-text">商品详情</view>
<view class="my-icons"></view>
</view>
<!-- 顶部区域 -->
<view class="">
<u-swiper :list="giftImages" height="390" @change="change" @click="click"></u-swiper>
</view>
<view class="bai-box">
<view class="box-title">{{goodsInfo.giftName}}</view>
<view class="box-jg">
<span
v-if="goodsInfo.exchangeMethod == '积分' || goodsInfo.exchangeMethod == '积分+金额' || goodsInfo.exchangeMethod == '积分+加钱购'">{{goodsInfo.exchangePoints}}积分</span>
<span v-if="goodsInfo.exchangeMethod == '积分+金额'">+</span>
<span
v-if="goodsInfo.exchangeMethod == '金额' || goodsInfo.exchangeMethod == '积分+金额'">¥{{goodsInfo.exchangeAmount}}</span>
</view>
<view class="dt-box">
<view class=""><u-tag :text='deliveryMethod' type="error" shape="circle"></u-tag></view>
<view class="hui-time">市场价:{{goodsInfo.market}}</view>
</view>
</view>
<view class="bai-box">
<view style="margin-bottom: 10px;">商品详情</view>
<u-line v-html="goodsInfo.detailedDescription"></u-line>
<!-- <view class="" v-html="html" ></view> -->
</view>
<view class="bottom-d">
<view class="anniux" @click="goorder()">
<text>立即兑换</text>
</view>
</view>
</view>
</view>
</template>
<script>
import config from '@/config'
import request from '../../utils/request'
export default {
data() {
return {
title: '',
goodsInfo: '',
baseUrl: config.baseUrl,
deliveryMethod: '',
giftImages: [],
}
},
components: {
},
onLoad() {
},
onShow() {
uni.$on('goodsInfo', (data) => {
this.goodsInfo = data
if (this.goodsInfo != null) {
this.dataProcessing()
}
})
uni.$emit('un')
},
methods: {
change() {},
click() {},
dataProcessing() {
this.giftImages = []
if (this.goodsInfo.giftImages != null && this.goodsInfo.giftImages != undefined) {
const myGiftImages = JSON.parse(this.goodsInfo.giftImages);
myGiftImages.forEach(res => {
if (res.fileName == undefined || res.fileName == null) {
this.giftImages.push(res.url)
} else {
let url = this.baseUrl + res.fileName
this.giftImages.push(url);
}
})
}
if (this.goodsInfo.deliveryMethod != null && this.goodsInfo.deliveryMethod != undefined) {
const deliveryData = JSON.parse(this.goodsInfo.deliveryMethod);
this.deliveryMethod = deliveryData.join('+');
} else {
this.deliveryMethod = '无配送信息'
}
},
goorder() {
// 先判断积分是否足够兑换
request({
url: '/business/userManager/user/getByUniApp',
method: 'get',
params: {
chainStoreId: uni.getStorageSync('chainStoreId')
}
}).then((res) => {
if (res.code == 200 && res.data) {
this.myPoints = res.data.points
if (res.data.points) {
if (!this.goodsInfo.exchangePoints) {
uni.navigateTo({
url: '/pagesHome/order/order'
})
} else if (res.data.points >= this.goodsInfo.exchangePoints) {
uni.navigateTo({
url: '/pagesHome/order/order'
})
} else {
// 积分不足
uni.showToast({
icon: 'none',
title: "积分不足"
})
}
}
}
})
},
goback() {
uni.navigateBack()
}
}
}
</script>
<style scoped lang="scss">
.content {
background: #f4f5f6;
}
.container {
width: 100%;
height: 100vh;
box-sizing: border-box;
padding-top: 88px;
}
.my-header {
width: 100%;
height: 88px;
background: #ffffff;
display: flex;
align-items: center;
justify-content: space-between;
color: #000;
box-sizing: border-box;
padding: 0px 15px;
padding-top: 40px;
.my-icons {
width: 20px;
}
position: fixed;
top: 0px;
}
.bai-box {
width: 100%;
background-color: #ffffff;
padding: 10px;
margin: 10px auto;
}
.dt-box {
width: 92%;
display: flex;
align-items: center;
justify-content: space-between;
}
.box-title {
font-weight: bold;
font-size: 18px;
}
.box-jg {
font-size: 20px;
color: red;
margin: 10px auto;
}
.hui-time {
color: #999999;
}
.bottom-d {
display: flex;
align-items: center;
justify-content: center;
background-color: #ffffff;
width: 100%;
height: 88px;
position: fixed;
bottom: 0px;
z-index: 99999;
}
.anniux {
width: 90%;
background: #1678ff;
color: white;
display: flex;
align-items: center;
justify-content: center;
color: white;
border-radius: 50px;
height: 50px;
}
</style>