136 lines
2.9 KiB
Vue
136 lines
2.9 KiB
Vue
<template>
|
|
<view class="content">
|
|
<!-- 搜索 -->
|
|
<search @handleSearch="handleSearch"></search>
|
|
<!-- 食谱 -->
|
|
<view class="footlist footbox" v-if="menuList.length">
|
|
<view class="list" v-for="(it,id) in menuList" :key="it" @click="handleDetail(it.id)">
|
|
<view class="topimg">
|
|
<image :src="it.cover_url" class="img" mode="aspectFill"></image>
|
|
</view>
|
|
<view class="item">
|
|
<view class="title">{{it.title}}</view>
|
|
<view class="name">
|
|
<image :src="it.create_user_head_pic"></image>
|
|
<text class="overflow">{{it.create_user_nickname}}</text>
|
|
</view>
|
|
<view class="zan" @click="handleZan(it)">
|
|
<icon class="t-icon" :class="[it.is_me_like_it=='yes'?'t-icon-icon3':'t-icon-icon_collect']">
|
|
</icon>
|
|
<text>{{it.likes_num}}</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="endtext" v-if="(!lastPage || page >= lastPage)&&menuList.length">—— 到底了,看看别的吧 ——</view>
|
|
<view v-if="!menuList.length" class="nolist">
|
|
<icon class="iconfont icon-wancan"></icon>
|
|
<text>还没有记录哦</text>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import {
|
|
mapState
|
|
} from "vuex";
|
|
import search from "../../components/search.vue"
|
|
export default {
|
|
data() {
|
|
return {
|
|
type: "",
|
|
name: "",
|
|
page: 1,
|
|
menuList: [],
|
|
lastPage: '',
|
|
}
|
|
},
|
|
components: {
|
|
search
|
|
},
|
|
onLoad(option) {
|
|
let that = this
|
|
that.type = option.pageName
|
|
uni.setNavigationBarTitle({
|
|
title: option.pageName
|
|
});
|
|
|
|
},
|
|
onShow() {
|
|
let that = this
|
|
that.name = ""
|
|
that.page = 1
|
|
that.menuList = []
|
|
that.handleCooklist()
|
|
},
|
|
onReachBottom() {
|
|
let that = this
|
|
if (!this.lastPage || this.page >= this.lastPage) {
|
|
uni.showToast({
|
|
title: '没有更多数据!',
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
this.page++
|
|
this.handleCooklist(this.page)
|
|
},
|
|
methods: {
|
|
handleCooklist() {
|
|
let that = this
|
|
let https = that.type == '我的菜谱' ? that.$model.getMyCookbook : that.$model.getUserCollectList
|
|
https({
|
|
page: that.page,
|
|
search_data: that.name
|
|
}).then(res => {
|
|
if (res.code != 0) return
|
|
that.menuList = res.data.content_list
|
|
that.lastPage = res.data.page_total
|
|
})
|
|
},
|
|
// 商品详情
|
|
handleDetail(id) {
|
|
uni.navigateTo({
|
|
url: "/pageTwo/me/menudetail?id=" + id + '&title=' + this.type
|
|
})
|
|
},
|
|
// 搜索
|
|
handleSearch(ite) {
|
|
let that = this
|
|
that.page = 1
|
|
that.name = ite
|
|
that.menuList = []
|
|
that.lastPage = ""
|
|
that.handleCooklist()
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.content {
|
|
background: #fff;
|
|
}
|
|
|
|
/deep/.serachBox {
|
|
padding-top: 20rpx !important;
|
|
}
|
|
|
|
.footlist {
|
|
position: relative;
|
|
margin-top: 68px;
|
|
padding: 30rpx;
|
|
width: calc(100% - 60rpx);
|
|
background: #fff;
|
|
border-radius: 30rpx 30rpx 0 0;
|
|
|
|
.item {
|
|
background: #f7f7f7 !important;
|
|
border-top: 1px solid #f7f7f7;
|
|
}
|
|
}
|
|
|
|
.nolist {
|
|
margin-top: 50%;
|
|
}
|
|
</style> |