123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525 |
- <template>
- <view>
- <view class="tui-tabs">
- <scroll-view id="tab-bar" scroll-with-animation class="tui-scroll-h" :scroll-x="true"
- :show-scrollbar="false" style="border-bottom: 2upx solid #F8F8F8;">
- <view style="display: flex;">
- <view v-for="(tab, index) in tabBars" :id="tab.id" :data-current="index" @tap='tabSlect(tab)'>
- <view class="tui-tab-item-title" style="margin-left: 130upx;"
- :class="{ 'tui-tab-item-title-active': tabIndex == tab.id }">{{ tab.name }}</view>
- </view>
- </view>
- </scroll-view>
- </view>
- <view style="display: flex;flex-wrap: wrap;margin-top: 80upx;">
- <view
- style="width: 345upx;height: 550upx;background-color: #FFFFFF; border-radius: 20upx;margin:20upx 0 0upx 20upx; padding-bottom: 10upx; box-shadow: rgba(183, 183, 183, 0.3) 1px 1px 10px 1px;"
- @tap='goDetail(item.id)' v-for="(item,index) in list" :key='index' v-if="list.length > 0">
- <image :src="item.coverImg" lazy-load="true"
- style="width: 345upx;height: 340upx;border-top-left-radius:20upx;border-top-right-radius:20upx;">
- </image>
- <view style="padding: 16upx 2upx 16upx 16upx;">
- <view style="width: 100%;height: 60upx;">
- <text class="limapboxqing2"><text class="indexr"
- style=""><text>自营</text></text>{{ item.title }}</text>
- </view>
- </view>
- <view>
- <view style="padding: 0rpx 15rpx;display: flex;margin:60rpx 0">
- <view
- style="width: 40%;font-size: 38upx;color: #05C25C;font-weight: 700;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
- ¥{{item.price}}</view>
- <view
- style="width: 60%;font-size: 24upx;color: #999999;margin-top: 10upx;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;text-align: right;">
- {{item.sales}}人已购买</view>
- </view>
- </view>
- </view>
- <!-- 悬浮上拉 -->
- <view class="scroll_top" @tap="topScrollTap" v-bind:class="[scrollTop ? 'active' : '','']"
- style="bottom: 56px;">
- <text class="iconfont icon-shangla"></text>
- </view>
- <!-- 加载更多提示 -->
- <view class="s-col is-col-24" v-if="list.length > 0">
- <load-more :loadingType="loadingType" :contentText="contentText"></load-more>
- </view>
- <!-- 加载更多提示 -->
- <!-- <empty v-if="list.length === 0" des="暂无数据" show="false"></empty> -->
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- tabIndex: '0',
- tabStatus: 'createAt',
- list: [],
- relation: false,
- isEnable: '否',
- //综合createAt 销量sales 佣金比例commissionPrice 超低价price
- tabBars: [{
- name: '综合',
- id: '0',
- status: 'createAt'
- },
- {
- name: '销量',
- id: '1',
- status: 'sales'
- },
- // {
- // name: '佣金',
- // id: '2',
- // status: 'commissionPrice'
- // },
- {
- name: '超低价',
- id: '2',
- status: 'price'
- }
- ],
- page: 0,
- size: 10,
- loadingType: 0,
- type: 1,
- barTitleName: '',
- scrollTop: false,
- contentText: {
- contentdown: '上拉显示更多',
- contentrefresh: '正在加载...',
- contentnomore: '没有更多数据了'
- }
- }
- },
- onLoad(d) {
- let relation_id = this.$queue.getData('relation_id');
- if (relation_id && relation_id !== 'undefined') {
- this.relation = true;
- } else {
- this.relation = false;
- }
- if (d.name) {
- this.barTitleName = d.name;
- uni.setNavigationBarTitle({
- title: d.name
- })
- if (d.name === '精选好物') {
- this.getSelectGoods('', this.tabStatus);
- } else if (d.name === '热卖榜单') {
- this.getSellingList('', this.tabStatus);
- } else if (d.name === '每日上新') {
- this.getNews('', this.tabStatus);
- } else if (d.name === '推荐商品') {
- this.getmrsc('', this.tabStatus);
- }
- }
- },
- onShow() {
- let a = this.$queue.getData("isEnable")
- if (a === '是') {
- let b = this.$queue.getData('isLieBiaoEnable');
- if (b) {
- this.isEnable = b;
- } else {
- this.isEnable = a;
- }
- } else {
- this.isEnable = a;
- }
- },
- methods: {
- getmrsc(type, sort) {
- this.loadingType = 1;
- uni.showLoading({
- title: '加载中...'
- });
- this.$Request.getT('/app/goods/recommend?page=' + this.page + '&size=' + this.size + '&sort=' + sort).then(
- res => {
- if (res.status === 0) {
- if (this.page === 0 || res.status) {
- this.list = [];
- }
- let grade = this.$queue.getData('grade');
- res.data.content.forEach(d => {
- d.descrition = '';
- // if (d.commissionPrice != 0) {
- // if (grade) {
- // if (this.relation) {
- // d.descrition = ((parseFloat(d.memberPrice) * parseFloat(d
- // .commissionPrice)) * parseFloat(grade)).toFixed(
- // 2);
- // } else {
- // d.descrition = ((parseFloat(d.price) * parseFloat(d
- // .commissionPrice)) * parseFloat(grade)).toFixed(2);
- // }
- // } else {
- // if (this.relation) {
- // d.descrition = ((parseFloat(d.memberPrice) * parseFloat(d
- // .commissionPrice)) * parseFloat(this.$queue
- // .minMoney()))
- // .toFixed(2);
- // } else {
- // d.descrition = ((parseFloat(d.price) * parseFloat(d
- // .commissionPrice)) * parseFloat(this.$queue
- // .minMoney()))
- // .toFixed(2);
- // }
- // }
- // }
- d.sales = d.sales > 10000 ? (d.sales / 10000).toFixed(1) + '万' : d.sales;
- this.list.push(d);
- });
- if (res.data.content.length === this.size) {
- this.loadingType = 0;
- } else {
- this.loadingType = 3;
- }
- } else {
- this.loadingType = 2;
- }
- uni.hideLoading();
- if (type === 'Refresh') {
- uni.stopPullDownRefresh(); // 停止刷新
- }
- });
- },
- getNews(type, sort) {
- this.loadingType = 1;
- uni.showLoading({
- title: '加载中...'
- });
- this.$Request.getT('/app/goods/news?page=' + this.page + '&size=' + this.size + '&sort=' + sort).then(res => {
- if (res.status === 0) {
- if (this.page === 0 || res.status) {
- this.list = [];
- }
- let grade = this.$queue.getData('grade');
- res.data.content.forEach(d => {
- d.descrition = '';
- // if (d.commissionPrice != 0) {
- // if (grade) {
- // if (this.relation) {
- // d.descrition = ((parseFloat(d.memberPrice) * parseFloat(d
- // .commissionPrice)) * parseFloat(grade)).toFixed(
- // 2);
- // } else {
- // d.descrition = ((parseFloat(d.price) * parseFloat(d
- // .commissionPrice)) * parseFloat(grade)).toFixed(2);
- // }
- // } else {
- // if (this.relation) {
- // d.descrition = ((parseFloat(d.memberPrice) * parseFloat(d
- // .commissionPrice)) * parseFloat(this.$queue
- // .minMoney()))
- // .toFixed(2);
- // } else {
- // d.descrition = ((parseFloat(d.price) * parseFloat(d
- // .commissionPrice)) * parseFloat(this.$queue
- // .minMoney()))
- // .toFixed(2);
- // }
- // }
- // }
- this.list.push(d);
- });
- if (res.data.content.length === this.size) {
- this.loadingType = 0;
- } else {
- this.loadingType = 3;
- }
- } else {
- this.loadingType = 2;
- }
- uni.hideLoading();
- if (type === 'Refresh') {
- uni.stopPullDownRefresh(); // 停止刷新
- }
- });
- },
- getSelectGoods(type, sort) {
- this.loadingType = 1;
- uni.showLoading({
- title: '加载中...'
- });
- this.$Request.getT('/app/goods/selectGoods?page=' + this.page + '&size=' + this.size + '&sort=' + sort).then(
- res => {
- if (res.status === 0) {
- if (this.page === 0 || res.status) {
- this.list = [];
- }
- let grade = this.$queue.getData('grade');
- res.data.content.forEach(d => {
- d.descrition = '';
- // if (d.commissionPrice != 0) {
- // if (grade) {
- // if (this.relation) {
- // d.descrition = ((parseFloat(d.memberPrice) * parseFloat(d
- // .commissionPrice)) * parseFloat(grade)).toFixed(
- // 2);
- // } else {
- // d.descrition = ((parseFloat(d.price) * parseFloat(d
- // .commissionPrice)) * parseFloat(grade)).toFixed(2);
- // }
- // } else {
- // if (this.relation) {
- // d.descrition = ((parseFloat(d.memberPrice) * parseFloat(d
- // .commissionPrice)) * parseFloat(this.$queue
- // .minMoney()))
- // .toFixed(2);
- // } else {
- // d.descrition = ((parseFloat(d.price) * parseFloat(d
- // .commissionPrice)) * parseFloat(this.$queue
- // .minMoney()))
- // .toFixed(2);
- // }
- // }
- // }
- this.list.push(d);
- });
- if (res.data.content.length === this.size) {
- this.loadingType = 0;
- } else {
- this.loadingType = 3;
- }
- } else {
- this.loadingType = 2;
- }
- uni.hideLoading();
- if (type === 'Refresh') {
- uni.stopPullDownRefresh(); // 停止刷新
- }
- });
- },
- getSellingList(type, sort) {
- this.loadingType = 1;
- uni.showLoading({
- title: '加载中...'
- });
- this.$Request.getT('/app/goods/selling?page=' + this.page + '&size=' + this.size + '&sort=' + sort).then(
- res => {
- if (res.status === 0) {
- if (this.page === 0 || res.status) {
- this.list = [];
- }
- let grade = this.$queue.getData('grade');
- res.data.content.forEach(d => {
- d.descrition = '';
- // if (d.commissionPrice != 0) {
- // if (grade) {
- // if (this.relation) {
- // d.descrition = ((parseFloat(d.memberPrice) * parseFloat(d
- // .commissionPrice)) * parseFloat(grade)).toFixed(
- // 2);
- // } else {
- // d.descrition = ((parseFloat(d.price) * parseFloat(d
- // .commissionPrice)) * parseFloat(grade)).toFixed(2);
- // }
- // } else {
- // if (this.relation) {
- // d.descrition = ((parseFloat(d.memberPrice) * parseFloat(d
- // .commissionPrice)) * parseFloat(this.$queue
- // .minMoney()))
- // .toFixed(2);
- // } else {
- // d.descrition = ((parseFloat(d.price) * parseFloat(d
- // .commissionPrice)) * parseFloat(this.$queue
- // .minMoney()))
- // .toFixed(2);
- // }
- // }
- // }
- this.list.push(d);
- });
- if (res.data.content.length === this.size) {
- this.loadingType = 0;
- } else {
- this.loadingType = 3;
- }
- } else {
- this.loadingType = 2;
- }
- uni.hideLoading();
- if (type === 'Refresh') {
- uni.stopPullDownRefresh(); // 停止刷新
- }
- });
- },
- getList() {
- this.$Request.getT('/app/goods/list?page=' + this.page + '&size=' + this.size + '&status=' + 1).then(res => {
- if (res.status === 0) {
- if (this.page === 0 || res.status) {
- this.list = [];
- }
- res.data.content.forEach(d => {
- this.list.push(d);
- });
- }
- });
- },
- goDetail(id) {
- uni.navigateTo({
- url: './commoditydetail?ordersId=' + id
- });
- },
- tabSlect(item) {
- this.switchTab(item.id);
- },
- switchTab(index) {
- this.page = 0;
- this.tabIndex = index;
- this.tabStatus = this.tabBars[index].status;
- this.list = [];
- this.getList1('switch', this.tabStatus);
- },
- topScrollTap: function() {
- uni.pageScrollTo({
- scrollTop: 0,
- duration: 300
- });
- },
- getList1(type, sort) {
- if (this.barTitleName === '精选好物') {
- this.getSelectGoods(type, sort);
- } else if (this.barTitleName === '热卖榜单') {
- this.getSellingList(type, sort);
- } else if (this.barTitleName === '每日上新') {
- this.getNews(type, sort);
- } else if (this.barTitleName === '推荐商品') {
- this.getmrsc('', this.tabStatus);
- }
- }
- },
- onPageScroll: function(e) {
- this.scrollTop = e.scrollTop > 200;
- },
- onReachBottom: function() {
- this.page = this.page + 1;
- this.getList1('', this.tabStatus);
- },
- onPullDownRefresh: function() {
- this.page = 0;
- this.getList1('Refresh', this.tabStatus);
- }
- }
- </script>
- <style lang="less">
- @import '../../../../static/less/index.less';
- @import '../../../../static/css/index.css';
- page {
- background: #F8F8F8;
- }
- .limapboxqing2 {
- font-size: 28upx;
- color: #333333;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- }
- .indexr {
- color: #FFFFFF;
- background: #05C25C;
- font-size: 22upx;
- padding-left: 12upx;
- display: inline-block;
- padding-right: 13upx;
- border-radius: 8upx;
- margin-right: 8upx;
- padding-top: 4upx;
- padding-bottom: 2upx;
- }
- .tui-tabs {
- flex: 1;
- flex-direction: column;
- overflow: hidden;
- background-color: #fafafa;
- /* #ifdef MP-ALIPAY || MP-BAIDU */
- height: 100vh;
- /* #endif */
- }
- .tui-scroll-h {
- width: 750rpx;
- height: 80rpx;
- background-color: #ffffff;
- flex-direction: row;
- /* #ifndef H5 */
- position: fixed;
- top: 0;
- left: 0;
- z-index: 999;
- /* #endif */
- /* #ifndef APP-PLUS */
- white-space: nowrap;
- /* #endif */
- /* #ifdef H5 */
- position: fixed;
- top: 44px;
- left: 0;
- z-index: 999;
- /* #endif */
- }
- .tui-line-h {
- /* #ifdef APP-PLUS */
- height: 1rpx;
- background-color: #cccccc;
- /* #endif */
- position: relative;
- }
- /* #ifndef APP-PLUS*/
- .tui-line-h::after {
- content: '';
- position: absolute;
- border-bottom: 1rpx solid #cccccc;
- -webkit-transform: scaleY(0.5);
- transform: scaleY(0.5);
- bottom: 0;
- right: 0;
- left: 0;
- }
- /* #endif */
- .tui-tab-item {
- /* #ifndef APP-PLUS */
- display: flex;
- /* #endif */
- // flex-wrap: nowrap;
- // padding-left: 34rpx;
- // padding-right: 34rpx;
- }
- .tui-tab-item-title {
- color: #555;
- font-size: 30rpx;
- height: 80rpx;
- line-height: 80rpx;
- flex-wrap: nowrap;
- /* #ifndef APP-PLUS */
- white-space: nowrap;
- /* #endif */
- }
- .tui-tab-item-title-active {
- color: #05C25C;
- font-size: 32upx;
- font-weight: bold;
- border-bottom-width: 6upx;
- text-align: center;
- }
- </style>
|