123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546 |
- <template>
- <view class="container">
- <view class="top">
- <!-- <image class="top-bg" src="../../static/img/top-bg.png" mode=""></image> -->
- <view class="top-main flex">
- <view class="search-box flex" @click="clickSearch()">
- <image class="search" src="../../static/img/search-h.png" mode=""></image>
- <view class="search-font">输入关键词搜索</view>
- </view>
- </view>
- <swiper class="carousel" autoplay="true" duration="400" interval="5000" @change="swiperChange">
- <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"
- @click="bannerNavToUrl(item)">
- <image class="img" :src="item.pic" mode="scaleToFill" />
- </swiper-item>
- </swiper>
- </view>
- <view class="box">
- <view class="box-title">
- <view class="left flex">
- <view class="item" @click="changeList(0)" :class="{action:checked==0}">
- 艺绘发售
- </view>
- <view class="item margin-l-30" @click="changeList(1)" :class="{action:checked==1}">
- 盲盒发售
- </view>
- </view>
- </view>
- <view v-show="checked==0" class="box-content" v-for="(item,index) in dataList[0].list" @click="buy(item)">
- <view class="img">
- <image :src="item.image" mode=""></image>
- </view>
- <view class="content-title">
- <view class="title">
- {{item.store_name}}
- </view>
- <view>
- <view class="text">
- 艺绘官方 发行
- </view>
- <view class="text flex">
- <view class="flex">
- <view class="textStock border-radius-10 flex">
- <view class="tip">
- 限量
- </view>
- <view class="num">
- {{item.stock}}
- </view>
- </view>
- <view class="tip border-radius-10 margin-l-10">
- 限购{{item.buy_limit}}份
- </view>
- </view>
- <view class="money">
- ¥{{item.price}}
- </view>
- </view>
- </view>
- </view>
- </view>
- <u-loadmore v-show="checked==0" :status="dataList[0].list.loadType" />
- <view v-show="checked==1" class="box-content" v-for="(item,index) in dataList[1].list" @click="buyMh(item)">
- <view class="img">
- <image :src="item.pic" mode=""></image>
- </view>
- <view class="content-title">
- <view class="title">
- {{item.name}}
- </view>
- <view class="text">
- 艺绘官方 发行
- </view>
- <view class="text">
- ¥{{item.price}}
- </view>
- </view>
- </view>
- <u-loadmore v-show="checked==1" :status="dataList[1].list.loadType" />
- </view>
- </view>
- </template>
- <script>
- import {
- getProducts,
- mysteryList
- } from '@/api/product.js';
- import {
- loadIndexs
- } from '@/api/index.js'
- import {
- mapState,
- mapMutations
- } from 'vuex';
- export default {
- data() {
- return {
- checked: 0, //当前选中的出售对象
- isSc: 2,
- carouselList: [], //轮播列表
- dataList: [{
- list: [], //艺发售
- page: 1,
- limit: 1,
- loadType: 'loadmore',
- }, {
- list: [], //盲盒发售
- page: 1,
- limit: 1,
- loadType: 'loadmore',
- }]
- };
- },
- computed: {
- ...mapState(['loginInterceptor', 'baseURL']),
- ...mapState('user', ['hasLogin', 'userInfo'])
- },
- onLoad: function(option) {
- this.loadIndex()
- },
- onShow: function() {
- this.getProduct()
- },
- onReachBottom() {
- this.getProduct()
- },
- methods: {
- ...mapMutations(['setLat', 'setLon']),
- loadIndex() {
- let obj = this
- loadIndexs().then(res => {
- obj.carouselList = res.data.banner
- })
- },
- // 切换选中的需要显示的列表数据
- changeList(ind) {
- // 判断是否重复点击
- if (this.checked == ind) {
- return
- }
- this.checked = ind;
- this.getProduct()
- },
- // 更新数据
- getProduct() {
- let obj = this;
- let item = obj.dataList[obj.checked];
- if (item.loadType === 'loading') {
- //防止重复加载
- return;
- }
- if (item.loadType === 'nomore') {
- //防止重复加载
- return;
- }
- // 修改当前对象状态为加载中
- item.loadType = 'loading';
- // 判断是否为艺绘商品
- if (obj.checked == 0) {
- this.getBaseYh(item)
- }
- // 判断是否盲盒
- if (obj.checked == 1) {
- this.mysteryList(item)
- }
- },
- // 盲盒列表
- mysteryList(item) {
- mysteryList({
- page: item.page,
- limit: item.limit
- }).then(res => {
- let arr = res.data.list.map((e) => {
- return e
- })
- item.list = item.list.concat(arr);
- item.page++;
- if (item.limit == arr.length) {
- //判断是否还有数据, 有改为 more, 没有改为noMore
- item.loadType = 'loadmore';
- return;
- } else {
- //判断是否还有数据, 有改为 more, 没有改为noMore
- item.loadType = 'nomore';
- }
- })
- },
- // 获取艺商品
- getBaseYh(item) {
- getProducts({
- page: item.page,
- limit: item.limit
- }).then(res => {
- let arr = res.data.map((e) => {
- let time = new Date(e.sell_time * 1000);
- e.cmy_pay_time = time.getFullYear() + '年' + (time.getMonth() + 1) + '月' + time
- .getDate() + '日' + time.getHours() + '时' + time.getMinutes() + '分' + time
- .getSeconds() + '秒'
- return e
- })
- item.list = item.list.concat(arr);
- item.page++;
- if (item.limit == arr.length) {
- //判断是否还有数据, 有改为 more, 没有改为noMore
- item.loadType = 'loadmore';
- return;
- } else {
- //判断是否还有数据, 有改为 more, 没有改为noMore
- item.loadType = 'nomore';
- }
- })
- },
- // 普通商品
- buy(item) {
- console.log(item, 'res');
- uni.navigateTo({
- url: '/pages/product/product?id=' + item.id + '&isSc=' + this.isSc
- })
- },
- // 盲盒
- buyMh(item) {
- uni.navigateTo({
- url: '/pages/product/productMh?id=' + item.id
- })
- },
- navTo(url) {
- uni.switchTab({
- url
- })
- },
- // 點擊搜索框
- clickSearch() {
- uni.navigateTo({
- url: '/pages/product/search'
- });
- },
- swiperChange() {}
- }
- };
- </script>
- <style lang="scss">
- page {
- width: 750rpx;
- min-height: 100%;
- // background: #111111;
- }
- .carousel {
- width: 750rpx;
- height: 375rpx;
- .carousel-item {
- height: 100%;
- width: 100%;
- .img {
- height: 100%;
- width: 100%;
- }
- }
- }
- .top {
- position: relative;
- width: 100%;
- .top-bg {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- width: 100%;
- height: 100%;
- }
- .top-main {
- position: relative;
- z-index: 2;
- padding: 30rpx;
- .search-box {
- justify-content: flex-start;
- width: 698rpx;
- height: 60rpx;
- background: #1d1c21;
- border-radius: 10rpx;
- padding-left: 20rpx;
- .search {
- width: 34rpx;
- height: 34rpx;
- }
- .search-font {
- margin-left: 14rpx;
- font-size: 28rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #a4a4a4;
- }
- }
- }
- }
- .box {
- padding: 30rpx;
- .box-title {
- margin-top: 20rpx;
- display: flex;
- justify-content: space-between;
- margin-bottom: 50rpx;
- .left {
- font-size: 34rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #FFFFFF;
- .action {
- color: #FDD58A;
- }
- }
- .right {
- font-size: 24rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #FFFFFF;
- line-height: 120rpx;
- }
- }
- .box-content {
- margin-bottom: 50rpx;
- background-color: rgb(15, 15, 15);
- border-radius: 20rpx;
- overflow: hidden;
- .img {
- width: 690rpx;
- height: 690rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- .content-title {
- padding: 30rpx 20rpx;
- border-bottom-left-radius: 10rpx;
- border-bottom-right-radius: 10rpx;
- background-color: rgb(29, 28, 33);
- .title {
- font-size: 39rpx;
- font-weight: bold;
- color: #FFFFFF;
- margin-bottom: 20rpx;
- }
- .text {
- margin: 10rpx 0;
- color: #FFFFFF;
- font-size: 28rpx;
- flex-grow: 1;
- .textStock {
- overflow: hidden;
- }
- .num {
- font-size: 18rpx;
- padding: 10rpx;
- color: #9F570E;
- background-color: #4D3414;
- }
- .money{
- font-size: 40rpx;
- }
- .tip {
- font-size: 20rpx;
- color: #9F570E;
- padding: 10rpx;
- line-height: 1;
- background: $bgBaseBg;
- }
- }
- }
- }
- }
- .popup-box {
- width: 522rpx;
- height: 605rpx;
- background-color: #ffffff;
- border-radius: 20rpx;
- position: relative;
- .img {
- position: relative;
- top: -56rpx;
- left: 0;
- width: 522rpx;
- height: 132rpx;
- display: flex;
- justify-content: center;
- image {
- border-radius: 20rpx 20rpx 0 0;
- width: 450rpx;
- height: 132rpx;
- }
- }
- .mian {
- margin-top: -44rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- // padding: 32rpx 32rpx;
- background-color: #ffffff;
- border-radius: 0 0 20rpx 20rpx;
- text-align: center;
- .delivery {
- font-size: 40rpx;
- color: #333333;
- display: flex;
- align-items: center;
- flex-direction: column;
- .title {}
- image {
- margin-top: 48rpx;
- width: 172rpx;
- height: 160rpx;
- }
- }
- .nocancel {
- font-size: 32rpx;
- color: #333333;
- margin-top: 14rpx;
- }
- .comfirm-box {
- margin-top: 52rpx;
- display: flex;
- // margin-bottom: 32rpx;
- // justify-content: space-around;
- .cancel {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 197rpx;
- height: 74rpx;
- border: 1px solid #dcc786;
- border-radius: 38rpx;
- font-size: 32rpx;
- color: #605128;
- }
- .comfirm {
- margin-left: 32rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- width: 197rpx;
- height: 74rpx;
- background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
- border-radius: 38px;
- font-size: 32rpx;
- color: #605128;
- }
- }
- }
- }
- .tongz {
- width: 690rpx;
- height: 70rpx;
- margin: 32rpx 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%;
- }
- }
- }
- </style>
|