123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- <template>
- <view>
- <u-sticky offset-top="0">
- <view class="sticky">
- <view class="nav">
- <block v-for="(item,index) in filterData" :key="index">
- <text :class="item.checked?'active':''" class="name"
- @click="checkTab(item)"
- >
- {{ item.name }}
- </text>
- </block>
- </view>
- </view>
- </u-sticky>
- <view class="u-p-l-10 u-p-r-10 waterfall">
- <u-waterfall ref="uWaterfall" v-model="flowList">
- <template v-slot:left="{leftList}">
- <view v-for="(item, index) in leftList" :key="index" class="demo-warter">
- <u-lazy-load :image="item.image" :index="index" border-radius="12" threshold="750"
- @click="clickImage(item.id)"></u-lazy-load>
- <view class="item-title">{{ item.goodsName }}</view>
- <view class="item-bottom">
- <view class="item-price">
- <view class="new-price">¥{{ item.newPrice }}</view>
- <view class="old-price">¥{{ item.oldPrice }}</view>
- </view>
- <view class="right">
- 免邮费
- </view>
- </view>
- </view>
- </template>
- <template v-slot:right="{rightList}">
- <view v-for="(item, index) in rightList" :key="index" class="demo-warter">
- <u-lazy-load :image="item.image" :index="index" border-radius="10" threshold="750"
- @click="clickImage(item.id)"></u-lazy-load>
- <view class="item-title">{{ item.goodsName }}</view>
- <view class="item-bottom">
- <view class="item-price">
- <view class="new-price">¥{{ item.newPrice }}</view>
- <view class="old-price">¥{{ item.oldPrice }}</view>
- </view>
- <view class="right">
- 免邮费
- </view>
- </view>
- </view>
- </template>
- </u-waterfall>
- <u-loadmore v-show="loading" :status="loadStatus" bg-color="rgb(250, 250, 250)" style="padding:10rpx 0;"
- @loadmore="findGoodsList"></u-loadmore>
- <u-back-top :scroll-top="scrollTop" top="1000"></u-back-top>
- <u-no-network></u-no-network>
- </view>
- </view>
- </template>
- <script>
- import config from "@/common/config.js" // 全局配置文件
- export default {
- data() {
- return {
- loading: true,
- indexArr: [],
- valueArr: [],
- defaultSelected: [],
- filterData: [{
- name: '综合排序',
- checked: true
- },
- {
- name: '销量',
- checked: false
- },
- {
- name: '价格',
- checked: false,
- },
- {
- name: '好评率',
- checked: false
- }
- ],
- pageNum: 1,
- pageSize: 20,
- scrollTop: 0,
- loadStatus: 'loadmore',
- flowList: [],
- }
- },
- onLoad() {
- // 获取数据
- this.findGoodsList();
- },
- onPageScroll(e) {
- this.scrollTop = e.scrollTop;
- },
- onReachBottom() {
- this.loadStatus = 'loading';
- // 获取数据
- this.findGoodsList()
- },
- // 下拉刷新
- onPullDownRefresh() {
- // 获取数据
- this.pageNum = 1
- this.flowList = []
- this.$refs.uWaterfall.clear();
- this.findGoodsList();
- // 关闭刷新
- uni.stopPullDownRefresh();
- },
- methods: {
- findGoodsList() {
- let url = "/api/mallApi/findGoodsList";
- this.$u.get(url, {
- pageNum: this.pageNum,
- pageSize: this.pageSize,
- orderByColumn: 'create_time',
- isAsc: 'desc'
- }).then(result => {
- // 商品数据
- const goodsList = result.rows;
- if (this.pageNum > 1 && goodsList.length < this.pageSize) {
- return this.loadStatus = 'nomore';
- }
- for (let i = 0; i < goodsList.length; i++) {
- // 先转成字符串再转成对象,避免数组对象引用导致数据混乱
- let item = goodsList[i]
- item.image = config.staticUrl + item.goodsFaceUrl
- this.flowList.push(item);
- }
- ++this.pageNum
- this.loadStatus = 'loadmore';
- });
- },
- clickImage(goodsId) {
- this.$u.route({
- url: '/pages/detail/detail',
- params: {
- goodsId: goodsId
- }
- })
- },
- //接收菜单结果
- confirm(e) {
- this.indexArr = e.index;
- console.log(this.indexArr);
- this.valueArr = e.value;
- console.log(this.valueArr);
- console.log(e);
- },
- code() {
- this.$mytip.toast('请咨询技术支持')
- },
- checkTab(item) {
- if (!item.isSort) {
- this.filterData.filter(data => {
- data.checked = false
- })
- item.checked = true
- } else {
- if (!item.asc) {
- item.asc = true
- item.desc = false
- } else {
- item.desc = true
- item.asc = false
- }
- }
- }
- }
- }
- </script>
- <style>
- page {
- background-color: #fff;
- }
- </style>
- <style lang="scss" scoped>
- .nav {
- width: 100%;
- height: 88 rpx;
- border-bottom: solid 1 rpx #eee;
- z-index: 12;
- background-color: #ffffff;
- display: flex;
- justify-content: space-around;
- align-items: center;
- font-size: 15px;
- color: $u-main-color;
- box-shadow: 4 rpx 0 10 rpx rgba(0, 0, 0, .06);
- .name {
- width: 120 rpx;
- height: 44 rpx;
- text-align: center;
- text-overflow: clip;
- overflow: hidden;
- position: relative;
- .sort {
- display: flex;
- flex-direction: column;
- position: absolute;
- height: 40 rpx;
- line-height: 40 rpx;
- right: 0;
- top: 0;
- }
- }
- .active {
- color: $base-color;
- border-bottom: 2px solid $base-color;
- height: 28px;
- line-height: 28px;
- font-weight: 600;
- }
- }
- .nomore {
- background-color: $u-bg-color;
- }
- .demo-warter {
- border-radius: 8px;
- margin-top: 3px;
- background-color: $u-bg-color;
- padding: 3px;
- position: relative;
- box-shadow: 4 rpx 0 10 rpx rgba(0, 0, 0, .06);
- }
- .item-title {
- font-size: 28 rpx;
- color: $u-main-color;
- font-weight: bold;
- padding-top: 10 rpx;
- padding-left: 10 rpx;
- background-color: #fff;
- }
- .item-bottom {
- background-color: #fff;
- display: flex;
- justify-content: space-between;
- align-items: center;
- .item-price {
- display: flex;
- align-items: center;
- width: 220 rpx;
- max-width: 220 rpx;
- text-overflow: ellipsis;
- overflow: hidden;
- white-space: nowrap;
- .new-price {
- font-weight: normal;
- font-size: 16px;
- color: $base-color;
- padding: 5px 0 5px 2px;
- }
- .old-price {
- font-weight: normal;
- font-size: 13px;
- text-decoration: line-through;
- color: $u-tips-color;
- padding: 5px 0 5px 5px;
- }
- }
- .right {
- color: #fff;
- background-image: linear-gradient(to left, rgba(#ff536f, 1), rgba(#ff536f, 0.6));
- padding: 2 rpx 12 rpx;
- border-radius: 30 rpx;
- margin-right: 5 rpx;
- }
- }
- .item-desc {
- font-weight: normal;
- font-size: 26 rpx;
- color: $u-tips-color;
- padding-bottom: 5 rpx;
- padding-left: 10 rpx;
- background-color: #fff;
- }
- </style>
|