BrowseList.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <member-base :show="false"><view style="position: absolute;top:0;right:0;left:0;bottom:0" class="scroll-view-wrapper div container">
  3. <view class="div common-header-wrap">
  4. <view class="status-holder"></view>
  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. <view class="div common-btn btn" slot="right" @click="clearallBrowse()">清空浏览记录</view>
  11. </uni-nav-bar>
  12. </view>
  13. </view>
  14. <view class="scroll-view div" style="position:relative">
  15. <view class="browse-wrapper div " >
  16. <scroll-view style="position: absolute;top:0;right:0;left:0;bottom:0" class="div" @scrolltolower="loadMore" scroll-y="true">
  17. <view class='div main-content' v-if="goodsbrowse_list && goodsbrowse_list.length">
  18. <view class='browse-item' v-for="(item, index) in goodsbrowse_list" v-bind:key="index">
  19. <view class='title'>{{item.time}}</view>
  20. <view class='goods_list' >
  21. <view class='goods-item' v-for="(goods, i) in item.goods_list" v-bind:key="i">
  22. <view class='img' :style="'width:'+windowWidth+'px;height:'+windowWidth+'px'"><image mode="aspectFit" class="image" :src="goods.goods_image_url" /></view>
  23. <view class='price'>¥{{goods.goods_promotion_price}}</view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <empty-record v-else></empty-record>
  29. </scroll-view>
  30. </view>
  31. </view>
  32. </view>
  33. </member-base>
  34. </template>
  35. <script>
  36. import {getFontSize} from '@/util/common'
  37. import TitleHeader from '../../TitleHeader'
  38. import { urlencode } from '@/util/common'
  39. import MemberBase from '../MemberBase'
  40. import { getBrowseList, clearallBrowse } from '../../../api/memberBrowse'
  41. import EmptyRecord from '../../EmptyRecord'
  42. import flexLine from '../../flexLine'
  43. export default {
  44. components:{
  45. TitleHeader,
  46. MemberBase,
  47. flexLine,
  48. EmptyRecord
  49. },
  50. mounted(){
  51. // #ifdef MP-WEIXIN
  52. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  53. // #endif
  54. },
  55. computed:{
  56. fontSize(){
  57. return getFontSize()
  58. },
  59. windowWidth: function () {
  60. const res = uni.getSystemInfoSync()
  61. var width=res.windowWidth
  62. var size=getFontSize()
  63. return (width-3*.6*size)/3
  64. },
  65. },
  66. data(){
  67. return {
  68. navHeight: 0,
  69. params: { 'page': 0, 'per_page': 5 },
  70. loading: false, // 是否加载更多
  71. isMore: true, // 是否有更多
  72. goodsbrowse_list: false
  73. }
  74. },
  75. created () {
  76. this.loadMore()
  77. },
  78. methods: {
  79. // 清空浏览记录
  80. clearallBrowse () {
  81. clearallBrowse(this.params).then(res => {
  82. this.goodsbrowse_list = false
  83. }).catch(function (error) {
  84. uni.showToast({icon:'none',title: error.message})
  85. })
  86. },
  87. goBack () {
  88. uni.navigateBack({delta:1})
  89. },
  90. goGoods (goods_id) {
  91. uni.navigateTo({ url: '/pages/home/goodsdetail/Goodsdetail'+'?'+urlencode( { 'goods_id': goods_id } )})
  92. },
  93. loadMore () {
  94. this.loading = true
  95. this.params.page = ++this.params.page
  96. if (this.isMore) {
  97. this.loading = false
  98. this.getBrowseList(true)
  99. }
  100. },
  101. getBrowseList () {
  102. uni.showLoading({ title: '加载中' })
  103. getBrowseList(this.params).then(res => {
  104. uni.hideLoading()
  105. if (res) {
  106. if (res.result.hasmore) {
  107. this.isMore = true
  108. } else {
  109. this.isMore = false
  110. }
  111. let temp = res.result.goodsbrowse_list
  112. if (temp) {
  113. if (!this.goodsbrowse_list) {
  114. this.goodsbrowse_list = temp
  115. } else {
  116. this.goodsbrowse_list = this.goodsbrowse_list.concat(temp)
  117. }
  118. }
  119. }
  120. })
  121. }
  122. }
  123. }
  124. </script>
  125. <style scoped lang="scss">
  126. .scroll-view-wrapper{display: flex;flex-direction: column;}
  127. .scroll-view{flex:1}
  128. .common-header{
  129. .btn{background: #000;color: #fff;box-shadow: 0px 2px 4px #d2d2d2;}
  130. }
  131. .container {
  132. height: 100%;
  133. display: flex;
  134. position: relative;
  135. flex-direction: column;
  136. justify-content: flex-start;
  137. align-items: stretch;
  138. }
  139. .main-content{background: #fff;padding: 0 $pageSpace;box-sizing: border-box;}
  140. .browse-wrapper .browse-item{}
  141. .browse-wrapper .browse-item .title{color: #333;font-size: .8rem;font-weight: bold;padding-top: .5rem;}
  142. .browse-wrapper .browse-item .goods_list{padding-top: .5rem;display: flex;flex-wrap: wrap;}
  143. .browse-wrapper .browse-item .goods_list .goods-item{width: 32%;margin-right: 1%;margin-bottom: .5rem;}
  144. .browse-wrapper .browse-item .goods_list .goods-item .img{border-radius: .5rem;overflow: hidden;}
  145. .browse-wrapper .browse-item .goods_list .goods-item .price{font-size: .8rem;color: $primaryColor;padding: .5rem 0;text-align: center;}
  146. </style>