commit message

This commit is contained in:
Chopper
2021-05-13 11:03:32 +08:00
commit 23804939eb
2158 changed files with 149684 additions and 0 deletions

View File

@@ -0,0 +1,155 @@
<template>
<view class="wrapper">
<u-navbar :border-bottom="false" :background="background" class="unavbar" :title="title">
<!-- 中间 -->
<view class="slot-wrap container-wrap">
<view v-if="search">
<u-search @search="searchFun()" @custom="searchFun()" v-model="params.goodsName"></u-search>
</view>
</view>
<!-- 右侧 -->
<view slot="right">
<view style="margin-right: 24rpx;" @click="searchFlag()">
<view v-if="search">取消</view>
<u-icon v-if="!search" size="44rpx" name="search"></u-icon>
</view>
</view>
</u-navbar>
<!-- 顶部栏 -->
<!-- 商品栏 -->
<div class="swiper">
<view class="view-item" v-for="(groupItem, groupIndex) in groupBuy" :key="groupIndex">
<view class="view-left">
<u-image border-radius="10" shape="square" :src="groupItem.goodsImage" width="186rpx" height="186rpx">
<view slot="error" style="font-size: 24rpx;">加载失败</view>
</u-image>
</view>
<view class="view-content">
<view class="view-content-name">
{{ groupItem.goodsName }}
</view>
<view class="view-content-bottom">
<view>
<view class="view-content-price">
<!-- {{groupItem.sales_price | unitPrice }} <span v-if="groupItem.point">+{{groupItem.point}}积分</span> -->
{{groupItem.price | unitPrice }}
</view>
<view class="view-content-original_price">
{{ groupItem.originPrice | unitPrice }}
</view>
</view>
<view>
<view class="btn-group" @click="toHref(groupItem)"> 去拼团 </view>
<view class="buy-content">已售{{groupItem.num || 0}}</view>
</view>
</view>
</view>
</view>
<u-loadmore bg-color='#f8f8f8' :status="status" />
</div>
</view>
</template>
<script>
import * as API_Promotions from "@/api/promotions";
import * as API_Goods from "@/api/goods";
export default {
components: {},
data() {
return {
status: "loadmore",
is_empty: false,
search: false,
title: "拼团活动",
background: {
backgroundColor: "#fff",
},
empty: false,
params: {
pageNumber: 1,
pageSize: 10,
categoryPath: "",
goodsName: "",
},
groupBuy: [],
};
},
mounted() {},
watch: {
search(val) {
val ? (this.title = "") : (this.title = "拼团活动");
},
},
onReachBottom(){
this.loadMore()
},
// 点击搜索按钮
onNavigationBarButtonTap(e) {
this.popupFlag = !this.popupFlag;
},
async onLoad() {
this.GET_AssembleGoods();
},
methods: {
loadMore() {
this.params.pageNumber++;
this.GET_AssembleGoods();
},
searchFlag() {
this.search = !this.search;
},
toHref(goods) {
uni.navigateTo({
url: `/pages/product/goods?id=${goods.skuId}&goodsId=${goods.goodsId}`,
});
},
searchFun() {
this.groupBuy = [];
this.GET_AssembleGoods();
},
// 请求拼团数据
GET_AssembleGoods() {
this.status = "loading";
const params = JSON.parse(JSON.stringify(this.params));
if (params.category_id === 0) delete params.category_id;
API_Promotions.getAssembleList(params)
.then((response) => {
const data = response.data.result.records;
if (!data || !data.length) {
this.is_empty = true;
this.status = "nomore";
} else {
if (data.length <= this.params.pageSize) {
this.status = "nomore";
} else {
this.status = "loadmore";
}
this.is_empty = false;
this.groupBuy.push(...(data || []));
}
})
.catch(() => {});
},
},
};
</script>
<style lang="scss" scoped>
@import "./style.scss";
</style>

View File

@@ -0,0 +1,617 @@
<template>
<view class="recommend" :style="styleWay">
<view class="status_bar">
<!-- 这里是状态栏 -->
</view>
<view class="prohibition" style="overscroll-behavior: unset;">
<view class="header" :style="'height:' + header.height + 'px;'">
<view class="left">
<u-icon @click="goMainPage" size="40" name="arrow-left"></u-icon>
</view>
{{ title }}
<view @click="goCart" class="right"><text class="alifont icon-gouwuche1" style="font-size: 40rpx;"></text></view>
</view>
</view>
<view class="recommend-head" :style="'margin-top:' + header.height + 'px;'">
<image src="/pages/floor/imgs/recommend/head-sample.png" mode="aspectFill"></image>
</view>
<view class="index-navs">
<ms-dropdown-item class="index-nav" :class="{ 'index-nav-active': nav == 1 }" v-model="sortType" @click.native="handledropdown(1)"
:hasSlot="true" :title="sortType || '综合排序'" ref="dropdownItem1">
<view class="dropdown-item-content">
<view class="dropdown-list" :class="{ 'dropdown-list-active': sortType == '综合排序' }" @click="setSortType('综合排序')">综合排序</view>
<view class="dropdown-list" :class="{ 'dropdown-list-active': sortType == '新品排序' }" @click="setSortType('新品排序')">新品排序</view>
</view>
</ms-dropdown-item>
<view class="index-nav-divider"></view>
<view class="index-nav" :class="{ 'index-nav-active': nav == 3 }" @click="setNav(3)">
销量
<view class="index-nav-arrows">
<view class="index-nav-arrow">
<image class="img" src="/static/index/arrow-up-1.png" v-if="sale === 'asc'" mode="aspectFit"></image>
<image class="img" src="/static/index/arrow-up.png" v-else mode="aspectFit"></image>
</view>
<view class="index-nav-arrow">
<image class="img" src="/static/index/arrow-down.png" v-if="sale === 'dec'" mode="aspectFit"></image>
<image class="img" src="/static/index/arrow-down-1.png" v-else mode="aspectFit"></image>
</view>
</view>
</view>
<view class="index-nav-divider"></view>
<view class="index-nav" :class="{ 'index-nav-active': nav == 4 }" @click="setNav(4)">
价格
<view class="index-nav-arrows">
<view class="index-nav-arrow">
<image class="img" src="/static/index/arrow-up-1.png" v-if="price === 'asc'" mode="aspectFit"></image>
<image class="img" src="/static/index/arrow-up.png" v-else mode="aspectFit"></image>
</view>
<view class="index-nav-arrow">
<image class="img" src="/static/index/arrow-down.png" v-if="price === 'dec'" mode="aspectFit"></image>
<image class="img" src="/static/index/arrow-down-1.png" v-else mode="aspectFit"></image>
</view>
</view>
</view>
<view class="index-nav-divider"></view>
<ms-dropdown-item class="index-nav" :class="{ 'index-nav-active': nav == 2 }" @click.native="handledropdown(2)"
v-model="current_tag" :hasSlot="true" :title="current_tag || '分类'" ref="dropdownItem2">
<view class="dropdown-tags">
<view class="dropdown-tag" :class="{ 'dropdown-tag-active': current_tag == item }" @click="setTags(item)" v-for="(item, index) in tags">{{ item }}</view>
<view class="dropdown-tag cancel-btn" @click="setTags('分类')">取消</view>
</view>
</ms-dropdown-item>
</view>
<view class="index-items">
<view class="index-item" v-for="(item, index) in goods" :key="index">
<view class="index-item-img" @click="toProduct(item.goods_id)">
<image :src="item.thumbnail" mode="aspectFill"></image>
<view class="index-item-title">{{ item.goodsName }}</view>
<view class="index-item-price">
¥{{ item.price | unitPrice }}
<!-- ¥{{ item.price | unitPrice }}{{ item.point ? '+' + item.point + '积分' : '' }} -->
<span class="tipsMkt">¥{{ item.mktprice }}</span>
</view>
<view class="index-item-title-desc">
<view>已售 {{ item.buy_count }}</view>
<view>好评率 {{ item.grade }}%</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import msDropdownItem from '@/components/ms-dropdown/dropdown-item.vue';
import {
getTagGoods
} from '@/api/goods.js';
import storage from '@/utils/storage.js';
export default {
components: {
msDropdownItem
},
data() {
return {
styleWay: {
'height': "100%",
'overflow': 'auto',
},
style_flag: false,
header: {
top: 0,
height: 40
},
originalGoods: [],
oldOriginalGoods: [],
// 分类的数据
sortData: [],
goods: [],
title: '',
mark: 'hot',
nav: 1,
sale: '',
price: '',
sortType: '',
tags: [],
current_tag: '',
typeSort1: true,
typeSort2: false,
};
},
async onLoad(options) {
if (options.title) {
this.title = options.title;
}
if (options.mark) {
this.mark = options.mark;
}
let response = await getTagGoods(-1, this.mark, 9999);
this.originalGoods = response.data;
this.reRank();
this.initCategory();
},
onNavigationBarButtonTap() {
uni.switchTab({
url: '/pages/tabbar/cart/cartList'
});
},
methods: {
handledropdown(val) {
if (!this.style_flag) {
this.styleWay = {
'overflow': "hidden",
'height': "100vh"
}
} else {
this.styleWay = {
'overflow': "auto",
'height': "100%"
}
}
this.style_flag = !this.style_flag
// 如果没有值的话就是全部关闭
if (!val) {
this.$refs.dropdownItem2.closePopup()
this.$refs.dropdownItem1.closePopup()
}
this.sale = '';
this.price = '';
// 如果等于1点击综合排序
if (val == 1) {
this.nav = 1
this.$refs.dropdownItem2.closePopup()
} else {
this.nav = 2
this.$refs.dropdownItem1.closePopup()
}
},
async getData() {
let response = await getTagGoods(-1, this.mark, 9999);
this.originalGoods = response.data;
this.reRank();
this.initCategory();
},
toProduct(goods_id) {
uni.navigateTo({
url: '/pages/product/goods?id=' + goods_id
});
},
goMainPage() {
uni.navigateBack()
},
goCart() {
let obj = {
from: 'recommend',
id: ''
};
storage.setCartBackbtn(obj);
uni.switchTab({
url: '/pages/tabbar/cart/cartList'
});
},
// 销量排序
saleSort(type) {
type == 'asc' ? this.originalGoods.sort(this.sortAsc('buy_count')) : this.originalGoods.sort(this.sortDec(
'buy_count'));
},
// 价格排序
priceSort(type) {
type == 'asc' ? this.originalGoods.sort(this.sortAsc('price')) : this.originalGoods.sort(this.sortDec('price'));
},
// 按照分类
cateSort(type) {
this.sortData = [];
// this.originalGoods =[]
for (let i = 0; i < this.originalGoods.length; i++) {
if (this.originalGoods[i].category_name == type) {
this.sortData.push(this.originalGoods[i]);
}
}
this.goods = this.sortData;
},
// 降序
sortDec(prop) {
return function(obj1, obj2) {
var val1 = obj1[prop];
var val2 = obj2[prop];
if (val1 < val2) {
return 1;
} else if (val1 > val2) {
return -1;
} else {
return 0;
}
};
},
// 升序
sortAsc(prop) {
return function(obj1, obj2) {
var val1 = obj1[prop];
var val2 = obj2[prop];
if (val1 < val2) {
return -1;
} else if (val1 > val2) {
return 1;
} else {
return 0;
}
};
},
setNav(type) {
this.handledropdown();
this.nav = type;
if (type == 3) {
// 销量 默认降序
this.typeSort1 ? this.setSort('sale', 'dec') : this.setSort('sale', 'asc');
this.typeSort1 = !this.typeSort1;
} else if (type == 4) {
// 价格 默认升序
this.typeSort2 ? this.setSort('price', 'asc') : this.setSort('price', 'dec');
this.typeSort2 = !this.typeSort2;
}
},
setSort(key, type) {
this.handledropdown();
if (key === 'sale') {
this.nav = 3;
this.saleSort(type);
this.$set(this, 'price', '');
}
if (key === 'price') {
this.nav = 4;
this.priceSort(type);
this.$set(this, 'sale', '');
}
if (this[key] === type) {
this.$set(this, key, '');
} else {
this.$set(this, key, type);
}
},
//
setSortType(value) {
this.nav = 1;
this.sortType = value;
// 新品排序
if (value == '新品排序') {
this.originalGoods.sort(this.sortDec('goods_id'));
} else {
this.getData();
}
this.$refs.dropdownItem1.closePopup();
},
setTags(value) {
this.current_tag = value;
this.$refs.dropdownItem2.closePopup();
if (value === '分类') {
this.nav = 1;
this.reRank();
} else {
this.nav = 2;
this.cateSort(value);
}
},
initCategory() {
let goods = this.goods;
let result = [];
for (var i = 0; i < goods.length; i++) {
result.push(goods[i].category_name);
}
this.tags = this.unique(result);
},
unique(arr) {
for (var i = 0; i < arr.length; i++) {
for (var j = i + 1; j < arr.length; j++) {
if (arr[i] == arr[j]) {
//第一个等同于第二个splice方法删除第二个
arr.splice(j, 1);
j--;
}
}
}
return arr;
},
reRank() {
this.goods = this.originalGoods;
}
}
};
</script>
<style lang="less" scoped>
.index {
padding-top: var(--status-bar-height);
}
.prohibition {
position: fixed;
width: 100%;
z-index: 100;
top: var(--status-bar-height);
}
.status_bar {
position: fixed;
top: 0px;
height: var(--status-bar-height);
width: 100%;
background: #1abc9c;
z-index: 100;
}
.header {
background: #1abc9c;
position: relative;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
font-size: 26rpx;
font-size: 34rpx;
height: 80rpx;
.left,
.right {
position: absolute;
width: max-content;
height: max-content;
top: 0;
bottom: 0;
margin: auto;
}
.left {
float: left;
top: 0;
bottom: 0;
left: 20rpx;
}
.right {
float: right;
right: 20rpx;
}
}
.tipsMkt {
float: right;
color: #c0c4cc;
text-decoration: line-through;
margin-right: 20rpx;
font-size: 24rpx;
line-height: 40rpx;
}
.img {
width: 13px !important;
height: 13px !important;
}
.recommend {
width: 100%;
padding-top: var(--status-bar-height);
}
.recommend-head {
image {
width: 3710 rpx;
height: 280 rpx;
}
}
.index-navs {
height: 80 rpx;
padding: 0 52 rpx;
background-color: #f7f7f7;
display: -webkit-box;
display: -webkit-flex;
display: flex;
align-items: center;
justify-content: space-between;
}
.index-nav {
color: #999;
font-size: 28 rpx;
display: -webkit-box;
display: -webkit-flex;
display: flex;
justify-content: center;
align-items: center;
&-active {
color: #1abc9c;
font-weight: 700;
.index-nav-desc {
color: #1abc9c;
}
}
}
.index-nav-desc {
margin-top: 8 rpx;
font-size: 22 rpx;
color: #999;
}
.index-nav-divider {
height: 64 rpx;
border-left: 1px solid #dddcdf;
}
.index-items {
margin-top: 20 rpx;
padding-left: 20 rpx;
background-color: #f7f7f7;
display: -webkit-box;
display: -webkit-flex;
display: flex;
align-items: center;
flex-wrap: wrap;
}
.index-item {
width: 346 rpx;
background-color: #fff;
margin: 0 18 rpx 20 rpx 0;
border-radius: 16 rpx;
box-sizing: border-box;
overflow: hidden;
}
.index-item-img {
image {
width: 346 rpx;
height: 320 rpx;
border-radius: 8rpx 8rpx 0 0;
}
}
.index-item-title {
font-size: 26 rpx;
color: #333333;
padding: 10 rpx 0 0 20 rpx;
box-sizing: border-box;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.index-item-title-desc {
font-size: 25 rpx;
color: #c0c4cc;
margin: 10rpx 20rpx;
display: flex;
justify-content: space-between;
}
.index-item-price {
overflow: hidden;
font-size: 110 rpx;
color: #ff5a10;
padding: 20 rpx 0 0 20 rpx;
}
.index-nav-arrows {
margin-top: 4 rpx;
display: -webkit-box;
display: -webkit-flex;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.index-nav-arrow {
image {
width: 32 rpx;
height: 32 rpx;
}
}
.index-nav-arrow:last-child {
margin-top: - 14 rpx;
}
.index-nav-arrow:first-child {
margin-bottom: - 14 rpx;
}
.dropdown-list {
width: 100%;
height: 88 rpx;
padding-left: 40 rpx;
font-size: 110 rpx;
color: #999;
font-weight: normal;
display: -webkit-box;
display: -webkit-flex;
display: flex;
align-items: center;
&-active {
color: #1abc9c;
}
}
.dropdown-tags {
padding: 110 rpx;
box-sizing: border-box;
display: -webkit-box;
display: -webkit-flex;
display: flex;
align-items: center;
flex-wrap: wrap;
z-index: 9;
}
.dropdown-tag {
// width: 710 rpx;
padding: 10rpx 20rpx;
height: 60 rpx;
margin: 0 22 rpx 22 rpx 0;
border-radius: 60 rpx;
background-color: #f9f9f9;
font-size: 110 rpx;
color: #999;
display: -webkit-box;
display: -webkit-flex;
display: flex;
justify-content: center;
align-items: center;
&-active {
background-color: #fff;
border: 1px solid #ed4743;
color: #ed4743;
}
}
.cancel-btn {
background-color: #e4e1e6;
}
</style>

266
pages/promotion/sale.vue Normal file
View File

@@ -0,0 +1,266 @@
<template>
<view class="sale">
<view class="status_bar">
<!-- 这里是状态栏 -->
</view>
<view class="prohibition" :style="'overscroll-behavior: unset;height:' + header.height + 'px;'">
<view class="header">
<view class="left">
<u-icon @click="goMainPage()" size="40" name="arrow-left"></u-icon>
</view>
特惠推荐
<view @click="goCart" class="right"><text class="alifont icon-gouwuche1"
style="font-size: 40rpx;"></text></view>
</view>
</view>
<view class="sale-head">
<image :style="'margin-top:' + header.height + 'px;'" src="/pages/floor/imgs/recommend/head-sample.png"
mode="aspectFill"></image>
</view>
<view class="sale-title">
<view>今日特惠</view>
</view>
<view class="sale-items">
<view class="sale-item" v-for="item in goods" @click="navigateTo(item)">
<view class="sale-item-img">
<image :src="item.thumbnail" mode="aspectFill"></image>
</view>
<view class="sale-item-content">
<view class="sale-item-title">
{{ item.name }}
<view class="sale-item-title-desc">{{ item.category }}</view>
</view>
<view class="sale-item-price">
<text class="sale-item-price-now">¥{{ item.price | unitPrice }}
<!-- <text v-if="item.point">+{{ item.point || 0 }}积分</text> -->
</text>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import {
getPlateformTagGoods
} from '@/api/goods.js';
import storage from '@/utils/storage.js';
export default {
data() {
return {
header: {
top: 0,
height: 40
},
goods: [],
tag_id: 1,
loadStatus: 'more'
};
},
async onLoad(options) {
if (options.title) {
uni.setNavigationBarTitle({
title: options.title
});
}
let response = await getPlateformTagGoods(this.tag_id);
this.goods = response.data;
},
onBackPress() {
// uni.preloadPage({
// url: '/pages/tabbar/home/index',
// success: function(res) {
// // 通过eventChannel向被打开页面传送数据
// console.log(res)
// }
// });
// //莫名其妙的,无法后退,尝试追加参数解决缓存问题
// uni.switchTab({
// url: '/pages/tabbar/home/index?' + new Date().getTime(),
// success: function(res) {
// // 通过eventChannel向被打开页面传送数据
// console.log(res);
// }
// });
},
methods: {
// 跳转
navigateTo(item) {
uni.navigateTo({
url: '/pages/product/goods?id=' + item.goods_id
});
},
goCart() {
//跳转购物车
let obj = {
from: 'sale',
id: ''
};
storage.setCartBackbtn(obj);
uni.preloadPage({
url: '/pages/tabbar/cart/cartList'
});
},
goMainPage() {
//莫名其妙的,无法后退,尝试追加参数解决缓存问题
uni.switchTab({
url: '/pages/tabbar/home/index'
});
}
}
};
</script>
<style lang="less" scoped>
.sale {
width: 100%;
min-height: 100vh;
background-color: #f7f7f7;
}
.index {
padding-top: var(--status-bar-height);
}
.prohibition {
position: fixed;
width: 100%;
z-index: 100;
top: var(--status-bar-height);
}
.status_bar {
position: fixed;
top: 0px;
height: var(--status-bar-height);
width: 100%;
background: #1abc9c;
z-index: 100;
}
.header {
background: #1abc9c;
position: relative;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
font-size: 26rpx;
font-size: 34rpx;
height: 80rpx;
.left,
.right {
position: absolute;
width: max-content;
height: max-content;
top: 0;
bottom: 0;
margin: auto;
}
.left {
float: left;
top: 0;
bottom: 0;
left: 20rpx;
}
.right {
float: right;
right: 20rpx;
}
}
.sale-head {
padding-top: var(--status-bar-height);
image {
width: 750 rpx;
height: 280 rpx;
border-radius: 0px;
}
margin-bottom: 20 rpx;
}
.sale-title {
width: 710 rpx;
height: 100 rpx;
margin: 0 auto;
font-size: 28 rpx;
color: #666;
border-radius: 14 rpx 14 rpx 0 0;
background-color: #f1f1f1;
display: -webkit-box;
display: -webkit-flex;
display: flex;
justify-content: center;
align-items: center;
justify-content: start;
view {
margin-left: 40 rpx;
font-size: 28rpx;
font-family: PingFang SC, PingFang SC-Regular;
font-weight: 400;
}
}
.sale-items {
display: -webkit-box;
display: -webkit-flex;
display: flex;
align-items: center;
flex-direction: column;
margin: 0 20rpx;
background-color: #fff;
}
.sale-item {
width: 710 rpx;
padding: 0 20rpx;
height: 180 rpx;
border-bottom: 1px solid #eeeeee;
// position: relative;
display: -webkit-box;
display: -webkit-flex;
display: flex;
align-items: center;
justify-content: start;
}
.sale-item-img {
margin-right: 20 rpx;
image {
width: 124 rpx;
height: 124 rpx;
border-radius: 8 rpx;
}
}
.sale-item-content {
line-height: 1.5em;
}
.sale-item-title {
font-size: 28 rpx;
color: #333;
}
.sale-item-title-desc {
font-size: 25 rpx;
color: #ccc;
}
.sale-item-price-now {
font-size: 28 rpx;
color: #ff5a10;
margin: 0;
}
</style>

445
pages/promotion/seckill.vue Normal file
View File

@@ -0,0 +1,445 @@
<template>
<view class="sale">
<view class="sale-head">
<image src="@/pages/promotion/static/head-sample.png"></image>
</view>
<scroll-view scroll-x>
<view class="index-navs">
<view class="index-nav-v">
<view class="index-nav" :class="{ 'index-nav-active': nav == index }" @click="setNav(index)" v-for="(item, index) in timeLine" :key="index">
{{ item.timeLine }}:00
<view class="index-nav-desc">{{ index === 0 && item.distanceStartTime === 0 ? '抢购中' : '即将开始' }}
</view>
</view>
</view>
</view>
<view class="trailer" v-if="timeLine[nav] && times">
{{ timeLine[nav].distanceStartTime === 0 ? (onlyOne ? '距结束' : '距下一轮') : '距开始' }}
{{ times.hours == '00' ? '0' : times.hours }}小时{{ times.minutes }}{{ times.seconds }}
</view>
</scroll-view>
<view class="sale-items" v-if="goodsList.length > 0">
<view class="sale-item" v-for="(item,index) in goodsList" :key="index">
<view class="sale-item-img">
<image :src="item.goodsImage" mode="aspectFill"></image>
</view>
<view class="sale-item-content">
<view class="sale-item-title">
{{ item.goodsName }}
<view class="sale-item-title-desc"></view>
</view>
<view class="sale-item-price">
<text class="sale-item-price-now">¥{{ item.price | unitPrice}}</text>
<text class="sale-item-price-origin"> ¥{{ item.originalPrice | unitPrice }}</text>
</view>
<view class="sale-item-surplus">
仅剩{{ item.quantity - item.salesNum }}
<view class="sale-item-surplus-text" :style="{ width: (item.quantity / (item.quantity - item.salesNum)) * 100 + '%' }">
</view>
</view>
<view class="sale-item-btn" @click="gotoGoodsDetail(item)">
{{ timeLine[nav].distanceStartTime === 0 ? (item.salesNum === item.quantity ? '已售空' : '购买') : '即将开始' }}
</view>
</view>
</view>
</view>
<view v-else>
<view class="nodata">
<image style="height: 240rpx;width: 320rpx;" src="/static/nodata.png" alt="" />
<div>暂无商品</div>
</view>
</view>
</view>
</template>
<script>
import { getSeckillTimeLine, getSeckillTimeGoods } from "@/api/promotions.js";
import Foundation from "@/utils/Foundation.js";
export default {
data() {
return {
nav: 0,
sale: "",
timeLine: "",
resTime: 0,
time: 0,
times: {},
onlyOne: "",
goodsList: [],
params: {
pageNumber: 1,
pageSize: 10,
},
price: "",
};
},
async onShow() {
await this.getTimeLine();
if (!this.timeLine) {
await uni.showToast({
icon: "none",
duration: 2000,
title: "今天没有活动,明天再来吧",
});
// setTimeout(() => {
// uni.switchTab({
// url: "/pages/index/index",
// });
// }, 2000);
// return;
}
this._setTimeInterval = setInterval(() => {
if (this.time <= 0) {
clearInterval(this._setTimeInterval);
this.getGoodsList();
this.getTimeLine();
} else {
this.times = Foundation.countTimeDown(this.time);
this.time--;
}
}, 1000);
},
onUnload() {
this._setTimeInterval && clearInterval(this._setTimeInterval);
},
methods: {
async getTimeLine() {
let res = await getSeckillTimeLine();
if (res.data.success && res.data.result.length > 0) {
let timeLine = res.data.result.sort(
(x, y) => Number(x.timeLine) - Number(y.timeLine)
);
this.timeLine = timeLine.slice(0, 5);
this.resTime = parseInt(new Date().getTime() / 1000);
this.onlyOne = res.data.result.length === 1;
this.diffTime = parseInt(new Date().getTime() / 1000) - this.resTime;
this.time =
this.timeLine[this.nav].distanceStartTime ||
(this.timeLine[this.nav + 1] &&
this.timeLine[this.nav + 1].distanceStartTime) ||
Foundation.theNextDayTime() - this.diffTime;
// || Foundation.theNextDayTime())
this.times = Foundation.countTimeDown(this.time);
this.getGoodsList();
}
},
async getGoodsList() {
this.params.timeLine = this.timeLine[this.nav].timeLine;
let res = await getSeckillTimeGoods(this.params.timeLine);
if (res.data.success && res.data.result.length != 0) {
this.goodsList = res.data.result;
} else {
this.goodsList = [];
}
},
gotoGoodsDetail(item) {
if (
item.sold_num === item.quantity ||
this.timeLine[this.nav].distanceStartTime !== 0
) {
return;
} else {
uni.navigateTo({
url: `/pages/product/goods?id=${item.skuId}&goodsId=${item.goodsId}`,
});
}
},
setNav(type) {
this.nav = type;
this.diffTime = parseInt(new Date().getTime() / 1000) - this.resTime;
this.time =
this.timeLine[this.nav].distanceStartTime ||
(this.timeLine[this.nav + 1] &&
this.timeLine[this.nav + 1].distanceStartTime) ||
Foundation.theNextDayTime() - this.diffTime;
this.times = Foundation.countTimeDown(this.time);
this.getGoodsList();
},
},
};
</script>
<style lang="less" scoped>
.sale {
width: 100%;
min-height: 100vh;
background-color: #f7f7f7;
}
.nodata {
flex-direction: column;
display: flex;
width: 100%;
justify-content: center;
align-items: center;
margin-top: 40rpx;
> div {
font-size: 24rpx;
margin-top: 20rpx;
color: #666;
}
}
.sale-head {
image {
width: 100%;
height: 280rpx;
}
}
.sale-title {
width: 710rpx;
height: 310rpx;
margin: 0 auto;
font-size: 32rpx;
color: 666;
background-color: #fff;
display: -webkit-box;
display: -webkit-flex;
display: flex;
justify-content: center;
align-items: center;
}
.sale-items {
padding-top: 20rpx;
display: -webkit-box;
display: -webkit-flex;
display: flex;
align-items: center;
flex-direction: column;
}
.sale-item {
width: 710rpx;
height: 226rpx;
padding-left: 20rpx;
margin-bottom: 10rpx;
border-radius: 12rpx;
background-color: #fff;
position: relative;
display: -webkit-box;
display: -webkit-flex;
display: flex;
align-items: center;
}
.sale-item-img {
margin-right: 20rpx;
image {
width: 186rpx;
height: 186rpx;
border-radius: 8rpx;
}
}
.sale-item-content {
line-height: 2em;
}
.sale-item-title {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
line-height: 1.5;
font-size: 28rpx;
color: #333;
}
.sale-item-title-desc {
font-size: 22rpx;
color: #999;
}
.sale-item-price {
font-size: 22rpx;
color: 999;
}
.sale-item-price-now {
font-size: 40rpx;
color: #ff5a10;
margin: 0 10rpx;
}
.sale-item-price-origin {
font-size: 20rpx;
color: #999;
-webkit-text-decoration-line: line-through;
text-decoration-line: line-through;
text-decoration: line-through;
}
.sale-item-surplus {
border: 2rpx solid rgb(34, 178, 140);
border-radius: 12px;
width: 166rpx;
color: rgb(31, 177, 138);
font-size: 20rpx;
position: relative;
text-align: center;
z-index: 2;
height: 32rpx;
line-height: 28rpx;
overflow: hidden;
}
.sale-item-surplus-text {
width: 166rpx;
background: rgb(234, 247, 245);
position: absolute;
top: 0;
left: 0;
z-index: -1;
height: 100%;
}
.sale-item-btn {
position: absolute;
right: 20rpx;
bottom: 20rpx;
padding: 0 20rpx;
height: 60rpx;
background-color: #1abc9c;
border-radius: 10rpx;
font-size: 25rpx;
color: #fff;
display: -webkit-box;
display: -webkit-flex;
display: flex;
justify-content: center;
align-items: center;
}
.trailer {
height: 100rpx;
background: #ffffff;
display: -webkit-box;
display: -webkit-flex;
display: flex;
justify-content: center;
align-items: center;
font-size: 22rpx;
color: #666666;
box-sizing: border-box;
position: relative;
z-index: 0;
}
.index-navs {
background-color: #f7f7f7;
display: -webkit-box;
display: -webkit-flex;
display: flex;
align-items: center;
justify-content: space-between;
}
.index-nav-v {
display: -webkit-box;
display: -webkit-flex;
display: flex;
justify-content: center;
align-items: center;
position: relative;
}
.index-nav {
font-size: 28rpx;
display: -webkit-box;
display: -webkit-flex;
display: flex;
justify-content: center;
align-items: center;
width: 150rpx;
flex-direction: column;
color: #bababa;
height: 115rpx;
line-height: 1em;
position: relative;
&-active {
background-image: url(/static/seckill/active.png);
background-size: 100% 115rpx;
background-repeat: no-repeat;
color: #ffffff;
position: relative;
z-index: 30;
.index-nav-desc {
color: #ffffff;
}
}
}
.index-nav-desc {
margin-top: 8rpx;
font-size: 22rpx;
color: #bababa;
}
.index-nav-divider {
height: 64rpx;
border-left: 1px solid #dddddd;
}
.index-items {
padding-left: 20rpx;
background-color: #f7f7f7;
display: -webkit-box;
display: -webkit-flex;
display: flex;
align-items: center;
flex-wrap: wrap;
}
.index-item {
width: 346rpx;
height: 2100rpx;
background-color: #fff;
margin: 0 18rpx 20rpx 0;
border-radius: 16rpx;
box-sizing: border-box;
overflow: hidden;
}
.index-item-img {
image {
width: 346rpx;
height: 320rpx;
}
}
.index-item-title {
font-size: 26rpx;
color: #333333;
height: 410rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
padding: 10rpx 0 0 20rpx;
box-sizing: border-box;
}
.index-item-title-desc {
font-size: 25rpx;
color: #999999;
margin-top: 10rpx;
}
.index-item-price {
font-size: 110rpx;
color: #ff5a10;
padding: 20rpx 0 0 20rpx;
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

131
pages/promotion/style.scss Normal file
View File

@@ -0,0 +1,131 @@
.view-item {
background: #fff;
border-radius: 0.4em;
margin: 20rpx 30rpx;
padding: 20rpx 0;
}
.nodata {
text-align: center;
margin: 40rpx 0 20rpx 0;
}
.container-wrap {
width: 100%;
}
.white_class {
color: #fff;
font-size: 28rpx;
}
.popupTips {
font-size: 22rpx;
font-family: PingFang SC, PingFang SC-Regular;
font-weight: 400;
text-align: left;
color: #999999;
margin: 0 20rpx;
/deep/ view {
line-height: 1.75;
}
}
.search {
margin: 30rpx 20rpx !important;
}
.view-left,
.view-content,
.view-right,
.view-item {
display: flex;
}
.wrapper {
width: 100%;
overflow: hidden;
}
.view-left {
width: 226rpx;
height: 100%;
overflow: hidden;
display: flex;
justify-content: center;
}
.view-content {
width: calc((100% - 240rpx));
padding-left: 20rpx;
flex-direction: column;
justify-content: center;
text-align: center;
}
.buy-content {
font-size: 22rpx;
font-family: PingFang SC, PingFang SC-Regular;
font-weight: 400;
margin-top: 15rpx;
text-align: center;
color: #999999;
}
.view-content-bottom {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
}
.group-wrapper {
padding: 16rpx 32rpx;
}
.view-content-name {
font-family: PingFang SC, PingFang SC-Regular;
font-weight: 400;
text-align: left;
color: #333333;
font-size: 28rpx;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
}
.view-content-price {
margin: 10rpx 0;
letter-spacing: 0px;
overflow: hidden;
font-size: 28rpx;
font-family: PingFang SC, PingFang SC-Regular;
font-weight: 400;
text-align: left;
color: #ff5a10;
text-overflow: ellipsis;
white-space: nowrap;
}
.view-content-original_price {
font-size: 22rpx;
font-family: PingFang SC, PingFang SC-Regular;
font-weight: 400;
text-decoration: line-through;
text-align: left;
color: #999999;
}
.btn-group {
background: $aider-light-color;
border-radius: 10rpx;
font-size: 24rpx;
font-family: PingFang SC, PingFang SC-Regular;
font-weight: 400;
color: #fff;
text-align: center;
padding: 6rpx 16rpx;
}
/deep/ .empty {
position: relative;
padding-top: 20%;
> .empty-content {
position: relative;
padding-top: 20%;
}
}