123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595 |
- <template>
- <view class="container">
- <view class="vheigh"></view>
-
-
- <view class="top-search flex">
- <view class="search-box flex" @click="clickSearch()">
- <image class="search" src="../../static/icon/search-h.png" mode=""></image>
- <view class="search-font"><input type="text" placeholder="输入关键词搜索" v-model="productname" /></view>
- </view>
- </view>
-
-
- <swiper class="top-swiper" autoplay="true" duration="400" interval="5000" @change="swiperChange">
-
- <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"><image :src="item.pic" /></swiper-item>
- </swiper>
-
- <view class="swiper-btm flex">
- <view class="btm-item flex">
- <image src="../../static/icon/index-gou.png" mode=""></image>
- <view class="">自用购物返利</view>
- </view>
- <view class="btm-item flex">
- <image src="../../static/icon/index-gou.png" mode=""></image>
- <view class="">分享好友赚钱</view>
- </view>
- <view class="btm-item flex">
- <image src="../../static/icon/index-gou.png" mode=""></image>
- <view class="">超值正品优惠</view>
- </view>
- </view>
-
-
-
- <view class="guess-section-box">
- <view class="guess-section-title"><image src="../../static/img/title.png" mode=""></image></view>
- <view class="guess-section">
- <view v-for="(item, index) in bastList" :key="index" class="guess-item" @click="navToDetailPage(item)">
- <view class="image-wrapper"><image :src="item.image" mode="scaleToFill"></image></view>
- <text class="title clamp margin-c-20">{{ item.store_name }}</text>
- <view class="cmy-hr"></view>
- <view class="price margin-c-20 flex">
- <view>
- <text class="font-size-sm ">¥</text>
- {{ item.price }}
- </view>
-
- {{ item.sales }
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import { loadIndexs } from '@/api/index.js';
- import { getUserInfo } from '@/api/user.js';
- import { getProducts } from '@/api/product.js';
- import { saveUrl, interceptor } from '@/utils/loginUtils.js';
- import { mapState } from 'vuex';
- export default {
- watch: {
- //自适应swiper高度
- checkid(newValue, oldValue) {
- let obj = this;
- if (newValue == 0) {
- let bHeight = Math.ceil(obj.bastList.length / 2);
- obj.swiperHeight = Math.ceil(obj.pageProportion * 520 * bHeight);
- }
- if (newValue == 1) {
- let bHeight = Math.ceil(obj.goodsList.length / 2);
- obj.swiperHeight = Math.ceil(obj.pageProportion * 520 * bHeight);
- }
- if (newValue == 2) {
- let bHeight = Math.ceil(obj.bastBanner.length / 2);
- obj.swiperHeight = Math.ceil(obj.pageProportion * 520 * bHeight);
- }
- }
-
- {
- // let obj = this;
- // let bHeight = Math.ceil(newValue.length / 2);
- // obj.$nextTick(function() {
- // uni.createSelectorQuery()
- // .select('#list-box')
- // .fields(
- // {
- // size: true
- // },
- {
- // obj.pageProportion = data.width / 750;
- // obj.swiperHeight = Math.ceil(obj.pageProportion * 520 * bHeight);
- // }
-
-
-
-
- },
- data() {
- return {
- pageProportion: 0, //保存页面基于750宽度的比例
- productname: '',
- swiperHeight: 0,
- checkid: 0,
- titleNViewBackground: '',
- carouselList: [], //轮播列表
- bastList: [], //精品推荐列表
- page: 1,
- limit: 10,
- loadingType: 'more' //加载更多状态
- };
- },
- computed: {
- ...mapState(['loginInterceptor']),
- ...mapState('user', ['hasLogin', 'userInfo'])
- },
- onLoad: function(option) {
- // #ifndef MP
- if (option.spread) {
- // 存储其他邀请人
- uni.setStorageSync('spread', option.spread);
- }
-
-
- if (option.scene) {
- // 存储小程序邀请人
- uni.setStorage({
- key: 'spread_code',
- data: option.scene
- });
- }
-
- },
- onReachBottom() {
- this.loadData();
- },
- onShow: function() {
- // 判断是否强制登录
- if (this.loginInterceptor && !this.hasLogin) {
- // 登录拦截
- interceptor();
- }
- this.productname = '';
- this.loadingType = 'more';
- this.page = 1;
- this.bastList = [];
- this.loadData();
- },
-
- onPullDownRefresh() {
- this.loadData();
- },
- methods: {
- navTo(url) {
- if (!this.hasLogin) {
- // 保存地址
- saveUrl();
- // 登录拦截
- interceptor();
- } else {
- uni.navigateTo({
- url
- });
- }
- },
-
- listChange(e) {
- this.checkid = e.detail.current;
- },
-
- clickSearch() {
- this.bastList = [];
- this.page = 1;
- this.limit = 10;
- this.loadingType = 'more';
- this.loadData();
- },
-
- async loadData() {
- let obj = this;
- loadIndexs({})
- .then(({ data }) => {
- let goods = data.info;
- this.carouselList = data.banner;
- this.swiperLength = this.carouselList.length;
- if (obj.loadingType == 'nomore' || obj.loadingType == 'loading') {
- return;
- }
- obj.loadingType = 'loading';
- getProducts({
- page: obj.page,
- limit: obj.limit,
- set_vip: 1,
- keyword: obj.productname
- })
- .then(({ data }) => {
- obj.bastList = obj.bastList.concat(data);
- //判断是否还有下一页,有是more 没有是nomore
- if (obj.limit == data.length) {
- obj.page++;
- obj.loadingType = 'more';
- } else {
- obj.loadingType = 'nomore';
- }
- uni.stopPullDownRefresh();
- })
- .catch(e => {
- console.log(e);
- });
- })
- .catch(e => {
- uni.stopPullDownRefresh();
- });
- },
-
- swiperChange(e) {
- const index = e.detail.current;
- this.swiperCurrent = index;
- this.titleNViewBackground = this.carouselList[index].background;
- },
-
- navToDetailPage(item) {
- let id = item.id;
- uni.navigateTo({
- url: '/pages/product/product?id=' + id + '&isPao=1'
- });
- },
-
- bannerNavToUrl(item) {
- // #ifdef H5
- if (item.wap_url.indexOf('http') > 0) {
- window.location.href = item.wap_url;
- }
-
-
- uni.navigateTo({
- url: item.wap_url
- });
- }
- }
- };
- </script>
- <style lang="scss">
- page {
- .cate-section {
- position: relative;
- z-index: 5;
- border-radius: 16rpx 16rpx 0 0;
- margin-top: -20rpx;
- }
- }
- page {
- background: #f7f8f7;
- }
- .top-search {
- height: 80rpx;
- padding: 0 20rpx;
- background-color: #fff;
- .search-box {
- justify-content: center;
- width: 698rpx;
- height: 60rpx;
- background: #eeeeee;
- // box-shadow: 0px 10rpx 20rpx 0px rgba(4, 114, 69, 0.22);
- border-radius: 30rpx;
- .search {
- width: 34rpx;
- height: 34rpx;
- }
- .search-font {
- width: 500rpx;
- margin-left: 14rpx;
- font-size: 28rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #cbcbcb;
- }
- }
- }
- // 顶部轮播图
- .top-swiper {
- width: 750rpx;
- height: 360rpx;
- // margin: 20rpx 0 0;
- image {
- width: 750rpx;
- height: 360rpx;
- }
- }
- .swiper-btm {
- height: 60rpx;
- width: 750rpx;
- background-color: #fff;
- margin-bottom: 20rpx;
- font-size: 21rpx;
- font-weight: 500;
- color: #333333;
- .btm-item {
- flex-grow: 1;
- justify-content: center;
- image {
- width: 25rpx;
- height: 25rpx;
- margin-right: 14rpx;
- }
- }
- }
- .cate-section {
- display: flex;
- justify-content: space-around;
- align-items: center;
- flex-wrap: wrap;
- padding: 30rpx 22rpx;
- .cate-item {
- display: flex;
- flex-direction: column;
- align-items: center;
- font-size: $font-sm + 2rpx;
- color: $font-color-dark;
- }
-
- image {
- width: 88rpx;
- height: 88rpx;
- margin-bottom: 14rpx;
- border-radius: 50%;
- opacity: 0.7;
- }
- }
- %icon {
- margin-right: 10rpx;
- display: inline-block;
- padding: 2rpx 10rpx;
- border: 1rpx solid $color-yellow;
- color: $color-yellow;
- line-height: 1;
- font-size: $font-base;
- border-radius: 10rpx;
- }
- .vheigh {
- height: var(--status-bar-height);
- }
- .guess-section {
- display: flex;
- flex-wrap: wrap;
- padding: 0 30rpx;
- .guess-item {
- overflow: hidden;
- display: flex;
- flex-direction: column;
- width: 48%;
- margin-bottom: 4%;
- border-radius: $border-radius-sm;
- background-color: white;
- box-shadow: $box-shadow;
- &:nth-child(2n + 1) {
- margin-right: 4%;
- }
- }
- .image-wrapper {
- width: 100%;
- height: 330rpx;
- border-radius: 3px;
- overflow: hidden;
- image {
- width: 100%;
- height: 100%;
- opacity: 1;
- }
- }
- .title {
- font-size: $font-base;
- color: $font-color-dark;
- font-weight: bold;
- line-height: 80rpx;
- }
- .price {
- font-size: $font-lg;
- color: $font-color-base;
- font-weight: bold;
- line-height: 1;
- line-height: 80rpx;
- }
- .icon {
- @extend %icon;
- }
- .detail {
- line-height: 1;
- }
- .tip {
- color: white;
- background-color: $color-yellow;
- line-height: 1.5;
- font-size: $font-sm;
- padding-left: 20rpx;
- }
- }
- // 推荐
- .recommend {
- width: 95%;
- height: 155rpx;
- margin: 0rpx auto;
- padding-top: 30rpx;
- font-size: 26rpx;
- text-align: center;
- color: #333333;
- align-items: flex-start;
- .recommend_list {
- width: 33%;
- }
- .re_title {
- font-size: 32rpx;
- font-weight: bold;
- }
- .re_name {
- color: #999999;
- padding-top: 10rpx;
- }
- .selected_icon {
- width: 25rpx;
- height: 10rpx;
- margin: 0px auto;
- display: none;
- image {
- width: 100%;
- height: 100%;
- }
- }
- .active {
- display: block;
- }
- .active_color {
- color: #dc4d46 !important;
- }
- }
- // 列表
- .list-box-h {
- height: 1550rpx;
- }
- // 优惠券
- .coupon-list {
- display: inline-block;
- }
- .row {
- border-radius: 15rpx;
- margin: 25rpx;
- height: 155rpx;
- // width: 552rpx;
- overflow: hidden;
- background-color: #ffffff;
- padding-right: 25rpx;
- .list-interval {
- border: 1px dashed $border-color-light;
- height: 100%;
- .top,
- .bottom {
- border-radius: 100rpx;
- width: 30rpx;
- height: 30rpx;
- position: absolute;
- background-color: $page-color-base;
- right: -15rpx;
- }
- .top {
- top: -18rpx;
- }
- .bottom {
- bottom: -18rpx;
- }
- }
- .list-money {
- height: 100%;
- min-width: 155rpx;
- text-align: center;
- image {
- height: 100%;
- width: 20rpx;
- }
- .list-money-text {
- flex-grow: 1;
- padding: 0 25rpx;
- .tit {
- text-align: center;
- padding: 15rpx 0rpx;
- font-size: 55rpx;
- color: $color-red;
- font-weight: bold;
- &.noAction {
- color: $font-color-light;
- }
- }
- .price {
- padding-bottom: 25rpx;
- color: $font-color-light;
- }
- }
- }
- .row_list_right {
- // flex-grow: 1;
- min-width: 200rpx;
- padding-left: 25rpx;
- line-height: 1;
- .right_time {
- padding: 10rpx 0rpx;
- color: $font-color-light;
- font-size: $font-sm;
- }
- .right_top {
- margin: 15rpx 0;
- .right_name {
- font-size: $font-base;
- color: #bc253a;
- font-weight: bold;
- }
- .right_title {
- font-size: $font-base;
- color: $font-base;
- font-weight: bold;
- &.noAction {
- color: $font-color-light;
- }
- }
- }
- }
- .right_use {
- margin: 15rpx 0;
- padding: 10rpx;
- width: 160rpx;
- text-align: center;
- color: #fff;
- background-color: #bc253a;
- border-radius: 50rpx;
- font-size: $font-sm;
- &.noAction {
- background-color: $font-color-light;
- }
- }
- .iconlocation {
- font-size: 36rpx;
- color: $font-color-light;
- }
- }
- .guess-section-box {
- margin-top: 20rpx;
- width: 750rpx;
- background: #fff;
- padding-top: 30rpx;
- .guess-section-title {
- width: 450rpx;
- height: 30rpx;
- margin: 0 auto 36rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- }
- </style>
|