123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- <template>
- <view>
- <!-- 数据列表 -->
- <mescroll-body top="0" :height="scrollHeight" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
- <view class="goods-list">
- <view class="item" v-for="(item,index) in dataList" :key="index" @click="showDetail(item)">
- <view class="img-box">
- <image :src="item.image" mode="aspectFill"></image>
- </view>
- <view class="info-box">
- <view class="title ellipsis2">{{item.productName}}</view>
- <view class="price-box">
- <view class="now">
- <text class="unit">¥</text>
- <text class="num">{{item.price.toFixed(2)}}</text>
- </view>
- <view class="old" v-show="item.price!=item.otPrice&&item.otPrice!==null&&item.otPrice!==undefined">¥{{item.otPrice.toFixed(2)}}</view>
- </view>
- </view>
- </view>
- </view>
- </mescroll-body>
- </view>
- </template>
- <script>
- import {getProducts} from '@/pages_shopping/api/product.js'
- import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
- export default {
- mixins: [MescrollMixin],
- props: {
- storeId:'',
- scrollHeight: 0
- },
- data() {
- return {
- form:{
- defaultOrder:'desc',
- newOrder:null,
- priceOrder:null,
- salesOrder:null,
- productName:"",
- storeId: ""
- },
- mescroll:null,
- // 上拉加载的配置
- upOption: {
- onScroll:true,
- use: true, // 是否启用上拉加载; 默认true
- page: {
- num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
- size: 10 // 每页数据的数量,默认10
- },
- noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
- empty: {
- icon:'https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/empty_icon.png',
- tip: '暂无数据'
- },
- textNoMore:"已经到底了",
- },
- // 列表数据
- dataList: [],
- };
- },
- watch: {
- storeId: {
- immediate: true, // 第一次也触发
- handler (newVal, oldVal) {
- console.log('msg 变了:', newVal)
- if(newVal) {
- console.log(this.mescroll)
- this.mescroll.resetUpScroll()
- }
- }
- }
- },
- methods:{
- mescrollInit(mescroll) {
- this.mescroll = mescroll;
- },
- /*下拉刷新的回调 */
- downCallback(mescroll) {
- mescroll.resetUpScroll()
- },
- upCallback(page) {
- //联网加载数据
- var that = this;
- const param = {
- page: page.num,
- pageSize: page.size,
- storeId: this.storeId
- }
- console.log("==============",'getProducts')
- getProducts(param).then(res => {
- if(res.code==200){
- //设置列表数据
- if (page.num == 1) {
- that.dataList = res.data.list;
-
- } else {
- that.dataList = that.dataList.concat(res.data.list);
-
- }
- that.mescroll.endBySize(res.data.list.length, res.data.total);
-
- }else{
- uni.showToast({
- icon:'none',
- title: "请求失败",
- });
- that.dataList = null;
- that.mescroll.endErr();
- }
- });
- },
- // 查看详情
- showDetail(item) {
- uni.navigateTo({
- url: '/pages_shopping/productDetails?productId='+item.productId + `${this.storeId ? '&storeId='+this.storeId : ''}`
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .desc {
- margin-top: 12rpx;
- font-family: PingFang SC, PingFang SC;
- font-weight: 400;
- font-size: 24rpx;
- color: #939599;
- }
- .goods-list{
- padding: 20upx;
- display: flex;
- flex-wrap: wrap;
- .item{
- margin-right: 20rpx;
- margin-bottom: 20rpx;
- width: 345rpx;
- background: #FFFFFF;
- box-shadow: 0px 0px 10rpx 4rpx rgba(199, 199, 199, 0.22);
- border-radius: 20rpx;
- overflow: hidden;
- &:nth-child(2n) {
- margin-right: 0;
- }
- .img-box{
- width: 100%;
- height: 334upx;
- image{
- width: 100%;
- height: 100%;
- }
- }
- .info-box{
- box-sizing: border-box;
- height: 182upx;
- padding: 20upx 20upx 30upx;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- .title{
- font-size: 26upx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #111111;
- line-height: 40upx;
- }
- .price-box{
- display: flex;
- align-items: flex-end;
- .now{
- display: flex;
- align-items: flex-end;
- margin-right: 20upx;
- .unit{
- font-size: 24upx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #FF6633;
- line-height: 1.2;
- margin-right: 4upx;
- }
- .num{
- font-size: 36upx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #FF6633;
- line-height: 1;
- }
- }
- .old{
- font-size: 26upx;
- font-family: PingFang SC;
- font-weight: 500;
- text-decoration: line-through;
- color: #BBBBBB;
- line-height: 1.1;
- }
- }
- }
- }
- }
- </style>
|