123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- <style lang="scss">
- .m-app{
- padding: 0px 20rpx;
- }
- .sreach{
- background: #fff;
- margin:20rpx 0;
- border-radius: 32rpx;
- padding: 16rpx 32rpx;
- .icon{
- width: 46rpx;
- height: 46rpx;
- }
- input{
- width: calc(100% - 46rpx - 16rpx - 50px);
- font-size: 16px;
- }
- .search-btn{
- font-size: 14px;
- color: #FF4C4C;
- }
- }
-
-
- .goods-items{
- .item{
- width: calc(50% - 10rpx);
- margin-right: 10rpx;
- margin-top: 20rpx;
- box-shadow: 0px 0px 20px 0px rgba(50,50,52,0.1);
- border-radius: 20rpx;
- &:nth-child(2n){
- margin-left: 10rpx;
- margin-right: 0;
- }
- .nimg{
- width: 100%;
- height: calc(50vw - 20rpx - 10rpx);
- border-radius: 20rpx 20rpx 0 0;
- }
- .title{
- padding: 20rpx;
- height: 80rpx;
- overflow:hidden;
- text-overflow:ellipsis;
- display:-webkit-box;
- -webkit-box-orient:vertical;
- -webkit-line-clamp:2;
- color: #333333;
- font-weight: bold;
- font-size: 30rpx;
- }
- .iview{
- padding: 20rpx;
- .score{
- color: #FF4C4C;
- font-weight: bold;
- font-size: 36rpx;
- .tag{
- font-weight: bold;
- font-size: 18rpx;
- color: #FF4C4C;
- }
- }
- .btn{
- background: linear-gradient(143.2747deg, #FF6A00, #EE0979);
- border-radius: 40rpx;
- padding: 10rpx 28rpx;
- font-size: 22rpx;
- color: #FFFFFF;
- }
- }
- }
- }
- </style>
- <template>
- <view class="m-app">
-
- <!--关键词搜索-->
- <view class="sreach fx-r fx-bc fx-ac" id="top-main" >
- <image class="icon" src="/static/img/tb-seach.png"></image>
- <input type="text" confirm-type="search" v-model="keyword" @confirm="tapInput" placeholder="请输入关键词" placeholder-style="color: #B3B3B3;" />
- <view class="fx-g1"></view>
- <view class="search-btn" @tap="tapInput" v-if="keyword != ''">搜索</view>
- </view>
-
-
- <scroll-view :style="'height:calc(100vh - ' + topHeight + 'px - ' + h5Foot + 'px)'" class="mid-body clearfix" scroll-y="true" @scrolltolower="loadMoreData">
- <view class="goods-items fx-r">
- <view class="item" @tap="tapOpen" v-for="item in data" :data-url="'/pages/goods/index?id=' + item.id">
- <image :src="item.img" mode="aspectFill" class="nimg"></image>
- <view class="title">
- {{ item.title }}
- </view>
- <view class="iview fx-r">
- <view class="score fx-r fx-be">
- {{ item.commission }}
- <view class="tag" v-if="sysData.is_audit == 0">>积分</view>
- </view>
- <view class="fx-g1"></view>
- <view class="btn" v-if="sysData.is_audit == 0">>提货</view>
- </view>
-
-
- </view>
- </view>
- <view class="loading fx-r fx-ac fx-bc" v-if="!page.isFoot">
- <image src="/static/img/xloading.png"></image>
- <text>正在载入更多...</text>
- </view>
- <view class="loading complete" :hidden="!page.isFoot">已加载全部</view>
-
- </scroll-view>
- </view>
- </template>
- <script>
- import {mapState,mapMutations } from 'vuex'
- var cateId = 0;
- var brandId = 0;
- var activeId = "";//限时抢购rush,秒杀专场seckill
- var is_rush = 0;//
- var type = "";
- export default {
- computed: mapState(['user','sysData']),
- data() {
- return {
- keyword : "",
- tabIndex : 0,
- topHeight:0,
- tabPriceIndex : 0,
- data : [],
- h5Foot : 0,
- page:{
- page:1,
- isLoad:false,
- isFoot:false
- }
- }
- },
- /**
- * 跳转的值
- * @param {Object} option
- */
- onLoad(option){
- this.keyword = option.keyword || "";
- cateId = option.cateId || 0;
- brandId = option.brandId || 0;
- activeId = option.activeId || '';
- if(this.utils.isDefine(option.title)) {
- uni.setNavigationBarTitle({
- title:option.title
- });
- }
- this.$nextTick(()=>{
- const query = uni.createSelectorQuery().in(this);
- query.select("#top-main").boundingClientRect(res=>{
- this.topHeight = res.height;
- }).exec();
- });
- //判断是否H5
- // #ifdef H5
- this.h5Foot = 50;
- // #endif
- this.getData(true);
- },
- methods: {
- /**
- * 输入
- */
- tapInput:function(ev){
- this.page = {page:1,isLoad:false,isFoot:false};
- this.getData(true);
- },
- /**
- * 下拉加载
- */
- loadMoreData:function(){
-
- if(this.page.isFoot || this.page.isLoad) {
- return;
- }
- this.page.page ++;
- this.getData();
- },
- /**
- * 获取get数据
- */
- getData:function(isPull = false){
- if (this.page.isLoad) return;
- this.page.isLoad = true;
- if (isPull) {
- uni.showLoading({ title: '获取数据中..'});
- }
- var post = {};
- if(this.keyword != "") {
- post.keyword = this.keyword;
- }
- post.page = this.page.page;
- this
- .request
- .post("goodsList",post)
- .then(res => {
- uni.hideLoading();
-
- uni.hideLoading();
- if (isPull) {
- this.data = res.data.list;
- uni.stopPullDownRefresh();
- } else {
- this.data = this.data.concat(res.data.list);
- }
- this.page.isLoad = false;
- //是否到底
- if (res.data.list.length != res.data.pageSize) {
- this.page.isFoot = true;
- }
-
- })
- .catch(res=>{
- console.log(res);
- uni.hideLoading();
- uni.showModal({title: '系统提示',content: '加载失败,重新点击尝试!',showCancel: false});
- });
- },
-
- /**
- * 打开其他页面
- * @param {Object} ev
- */
- tapOpen: function(ev) {
- let url = ev.currentTarget.dataset.url
- uni.navigateTo({
- url: url
- });
- },
- /**
- * 返回上一页
- */
- tapBack: function () {
- uni.navigateBack({ delta: 1 });
- },
- }
- }
- </script>
|