seckill.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <view class="seckill-section m-t" v-if="show" @click="navTo('/pages/hall/hall')">
  3. <view class="s-header" >
  4. <view class="f-left-icon"><image src="../../static/img/seckill-inco.png" mode=""></image></view>
  5. <view class="tit-box"><text class="tit">商品认购区</text></view>
  6. <!-- <view class="tip-box">
  7. <text class="tip" v-if="status == 1">{{ showTime }}点场结束</text>
  8. <text class="tip" v-if="status == 2">距离下场开始</text>
  9. <text class="tip" v-if="status == 0">当天活动已结束</text>
  10. <uni-countdown v-if="status == 1 || status == 2" :show-day="false" :hour="stopTimeH" :minute="stopTimeM" :second="stopTimeS"></uni-countdown>
  11. </view> -->
  12. <view class="textNav iconfont iconenter" >更多</view>
  13. </view>
  14. <view class="floor-list">
  15. <image src="../../static/img/cgg.png" mode=""></image>
  16. </view>
  17. <!-- <scroll-view class="floor-list" scroll-x>
  18. <view class="scoll-wrapper position-relative" @click="navTo('/pages/product/classify?type=2')">
  19. <view v-for="(item, index) in list" :key="index" class="floor-item">
  20. <image class="list-image" :src="item.image" mode="aspectFill"></image>
  21. <text class="title clamp">{{ item.title }}</text>
  22. <text class="price">¥{{ item.price }}</text>
  23. </view>
  24. <view v-if="list.length == 0" class="floor-item ">
  25. <image class="list-image" mode="aspectFill"></image>
  26. <text class="title clamp"></text>
  27. <text class="price"></text>
  28. </view>
  29. <view v-if="list.length == 0" class="noGoodsBg"><view>敬请期待</view></view>
  30. </view>
  31. </scroll-view> -->
  32. </view>
  33. </template>
  34. <script>
  35. import uniCountdown from '@/components/uni-countdown/uni-countdown.vue';
  36. import { getSeckillList, getSeckillClass,groomList } from '@/api/product.js';
  37. import { timeComputed } from '@/utils/rocessor.js';
  38. export default {
  39. components: {
  40. uniCountdown
  41. },
  42. data() {
  43. return {
  44. list: [],
  45. page: 1,
  46. limit: 10,
  47. showTime: '', //显示的时间
  48. showTImeId: '', //显示时间id用于查询数据
  49. stopTimeH: 0,
  50. stopTimeM: 0,
  51. stopTimeS: 0,
  52. // 判断是否所有活动已经结束
  53. stop: false, //活动是否已经结束
  54. show: false, //是否显示活动
  55. status: 0 //获取状态值1为有活动开始中 2为活动未开始 0为活动已经结束
  56. };
  57. },
  58. created: function(e) {
  59. // 载入分类
  60. this.getClass();
  61. },
  62. onLoad() {
  63. this.getList()
  64. },
  65. methods: {
  66. navTo(url) {
  67. uni.switchTab({
  68. url,
  69. success: () => {
  70. },fail: (err) => {
  71. console.log(err,'err');
  72. }
  73. });
  74. },
  75. getList() {
  76. groomList(
  77. {
  78. page: this.page,
  79. limit: this.limit
  80. },2
  81. )
  82. .then(res => {
  83. console.log(res,'eeee11');
  84. this.list = res.data.list;
  85. })
  86. .catch(e => {
  87. console.log(e);
  88. });
  89. },
  90. getClass() {
  91. let obj = this;
  92. getSeckillClass({})
  93. .then(({ data }) => {
  94. let arr = data.seckillTime;
  95. // 用于判断是否有数据
  96. let showDate = false;
  97. for (var i = 0; i < arr.length; i++) {
  98. let ar = arr[i];
  99. if (ar.status === 1 || ar.status === 2) {
  100. obj.status = ar.status;
  101. // 保存要显示的场次时间
  102. obj.showTime = ar.time;
  103. // 保存要显示活动商品的id
  104. obj.showTImeId = ar.id;
  105. // 保存当前状态值
  106. // 计算倒计时时间
  107. if (ar.status === 1) {
  108. obj.timeComputed(ar.stop * 1000);
  109. } else {
  110. // 获取需要开始
  111. let arTime = ar.time.split(':');
  112. let h = arTime[0];
  113. let m = arTime[1];
  114. let time = new Date();
  115. // 设置时间
  116. time.setHours(h, m, 0);
  117. obj.timeComputed(time.getTime());
  118. }
  119. // 获取商品列表
  120. obj.getList();
  121. // 保存当前有活动在举行
  122. showDate = true;
  123. // 任务查询结束跳出循环
  124. break;
  125. }
  126. }
  127. // 判断是否有活动
  128. if (arr.length > 0) {
  129. obj.show = true;
  130. }
  131. // 判断今天活动是否已经全部结束
  132. if (!showDate) {
  133. // 保存活动结束最后一个小时的活动商品
  134. obj.showTImeId = arr[arr.length - 1].id;
  135. // 活动已经结束
  136. obj.status = 0;
  137. // 获取结束时的商品
  138. obj.getList();
  139. console.log(obj.status);
  140. }
  141. // 如果所有场次均已经结束
  142. })
  143. .catch(e => {
  144. uni.showModal({
  145. title: JSON.stringify(e)
  146. });
  147. });
  148. },
  149. // 计算倒计时时间
  150. timeComputed(da) {
  151. let obj = this;
  152. let stopTime = timeComputed(da);
  153. obj.stopTimeH = stopTime.hours;
  154. obj.stopTimeM = stopTime.minutes;
  155. obj.stopTimeS = stopTime.seconds;
  156. }
  157. }
  158. };
  159. </script>
  160. <style lang="scss">
  161. /* 秒杀专区 */
  162. .seckill-section {
  163. padding: 4rpx 30rpx 24rpx;
  164. .s-header {
  165. display: flex;
  166. align-items: center;
  167. height: 92rpx;
  168. line-height: 1;
  169. .tit-box {
  170. margin-left: 6rpx;
  171. flex-shrink: 0;
  172. }
  173. .tit {
  174. @extend %font-title;
  175. }
  176. .f-left-icon {
  177. width: 36rpx;
  178. height: 36rpx;
  179. image{
  180. width: 100%;
  181. height: 100%;
  182. }
  183. }
  184. .textNav {
  185. line-height: 1;
  186. padding: 15rpx 0;
  187. flex-shrink: 0;
  188. flex-grow: 1;
  189. min-width: 100rpx;
  190. }
  191. .tip-box {
  192. flex-grow: 1;
  193. display: flex;
  194. justify-content: flex-start;
  195. align-items: center;
  196. }
  197. .tip {
  198. font-size: $font-sm;
  199. color: $font-color-light;
  200. padding-left: 10rpx;
  201. padding-right: 10rpx;
  202. }
  203. .timer {
  204. display: inline-block;
  205. width: 40rpx;
  206. height: 36rpx;
  207. text-align: center;
  208. line-height: 36rpx;
  209. margin-right: 14rpx;
  210. font-size: $font-sm + 2rpx;
  211. color: #fff;
  212. border-radius: 2px;
  213. background: rgba(0, 0, 0, 0.8);
  214. }
  215. .iconenter {
  216. font-size: $font-sm;
  217. color: $font-color-light;
  218. flex: 1;
  219. text-align: right;
  220. }
  221. }
  222. .floor-list {
  223. white-space: nowrap;
  224. background-color: white;
  225. padding: 20rpx;
  226. border-radius: 5rpx;
  227. box-shadow: $box-shadow;
  228. }
  229. image{
  230. width: 650rpx;
  231. height: 206rpx;
  232. border-radius: 10rpx;
  233. overflow: hidden;
  234. }
  235. .scoll-wrapper {
  236. display: flex;
  237. align-items: flex-start;
  238. .noGoodsBg {
  239. display: flex;
  240. align-items: center;
  241. justify-content: center;
  242. height: 100%;
  243. position: absolute;
  244. top: 0;
  245. left: 0;
  246. width: 100%;
  247. color: $font-color-light;
  248. }
  249. .floor-item {
  250. width: 150rpx;
  251. margin-right: 20rpx;
  252. font-size: $font-sm + 2rpx;
  253. color: $font-color-dark;
  254. line-height: 1.8;
  255. .list-image {
  256. width: 150rpx;
  257. height: 150rpx;
  258. border-radius: 6rpx;
  259. }
  260. .price {
  261. color: $color-red;
  262. }
  263. }
  264. }
  265. }
  266. </style>