app-index-miaosha.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <view class="app-index-miaosha">
  3. <view class="dir-left-nowrap cross-center top">
  4. <image class="box-grow-0 img" src="../../../static/image/icon/icon-home-miaosha.png"></image>
  5. <view class="box-grow-0 text1">整点秒杀</view>
  6. <template v-if="newData.open_date">
  7. <view :class="timer ? 'box-grow-0' : 'box-grow-1'">{{newData.str}}</view>
  8. <view class="box-grow-1 dir-left-nowrap time-box" v-if="timer">
  9. <view class="main-center cross-center time">{{timer.hour}}</view>
  10. <view class="main-center cross-center maohao">:</view>
  11. <view class="main-center cross-center time">{{timer.min}}</view>
  12. <view class="main-center cross-center maohao">:</view>
  13. <view class="main-center cross-center time">{{timer.sec}}</view>
  14. </view>
  15. </template>
  16. <view class="box-grow-0">
  17. <app-form-id @click="jump(`/plugins/miaosha/advance/advance`)">
  18. <view class="dir-left-nowrap cross-center">
  19. <view class="box-grow-0 more">更多</view>
  20. <image class="box-grow-0 icon" src="../../../static/image/icon/arrow-right.png"></image>
  21. </view>
  22. </app-form-id>
  23. </view>
  24. </view>
  25. <view class="dir-left-nowrap list">
  26. <block v-for="(miaosha, key) in newData.list" :key="key">
  27. <app-form-id @click="router_jump(miaosha)">
  28. <view class="box-grow-0 dir-top-nowrap item">
  29. <view class="box-grow-0 cover-pic">
  30. <view class="out-dialog" v-if="miaosha.goods_stock == 0 && appSetting.is_show_stock == '1'">
  31. <image :src="appSetting.is_use_stock == '1' ? appImg.plugins_out : appSetting.sell_out_pic"></image>
  32. </view>
  33. <app-image :img-src="miaosha.cover_pic" width="220rpx" height="220rpx"></app-image>
  34. </view>
  35. <view class="box-grow-0 t-omit-two goods-name">{{miaosha.name}}</view>
  36. <view class="box-grow-1 dir-top-nowrap main-right">
  37. <view v-if="miaosha.is_level == 1">
  38. <app-member-price :price="miaosha.level_price"></app-member-price>
  39. </view>
  40. <app-sup-vip :is_vip_card_user="miaosha.vip_card_appoint.is_vip_card_user" margin="4rpx 0 0" v-if="miaosha.vip_card_appoint.discount > 0" :discount="miaosha.vip_card_appoint.discount"></app-sup-vip>
  41. <view :class="theme + '-color'">{{miaosha.price_content}}</view>
  42. </view>
  43. </view>
  44. </app-form-id>
  45. </block>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import {mapState, mapGetters} from 'vuex';
  51. import appMemberPrice from "../app-member-mark/app-member-price.vue";
  52. import appSupVip from '../app-sup-vip/app-sup-vip.vue';
  53. import routeJump from '../../../core/routeJump.js';
  54. export default {
  55. name: "app-index-miaosha",
  56. components: {
  57. 'app-member-price': appMemberPrice,
  58. 'app-sup-vip': appSupVip,
  59. },
  60. props: {
  61. value: {
  62. type: Object,
  63. default() {
  64. return {
  65. open_date: null,
  66. list: []
  67. };
  68. }
  69. },
  70. pageHide: Boolean,
  71. },
  72. data() {
  73. return {
  74. newData: this.value,
  75. timer: null,
  76. time: null,
  77. is_vip: true,
  78. };
  79. },
  80. computed: {
  81. ...mapState({
  82. mall: state => state.mallConfig.mall,
  83. appSetting: state => state.mallConfig.mall.setting,
  84. appImg: state => state.mallConfig.__wxapp_img.mall,
  85. theme: state => state.mallConfig.theme
  86. }),
  87. ...mapGetters('mallConfig', {
  88. getVideo: 'getVideo'
  89. }),
  90. },
  91. beforeDestroy() {
  92. clearInterval(this.time);
  93. },
  94. watch: {
  95. pageHide: {
  96. handler(v) {
  97. if (v) {
  98. clearInterval(this.time);
  99. return ;
  100. }
  101. let timenow = new Date();//获取当前时间
  102. if ((new Date(this.newData.open_date)).getDate() != timenow.getDate()) {
  103. this.newData.str = '预告 ' + this.newData.open_date + ' ' + this.newData.open_time + '点场';
  104. } else if (this.newData.open_time != timenow.getHours()) {
  105. this.newData.str = '预告 ' + this.newData.open_time + '点场';
  106. } else {
  107. let timelog = this.newData.date_time * 1000 - timenow.getTime();//时间差的所有毫秒数
  108. this.time = setInterval(() => {
  109. // console.log('首页秒杀');
  110. timelog -= 1000;
  111. this.newData.str = this.newData.open_time + '点场';
  112. if (timelog <= 0) {
  113. clearInterval(this.time);
  114. return;
  115. }
  116. let hour = parseInt((timelog / 1000 / 60 / 60));
  117. let min = parseInt((timelog / 1000 / 60) % 60);
  118. let sec = parseInt((timelog / 1000) % 60);
  119. this.timer = {
  120. hour: hour < 10 ? "0" + hour : hour,
  121. min: min < 10 ? "0" + min : min,
  122. sec: sec < 10 ? "0" + sec : sec
  123. };
  124. }, 1000);
  125. }
  126. },
  127. immediate: true
  128. },
  129. },
  130. methods: {
  131. jump(url) {
  132. routeJump({
  133. open_type: 'navigate',
  134. page_url: url,
  135. params: []
  136. })
  137. },
  138. router_jump(data) {
  139. // #ifndef MP-BAIDU
  140. if (data.video_url && this.getVideo == 1) {
  141. uni.navigateTo({
  142. url: `/pages/goods/video?goods_id=${data.id}&sign=miaosha`
  143. });
  144. } else {
  145. uni.navigateTo({
  146. url: data.page_url
  147. });
  148. }
  149. // #endif
  150. // #ifdef MP-BAIDU
  151. uni.navigateTo({
  152. url: data.page_url
  153. });
  154. // #endif
  155. }
  156. }
  157. }
  158. </script>
  159. <style scoped lang="scss">
  160. .more {
  161. font-size: $uni-font-size-general-two;
  162. margin-right: #{12rpx};
  163. color: $uni-general-color-two;
  164. }
  165. .icon {
  166. width: #{12rpx};
  167. height: #{22rpx};
  168. display: block;
  169. }
  170. .app-index-miaosha {
  171. background-color: $uni-weak-color-two;
  172. .top {
  173. height: #{80rpx};
  174. padding: 0 #{24rpx};
  175. background-color: #ffffff;
  176. font-size: $uni-font-size-weak-one;
  177. .img {
  178. width: #{46rpx};
  179. height: #{46rpx};
  180. display: block;
  181. margin-right: #{16rpx};
  182. }
  183. .text1 {
  184. color: #ff8831;
  185. font-size: $uni-font-size-general-one;
  186. margin-right: #{20rpx};
  187. }
  188. .time-box {
  189. margin-left: #{23rpx};
  190. .time {
  191. width: #{32rpx};
  192. height: #{34rpx};
  193. background-color: #4c4c4c;
  194. color: #ffffff;
  195. font-size: #{20rpx};
  196. border-radius: #{4rpx};
  197. }
  198. .maohao {
  199. width: #{20rpx};
  200. height: #{34rpx};
  201. }
  202. }
  203. }
  204. .list {
  205. margin-top: #{8rpx};
  206. overflow-x: auto;
  207. -webkit-overflow-scrolling: touch;
  208. .item {
  209. background-color: #ffffff;
  210. margin-right: #{8rpx};
  211. font-size: $uni-font-size-general-one;
  212. padding: #{20rpx} #{20rpx} #{24rpx} #{20rpx};
  213. height: 100%;
  214. border-radius: #{8rpx};
  215. .cover-pic {
  216. width: #{220rpx};
  217. height: #{220rpx};
  218. display: block;
  219. margin-bottom: #{20rpx};
  220. .out-dialog {
  221. width: #{220rpx};
  222. height: #{220rpx};
  223. position: absolute;
  224. top: #{20rpx};
  225. left: #{20rpx};
  226. z-index: 10;
  227. background-color: rgba(0,0,0,.5);
  228. image {
  229. width: #{220rpx};
  230. height: #{220rpx};
  231. }
  232. }
  233. }
  234. .goods-name {
  235. width: #{220rpx};
  236. font-size: $uni-font-size-general-two;
  237. }
  238. .price {
  239. text-decoration: line-through;
  240. color: $uni-general-color-two;
  241. margin-bottom: #{15rpx};
  242. font-size: $uni-font-size-weak-one;
  243. &:before {
  244. content: '¥';
  245. }
  246. }
  247. }
  248. }
  249. }
  250. </style>