| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <!-- 专区页面 -->
- <template>
- <view class="zone">
- <view class="listbox">
- <Goods v-for="(item, index) in list" :key="index" :data="item"></Goods>
- </view>
- <NoData v-if="finish&&list.length<1"></NoData>
- <LoadMore v-else :loadtype="{page, loading, finish}"></LoadMore>
- </view>
- </template>
- <script>
- import Goods from '@/pages/mall/components/goods.vue';
- export default {
- name: 'zone',
- components: {
- Goods
- },
- data(){
- return {
- type:'default',
- page:1,
- loading:false,
- finish:false,
- pullDown:false,
- list: [],
- }
- },
- onLoad(opt) {
- if(opt){
- this.type = opt.type;
- }
- uni.setNavigationBarTitle({
- title:this.type=='hot'?'热门好物':this.type=='recommend'?'精选推荐':'好物推荐'
- });
- this.getList();
- },
- onReachBottom() {
- this.getList();
- },
- onPullDownRefresh(){
- this.pullDown = true;
- this.reData();
- },
- methods: {
- // 刷新数据
- reData(){
- this.page=1;
- this.finish=false;
- this.list=[];
- this.getList();
- },
- getList(){
- if(this.finish)return false;
- if(this.loading)return false;
- this.$u.api.getGoodsListAjax({
- page:this.page,
- tags_type:this.type,
- }).then(({code,data})=>{
- console.log(code,data)
- if(this.pullDown){
- uni.stopPullDownRefresh();
- this.pullDown = false;
- }
- this.loading = false;
- let returnData = data.data;
- if(code==1){
- if(data.last_page<=data.current_page){
- this.finish = true;
- }
- returnData.forEach(e => {
- e.checked = false;
- })
- if(data.current_page==1){
- this.list = returnData;
- }else{
- this.list=this.list.concat(returnData);
- }
- }else{
- this.finish = true;
- }
- this.page++;
- }).catch(()=>{
- this.loading = false;
- this.finish = true;
- if(this.pullDown){
- uni.stopPullDownRefresh();
- this.pullDown = false;
- }
- })
- },
- }
- };
- </script>
- <style lang="scss" scoped>
- .zone{
- // background-color: #fff;
- }
- .listbox{
- margin: 20rpx 20rpx 0;
- background-color: #fff;
- }
- </style>
|