123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369 |
- <template>
- <view class="center">
- <view class="top">
- <view class="status_bar"><!-- 这里是状态栏 --></view>
- <view class="top-bg"><image src="../../static/img/index-bg.png" mode=""></image></view>
- </view>
- <view class="carousel">
- <swiper autoplay="true" duration="400" interval="5000" @change="swiperChange" class="bor">
- <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"><image :src="item.pic" /></swiper-item>
- </swiper>
- </view>
- <view class="swiper-dot">
- <template v-for="item in swiperLength">
- <view class="swiper-dots-item" :key="item" :class="{ action: swiperCurrent + 1 === item }"></view>
- </template>
- </view>
- <view class="main">
- <view class="main-item" v-for="(item, index) in main" :key="index" @click="nav(item.url)">
- <view class="pic"><image :src="item.pic" mode=""></image></view>
- <view class="main-name">{{ item.name }}</view>
- </view>
- </view>
- <!-- 商品栏 -->
- <view class="commodity">
- <view class="commodity-item" v-for="(item, index) in commodityList" @click="navToDetailPages(item)">
- <view class="commodity-prc">
- <image :src="item.image" mode=""></image>
- <view class="fanli" v-if="item.type == 1">
- <view class="fanli-bg"><image src="../../static/img/index-fanl.png" mode=""></image></view>
- <!-- <view class="fanli-font flex">
- <view class="font-left">购物最高可返消费金额的</view>
- <view class="font-right">10<text>%</text></view>
- </view> -->
- </view>
- </view>
- <view class="commodity-info">
- <view class="commodity-name clamp">{{ item.store_name }}</view>
- <view class="commodity-systom clamp">{{ item.systom }}</view>
- <view class="commodity-price">
- ¥{{ item.price }}
- <text>¥{{ item.ot_price }}</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import { getTime } from '@/utils/rocessor.js';
- import { loadIndexs } from '@/api/user.js';
- import { saveUrl,interceptor } from '@/utils/loginUtils.js';
- import { mapState,mapMutations } from 'vuex';
- export default {
- computed: {
- ...mapState('user',['userInfo', 'baseURL', 'hasLogin', 'urlFile'])
- },
- data() {
- return {
- carouselList: [],
- main: [
- {
- name: '自动拼团',
- pic: '../../static/icon/index1.png',
- url:'/pages/index/appointment'
- },
- {
- name: '11人团专区',
- pic: '../../static/icon/index2.png',
- url:'/pages/product/ping'
- },
- {
- name: '拼团合伙人',
- pic: '../../static/icon/index3.png',
- url:'/pages/index/node'
- },
- {
- name: '素材分享',
- pic: '../../static/icon/index4.png',
- url:''
- },
- {
- name: '邀请有礼',
- pic: '../../static/icon/index5.png',
- url:'/pages/user/shareQrCode'
- },
- {
- name: '拼购福利',
- pic: '../../static/icon/index6.png',
- url:'/pages/user/fulilist'
- },
- {
- name: '互助专区',
- pic: '../../static/icon/index7.png',
- url:'/pages/assets/logroll'
- },
- {
- name: '签到领钱',
- pic: '../../static/icon/index8.png',
- url:'/pages/index/sign'
- },
- {
- name: '服务器兑换',
- pic: '../../static/icon/index9.png',
- url:'/pages/market/market'
- },
- {
- name: '话费充值',
- pic: '../../static/icon/index10.png',
- url:'/pages/money/phone'
- }
- ],
- swiperLength: 0,
- swiperCurrent: 0,
- commodityList: []
- };
- },
- //页面加载即刻发生
- onShow() {
- this.loadDate();
- },
- methods: {
- async loadDate() {
- const obj = this;
- loadIndexs({}).then(({ data }) => {
- console.log(data);
- obj.carouselList = data.banner;
- obj.swiperLength = data.banner.length;
- obj.commodityList = data.likeInfo;
- });
- },
- //轮播图切换修改背景色
- swiperChange(e) {
- const index = e.detail.current;
- this.swiperCurrent = index;
- },
- navToDetailPages(e) {
- if (!this.hasLogin) {
- uni.showModal({
- title: '登录',
- content: '您未登录,是否马上登陆?',
- success: e => {
- if (e.confirm) {
- interceptor();
- }
- },
- fail: e => {
- console.log(e);
- }
- });
- return;
- }
- uni.navigateTo({
- url: '/pages/product/product?id=' + e.id
- });
- },
- nav(url){
- if (!this.hasLogin) {
- uni.showModal({
- title: '登录',
- content: '您未登录,是否马上登陆?',
- success: e => {
- if (e.confirm) {
- interceptor();
- }
- },
- fail: e => {
- console.log(e);
- }
- });
- return;
- }
- uni.navigateTo({
- url,
- fail (error) {
- uni.switchTab({
- url
- });
- }
- });
- }
- }
- };
- </script>
- <style lang="scss">
- .center {
- height: auto;
- min-height: 100%;
- background-color: #ffffff;
- }
- .status_bar {
- height: var(--status-bar-height);
- width: 100%;
- }
- .top {
- width: 100%;
- height: 368rpx ;
- position: relative;
- .top-bg {
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 368rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- }
- .carousel {
- width: 700rpx;
- height: 300rpx;
- border-radius: 14rpx;
- margin: -180rpx auto 0;
- .bor {
- border-radius: 14rpx;
- .carousel-item {
- image {
- width: 100%;
- height: 100%;
- border-radius: 14rpx;
- }
- }
- }
- }
- .swiper-dot {
- position: relative;
- z-index: 10;
- margin-top: -40rpx;
- display: flex;
- justify-content: center;
- .swiper-dots-item {
- width: 14rpx;
- height: 14rpx;
- background: #aaaaaa;
- border-radius: 50%;
- margin: 0 16rpx;
- // z-index: 999;
- }
- .action {
- background-color: #ffffff;
- }
- }
- .main {
- margin-top: 80rpx;
- display: flex;
- width: 100%;
- align-items: center;
- flex-wrap: wrap;
- .main-item {
- margin: 20rpx 0;
- width: 20%;
- display: flex;
- flex-direction: column;
- align-items: center;
- .pic {
- width: 64rpx;
- height: 64rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- .main-name {
- font-size: 24rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #333333;
- margin-top: 10rpx;
- }
- }
- }
- .commodity {
- padding: 36rpx 14rpx;
- margin-top: 20rpx;
- display: flex;
- flex-wrap: wrap;
- .commodity-item {
- width: 348rpx;
- background: #ffffff;
- box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
- margin: 10rpx 6rpx 0;
- border-radius: 10rpx;
- .commodity-prc {
- width: 344rpx;
- height: 344rpx;
- border-radius: 10rpx;
- position: relative;
- image {
- width: 100%;
- height: 100%;
- }
- .fanli {
- position: absolute;
- bottom: 0;
- left: 0;
- width: 344rpx;
- height: 96rpx;
- .fanli-bg{
- position: absolute;
- bottom: 0;
- left: 0;
- width: 344rpx;
- height: 96rpx;
- }
- .fanli-font {
- position: relative;
- z-index: 10;
- color: #FFFFFF;
- height: 96rpx;
- align-items: flex-end;
- padding: 36rpx 10rpx 10rpx;
- .font-left {
- width: 226px;
- font-size: 20rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #FFFFFF;
- }
- .font-right {
- font-size: 62rpx;
- font-family: Microsoft YaHei;
- font-weight: bold;
- color: #FFFFFF;
- text {
- font-size: 26rpx;
- }
- }
- }
- }
- }
- .commodity-info {
- padding: 28rpx 20rpx 35rpx 24rpx;
- .commodity-name {
- width: 100%;
- font-size: 30rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #333333;
- }
- .commodity-systom {
- margin-top: 16rpx;
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #666666;
- }
- .commodity-price {
- margin-top: 34rpx;
- font-size: 36rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #e83f30;
- text {
- display: inline-block;
- padding-left: 6rpx;
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: bold;
- text-decoration: line-through;
- color: #999999;
- }
- }
- }
- }
- }
- </style>
|