<template>
	<view>
		<d-search-log @onSearchNameApi="onSearchNameApi"></d-search-log>
		<view>
			<view class="serach-list" v-for="(data,i) in dishList" :key="i">

				<view class="dish-item">
					<image class="dish-image" :src="data[i].dish_src"></image>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	import Vue from 'vue'
	export default {
		data() {
			return {
				dishList: [],
			};
		},
		onLoad() {

		},
		methods: {
			async onSearchNameApi(e) {
				let that = this
				let data = []
				uniCloud.callFunction({
					name: 'getDishes',
					data: {
						api: 'getByName',
						dish_name: e
					},
					success: function(res) {

						/*that.dishList.splice(0)
						data = [res.result.data]
						for (let i = 0; i < data.length; i++) {
							Vue.set(that.dishList, i, data[i])
						}*/
						
						console.log(res)
					}
				})
			}


		}
	}
</script>

<style lang="scss">
	.searchbox {
		width: 500;
		display: flex;
	}

	.search-list {
		display: flex;
	}

	.dish_image {
		width: 100rpx;
		height: 70rpx;
	}
</style>