123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645 |
- <template>
- <view class="core">
- <!-- nav -->
- <u-navbar leftIconSize="0" :placeholder="true" bgColor="#ffffff">
- <view class="u-nav-slot" slot="left">
- <view class="u-nav-slot__input flex">
- <u--input v-model="goodsTitle" @confirm="toGoodsList()" confirmType="search" placeholder="搜索商品" border="none" prefixIcon="search" prefixIconStyle="font-size: 22px;color: #909399" />
- <!-- <view class="u-nav-slot__input__btn" @click="toGoodsList()">搜索</view> -->
- </view>
- </view>
- </u-navbar>
- <!-- 固定顶部搜索、分类 -->
- <view class="fixed-top">
- <view class="fixed-top-classify">
- <u-tabs @change="changeClassify" :scrollable="true" :list="classifyList" lineWidth="20" lineHeight="2"
- lineColor="#FF8D0B" :activeStyle="{
- color: '#333',
- transform: 'scale(1.1)'
- }" :inactiveStyle="{
- color: '#999',
- transform: 'scale(1.1)'
- }" itemStyle="padding-left: 15px; padding-right: 15px; height: 44px; text-align: center;">
- </u-tabs>
- </view>
- </view>
- <view class="core-none"></view>
-
- <!-- 轮播 -->
- <view class="core-swiper" v-if="swiperList.length">
- <swiper class="core-swiper-centent" circular :indicator-dots="true" :autoplay="true" :interval="3000" indicator-active-color="#fff">
- <swiper-item class="swiper-item" v-for="(item, index) in swiperList" :key="index" @click="toPage(item)">
- <image :src="item.picUrl" mode=""></image>
- </swiper-item>
- </swiper>
- </view>
-
- <!-- 二级分类 -->
- <view class="core-category">
- <swiper class="core-category-swiper" :autoplay="false">
- <swiper-item class="swiper-item" v-for="(item, index) in classifyIndex == 0 ? classifyListFilter : classifyList[classifyIndex].list" :key="index">
- <view class="swiper-item__content" v-for="(items, indexs) in item" :key="indexs">
- <image :src="items.picUrl" mode="aspectFit" @click="toCategoryGoods(index, indexs)"></image>
- <view class="name">{{ items.name }}</view>
- </view>
- </swiper-item>
- </swiper>
- </view>
-
- <!-- 标签商品 -->
- <view class="tag-goods" v-for="(item, index) in exclusiveSingle" :key="index">
- <image class="tag-goods-imgBg" src="../../static/core/core_bg.png" mode=""></image>
- <view class="tag-goods-content">
- <view class="tag-goods-content-nav flex">
- <view class="tag-goods-content-nav__left flex">
- <image src="../../static/core/core_tag.png" mode=""></image>
- <view class="title">{{ item.name }}</view>
- <image src="../../static/core/core_tag.png" mode=""></image>
- </view>
- <view class="tag-goods-content-nav__right flex" @click="toTagGoods(item)">
- <view class="title">更多</view>
- <image src="../../static/core/core_right.png" mode=""></image>
- </view>
- </view>
-
- <view class="tag-goods-content-list">
- <view class="tag-goods-content-list-item flex" v-for="(items, indexs) in item.data" :key="indexs" @click="toGoodsDetail(items)">
- <view class="image flex">
- <image :src="items.picUrl" mode="aspectFit"></image>
- </view>
- <view class="title">{{ items.exchangePrice }}盲豆</view>
- </view>
- </view>
- </view>
- </view>
-
- <!-- 商品列表 -->
- <view class="core-goods">
- <view class="core-goods-list flex">
- <view class="core-goods-list-item flex" v-for="(item, index) in list" :key="index" @click="toGoodsDetail(item)">
- <view class="image-wrap flex">
- <image :src="item.picUrl" mode="aspectFit"></image>
- </view>
- <view class="content">
- <view class="content-title ells-one">{{ item.title }}</view>
- <view class="content-coin flex">
- <view class="content-coin__left flex">
- <image src="../../static/public/goods_coin.png" mode=""></image>
- <view class="num"><text>×</text>{{ item.exchangePrice }}</view>
- </view>
- <view class="content-coin__right" v-if="item.originPrice">{{ item.originPrice }}</view>
- </view>
- <view class="content-price">¥{{ $numberFormat(item.value) }}</view>
- </view>
- </view>
- <view class="core-goods-list-item"></view>
- </view>
- </view>
-
- <custom-tab-bar :activeValue="'core'" />
- </view>
- </template>
- <script>
- import env from '../../config/env.js'
- import $http from '@/utils/request.js'
- import CustomTabBar from '../../components/custom-tab-bar/custom-tab-bar.vue'
- export default {
- components: {
- CustomTabBar,
- },
- data() {
- return {
- imgTop: [],
- goods: [],
- exclusive: [],
- exclusiveSingle: [],
- pageNum: 1,
- total: 0,
- list: [],
-
- /////////
- classifyList: [], // 分类列表
- classifyIndex: 0, // 分类选中下标
- classifyListFilter: [],
- swiperList: [], // 轮播图
- goodsTitle: '',
- };
- },
- onLoad() {
- this.pageList()
- this.getExclusive()
- this.getClassify()
- this.getSwiper()
- },
- methods: {
- pageList() {
- this.pageNum = 1
- this.total = 0
- this.list = []
- this.getList()
- },
-
- // 获取分类
- getClassify() {
- $http.post('/api/v1/mp/user/exchange/category/listTree', {}).then(res => {
- if(res.code == 0){
- let interval = 10
- this.classifyList = res && res.rows
- this.classifyList.forEach(item => {
- item.picUrl = env.filePublic + item.picUrl.split(',')[0] + '?imageView2/2/w/340'
- item.goodsCategoryList.forEach(ele => {
- ele.picUrl = env.filePublic + ele.picUrl.split(',')[0] + '?imageView2/2/w/340'
- })
- item.list = []
- if(item.goodsCategoryList.length > interval) {
- let num = Math.ceil(item.goodsCategoryList.length / interval)
- let arr = []
-
- let a = 0
- let stop = interval
- for(let i = 1; i <= num; i++) {
- arr = item.goodsCategoryList.slice(a, stop)
- a = i * interval
- stop = stop + interval
-
- }
- } else {
- item.list.push(item.goodsCategoryList)
- }
- })
- if(this.classifyList.length > interval) {
- let num = Math.ceil(this.classifyList.length / interval)
- let arr = []
-
- let a = 0
- let stop = interval
- for(let i = 1; i <= num; i++) {
- arr = this.classifyList.slice(a, stop)
- a = i * interval
- stop = stop + interval
- this.classifyListFilter.push(arr)
- }
- } else {
- this.classifyListFilter =[ [ ...this.classifyList ] ]
- }
- this.classifyList.unshift({ name: '全部' })
-
- }
- })
- },
-
- //轮播图
- getSwiper() {
- $http.post(`/api/v1/mp/user/exchange/banner/list`, {
- noToken: true,
- location: "top"
- }).then(res => {
- res.data.forEach(item => item.picUrl = env.filePublic + item.picUrl.split(',')[0])
- this.swiperList = res.data
- })
- },
-
- // 标签商品
- async getExclusive() {
- let resData = await $http.post(`/api/v1/mp/user/exchange/activity/list`, {
- noToken: true
- })
- let goodsList = []
- for (let item of resData.data) {
-
- let resDatas = await $http.post(`/api/v1/mp/user/exchange/goods/list?pageNum=1&pageSize=10`, {
- noToken: true,
- tagIds: item.tagId
- })
- goodsList.push({
- data: resDatas.rows,
- name: item.name,
- tagId: item.tagId
- })
- }
- goodsList.forEach(item => {
- item.data.forEach(items => {
- items.picUrl = env.filePublic + items.picUrl.split(',')[0] + '?imageView2/2/w/340'
- })
- })
- this.exclusiveSingle = goodsList
- },
-
- // 商品列表
- getList() {
- uni.showLoading({
- title: '加载中'
- });
- let data = {
- categoryId: this.categoryId,
- tagIds: this.tagIds,
- ...this.coinNum,
- noToken: true
- }
- $http.post(`/api/v1/mp/user/exchange/goods/list?pageNum=${this.pageNum}&pageSize=20`,data).then(
- res => {
- uni.hideLoading();
- if (res.code == 0) {
- res.rows.forEach(item => {
- let picUrlArr = item.picUrl.split(',')
- item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/340'
- })
-
- this.total = res.total
- this.list = this.list.concat(res.rows)
- }
- }).catch(() => {
- uni.hideLoading();
- })
- },
-
- // 切换分类
- changeClassify(e) {
- this.classifyIndex = e.index
- },
- // 跳转点击事件
- toPage(item) {
- if (item.type == "link") {
- uni.navigateTo({
- url: `/packageOperate/webview/index?url=${ item.linkUrl }`,
- })
- } else if (item.type == "tag") {
- uni.navigateTo({
- url: `/packageGoods/goods/list?name=${ item.name }&tagIds=${ item.goodsTags ? item.goodsTags : '' }`
- })
- }
- },
- // 商品详情
- toGoodsDetail(item) {
- uni.navigateTo({
- url: `/packageGoods/goods/detail?id=${ item.goodsId }`
- })
- },
-
- // 商品列表
- toGoodsList() {
- uni.navigateTo({
- url: `/packageGoods/goods/list?title=${ this.goodsTitle }`
- })
- },
-
- // 商品标签
- toTagGoods(item) {
- uni.navigateTo({
- url: `/packageGoods/goods/list?name=${ item.name }&tagIds=${ item.tagId ? item.tagId : '' }`
- })
- },
-
- // 商品分类
- toCategoryGoods(index, indexs) {
- let list = this.classifyIndex == 0 ? this.classifyListFilter : this.classifyList[this.classifyIndex].list
- let item = list[index][indexs]
- uni.navigateTo({
- url: `/packageGoods/goods/list?name=${ item.name }&categoryId=${ item.categoryId ? item.categoryId : '' }`
- })
- },
- },
- onReachBottom() {
- // 判断是否有数据
- if (this.total > this.pageNum * 20) {
- setTimeout(() => {
- ++this.pageNum
- this.getList()
- }, 500)
- } else {
- uni.$u.toast('已经到底了')
- }
- },
- onShareAppMessage(res) {
- return {
- title: '盲票,玩的就是有趣',
- path: '/pages/index/index',
- // imageUrl:'../../static/icon/lucky_bg.png',
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .core {
- background-color: #fff;
-
- &-none {
- height: 120rpx;
- }
- }
-
- // 搜索
- .u-nav-slot {
- text {
- font-size: 32rpx;
- }
-
- &__input {
- position: relative;
- height: 70rpx;
- width: 518rpx;
- padding-left: 30rpx;
- background: #F4F5F6;
- border-radius: 35rpx;
-
- &__btn {
- z-index: 200;
- width: 140rpx;
- height: 70rpx;
- line-height: 70rpx;
- font-size: 30rpx;
- text-align: center;
- font-weight: bold;
- color: #fff;
- background-color: #FF8D0B;
- border-radius: 35rpx;
- }
- }
- }
-
- // 固定搜索、分类
- .fixed-top {
- position: fixed;
- z-index: 100;
- width: 100%;
- background-color: #fff;
-
- // 搜索
- &-search {
- justify-content: space-between;
- padding: 14rpx 30rpx 34rpx;
-
- &__input {
- position: relative;
- flex: 1;
- height: 84rpx;
- padding-left: 46rpx;
- background: #F4F5F6;
- border-radius: 20rpx;
-
- &__btn {
- position: absolute;
- right: 0;
- width: 110rpx;
- height: 76rpx;
- line-height: 76rpx;
- font-size: 34rpx;
- text-align: center;
- font-weight: bold;
- color: #FFC062;
- background-color: #333333;
- border-radius: 18rpx;
- }
- }
-
- image {
- width: 52rpx;
- height: 52rpx;
- margin-left: 50rpx;
- }
- }
-
- // 分类
- &-classify {
- padding-bottom: 20rpx;
- }
- }
-
- // 轮播
- .core-swiper {
- margin: 0 34rpx 20rpx;
- border-radius: 16rpx;
-
- &-centent {
- height: 300rpx;
-
- .swiper-item {
- width: 100%;
- height: 100%;
-
- image {
- width: 100%;
- height: 100%;
- border-radius: 16rpx;
- }
- }
- }
- }
-
- // 二级分类
- .core-category {
- width: 100%;
- height: 360rpx;
- margin-bottom: 34rpx;
- padding: 0 34rpx;
-
- &-swiper {
-
- width: 100%;
- height: 100%;
-
- .swiper-item {
- width: 100%;
- height: 100%;
- display: flex;
- flex-wrap: wrap;
-
- &__content {
- display: flex;
- align-items: center;
- flex-direction: column;
- justify-content: space-between;
- width: 20%;
- height: 50%;
-
- image {
- width: 90%;
- height: 70%;
- }
- }
- }
- }
- }
-
- // 标签商品
- .tag-goods {
- display: flex;
- align-items: center;
- position: relative;
- margin: 0 34rpx 34rpx;
- height: 350rpx;
-
- &-imgBg {
- position: absolute;
- top: 0;
- width: 100%;
- height: 350rpx;
- }
-
- &-content {
- width: 100%;
- position: absolute;
- top: 0;
- z-index: 5;
- padding: 26rpx 22rpx;
-
- &-nav {
- justify-content: space-between;
- height: 40rpx;
- margin-bottom: 10rpx;
-
- &__left {
- image {
- width: 40rpx;
- height: 30rpx;
- }
-
- .title {
- font-family: YouSheBiaoTiHei;
- font-weight: 400;
- font-size: 40rpx;
- color: #FFFFFF;
- padding: 0 36rpx;
- }
- }
-
- &__right {
- .title {
- font-family: YouSheBiaoTiHei;
- font-weight: 400;
- color: #FFFFFF;
- margin-right: 12rpx;
- }
-
- image {
- width: 22rpx;
- height: 20rpx;
- }
- }
- }
-
- &-list {
- display: flex;
- height: 260rpx;
- overflow-x: auto;
-
- &-item {
- flex-direction: column;
- margin-right: 14rpx;
-
- .image {
- width: 180rpx;
- height: 180rpx;
- background: #FFFFFF;
- box-shadow: 0px 0px 4px 0px rgba(100, 100, 100, 0.13);
- border-radius: 4rpx;
- margin-bottom: 24rpx;
-
- image {
- width: 100%;
- height: 100%;
- }
- }
-
- .title {
- text-align: center;
- line-height: 28rpx;
- color: #FFFFFF;
- }
- }
- }
- }
- }
-
- // 商品列表
- .core-goods {
- padding: 0 34rpx;
-
- &-list {
- width: 100%;
- justify-content: space-between;
- flex-wrap: wrap;
-
- &-item {
- flex-direction: column;
- justify-content: flex-start;
- width: 48%;
- padding-bottom: 32rpx;
- background: #FFFFFF;
- box-shadow: 0px 0px 3px 0px rgba(100, 100, 100, 0.1);
- border-radius: 16rpx;
- margin-bottom: 30rpx;
-
- .image-wrap {
- width: 100%;
- height: 320rpx;
- margin-bottom: 16rpx;
-
- image {
- width: 100%;
- height: 100%;
- border-radius: 16rpx 16rpx 0 0;
- }
- }
-
- .content {
- width: 100%;
- padding: 0 22rpx;
-
- &-title {
- height: 28rpx;
- font-size: 28rpx;
- line-height: 28rpx;
- font-weight: bold;
- margin-bottom: 30rpx;
- }
-
- &-coin {
- height: 30rpx;
-
- font-size: 24rpx;
- justify-content: space-between;
- margin-bottom: 24rpx;
-
- &__left {
- margin-right: 24rpx;
- font-size: 28rpx;
- font-weight: bold;
-
- text {
- font-weight: normal;
- }
-
- image {
- width: 34rpx;
- height: 30rpx;
- }
- }
-
- &__right {
- color: #666666;
- text-decoration: line-through;
- }
- }
-
- &-price {
- font-size: 24rpx;
- line-height: 24rpx;
- color: #666666;
- }
- }
- }
-
- &-item:last-child {
- box-shadow: none;
- }
- }
- }
- </style>
- <style lang="scss" scoped>
-
- </style>
|