123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- <template>
- <view>
- <view class="search">
- <view style="margin: 10rpx 20rpx;margin-top: 20rpx;">
- <u-search placeholder="请输入商品名称" inputAlign="center" bgColor="#fff" shape="square" v-model="search.cname"
- @search="searchButton" @custom="searchButton" :animation="true"></u-search>
- </view>
- <view style="margin: -15rpx auto 10rpx auto;display: flex;padding: 0 20rpx;z-index: 999;" v-if="show == true">
- <u-tag :text="search.brandNmae" borderColor="#FD4B09" color="#FD4B09" plain size="medium" closable
- :show="show" @close="close" @click="close"></u-tag>
- </view>
- </view>
- <view :style="{marginTop:show == true?'164rpx':'108rpx'}">
- <u-swiper :list="list3" indicator indicatorMode="dot" circular></u-swiper>
- </view>
- <view style="background-color: #fff;margin-bottom: 20rpx;">
- <view style="padding: 20rpx 0 0 0;">
- <u-grid :border="false" @click="click" col="5">
- <u-grid-item v-for="(item,index) in brandList" :key="index">
- <view v-if="item.brandFilesList.length>0" style="text-align: center;">
- <view v-for="(li,i) in item.brandFilesList" :key="i" :src="li.url">
- <image :src="li.url" style="width: 80rpx;height: 80rpx;"></image>
- <view style="font-size: 28rpx;">{{item.cname}}</view>
- </view>
- </view>
- <view v-else style="text-align: center;">
- <u-icon :customStyle="{paddingBottom:8+'rpx'}" labelPos="bottom" name="error-circle"
- :size="40"></u-icon>
- <view style="font-size: 28rpx;">{{item.cname}}</view>
- </view>
- </u-grid-item>
- </u-grid>
- </view>
- <view style="padding: 20rpx 20rpx;">
- <u-divider text="爆品推荐"></u-divider>
- </view>
- </view>
- <view style="margin-top: 0rpx;" class="content">
- <view class="left">
- <block v-for="(item,index) in dataList" :key="index" v-if="index%2==0">
- <view class="item" @click="choice(item,index)">
- <image v-for="(ite,ind) in item.filesList" :key="ind" v-if="ite.version === '0'" :src="ite.url"
- style="width: 100%;height: 340rpx;border-top-left-radius: 20rpx;border-top-right-radius: 20rpx;">
- </image>
- <view style="width: calc(100% - 20rpx);margin: 0 auto;">
- <u--text :text="item.cname" size="12"></u--text>
- <view style="display: flex;justify-content: space-between;margin: 5rpx auto;">
- <view style="padding-top: 12rpx;">
- <view v-if="item.billType == 0"
- style="font-size: 16rpx;background-color: #FD4B09;color: #fff;padding: 6rpx;border-radius: 6rpx;">
- 今日达</view>
- <view v-else
- style="font-size: 16rpx;background-color: #5ac725;color: #fff;padding: 6rpx;border-radius: 6rpx;">
- 次日达</view>
- </view>
- <view style="color: #FD4B09;font-size: 40rpx;">¥{{item.mallPrice}}</view>
- </view>
- </view>
- </view>
- </block>
- </view>
- <view class="right">
- <block v-for="(item,index) in dataList" :key="index" v-if="index%2==1">
- <view class="item" @click="choice(item,index)">
- <image v-for="(ite,ind) in item.filesList" :key="ind" v-if="ite.version === '0'" :src="ite.url"
- style="width: 100%;height: 340rpx;border-top-left-radius: 20rpx;border-top-right-radius: 20rpx;">
- </image>
- <view style="width: calc(100% - 20rpx);margin: 0 auto;">
- <u--text :text="item.cname" size="12"></u--text>
- <view style="display: flex;justify-content: space-between;margin: 5rpx auto;">
- <view style="padding-top: 12rpx;">
- <view v-if="item.billType == 0"
- style="font-size: 16rpx;background-color: #FD4B09;color: #fff;padding: 6rpx;border-radius: 6rpx;">
- 今日达</view>
- <view v-else
- style="font-size: 16rpx;background-color: #5ac725;color: #fff;padding: 6rpx;border-radius: 6rpx;">
- 次日达</view>
- </view>
- <view style="color: #FD4B09;font-size: 40rpx;">¥{{item.mallPrice}}</view>
- </view>
- </view>
- </view>
- </block>
- </view>
- </view>
- <u-empty v-if="dataList.length == 0" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" />
- <u-loadmore v-if="page.total !== 0 && dataList.length != 0" :status="status" />
- </view>
- </template>
- <script>
- import {
- appList,
- userDept,
- validationCorpEmpty
- } from '@/api/tabBar/home.js'
- import {
- listAll
- } from '@/api/tabBar/classification.js'
- export default {
- data() {
- return {
- show:false,
- search: {},
- page: {
- total: 0,
- size: 10,
- current: 1
- },
- status: 'loadmore',
- dataList: [],
- list3: [
- 'https://td.echepei.com/file/applets/temporary/images/swiper1.jpg',
- 'https://td.echepei.com/file/applets/temporary/images/swiper2.jpg',
- 'https://td.echepei.com/file/applets/temporary/images/swiper3.jpg'
- ],
- brandList: []
- }
- },
- onReachBottom() {
- this.status = 'loading'
- if (this.dataList.length < this.page.total) {
- this.page.current++
- this.onSearch()
- } else {
- this.status = 'nomore'
- }
- },
- onShow() {
- uni.showLoading({
- title: '加载中',
- mask: true
- });
- validationCorpEmpty().then(res => {
- uni.hideLoading();
- //获取公司名称
- userDept().then(res => {
- uni.setNavigationBarTitle({
- title: res.data.fullName
- })
- })
- //获取所有品牌
- listAll().then(res => {
- this.brandList = res.data
- })
- this.page = {
- total: 0,
- size: 10,
- current: 1
- }
- this.dataList = []
- this.onSearch()
- }).catch(err => {
- uni.hideLoading();
- uni.$u.route('/pages/views/personalInformation/index');
- })
- },
- methods: {
- onSearch() {
- uni.showLoading({
- title: '加载中',
- mask: true
- });
- appList({
- size: this.page.size,
- current: this.page.current,
- ...this.search
- }).then(res => {
- this.dataList = this.dataList.concat(res.data.records)
- this.page.total = res.data.total
- if (this.dataList.length == res.data.total) {
- this.status = 'nomore'
- }
- uni.hideLoading();
- }).catch(err => {
- uni.hideLoading();
- })
- },
- close(){
- this.show = false
- this.search.brandId = ''
- this.search.brandName = ''
- },
- click(name) {
- this.page = {
- total: 0,
- size: 10,
- current: 1
- }
- this.dataList = []
- this.search = {
- ...this.search,
- brandId: this.brandList[name].id,
- brandNmae: this.brandList[name].cname,
- }
- this.show = true
- this.onSearch()
- },
- searchButton(value) {
- this.dataList = []
- this.page = {
- total: 0,
- size: 10,
- current: 1
- }
- this.search = {
- ...this.search,
- cname: value,
- }
- this.onSearch()
- },
- //打开明细
- choice(item, index) {
- uni.$u.route('/pages/views/buyGoods/commodityDetails', {
- id: item.id
- });
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- ::v-deep .u-divider {
- margin: 0 !important;
- }
- .content {
- text-align: justify;
- }
- .left,
- .right {
- display: inline-block;
- vertical-align: top;
- width: 50%;
- }
- .item {
- width: calc(100% - 20rpx);
- margin: 0 auto;
- background-color: #FFFFFF;
- border-radius: 10rpx;
- break-inside: avoid;
- margin-bottom: 20rpx;
- }
- .search {
- width: 100%;
- position: fixed;
- top: 0;
- z-index: 8;
- background-color: #f2f2f2;
- }
- </style>
|