GoodsSeckill.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <div class="flash-sale" ref="container">
  3. <div class="saleBox">
  4. <div class="header" v-if="timeList[active]">
  5. <img :src="timeList[active].slide" />
  6. </div>
  7. </div>
  8. <div class="logoPic">
  9. <img src="../../assets/images/baokuan.png" />
  10. </div>
  11. <Tabs
  12. class="time-tabs"
  13. line-height="0"
  14. v-model="active"
  15. animated
  16. title-inactive-color="2"
  17. sticky
  18. ref="timeList"
  19. >
  20. <Tab v-for="(item, index) in timeList" :key="index">
  21. <div slot="title" class="timeItem" @click="setTime(index)">
  22. <div class="time">{{ item.time }}</div>
  23. <div class="state">{{ item.state }}</div>
  24. </div>
  25. <!--<div class="countDown font-color-red acea-row row-center-wrapper">-->
  26. <!--<div v-if="item.status === 0" class="activity">活动已结束</div>-->
  27. <!--<CountDown-->
  28. <!--:is-day="false"-->
  29. <!--:tip-text="'距结束仅剩 '"-->
  30. <!--:day-text="''"-->
  31. <!--:hour-text="' : '"-->
  32. <!--:minute-text="' : '"-->
  33. <!--:second-text="''"-->
  34. <!--:datatime="datatime"-->
  35. <!--v-if="item.status === 1"-->
  36. <!--&gt;</CountDown>-->
  37. <!--<div v-if="item.status === 2" class="activity">活动即将开始</div>-->
  38. <!--</div>-->
  39. <div class="list">
  40. <div
  41. class="item acea-row row-between-wrapper"
  42. v-for="(itemSeckill, indexSeckill) in seckillList"
  43. :key="indexSeckill"
  44. @click="goDetail(itemSeckill.id, item.status)"
  45. >
  46. <div class="pictrue">
  47. <img :src="itemSeckill.image" />
  48. </div>
  49. <div class="text acea-row row-column-around">
  50. <div class="line1" v-text="itemSeckill.title"></div>
  51. <div class="money">
  52. <span
  53. class="num font-color-red"
  54. v-text="'¥' + itemSeckill.price"
  55. ></span>
  56. <span
  57. v-text="'¥' + itemSeckill.ot_price"
  58. class="ot_price"
  59. ></span>
  60. </div>
  61. <div class="stock">
  62. 限量<span v-text="itemSeckill.stock + '件'"></span>
  63. </div>
  64. <div class="progress">
  65. <div
  66. class="bg-red"
  67. :style="{
  68. width: loading ? itemSeckill.percent + '%' : ''
  69. }"
  70. ></div>
  71. <div
  72. class="piece"
  73. v-text="'已抢' + itemSeckill.percent + '%'"
  74. ></div>
  75. </div>
  76. </div>
  77. <div
  78. class="grab bg-color-red"
  79. v-if="item.status === 1 && itemSeckill.quota > 0"
  80. >
  81. 马上抢
  82. </div>
  83. <div
  84. class="grab bg-color-hui"
  85. v-if="item.status === 1 && itemSeckill.quota <= 0"
  86. >
  87. 已售磬
  88. </div>
  89. <div class="grab bg-color-red" v-if="item.status === 2">
  90. 未开始
  91. </div>
  92. <div class="grab bg-color-hui" v-if="item.status === 0">
  93. 已结束
  94. </div>
  95. </div>
  96. </div>
  97. <div
  98. class="noCommodity"
  99. v-cloak
  100. v-if="!status || (seckillList.length === 0 && page > 1)"
  101. >
  102. <div class="noPictrue">
  103. <img src="@assets/images/noGood.png" class="image" />
  104. </div>
  105. </div>
  106. <Loading
  107. :loaded="status"
  108. :loading="loadingList"
  109. v-if="seckillList.length > 0"
  110. ></Loading>
  111. </Tab>
  112. </Tabs>
  113. <div id="title0"></div>
  114. <div id="title1"></div>
  115. <div id="title2"></div>
  116. </div>
  117. </template>
  118. <script>
  119. import { getSeckillConfig, getSeckillList } from "@api/activity";
  120. //import CountDown from "@components/CountDown";
  121. import { Tab, Tabs } from "vant";
  122. import Loading from "@components/Loading";
  123. export default {
  124. name: "GoodsSeckill",
  125. components: {
  126. // CountDown,
  127. Tab,
  128. Tabs,
  129. Loading
  130. },
  131. props: {},
  132. data: function() {
  133. return {
  134. timeList: [],
  135. stickys: false,
  136. loading: false,
  137. datatime: 0,
  138. active: 0,
  139. seckillList: [],
  140. status: false, //砍价列表是否获取完成 false 未完成 true 完成
  141. loadingList: false, //当前接口是否请求完成 false 完成 true 未完成
  142. page: 1, //页码
  143. limit: 20 //数量
  144. };
  145. },
  146. mounted: function() {
  147. this.mountedStart();
  148. },
  149. methods: {
  150. mountedStart: function() {
  151. var that = this;
  152. getSeckillConfig().then(res => {
  153. that.$set(that, "timeList", res.data.seckillTime);
  154. that.$set(that, "active", res.data.seckillTimeIndex);
  155. that.datatime = that.timeList[that.active].stop;
  156. that.getSeckillList();
  157. that.$nextTick(function() {
  158. that.stickys = true;
  159. that.$refs.timeList.scrollIntoView();
  160. });
  161. });
  162. this.$scroll(this.$refs.container, () => {
  163. !this.loadingList && this.getSeckillList();
  164. });
  165. setTimeout(function() {
  166. that.loading = true;
  167. }, 500);
  168. },
  169. setTime: function(index) {
  170. var that = this;
  171. that.active = index;
  172. that.datatime = that.timeList[that.active].stop;
  173. that.seckillList = [];
  174. that.page = 1;
  175. that.status = false;
  176. that.getSeckillList();
  177. },
  178. getSeckillList: function() {
  179. var that = this;
  180. if (that.loadingList) return;
  181. if (that.status) return;
  182. that.loadingList = true;
  183. var time = that.timeList[that.active].id;
  184. getSeckillList(time, { page: that.page, limit: that.limit })
  185. .then(res => {
  186. that.status = res.data.length < that.limit;
  187. that.seckillList.push.apply(that.seckillList, res.data);
  188. that.page++;
  189. that.loadingList = false;
  190. })
  191. .catch(() => {
  192. that.loadingList = false;
  193. });
  194. },
  195. goDetail: function(id, status) {
  196. var that = this;
  197. var time = that.timeList[that.active].stop;
  198. this.$router.push({
  199. path: "/activity/seckill_detail/" + id + "/" + time + "/" + status
  200. });
  201. }
  202. }
  203. };
  204. </script>
  205. <style scoped>
  206. .saleBox {
  207. width: 100%;
  208. height: 2.54rem;
  209. background: #ff1f44;
  210. opacity: 1;
  211. border-radius: 0 0 0.5rem 0.5rem;
  212. padding: 0.24rem 0.2rem 0 0.2rem;
  213. box-sizing: border-box;
  214. }
  215. .header {
  216. width: 100%;
  217. height: 3rem;
  218. box-sizing: border-box;
  219. margin-top: 0.4rem;
  220. border-radius: 0.2rem 0.2rem 0 0;
  221. overflow: hidden;
  222. background: #f5f5f5;
  223. }
  224. .header img {
  225. width: 100%;
  226. height: 100%;
  227. border-radius: 0.2rem;
  228. overflow: hidden;
  229. }
  230. .logoPic {
  231. width: 0.75rem;
  232. height: 0.7rem;
  233. position: absolute;
  234. top: 3.9rem;
  235. z-index: 9999;
  236. left: 3.5%;
  237. }
  238. .logoPic img {
  239. width: 100%;
  240. height: 100%;
  241. }
  242. .timeItem {
  243. font-size: 0.22rem;
  244. color: #333;
  245. width: 100%;
  246. text-align: center;
  247. background-color: #f5f5f5;
  248. padding: 0.21rem 0 0.28rem 0;
  249. }
  250. .flash-sale {
  251. height: 100%;
  252. background: #f5f5f5 !important;
  253. }
  254. .time-tabs {
  255. background: #f5f5f5;
  256. top: 1.1rem;
  257. }
  258. .time-tabs.van-tabs--line {
  259. padding: 0;
  260. background: #f5f5f5;
  261. }
  262. .timeItem .time {
  263. font-size: 0.36rem;
  264. font-weight: bold;
  265. height: 0.5rem;
  266. line-height: 0.5rem;
  267. }
  268. .timeItem .state {
  269. height: 0.3rem;
  270. line-height: 0.3rem;
  271. font-size: 0.2rem;
  272. width: auto;
  273. margin: auto;
  274. }
  275. .activity {
  276. color: #333;
  277. }
  278. .list {
  279. padding: 0 0.2rem;
  280. }
  281. .stock {
  282. color: #999999;
  283. font-size: 0.22rem;
  284. margin-bottom: 0.08rem;
  285. }
  286. .ot_price {
  287. text-decoration: line-through;
  288. color: #999999;
  289. font-size: 0.24rem;
  290. }
  291. .flash-sale .list .item .grab {
  292. background-color: #999;
  293. }
  294. </style>