123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- <template>
- <view >
- <view class="top-fixed">
- <view class="search-cont">
- <view class="inner">
- <image class="icon-search" src="/static/images/search.png" mode=""></image>
- <input type="text" @confirm="goSearch" :value="form.title" placeholder="输入商品名称" placeholder-style="font-size:28rpx;color:#BBBBBB;font-family: PingFang SC;" />
- </view>
- </view>
- <view class="cate-list">
- <!-- 关键字列表 -->
- <scroll-view scroll-x="true" >
- <view class="inner">
- <view v-for="(item,index) in cates" :key="index" :class="cateId == item.dictValue?'item active':'item'" @click="choseCate(item)">
- {{ item.dictLabel }}
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
-
- <mescroll-body top="204rpx" 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="sku">{{item.sku}}</view>
- <view class="price-box">
- <view class="now">
- <text class="unit">¥</text>
- <text class="num">{{item.price.toFixed(2)}}</text>
- </view>
- <!-- <view class="old">¥{{item.otPrice.toFixed(2)}}</view> -->
- </view>
- <view class="tui-money">
- 分享赚{{item.brokerage.toFixed(2)}}
-
- </view>
- </view>
- </view>
- </view>
- </mescroll-body>
- </view>
- </template>
- <script>
- import {getStoreProductAttrValueList} from '@/api/product.js'
- import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
- export default {
- mixins: [MescrollMixin],
- data() {
- return {
- cateId:0,
- cates:[],
- searchKey:"",
- 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:'/static/images/no_data.png',
- tip: '暂无数据'
- }
- },
- // 列表数据
- dataList: [],
- };
- },
- onLoad(options) {
- var that=this;
- this.cates=this.utils.getDict("storeProductTuiCate");
- },
- methods: {
- choseCate(item){
- this.cateId = item.dictValue;
- this.mescroll.resetUpScroll()
- },
- goSearch(e) {
- this.searchKey=e.detail.value;
- this.mescroll.resetUpScroll()
-
- },
- mescrollInit(mescroll) {
- this.mescroll = mescroll;
- },
- /*下拉刷新的回调 */
- downCallback(mescroll) {
- mescroll.resetUpScroll()
- },
- upCallback(page) {
- //联网加载数据
- var that = this;
- var data = {
- tuiCateId:this.cateId,
- productName:this.searchKey,
- page: page.num,
- pageSize: page.size
- };
- getStoreProductAttrValueList(data).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
- })
- },
- }
- }
- </script>
- <style lang="scss">
- .top-fixed{
- width: 100%;
- position: fixed;
- top: 0;
- left: 0;
- z-index: 10;
- .search-cont{
- padding: 16upx 30upx;
- background-color: #FFFFFF;
- display:flex;
- align-items: center;
- justify-content: space-between;
- .inner{
- box-sizing: border-box;
- width: 100%;
- height: 72upx;
- background: #F7F7F7;
- border-radius: 36upx;
- display: flex;
- align-items: center;
- padding: 0 30upx;
- .icon-search{
- width: 28upx;
- height: 28upx;
- margin-right: 20upx;
- }
- input{
- height: 60upx;
- line-height: 60upx;
- flex: 1;
- }
-
- }
-
- }
- .cate-list{
- box-sizing: border-box;
- background: #fff;
- padding: 10upx 27upx;
- height: 100upx;
- .inner{
- display: flex;
- }
- .item{
- flex-shrink: 0;
- padding: 0 24upx;
- height: 64upx;
- line-height: 64upx;
- font-size: 28upx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #018C39;
- background: #F5FFFE;
- border: 1px solid #8AD5CE;
- border-radius: 32upx;
- margin: 0 20upx 20upx 0;
- &.active{
- color: #FFFFFF;
- background: #018C39;
- border: 1px solid #018C39;
- }
- }
- }
- }
- .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;
- padding: 20upx 20upx 30upx;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- position: relative;
- .title{
- font-size: 26upx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #111111;
- line-height: 40upx;
- }
- .sku{
- font-size: 26upx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #BBBBBB;
- line-height: 1.1;
- }
- .price-box{
- margin-bottom: 50rpx;
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- .now{
- display: flex;
- align-items: flex-end;
- margin-bottom: 5upx;
- .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;
- }
- }
- .tui-money{
- position: absolute;
- right:0rpx;
- bottom: 15rpx;
- font-size: 30upx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #FFF;
- background:linear-gradient(to right, #FF6633 , #F11118);
- padding: 6rpx 12rpx;
- border-radius: 30rpx 0rpx 0rpx 30rpx;
-
- }
- }
- }
- }
-
- </style>
|