123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- <template>
- <view class="indexBox">
- <view class="hot-list-box">
- <view class="list-box">
- <view class="list" v-for="(item,index) in navList.orderList">
- <view class="list-image-box">
- <image class="list-image" :src="item.img" mode="widthFix"></image>
- </view>
- <view class="list-content">
- <view class="list-title clamp">
- {{item.title}}
- </view>
- <view class="list-money flex flex-start">
- <view class="money">
- ¥{{item.price}}
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <uni-load-more :status="navList.loadingType"></uni-load-more>
- </view>
- </template>
- <script>
- import {
- mapState,
- mapMutations
- } from 'vuex';
- import {
- share
- } from '@/api/wx';
- import {
- getBannerList,
- getShowTemplateList
- } from '@/api/model.js';
- export default {
- data() {
- return {
- ishot:0,//判断是否热门
- isrecommend:0,//判断是否推荐
- // 商品列表
- navList: {
- state: 1,
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10, //每次信息条数
- count: 0, //总消息条数
- },
- };
- },
- onLoad: function(option) {
- if(option.isrecommend){
- uni.setNavigationBarTitle({
- title:'精品推荐'
- })
- this.isrecommend = option.isrecommend
- }else if(option.ishot){
- uni.setNavigationBarTitle({
- title:'热门装扮'
- })
- this.ishot = option.ishot
- }
- this.getShowTemplateList();
- },
- // 滚动到底部
- onReachBottom() {
- this.getShowTemplateList();
- },
- methods: {
- // 获取模板列表
- getShowTemplateList(source) {
- //这里是将订单挂载到tab列表下
- let navItem = this.navList;
- let state = navItem.state;
- if (source === 'tabChange' && navItem.loaded === true) {
- //tab切换只有第一次需要加载数据
- return;
- }
- if (navItem.loadingType === 'loading') {
- //防止重复加载
- return;
- }
- if (navItem.loadingType === 'noMore') {
- //防止重复加载
- return;
- }
- // 修改当前对象状态为加载中
- navItem.loadingType = 'loading';
- getShowTemplateList({
- is_recommend: this.isrecommend,
- is_hot: this.ishot,
- page: navItem.page,
- pageSize: navItem.limit
- })
- .then(({
- data
- }) => {
- let arr = data.list.map(e => {
- return e;
- });
- navItem.orderList = navItem.orderList.concat(arr);
- navItem.page++;
- if (navItem.limit == arr.length) {
- //判断是否还有数据, 有改为 more, 没有改为noMore
- navItem.loadingType = 'more';
- return;
- } else {
- //判断是否还有数据, 有改为 more, 没有改为noMore
- navItem.loadingType = 'noMore';
- }
- uni.hideLoading();
- this.$set(navItem, 'loaded', true);
- })
- .catch(e => {
- console.log(e);
- });
- },
- navTo(url) {
- if (url) {
- if (url.indexOf('http') > -1) {
- // #ifdef H5
- window.location.href = url
- // #endif
- // #ifdef APP
- plus.runtime.openURL(url)
- // #endif
- } else {
- uni.navigateTo({
- url: url
- })
- }
- }
- }
- },
- };
- </script>
- <style lang="scss">
- page,
- .indexBox {
- height: auto;
- min-height: 100%;
- }
- .hot-list-box {
- padding: $page-row-spacing;
- padding-bottom: 0;
- .list-box {
- display: flex;
- flex-wrap: wrap;
- justify-content: space-between;
- align-items: flex-start;
- padding-bottom: 20rpx;
- .list {
- box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
- border-radius: 15rpx;
- .list-image-box {
- width: 330rpx;
- height: 420rpx;
- overflow: hidden;
- .list-image {
- width: 100%;
- }
- }
- .list-content {
- padding: 20rpx;
- line-height: 1;
- .list-title {
- color: $font-color-dark;
- font-size: $font-base;
- margin-bottom: 20rpx;
- }
- .list-money {
- .money {
- font: $font-lg;
- color: #FF3342;
- }
- }
- }
- }
- }
- }
- </style>
|