list.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <template>
  2. <view class="bargain-container">
  3. <view class="top-box">
  4. <view class="inner-tab">
  5. <scroll-view scroll-X="true" show-scrollbar="false" class="scroll-X">
  6. <view class="tab-list">
  7. <view :class="bargain_activity_id == item.bargain_activity_id ? 'item active' : 'item'" v-for="(item, index) in categorys"
  8. :key="index" @click="tabTypeFunc(index, item.bargain_activity_id)">
  9. {{ item.title }}
  10. </view>
  11. </view>
  12. </scroll-view>
  13. </view>
  14. <!--图片-->
  15. <view class="banner-image d-c-c" v-if="listData.detail">
  16. <image :src="listData.detail.file_path" mode="widthFix"></image>
  17. </view>
  18. <!--活动时间-->
  19. <view class="ad-datetime p-30-0 d-c-c pb0" v-if="listData.detail">
  20. <Countdown ref='countdown' :config="countdownConfig" @returnVal="returnValFunc"></Countdown>
  21. </view>
  22. </view>
  23. <!--内容-->
  24. <view class="bargain-list" v-if="!loading">
  25. <scroll-view scroll-y="true" class="scroll-Y" :style="'height:' + scrollviewHigh + 'px;'" lower-threshold="50">
  26. <!--列表-->
  27. <view class="list d-s-c f-w">
  28. <view class="item d-s-s d-stretch" v-for="(item, index) in listData.list" :key="index">
  29. <view class="product-cover pr">
  30. <image :src="item.product.file_path" mode="aspectFit"></image>
  31. </view>
  32. <view class="product-info d-b-c d-c">
  33. <view class="product-title text-ellipsis-2 f26 gray3">{{ item.product.product_name }}</view>
  34. <view class="people-num price">
  35. <text class="f24">¥</text>
  36. <text class="f36 fb">{{ item.bargain_price }}</text>
  37. <text class="ml10 text-d-line gray9 f24">¥{{ item.product_price }}</text>
  38. </view>
  39. <view class="d-b-c ww100">
  40. <view class="f24">
  41. </view>
  42. <view class="right-btn"><button type="primary" @click="gotoDetail(item)">去砍价</button></view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </scroll-view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import Countdown from '@/components/countdown/countdown.vue'
  53. export default {
  54. components: {
  55. Countdown
  56. },
  57. data() {
  58. return {
  59. /*手机高度*/
  60. phoneHeight: 0,
  61. /*可滚动视图区域高度*/
  62. scrollviewHigh: 0,
  63. /*活动类别*/
  64. categorys: [],
  65. /*当前活动Is*/
  66. bargain_activity_id: 0,
  67. /*商品列表*/
  68. listData: [],
  69. /*倒计时配置*/
  70. countdownConfig: {
  71. /*开始时间*/
  72. startstamp: 0,
  73. /*结束时间*/
  74. endstamp: 0
  75. },
  76. /*是否正在加载*/
  77. loading: true
  78. };
  79. },
  80. computed: {},
  81. onLoad(e) {},
  82. onShow() {
  83. /*获取产品列表*/
  84. this.getCategory();
  85. },
  86. mounted() {
  87. this.init();
  88. },
  89. onReachBottom() {},
  90. methods: {
  91. /*初始化*/
  92. init() {
  93. let _this = this;
  94. uni.getSystemInfo({
  95. success(res) {
  96. _this.phoneHeight = res.windowHeight;
  97. // 计算组件的高度
  98. let view = uni.createSelectorQuery().select('.top-box');
  99. view.boundingClientRect(data => {
  100. let h = _this.phoneHeight - data.height;
  101. _this.scrollviewHigh = h;
  102. }).exec();
  103. }
  104. });
  105. },
  106. /*类别切换*/
  107. tabTypeFunc(e, n) {
  108. this.type_active = e;
  109. this.bargain_activity_id = n;
  110. this.productList = [];
  111. this.getProdct();
  112. },
  113. /*获取数据*/
  114. getCategory() {
  115. let self = this;
  116. let param = {};
  117. let index = self.type_active;
  118. self._get('plus.bargain.product/active', {
  119. param
  120. }, function(res) {
  121. self.categorys = res.data.list;
  122. self.bargain_activity_id = self.categorys[0].bargain_activity_id;
  123. self.getProdct();
  124. });
  125. },
  126. /*获取商品*/
  127. getProdct() {
  128. let self = this;
  129. uni.showLoading({
  130. title: '加载中'
  131. });
  132. let bargain_activity_id = self.bargain_activity_id;
  133. self.loading = true;
  134. self._get(
  135. 'plus.bargain.product/product', {
  136. bargain_activity_id: bargain_activity_id
  137. },
  138. function(res) {
  139. self.listData = res.data;
  140. self.countdownConfig.endstamp = res.data.detail.end_time;
  141. self.countdownConfig.startstamp = res.data.detail.start_time;
  142. uni.hideLoading();
  143. self.loading = false;
  144. }
  145. );
  146. },
  147. /*跳转产品详情*/
  148. gotoDetail(e) {
  149. this.$refs.countdown.clear();
  150. let url = 'pages/plus/bargain/detail/detail?bargain_product_id=' + e.bargain_product_id
  151. this.gotoPage(url);
  152. },
  153. /*跳转搜索页面*/
  154. gotoSearch() {
  155. this.page = 1;
  156. this.getData();
  157. },
  158. /*倒计时返回值*/
  159. returnValFunc(e) {
  160. console.log(e);
  161. },
  162. }
  163. };
  164. </script>
  165. <style lang="scss">
  166. page {
  167. background: #f2f2f2;
  168. }
  169. .bargain-container .inner-tab {
  170. background: #ffffff;
  171. }
  172. .bargain-container .inner-tab .tab-list {
  173. height: 100rpx;
  174. display: flex;
  175. justify-content: flex-start;
  176. align-items: center;
  177. background: #FFFFFF;
  178. }
  179. .bargain-container .inner-tab .item {
  180. height: 100rpx;
  181. line-height: 100rpx;
  182. white-space: nowrap;
  183. padding: 0 30rpx;
  184. font-size: 30rpx;
  185. color: #333333;
  186. }
  187. .bargain-container .inner-tab .item.active,
  188. .bargain-container .inner-tab .item .arrow.active .iconfont {
  189. background: #FFFFFF;
  190. font-size: 32rpx;
  191. color: #F6220C;
  192. position: relative;
  193. }
  194. .bargain-container .inner-tab .item.active::after {
  195. content: '';
  196. width: 60%;
  197. height: 4rpx;
  198. background: #F6220C;
  199. border-radius: 2rpx;
  200. position: absolute;
  201. bottom: 17rpx;
  202. left: 0;
  203. right: 0;
  204. margin: auto;
  205. }
  206. .bargain-container .inner-tab .box {
  207. display: flex;
  208. justify-content: center;
  209. align-items: center;
  210. flex-direction: row;
  211. }
  212. .bargain-container .inner-tab .arrows {
  213. margin-left: 10rpx;
  214. line-height: 0;
  215. }
  216. .bargain-container .inner-tab .iconfont {
  217. line-height: 24rpx;
  218. font-size: 24rpx;
  219. }
  220. .bargain-container .inner-tab .arrow,
  221. .bargain-container .inner-tab .svg-icon {
  222. width: 20rpx;
  223. height: 20rpx;
  224. }
  225. .bargain-container .banner-image {
  226. width: 100%;
  227. box-sizing: border-box;
  228. }
  229. .bargain-container .banner-image image {
  230. width: 750rpx;
  231. height: 365rpx;
  232. }
  233. .bargain-container .ad-datetime::v-deep text {
  234. color: #333333;
  235. font-size: 28rpx;
  236. }
  237. .bargain-container .ad-datetime::v-deep .box {
  238. padding: 4rpx;
  239. border-radius: 4rpx;
  240. background: #F6220C;
  241. color: #ffffff;
  242. }
  243. .bargain-list .list {
  244. padding: 20rpx;
  245. }
  246. .bargain-list .list .item {
  247. width: 100%;
  248. padding: 30rpx;
  249. margin-bottom: 20rpx;
  250. box-sizing: border-box;
  251. border-radius: 16rpx;
  252. background: #ffffff;
  253. }
  254. .bargain-list .product-cover {
  255. padding: 4rpx;
  256. }
  257. .bargain-list .product-cover image {
  258. width: 200rpx;
  259. height: 200rpx;
  260. border-radius: 12rpx;
  261. }
  262. .bargain-list .product-info {
  263. flex: 1;
  264. padding-left: 20rpx;
  265. overflow: hidden;
  266. }
  267. .bargain-list .product-cover .people-num {
  268. position: absolute;
  269. right: 0;
  270. bottom: 0;
  271. left: 0;
  272. height: 50rpx;
  273. padding: 0 20rpx;
  274. line-height: 50rpx;
  275. font-size: 24rpx;
  276. box-sizing: border-box;
  277. background: rgba(0, 0, 0, 0.6);
  278. }
  279. .bargain-list .ad-datetime .box {
  280. padding: 4rpx;
  281. border-radius: 4rpx;
  282. background: #000000;
  283. color: #ffffff;
  284. }
  285. .bargain-list .product-title {
  286. width: 100%;
  287. height: 40rpx;
  288. line-height: 40rpx;
  289. font-size: 26rpx;
  290. color: #333333;
  291. }
  292. .bargain-list .people-num {
  293. width: 100%;
  294. }
  295. .bargain-list .already-sale {
  296. padding: 4rpx 0;
  297. color: #999;
  298. font-size: 24rpx;
  299. }
  300. .bargain-list .price {
  301. width: 100%;
  302. color: $dominant-color;
  303. font-size: 24rpx;
  304. }
  305. .bargain-list .price .num {
  306. padding: 0 4rpx;
  307. }
  308. .bargain-list .slider-box .slider {
  309. margin-top: 10rpx;
  310. height: 10rpx;
  311. background: #cccccc;
  312. border-radius: 5rpx;
  313. }
  314. .bargain-list .slider-box .slider-inner {
  315. height: 10rpx;
  316. background: $dominant-color;
  317. border-radius: 5rpx;
  318. }
  319. .bargain-list .right-btn button {
  320. height: 60rpx;
  321. line-height: 60rpx;
  322. border-radius: 30rpx;
  323. background: #8D60FF;
  324. color: #ffffff;
  325. font-size: 32rpx;
  326. }
  327. </style>