PresellList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <home-base :show="false">
  3. <view class="div container">
  4. <view class="div common-header-wrap">
  5. <view :style="'height:'+navHeight+'px'"></view>
  6. <view class="common-header-holder"></view>
  7. <view class="common-header-fixed">
  8. <title-header />
  9. <uni-nav-bar title="预售活动" class="common-header" left-icon="back" @clickLeft="goBack()">
  10. </uni-nav-bar>
  11. </view>
  12. </view>
  13. <view class="div ui-goodslist-filter">
  14. <view class="ul filter-list">
  15. <view class="li item"
  16. v-for='(item, index) in sortkey'
  17. v-bind:key='item.id'
  18. v-on:click='setActiveSortkey(item, index)'
  19. v-bind:class="{'sortactive': item.id == currentSortKey.id, 'sortnormal' : item.id != currentSortKey.id}">
  20. {{item.name}}
  21. </view>
  22. </view>
  23. </view>
  24. <view class="div time-list">
  25. <text v-for="(item,index) in timeList" :key="index" class="span time-item" @click="setTime(index)" :class="{'time-active':timeActive==index}">{{item.text}}</text>
  26. </view>
  27. <view class="div goodslist-body show-goods-list" >
  28. <!-- 无限加载滚动列表 -->
  29. <scroll-view class="scroll-view div flex-wrapper" @scrolltolower="loadMore" scroll-y="true">
  30. <view class="div" v-if="presellList">
  31. <view class="div ui-product-body"
  32. v-for='(item, index) in presellList'
  33. v-bind:key='index'
  34. v-on:click='goDetail(item)'
  35. >
  36. <view class="div list">
  37. <view class="div ui-image-wrapper">
  38. <image class="img product-img" :src="item.goods_image_url">
  39. </view>
  40. <view class="div flex-right">
  41. <view class="div product-header">
  42. <text class="h3 title clear-bottom">{{ item.goods_name }}</text>
  43. </view>
  44. <view class="div btn-wrapper">
  45. <view class="div p-price">
  46. <text class="span strong">¥{{ item.presell_price }}</text><text class="span presell_limit_number">¥{{item.goods_price}}</text>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="div bottom-btn">
  52. <view class="div bottom-content" v-if="currentSortKey.id">
  53. <view class="div bottom-title">预付定金</view>
  54. <view class="div bottom-desc">¥{{item.presell_deposit_amount}}</view>
  55. </view>
  56. <view class="div bottom-content" v-else>
  57. <view class="div bottom-title">发货时间</view>
  58. <view class="div bottom-desc">{{ $moment.unix(item.presell_shipping_time).format('YYYY-MM-DD') }}</view>
  59. </view>
  60. <view class="div triangle-bottomright"></view>
  61. <view class="div big-btn">立刻购买</view>
  62. </view>
  63. </view>
  64. <view class="div loading-wrapper" v-if="presellList.length > 0">
  65. <view class="p common-no-more" v-if='!isMore'>没有更多了</view>
  66. <uni-load-more status="loading" color='#e93b3d' v-if='isMore'></uni-load-more>
  67. </view>
  68. <empty-record v-if='presellList.length <= 0 && !isMore'></empty-record>
  69. </view>
  70. </scroll-view>
  71. </view>
  72. </view>
  73. </home-base>
  74. </template>
  75. <script>
  76. import {getFontSize,urlencode} from '@/util/common'
  77. import HomeBase from '../HomeBase'
  78. import EmptyRecord from '../../EmptyRecord'
  79. import TitleHeader from '../../TitleHeader'
  80. import { getPresellList,getPresellTime } from '../../../api/homesearch'
  81. export default {
  82. name: 'GroupbuyList',
  83. components: {
  84. HomeBase,
  85. TitleHeader,
  86. EmptyRecord
  87. },
  88. mounted(){
  89. // #ifdef MP-WEIXIN
  90. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  91. // #endif
  92. },
  93. computed:{
  94. fontSize(){
  95. return getFontSize()
  96. },
  97. },
  98. data () {
  99. return {
  100. navHeight: 0,
  101. sortkey: [
  102. {
  103. name: '全款预售',
  104. id: 0
  105. },
  106. {
  107. name: '定金预售',
  108. id: 1
  109. }
  110. ], // 排序数据
  111. currentSortKey: { id: 0 }, // 当前选中的排序
  112. presellList: false,
  113. params: { 'page': 0, 'per_page': 10 },
  114. loading: false, // 是否加载更多
  115. isMore: true, // 是否有更多
  116. timeList:false,
  117. timeActive:0,
  118. }
  119. },
  120. created: function () {
  121. this.getPresellTime()
  122. this.loadMore()
  123. },
  124. methods: {
  125. goBack(){uni.navigateBack({delta:1})},
  126. getPresellTime(){
  127. getPresellTime({presell_type:this.currentSortKey.id?2:1}).then(res=>{
  128. this.timeList=res.result.time_list
  129. this.reload()
  130. })
  131. },
  132. setTime(index){
  133. this.timeActive=index
  134. this.reload()
  135. },
  136. loadMore () {
  137. if(!this.timeList){
  138. return
  139. }
  140. if (this.loading) {
  141. return
  142. }
  143. this.params.page = ++this.params.page
  144. if (this.isMore) {
  145. this.getPresellList(true)
  146. }
  147. },
  148. reload () {
  149. // 重新加载数据
  150. this.params.page = 0
  151. this.isMore = true
  152. this.loading = false
  153. this.presellList = false
  154. this.loadMore()
  155. },
  156. getPresellList () {
  157. this.loading = true
  158. getPresellList(Object.assign(this.params,{start_time:this.timeList.length?this.timeList[this.timeActive].time:'',presell_type:this.currentSortKey.id?2:1})).then(res => {
  159. if (res.result.hasmore) {
  160. this.isMore = true
  161. } else {
  162. this.isMore = false
  163. }
  164. if (this.presellList) {
  165. this.presellList = this.presellList.concat(res.result.presell_list)
  166. } else {
  167. this.presellList = res.result.presell_list
  168. }
  169. this.loading = false
  170. }).catch((error)=>{
  171. uni.showToast({icon:'none',title: error.message})
  172. this.loading = false
  173. })
  174. },
  175. goDetail (item) {
  176. uni.navigateTo({ url: '/pages/home/goodsdetail/Goodsdetail'+'?'+urlencode( { 'goods_id': item.goods_id } )})
  177. },
  178. setActiveSortkey (item, index) {
  179. this.currentSortKey = item
  180. this.getPresellTime()
  181. this.timeActive=0
  182. },
  183. }
  184. }
  185. </script>
  186. <style scoped lang='scss'>
  187. .ui-goodslist-filter {
  188. width: auto;
  189. background: #fff;
  190. .ul.filter-list{
  191. display: flex;
  192. width: auto;
  193. justify-content: space-around;
  194. align-content: center;
  195. align-items: center;
  196. border: 0;
  197. .li{
  198. font-size:$subFontSize;
  199. color: #333;
  200. border-bottom: .1rem solid transparent;
  201. position: relative;
  202. flex-basis: 4.54rem;
  203. text-align: center;
  204. height: 1.9rem;
  205. padding: 0;
  206. line-height: 1.9rem;
  207. .a {
  208. height: 1.9rem;
  209. display: inline-block;
  210. }
  211. .img {
  212. height: .18rem;
  213. width: .36rem;
  214. vertical-align: middle;
  215. }
  216. .iconfont{display: inline-block}
  217. }
  218. .li.sortactive {color:$primaryColor;
  219. &::after{background-color:$primaryColor;width:1rem;height: 2px;content:'';display: block;margin: 0 auto;}
  220. .a {
  221. color:$primaryColor;
  222. }
  223. .iconfont{color:$primaryColor;}
  224. .iconfont.active{transform: rotate(180deg);}
  225. }
  226. .li.sortnormal {
  227. border-bottom-color: transparent;
  228. .a {
  229. color: #333;
  230. }
  231. }
  232. }
  233. }
  234. .ui-product-body {
  235. background:#fff;
  236. margin-bottom:.5rem;
  237. .list {
  238. display: flex;
  239. width: auto;
  240. align-items: center;
  241. justify-content: space-between;
  242. padding:0.5rem;
  243. position: relative;
  244. .div.ui-image-wrapper {
  245. width: 4rem;
  246. height: 4rem;
  247. position: relative;
  248. display: flex;
  249. justify-content: center;
  250. align-content: center;
  251. align-items: center;
  252. flex-basis: 4rem;
  253. flex-shrink: 0;
  254. background-position:center center!important;
  255. background-size:5rem 5rem;
  256. background-repeat:no-repeat;
  257. -webkit-background-size: cover;
  258. -moz-background-size: cover;
  259. -o-background-size: cover;
  260. background-size: cover;
  261. .img.product-img{
  262. width:4rem;
  263. height:4rem;
  264. border-radius:.4rem;
  265. flex-basis:4rem;
  266. flex-shrink: 0;
  267. }
  268. }
  269. .flex-right {
  270. padding-left:0.7rem;
  271. flex: 1;
  272. overflow: hidden;
  273. position:relative;
  274. height: 4rem;
  275. display: flex;
  276. flex-direction: column;
  277. justify-content: space-around;
  278. .title {
  279. color: #333;
  280. font-size:$subFontSize;
  281. font-weight: normal;
  282. height:2rem;
  283. line-height:1rem;
  284. font-weight: normal;
  285. display:-moz-box;
  286. display:-webkit-box;
  287. -webkit-line-clamp: 2;
  288. -moz-line-clamp: 2;
  289. -moz-box-orient:vertical;
  290. -webkit-box-orient:vertical;
  291. box-orient:vertical;
  292. overflow: hidden;
  293. margin-bottom:0.4rem;
  294. &.clear-bottom {
  295. margin-bottom: 0;
  296. }
  297. }
  298. .product-header {
  299. margin-bottom:.4rem;
  300. display: flex;
  301. align-items: center;
  302. }
  303. .p-price {font-size:$fontSize;color:#999;
  304. .strong{
  305. color: $primaryColor;
  306. font-size:$h2;
  307. line-height:.8rem;
  308. margin-right:.2rem;
  309. }
  310. }
  311. .presell_limit_number{font-size:$fontSize;color:#999;text-decoration: line-through}
  312. .btn-wrapper{display: flex;justify-content: space-between;margin-top:1rem;}
  313. .btn{color: #fff;background: $primaryColor;
  314. &.disable{background: #eee;}
  315. }
  316. }
  317. }
  318. }
  319. .bottom-btn{
  320. border-top:1px dashed #eee;
  321. display: flex;
  322. align-items: center;
  323. .bottom-content{
  324. flex:1;
  325. padding-left:$pageSpace;
  326. .bottom-title{
  327. font-size:.7rem;
  328. padding-bottom:.3rem;
  329. }
  330. .bottom-desc{
  331. font-size:.65rem;
  332. color:#999
  333. }
  334. }
  335. .big-btn{
  336. font-size:.9rem;
  337. width:5rem;
  338. padding-left:.5rem;
  339. background: $primaryColor;
  340. color:#fff;
  341. line-height: 3rem;
  342. }
  343. .triangle-bottomright {
  344. width: 0;
  345. height: 0;
  346. border-bottom: 3rem solid $primaryColor;
  347. border-left: 3rem solid transparent;
  348. }
  349. }
  350. .time-list{
  351. padding:1rem 0;
  352. background: #fff;
  353. white-space: nowrap;
  354. overflow: hidden;
  355. overflow-x: auto;
  356. .time-item{
  357. padding:0 $pageSpace;
  358. font-size:.9rem;
  359. &.time-active{
  360. color:$primaryColor;
  361. font-size: 1.1rem;
  362. }
  363. }
  364. }
  365. .time-list::-webkit-scrollbar {
  366. display: none; /* Chrome Safari */
  367. }
  368. </style>