ms_goods.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <div class="module-item-goods" :style="!module.base.m ? 'margin-top:0' : ''" v-if="list.length>0">
  3. <div class="item-goods-con" :style="style">
  4. <view class="">
  5. <moduleBg :base="module.base" />
  6. <moduleTwtit :miaosha='miaosha' :type="module.type" :title="module.title" v-if="module.title.s" />
  7. </view>
  8. <div class="item-goods-style1" :class="module.base.s == 1 ? 'style2' : ''">
  9. <div class="scroll-true flex-grow-1">
  10. <div class="item" style="width: 30%;" v-for="(item, index) in list" :key="index"
  11. @click="$util.openMsGoods(list,index)">
  12. <div class="pic" style="height: auto;">
  13. <image style="width: 100%;height: 212upx;" class="pic_img" :src="url+item.thumb" />
  14. </div>
  15. <div class="c" style="padding: 0 5px;">
  16. <div class="tit" v-if="module.base.t.s">
  17. <moduleText :text="module.base.t" :name="item.name" />
  18. </div>
  19. <div class="price" v-if="module.base.sjg ">
  20. <template v-if="module.base.sjg">
  21. <span>
  22. <b>¥{{ item.price }}</b>
  23. </span>
  24. </template>
  25. </div>
  26. <div v-if="module.base.sgm">
  27. <span style="text-decoration:line-through;color: #999" class='ft24'>
  28. ¥{{item.original_price }}
  29. </span>
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. </div>
  35. <div class="noadd" v-if="list.length == 0">
  36. 暂无秒杀商品
  37. </div>
  38. </div>
  39. </div>
  40. </template>
  41. <script>
  42. import moduleBg from './bg.vue';
  43. import moduleText from './text.vue';
  44. import moduleTwtit from './twtit.vue';
  45. export default {
  46. props: ['module'],
  47. components: {
  48. moduleBg,
  49. moduleText,
  50. moduleTwtit
  51. },
  52. data() {
  53. return {
  54. url: getApp().globalData.URL,
  55. shopList: [],
  56. t: {},
  57. list: [],
  58. miaosha: {},
  59. };
  60. },
  61. computed: {
  62. style() {
  63. if (this.module.base.fc != '') {
  64. return `color:${this.module.base.fc}`;
  65. }
  66. },
  67. },
  68. mounted() {
  69. this.getGoodsList();
  70. },
  71. methods: {
  72. //获取商品列表
  73. getGoodsList() {
  74. // console.log(this.module, "获取商品列表")
  75. this.$http.request('seckill/index', {
  76. store_id: this.$store.state.store_id,
  77. controller: "admin",
  78. page: 1,
  79. limit: 8,
  80. }, "", "", "").then(t => {
  81. // console.log(t, "列表")
  82. if (t.code == 200) {
  83. var name = '',
  84. times = 0;
  85. var shopList = [];
  86. var timestamp = Date.parse(new Date()) / 1000; //当前时间
  87. if (t.data.start_time && t.data.end_time) {
  88. var s_time = t.data.start_time - timestamp;
  89. var end_time = t.data.end_time - timestamp;
  90. if (s_time > 0) {
  91. name = '活动未开始'
  92. times = s_time;
  93. }
  94. if (s_time < 0 && end_time > 0) {
  95. name = '活动进行中'
  96. times = end_time;
  97. }
  98. if (end_time < 0) {
  99. name = '活动已结束'
  100. times = 0;
  101. }
  102. var miaosha = {
  103. start_time: t.data.start_time,
  104. end_time: t.data.end_time,
  105. name: name,
  106. rest_time: times,
  107. }
  108. this.module.miaosha = miaosha;
  109. this.miaosha = miaosha;
  110. for (let i of t.data.list) {
  111. shopList.push({
  112. name: i.name,
  113. price: i.price,
  114. original_price: i.original_price,
  115. thumb: i.image_brief,
  116. id: i.id
  117. })
  118. }
  119. this.list = shopList;
  120. this.module.list = shopList;
  121. } else {
  122. var miaosha = {
  123. start_time: 0,
  124. end_time: 0,
  125. name: '活动已结束',
  126. rest_time: 0,
  127. }
  128. this.module.miaosha = miaosha;
  129. this.miaosha = miaosha;
  130. this.list = shopList;
  131. this.module.list = shopList;
  132. }
  133. // console.log(s_time, timestamp,this.module.miaosha,"this.module.miaosha")
  134. // console.log(this.module,"this.module.list")
  135. }
  136. }).catch((function(e) {}))
  137. },
  138. },
  139. };
  140. </script>
  141. <style>
  142. @import url("./goods.css");
  143. .module-item-goods {
  144. margin-top: 10px;
  145. }
  146. .scroll-true {
  147. white-space: nowrap;
  148. overflow-x: auto;
  149. }
  150. .scroll-true .item {
  151. display: inline-block;
  152. width: 30%;
  153. margin-right: 10px;
  154. }
  155. .el-scrollbar__wrap {
  156. overflow-y: hidden;
  157. }
  158. .pic_img {
  159. width: 106px;
  160. height: 106px;
  161. }
  162. .item-goods-style1 {
  163. position: relative;
  164. padding: 20rpx 0;
  165. }
  166. .noadd {
  167. position: relative;
  168. color: #999;
  169. }
  170. </style>