123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677 |
- <template>
- <view class="container">
- <!-- 头部轮播 -->
- <view class="carousel-section">
- <!-- 标题栏和状态栏占位符 -->
- <view class="titleNview-placing"></view>
- <swiper class="carousel" autoplay="true" duration="400" interval="5000">
- <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item" @click="bannerNavToUrl(item)"><image :src="item.pic" /></swiper-item>
- </swiper>
- </view>
- <view class="tongz flex">
- <view>
- <view class="tongz-bg"><image src="../../static/img/xtxx.png" mode=""></image></view>
- <view class="tongz-left flex">
- <image class="image-left" src="../../static/icon/ld.png" mode=""></image>
- <u-notice-bar
- style="width: 100%;"
- mode="vertical"
- type="none"
- :volume-icon="false"
- :more-icon="true"
- :list="showTitle"
- @click="goDetails"
- @getMore="nav('/pages/user/addmen?id=2')"
- ></u-notice-bar>
- </view>
- </view>
- </view>
- <u-tabs :list="typeList" active-color="#4E6CFF" name="name" bg-color="transparent" :current="typeIndex" @change="changeType"></u-tabs>
- <swiper class="list-box" @change="listChange" :style="{ height: swiperHeight + 'px' }" :current="typeIndex">
- <swiper-item v-for="ls in typeList">
- <!-- <view class="guess-section">
- <view v-for="(item, index) in ls.list" :key="index" class="guess-item" @click="navToDetailPage(item)">
- <view class="image-wrapper"><image :src="item.image" mode="scaleToFill"></image></view>
- <text class="title clamp2 margin-c-20">{{ item.store_name }}</text>
- <view class="cmy-hr"></view>
- <view class="price margin-c-20 flex">
- <view>
- <image class="iconJf" src="../../static/icon/iconU1.png" mode="widthFix"></image>
- {{ item.price }}
- </view>
- <view class="font-size-sm">
- <text class="font-color-gray">{{ item.sales }}人购买</text>
- </view>
- </view>
- </view>
- </view> -->
- <view class="good-wrapper">
- <view class="good" v-for="(item, index) in ls.list" :key="index" @click="navToDetailPage(item)">
- <view class="image-wrapper"><image :src="item.image" mode="scaleToFill"></image></view>
- <view class="good-info">
- <view class="info-title clamp2">
- {{item.store_name}}
- </view>
- <view class="info-price">
- <image class="jff" src="../../static/icon/iconU1.png" mode="widthFix"></image>{{item.price}}
- </view>
- </view>
- </view>
- </view>
- <u-loadmore :status="ls.load" />
- </swiper-item>
- </swiper>
- </view>
- </template>
- <script>
- import { loadIndexs, article } from '@/api/index.js';
- import { getUserInfo } from '@/api/user.js';
- import { interceptor } from '@/utils/loginUtils';
- import { mapState } from 'vuex';
- import { getCategoryList, getProducts } from '@/api/product.js';
- export default {
- data() {
- return {
- shareShow: false, //分享海报
- pageProportion: 0, //保存页面基于750宽度的比例
- swiperHeight: 0,
- swiperLength: 0,
- carouselList: [], //轮播列表
- page: 1,
- limit: 5,
- // 商品分类数据
- typeList: [{}],
- //保存当前选中的分类
- typeIndex: 0,
- showList: [],
- showTitle: []
- };
- },
- computed: {
- ...mapState('user', ['hasLogin', 'userInfo'])
- },
- onLoad: function(option) {
- // #ifndef MP
- if (option.spread) {
- // 存储其他邀请人
- uni.setStorageSync('spread', option.spread);
- }
- // #endif
- this.init();
- this.getShowList()
- },
- //下拉刷新
- onPullDownRefresh() {
- this.init();
- },
- // #ifndef MP
- // 监听导航栏输入框点击事件
- onNavigationBarSearchInputClicked(e) {
- //跳转到搜索页面
- this.clickSearch();
- },
- // #endif
- onReachBottom() {
- this.getProducts(this.typeList[this.typeIndex]);
- },
- methods: {
- // 初始化页面数据
- init() {
- this.loadData();
- // 获取分类
- this.getType();
- // 获取页面初始比例
- this.getBl();
- },
- // 获取初始化页面比例
- getBl() {
- let obj = this;
- obj.$nextTick(function() {
- uni.createSelectorQuery()
- .select('.container')
- .fields(
- {
- size: true
- },
- function(data) {
- obj.pageProportion = data.width / 750;
- }
- )
- .exec();
- });
- },
- // 设置切换高度
- getlistHeight(item) {
- let obj = this;
- let bHeight = Math.ceil(item.length / 2);
- obj.swiperHeight = Math.ceil(obj.pageProportion * 520 * bHeight + 30);
- },
- // tabs切换
- changeType(e) {
- console.log(e, 'dianji');
- console.log(this.typeList[e])
- this.typeIndex = e;
- // 判断是否已经加载过数据
- const item = this.typeList[this.typeIndex];
- if (!item.loding) {
- this.getProducts(item);
- }
- },
- // sw切换
- listChange(e) {
- if (e.detail.current != this.typeIndex) {
- this.typeIndex = e.detail.current;
- // 判断是否已经加载过数据
- const item = this.typeList[this.typeIndex];
- if (!item.loding) {
- this.getProducts(item);
- }
- }
- },
- //商品详情页
- navToDetailPages(item) {
- let id = item.product_id;
- //let type = 2;
- uni.navigateTo({
- url: '/pages/product/product?id=' + id
- });
- },
- // 获取商品分类
- getType() {
- const obj = this;
- getCategoryList({})
- .then(({ data }) => {
- obj.typeList = data.map(function(s) {
- return {
- name: s.cate_name,
- id: s.id,
- page: 1,
- limit: 10,
- list: [],
- load: 'loadmore', //loadmore/loading / nomore
- isLoding: false //用于判断是否已经载入过分类
- };
- });
- // 加载商品
- obj.getProducts(this.typeList[this.typeIndex]);
- })
- .catch(err => {
- console.log(err);
- });
- },
- // 获取商品信息
- getProducts(item) {
- // 判断是否已经没有数据
- if (item.load == 'nomore') {
- return;
- }
- // 判断是否加载中
- if (item.load == 'loading') {
- return;
- }
- // 判断是否为初次加载
- if (!item.isLoding) {
- item.isLoding = true;
- }
- // 设置开始加载
- item.load = 'loading';
- getProducts({
- cid: item.id,
- page: item.page,
- limit: item.limit
- })
- .then(e => {
- item.list = item.list.concat(e.data);
- if (item.list.length == item.limit) {
- item.page++;
- item.load = 'loadmore';
- } else {
- item.load = 'nomore';
- }
- // 初始化高度
- this.getlistHeight(item.list);
- })
- .catch(e => {
- console.log(e);
- });
- },
- // 點擊搜索框
- clickSearch() {
- uni.navigateTo({
- url: '/pages/product/search'
- });
- },
- // 请求载入数据
- async loadData() {
- loadIndexs({})
- .then(({ data }) => {
- let goods = data.info;
- this.carouselList = data.banner;
- this.swiperLength = this.carouselList.length;
- this.menusList = data.menus;
- uni.stopPullDownRefresh();
- })
- .catch(e => {
- uni.stopPullDownRefresh();
- });
- },
- //详情页
- navToDetailPage(item) {
- let id = item.id;
- uni.navigateTo({
- url: '/pages/product/product?id=' + id
- });
- },
- // 轮播图跳转
- bannerNavToUrl(item) {
- // #ifdef H5
- if (item.wap_url.indexOf('http') > 0) {
- window.location.href = item.wap_url;
- }
- // #endif
- //测试数据没有写id,用title代替
- uni.navigateTo({
- url: item.wap_url
- });
- },
- //获取系统消息
- getShowList() {
- article({
- page: 1,
- limit: 3
- },2).then( ({data}) => {
- this.showList = data
- this.showTitle = data.map( item => {
- return item.title
- })
- })
- },
- //系统消息跳转详情
- goDetails(e) {
- console.log(e)
- uni.navigateTo({
- url: '/pages/user/addmenDetail?id=' + this.showList[e].id
- });
- },
- nav(url) {
- // console.log('dddddddddddddddddd')
- uni.navigateTo({
- url: url
- })
- }
- }
- };
- </script>
- <style lang="scss">
- page {
- background: #f7f8f7;
- }
- .m-t {
- margin-top: 16rpx;
- }
- .list-box {
- margin-top: 30rpx;
- }
- /* 头部 轮播图 */
- .carousel-section {
- position: relative;
- padding-top: 10px;
- overflow: hidden;
- background: url(../../static/img/indexBg.png) no-repeat;
- background-size: 100% 100%;
- .titleNview-placing {
- height: var(--status-bar-height);
- padding-top: 44px;
- box-sizing: content-box;
- }
- .titleNview-background {
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 426rpx;
- transition: 0.4s;
- }
- .carousel {
- width: 680rpx;
- height: 340rpx;
- margin: 0 auto;
- .carousel-item {
- width: 100%;
- height: 100%;
- overflow: hidden;
- }
- image {
- width: 100%;
- height: 100%;
- border-radius: $border-radius-sm;
- }
- }
- }
- /*公用边框样式*/
- %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;
- }
- .f-header {
- display: flex;
- align-items: center;
- height: 92rpx;
- padding: 6rpx 30rpx 8rpx;
- image {
- flex-shrink: 0;
- width: 80rpx;
- height: 80rpx;
- margin-right: 20rpx;
- }
- .tit-box {
- @extend %font-title-box;
- }
- .tit {
- @extend %font-title;
- }
- .iconenter {
- font-size: $font-lg + 2rpx;
- color: $font-color-light;
- }
- .f-left-icon {
- @extend %f-left-icon;
- }
- .iconfont {
- font-size: $font-sm - 2rpx;
- }
- }
- /* 商品列表 */
- .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 {
- padding-top: 10rpx;
- font-size: $font-base;
- color: $font-color-dark;
- font-weight: bold;
- line-height: 1.5;
- }
- .price {
- font-size: $font-lg;
- color: $base-color;
- font-weight: bold;
- line-height: 1;
- line-height: 80rpx;
- .iconJf {
- width: 23rpx;
- margin-right: 5rpx;
- }
- }
- .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;
- }
- }
- // 列表
- .list-box-h {
- height: 1550rpx;
- }
- .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;
- }
- }
- .xtxx {
- width: 100%;
- height: 70rpx;
- position: relative;
- margin: 22rpx 0 20rpx;
- .bg {
- display: inline-block;
- width: 690rpx;
- position: absolute;
- right: 0;
- left: 0;
- margin: 0 auto;
- }
- .ld {
- width: 28rpx;
- height: 34rpx;
- position: absolute;
- top: 18rpx;
- left: 55rpx;
- }
- }
- .tongz {
- width: 690rpx;
- height: 70rpx;
- margin: 48rpx auto 0;
- padding: 18rpx 30rpx 18rpx 24rpx;
- align-items: center;
- position: relative;
- .tongz-bg {
- position: absolute;
- top: 0;
- right: 0;
- left: 0;
- width: 690rpx;
- height: 70rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- .tongz-left {
- width: 640rpx;
- .image-left {
- width: 28rpx;
- height: 34rpx;
- }
- .tongz-font {
- margin-left: 22rpx;
- font-size: 28rpx;
- font-family: Source Han Sans CN;
- font-weight: 400;
- color: #0f253a;
- }
- }
- .tongz-right {
- position: relative;
- z-index: 11;
- width: 12rpx;
- height: 26rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- }
- .good-wrapper {
- padding: 0 30rpx;
- .good {
- width: 681rpx;
- height: 257rpx;
- background: #FFFFFF;
- box-shadow: 0px 0px 15rpx 0px rgba(10, 13, 47, 0.14);
- border-radius: 14rpx;
- margin: 0 auto 20rpx;
- padding: 18rpx 19rpx 17rpx;
- display: flex;
-
- .image-wrapper {
- width: 222rpx;
- height: 222rpx;
- border-radius: 14rpx;
- flex-shrink: 0;
- // background-color: red;
- image {
- width: 100%;
- height: 100%;
- opacity: 1;
- border-radius: 14rpx;
- }
- }
- .good-info {
- padding-left: 22rpx;
- position: relative;
- .info-title {
- padding-top: 20rpx;
- font-size: 32rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #333333;
- }
- .info-price {
- font-size: 36rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #FFC000;
- line-height: 35px;
- position: absolute;
- bottom: 0;
- left: 22rpx;
- display: flex;
- align-items: center;
- }
- }
-
- }
- }
- </style>
|