list.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <template>
  2. <view class="seckill-product-wrap">
  3. <!--活动广告-->
  4. <view class="top-box">
  5. <!--活动类别-->
  6. <view class="active-top-tab">
  7. <scroll-view scroll-X="true" show-scrollbar="false" class="scroll-X mb30">
  8. <view class="tab-list d-s-c">
  9. <view class="tab-item" :class="{ active: type_active == index }" v-for="(item, index) in activeList" :key="index"
  10. @click="tabTypeFunc(index)">
  11. {{ item.title }}
  12. </view>
  13. </view>
  14. </scroll-view>
  15. <view class="ad-activity" v-if="listData.detail">
  16. <image :src="listData.detail.file_path" mode=""></image>
  17. </view>
  18. <!--活动时间-->
  19. <view class="ad-datetime ww100 pt40 pb10 d-c-c" v-if="listData.detail">
  20. <Countdown ref='countdown' :config="countdownConfig" @returnVal="returnValFunc"></Countdown>
  21. </view>
  22. <view class="every-day-time d-c-c mb20">
  23. <text>每日活动时间:{{currActive.day_start_time}}至{{currActive.day_end_time}}</text>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="seckill-list-wrap" v-if="!loading">
  28. <scroll-view scroll-y="true" class="scroll-Y" :style="'height:' + scrollviewHigh + 'px;'" lower-threshold="50">
  29. <!--列表-->
  30. <view class="list p-0-20">
  31. <view class="item d-stretch" v-for="(item, index) in listData.list" :key="index">
  32. <view class="product-cover">
  33. <image :src="item.product.file_path" mode="aspectFit"></image>
  34. </view>
  35. <view class="d-b-c d-c flex-1 ml26">
  36. <view class="product-title ww100">{{ item.product.product_name }}</view>
  37. <view class="price ww100 red">
  38. <text class="f24">秒杀价:¥</text>
  39. <text class="num f36 fb">{{ item.seckill_price }}</text>
  40. <text class="ml20 text-d-line gray9 f24">¥{{ item.product_price }}</text>
  41. </view>
  42. <view class="slider-box ww100 d-b-c">
  43. <view class="left flex-1">
  44. <text class="already-sale">已抢购{{ item.product_sales }}件</text>
  45. <view class="slider">
  46. <view class="slider-inner" :style="'width:' + (item.product_sales / (item.product_sales + item.stock)) * 100 + '%;'"></view>
  47. </view>
  48. </view>
  49. <view class="right-btn ml30"><button type="primary" @click="gotoDetail(item.seckill_product_id)">马上抢</button></view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <!-- 没有记录 -->
  55. <view class="d-c-c p30" v-if="listData.length == 0 && !loading">
  56. <text class="iconfont icon-wushuju"></text>
  57. <text class="cont">亲,暂无相关记录哦</text>
  58. </view>
  59. </scroll-view>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. import Countdown from '@/components/countdown/countdown.vue';
  65. export default {
  66. components: {
  67. Countdown
  68. },
  69. data() {
  70. return {
  71. /*手机高度*/
  72. phoneHeight: 0,
  73. /*可滚动视图区域高度*/
  74. scrollviewHigh: 0,
  75. /*活动列表*/
  76. activeList: [],
  77. /*当前活动角标*/
  78. type_active: 0,
  79. /*类别选中*/
  80. currActive: {},
  81. /*产品列表*/
  82. listData: [],
  83. /*活动详情*/
  84. detailData: {},
  85. /*是否正在加载*/
  86. loading: true,
  87. /*倒计时配置*/
  88. countdownConfig: {
  89. /*开始时间*/
  90. startstamp: 0,
  91. /*结束时间*/
  92. endstamp: 0
  93. }
  94. };
  95. },
  96. computed: {},
  97. onShow() {
  98. this.getActive();
  99. },
  100. mounted() {
  101. this.init();
  102. },
  103. onPullDownRefresh() {},
  104. methods: {
  105. /*初始化*/
  106. init() {
  107. let _this = this;
  108. uni.getSystemInfo({
  109. success(res) {
  110. _this.phoneHeight = res.windowHeight;
  111. // 计算组件的高度
  112. let view = uni.createSelectorQuery().select('.top-box');
  113. view.boundingClientRect(data => {
  114. let h = _this.phoneHeight - data.height + 43;
  115. _this.scrollviewHigh = h;
  116. }).exec();
  117. }
  118. });
  119. },
  120. /*类别切换*/
  121. tabTypeFunc(e) {
  122. this.type_active = e;
  123. this.currActive = this.activeList[e];
  124. this.getData();
  125. },
  126. goback() {
  127. uni.navigateBack({
  128. })
  129. },
  130. /*获取活动类别*/
  131. getActive() {
  132. let self = this;
  133. let param = {};
  134. self.loading = true;
  135. self._get(
  136. 'plus.seckill.product/active', {
  137. param
  138. },
  139. function(res) {
  140. self.activeList = res.data.list;
  141. if (self.activeList && self.activeList.length > 0) {
  142. self.currActive = self.activeList[0];
  143. self.getData();
  144. }
  145. }
  146. );
  147. },
  148. /*获取数据*/
  149. getData() {
  150. let self = this;
  151. self.loading = true;
  152. self._get(
  153. 'plus.seckill.product/product', {
  154. seckill_activity_id: self.currActive.seckill_activity_id
  155. },
  156. function(res) {
  157. self.listData = res.data;
  158. self.countdownConfig.endstamp = res.data.detail.end_time;
  159. self.countdownConfig.startstamp = res.data.detail.start_time;
  160. uni.hideLoading();
  161. self.loading = false;
  162. }
  163. );
  164. },
  165. /*跳转产品详情*/
  166. gotoDetail(e) {
  167. this.$refs.countdown.clear();
  168. this.gotoPage('/pages/plus/seckill/detail/detail?seckill_product_id=' + e);
  169. },
  170. /*跳转搜索页面*/
  171. gotoSearch() {
  172. this.getData();
  173. },
  174. /*倒计时返回值*/
  175. returnValFunc(e) {
  176. }
  177. }
  178. };
  179. </script>
  180. <style lang="scss">
  181. page {
  182. background-color: #F2F2F2;
  183. }
  184. .top-box {
  185. position: relative;
  186. }
  187. .seckill-product-wrap .tab-item {
  188. flex: 0;
  189. padding: 0 30rpx;
  190. font-size: 33rpx;
  191. height: 86rpx;
  192. line-height: 86rpx;
  193. white-space: nowrap;
  194. color: #333333;
  195. }
  196. .seckill-product-wrap .tab-item.active {
  197. color: #F6220C;
  198. font-size: 33rpx;
  199. opacity: 1;
  200. position: relative;
  201. }
  202. .seckill-product-wrap .tab-item.active::after {
  203. content: "";
  204. width: 120rpx;
  205. height: 4rpx;
  206. background: #F6220C;
  207. border-radius: 2rpx;
  208. position: absolute;
  209. border: 30rpx;
  210. }
  211. .seckill-product-wrap .every-day-time text {
  212. padding: 8rpx 16rpx;
  213. font-size: 26rpx;
  214. color: #333;
  215. opacity: 0.5;
  216. }
  217. .seckill-product-wrap .ad-activity {
  218. position: relative;
  219. overflow: hidden;
  220. }
  221. .seckill-product-wrap .ad-activity image {
  222. width: 750rpx;
  223. height: 367rpx;
  224. border-radius: 12rpx;
  225. }
  226. .seckill-list-wrap {}
  227. .seckill-list-wrap .list .item {
  228. padding: 30rpx;
  229. display: flex;
  230. border-radius: 16rpx;
  231. margin-bottom: 20rpx;
  232. background: #ffffff;
  233. }
  234. .seckill-list-wrap .product-cover,
  235. .seckill-list-wrap .product-cover image {
  236. width: 200rpx;
  237. height: 200rpx;
  238. }
  239. .active-top-tab .ad-datetime::v-deep .box {
  240. height: 40rpx;
  241. padding: 4rpx;
  242. line-height: 40rpx;
  243. text-align: center;
  244. border-radius: 8rpx;
  245. font-size: 28rpx;
  246. background: #F6220C;
  247. color: #FFFFFF;
  248. }
  249. .active-top-tab .ad-datetime::v-deep text {
  250. color: #333;
  251. font-size: 28rpx;
  252. }
  253. .seckill-list-wrap .product-title {
  254. display: -webkit-box;
  255. overflow: hidden;
  256. -webkit-line-clamp: 2;
  257. -webkit-box-orient: vertical;
  258. font-size: 26rpx;
  259. }
  260. .seckill-list-wrap .already-sale {
  261. padding: 4rpx 0;
  262. color: #8228EB;
  263. font-size: 22rpx;
  264. }
  265. .seckill-list-wrap .slider-box .slider {
  266. margin-top: 11rpx;
  267. height: 8rpx;
  268. background: #F2F2F2;
  269. border-radius: 5rpx;
  270. }
  271. .seckill-list-wrap .slider-box .slider-inner {
  272. height: 8rpx;
  273. background: linear-gradient(-90deg, #CB2BFF 0%, #7727E7 100%);
  274. border-radius: 4rpx;
  275. }
  276. .seckill-list-wrap .right-btn button {
  277. background: linear-gradient(90deg, #FF6B6B 4%, #F6220C 100%);
  278. color: #ffffff;
  279. height: 60rpx;
  280. border-radius: 30rpx;
  281. line-height: 60rpx;
  282. }
  283. .reg180 {
  284. padding-right: 20rpx;
  285. text-align: right;
  286. transform: rotateY(180deg);
  287. position: absolute;
  288. bottom: 0;
  289. }
  290. .icon-jiantou {
  291. color: #FFFFFF;
  292. font-size: 30rpx;
  293. }
  294. .head_top {
  295. position: absolute;
  296. top: 0;
  297. z-index: 20;
  298. padding-top: var(--status-bar-height);
  299. height: 30px;
  300. line-height: 30px;
  301. color: #FFFFFF;
  302. font-size: 28rpx;
  303. }
  304. .tab-item.active::after {
  305. content: '';
  306. width: 60%;
  307. height: 4rpx;
  308. background: #F2F2F2;
  309. border-radius: 2rpx;
  310. position: absolute;
  311. bottom: 5rpx;
  312. }
  313. </style>