index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <!-- 限时秒杀模块 -->
  3. <div :style="colorStyle">
  4. <view class='flash-sale'>
  5. <view class="saleBox"></view>
  6. <view class='header' v-if="timeList.length>0">
  7. <image :src='timeList[active].slide'></image>
  8. </view>
  9. <view class="seckillList acea-row row-between-wrapper">
  10. <view class="priceTag">
  11. <image src="../static/priceTag.png"></image>
  12. </view>
  13. <view class='timeLsit'>
  14. <scroll-view class="scroll-view_x style-add" scroll-x scroll-with-animation :scroll-left="scrollLeft" :scroll-into-view="intoindex">
  15. <block v-for="(item,index) in timeList" :key='index'>
  16. <view @tap='settimeList(item,index)' class='item' :class="active == index?'on':''" :id='"sort"+index'>
  17. <view class='time'>{{item.time}}</view>
  18. <view class="state">{{item.state}}</view>
  19. </view>
  20. </block>
  21. </scroll-view>
  22. </view>
  23. </view>
  24. <view class='list'>
  25. <block v-for="(item,index) in seckillList" :key='index'>
  26. <view class='item acea-row row-between-wrapper' @tap='goDetails(item)'>
  27. <view class='pictrue'>
  28. <image :src='item.image'></image>
  29. </view>
  30. <view class='text acea-row row-column-around'>
  31. <view class='name line1'>{{item.title}}</view>
  32. <view class='money'>¥
  33. <text class='num font-color'>{{item.price}}</text>
  34. <text class="y_money">¥{{item.ot_price}}</text>
  35. </view>
  36. <view class="limit">限量 <text class="limitPrice">{{item.quota_show}}{{item.unit_name || ''}}</text></view>
  37. <view class="progress">
  38. <view class='bg-reds' :style="'width:'+item.percent+'%;'"></view>
  39. <view class='piece'>已抢{{item.percent}}%</view>
  40. </view>
  41. </view>
  42. <view class='grab bg-color' v-if="status == 1">马上抢</view>
  43. <view class='grab bg-color' v-else-if="status == 2">未开始</view>
  44. <view class='grab bg-color-hui' v-else>已结束</view>
  45. </view>
  46. </block>
  47. </view>
  48. </view>
  49. <view class="no-goods" v-if="seckillList.length == 0 && (page != 1 || active== 0)">
  50. <image :src="imgHost + '/statics/images/no-thing.png'" mode=""></image>
  51. <text class="tip">暂无秒杀商品,去看看其他商品吧~</text>
  52. </view>
  53. <home v-if="navigation"></home>
  54. </div>
  55. </template>
  56. <script>
  57. import {
  58. getSeckillIndexTime,
  59. getSeckillList
  60. } from '../../../api/activity.js';
  61. import home from '@/components/home/index.vue'
  62. import colors from '@/mixins/color.js'
  63. import {HTTP_REQUEST_URL} from '@/config/app';
  64. export default {
  65. components: {
  66. home
  67. },
  68. mixins:[colors],
  69. data() {
  70. return {
  71. topImage: '',
  72. seckillList: [],
  73. timeList: [],
  74. active: 5,
  75. scrollLeft: 0,
  76. interval: 0,
  77. status: 1,
  78. countDownHour: "00",
  79. countDownMinute: "00",
  80. countDownSecond: "00",
  81. page: 1,
  82. limit: 8,
  83. loading: false,
  84. loadend: false,
  85. pageloading: false,
  86. intoindex:'',
  87. imgHost:HTTP_REQUEST_URL
  88. }
  89. },
  90. onLoad() {
  91. this.getSeckillConfig();
  92. },
  93. onShow(){
  94. uni.removeStorageSync('form_type_cart');
  95. },
  96. methods: {
  97. getSeckillConfig: function() {
  98. let that = this;
  99. getSeckillIndexTime().then(res => {
  100. that.topImage = res.data.lovely;
  101. that.timeList = res.data.seckillTime;
  102. that.active = res.data.seckillTimeIndex;
  103. that.$nextTick(()=>{
  104. that.intoindex = 'sort'+res.data.seckillTimeIndex
  105. })
  106. if (that.timeList.length) {
  107. // wxh.time(that.data.timeList[that.data.active].stop, that);
  108. that.scrollLeft = (that.active - 1.37) * 100
  109. setTimeout(function() {
  110. that.loading = true
  111. }, 2000);
  112. that.seckillList = [],
  113. that.page = 1
  114. that.status = that.timeList[that.active].status
  115. that.getSeckillList();
  116. }
  117. });
  118. },
  119. getSeckillList: function() {
  120. var that = this;
  121. var data = {
  122. page: that.page,
  123. limit: that.limit
  124. };
  125. if (that.loadend) return;
  126. if (that.pageloading) return;
  127. this.pageloading = true
  128. getSeckillList(that.timeList[that.active].id, data).then(res => {
  129. var seckillList = res.data;
  130. var loadend = seckillList.length < that.limit;
  131. that.page++;
  132. that.seckillList = that.seckillList.concat(seckillList),
  133. that.page = that.page;
  134. that.pageloading = false;
  135. that.loadend = loadend;
  136. }).catch(err => {
  137. that.pageloading = false
  138. });
  139. },
  140. settimeList: function(item, index) {
  141. var that = this;
  142. this.active = index
  143. if (that.interval) {
  144. clearInterval(that.interval);
  145. that.interval = null
  146. }
  147. that.interval = 0,
  148. that.countDownHour = "00";
  149. that.countDownMinute = "00";
  150. that.countDownSecond = "00";
  151. that.status = that.timeList[that.active].status;
  152. that.loadend = false;
  153. that.page = 1;
  154. that.seckillList = [];
  155. // wxh.time(e.currentTarget.dataset.stop, that);
  156. that.getSeckillList();
  157. },
  158. goDetails(item){
  159. uni.navigateTo({
  160. url: '/pages/activity/goods_seckill_details/index?id=' + item.id + '&time=' + this.timeList[this.active].stop + '&status=' + this.status
  161. })
  162. }
  163. },
  164. /**
  165. * 页面上拉触底事件的处理函数
  166. */
  167. onReachBottom: function() {
  168. this.getSeckillList();
  169. }
  170. }
  171. </script>
  172. <style lang="scss">
  173. .style-add {
  174. width:auto;
  175. overflow:hidden;
  176. height:106rpx;
  177. }
  178. page {
  179. background-color: #F5F5F5 !important;
  180. }
  181. .no-goods{
  182. margin: 0 30rpx;
  183. background-color: #fff;
  184. text-align: center;
  185. padding: 20rpx 0 100rpx 0;
  186. color: #999;
  187. border-radius: 10rpx;
  188. image{
  189. width: 414rpx;
  190. height: 304rpx;
  191. margin: 40rpx auto 0 auto;
  192. display: block;
  193. }
  194. }
  195. .flash-sale .header {
  196. width: 710rpx;
  197. height: 300rpx;
  198. margin: -215rpx auto 0 auto;
  199. border-radius: 20rpx;
  200. }
  201. .flash-sale .header image {
  202. width: 100%;
  203. height: 100%;
  204. border-radius: 20rpx;
  205. }
  206. .flash-sale .seckillList {
  207. padding: 0 20rpx;
  208. }
  209. .flash-sale .seckillList .priceTag {
  210. width: 75rpx;
  211. height: 70rpx;
  212. }
  213. .flash-sale .seckillList .priceTag image {
  214. width: 100%;
  215. height: 100%;
  216. }
  217. .flash-sale .timeLsit {
  218. width: 610rpx;
  219. white-space: nowrap;
  220. margin: 10rpx 0;
  221. }
  222. .flash-sale .timeLsit .item {
  223. display: inline-block;
  224. font-size: 20rpx;
  225. color: #666;
  226. text-align: center;
  227. padding: 11rpx 0;
  228. box-sizing: border-box;
  229. height: 96rpx;
  230. margin-right: 35rpx;
  231. }
  232. .flash-sale .timeLsit .item .time {
  233. font-size: 36rpx;
  234. font-weight: 600;
  235. color: #333;
  236. }
  237. .flash-sale .timeLsit .item.on .time {
  238. color: var(--view-theme);
  239. }
  240. .flash-sale .timeLsit .item.on .state {
  241. width: 90rpx;
  242. height: 30rpx;
  243. border-radius: 15rpx;
  244. background: var(--view-theme);
  245. color: #fff;
  246. }
  247. .flash-sale .countDown {
  248. height: 92rpx;
  249. border-bottom: 1rpx solid #f0f0f0;
  250. margin-top: -14rpx;
  251. font-size: 28rpx;
  252. color: #282828;
  253. }
  254. .flash-sale .countDown .num {
  255. font-size: 28rpx;
  256. font-weight: bold;
  257. background-color: #ffcfcb;
  258. padding: 4rpx 7rpx;
  259. border-radius: 3rpx;
  260. }
  261. .flash-sale .countDown .text {
  262. font-size: 28rpx;
  263. color: #282828;
  264. margin-right: 13rpx;
  265. }
  266. .flash-sale .list .item {
  267. height: 230rpx;
  268. position: relative;
  269. width: 710rpx;
  270. margin: 0 auto 20rpx auto;
  271. background-color: #fff;
  272. border-radius: 20rpx;
  273. padding: 0 25rpx;
  274. }
  275. .flash-sale .list .item .pictrue {
  276. width: 180rpx;
  277. height: 180rpx;
  278. border-radius: 10rpx;
  279. }
  280. .flash-sale .list .item .pictrue image {
  281. width: 100%;
  282. height: 100%;
  283. border-radius: 10rpx;
  284. }
  285. .flash-sale .list .item .text {
  286. width: 460rpx;
  287. font-size: 30rpx;
  288. color: #333;
  289. height: 166rpx;
  290. }
  291. .flash-sale .list .item .text .name {
  292. width: 100%;
  293. }
  294. .flash-sale .list .item .text .money {
  295. font-size: 30rpx;
  296. color: #E93323;
  297. }
  298. .flash-sale .list .item .text .money .num {
  299. font-size: 40rpx;
  300. font-weight: 500;
  301. font-family: 'Guildford Pro';
  302. }
  303. .flash-sale .list .item .text .money .y_money {
  304. font-size: 24rpx;
  305. color: #999;
  306. text-decoration-line: line-through;
  307. margin-left: 15rpx;
  308. }
  309. .flash-sale .list .item .text .limit {
  310. font-size: 22rpx;
  311. color: #999;
  312. margin-bottom: 5rpx;
  313. }
  314. .flash-sale .list .item .text .limit .limitPrice {
  315. margin-left: 10rpx;
  316. }
  317. .flash-sale .list .item .text .progress {
  318. overflow: hidden;
  319. background-color: #FFEFEF;
  320. width: 260rpx;
  321. border-radius: 18rpx;
  322. height: 18rpx;
  323. position: relative;
  324. }
  325. .flash-sale .list .item .text .progress .bg-reds {
  326. width: 0;
  327. height: 100%;
  328. transition: width 0.6s ease;
  329. background: linear-gradient(90deg, rgba(233, 51, 35, 1) 0%, rgba(255, 137, 51, 1) 100%);
  330. }
  331. .flash-sale .list .item .text .progress .piece {
  332. position: absolute;
  333. left: 8%;
  334. transform: translate(0%, -50%);
  335. top: 49%;
  336. font-size: 16rpx;
  337. color: #FFB9B9;
  338. }
  339. .flash-sale .list .item .grab {
  340. font-size: 28rpx;
  341. color: #fff;
  342. width: 150rpx;
  343. height: 54rpx;
  344. border-radius: 27rpx;
  345. text-align: center;
  346. line-height: 54rpx;
  347. position: absolute;
  348. right: 30rpx;
  349. bottom: 30rpx;
  350. background: #bbbbbb;
  351. }
  352. .flash-sale .saleBox {
  353. width: 100%;
  354. height: 230rpx;
  355. background: var(--view-theme);
  356. border-radius: 0 0 50rpx 50rpx;
  357. }
  358. </style>