index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. <template>
  2. <view>
  3. <block v-if="!openState">
  4. <notOpen></notOpen>
  5. </block>
  6. <block v-else>
  7. <view class="nav_label" :style="{backgroundImage:'url('+ bgImg +')'}">
  8. <view class="back_icon1" @click="goBack">
  9. <image :src="imgUrl+'store/white_arrow_l.png'" mode=""></image>
  10. </view>
  11. <scroll-view scroll-x class="nav" v-if="list.length" >
  12. <view :class="'nav_item ' + (active=='0'?'on':'')" @tap="changeNav" data-id='0'>
  13. <text>首页</text>
  14. </view>
  15. <view v-for="(item, index) in list" :key="index" :class="'nav_item ' + (active==item.labelId?'on':'')" @tap="changeNav" :data-id="item.labelId">
  16. <text>{{item.labelName}}</text>
  17. </view>
  18. </scroll-view>
  19. </view>
  20. <!-- <view class="clearfix" :hidden="active!=''">
  21. <DiyPage :sourceData="home_info" v-if="home_info.length"></DiyPage>
  22. </view> -->
  23. <view class="goods_list" v-if="goodsList.length">
  24. <navigator v-for="(item, index) in goodsList" :key="index" class="goods_item" :url="'/pages/product/detail?productId=' + item.productId + '&promotionId='+item.groupId" hover-class="none">
  25. <view class="item_left">
  26. <image :src="item.goodsImage" mode="aspectFit"></image>
  27. </view>
  28. <view class="item_right">
  29. <view class="goods_name">
  30. <view class="goods_name_img" >
  31. <image :src="icon" mode="widthFix"></image>
  32. </view>
  33. <text>{{item.goodsName}}</text>
  34. </view>
  35. <view class="goods_info">
  36. <!-- <view class="goods_price">
  37. <text>¥<text>{{item.goods_price}}</text></text>
  38. <text>已拼{{item.sales}}件</text>
  39. </view> -->
  40. <view class="price">
  41. <view class="small_price">¥<text class="big_price">{{item.spellPrice,'int'}}</text>.<text class="small_price" style="margin-right:10rpx;">{{$getPartNumber(item.spellPrice,'decimal').split('.')[1]}}</text></view>
  42. <text class="num">¥{{$getPartNumber(item.productPrice,'int')}}{{$getPartNumber(item.productPrice,'decimal')}}</text>
  43. </view>
  44. <view class="group_now">
  45. <view class="group_now_left" :style="{backgroundImage:'url(' +imgUrl + 'ladder/ladder_regiment.png)'}">{{$L('马上拼')}} ></view>
  46. <view class="group_now_right">{{$L('已团')}}{{item.saleNum}}{{$L('件')}}</view>
  47. </view>
  48. <!-- <view class="goods_btn">去拼团
  49. <image :src="imgUrl+'addons/ico_011.png'" mode="widthFix"></image>
  50. </view> -->
  51. </view>
  52. </view>
  53. </navigator>
  54. </view>
  55. <view class="empty" v-if="!goodsList.length&&loading">
  56. <image :src="imgUrl+'empty_goods.png'"></image>
  57. <text>{{$L('暂无商品')}}</text>
  58. </view>
  59. <view class="top_wrap" v-show="isShowTopBtn == true">
  60. <image :src="topImg" mode="" @click="top"></image>
  61. </view>
  62. <!-- <common title="阶梯团"></common> -->
  63. </block>
  64. </view>
  65. </template>
  66. <script>
  67. import request from "../../../utils/request";
  68. export default {
  69. data() {
  70. return {
  71. list: [],
  72. active: '0',
  73. goodsList: [],
  74. autoplay: true,
  75. interval: 5000,
  76. duration: 1000,
  77. indicatorDots: true,
  78. loading: false,
  79. imgUrl: getApp().globalData.imgUrl ,//图片地址
  80. home_info: "",
  81. bgImg:getApp().globalData.imgUrl+'ladder/ladder_bg.png',
  82. icon:getApp().globalData.imgUrl+'ladder/icon2.png',
  83. topImg:getApp().globalData.imgUrl+'ladder/top.png',
  84. isShowTopBtn:false,
  85. ifOnShow:false,
  86. openState:true
  87. };
  88. },
  89. components: {},
  90. props: {},
  91. onLoad: function (options) {
  92. this.getClassList();
  93. // this.getIndexData();
  94. this.getGoodsList()
  95. },
  96. onReachBottom() {
  97. if (this.hasmore) {
  98. this.getGoodsList();
  99. }
  100. },
  101. methods: {
  102. // 获取装修数据
  103. // getIndexData() {
  104. // request({
  105. // url: getApp().globalData.ser_url + '/index.php?app=index&mod=index_data&sld_addons=pin_ladder',
  106. // success: res => {
  107. // let home_info_data = res.data.datas.tmp_data;
  108. // this.setData({
  109. // home_info: home_info_data
  110. // });
  111. // }
  112. // });
  113. // },
  114. // 获取阶梯团分类
  115. getClassList() {
  116. let params ={
  117. url:'v3/promotion/front/ladder/group/list',
  118. method:'GET'
  119. }
  120. this.$request(params).then(res=>{
  121. if(res.state==200){
  122. this.list = res.data.labelList
  123. }
  124. })
  125. },
  126. // 获取商品列表
  127. getGoodsList() {
  128. let params = {
  129. url:'v3/promotion/front/ladder/group/list',
  130. method:"GET",
  131. data:{
  132. labelId:this.active,
  133. current:this.pn
  134. }
  135. }
  136. this.$request(params).then(res=>{
  137. if(res.state == 200){
  138. this.openState = true
  139. if(this.pn==1){
  140. this.goodsList = res.data.goodsList
  141. }else{
  142. this.goodsList = this.goodsList.concat(res.data.goodsList)
  143. }
  144. this.loading = true
  145. this.hasmore = this.$checkPaginationHasMore(res.data.pagination)
  146. if(this.hasmore){
  147. this.pn++
  148. }
  149. }else if(res.state==259){
  150. this.openState = false
  151. }
  152. })
  153. },
  154. //
  155. changeNav(e) {
  156. let id = e.currentTarget.dataset.id;
  157. let {
  158. active
  159. } = this;
  160. if (active == id) return;
  161. this.active = id
  162. this.loading = false
  163. this.pn = 1;
  164. this.hasmore = true;
  165. this.getGoodsList();
  166. },
  167. // 获取滚动距离
  168. onPageScroll(e){ //根据距离顶部距离是否显示回到顶部按钮
  169. if(e.scrollTop>600){ //当距离大于600时显示回到顶部按钮
  170. this.isShowTopBtn = true
  171. }else{ //当距离小于600时隐藏回到顶部按钮
  172. this.isShowTopBtn = false
  173. }
  174. },
  175. // 回到顶部
  176. top(){
  177. uni.pageScrollTo({
  178. scrollTop: 0,
  179. duration: 300
  180. });
  181. },
  182. goBack(){
  183. uni.navigateBack({
  184. })
  185. }
  186. }
  187. };
  188. </script>
  189. <style lang="scss">
  190. page {
  191. background-color: #F5F5F5;
  192. padding-top: 80rpx;
  193. width: 750rpx;
  194. margin: 0 auto;
  195. }
  196. /* #ifdef H5 */
  197. page {
  198. padding-top: 0rpx;
  199. }
  200. /* #endif */
  201. .nav {
  202. display: block;
  203. white-space: nowrap;
  204. overflow: hidden;
  205. z-index: 9999;
  206. background-size: 100% 100%;
  207. }
  208. .back_icon1{
  209. display: flex;
  210. align-items: center;
  211. padding-left: 10rpx;
  212. image{
  213. width: 52rpx;
  214. height: 49rpx;
  215. }
  216. }
  217. .nav_label{
  218. display: flex;
  219. position: relative;
  220. position: fixed;
  221. top: 0;
  222. left: 0;
  223. right: 0;
  224. margin: 0 auto;
  225. width: 750rpx;
  226. height: 88rpx;
  227. z-index: 9999;
  228. }
  229. .nav_item {
  230. display: inline-block;
  231. line-height: 86rpx;
  232. text-align: center;
  233. color: #fff;
  234. font-size: 30rpx;
  235. padding: 0 30rpx;
  236. overflow: hidden;
  237. }
  238. .nav_item.on {
  239. font-weight: bold;
  240. font-size: 32rpx;
  241. }
  242. .goods_list{
  243. padding:0 20rpx;
  244. padding-bottom: 20rpx;
  245. }
  246. .goods_list .goods_item {
  247. width:100%;
  248. height:310rpx;
  249. display:flex;
  250. background-color: #fff;
  251. border-radius: 15rpx;
  252. box-sizing: border-box;
  253. margin-top:20rpx;
  254. padding:20rpx;
  255. }
  256. .goods_item .item_left {
  257. display: flex;
  258. align-items: center;
  259. justify-content: center;
  260. width: 270rpx;
  261. height: 270rpx;
  262. margin-right:20rpx;
  263. }
  264. .goods_item .item_left image {
  265. width:100%;
  266. height:270rpx;
  267. background-color: #f7f7f7;
  268. border-radius: 15rpx;
  269. }
  270. .goods_item .item_right {
  271. display: flex;
  272. min-height: 200rpx;
  273. flex-direction: column;
  274. justify-content: space-around;
  275. position:relative;
  276. }
  277. .goods_item .item_right .goods_name {
  278. width:370rpx;
  279. font-size: 28rpx;
  280. line-height:44rpx;
  281. font-weight: 600;
  282. color:#2D2D2D;
  283. overflow: hidden;
  284. text-overflow: ellipsis;
  285. display: -webkit-box;
  286. word-break: break-all;
  287. -webkit-box-orient: vertical;
  288. -webkit-line-clamp: 2;
  289. margin-top: -20px;
  290. }
  291. .goods_name_img{
  292. display: inline-block;
  293. box-sizing: border-box;
  294. }
  295. .goods_item .item_right .goods_name image{
  296. display: inline-block;
  297. width: 122rpx;
  298. height:31rpx;
  299. margin-bottom: -5rpx;
  300. margin-right:10rpx;
  301. }
  302. .item_right .goods_info {
  303. display: flex;
  304. align-items: center;
  305. justify-content: space-between;
  306. }
  307. .goods_info .price {
  308. display: flex;
  309. align-items: center;
  310. font-weight: bold;
  311. color:#FC1C1C;
  312. margin-top: 20rpx;
  313. margin-right:10rpx;
  314. position: absolute;
  315. bottom:82rpx;
  316. left:0;
  317. }
  318. .goods_info .small_price{
  319. font-size:24rpx;
  320. }
  321. .goods_info .big_price{
  322. font-size:34rpx;
  323. }
  324. /* .goods_info .goods_price>text:nth-child(1) {
  325. color: #EE1B21;
  326. font-size: 34rpx;
  327. }
  328. .goods_info .goods_price>text text{
  329. font-size: 50rpx;
  330. }
  331. .goods_info .goods_price text:nth-child(2) {
  332. color: #808080;
  333. font-size: 24rpx;
  334. margin-left: 30rpx;
  335. margin-top: 20rpx;
  336. } */
  337. .group_now{
  338. position:absolute;
  339. bottom:10rpx;
  340. left:0;
  341. width:270rpx;
  342. height:50rpx;
  343. line-height: 50rpx;
  344. border-radius: 25px;
  345. display:flex;
  346. align-items: center;
  347. border:1rpx solid #FFA63D;
  348. box-sizing: border-box;
  349. }
  350. .group_now .group_now_left{
  351. font-size:26rpx;
  352. color:#fff;
  353. width:148rpx;
  354. text-align: center;
  355. border-radius: 25rpx 0 0 25rpx;
  356. /* background:#FE9A22; */
  357. background-size: 100% 100%;
  358. box-sizing: border-box;
  359. margin-left:-1rpx;
  360. }
  361. .group_now .group_now_right{
  362. width:122rpx;
  363. text-align: center;
  364. font-size:22rpx;
  365. color:#FE9A22;
  366. font-weight: 400;
  367. box-sizing: border-box;
  368. }
  369. .goods_info .price .num {
  370. font-weight: 500;
  371. color: #9A9A9A;
  372. font-size: 24rpx;
  373. text-decoration: line-through;
  374. }
  375. .goods_info .goods_btn {
  376. display: flex;
  377. align-items: center;
  378. justify-content: center;
  379. width: 172rpx;
  380. height: 64rpx;
  381. border-radius: 32rpx;
  382. color: #fff;
  383. font-size: 28rpx;
  384. background: #ED6307;
  385. }
  386. .goods_info .goods_btn image{
  387. width: 10rpx;
  388. height: 18rpx;
  389. margin-left: 15rpx;
  390. transform: rotate(180deg);
  391. }
  392. .empty{
  393. display: flex;
  394. align-items: center;
  395. justify-content: center;
  396. flex-direction: column;
  397. height: 70vh;
  398. }
  399. .empty image{
  400. width:254rpx;
  401. height: 263rpx;
  402. margin-bottom: 30rpx;
  403. }
  404. .empty text{
  405. color: #333;
  406. font-size: 28rpx;
  407. }
  408. .top_wrap{
  409. position: fixed;
  410. right:46rpx;
  411. bottom:66rpx;
  412. width:85rpx;
  413. height:85rpx;
  414. left: 0;
  415. right: 0;
  416. margin: 0 auto;
  417. transform: translateX(286rpx);
  418. }
  419. .top_wrap image{
  420. width:85rpx;
  421. height:85rpx;
  422. }
  423. </style>