|
|
- <template>
- <view class="pages">
- <u-sticky>
- <view>
- <view class="search"><u-search v-model="keyword" placeholder="请输入要搜索的商品" height="70" :show-action="false" @search="search" /></view>
- <!-- 分区 -->
- <u-tabs :list="nav_list" :is-scroll="true" :current="status" @change="getGoodsListInfo" bar-width="80" active-color="#01AEEA" font-size="34"></u-tabs>
- </view>
- </u-sticky>
- <view class="top_bg_text" :style="'background-image: url('+pageImage+')'">
- <!-- <text class="title_max">{{title}}</text>
- <text class="title_min">{{title_alt}}</text> -->
- </view>
- <view class="over_y">
- <view class="item_goods" v-for="(item,index) in list" :key="index">
- <!-- 结束遮罩层 -->
- <view class="end_goods" v-if="item.num >= item.sum || item.isEND">
- <text>已结束</text>
- </view>
- <goods-item :goods="item" thereTo='PreferentialSpellGroup'></goods-item>
- </view>
- </view>
- </view>
- </template>
-
- <script>
- import config from "@/utils/js/config.js"
- export default {
- data() {
- return {
- status: '0',
- butClass:'1',
- nav_list: [
- {
- name: "全部"
- },
- ],
- payNum:0, // 0 非处方 1处方
- http_img: config.img_url,
- pageImage: "",
- title: "特惠拼团专区",
- title_alt: "拼团购买更实惠!",
- list: [],
- pageNo: 1,
- pageSize: 10,
- total: null,
- isLock: true,
- id: '',
- keyword: ''
- }
- },
- onPullDownRefresh() {
- this.pageNo= 1;
- this.total = null;
- this.list = [];
- this.getGoodsList();
- },
- onReachBottom() {
- if(this.isLock) {
- if(this.total !== null && this.pageNo * this.pageSize >= this.total){
- this.isLock = false;
- this.$Toast('没有更多数据了哦!');
- setTimeout(()=>{
- this.isLock = true;
- },3000)
- return
- }
- this.pageNo+=1;
- this.getGoodsList();
- }
- },
- onLoad(options) {
- this.id = options.id;
- this.pageImage = options.pageImage
- this.getGoodsList();
- this.getButClass();
- },
- methods: {
- getButClass(){
- this.$api('getButClassList', {}).then(res => {
- this.nav_list = this.nav_list.concat(res.result)
- }).catch(err => {
- this.$Toast(err.message)
- })
- },
- search () {
- this.pageNo = 1
- this.getGoodsList()
- },
- getGoodsListInfo(e){
- this.status = e;
- this.list = [];
- this.butClass = this.nav_list[e].id;
- this.pageNo = 1;
- this.total = null;
- this.isLock = true;
- this.payNum = e;
- this.getGoodsList()
- console.log("获取新数据",e)
- },
- getGoodsList() {
- uni.showLoading();
- const params = {
- pageNo: this.pageNo,
- pageSize: this.pageSize,
- bottonId:this.id,
- title: this.keyword,
- payNum:this.payNum,
- butClass:this.butClass
- }
- this.$api('getGoodsList',params).then(res => {
- let { code, result, message} = res;
- uni.hideLoading();
- if(code == 200){
- if(this.total == null) {
- this.total = result.total;
- }
- result.records.forEach(item => {
- // const picArray= item.pic.split(',')
- // item.pic= picArray[0]
- if(item.pic!==null){
- const picArray=item.pic.split(',')
- item.pic= picArray[0]
- }else{
- item.pic= []
- }
- // 判断是否结束
- const endTime = new Date(item.endTime);
- const newTime = new Date();
- item.isEND = newTime > endTime ? true: false;
-
- })
- // this.list = this.list.concat(result.records);
- this.list = !this.keyword ? this.list.concat(result.records) : result.records
- }else{
- this.$Toast(message);
- }
- }).catch( err => {
- uni.hideLoading();
- this.$Toast(err.message);
- })
- },
- }
- }
- </script>
-
- <style lang="scss" scoped>
- .search {
- // position: fixed;
- width: 100%;
- top: 0;
- left: 0;
- padding: 28rpx;
- background: #fff;
- z-index: 1;
- }
- .top_bg_text{
- width: 100%;
- height: 184rpx;
- margin-top: 30rpx;
- background-size: 100% 184rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- .title_max{
- margin-top: 20rpx;
- font-size: 54rpx;
- font-weight: bold;
- color: #73B8DE;
- }
- .title_min{
- margin-top: 10rpx;
- font-size: 28rpx;
- color: #73B8DE;
- }
- }
- .pages{
- background-color: #F5F5F5;
- // padding-top: 120rpx;
- height: 100%;
- .top_img{
- margin-top: 30rpx;
- margin-bottom: 50rpx;
- height: 184rpx;
- }
- }
- .over_y {
- overflow-y: auto;
- }
-
- .item_goods {
- margin: 0 auto;
- width: 713rpx;
- margin-top: 38rpx;
- margin-bottom: 30rpx;
- background-color: #FFF;
- border-radius: 34rpx;
- box-shadow: 0 3px 6px 0 rgba(0, 0, 0, 0.16);
- position: relative;
- .end_goods{
- width: 100%;
- height: 100%;
- background-color: rgba(0, 0, 0, .5);
- position: absolute;
- top: 0;
- left: 0;
- z-index: 100;
- border-radius: 34rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 66rpx;
- color: #fff;
- }
- }
- </style>
|