seck.vue 6.7 KB

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