123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406 |
- <template>
- <view class="content">
- <swiper class="swiper-box" :current="current" autoplay circular>
- <swiper-item v-for="(item, index) in info" :key="index">
- <view :class="item.colorClass" class="swiper-item">
- <image class="image" :src="item.url" mode="aspectFill" :draggable="false" @click="onBanner(index)" />
- </view>
- </swiper-item>
- </swiper>
- <view class="back">
- <view class="sticky">
- <van-search class='top-search' shape="round" background="#fff" placeholder="请输入搜索关键词" />
- <view class="grid">
- <view class="grid-item" :class="{border:listType==0}" @click="listType=0">
- <van-icon name="/static/imgs/精选.png" size="30px" />
- <text class="text">精选</text>
- </view>
- <view class="grid-item" :class="{border:listType==item.id}" @click="listType=item.id" v-for="(item,index) in typeList"
- :key='index'>
- <van-icon :name="item.fileUrl || '/static/imgs/买车.png'" size="30px" />
- <text class="text">{{item.productName}}</text>
- </view>
- <view class="grid-item" :class="{border:listType==5}" @click="moreShow=!moreShow,typeMore()">
- <van-icon name="/static/imgs/出行.png" size="30px" />
- <text class="text">{{moreShow?'收起':'更多'}}</text>
- </view>
- </view>
- </view>
-
- <loadSke :loading='loading' :list='applist'>
- <view class='list-item' v-for="(item, index) in applist" :key="index" @click="goMiniApp(item)">
- <image class="avatar" mode="aspectFill" :src="item.appletLogoFileUrl || '/static/imgs/酒店.png'">
- <view class="item-right">
- <view class="top">
- <van-icon class="icon" v-if="item.collectionStatus=='0'" @tap.stop='addSc(index)' name="/static/imgs/收藏.png"
- size='15' />
- <van-icon class="icon" v-else name="/static/imgs/已收藏.png" @tap.stop='delSc(index)' size='15' />
- <van-icon class="icon" name="/static/imgs/转发.png" @tap.stop='showShare=true' size='14' />
- <!-- <van-icon class="icon" name="/static/imgs/不喜欢.png" size='12' /> -->
- </view>
- <view class="center">
- <text class="details">{{item.appletIntroduce || '该商家暂无描述,敬请期待!'}}</text>
- </view>
- <view class="bottom">
- <text class="title">{{item.corporateName}}</text>
- <view class="right" v-if="false">
- <view class="flex">
- <van-icon class="icon" name="/static/imgs/评论.png" size='15' />
- <text>54</text>
- </view>
- <view class="flex">
- <van-icon class="icon" name="/static/imgs/好评率.png" size='15' />
- <text>99%</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </loadSke>
- </view>
-
- <van-share-sheet :show="showShare" :options="options" @select="onSelect" @close='shareClose' />
- </view>
- </template>
- <script>
- import loadSke from '@/components/skeleton/index/index.vue'
- import {
- debounce
- } from '@/utils/utils.js'
- import {
- typeList,
- getTypeAppList,
- addFavorites,
- delFavorites,
- BrowseRecordAdd
- } from '@/api/applist.js'
- export default {
- components: {
- loadSke
- },
- data() {
- return {
- comname: 'xueche',
- active: 0,
- tabActive: 0,
- info: [{
- colorClass: 'uni-bg-red',
- url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg',
- content: '内容 A'
- },
- {
- colorClass: 'uni-bg-green',
- url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg',
- content: '内容 B'
- },
- {
- colorClass: 'uni-bg-blue',
- url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg',
- content: '内容 C'
- }
- ],
- current: 0,
- mode: 'round',
- applist: [],
- typeList: {},
- listType: 0,
- loading: true,
- showShare: false,
- moreShow: false,
- options: [{
- name: '微信',
- icon: 'wechat',
- openType: 'share'
- }],
- pageNum: 1,
- pageSize: 10
- }
- },
- mounted() {
- this.initAppList()
- },
- watch: {
- listType(val) {
- this.pageNum = 1
- this.loading = true
- getTypeAppList(val, {
- pageNum: this.pageNum,
- pageSize: this.pageSize
- }).then(res => {
- this.applist = res.rows
- this.$nextTick(() => {
- this.loading = false
- })
- })
- }
- },
- methods: {
- initAppList() {
- typeList({
- pid: 0
- }).then(res => {
- this.typeList = res.rows.slice(0, 8)
- })
- getTypeAppList(0, {
- pageNum: 1,
- pageSize: 10
- }).then(res => {
- this.applist = res.rows
- this.$nextTick(() => {
- this.loading = false
- })
- })
- },
- onBottom() {
- this.pageNum++
- getTypeAppList(this.listType, {
- pageNum: this.pageNum,
- pageSize: this.pageSize
- }).then(res => {
- this.applist = this.applist.concat(res.rows)
- })
- },
- typeMore() {
- if (this.moreShow) {
- typeList({
- pid: 0
- }).then(res => {
- this.typeList = res.rows
- })
- } else {
- this.typeList = this.typeList.slice(0, 8)
- }
- },
- addSc(index) {
- addFavorites(this.applist[index].id).then(res => {
- if (res.code == 200) {
- this.$set(this.applist[index], 'collectionStatus', '1')
- this.Toast('收藏成功!');
- }
- })
- },
- delSc(index) {
- delFavorites(this.applist[index].id).then(res => {
- if (res.code == 200) {
- this.$set(this.applist[index], 'collectionStatus', '0')
- this.Toast('取消收藏成功!');
- }
- })
- },
- shareClose() {
- this.showShare = false;
- },
- onSelect(event) {
- this.Toast(event.detail.name);
- this.onClose();
- },
- getAppList() {
- featuredAppList({
- pageNum: 1,
- pageSize: 10
- }).then(res => {
- console.log(res)
- this.applist = res.rows
- this.$nextTick(() => {
- this.loading = false
- })
- })
- },
- goMiniApp(item) {
- wx.navigateToMiniProgram({
- appId: item.appletAddress,
- success: (res) => {
- // 打开成功
- console.log('打开成功', item)
- BrowseRecordAdd(item.id)
- }
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .back{}
- .content {
- padding-bottom: 1rpx;
- }
- .swiper-box {
- position: sticky;
- top: 0px;
- left: 0;
- height: 422rpx;
- z-index: 9;
- }
- .sticky-top {
- position: sticky;
- top: 56vw;
- left: 0;
- // margin: 30rpx 30rpx;
- // border-radius: 20rpx;
- overflow: hidden;
- background-color: #4fc08d;
- z-index: 10;
- display: flex;
- justify-content: center;
- align-items: center;
- .top-search {
- flex: 1;
- }
- }
- .sticky {
- position: sticky;
- top: 100rpx;
- left: 0;
- background-color: #fff;
- z-index: 9;
- .grid {
- display: flex;
- flex-wrap: wrap;
- justify-content: flex-start;
- overflow: auto;
- .grid-item {
- flex-shrink: 0;
- width: 20%;
- height: 130rpx;
- display: flex;
- justify-content: center;
- flex-direction: column;
- align-items: center;
- text-align: center;
- font-size: 34rpx;
- padding: 10rpx;
- box-sizing: border-box;
- position: relative;
- .text {
- font-size: .8em;
- margin-top: 5rpx;
- color: #999999;
- font-weight: 400;
- }
- }
- .border::after {
- content: '';
- position: absolute;
- bottom: -5rpx;
- width: 30rpx;
- height: 5rpx;
- background-color: red;
- }
- }
- }
- .list-item {
- display: flex;
- align-items: center;
- justify-content: space-between;
- background-color: #FFFFFF;
- height: 170rpx;
- padding: 34rpx 20rpx;
- margin: 24rpx 30rpx;
- border-radius: 20rpx;
- .avatar {
- flex-shrink: 0;
- width: 161rpx;
- height: 161rpx;
- margin-right: 16rpx;
- }
- .item-right {
- flex: 1;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- height: 200rpx;
- .top {
- .icon {
- margin-top: -20rpx;
- padding: 20rpx;
- }
- display: flex;
- justify-content: flex-end;
- }
- .center {
- align-self: flex-start;
- .details {
- width: 436rpx;
- height: 70rpx;
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: 400;
- color: #0F0404;
- display: -webkit-box;
- margin-bottom: 20rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- word-wrap: break-word;
- white-space: normal !important;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- }
- }
- .bottom {
- display: flex;
- justify-content: space-between;
- align-items: center;
- .title {
- padding: 3rpx 12rpx;
- height: 30rpx;
- background: #FFE6E6;
- border: 1rpx solid #E31818;
- border-radius: 2rpx;
- font-size: 20rpx;
- font-family: PingFang SC;
- font-weight: 400;
- color: #E31818;
- line-height: 20rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .right {
- width: 170rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- font-size: 22rpx;
- font-family: PingFang SC;
- font-weight: 400;
- color: #999999;
- line-height: 35rpx;
- .flex {
- display: flex;
- justify-content: center;
- .icon {
- margin-right: 5rpx;
- }
- }
- }
- }
- }
- }
- </style>
|