good-floor.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <view class="container clearfix">
  3. <tui-skeleton
  4. v-if="skeletonShow"
  5. backgroundColor="#fafafa"
  6. borderRadius="10rpx"
  7. :isLoading="true"
  8. :loadingType="5"
  9. ></tui-skeleton>
  10. <view class="cm-member-main " v-else>
  11. <view class="cm-member-product clearfix">
  12. <view
  13. v-for="(pro, index) in productList"
  14. :key="index"
  15. :id="pro.productId"
  16. class="product-list"
  17. @click="productDetail(pro.productId)"
  18. >
  19. <view class="product-image"> <image :src="pro.mainImage" mode=""></image> </view>
  20. <view class="product-mains">
  21. <view class="product-name"> {{ pro.name }} </view>
  22. <view class="product-price" v-if="hasLogin">
  23. <!-- 价格 -->
  24. ¥{{ pro.price | NumFormat }}
  25. </view>
  26. <view v-else class="product-price-none">
  27. <uni-grader :grade="Number(pro.priceGrade)"></uni-grader>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <!--加载loadding-->
  33. <tui-loadmore :visible="loadding" :index="3" type="black"></tui-loadmore>
  34. <tui-nomore :visible="!pullUpOn" :backgroundColor="'#F7F7F7'" :text="nomoreText"></tui-nomore>
  35. <!--加载loadding-->
  36. </view>
  37. <!-- 透明模态层 -->
  38. <modal-layer v-if="isModallayer"></modal-layer>
  39. </view>
  40. </template>
  41. <script>
  42. import { mapState, mapMutations } from 'vuex'
  43. import modalLayer from '@/components/modal-layer'
  44. import uniGrader from '@/components/uni-grade/uni-grade.vue'
  45. import shareMixin from '@/mixins/shareMixin.js'
  46. export default {
  47. mixins: [ shareMixin ],
  48. components: {
  49. modalLayer,
  50. uniGrader
  51. },
  52. data() {
  53. return {
  54. skeletonShow:true,
  55. isModallayer: false,
  56. productList: [],
  57. nomoreText: '上拉显示更多',
  58. hasNextPage: false,
  59. loadding: false,
  60. pullUpOn: true,
  61. pullFlag: true,
  62. pathTitle:'',
  63. pathId:''
  64. }
  65. },
  66. onLoad(option) {
  67. this.pathId = option.id
  68. this.pathTitle = option.title
  69. this.mallOrganizeProducts(option.id)
  70. uni.setNavigationBarTitle({ title: option.title })
  71. },
  72. filters: {
  73. NumFormat: function(text) {
  74. //处理金额
  75. return Number(text).toFixed(2)
  76. }
  77. },
  78. computed: {
  79. ...mapState(['hasLogin'])
  80. },
  81. methods: {
  82. async mallOrganizeProducts(floorId){
  83. //初始化首页数据
  84. try{
  85. const res = await this.CommonService.mallOrganizeProducts({ floorId: floorId })
  86. this.productList = res.data
  87. this.skeletonShow = false
  88. }catch(error){
  89. //TODO handle the exception
  90. console.log('error',error)
  91. }
  92. },
  93. productDetail(productId) {
  94. // 跳转商品详情
  95. this.isModallayer = true
  96. this.$api.navigateTo(`/pages/goods/product?id=${productId}`)
  97. this.isModallayer = false
  98. },
  99. },
  100. onPullDownRefresh() {
  101. setTimeout(() => {
  102. this.getSvipProductPage()
  103. uni.stopPullDownRefresh()
  104. }, 200)
  105. },
  106. onReachBottom() {
  107. if (this.hasNextPage) {
  108. this.loadding = true
  109. this.pullUpOn = true
  110. this.getOnReachBottomData()
  111. }
  112. },
  113. onShow() {}
  114. }
  115. </script>
  116. <style lang="scss">
  117. page {
  118. background-color: #f7f7f7;
  119. }
  120. .container {
  121. width: 100%;
  122. height: auto;
  123. }
  124. .cm-member-main {
  125. width: 100%;
  126. box-sizing: border-box;
  127. padding: 0 24rpx 24rpx 24rpx;
  128. background-color: #f7f7f7;
  129. .cm-member-product {
  130. width: 100%;
  131. margin-top: 24rpx;
  132. .product-list {
  133. width: 339rpx;
  134. height: 516rpx;
  135. border-radius: 16rpx;
  136. float: left;
  137. margin-right: 24rpx;
  138. margin-bottom: 24rpx;
  139. background-color: #ffffff;
  140. &:nth-child(2n) {
  141. margin-right: 0;
  142. }
  143. .product-image {
  144. width: 339rpx;
  145. height: 339rpx;
  146. image {
  147. width: 339rpx;
  148. height: 339rpx;
  149. display: block;
  150. border-radius: 16rpx 16rpx 0 0;
  151. }
  152. }
  153. .product-mains {
  154. width: 100%;
  155. height: auto;
  156. box-sizing: border-box;
  157. padding: 0 24rpx;
  158. margin-top: 16rpx;
  159. .product-name {
  160. height: 80rpx;
  161. line-height: 40rpx;
  162. text-overflow: ellipsis;
  163. overflow: hidden;
  164. display: -webkit-box;
  165. -webkit-line-clamp: 2;
  166. line-clamp: 2;
  167. -webkit-box-orient: vertical;
  168. font-size: $font-size-28;
  169. color: #333333;
  170. text-align: justify;
  171. }
  172. .product-price {
  173. width: 100%;
  174. line-height: 40rpx;
  175. font-size: $font-size-28;
  176. color: #F85050;
  177. margin-top: 16rpx;
  178. }
  179. .product-price-none {
  180. color: #f8c499;
  181. float: left;
  182. line-height: 54rpx;
  183. margin-top: 16rpx;
  184. .p-no {
  185. float: left;
  186. font-size: $font-size-24;
  187. color: $text-color;
  188. }
  189. }
  190. }
  191. }
  192. }
  193. }
  194. </style>