my-product-tabbar.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <view class="my-product">
  3. <view class="header">
  4. <view class="title">
  5. 我的商品
  6. </view>
  7. <view style="position: relative;">
  8. <view class="sub-title">全部商品</view>
  9. <view class="release">
  10. <navigator url="/pages/product/product-edit">发布商品</navigator>
  11. </view>
  12. </view>
  13. </view>
  14. <view class="product-list">
  15. <view class="product-item" v-for="product in products" @tap="goToEdit(product.id)">
  16. <view class="product-image">
  17. <image class="image" :src="product.images|imagesFilter" mode="scaleToFill"></image>
  18. </view>
  19. <view>
  20. <view class="row row-1">
  21. <text class="title"><text class="sxzg-icon">省心直供</text>{{product.name}}</text>
  22. </view>
  23. <view class="row row-2">
  24. <text class="org-price">¥{{product.org_price}}</text>
  25. </view>
  26. <view class="row row-3">
  27. <text class="sxj-icon">省心价</text>
  28. <text class="price">¥{{product.price}}</text>
  29. </view>
  30. <view class="row row-4">
  31. <text>发布日期:</text>
  32. <text class="time">{{product.createtime|datetimeFilter}}</text>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. data() {
  42. return {
  43. page: 1,
  44. pageLoading: false,
  45. products: []
  46. }
  47. },
  48. onLoad() {
  49. this.getProductData();
  50. },
  51. onPageScroll(e) {
  52. const query = uni.createSelectorQuery();
  53. query.select("#my-product").boundingClientRect(data => {
  54. if (e.scrollTop > data.height - uni.getSystemInfoSync().windowHeight * 2) {
  55. this.getProductData();
  56. }
  57. }).exec();
  58. },
  59. onPullDownRefresh() {
  60. this.refresh();
  61. },
  62. onShow() {
  63. this.refresh();
  64. },
  65. methods: {
  66. getProductData() {
  67. return new Promise((resolve, reject) => {
  68. this.$http.get({
  69. url: "/product/my",
  70. data: {
  71. limit: 10,
  72. page: this.page,
  73. },
  74. success: (res) => {
  75. this.products = [...this.products, ...res.data.data.rows];
  76. this.page++;
  77. this.pageLoading = false;
  78. resolve(res)
  79. },
  80. fail: (err) => {
  81. reject(err)
  82. }
  83. })
  84. })
  85. },
  86. goToEdit(id) {
  87. uni.navigateTo({
  88. url: "/pages/product/product-edit?id=" + id
  89. })
  90. },
  91. refresh() {
  92. this.page = 1;
  93. this.products = [];
  94. this.getProductData()
  95. .then(uni.stopPullDownRefresh())
  96. .catch(uni.stopPullDownRefresh());
  97. }
  98. }
  99. }
  100. </script>
  101. <style lang="scss" scoped>
  102. .my-product {
  103. overflow: hidden;
  104. }
  105. .header {
  106. margin: 20upx;
  107. background: white;
  108. text-align: center;
  109. border-radius: 20upx;
  110. padding-bottom: 10upx;
  111. .title {
  112. height: 100upx;
  113. font-size: 32upx;
  114. line-height: 100upx;
  115. // font-weight: bold;
  116. }
  117. .sub-title {
  118. font-size: 28upx;
  119. color: #999999;
  120. }
  121. .release {
  122. position: absolute;
  123. right: 20upx;
  124. font-size: 24upx;
  125. bottom: 4upx;
  126. }
  127. }
  128. .product-list {
  129. .product-item {
  130. display: flex;
  131. background: white;
  132. margin: 20upx;
  133. padding: 20upx;
  134. .product-image {
  135. width: 180upx;
  136. height: 180upx;
  137. margin-right: 20upx;
  138. }
  139. .image {
  140. width: 180upx;
  141. height: 180upx;
  142. background: #EEEEEE;
  143. }
  144. }
  145. .sxzg-icon {
  146. color: $primary-color;
  147. font-size: 16rpx;
  148. width: 80rpx;
  149. text-align: center;
  150. line-height: normal;
  151. border: 2rpx solid $primary-color;
  152. border-radius: 20rpx;
  153. display: inline-block;
  154. position: relative;
  155. top: -4rpx;
  156. margin-right: 10upx;
  157. // transform: scale(0.9);
  158. }
  159. .title {
  160. font-size: 24rpx;
  161. display: inline-block;
  162. white-space: normal;
  163. display: -webkit-box;
  164. -webkit-box-orient: vertical;
  165. -webkit-line-clamp: 2;
  166. overflow: hidden;
  167. height: 68upx;
  168. }
  169. .row {
  170. // padding: 0 10upx;
  171. }
  172. .row-2 {
  173. display: flex;
  174. justify-content: space-between;
  175. }
  176. .org-price {
  177. font-size: 26rpx;
  178. color: #cccccc;
  179. }
  180. .org-price {
  181. text-decoration: line-through;
  182. }
  183. .sxj-icon {
  184. background: $primary-color;
  185. color: white;
  186. font-size: 20upx;
  187. padding: 0 5upx;
  188. border-radius: 5upx;
  189. vertical-align: middle;
  190. }
  191. .price {
  192. font-size: 26rpx;
  193. color: $primary-color;
  194. font-weight: bold;
  195. }
  196. .row-4 {
  197. font-size: 24upx;
  198. color: #999999;
  199. }
  200. }
  201. </style>