index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  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="img_url+'store/white_arrow_l.png'" mode=""></image>
  10. </view>
  11. <scroll-view class="nav-container" scroll-x>
  12. <view :class="'item ' + (tid==0?'on':'')" data-id="0" @tap="changeNav">{{$L("首页")}}</view>
  13. <view v-for="(item, index) in NavData" :key="index" :class="'item ' + (tid==item.spellLabelId?'on':'')" :data-id="item.spellLabelId"
  14. @tap="changeNav">{{item.spellLabelName}}</view>
  15. </scroll-view>
  16. </view>
  17. <view class="goods-list" v-if="goodsList.length" :style="'padding-bottom:'+bottomSateArea">
  18. <view v-for="(item, index) in goodsList" :key="index" class="item">
  19. <view class="goods-list-top">
  20. <view class="img">
  21. <image :src="item.goodsImage" mode="aspectFit"></image>
  22. </view>
  23. <view class="goods-info">
  24. <view class="info">
  25. <view class="goods_nameBox">
  26. <text class="goods_nameText">{{item.goodsName}}</text>
  27. </view>
  28. <!-- <view class="p">已参与{{item.incom_num}}人</view> -->
  29. <view class="goods_price_wrap">
  30. <view class="now_price">
  31. <text class="small_price">¥</text><text class="big_price">{{item.spellPrice.toFixed(2).toString().split('.')[0]}}.</text><text
  32. class="small_price">{{item.spellPrice.toFixed(2).toString().split('.')[1]}}</text>
  33. </view>
  34. <view class="old_price">¥{{item.productPrice}}</view>
  35. </view>
  36. <navigator :url="'/pages/product/detail?productId=' + item.productId + '&promotionId='+item.spellId" hover-class="none">
  37. <view class="group_num_wrap">
  38. <image :src="iconImg" mode="" class="iconImg"></image>
  39. <text>{{item.requiredNum}}{{$L("人团")}}</text>
  40. </view>
  41. <view class="go_to_group">{{$L("去拼团")}}</view>
  42. </navigator>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="activity-info">
  47. <image :src="saveImg" mode="" class="save_img"></image>
  48. <text class="group_bottom_text">{{$L("拼团购买立省")}}{{item.spellDiscount}}<block v-if="item.leaderDiscount!=0">,{{$L("团长优惠")}}{{item.leaderDiscount}}{{$L("元")}}</block>;{{$L("单独购买价")}}{{item.productPrice}}</text>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="empty" v-if="!goodsList.length && isLoading">
  53. <view class="img">
  54. <image :src="img_url+'index/empty.png'" mode="widthFix"></image>
  55. </view>
  56. <view class="tip">{{$L("暂无商品")}}</view>
  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. </block>
  63. </view>
  64. </template>
  65. <script>
  66. import notOpen from '@/components/not_open.vue'
  67. export default {
  68. data() {
  69. return {
  70. key: '',
  71. tid: '',
  72. isLoading: false,
  73. NavData: "",
  74. goodsList: "",
  75. pn: 1,
  76. hasmore: true,
  77. img_url: getApp().globalData.imgUrl,
  78. bgImg: getApp().globalData.imgUrl + 'pinGroup/group_bg.png',
  79. iconImg: getApp().globalData.imgUrl + 'pinGroup/icon.png',
  80. saveImg: getApp().globalData.imgUrl + 'pinGroup/save.png',
  81. topImg: getApp().globalData.imgUrl + 'pinGroup/top.png',
  82. isShowTopBtn: false,
  83. bottomSateArea: 0, //iphone手机底部一条黑线的高度
  84. gids: [],
  85. openState:true
  86. };
  87. },
  88. components: {
  89. notOpen
  90. },
  91. props: {},
  92. onLoad: function(options) {
  93. this.initData();
  94. },
  95. onReachBottom() {
  96. if (this.hasmore) {
  97. this.getList();
  98. }
  99. },
  100. methods: {
  101. initData() {
  102. this.getNavData();
  103. this.getList();
  104. },
  105. getNavData() {
  106. let params ={
  107. url:'v3/promotion/front/spell/list',
  108. method:'GET'
  109. }
  110. this.$request(params).then(res=>{
  111. if(res.state==200){
  112. this.isLoading = true
  113. this.NavData = res.data.labelList
  114. }
  115. })
  116. },
  117. getList() {
  118. let params = {
  119. url:'v3/promotion/front/spell/list',
  120. method:"GET",
  121. data:{
  122. labelId:this.tid,
  123. current:this.pn
  124. }
  125. }
  126. this.$request(params).then(res=>{
  127. if(res.state == 200){
  128. this.openState = true
  129. if(this.pn==1){
  130. this.goodsList = res.data.goodsList
  131. }else{
  132. this.goodsList = this.goodsList.concat(res.data.goodsList)
  133. }
  134. this.loading = true
  135. this.hasmore = this.$checkPaginationHasMore(res.data.pagination)
  136. if(this.hasmore){
  137. this.pn++
  138. }
  139. }else if(res.state==259){
  140. this.openState = false
  141. }
  142. })
  143. },
  144. changeNav(e) {
  145. let newTid = e.currentTarget.dataset.id;
  146. let {
  147. tid
  148. } = this;
  149. if (newTid == tid) return;
  150. this.pn = 1;
  151. this.hasmore = true;
  152. this.tid = newTid
  153. this.getList();
  154. },
  155. // 获取滚动距离
  156. onPageScroll(e) { //根据距离顶部距离是否显示回到顶部按钮
  157. if (e.scrollTop > 600) { //当距离大于600时显示回到顶部按钮
  158. this.isShowTopBtn = true
  159. } else { //当距离小于600时隐藏回到顶部按钮
  160. this.isShowTopBtn = false
  161. }
  162. },
  163. // 回到顶部
  164. top() {
  165. uni.pageScrollTo({
  166. scrollTop: 0,
  167. duration: 300
  168. });
  169. },
  170. goBack(){
  171. uni.navigateBack({
  172. })
  173. }
  174. }
  175. };
  176. </script>
  177. <style lang="scss">
  178. /* integral/activity/pin_index/pin_index.wxss */
  179. page {
  180. background-color: #f5f5f5;
  181. padding-top: 90rpx;
  182. width: 750rpx;
  183. margin: 0 auto;
  184. }
  185. /* #ifdef H5 */
  186. page {
  187. padding-top: 0rpx;
  188. }
  189. /* #endif */
  190. .nav_label{
  191. display: flex;
  192. position: relative;
  193. position: fixed;
  194. top: 0;
  195. left: 0;
  196. right: 0;
  197. margin: 0 auto;
  198. width: 750rpx;
  199. height: 88rpx;
  200. z-index: 9999;
  201. }
  202. .nav-container {
  203. white-space: nowrap;
  204. z-index: 999;
  205. background-size: 100% 100%;
  206. right: 0;
  207. margin: 0 auto;
  208. }
  209. .back_icon1{
  210. display: flex;
  211. align-items: center;
  212. padding-left: 10rpx;
  213. image{
  214. width: 52rpx;
  215. height: 49rpx;
  216. }
  217. }
  218. .nav-container .item {
  219. display: inline-block;
  220. color: #fff;
  221. font-size: 30rpx;
  222. margin: 0 30rpx;
  223. line-height: 40rpx;
  224. margin-top: 25rpx;
  225. }
  226. .nav-container .item.on {
  227. font-weight: bold;
  228. font-size: 32rpx;
  229. padding-bottom: 8rpx;
  230. box-sizing: border-box;
  231. }
  232. .goods-list {
  233. padding: 0 20rpx;
  234. }
  235. .goods-list .item {
  236. height: 382rpx;
  237. display: flex;
  238. flex-direction: column;
  239. border-radius: 15rpx;
  240. box-sizing: border-box;
  241. background-color: #fff;
  242. font-size: 24rpx;
  243. color: #999;
  244. margin-top: 20rpx;
  245. padding: 20rpx 20rpx 0 20rpx;
  246. }
  247. .goods-list-top .img {
  248. position: relative;
  249. width: 270rpx;
  250. height: 270rpx;
  251. margin-right: 20rpx;
  252. background-color: #f8f8f8;
  253. border-radius: 15rpx;
  254. }
  255. .img image {
  256. width: 270rpx;
  257. height: 270rpx;
  258. border-radius: 15rpx;
  259. }
  260. .img .activity-info {
  261. position: absolute;
  262. bottom: 30rpx;
  263. left: 30rpx;
  264. width: 120rpx;
  265. height: 80rpx;
  266. background-color: #EF1B21;
  267. border-radius: 4rpx;
  268. color: #fff;
  269. line-height: 30rpx;
  270. text-align: center;
  271. }
  272. .goods-list .item {
  273. display: flex;
  274. flex-direction: column;
  275. }
  276. .goods-list-top {
  277. display: flex;
  278. }
  279. .activity-info .t {
  280. display: block;
  281. margin: 6rpx;
  282. height: 36rpx;
  283. line-height: 36rpx;
  284. color: #EF1B21;
  285. background-color: #fff;
  286. }
  287. .goods-info {
  288. display: flex;
  289. flex-direction: column;
  290. position: relative;
  291. }
  292. .goods-info .info view {
  293. margin-bottom: 5rpx;
  294. }
  295. .goods-info .goods_price_wrap {
  296. display: flex;
  297. align-items: flex-end;
  298. margin-top: 30rpx;
  299. }
  300. .goods_price_wrap .now_price {
  301. /* display: flex; */
  302. font-size: 24rpx;
  303. font-weight: 600;
  304. color: #FC1C1C;
  305. font-weight: bold;
  306. }
  307. .now_price .big_price {
  308. font-size: 34rpx;
  309. }
  310. .goods-info .info .old_price {
  311. color: #9A9A9A;
  312. font-size: 20rpx;
  313. margin-left: 10rpx;
  314. text-decoration: line-through;
  315. padding-bottom: 4rpx;
  316. }
  317. .goods-info .info .p {
  318. font-size: 24rpx;
  319. color: #666;
  320. display: flex;
  321. align-items: center;
  322. }
  323. .goods-info .p .line {
  324. display: block;
  325. width: 1rpx;
  326. height: 20rpx;
  327. margin: 0 15rpx;
  328. background-color: #999;
  329. }
  330. .goods-info navigator {
  331. display: flex;
  332. align-items: center;
  333. justify-content: center;
  334. width: 280rpx;
  335. height: 50rpx;
  336. color: #fff;
  337. font-size: 28rpx;
  338. border-radius: 38rpx;
  339. position: absolute;
  340. bottom: 0;
  341. left: 0;
  342. }
  343. .group_num_wrap {
  344. display: flex;
  345. justify-content: center;
  346. align-items: center;
  347. width: 150rpx;
  348. height: 46rpx;
  349. color: #FC1C1C;
  350. font-size: 25rpx;
  351. border-radius: 25rpx 0 0 25rpx;
  352. border: 1rpx solid #FC1C1C;
  353. padding-right: 10px;
  354. }
  355. .goods-info .iconImg {
  356. width: 31rpx;
  357. height: 27rpx;
  358. margin-right: 10rpx;
  359. }
  360. .go_to_group {
  361. display: flex;
  362. align-items: center;
  363. justify-content: center;
  364. width: 148rpx;
  365. height: 50rpx;
  366. font-size: 26rpx;
  367. color: #fff;
  368. background-color: #FC1C1C;
  369. border-radius: 0 25rpx 25rpx 25rpx;
  370. margin-left: -30rpx;
  371. }
  372. .empty {
  373. display: flex;
  374. width: 750rpx;
  375. height: calc(100vh - 100rpx);
  376. flex-direction: column;
  377. align-items: center;
  378. /* justify-content: center; */
  379. margin-top: 200rpx;
  380. }
  381. .empty .img {
  382. width: 210rpx;
  383. height: 210rpx;
  384. background-color: #DDD;
  385. border-radius: 50%;
  386. display: flex;
  387. align-items: center;
  388. justify-content: center;
  389. }
  390. .empty .img image {
  391. width: 210rpx;
  392. height: 210rpx;
  393. }
  394. .empty .tip {
  395. color: #000;
  396. font-size: 30rpx;
  397. margin: 30rpx 0;
  398. }
  399. .empty text {
  400. font-size: 26rpx;
  401. color: #999;
  402. }
  403. .goods_nameBox {
  404. margin-top: 20rpx;
  405. }
  406. .goods_nameText {
  407. color: #2E2E2E;
  408. font-size: 29rpx;
  409. font-weight: 600;
  410. text-overflow: -o-ellipsis-lastline;
  411. overflow: hidden;
  412. text-overflow: ellipsis;
  413. display: -webkit-box;
  414. -webkit-line-clamp: 2;
  415. line-clamp: 2;
  416. -webkit-box-orient: vertical;
  417. }
  418. .activity-info {
  419. width: 100%;
  420. height: 70rpx;
  421. display: flex;
  422. align-items: center;
  423. font-size: 26rpx;
  424. color: #666;
  425. margin-top: 20rpx;
  426. border-top: 1rpx solid #F2F2F2;
  427. }
  428. .activity-info .save_img {
  429. width: 30rpx;
  430. height: 30rpx;
  431. margin-right: 20rpx;
  432. }
  433. .top_wrap {
  434. position: fixed;
  435. right: 46rpx;
  436. bottom: 66rpx;
  437. width: 85rpx;
  438. height: 85rpx;
  439. }
  440. .top_wrap image {
  441. width: 85rpx;
  442. height: 85rpx;
  443. }
  444. .group_bottom_text {
  445. white-space: nowrap;
  446. text-overflow: ellipsis;
  447. overflow: hidden;
  448. }
  449. </style>