app-index-flash-sale.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. <template>
  2. <view class="index-advance">
  3. <view class="top dir-left-nowrap cross-center" @click="jump(`/plugins/flash_sale/index/index`)">
  4. <image class="box-grow-0" src="../../../static/image/icon/flash_sale.png"></image>
  5. <view class="box-grow-1 dir-left-nowrap">
  6. <view>限时抢购</view>
  7. <template v-if="timing && (newData.activity || newData.next_activity)">
  8. <view class="dir-left-nowrap time-box">
  9. <view class="main-center cross-center time">{{time_str.day}}</view>
  10. <view class="main-center cross-center maohao">:</view>
  11. <view class="main-center cross-center time">{{time_str.hou}}</view>
  12. <view class="main-center cross-center maohao">:</view>
  13. <view class="main-center cross-center time">{{time_str.min}}</view>
  14. <view class="main-center cross-center maohao">:</view>
  15. <view class="main-center cross-center time">{{time_str.sec}}</view>
  16. </view>
  17. <view :class="time_str ? 'box-grow-0' : 'box-grow-1'" style="color: #353535;margin-left: 10rpx;font-size: 22rpx;">{{newData.str}}</view>
  18. </template>
  19. </view>
  20. <view class="box-grow-0">
  21. <view class="dir-left-nowrap cross-center">
  22. <view class="box-grow-0 more">更多</view>
  23. <image class="box-grow-0 icon" src="../../../static/image/icon/arrow-right.png"></image>
  24. </view>
  25. </view>
  26. </view>
  27. <view v-if="style == '1'" class="dir-left-nowrap list">
  28. <block v-for="(item, key) in newData.list" :key="key">
  29. <view class="box-grow-0 item" @click="jump_router(item)" >
  30. <view class="cover-pic">
  31. <app-image :img-src="item.goodsWarehouse.cover_pic" width="220rpx" height="220rpx"></app-image>
  32. <view class="out-dialog" v-if="item.goods_stock == 0 && appSetting.is_show_stock == '1'">
  33. <image :src="appSetting.is_use_stock == '1' ? appImg.plugins_out : appSetting.sell_out_pic"></image>
  34. </view>
  35. <view class="title t-omit-two">
  36. {{item.name}}
  37. </view>
  38. <view class="des-price" :class="theme+ '-m-back ' + theme">
  39. {{item.discount_type == 1 ? item.min_discount + '折' : '减' + item.min_discount + '元'}}
  40. </view>
  41. </view>
  42. <view class="content dir-top-nowrap main-right">
  43. <view class="member-price" v-if="item.is_level == 1">
  44. <app-member-price :price="item.level_price"></app-member-price>
  45. </view>
  46. <app-sup-vip :is_vip_card_user="item.vip_card_appoint.is_vip_card_user"
  47. margin="4rpx 0 8rpx"
  48. v-if="item.vip_card_appoint.discount"
  49. :discount="item.vip_card_appoint.discount"></app-sup-vip>
  50. <view :class="theme+ '-m-text ' + theme" class="price">
  51. <text class="text">{{item.price_content}}</text>
  52. </view>
  53. <view class="old-price">
  54. ¥{{item.goodsWarehouse.original_price}}
  55. </view>
  56. </view>
  57. </view>
  58. </block>
  59. </view>
  60. <view v-if="style === '2'">
  61. <app-goods-list :theme="theme" :list="newData" sign="flash_sale"></app-goods-list>
  62. </view>
  63. </view>
  64. </template>
  65. <script>
  66. import {mapState, mapGetters} from 'vuex';
  67. import appGoodsList from "../app-goods-list/app-goods-list.vue";
  68. export default {
  69. name: "app-index-flash-sale",
  70. props: {
  71. theme: String,
  72. index: Number,
  73. page_id: Number,
  74. is_required: Boolean,
  75. pageHide: Boolean,
  76. },
  77. components: {
  78. appGoodsList
  79. },
  80. data() {
  81. return {
  82. newData: {},
  83. style: '1',
  84. goods_num: 20,
  85. time_str:{
  86. day: '00',
  87. hou: '00',
  88. min: '00',
  89. sec: '00'
  90. },
  91. timing: null,
  92. };
  93. },
  94. computed: {
  95. ...mapState({
  96. appImg: state => state.mallConfig.__wxapp_img.mall,
  97. appSetting: state => state.mallConfig.mall.setting,
  98. mall: state => state.mallConfig.mall,
  99. }),
  100. ...mapGetters('mallConfig',{
  101. vip: 'getVip'
  102. }),
  103. ...mapGetters('mallConfig', {
  104. getVideo: 'getVideo'
  105. })
  106. },
  107. methods: {
  108. jump(url) {
  109. uni.navigateTo({
  110. url: url
  111. });
  112. },
  113. jump_router(data) {
  114. // #ifndef MP-BAIDU
  115. if (data.goodsWarehouse.video_url && this.getVideo == 1) {
  116. uni.navigateTo({
  117. url: `/pages/goods/video?goods_id=${data.id}&sign=flash_sale`
  118. });
  119. } else {
  120. uni.navigateTo({
  121. url: `/plugins/flash_sale/goods/goods?id=${data.id}`
  122. })
  123. }
  124. // #endif
  125. // #ifdef MP-BAIDU
  126. uni.navigateTo({
  127. url: `/plugins/flash_sale/goods/goods?id=${data.id}`
  128. })
  129. // #endif
  130. },
  131. loadData() {
  132. let para = {
  133. type: this.page_id === 0 ? 'mall' : 'diy',
  134. key: 'flash_sale',
  135. page_id: this.page_id,
  136. index: this.index
  137. }
  138. if(this.goods_num) {
  139. para.goods_num = this.goods_num
  140. }
  141. this.$request({
  142. url: this.$api.index.extra,
  143. data: para
  144. }).then(e => {
  145. this.newData = e.data;
  146. if (this.newData.activity) {
  147. this.newData.str = '结束';
  148. this.set_time(this.newData.activity.end_at);
  149. } else {
  150. this.newData.str = '开始';
  151. this.set_time(this.newData.next_activity.start_at);
  152. }
  153. });
  154. },
  155. set_time(time_at) {
  156. clearInterval(this.timing);
  157. let time_str = new Date(time_at.replace(/-/g, '/'));
  158. this.now_time(time_str);
  159. this.timing = setInterval(() => {
  160. this.now_time(time_str);
  161. }, 1000);
  162. },
  163. now_time(time_str) {
  164. let time = time_str.getTime() - new Date().getTime();
  165. if (time < 0) {
  166. clearInterval(this.timing);
  167. this.timing = null;
  168. }
  169. let day = parseInt(time/1000/60/60/24);
  170. let hou = parseInt((time/1000/60/60)%24);
  171. let min = parseInt((time/1000/60)%60);
  172. let sec = parseInt((time/1000)%60);
  173. this.time_str.day = day < 10 ? '0' + day : day;
  174. this.time_str.hou = hou < 10 ? '0' + hou : hou;
  175. this.time_str.min = min < 10 ? '0' + min : min;
  176. this.time_str.sec = sec < 10 ? '0' + sec : sec;
  177. },
  178. },
  179. mounted() {
  180. let storage = this.$storage.getStorageSync('INDEX_MALL');
  181. this.style = storage.home_pages[this.index].style;
  182. this.goods_num = storage.home_pages[this.index].goods_num;
  183. this.loadData();
  184. },
  185. beforeDestroy() {
  186. clearInterval(this.timing);
  187. },
  188. watch: {
  189. pageHide: {
  190. handler(v) {
  191. if (v) {
  192. clearInterval(this.timing);
  193. return ;
  194. } else {
  195. if (this.newData.activity) {
  196. this.newData.str = '结束';
  197. this.set_time(this.newData.activity.end_at);
  198. } else if (this.newData.next_activity) {
  199. this.newData.str = '开始';
  200. this.set_time(this.newData.next_activity.start_at);
  201. }
  202. }
  203. },
  204. immediate: true
  205. },
  206. >>>>>>> dev
  207. },
  208. }
  209. </script>
  210. <style scoped lang="scss">
  211. .index-advance {
  212. background-color: #f7f7f7;
  213. margin-bottom: #{20upx};
  214. .top {
  215. padding: #{0 24rpx};
  216. color: #ff4544;
  217. font-size: $uni-font-size-general-one;
  218. height: #{72rpx};
  219. background-color: white;
  220. >image {
  221. width: #{46rpx};
  222. height: #{46rpx};
  223. display: block;
  224. margin-right: #{8rpx};
  225. background-color: #ff4544;
  226. }
  227. .more {
  228. font-size: $uni-font-size-general-two;
  229. margin-right: #{12rpx};
  230. color: $uni-general-color-two;
  231. }
  232. .icon {
  233. width: #{12rpx};
  234. height: #{22rpx};
  235. display: block;
  236. }
  237. }
  238. .list {
  239. overflow-x: auto;
  240. -webkit-overflow-scrolling: touch;
  241. background-color: #f7f7f7;
  242. margin-top: #{4rpx};
  243. .item {
  244. margin-right: #{4rpx};
  245. font-size: $uni-font-size-general-one;
  246. width: #{260rpx};
  247. padding: #{0 20rpx 20upx 20rpx};
  248. background-color: white;
  249. overflow: hidden;
  250. .cover-pic {
  251. width: #{220rpx};
  252. height: #{331upx};
  253. display: block;
  254. margin-top: #{20rpx};
  255. position: relative;
  256. .out-dialog {
  257. width: #{220rpx};
  258. height: #{220rpx};
  259. position: absolute;
  260. top: 0;
  261. left: 0;
  262. z-index: 10;
  263. will-change: transform;
  264. background-color: rgba(0,0,0,.5);
  265. image {
  266. width: #{220rpx};
  267. height: #{220rpx};
  268. }
  269. }
  270. }
  271. .title {
  272. width: #{224rpx};
  273. height: #{64rpx};
  274. font-size: #{25rpx};
  275. line-height: #{32upx};
  276. margin-top: #{10upx};
  277. color: $uni-important-color-black;
  278. }
  279. .content {
  280. height: calc(100% - #{355upx});
  281. }
  282. .member-price {
  283. height: #{28upx};
  284. margin-bottom: #{8upx};
  285. margin-top: #{4upx};
  286. }
  287. .price {
  288. font-size: 28upx;
  289. .text {
  290. text-overflow: ellipsis;
  291. -webkit-box-orient: vertical;
  292. -webkit-line-clamp: 1;
  293. overflow: hidden;
  294. line-height: 1;
  295. vertical-align: sub;
  296. }
  297. }
  298. .old-price {
  299. font-size: #{21upx};
  300. line-height: 1;
  301. color: #999999;
  302. text-decoration:line-through;
  303. margin: #{5upx 0 0upx 0};
  304. }
  305. .des-price {
  306. display: inline-block;
  307. font-size: #{19rpx};
  308. color: #ffffff;
  309. /*line-height: 1;*/
  310. border-radius: #{7rpx};
  311. padding: #{0rpx 5rpx};
  312. word-break: break-all;
  313. text-overflow: ellipsis;
  314. -webkit-box-orient: vertical;
  315. -webkit-line-clamp: 1;
  316. overflow: hidden;
  317. margin: #{4upx 0};
  318. }
  319. }
  320. }
  321. }
  322. .time-box {
  323. margin-left: #{23rpx};
  324. .time {
  325. width: #{32rpx};
  326. height: #{34rpx};
  327. background-color: #4c4c4c;
  328. color: #ffffff;
  329. font-size: #{20rpx};
  330. border-radius: #{4rpx};
  331. }
  332. .maohao {
  333. width: #{20rpx};
  334. height: #{34rpx};
  335. color: #353535;
  336. }
  337. }
  338. </style>