list.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <view class="container">
  3. <!-- 空白页 -->
  4. <!-- <empty v-if="loadingType === 'nomore' && groupShopList.length === 0"></empty> -->
  5. <view style="padding: 150rpx 0rpx;" v-if="loadingType === 'nomore' && groupShopList.length === 0">
  6. <missing v-if="loadingType === 'nomore' && groupShopList.length === 0"
  7. :imgUrl="'http://qiniuoss.nauzone.cn/%E7%BB%84%203%20%E6%8B%B7%E8%B4%9D@3x.png'" :desc="'暂时没有订单哦!'"></missing>
  8. </view>
  9. <view class="favorite-list">
  10. <block v-for="(item, index) in groupShopList" :key="index">
  11. <navigator class="favorite-item" :class="{'b-b': index!==groupShopList.length-1}"
  12. :url="'/pages/product/detail?id=' + item.productId + '&gid=' + item.id">
  13. <view class="image-wrapper">
  14. <image :src="JSON.parse(item.image)[0].url " :class="[item.loaded]" mode="aspectFill" lazy-load
  15. @load="onImageLoad('groupShopList', index)" @error="onImageError('groupShopList', index)"></image>
  16. </view>
  17. <view class="item-right">
  18. <text class="clamp title">{{item.storeName}}</text>
  19. <view class="pro-box">
  20. <view class="progress-box">
  21. <progress :percent="100 * item.alreadyBuyNumber / item.minimumNumber" activeColor="#fa436a" active
  22. stroke-width="6" />
  23. </view>
  24. <text>{{item.minimumNumber}}人成团</text>
  25. </view>
  26. <text class="attr">已拼团{{item.alreadyBuyNumber}}件</text>
  27. <text class="price">
  28. <text style="text-decoration:line-through;color: #6B6B6B;">¥{{item.otPrice}}</text>
  29. <text style="padding-left: 10px;color: #fa436a; font-size: 36upx;">¥{{item.minPrice}}</text>
  30. </text>
  31. </view>
  32. </navigator>
  33. </block>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. // import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  39. import missing from '@/components/missing.vue'
  40. // import empty from "@/components/empty";
  41. export default {
  42. components: {
  43. // uniLoadMore,
  44. missing
  45. // empty
  46. },
  47. data() {
  48. return {
  49. groupShopList: [],
  50. pageNo: 1,
  51. loadingType: 'more'
  52. };
  53. },
  54. onLoad(options) {
  55. this.loadData()
  56. },
  57. //下拉刷新
  58. onPullDownRefresh() {
  59. this.loadData('refresh');
  60. },
  61. //加载更多
  62. onReachBottom() {
  63. this.loadData();
  64. },
  65. methods: {
  66. //获取收藏列表
  67. loadData(type) {
  68. const that = this
  69. if (type === 'refresh') {
  70. that.pageNo = 1
  71. that.groupShopList = []
  72. that.loadingType = 'more'
  73. }
  74. if (that.loadingType == 'more') {
  75. that.loadingType = 'loading'
  76. that.$api.request('get', 'group/app/getGroupShopPage', {
  77. pageNo: that.pageNo,
  78. pageSize: 10,
  79. storageId: this.$store.state.storageId
  80. }).then(res => {
  81. that.loadingType = that.pageNo < res.total / that.pageNo + (res.total % that.pageNo == 0 ? 0 : 1) ?
  82. 'more' : 'noMore'
  83. that.pageNo = that.pageNo + 1
  84. res.rows.forEach(item => {
  85. that.groupShopList.push(item);
  86. })
  87. if (type === 'refresh') {
  88. uni.stopPullDownRefresh();
  89. }
  90. })
  91. }
  92. },
  93. //监听image加载完成
  94. onImageLoad(key, index) {
  95. this.$set(this[key][index], 'loaded', 'loaded');
  96. },
  97. //监听image加载失败
  98. onImageError(key, index) {
  99. this[key][index].image = '/static/errorImage.jpg';
  100. },
  101. },
  102. }
  103. </script>
  104. <style lang="scss">
  105. .container {
  106. padding-bottom: 134upx;
  107. /* 空白页 */
  108. .empty {
  109. position: fixed;
  110. left: 0;
  111. top: 0;
  112. width: 100%;
  113. height: 100vh;
  114. padding-bottom: 100upx;
  115. display: flex;
  116. justify-content: center;
  117. flex-direction: column;
  118. align-items: center;
  119. background: #fff;
  120. image {
  121. width: 240upx;
  122. height: 160upx;
  123. margin-bottom: 30upx;
  124. }
  125. .empty-tips {
  126. display: flex;
  127. font-size: $font-sm+2upx;
  128. color: $font-color-disabled;
  129. .navigator {
  130. color: $uni-color-primary;
  131. margin-left: 16upx;
  132. }
  133. }
  134. }
  135. }
  136. /* 收藏列表项 */
  137. .favorite-item {
  138. display: flex;
  139. position: relative;
  140. padding: 30upx 40upx;
  141. .image-wrapper {
  142. width: 230upx;
  143. height: 230upx;
  144. flex-shrink: 0;
  145. position: relative;
  146. image {
  147. border-radius: 8upx;
  148. }
  149. }
  150. .checkbox {
  151. position: absolute;
  152. left: -16upx;
  153. top: -16upx;
  154. z-index: 8;
  155. font-size: 44upx;
  156. line-height: 1;
  157. padding: 4upx;
  158. color: $font-color-disabled;
  159. background: #fff;
  160. border-radius: 50px;
  161. }
  162. .item-right {
  163. display: flex;
  164. flex-direction: column;
  165. flex: 1;
  166. overflow: hidden;
  167. position: relative;
  168. padding-left: 30upx;
  169. .title,
  170. .price {
  171. font-size: $font-base + 2upx;
  172. color: $font-color-dark;
  173. height: 40upx;
  174. line-height: 40upx;
  175. }
  176. .attr {
  177. font-size: $font-sm + 2upx;
  178. color: $font-color-light;
  179. height: 50upx;
  180. line-height: 50upx;
  181. }
  182. .pro-box {
  183. display: flex;
  184. align-items: center;
  185. margin-top: 10upx;
  186. font-size: $font-sm;
  187. color: $font-base;
  188. padding-right: 10upx;
  189. .progress-box {
  190. flex: 1;
  191. border-radius: 10px;
  192. overflow: hidden;
  193. margin-right: 8upx;
  194. }
  195. }
  196. .price {
  197. height: 60upx;
  198. line-height: 60upx;
  199. }
  200. }
  201. }
  202. </style>