<template>
	<view>
		<i-swiper :resdata="piclist" :width="750" :height="750" :round='false' />
		<view class="bg-white p-3">
			<view class="flex align-center">
				<!-- <text class="d-inline-block bg-danger font20 text-white px-1 line2 rounded mr-1">秒杀</text> -->
				<view class="flex-1 text-ellipsis-1 font32">{{goodsInfo.name}}</view>
			</view>
			<view class=" flex align-end mt-2">
				<view class="text-danger">
					<text class="cny_jf">{{goodsInfo.price_selling}}</text>
				</view>
				<view class="font24 text-through cny ml-2 text-muted">{{goodsInfo.price_market}}</view>
			</view>
		</view>
		<view class="mt-2 bg-white p-3">
			<view class="font32 font-weight-bold">图文详情</view>
			<i-spread width="690rpx" height="2000rpx" :isShrink="true">
				<u-parse :content="goodsInfo.content" @preview="preview" @navigate="navigate"></u-parse>
			</i-spread>
		</view>
		<view class="cu-tabbar-height"></view>
		<view class="bg-white fixed-bottom">
			<view class=" px-2 py-1 border-top flex align-center">
				<view class="flex-1 flex align-center ">
					<view class="text-center flex-1" @click="toIndex">
						<uni-icons type="home" size="20" color="#333333"></uni-icons>
						<view class="font24">首页</view>
					</view>
				</view>
				<view class="flex-2 flex align-center ml-2">
					<view class="bg-danger text-white text-center py-2 font30 line15 rounded-circle flex-1" @click="toEvaluate">立即兑换</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
import { TaAjax } from '../../common/ajax';

	export default {
		data() {
			return {
				code: 0,
				goodsInfo: {},
				piclist: [],
			}
		},
		onLoad(e) {
			this.code = e.code
			if (!this.code) {
				uni.showToast({
					title: '参数错误',
					icon: 'none',
					duration: 2000,
					complete() {
						uni.navigateBack({
							delta: 1,
						})
					}
				})
			}
		},
		onShow() {
			this.loadData()
		},
		methods: {
			loadData() {
				TaAjax.get('/points_mall/api.goods/get', {
					code: this.code
				}).then((result) => {
					const data = result.data;
					const data_list = data.list;
					this.goodsInfo = data_list[0];
					this.piclist = this.goodsInfo.slider
				}).catch((e) => {
					console.warn(e)
				}).finally(() => {
				});
			},
			toIndex(){
				uni.switchTab({
					url:'/pages/points-mall/index'
				})
			},
			toEvaluate(){
				uni.showLoading({
					title: '加载中',
				})
				TaAjax.post('/points_mall/api.auth.order/add_goods', {
					code: this.code
				}).then((result) => {
					const data = result.data;
					const order_no = data.order_no;
					uni.navigateTo({
						url:'/pages/points-mall/buy?order_no='+order_no
					})
				}).finally(() => {
					uni.hideLoading()
				});
			},
			
		}
	}
</script>

<style scoped>
	.bg-light-danger {
		background-color: #fad8d6;
	}
</style>