123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616 |
- <template>
- <mobile-frame :frameStyle="frameStyle" @toPath="toPath">
- <scroll-view scroll-y="true" class="scroll-view" scroll-with-animation :scroll-top="scrollTop" @scroll="scroll"
- @scrolltolower="toPage">
- <view class="list-scroll-view">
- <view class="main">
- <view class="zero one">
- <input type="text" placeholder="搜索商品" @tap="toCommon('pagesHome/market/search')"
- placeholder-class="placss">
- </view>
- <view class="zero two">
- <swiper class="swiper" circular :indicator-dots="true" indicator-color="#ffffff"
- indicator-active-color="#FB1438" :autoplay="true" :interval="3000" :duration="1000">
- <swiper-item class="list" v-for="(item,index) in bannerList" :key="index"
- @tap="toBanner(item)">
- <image class="image" :src="item.url&&item.url.length>0?item.url[0].url:''" mode="">
- </image>
- </swiper-item>
- </swiper>
- </view>
- <view class="zero thr">
- <view class="list" v-for="(item,index) in btnList" :key="index" @tap="toIndexModel(item)">
- <image class="image" :src="item.url&&item.url.length>0?item.url[0].url:''" mode=""></image>
- <view class="textOver name">
- {{item.name}}
- </view>
- </view>
- </view>
- <view class="zero four" v-if="recomList&&recomList.length>0">
- <view class="recomList" v-for="(item,index) in recomList" :key="index"
- v-if="item.list&&item.list.length>0">
- <view class="list" v-for="(tag,indexs) in item.list" :key="indexs" @tap="toBuy(tag)">
- <view class="list_1">
- <view class="txt">
- <text>{{tag.title}}</text>
- </view>
- <view class="more" v-if="indexs==1" @tap.stop="toMore(tag)">
- <text>更多</text>
- </view>
- </view>
- <view class="list_2">
- <image class="image" :src="tag.url&&tag.url.length>0?tag.url[0].url:''" mode="">
- </image>
- </view>
- <view class="list_3 textOver">
- {{tag.name}}
- </view>
- </view>
- </view>
- </view>
- <view class="zero act">
- <view class="list" v-for="(item,index) in platformactList" :key="index" @tap="toAct(item)">
- <view class="img">
- <image class="image" :src="item.cover&&item.cover.length>0?item.cover[0].url:''"
- mode="">
- </image>
- </view>
- <view class="title" v-if="item.act_time.is_use=='0'">
- <text>{{item.act_time.title}}</text>
- </view>
- <view class="time" v-if="item.act_time.is_use=='0'">
- <text>{{item.act_time.value}}</text>
- </view>
- </view>
- </view>
- <view class="zero five">
- <view class="five_pubu">
- <view class="list" v-for="(item,index) in marketList" :key="index" @tap="toBuy(item)">
- <image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''" mode="">
- </image>
- <view class="name textOver">
- {{item.name}}
- </view>
- <view class="other">
- <view class="money">
- <view class="money_1">
- <text>¥</text><text>{{item.sell_money||0}}</text>
- </view>
- <view class="money_2">
- <text>¥</text><text>{{item.flow_money||0}}</text>
- </view>
- </view>
- </view>
- <view class="other" v-if="item.leader_price">
- <view class="leader">
- <text>会员价</text><text>¥</text><text>{{item.leader_price||0}}</text>
- </view>
- </view>
- <view class="other" v-if="item.p_act">
- <text class="label" v-for="(tag,index) in item.p_act" :key="index">{{tag}}</text>
- </view>
- <view class="acttags">
- <text v-for="(i,indexx) in item.actTagsShow" :key="indexx">{{i.label}}</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
- <view class="backTop" v-if="old_scrollTop>500">
- <text @tap="goTop" class="iconfont icon-fanhuidingbu"></text>
- </view>
- </mobile-frame>
- </template>
- <script>
- export default {
- data() {
- return {
- frameStyle: {
- useBar: true
- },
- bannerList: [ // 轮播图
- ],
- btnList: [ //功能按钮
- ],
- recomList: [ //推荐好物
- ],
- platformactList: [ //平台活动
- ],
- marketList: [ //商品列表
- ],
- total: 0,
- skip: 0,
- limit: 10,
- page: 0,
- // 返回顶部
- scrollTop: 0,
- old_scrollTop: 0
- };
- },
- onLoad: async function() {
- const that = this;
- await that.search();
- },
- onPullDownRefresh: async function() {
- const that = this;
- that.clearPage();
- await that.search();
- uni.stopPullDownRefresh();
- },
- methods: {
- async search() {
- const that = this;
- let res;
- // 轮播图
- res = await that.$api(`/banner`, 'GET', {
- status: '0'
- });
- if (res.errcode == '0') {
- that.$set(that, `bannerList`, res.data);
- }
- // 首页模块管理
- res = await that.$api(`/indexModule`, 'GET', {});
- if (res.errcode == '0') {
- that.$set(that, `btnList`, res.data);
- }
- // 推荐好货
- res = await that.$api(`/viewGoods/iatg`, 'GET', {});
- if (res.errcode == '0') that.$set(that, `recomList`, res.data);
- // 平台活动
- res = await that.$api(`/platformAct`, 'GET', {
- show_index: '0',
- is_use:'0'
- });
- if (res.errcode == '0') that.$set(that, `platformactList`, res.data);
- // 首页产品查询
- that.searchMarket()
- },
- // 首页产品查询
- async searchMarket() {
- const that = this;
- let res;
- let info = {
- skip: that.skip,
- limit: that.limit
- };
- // 首页产品列表
- res = await that.$api(`/viewGoods/indexGoodsList`, `GET`, {
- ...info
- });
- if (res.errcode == '0') {
- let list = [...that.marketList, ...res.data];
- that.$set(that, `marketList`, list);
- that.$set(that, `total`, res.total)
- }
- },
- // 公共跳转
- toCommon(e) {
- uni.navigateTo({
- url: `/${e}`
- })
- },
- // 轮播图跳转
- toBanner(e) {
- uni.navigateTo({
- url: `/${e.to}?id=${e._id}`
- })
- },
- // 首页模块菜单跳转
- toIndexModel(data) {
- if (data && data.status == '1') {
- uni.showToast({
- title: '升级中敬请期待!',
- icon: 'none'
- })
- } else {
- uni.navigateTo({
- url: `/${data.to}`
- })
- }
- },
- // 推荐好物更多
- toMore(e) {
- const that = this;
- uni.navigateTo({
- url: `/pagesRest/recom/index?act_tags=${e.value}`
- })
- },
- // 平台活动
- toAct(e) {
- const that = this;
- uni.navigateTo({
- url: `/pagesRest/activity/info?id=${e._id}`
- })
- },
- // 购买
- toBuy(e) {
- const that = this;
- let id = e._id || e.id;
- uni.navigateTo({
- url: `/pagesHome/order/detail?id=${id}`
- })
- },
- // 分页
- toPage(e) {
- const that = this;
- let list = that.marketList;
- let limit = that.limit;
- if (that.total > list.length) {
- uni.showLoading({
- title: '加载中',
- mask: true
- })
- let page = that.page + 1;
- that.$set(that, `page`, page)
- let skip = page * limit;
- that.$set(that, `skip`, skip)
- that.searchMarket();
- uni.hideLoading();
- }
- },
- // 计算高度
- scroll: function(e) {
- const that = this;
- that.old_scrollTop = e.detail.scrollTop
- },
- // 返回顶部
- goTop: function(e) {
- const that = this;
- that.scrollTop = that.old_scrollTop;
- that.$nextTick(function() {
- that.scrollTop = 0
- });
- },
- clearPage() {
- const that = this;
- that.$set(that, `bannerList`, [])
- that.$set(that, `btnList`, [])
- that.$set(that, `recomList`, [])
- that.$set(that, `platformactList`, [])
- that.$set(that, `marketList`, [])
- that.$set(that, `skip`, 0)
- that.$set(that, `limit`, 6)
- that.$set(that, `page`, 0)
- },
- // 菜单跳转
- toPath(e) {
- let url = `/${e.route}`;
- if (e.type == '0') uni.redirectTo({
- url
- })
- else {
- uni.navigateTo({
- url
- })
- }
- },
- }
- }
- </script>
- <style lang="scss">
- .main {
- padding: 2vw;
- .zero {
- margin: 0 0 2vw 0;
- }
- .zero:last-child {
- margin: 0
- }
- .one {
- background-color: var(--fFB1Color);
- border-radius: 20px;
- padding: 0 2vw 0 5vw;
- input {
- font-size: var(--font15Size);
- color: var(--fffColor);
- border-radius: 14px;
- width: 100%;
- padding: 1.5vw;
- }
- .placss {
- color: var(--fffColor);
- }
- }
- .two {
- swiper {
- height: 50vw;
- border-radius: 5px;
- }
- .list {
- border-radius: 5px;
- .image {
- width: 100%;
- height: 100%;
- border-radius: 5px;
- }
- }
- }
- .thr {
- display: flex;
- flex-direction: row;
- justify-content: space-around;
- flex-wrap: wrap;
- .list {
- width: 17vw;
- text-align: center;
- margin: 0 0 2vw 0;
- .image {
- width: 80%;
- height: 13vw;
- margin: 1.5vw 0 1.5vw 0;
- }
- .name {
- font-size: var(--font13Size);
- }
- }
- }
- .four {
- display: flex;
- flex-direction: row;
- justify-content: space-around;
- flex-wrap: wrap;
- background-color: var(--f2Color);
- padding: 2vw 0 0 0;
- .recomList {
- width: 41vw;
- display: flex;
- justify-content: space-around;
- background-image: linear-gradient(to bottom, rgba(250, 216, 213, 1) 5%, rgba(255, 255, 255, 1) 22%);
- margin: 0 0 2vw 0;
- border-radius: 5px;
- padding: 2vw;
- .list {
- width: 20vw;
- text-align: center;
- .list_1 {
- display: flex;
- justify-content: space-between;
- margin: 0 0 1vw 0;
- .txt {
- font-size: 15px;
- }
- .more {
- font-size: 12px;
- margin: 0 0 4px 0;
- }
- }
- .list_2 {
- margin: 0 0 1vw 0;
- .image {
- width: 96%;
- height: 18vw;
- }
- }
- .list_3 {
- width: 17vw;
- font-size: var(--font12Size);
- border: 1px solid var(--fFB1Color);
- border-radius: 25px;
- padding: 0 1vw;
- text-align: center;
- }
- }
- }
- }
- .act {
- background-color: var(--f2Color);
- padding: 2vw 2vw 0 2vw;
- display: flex;
- flex-direction: column;
- .act_1 {
- text-align: center;
- margin: 0 0 2vw 0;
- font-family: cursive;
- color: var(--fFB1Color);
- font-size: 20px;
- }
- .list {
- border-radius: 10px;
- position: relative;
- .img {
- .image {
- width: 100%;
- height: 14vh;
- box-shadow: 0 0 5px #f1f1f1;
- border-radius: 10px;
- }
- }
- .title {
- position: absolute;
- top: 5vw;
- text-align: center;
- width: 95%;
- left: 2vw;
- text {
- font-size: 20px;
- font-family: cursive;
- color: #000000;
- font-weight: bold;
- overflow: hidden;
- text-overflow: ellipsis;
- -webkit-line-clamp: 2;
- word-break: break-all;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- }
- }
- .time {
- position: absolute;
- bottom: 2vw;
- right: 2vw;
- font-size: 12px;
- width: 100%;
- text-align: right;
- }
- }
- }
- .five {
- display: flex;
- flex-direction: column;
- background-color: var(--f2Color);
- padding: 2vw 0;
- .five_pubu {
- // column-count: 2;
- // column-gap: 2vw;
- display: flex;
- justify-content: space-between;
- flex-wrap: wrap;
- padding: 0 2vw;
- .list {
- // break-inside: avoid;
- position: relative;
- width: 41vw;
- background-color: var(--fffColor);
- padding: 2vw;
- margin: 0 0 2vw 0;
- border-radius: 10px;
- .image {
- width: 100%;
- height: 40vw;
- }
- .name {
- font-size: var(--font14Size);
- }
- .other {
- display: flex;
- flex-direction: row;
- padding: 1vw 0 0 0;
- .money {
- display: flex;
- .money_1 {
- color: var(--fFB1Color);
- font-size: 12px;
- text:last-child {
- font-size: 16px;
- padding: 0 0 0 1vw;
- }
- }
- .money_2 {
- font-size: 12px;
- margin: 0 0 0 2vw;
- color: var(--f99Color);
- text {
- text-decoration: line-through;
- }
- text:last-child {
- font-size: 16px;
- padding: 0 0 0 1vw;
- }
- }
- }
- .label {
- font-size: 12px;
- color: #FFA500;
- border: 1px solid #FFA500;
- border-radius: 5px;
- padding: 0 1vw;
- margin: 0 1vw 0 0;
- }
- .leader {
- font-size: 12px;
- text-align: center;
- color: #23B67A;
- text:last-child {
- font-size: 16px;
- padding: 0 0 0 1vw;
- }
- }
- }
- .acttags {
- position: absolute;
- top: 2vw;
- width: 93%;
- text {
- display: inline-block;
- background-color: var(--fFB1Color);
- color: #fff;
- border-radius: 1vw;
- padding: 0.5vw;
- font-size: 12px;
- margin: 0 1vw 0 0;
- }
- }
- }
- }
- }
- }
- .scroll-view {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- .list-scroll-view {
- display: flex;
- flex-direction: column;
- }
- }
- .backTop {
- position: fixed;
- bottom: 20vw;
- right: 5vw;
- text {
- font-size: 30px;
- background-color: #0000005f;
- border-radius: 90px;
- }
- }
- </style>
|