list.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  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 scroll-x class="nav" v-if="labelList.length" >
  12. <view class="nav_item" @tap="changeNav(0)" :class="{on:curPresellLabelId == 0}">
  13. <text>{{$L('首页')}}</text>
  14. </view>
  15. <view v-for="(item, index) in labelList" :key="index"
  16. :class="'nav_item ' + (curPresellLabelId==item.presellLabelId?'on':'')"
  17. @tap="changeNav(item.presellLabelId)">
  18. <text>{{item.presellLabelName}}</text>
  19. </view>
  20. </scroll-view>
  21. </view>
  22. <view class="goods_list" v-if="goodsList.length">
  23. <navigator v-for="(item, index) in goodsList" :key="index" class="goods_item"
  24. :url="'/pages/product/detail?productId=' + item.productId + '&type=presale'" hover-class="none">
  25. <view class="item_left">
  26. <image :src="item.goodsImage" mode="" style="width:294rpx;height:294rpx;"></image>
  27. </view>
  28. <view class="item_right">
  29. <text class="goods_name">{{item.goodsName}}</text>
  30. <view class="goods_info">
  31. <view class="goods_price">
  32. <view class="now_price">
  33. <text class="small_price">¥</text>
  34. <text class="big_price">{{filters.toSplit(filters.toFix(item.presellPrice))[0]}}.</text>
  35. <text
  36. class="small_price">{{filters.toSplit(filters.toFix(item.presellPrice))[1]}}</text>
  37. </view>
  38. <view class="old_price">¥{{item.productPrice}}</view>
  39. </view>
  40. </view>
  41. <view class="presale_btn_wrap">
  42. <view class="presale_num_wrap">
  43. <image :src="iconImg" mode="" class="iconImg"></image>
  44. <text>{{$L('已预定')}}{{item.saleNum}}人</text>
  45. </view>
  46. <view class="goods_btn">{{$L('立即预定')}}</view>
  47. </view>
  48. </view>
  49. </navigator>
  50. </view>
  51. <loadingState v-if="loadingState == 'first_loading'||goodsList.length > 0" :state='loadingState' />
  52. <view class="empty" v-if="!goodsList.length && loading">
  53. <image :src="img_url+'preSale/empty.png'"></image>
  54. <text>{{$L('暂无商品')}}</text>
  55. </view>
  56. <view class="top_wrap" v-show="isShowTopBtn == true">
  57. <image :src="topImg" mode="" @click="top"></image>
  58. </view>
  59. <common title="预售" :gids="gids" v-if="gids.length"></common>
  60. </block>
  61. </view>
  62. </template>
  63. <script module="filters" lang="wxs" src="../../../utils/filter.wxs"></script>
  64. <script>
  65. import loadingState from "@/components/loading-state.vue";
  66. import notOpen from '@/components/not_open.vue'
  67. const app = getApp();
  68. export default {
  69. data() {
  70. return {
  71. list: [],
  72. active: '0',
  73. autoplay: true,
  74. interval: 5000,
  75. duration: 1000,
  76. indicatorDots: true,
  77. img_url: app.globalData.imgUrl,
  78. loading: false,
  79. home_info: "",
  80. pn: 1,
  81. hasmore: true,
  82. isShowTopBtn: false,
  83. bgImg: getApp().globalData.imgUrl + 'preSale/presale_bg.png',
  84. iconImg: getApp().globalData.imgUrl + 'preSale/icon4.png',
  85. topImg: getApp().globalData.imgUrl + 'preSale/top.png',
  86. gids: [],
  87. current: 1,
  88. pageSize: 10,
  89. labelList: [],
  90. goodsList: [],
  91. curPresellLabelId: 0, //当前选中的labelId
  92. loadingState: 'first_loading',
  93. openState: true
  94. };
  95. },
  96. components: {
  97. loadingState,
  98. notOpen
  99. },
  100. props: {},
  101. onLoad: function (options) {
  102. this.getPreSaleList();
  103. },
  104. onReachBottom() {
  105. if (this.hasmore) {
  106. this.getPreSaleList();
  107. }
  108. },
  109. methods: {
  110. //获取预售列表
  111. getPreSaleList() {
  112. let that = this;
  113. let param = {};
  114. param.url = '/v3/promotion/front/preSell/list';
  115. param.method = 'GET';
  116. param.data = {};
  117. param.data.current = that.current;
  118. param.data.pageSize = that.pageSize;
  119. param.data.labelId = that.curPresellLabelId;
  120. that.loadingState = that.loadingState == 'first_loading' ? that.loadingState : 'loading';
  121. that.$request(param).then(res => {
  122. if (res.state == 200) {
  123. this.loading = true
  124. this.openState = true
  125. let result = res.data;
  126. that.labelList = result.labelList;
  127. if (that.current == 1) {
  128. that.goodsList = result.goodsList;
  129. } else {
  130. that.goodsList = that.goodsList.concat(result.goodsList);
  131. }
  132. that.hasMore = that.$checkPaginationHasMore(res.data.pagination);
  133. if (that.hasMore) {
  134. that.current++;
  135. that.loadingState = 'allow_loading_more';
  136. } else {
  137. that.loadingState = 'no_more_data';
  138. }
  139. } else if (res.state == 259) {
  140. this.openState = false
  141. } else {
  142. that.$api.msg(res.msg);
  143. }
  144. }).catch((e) => {
  145. //异常处理
  146. })
  147. },
  148. bigPrice(val) {
  149. return val.split('.')[0]
  150. },
  151. smallPrice(val) {
  152. return val.split('.')[1]
  153. },
  154. changeNav(presellLabelId) {
  155. let that = this;
  156. that.curPresellLabelId = presellLabelId;
  157. that.current = 1;
  158. that.getPreSaleList();
  159. },
  160. // 获取滚动距离
  161. onPageScroll(e) { //根据距离顶部距离是否显示回到顶部按钮
  162. if (e.scrollTop > 600) { //当距离大于600时显示回到顶部按钮
  163. this.isShowTopBtn = true
  164. } else { //当距离小于600时隐藏回到顶部按钮
  165. this.isShowTopBtn = false
  166. }
  167. },
  168. // 回到顶部
  169. top() {
  170. uni.pageScrollTo({
  171. scrollTop: 0,
  172. duration: 300
  173. })
  174. },
  175. goBack(){
  176. uni.navigateBack({
  177. })
  178. }
  179. }
  180. };
  181. </script>
  182. <style lang="scss">
  183. /* addons/pages/presaleIndex.wxss */
  184. page {
  185. background-color: #F5F5F5;
  186. padding-top: 82rpx;
  187. width: 750rpx;
  188. margin: 0 auto;
  189. }
  190. /* #ifdef H5 */
  191. page {
  192. padding-top: 0rpx;
  193. }
  194. /* #endif */
  195. .nav_label{
  196. display: flex;
  197. position: relative;
  198. position: fixed;
  199. top: 0;
  200. left: 0;
  201. right: 0;
  202. margin: 0 auto;
  203. width: 750rpx;
  204. height: 88rpx;
  205. z-index: 9999;
  206. }
  207. .nav {
  208. height: 88rpx;
  209. display: block;
  210. white-space: nowrap;
  211. overflow: hidden;
  212. z-index: 9999;
  213. right: 0;
  214. margin: 0 auto;
  215. }
  216. .back_icon1{
  217. display: flex;
  218. align-items: center;
  219. padding-left: 10rpx;
  220. image{
  221. width: 52rpx;
  222. height: 49rpx;
  223. }
  224. }
  225. .nav_item {
  226. display: inline-block;
  227. line-height: 86rpx;
  228. text-align: center;
  229. color: #fff;
  230. font-size: 30rpx;
  231. padding: 0 20rpx;
  232. }
  233. .nav_item.on {
  234. font-size: 30rpx;
  235. }
  236. .nav_item.on text {
  237. font-weight: bold;
  238. font-size: 32rpx;
  239. display: inline-block;
  240. padding: 0 10rpx;
  241. line-height: 50rpx;
  242. }
  243. .goods_list {
  244. padding: 0 20rpx;
  245. background-color: white;
  246. }
  247. .goods_list .goods_item {
  248. height: 334rpx;
  249. display: flex;
  250. align-items: center;
  251. border-bottom: 1rpx solid #F2F2F2;
  252. }
  253. .goods_list navigator:nth-last-child(1) {
  254. border-bottom: none;
  255. }
  256. .goods_item .item_left {
  257. display: flex;
  258. align-items: center;
  259. justify-content: center;
  260. width: 294rpx;
  261. height: 294rpx;
  262. }
  263. .goods_item .item_left image {
  264. width: 294rpx;
  265. height: 294rpx;
  266. border-radius: 15rpx;
  267. }
  268. .goods_item .item_right {
  269. flex: 1;
  270. display: flex;
  271. min-height: 200rpx;
  272. flex-direction: column;
  273. margin-left: 20rpx;
  274. justify-content: space-between;
  275. height: 100%;
  276. padding-bottom: 20rpx;
  277. box-sizing: border-box;
  278. position: relative;
  279. }
  280. .goods_item .item_right .goods_name {
  281. margin-top: 43rpx;
  282. font-size: 28rpx;
  283. color: #2D2D2D;
  284. font-weight: 600;
  285. line-height: 40rpx;
  286. overflow: hidden;
  287. text-overflow: ellipsis;
  288. display: -webkit-box;
  289. word-break: break-all;
  290. -webkit-box-orient: vertical;
  291. -webkit-line-clamp: 2;
  292. }
  293. .item_right .goods_info {
  294. display: flex;
  295. align-items: center;
  296. justify-content: space-between;
  297. }
  298. .goods_info .goods_price {
  299. display: flex;
  300. align-items: flex-end;
  301. position: absolute;
  302. bottom: 100rpx;
  303. }
  304. .now_price {
  305. color: #FE006D;
  306. font-weight: bold;
  307. }
  308. .now_price .small_price {
  309. font-size: 24rpx;
  310. }
  311. .now_price .big_price {
  312. font-size: 34rpx;
  313. }
  314. .goods_price .old_price {
  315. color: #999;
  316. font-size: 24rpx;
  317. text-decoration: line-through;
  318. margin-left: 10rpx;
  319. padding-bottom: 4rpx;
  320. }
  321. .presale_btn_wrap {
  322. display: flex;
  323. align-items: center;
  324. justify-content: center;
  325. height: 50rpx;
  326. color: #333;
  327. font-size: 24rpx;
  328. border-radius: 25rpx;
  329. position: absolute;
  330. bottom: 40rpx;
  331. left: 0;
  332. }
  333. .presale_num_wrap {
  334. display: flex;
  335. align-items: center;
  336. height: 46rpx;
  337. color: #333333;
  338. font-size: 25rpx;
  339. border-radius: 25rpx 0 0 25rpx;
  340. border: 1rpx solid #A92DC9;
  341. padding-right: 40rpx;
  342. padding-left: 20rpx;
  343. white-space: nowrap;
  344. }
  345. .presale_num_wrap .iconImg {
  346. width: 29rpx;
  347. height: 34rpx;
  348. margin-right: 10rpx;
  349. }
  350. .goods_btn {
  351. min-width: 140rpx;
  352. height: 50rpx;
  353. display: flex;
  354. align-items: center;
  355. justify-content: center;
  356. border-radius: 0 25rpx 25rpx 25rpx;
  357. color: #fff;
  358. font-size: 26rpx;
  359. background: linear-gradient(90deg, #EC0093 0%, #FF085B 100%);
  360. margin-left: -30rpx;
  361. }
  362. .empty {
  363. display: flex;
  364. align-items: center;
  365. justify-content: center;
  366. flex-direction: column;
  367. height: 70vh;
  368. }
  369. .empty image {
  370. width: 200rpx;
  371. height: 200rpx;
  372. margin-bottom: 30rpx;
  373. }
  374. .empty text {
  375. color: #333;
  376. font-size: 28rpx;
  377. }
  378. .top_wrap {
  379. position: fixed;
  380. right: 46rpx;
  381. bottom: 66rpx;
  382. width: 85rpx;
  383. height: 85rpx;
  384. }
  385. .top_wrap image {
  386. width: 85rpx;
  387. height: 85rpx;
  388. }
  389. </style>