SeckillGood.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <view class="limitCard" v-if="currSeckill && currSeckill.length > 0">
  3. <view class="limitCard_top">
  4. <view class="limitCard_top_title">限时秒杀</view>
  5. <view class="limitCard_top_lab">{{ currTime }}点场 剩余</view>
  6. <!-- <view class="limitCard_top_time">3天 17 : 26 : 35</view> -->
  7. <view class="limitCard_top_time" v-if="finishTime">
  8. <uv-count-down
  9. :time="finishTime"
  10. format="DD:HH:mm:ss"
  11. autoStart
  12. millisecond
  13. @change="onChange"
  14. @finish="onFinish"
  15. >
  16. <view class="time">
  17. <text class="time__item" v-if="timeData.days"
  18. >{{ timeData.days }}天</text
  19. >
  20. <text class="time__item"
  21. >{{
  22. timeData.hours > 10 ? timeData.hours : "0" + timeData.hours
  23. }}:</text
  24. >
  25. <text class="time__item"
  26. >{{
  27. timeData.minutes > 10
  28. ? timeData.minutes
  29. : "0" + timeData.minutes
  30. }}:</text
  31. >
  32. <text class="time__item">{{ timeData.seconds }}</text>
  33. </view>
  34. </uv-count-down>
  35. </view>
  36. </view>
  37. <swiper
  38. class="swiper"
  39. indicator-color="#EDEDED"
  40. indicator-active-color="#3775F6"
  41. circular
  42. :indicator-dots="true"
  43. :autoplay="false"
  44. :interval="2000"
  45. :duration="500"
  46. >
  47. <swiper-item v-for="(item, key) in currSeckill" :key="key">
  48. <view class="listBox">
  49. <view
  50. class="listBox_item"
  51. v-for="itemSon in item"
  52. @click="
  53. goProductDetails('/pages/seckill/seckillGoods?id=' + itemSon.id)
  54. "
  55. :key="itemSon.id"
  56. >
  57. <!-- ?x-oss-process=style/w_350 -->
  58. <image
  59. v-if="itemSon && itemSon.coverImage"
  60. :src="`${itemSon.coverImage}`"
  61. mode=""
  62. >
  63. </image>
  64. <!-- <view>¥<text>64.</text>20</view> -->
  65. <view class="">
  66. <rich-text
  67. :nodes="$mUtil.priceBigSmall(itemSon.minPrice)"
  68. ></rich-text>
  69. </view>
  70. </view>
  71. </view>
  72. </swiper-item>
  73. </swiper>
  74. </view>
  75. </template>
  76. <script setup>
  77. import { ref, onMounted } from "vue";
  78. import { seckillActivityProductFlash_Api } from "@/api/seckill.js";
  79. const props = defineProps({
  80. businessId: {
  81. type: [Number, String],
  82. default: "",
  83. },
  84. });
  85. const currSeckill = ref([]);
  86. const currTime = ref(0);
  87. const timeData = ref({});
  88. const finishTime = ref(0);
  89. const onChange = (e) => {
  90. timeData.value = e;
  91. };
  92. const onFinish = () => {
  93. seckillActivityProductFlash();
  94. };
  95. // 一维数组转二维数组
  96. const oneArrToTwoArr = (data = []) => {
  97. let newData = [];
  98. let zyf = 4; //一维数组转二维数组长度(此处是二维数组每一个长度控制)
  99. for (let i = 0; i < Math.ceil(data.length / zyf); i++) {
  100. newData[i] = [];
  101. newData[i].push(data[i * zyf]);
  102. for (let j = 1; j < zyf; j++) {
  103. if (data[i * zyf + j] == undefined) {
  104. //超出长度控住
  105. return newData;
  106. } else {
  107. newData[i].push(data[i * zyf + j]);
  108. }
  109. }
  110. }
  111. return newData;
  112. };
  113. const seckillActivityProductFlash = () => {
  114. seckillActivityProductFlash_Api({
  115. businessId: props.businessId,
  116. limit: 10,
  117. }).then((res) => {
  118. // console.log(res);
  119. if (res.code == 200) {
  120. currSeckill.value = res.data.list ? oneArrToTwoArr(res.data.list || []) : [];
  121. currTime.value = res.data.startHour;
  122. // finishTime.value = res.data.finishTime;
  123. if (res.data.finishTime) {
  124. finishTime.value = res.data.finishTime - new Date().getTime();
  125. }else{
  126. finishTime.value = 0;
  127. }
  128. }
  129. });
  130. };
  131. const goProductDetails = (url) => {
  132. uni.navigateTo({
  133. url,
  134. });
  135. };
  136. onMounted(() => {
  137. seckillActivityProductFlash();
  138. });
  139. defineExpose({
  140. init: seckillActivityProductFlash,
  141. });
  142. </script>
  143. <style lang="scss" scoped>
  144. .limitCard {
  145. margin: auto;
  146. // width: 720rpx;
  147. height: 410rpx;
  148. padding: 0 30rpx;
  149. // background: url("/static/convenienceService/cardBg.png") 0 0 no-repeat;
  150. background-size: 720rpx 410rpx;
  151. box-sizing: border-box;
  152. .limitCard_top {
  153. display: flex;
  154. padding: 35rpx 30rpx 20rpx 30rpx;
  155. align-items: center;
  156. border-bottom: 1rpx solid #e6e6e6;
  157. .limitCard_top_title {
  158. font-size: 36rpx;
  159. color: #1a1a1a;
  160. font-weight: 700;
  161. display: flex;
  162. align-items: center;
  163. position: relative;
  164. padding-right: 15rpx;
  165. &::after {
  166. display: block;
  167. content: "";
  168. width: 1rpx;
  169. height: 33rpx;
  170. background: #707070;
  171. position: absolute;
  172. right: 0;
  173. top: 10rpx;
  174. }
  175. }
  176. .limitCard_top_lab {
  177. font-size: 24rpx;
  178. color: #666666;
  179. margin: 0 30rpx 0 15rpx;
  180. }
  181. .limitCard_top_time {
  182. border-radius: 17rpx;
  183. background: #ff0000;
  184. font-size: 24rpx;
  185. color: #fff;
  186. font-weight: 700;
  187. padding: 0 15rpx;
  188. }
  189. }
  190. .swiper {
  191. height: 280rpx;
  192. .listBox {
  193. padding: 25rpx 20rpx;
  194. display: flex;
  195. box-sizing: border-box;
  196. .listBox_item {
  197. margin-right: 20rpx;
  198. image {
  199. width: 140rpx;
  200. height: 140rpx;
  201. }
  202. > view {
  203. width: 140rpx;
  204. font-size: 20rpx;
  205. color: #333333;
  206. text-align: center;
  207. text {
  208. font-size: 28rpx;
  209. font-weight: 600;
  210. display: inline-block;
  211. margin-left: 10rpx;
  212. }
  213. }
  214. &:last-child {
  215. margin-right: 0 !important;
  216. }
  217. }
  218. }
  219. }
  220. }
  221. </style>