index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <template>
  2. <!-- 限时秒杀模块 -->
  3. <view :style="colorStyle">
  4. <!-- #ifdef H5 -->
  5. <view class="w-full bg-top h-604 relative" :style="{backgroundImage:headerBg}">
  6. <!-- #endif -->
  7. <!-- #ifndef H5 -->
  8. <view class="w-full bg-top relative" :style="{backgroundImage:headerBg,height: (sysHeight + 262) * 2 + 'rpx'}">
  9. <!-- #endif -->
  10. <view class="fixed-lt w-full z-20"
  11. :class="pageScrollStatus ? 'sticky' : ''"
  12. :style="{'padding-top': sysHeight + 'px','background': pageScrollStatus ? '#e93323' : 'transparent'}">
  13. <view class="w-full px-20 pl-20 h-80 flex-between-center">
  14. <text class="iconfont icon-ic_leftarrow fs-40 text--w111-fff" @click="goPage(3)"></text>
  15. <text class="fs-34 fw-500 text--w111-fff">{{pageScrollStatus ? '限时秒杀' : ''}}</text>
  16. <text></text>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="relative w-full content">
  21. <view class="_box h-106 flex-y-center"
  22. :class="pageScrollStatus ? '' : 'rd-t-24rpx'"
  23. :style="{'top': 50 + sysHeight + 'px'}">
  24. <scroll-view scroll-x="true" scroll-with-animation class="white-nowrap vertical-middle w-full relative z-10"
  25. :class="{'sel1':active == 0,'sel-last':active == timeList.length - 1}"
  26. show-scrollbar="false">
  27. <view class="scroll-item"
  28. v-for="(item,index) in timeList" :key='index'
  29. :class="active == index ? 'active-card' : ''"
  30. :style="{'background-image': active == index ? navActiveBg : ''}"
  31. @tap='settimeList(item,index)'>
  32. <view class="flex-col flex-center z-10 relative t-22">
  33. <text class="SemiBold fs-40 lh-40rpx"
  34. :class="active == index ? 'text--w111-333':'text--w111-fff'">{{item.time}}</text>
  35. <text class="inline-block h-36 lh-34rpx fs-24"
  36. :class="active == index ? 'red-tag':'text--w111-fff'">{{item.state}}</text>
  37. </view>
  38. </view>
  39. </scroll-view>
  40. <view class="abs-lb w-full"
  41. :style="{'background': pageScrollStatus ? '#e93323' : 'rgba(245,245,245,0.2)','height': pageScrollStatus ? '130rpx' : '96rpx'}"></view>
  42. </view>
  43. <view class="bg--w111-f5f5f5 pt-32 pl-20 pr-20 relative" >
  44. <view class="card w-full bg--w111-fff rd-24rpx p-20 flex" v-for="(item,index) in seckillList" :key="index"
  45. @tap='goDetails(item)'>
  46. <view class="w-240 h-240">
  47. <easy-loadimage
  48. mode="widthFix"
  49. :image-src="item.image"
  50. :border-src="item.activity_image"
  51. width="240rpx"
  52. height="240rpx"
  53. borderRadius="20rpx"></easy-loadimage>
  54. </view>
  55. <view class="flex-1 h-240 pl-20 flex-col justify-between">
  56. <view class="w-full">
  57. <view class="w-410 fs-28 lh-40rpx line1">{{item.title}}</view>
  58. <view class="w-410 flex items-end flex-wrap mt-12" v-if="item.store_label.length">
  59. <BaseTag
  60. :text="label.label_name"
  61. :color="label.color"
  62. :background="label.bg_color"
  63. :borderColor="label.border_color"
  64. :circle="label.border_color ? true : false"
  65. :imgSrc="label.icon"
  66. v-for="(label, idx) in item.store_label" :key="idx"></BaseTag>
  67. </view>
  68. </view>
  69. <view class="flex items-baseline">
  70. <text class="fs-22 lh-30rpx text-primary pr-8">秒杀价:</text>
  71. <baseMoney :money="item.price" symbolSize="24" integerSize="40" decimalSize="24" color="#E93323" weight></baseMoney>
  72. <text class="fs-22 lh-30rpx text--w111-999 pl-16 text-line">¥{{item.ot_price}}</text>
  73. </view>
  74. <view class="w-full progress-box flex-between-center" v-if="status == 1">
  75. <view class="flex-y-center">
  76. <view class="progress ml-16">
  77. <view class="active" :style="'width:'+item.percent+'%;'"></view>
  78. </view>
  79. <text class="fs-22 text-primary pl-8">已抢{{item.percent}}%</text>
  80. </view>
  81. <view class="qiang"></view>
  82. </view>
  83. <view class="w-full yuyue-box flex-between-center" v-else-if="status == 2">
  84. <view class="flex-y-center fs-22 pl-16">活动即将开始</view>
  85. <view class="yuyue"></view>
  86. </view>
  87. <view class="w-full over-box flex-between-center" v-else>
  88. <view class="flex-y-center fs-22 pl-16">活动已结束</view>
  89. <view class="over"></view>
  90. </view>
  91. </view>
  92. </view>
  93. <view class="abs-lt cir" v-show="active > 0"></view>
  94. </view>
  95. <view class="bg--w111-f5f5f5 p-20" v-if="!seckillList.length && !pageloading">
  96. <emptyPage title="暂无秒杀商品,去看看其他商品吧~" src="/statics/images/noActivity.gif"></emptyPage>
  97. </view>
  98. </view>
  99. </view>
  100. </template>
  101. <script>
  102. let sysHeight = uni.getSystemInfoSync().statusBarHeight;
  103. import { getSeckillIndexTime, getSeckillList } from '@/api/activity.js';
  104. import colors from '@/mixins/color.js'
  105. import {HTTP_REQUEST_URL} from '@/config/app';
  106. import emptyPage from '@/components/emptyPage.vue';
  107. export default {
  108. components: {
  109. emptyPage
  110. },
  111. mixins:[colors],
  112. data() {
  113. return {
  114. sysHeight:sysHeight,
  115. topImage: '',
  116. seckillList: [],
  117. timeList: [],
  118. active: 5,
  119. scrollLeft: 0,
  120. interval: 0,
  121. status: 1,
  122. countDownHour: "00",
  123. countDownMinute: "00",
  124. countDownSecond: "00",
  125. page: 1,
  126. limit: 8,
  127. loading: false,
  128. loadend: false,
  129. pageloading: false,
  130. intoindex:'',
  131. imgHost:HTTP_REQUEST_URL,
  132. pageScrollStatus: false
  133. }
  134. },
  135. computed:{
  136. headerBg(){
  137. return 'url('+this.imgHost+'/statics/images/product/seckill_header.png'+')'
  138. },
  139. navActiveLeft(){
  140. if(this.active == 0){
  141. return 0
  142. } else if(this.active == 1){
  143. return '134rpx'
  144. } else {
  145. return 154 * this.active + 'rpx'
  146. }
  147. },
  148. navActiveBg(){
  149. if(this.active == 0){
  150. return 'url('+this.imgHost+'/statics/images/product/seckill_header_icon1.png'+')'
  151. }else{
  152. return 'url('+this.imgHost+'/statics/images/product/seckill_header_icon2.png'+')'
  153. }
  154. }
  155. },
  156. onPageScroll(object) {
  157. if (object.scrollTop > 200) {
  158. this.pageScrollStatus = true;
  159. } else if (object.scrollTop < 200) {
  160. this.pageScrollStatus = false;
  161. }
  162. uni.$emit('scroll');
  163. },
  164. onLoad() {
  165. this.getSeckillConfig();
  166. },
  167. onShow(){
  168. uni.removeStorageSync('form_type_cart');
  169. },
  170. methods: {
  171. getSeckillConfig: function() {
  172. let that = this;
  173. getSeckillIndexTime().then(res => {
  174. that.topImage = res.data.lovely;
  175. that.timeList = res.data.seckillTime;
  176. that.active = res.data.seckillTimeIndex;
  177. that.$nextTick(()=>{
  178. that.intoindex = 'sort'+res.data.seckillTimeIndex
  179. })
  180. if (that.timeList.length) {
  181. that.scrollLeft = (that.active - 1.37) * 100
  182. setTimeout(function() {
  183. that.loading = true
  184. }, 2000);
  185. that.seckillList = [],
  186. that.page = 1
  187. that.status = that.timeList[that.active].status
  188. that.getSeckillList();
  189. }
  190. });
  191. },
  192. getSeckillList: function() {
  193. var that = this;
  194. var data = {
  195. page: that.page,
  196. limit: that.limit
  197. };
  198. if (that.loadend) return;
  199. if (that.pageloading) return;
  200. this.pageloading = true
  201. getSeckillList(that.timeList[that.active].id, data).then(res => {
  202. var seckillList = res.data;
  203. var loadend = seckillList.length < that.limit;
  204. that.page++;
  205. that.seckillList = that.seckillList.concat(seckillList),
  206. that.page = that.page;
  207. that.pageloading = false;
  208. that.loadend = loadend;
  209. }).catch(err => {
  210. that.pageloading = false
  211. });
  212. },
  213. settimeList: function(item, index) {
  214. var that = this;
  215. this.active = index
  216. if (that.interval) {
  217. clearInterval(that.interval);
  218. that.interval = null
  219. }
  220. that.interval = 0,
  221. that.countDownHour = "00";
  222. that.countDownMinute = "00";
  223. that.countDownSecond = "00";
  224. that.status = that.timeList[that.active].status;
  225. that.loadend = false;
  226. that.page = 1;
  227. that.seckillList = [];
  228. // wxh.time(e.currentTarget.dataset.stop, that);
  229. that.getSeckillList();
  230. },
  231. goDetails(item){
  232. uni.navigateTo({
  233. url: '/pages/activity/goods_details/index?id=' + item.id + '&type=1&time_id=' + this.timeList[this.active].id
  234. })
  235. },
  236. goPage(type, url){
  237. if(type == 1){
  238. uni.navigateTo({
  239. url
  240. })
  241. }else if(type == 2){
  242. uni.switchTab({
  243. url
  244. })
  245. }else if(type == 3){
  246. uni.navigateBack();
  247. }
  248. }
  249. },
  250. /**
  251. * 页面上拉触底事件的处理函数
  252. */
  253. onReachBottom: function() {
  254. this.getSeckillList();
  255. }
  256. }
  257. </script>
  258. <style lang="scss">
  259. .bg-top{
  260. background-size: 100% 100%;
  261. background-repeat: no-repeat;
  262. }
  263. .sticky{
  264. &:after{
  265. content:'';
  266. width:100%;
  267. height: 20px;
  268. background-color: #E93323;
  269. position: absolute;
  270. left: 0;
  271. bottom: -20rpx;
  272. }
  273. }
  274. .content{
  275. top: -114rpx;
  276. }
  277. ._box{
  278. position: sticky;
  279. z-index: 99;
  280. }
  281. .card ~ .card{
  282. margin-top: 20rpx;
  283. }
  284. .w-21-p111-{
  285. width: 21%;
  286. }
  287. .max-w-96{
  288. max-width: 96rpx;
  289. }
  290. .fq{
  291. background-color: #E93323;
  292. color: #fff;
  293. }
  294. .text-primary{
  295. color: #E93323;;
  296. }
  297. .text-line{
  298. text-decoration: line-through;
  299. }
  300. .progress-box{
  301. height: 64rpx;
  302. background-color: rgba(233, 51, 35, 0.05);
  303. border-radius: 16rpx;
  304. }
  305. .progress{
  306. width:160rpx;
  307. height: 18rpx;
  308. border-radius: 10rpx;
  309. background-color: rgba(233, 51, 35, 0.2);
  310. .active{
  311. height: 18rpx;
  312. border-radius: 10rpx;
  313. background: linear-gradient(90deg, #FF7931 0%, #E93323 100%);
  314. }
  315. }
  316. .qiang{
  317. width:112rpx;
  318. height: 64rpx;
  319. background-image: url('../static/qiang.png');
  320. background-size: cover;
  321. }
  322. .yuyue-box{
  323. height: 64rpx;
  324. background-color: #FFF1E5;
  325. border-radius: 16rpx;
  326. color: #FF7D00;
  327. }
  328. .yuyue{
  329. width:140rpx;
  330. height: 64rpx;
  331. background-image: url('../static/yuyue.png');
  332. background-size: cover;
  333. }
  334. .over-box{
  335. height: 64rpx;
  336. background-color: rgba(233, 51, 35, 0.05);
  337. border-radius: 16rpx;
  338. color: rgba(233, 51, 35, 0.60);
  339. }
  340. .over{
  341. width:140rpx;
  342. height: 64rpx;
  343. background-image: url('../static/over.png');
  344. background-size: cover;
  345. }
  346. .sel1 .scroll-item{
  347. right: 30rpx;
  348. }
  349. .sel-last {
  350. /deep/.uni-scroll-view{
  351. margin-right: -10rpx;
  352. }
  353. .scroll-item{
  354. // left: 40rpx;
  355. // left: 32rpx;
  356. }
  357. .active-card{
  358. width: 180rpx;
  359. padding-left: 10px;
  360. .relative{
  361. width: 160rpx;
  362. }
  363. }
  364. }
  365. .scroll-item{
  366. display: inline-block;
  367. height: 96rpx;
  368. width: 21%;
  369. position: relative;
  370. bottom: 0;
  371. }
  372. .active-card{
  373. width:234rpx;
  374. height: 106rpx;
  375. background-size: cover;
  376. z-index: 99;
  377. }
  378. .t-22{
  379. top: 22rpx;
  380. }
  381. .red-tag{
  382. display: inline-block;
  383. padding: 0 12rpx;
  384. height: 36rpx;
  385. border-radius: 18rpx;
  386. text-align: center;
  387. line-height: 36rpx;
  388. background-color: #E93323;
  389. font-size: 22rpx;
  390. color: #fff;
  391. }
  392. .cir{
  393. width: 24rpx;
  394. height: 24rpx;
  395. background-color: #ED593E;
  396. &:after{
  397. content: '';
  398. width: 24rpx;
  399. height: 24rpx;
  400. position: absolute;
  401. left: 0;
  402. top: 0;
  403. border-top-left-radius: 100%; /* 左上角为半径大小的弧形 */
  404. background-color: #f5f5f5;
  405. }
  406. }
  407. </style>