<template>
	<view>
		<!-- #ifdef MP-ALIPAY -->
		<u-navbar title="商家信息" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" leftIconSize="0"/>
		<!-- #endif -->
		<!-- #ifdef MP-WEIXIN -->
		<u-navbar title="商家信息" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
		<!-- #endif -->
		<!-- #ifndef MP-WEIXIN || MP-ALIPAY -->
		<view v-if="pagesNum > 1">
			<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="商家信息" />
		</view>
		<view v-else>
			<u-navbar leftIconSize="0" :placeholder="true" bgColor="#fff" :border="true" title="商家信息">
				<view class="nav-left flex" slot="left" @click="$toIndex()">
					<u-icon name="arrow-left" size="20" color="#333"></u-icon>
				</view>
			</u-navbar>
		</view>
		<!-- #endif -->
		<view class="company">该商品由以下商家提供</view>
		<view class="detail-description" v-for="(item,index) in merchantInfo" :key="index">
			<image :src="item" mode="scaleToFill"></image>
		</view>
	</view>
</template>

<script>
	import env from '../../config/env.js'
	import $http from '@/utils/request.js'
	export default {
		data() {
			return {
				merchantInfo: [],
				goodsId:'',
				data:[],
				pagesNum: '',
			}
		},
		onLoad(opthios) {
			this.goodsId = opthios.goodsId
		},
		onShow() {
			this.pagesNum = getCurrentPages().length
			this.getDetail()
		},
		methods: {
			toGoodsDetail(){
				uni.navigateBack({})
			},
			getDetail(){
				uni.showLoading({
					title: '加载中'
				});
				$http.post('/api/v1/mp/user/exchange/goods/detail', {
					goodsId: this.goodsId,
					noToken: true
				}).then(res => {
					uni.hideLoading();
					if (res.code == 0) {
						let merchantInfos = res.data.merchantInfo.split(',')
						merchantInfos.forEach(item => {
							this.merchantInfo.push(env.filePublic + item + '?imageView2/2/w/750')
						})
					}
				}).catch(() => {
					uni.hideLoading();
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.company{
		margin: 20rpx 40rpx;
	}
	.detail-description {
		image {
			width: 100%;
		}
	}
</style>
