<template>
	<view class="page">
		<!-- 搜索 -->
<!-- 		<view class="head-search">
			<u-search bg-color="#fff" placeholder="请输入关键词" v-model="query.advertisingName" :show-action="false" @search="search"></u-search>
			<u-button type="success" @click="search">搜索</u-button>
		</view> -->
		<!-- 搜索 -->
		<view style="margin: 20rpx 0;background-color: #FFFFFF;border-radius: 18rpx;border: 2rpx solid #E8E8E8;	margin: 22rpx 24rpx;overflow: hidden;" >
			<u-search :action-style="{'background':'#19be6b','color':'#fff','height':'32px','line-height':'32px','border-radius':'18rpx'}" bg-color="#fff" placeholder="请输入关键词" v-model="pageindex.advertisingName" action-text="搜索" @clear="search" @search="search" @custom="search"></u-search>
		</view>
		<view class="screen-list">
			<view class="list" @click="typeshow = true">
				<text>类型</text>
				<image  :src="$imgUrl('/down.png')"></image>
				<u-select v-model="typeshow" :list="typeList" @confirm="(v) => {queryChange('advertisingType', v)}"></u-select>
			</view>
		<!-- 	<view class="list" @click="setList(1)">
				<text>租金</text>
				<image :src="$imgUrl('/down.png')"></image>
			</view>

			<view class="list" @click="setList(2)">
				<text>筛选</text>
				<image :src="$imgUrl('/down.png')"></image>
			</view> -->
			<u-select v-model="show" :list="companys" @confirm="handleCompanyConfirm" mini borderless></u-select>
		</view>
		<!-- 订单列表 -->
		<view class="goods-data">
			<view v-if="tableData.length == 0" style="padding: 50rpx 0;text-align: center;">暂无数据</view>
			<view class="goods-list">
				<view class="list" v-for="(item,index) in tableData" :key="index" @click="toDetail(item)">
					<view class="thumb">
						<u-image width="20vw" height="20vw" border-radius="20" :src="item.locationDiagram.length>0?imgurl +item.locationDiagram.split(',')[0]:'' "></u-image>
						<!-- <image :src="item.locationDiagram" mode="widthFix"></image> -->
					</view>
					<view class="item">
						<view class="title">
							<text class="one-omit">{{item.advertisingName}}</text>
						</view>
						<view>
							<view class="goods-list-text">
								<view class="goods-list-txt">广告位类型：{{item.advertisingType}}</view>
								<view class="goods-list-txt">广告尺寸：{{item.dimensions}}</view>
							</view>
							<view class="goods-list-text" v-if="item.advertisingType == '线上广告位'">
								<view class="goods-list-txt">轮播顺序：<text>{{item.rotationOrder}}</text></view>
								<view class="goods-list-txt">所属移动端：<text>{{item.affiliation}}</text></view>
							</view>
							<view class="goods-list-text" v-if="item.advertisingType == '实体广告位'">
								<view class="goods-list-txt">位置信息：<text>{{item.detailedLocation}}</text></view>
								<view class="goods-list-txt">广告材质：<text>{{item.advertisingMaterial}}</text></view>
							</view>
						</view>
						
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tableData: [],
				query: {
				
					  publishStatus:2
				},
				pageindex: {
					advertisingName: '',
					advertisingType: '',
				  pageNumber: 0,
				  pageSize: 10,
				  publishStatus:2
				},
				typeshow: false,
				typeList: [
					{ value: '线上广告位', label: '线上广告位'},
					{ value: '实体广告位', label: '实体广告位'},
				],
				show:false,
				
				companys:[
					{
						value: '1',
						label: '线上广告位'
					},
					{
						value: '2',
						label: '实体广告位'
					}
				],
				imgurl:''
			};
		},
		onLoad() {
			this.imgurl = this.$img
		},
		mounted() {
		this.getAll()
		  },
		methods: {
			//查询全数据
			getAll() {
				
				this.$http.sendRequest('/cereAdvertisingInformation/queryByPage', 'POST', this.pageindex, 1).then(res => {
				    //成功回调
					this.tableData = res.data.data.content;
				}).catch(err => {
				    console.log(err)
				     	//请求失败
				})
				// let pages ={
				// 	pageNumber:0,
				// 	pageSize:10,
				// 	resourcesId:`gg${}`
				// }
				// this.$http.sendRequest('/cereResourceStrategy/queryByResources', 'POST', pages, 1).then(res => {
				//     //成功回调
				// 	this.tableData = res.data.data.content;
				// }).catch(err => {
				//     console.log(err)
				//      	//请求失败
				// })
			},
			search() {
				this.pageindex.advertisingType = '' 
				this.getAll()
			},
			queryChange(key, val) {
				this.pageindex[`${key}`] = val[0].value;
				this.getAll()
			},
			toDetail(item) {
				let items = JSON.stringify(item)
				console.log(items)
				uni.navigateTo({
					url: `/pages/advertisementDetail/advertisementDetail?item=${items}`
				})
			},
			
			
			// advertisementTime() {
			// 	uni.navigateTo({
			// 		url: '/pages/advertisementTime/advertisementTime'
			// 	})
			// },
			setList(val){
				console.log(val)
				if(val == 0){
					this.companys=[
					{
						value: '1',
						label: '线上广告位'
					},
					{
						value: '2',
						label: '线下广告位'
					}
				]
				}else if(val ==1){
					this.companys = []
				}else if(val ==2){
					this.companys = []
				}
				
				this.show = true
			},
			handleCompanyConfirm(val){
				let page = {
					pageNumber: 0,
					pageSize: 10,
					publishStatus:2,
					advertisingType:val[0].label
				}
				this.$http.sendRequest('/cereAdvertisingInformation/queryByPage', 'POST', page, 1).then(res => {
					//成功回调
					this.tableData = res.data.data.content
				})
			},
			sousu(){
				if(this.keyword != ''){
				}
			},
		}
	}
</script>

<style scoped lang="scss">
	@import 'advertisement.scss';
</style>
