You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

519 lines
12 KiB

4 years ago
<template>
<view class="content">
<!--nav bar-->
<view class="navbar">
<view class="navbar-fixed">
<!-- statusHeight 状态栏的高度 蓝色区块-->
<view class="statusHeight" :style="{ height: statusBarHeight + 'px' }"></view>
<!-- navcontent tabbar导航栏高度 绿色区块-->
<view class="navcontent" :style="{ height: navBarHeight + 'px' }">
4 years ago
<view class="iconfont icon-arrow-left-bold" @click="toback"></view>
4 years ago
<view class="input-view">
4 years ago
<input confirm-type="search" v-model="keyword" class="nav-bar-input" type="text"
placeholder="输入搜索关键词" @confirm="confirm">
</view>
4 years ago
</view>
</view>
<!-- 占位盒子 它的高度=状态栏高度+导航栏高度-->
4 years ago
<view class="placeholder" :style="{ height: navBarHeight + statusBarHeight + 'px', background: 'red' }">
</view>
4 years ago
<view class="termBox">
4 years ago
<!-- <view class="termOuter">
4 years ago
<view class="termCol cur">综合排序<text class="iconfont icon-arrowbottom"></text></view>
<view class="termCol">距离最近<text class="iconfont icon-arrowbottom"></text></view>
<view class="termCol">优质商户<text class="iconfont icon-arrowbottom"></text></view>
<view class="termCol">筛选<text class="iconfont icon-filter"></text></view>
4 years ago
</view> -->
</view>
4 years ago
<view class="shopContent">
3 years ago
<!--为您推荐-->
<u-empty v-if="dataList.length==0" marginTop="250"></u-empty>
4 years ago
<view class="introBox hasMenu" v-if="dataList.length>0">
4 years ago
<block v-for="(item,index) in dataList">
<view class="intro_column" @tap="gotoDetail" :data-id="item.id">
<view class="imgOuter">
<image mode="aspectFill" :src="item.poster"></image>
<view class="i_intro">{{item.product_type.name}}</view>
</view>
4 years ago
<view class="columnInfo">
4 years ago
<view class="title">{{item.name}}</view>
4 years ago
<view class="discuss">
<view class="starBox">
4 years ago
<image mode="heightFix" src="../../static/icon_detail_star_pre@2x.png">
</image>
<image mode="heightFix" src="../../static/icon_detail_star_pre@2x.png">
</image>
<image mode="heightFix" src="../../static/icon_detail_star_pre@2x.png">
</image>
4 years ago
<image mode="heightFix" src="../../static/icon_detail_star_pre@2x.png">
4 years ago
</image>
4 years ago
<image mode="heightFix" src="../../static/icon_detail_star_pre@2x.png">
4 years ago
</image>
4 years ago
</view>
4 years ago
</view>
<view class="subInfo">{{item.merchant.address}}</view>
<view class="menu"><text class="hui"></text>{{item.merchant.name}}</view>
4 years ago
</view>
</view>
4 years ago
</block>
</view>
4 years ago
</view>
</view>
4 years ago
<!--nav end-->
4 years ago
</view>
</template>
<script>
4 years ago
import {
weixin
} from '../../../../utils/weixin.js';
4 years ago
export default {
data() {
return {
4 years ago
statusBarHeight: 20, //状态栏的高度系统默认20px
menuBarHeight: 32, //微信胶囊的高度
navBarHeight: 44, //uniapp 默认的高度是44这里默认高度也就是H5导航栏的高度 根据公式计算的高度不是固定值44
keyword: "",
dataList: [],
4 years ago
currentPage: 1,
3 years ago
product_type_id: 0,
isLoading: false
4 years ago
4 years ago
}
},
4 years ago
onShareAppMessage() {
var url = 'packages/packageBuy/pages/shopList/shopList';
console.log(url)
return {
title: "福利集合",
path: url
}
},
onShareTimeline() {
var url = 'packages/packageBuy/pages/shopList/shopList';
return {
title: "福利集合",
path: url,
}
},
4 years ago
onReachBottom: function(e) {
3 years ago
if (!isLoading)
console.log("onReachBottom", this.currentPage + 1)
4 years ago
this.loadPage(this.currentPage + 1);
},
onPullDownRefresh: function(e) {
console.log("onPullDownRefresh", this.currentPage + 1)
this.loadPage(1);
},
4 years ago
onLoad(options) {
4 years ago
//获取系统信息 具体信息请转至 https://uniapp.dcloud.io/api/system/info
let res = uni.getSystemInfoSync();
4 years ago
4 years ago
console.log('状态栏的高度', res.statusBarHeight);
this.statusBarHeight = res.statusBarHeight;
4 years ago
4 years ago
// #ifdef MP-WEIXIN
4 years ago
//获取胶囊位置信息
let menuBottonInfo = uni.getMenuButtonBoundingClientRect();
//微信胶囊的高度
this.menuBarHeight = menuBottonInfo.height;
// 胶囊底部 - 状态栏 + 胶囊顶部 - 状态栏 = 导航栏的高度(胶囊距离顶部的距离+胶囊距离底部距离+胶囊自身的高度)
this.navBarHeight = menuBottonInfo.bottom - res.statusBarHeight + (menuBottonInfo.top - res.statusBarHeight);
4 years ago
// #endif
4 years ago
4 years ago
if (options.promotion_id) {
uni.setStorageSync("base_promotion_id", options.promotion_id)
}
if (options.product_type_id) {
this.product_type_id = options.product_type_id
}
},
onShow() {
4 years ago
this.loadPage(1);
4 years ago
},
methods: {
4 years ago
toback: function() {
3 years ago
let route = getCurrentPages();
console.log(route)
if (route.length > 1) {
uni.navigateBack({
delta: 1
})
} else {
uni.switchTab({
url: "../../../../pages/home/home"
})
4 years ago
}
4 years ago
},
confirm: function() {
this.loadPage(1);
},
gotoDetail: function(e) {
var id = e.currentTarget.dataset.id
uni.navigateTo({
url: "../shopDetail/shopDetail?id=" + id
})
},
loadPage: function(page) {
uni.hideKeyboard()
var that = this;
3 years ago
that.isLoading = true;
4 years ago
weixin.request({
bindThis: that,
api: '/api/member/get-products',
customLoading: false,
data: {
page: page,
page_size: 6,
keyword: that.keyword,
4 years ago
product_type_id: that.product_type_id
4 years ago
},
utilSuccess: function(r) {
var res = r.data.data;
4 years ago
3 years ago
that.isLoading = false;
4 years ago
var hasNoMore = that.dataList.length < 6 && page > 1;
if (hasNoMore || res.length == 0 && page > 1) {
uni.stopPullDownRefresh(); // 服务器总条数 < 每页条数, 会将第一页的条数重新返回
// 已加载到最后一页
uni.showToast({
title: '已加载到最后一页',
icon: 'none'
});
return;
}
var dataList = that.dataList;
for (var m of res) {
m.created_at = m.created_at.split("T")[0] + " " + m.created_at.split("T")[1]
.split(".")[0];
m.poster = (weixin.isNull(m.poster) ? "../../static/rishang.png" : m
.poster_url)
}
if (page == 1) {
dataList = res;
} else {
dataList.push(...res);
}
that.currentPage = page;
that.dataList = dataList;
},
utilFail: function(res) {
if (page == 1) {
that.currentPage = page;
that.orders = [];
}
util.alert(res);
}
});
}
4 years ago
}
}
</script>
<style>
4 years ago
page {
display: flex
}
4 years ago
</style>
<style lang="scss" scoped>
.navbar {
display: flex;
flex-direction: column;
flex: 1;
overflow: hidden;
4 years ago
4 years ago
.navbar-fixed {
position: fixed;
top: 0;
left: 0;
z-index: 99;
width: 100%;
background-color: #fff;
4 years ago
4 years ago
.statusHeight {
background-color: #fff;
}
4 years ago
4 years ago
.navcontent {
background-color: #fff;
display: flex;
justify-content: flex-start;
align-items: center;
align-content: center;
4 years ago
.iconfont {
margin: 0 20rpx;
font-size: 40rpx;
color: #333;
4 years ago
}
}
}
4 years ago
4 years ago
.shopContent {
box-sizing: border-box;
height: 100%;
flex: 1;
overflow: hidden;
}
4 years ago
4 years ago
.scroll-y-item {
height: 100%;
}
}
4 years ago
4 years ago
.input-view {
line-height: 64rpx;
width: 450rpx;
height: 64rpx;
background: #EEEEEE;
border-radius: 32rpx;
font-size: 28rpx;
4 years ago
color: #333;
4 years ago
box-sizing: border-box;
position: relative;
4 years ago
.nav-bar-input {
4 years ago
position: absolute;
4 years ago
width: 100%;
height: 100%;
top: 0;
left: 0;
4 years ago
padding: 0 30rpx;
box-sizing: border-box;
}
4 years ago
}
.introBox {
width: 710rpx;
margin: 20rpx auto 0 auto;
4 years ago
border-radius: 16rpx;
background: #fff;
4 years ago
padding: 0 24rpx;
4 years ago
box-sizing: border-box;
}
4 years ago
.introBox .intro_column:last-child {
border-bottom: none;
}
.intro_column {
4 years ago
display: flex;
justify-content: flex-start;
4 years ago
padding: 20rpx 0;
border-bottom: 2rpx solid #EAEAEA;
.imgOuter {
width: 260rpx;
height: 210rpx;
4 years ago
position: relative;
4 years ago
image {
width: 260rpx;
height: 210rpx;
border-radius: 5rpx;
}
.i_intro {
position: absolute;
top: 0;
left: 0;
//width: 68rpx;
padding: 0rpx 10rpx;
height: 32rpx;
background: #FF578A;
border-radius: 5rpx 0px 18rpx 5rpx;
font-size: 22rpx;
font-weight: 400;
color: #FFFFFF;
line-height: 32rpx;
text-align: center;
}
4 years ago
}
4 years ago
.columnInfo {
width: 360rpx;
margin-left: 22rpx;
.discuss {
margin: 13rpx 0 !important;
}
.menu {
font-size: 24rpx;
color: #333;
margin-top: 10rpx;
.hui {
margin-right: 8rpx;
display: inline-block;
width: 30rpx;
height: 30rpx;
background: #FF753E;
border-radius: 2rpx;
font-size: 22rpx;
color: #FFFFFF;
text-align: center;
line-height: 30rpx;
}
4 years ago
}
4 years ago
.title {
width: 100%;
font-size: 30rpx;
font-weight: bold;
color: #333;
4 years ago
overflow: hidden;
white-space: nowrap;
4 years ago
text-overflow: ellipsis;
4 years ago
}
4 years ago
.tags text {
4 years ago
height: 28rpx;
4 years ago
background: rgba(255, 177, 62, 0.1);
4 years ago
border-radius: 4rpx;
4 years ago
line-height: 28rpx;
font-size: 20rpx;
4 years ago
padding: 0 10rpx;
4 years ago
margin-right: 10rpx;
color: #FF753E;
4 years ago
}
4 years ago
.subInfo {
width: 100%;
font-size: 24rpx;
color: #999;
font-weight: 400;
4 years ago
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
4 years ago
padding-top: 5rpx;
.font_red {
margin-left: 10rpx;
}
4 years ago
}
4 years ago
.price {
4 years ago
display: flex;
justify-content: flex-start;
align-items: center;
align-content: center;
4 years ago
margin-top: 8rpx;
text {
margin-right: 10rpx;
}
.shareMoney {
4 years ago
height: 28rpx;
4 years ago
border: 2rpx solid #FF578A;
4 years ago
border-radius: 4rpx;
4 years ago
line-height: 28rpx;
font-size: 20rpx;
margin-right: 10rpx;
padding-right: 10rpx;
color: #FF578A;
4 years ago
display: flex;
flex-direction: flex-start;
4 years ago
text {
background: #FF578A;
color: #fff;
padding: 0 10rpx;
}
4 years ago
}
4 years ago
.free {
4 years ago
height: 28rpx;
background: #FF753E;
border-radius: 4rpx;
4 years ago
line-height: 28rpx;
font-size: 20rpx;
4 years ago
padding: 0 10rpx;
4 years ago
margin-right: 10rpx;
color: #fff;
4 years ago
}
}
4 years ago
}
4 years ago
}
4 years ago
.termBox {
4 years ago
width: 750rpx;
4 years ago
// height: 100rpx;
background: #fff;
.termOuter {
4 years ago
display: flex;
align-items: center;
align-content: center;
justify-content: flex-start;
4 years ago
.termCol {
width: 27%;
text-align: center;
4 years ago
font-size: 28rpx;
font-weight: 400;
4 years ago
color: #333333;
padding-top: 36rpx;
.iconfont {
font-size: 24rpx;
color: #666666;
line-height: 28rpx;
margin-left: 8rpx;
}
4 years ago
}
4 years ago
.termCol.cur {
color: #FF578A;
.iconfont {
color: #FF578A;
}
4 years ago
}
4 years ago
.termCol:last-child {
width: 19%;
}
4 years ago
}
}
4 years ago
.discuss {
display: flex;
justify-content: flex-start;
margin: 25rpx 0;
position: relative;
align-items: center;
align-content: center;
.dis_l {
font-size: 28rpx;
color: #333;
font-weight: 500;
padding-top: 5rpx;
margin-right: 32rpx;
}
.starBox {
4 years ago
display: flex;
justify-content: flex-start;
4 years ago
image {
display: block;
width: 26rpx;
height: 26rpx;
margin-right: 8rpx;
}
4 years ago
}
4 years ago
}
</style>