app-index-miaosha.vue 11 KB

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