<template>
	<view style="background-repeat: no-repeat;background-size: 100% auto;" :style="{
      'background-image': `url(${goodsInfo.bgImg})`,
	  'background-color':`${goodsInfo.backgroundColor}`,
      'border-color': goodsInfo.goodsStyle == 2 ? 'rgb(226, 226, 226)' : '',
	  'paddingTop':`${goodsInfo.bgPaddingTop!=''?goodsInfo.bgPaddingTop:0}px`,
	  'paddingBottom':`${goodsInfo.bgPaddingBottom!=''?goodsInfo.bgPaddingBottom:0}px`,
	  'marginLeft':`${goodsInfo.bgPaddingLeft!=''?goodsInfo.bgPaddingLeft:0}px`,
	  'marginRight':`${goodsInfo.bgPaddingRight!=''?goodsInfo.bgPaddingRight:0}px`,
    }">
		<view
		  class="her-scoller">
		
		  <view
		    class="good-five"
		    @click="openGood(item)"
		    v-for="(item, gli) in goodList"
		    :key="gli"
		    :style="{
		      border: goodsInfo.goodsStyle == 2 ? '1px solid rgb(226, 226, 226)' : '',
		      background:
		        goodsInfo.goodsStyle == 1 || goodsInfo.goodsStyle == 2 ? '#FFF' : '',
		    }"
		  >
		    <view class="tips" v-if="goodsInfo.showGoodsTag"
		      >
				  <image
					:src="goodsInfo.goodsTagPicUrl"
					mode="widthFix"
					style="width: 100%" v-if="goodsInfo.goodsTagPicUrl.indexOf('goods-tag-xp.png')==-1"/>
			</view>
			<view style="position: absolute; z-index: 2; top:135rpx;left:12rpx;right: 12rpx;display: flex;font-size: 18rpx;color:#FFF">
				<view style="height: 24rpx;line-height: 24prx;padding: 0 8rpx;background-color: #18A86B;">
					{{item.thirdname.split('·')[0]}}
				</view>
				<view style="width:1px;flex:1;height: 24rpx;line-height: 24prx;padding: 0 8rpx;background-color: rgba(0,0,0,.4);">
					{{item.startDate?item.startDate:item.thirdname.split('·')[1]}}
				</view>
			</view>
		    <view class="img-box-style5">
		      <image
		        style="width: 100%; height: 100%; border-radius: 10rpx 10rpx 0 0"
		        :mode="goodsInfo.fill == 1 ? 'aspectFill' : 'aspectFit'"
		        :src="item.picUrl"
		      />
		    </view>
		    <view class="good-info">
		      <view class="good-name" v-if="goodsInfo.showGoodsName">{{
		        item.name
		      }}</view>
		      <!-- <view class="good-sub-name" style="height: 35rpx">
		        <template v-if="item.subname">{{ item.subname }}</template>
		      </view> -->
		      <view class="good-price-info">
		        <view class="price" style="display: flex; align-items: center;">
		          <!-- <view class="good-sub-name" style="flex: 1">{{
		            item.thirdname
		          }}</view> -->
		          <span style="width: 1px; flex:1">
					  <text style="font-weight: bold;font-size: 22rpx;color: #080A09;margin-right: 5rpx;">¥</text>
		            {{ goodsInfo.showGoodsPrice ? item.price : "" }}
		          </span>
				  <span style="font-size: 18rpx;color: #B99846;">
					  {{item.startCity?item.startCity:''}}
				  </span>
		          <!-- <span style='text-decoration: line-through;font-size: 10px;color: gray;font-family: aa;'>原价:{{goodsInfo.showGoodsPrice ? getPrice(item.OriginalPrice) : ''}}</span> -->
		        </view>
		        <!-- <view
		          class="buy"
		          v-if="goodsInfo.showBuyBtn"
		          @click.stop="showSkuHandler(item)"
		        >
		          <u-icon
		            name="cart-o"
		            size="40"
		            :color="mainColor"
		            v-if="goodsInfo.buyBtn == 'cart'"
		          />
		          <u-icon
		            name="add-o"
		            size="40"
		            :color="mainColor"
		            v-else-if="goodsInfo.buyBtn == 'add'"
		          />
		          <u-button
		            type="primary"
		            size="mini"
		            :ripple="true"
		            :color="goodsInfo.buttonColor"
		            :custom-style="`backgroundColor:${goodsInfo.buttonColor},color:${
		              goodsInfo.buyBtnStyle == 2 || goodsInfo.buyBtnStyle == 4
		                ? goodsInfo.buttonColor
		                : '#FFF'
		            }`"
		            :plain="goodsInfo.buyBtnStyle == 2 || goodsInfo.buyBtnStyle == 4"
		            :shape="
		              goodsInfo.buyBtnStyle == 3 || goodsInfo.buyBtnStyle == 4
		                ? 'circle'
		                : 'square'
		            "
		            v-else
		          >
		            {{ goodsInfo.buyBtnText }}
		          </u-button>
		        </view> -->
		      </view>
		    </view>
		  </view>
		  <good-sku
		    v-if="showSku"
		    :option-type="2"
		    borderRadius="20"
		    v-model="showSku"
		    :good="sku"
		  ></good-sku>
		  <auth
		    v-if="showAuth"
		    @changeuserinfo="reloadUserinfo"
		    @gbAuth="gbAuth"
		  ></auth>
		</view>
	</view>
</template>
<script>
import goodSku from "../goods/goodsku";
import auth from "@/components/auth/index.vue";
export default {
  components: {
    goodSku,
    auth,
  },
  props: ["goodList", "goodsInfo"],
  data() {
    return {
      mainColor: "",
      activeKey: 0,
      showSku: false,
      sku: {},
      showAuth: false,
      u: {},
    };
  },
  created() {
    this.mainColor = this.$uiConfig.mainColor;
	console.log(this.goodsInfo)
  },
  methods: {
    openGood(item) {
      //线路
      if (item.goodType == 4) {
        var url =
          "/pages/jiuzhai/jz_LineDetail?tcid=" +
          item.id +
          "&configId=" +
          item.subid;
        console.log("url5", url);
        uni.navigateTo({
          url: url,
        });
      }
      //酒店
      else if (item.goodType == 1) {
        uni.navigateTo({
          url: "/pages/hotel/detail?id=" + item.id,
        });
      }
      //餐食
      else if (item.goodType == 2) {
        uni.navigateTo({
          url: "/pages/restaurant/detail?id=" + item.id,
        });
      }
      //景点
      else if (item.goodType == 3) {
        uni.navigateTo({
          url: "/pages/ticketCoupons/detail?id=" + item.id,
        });
      }
    },
    showSkuHandler(g) {
      this.sku = g;
      this.u = uni.getStorageSync("mall_UserInfo");
      if (!this.u) {
        this.u = {
          nickName: "未登录",
          avatarUrl: "",
        };
        this.showAuth = true;
      } else {
        this.showSku = true;
      }
    },
    reloadUserinfo() {
      this.u = uni.getStorageSync("mall_UserInfo");
      // this.showAuth = false;
    },
    //关闭登录窗口
    gbAuth() {
      this.showAuth = false;
    },
  },
};
</script>

<style scoped>
.her-scoller {
  overflow-x: auto !important;
  padding: 12px;
  /* display: flex; */
  white-space: nowrap;
}
/* .her-scoller::after {
  clear: both;
  content: " ";
  display: block;
} */
.her-scoller .good-five {
  position: relative;
  margin-right: 30rpx;
  display: inline-block;
  width: 265rpx;
  /* box-shadow: 0px 10px 30px 0px rgba(36, 36, 36, 0.2); */
  border-radius: 12rpx;
  overflow: hidden;
}
.her-scoller .good-five .tips {
  width: 94rpx;
  height: 37rpx;
  position: absolute;
  top: 18rpx;
  left: -4rpx;
  z-index: 4;
}
.her-scoller .good-five .img-box-style5 {
  /* width: 100%; */
  height: 168rpx;
  border-top-right-radius: 12rpx;
  border-top-left-radius: 12rpx;
  overflow: hidden;
}

.her-scoller .good-five .good-info {
  padding: 18rpx;
  background-color: #FFF;
  
}
.her-scoller .good-five .good-info .good-name {
  text-overflow: ellipsis;
   display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	width: 221rpx;
	    white-space: break-spaces;
	font-weight: bold;
	font-size: 22rpx;
	color: #080A09;
	line-height: 30rpx;
}
.her-scoller .good-five .good-info .good-sub-name {
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  white-space: nowrap;
  font-size: 22rpx;
  color: #999999;
  margin-bottom: 10rpx;
}
.her-scoller .good-five .good-info .good-price-info {
  display: flex;
  justify-items: center;
  align-items: center;
}
.her-scoller .good-five .good-info .good-price-info .price {
  flex: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  display: flex;
  /* flex-direction: column; */
  font-weight: 800;
  font-size: 34rpx;
  color: #FF3166;
}
.her-scoller .good-five .good-info .good-price-info .buy {
  width: 24px;
  text-align: right;
}
</style>
