时空网前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

231 lines
5.4 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <template>
  2. <view class="lf-row-center lf-flex-column">
  3. <view class="ctab">
  4. <u-tabs :list="tab_list" :is-scroll="true" :show-bar="false" :current="current" @change="change"></u-tabs>
  5. </view>
  6. <view class="com" v-for="(tab, tabIndex) in tab_list" v-if="tabIndex == current" :key="tab.id">
  7. <view class="lf-row-between list" v-for="(item, index) in tab.list" :key="item.id" @click="toDetail(item)">
  8. <view class="left">
  9. <image :src="item.cover" mode=""></image>
  10. </view>
  11. <view class="right">
  12. <view class="lf-line-2 title">{{ item.name }}</view>
  13. <view class="lf-flex tips">
  14. <view class="u-line-progress">
  15. <u-line-progress :percent="item.specs[0].sold_percent" height="20" :striped="true" active-color="#FE9903" :show-percent="false" inactive-color="#F5F5F5"></u-line-progress>
  16. </view>
  17. <text class="progress">{{ item.specs[0].sold_percent_text }}</text>
  18. <text class="bought">{{ item.specs[0].sold_stock_text }}</text>
  19. </view>
  20. <view class="lf-row-between price">
  21. <text class="lf-font-bold">
  22. <text class="lf-font-24"></text>
  23. <text class="lf-font-42">{{ item.specs[0].selling_price }}</text>
  24. </text>
  25. <text class="lf-font-24">{{ item.specs[0].original_price }}</text>
  26. <button>立即抢购</button>
  27. </view>
  28. </view>
  29. </view>
  30. <!-- 加载 -->
  31. <view class="loading-more">
  32. <text v-if="tab.list.length" :class="{'loading-more-text': tab.loadingClass}">{{ tab.loadingText }}</text>
  33. <my-nocontent v-else></my-nocontent>
  34. </view>
  35. <!-- 回到顶部 -->
  36. <u-back-top :scroll-top="pageScrollTop"></u-back-top>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data() {
  43. return {
  44. tab_list: [],
  45. current: 0, // tab下表
  46. pageSize: 10
  47. }
  48. },
  49. onLoad() {
  50. this.getCategoryList();
  51. },
  52. methods: {
  53. // 切换tab
  54. change(index) {
  55. this.current = index;
  56. },
  57. // 获取分类tab
  58. getCategoryList(){
  59. this.$http(this.API.API_CATEGORY_LIST).then(res => {
  60. let res_list = res.data || [];
  61. let tab_list = res_list.map(item => {
  62. return {
  63. id: item.id,
  64. name: item.name,
  65. type: item.type,
  66. list: [],
  67. loadingClass: true,
  68. loadingText: '正在加载中',
  69. page: 1,
  70. isPage: true
  71. }
  72. })
  73. this.tab_list = tab_list;
  74. this.getGoodsList();
  75. })
  76. },
  77. // 获取分类下的商品列表
  78. getGoodsList(){
  79. let per_page = this.pageSize;
  80. let tab_item = this.tab_list[this.current];
  81. this.$http(this.API.API_GOODS_LIST, {
  82. category_id: tab_item.id,
  83. type: tab_item.type,
  84. page: tab_item.page,
  85. per_page
  86. }).then(res => {
  87. console.log("res", res);
  88. let isPage = res.data.has_more_page;
  89. tab_item.isPage = isPage;
  90. if(isPage){
  91. tab_item.loadingClass = true;
  92. tab_item.loadingText = '正在加载中';
  93. }else{
  94. tab_item.loadingClass = false;
  95. tab_item.loadingText = '没有更多数据啦~';
  96. }
  97. if(tab_item.page == 1){
  98. tab_item.list = res.data.items;
  99. }else{
  100. tab_item.list.push(...res.data.items);
  101. }
  102. })
  103. },
  104. // 去到详情页
  105. toDetail(item){
  106. this.$url('/pages/goodsDetail/index?id='+ item.id);
  107. }
  108. },
  109. onReachBottom(){
  110. let tab_item = this.tab_list[this.current];
  111. if(tab_item.isPage){
  112. tab_item.page = tab_item.page + 1;
  113. this.getGoodsList();
  114. }
  115. },
  116. onPullDownRefresh(){
  117. let tab_item = this.tab_list[this.current];
  118. tab_item.page = 1;
  119. tab_item.isPage = true;
  120. tab_item.loadingClass = true;
  121. tab_item.loadingText = '正在加载中';
  122. this.getGoodsList();
  123. uni.stopPullDownRefresh()
  124. }
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. .title {
  129. font-size: 28rpx;
  130. color: $u-content-color;
  131. height: 88rpx;
  132. }
  133. // tab
  134. .ctab{
  135. width: 100%;
  136. margin: 20rpx 0 0rpx 0rpx;
  137. padding: 0 22rpx;
  138. }
  139. // 商品列表
  140. .com{
  141. width: 100%;
  142. overflow: hidden;
  143. .list{
  144. border-radius: 10rpx;
  145. overflow: hidden;
  146. margin: 20rpx 32rpx;
  147. background-color: #FFFFFF;
  148. box-shadow:0 0 10px 5px #e5e5e5;
  149. align-items: flex-start;
  150. .left{
  151. overflow: hidden;
  152. image{
  153. width: 204rpx;
  154. height: 204rpx;
  155. margin: 20rpx;
  156. border-radius: 10rpx;
  157. }
  158. }
  159. .right{
  160. overflow: hidden;
  161. width: 64%;
  162. .title{
  163. margin: 18rpx 20rpx 0 0;
  164. color: #222222;
  165. font-size: 32rpx;
  166. }
  167. .tips{
  168. margin: 16rpx 0;
  169. overflow: hidden;
  170. .u-line-progress{
  171. width: 112rpx;
  172. overflow: hidden;
  173. margin-right:20rpx ;
  174. }
  175. .progress{
  176. color: #777777;
  177. font-size: 24rpx;
  178. }
  179. .bought{
  180. color: #777777;
  181. font-size: 24rpx;
  182. margin-right: 20rpx;
  183. }
  184. }
  185. .price{
  186. overflow: hidden;
  187. color:#FF0000;
  188. // text{
  189. // font-size: 48rpx;
  190. // color:#FF0000;
  191. // font-weight: 500;
  192. // }
  193. // text:nth-child(1){
  194. // color: #FF0000;
  195. // font-size: 28rpx;
  196. // }
  197. // text:nth-child(2){
  198. // color: #FF0000;
  199. // font-size: 48rpx;
  200. // }
  201. // text:nth-child(3){
  202. // color: #FF0000;
  203. // font-size: 28rpx;
  204. // }
  205. // text:nth-child(4){
  206. // color: #777777;
  207. // font-size: 28rpx;
  208. // text-decoration:line-through;
  209. // font-weight: 400;
  210. // }
  211. button{
  212. width: 160rpx;
  213. height: 60rpx;
  214. background: #FE9903;
  215. border-radius: 15px;
  216. font-size: 24rpx;
  217. color: #FFFFFF;
  218. margin: 0rpx 20rpx 0rpx 20rpx;
  219. border: none;
  220. }
  221. }
  222. }
  223. }
  224. }
  225. </style>