时空网前端
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.

265 lines
6.3 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 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 lf-m-r-10">{{ 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. // this.get();
  52. },
  53. methods: {
  54. get(){
  55. this.$http(this.API.TEST, {
  56. goods_id: 1,
  57. goods_specs_id: 1,
  58. number: 1,
  59. token: 'b1f20b424ec9e7a2a4c9788fd0f75643'
  60. }).then(res => {
  61. console.log(res)
  62. // let nonceStr = res.data.nonceStr
  63. // appId: "wxb35ef055a4dd8ad4"
  64. // nonceStr: "60d3125d138af"
  65. // order_num: "2842855348400816128"
  66. // package: "prepay_id=wx23185213000285e14ea77ac97acc670000"
  67. // paySign: "6DC330CBDF6C29BEDD4D254D9DA97364"
  68. // signType: "MD5"
  69. // timeStamp: "1624445533"
  70. uni.requestPayment({
  71. orderInfo: res.data.order_num,
  72. timeStamp: res.data.timeStamp,
  73. nonceStr: res.data.nonceStr,
  74. package: res.data.package,
  75. signType: res.data.signType,
  76. paySign: res.data.paySign,
  77. complete: result => {
  78. console.log(result)
  79. }
  80. })
  81. })
  82. },
  83. // 切换tab
  84. change(index) {
  85. this.current = index;
  86. },
  87. // 获取分类tab
  88. getCategoryList(){
  89. this.$http(this.API.API_CATEGORY_LIST).then(res => {
  90. let res_list = res.data || [];
  91. let tab_list = res_list.map(item => {
  92. return {
  93. id: item.id,
  94. name: item.name,
  95. type: item.type,
  96. list: [],
  97. loadingClass: true,
  98. loadingText: '正在加载中',
  99. page: 1,
  100. isPage: true
  101. }
  102. })
  103. this.tab_list = tab_list;
  104. this.getGoodsList();
  105. })
  106. },
  107. // 获取分类下的商品列表
  108. getGoodsList(){
  109. let per_page = this.pageSize;
  110. let tab_item = this.tab_list[this.current];
  111. this.$http(this.API.API_GOODS_LIST, {
  112. category_id: tab_item.id,
  113. type: tab_item.type,
  114. page: tab_item.page,
  115. per_page
  116. }).then(res => {
  117. console.log("res", res);
  118. let isPage = res.data.has_more_page;
  119. tab_item.isPage = isPage;
  120. if(isPage){
  121. tab_item.loadingClass = true;
  122. tab_item.loadingText = '正在加载中';
  123. }else{
  124. tab_item.loadingClass = false;
  125. tab_item.loadingText = '没有更多数据啦~';
  126. }
  127. if(tab_item.page == 1){
  128. tab_item.list = res.data.items;
  129. }else{
  130. tab_item.list.push(...res.data.items);
  131. }
  132. })
  133. },
  134. // 去到详情页
  135. toDetail(item){
  136. this.$url('/pages/goodsDetail/index?id='+ item.id);
  137. }
  138. },
  139. onReachBottom(){
  140. let tab_item = this.tab_list[this.current];
  141. if(tab_item.isPage){
  142. tab_item.page = tab_item.page + 1;
  143. this.getGoodsList();
  144. }
  145. },
  146. onPullDownRefresh(){
  147. let tab_item = this.tab_list[this.current];
  148. tab_item.page = 1;
  149. tab_item.isPage = true;
  150. tab_item.loadingClass = true;
  151. tab_item.loadingText = '正在加载中';
  152. this.getGoodsList();
  153. uni.stopPullDownRefresh()
  154. }
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. .title {
  159. font-size: 28rpx;
  160. color: $u-content-color;
  161. height: 88rpx;
  162. }
  163. // tab
  164. .ctab{
  165. width: 100%;
  166. margin: 20rpx 0 0rpx 0rpx;
  167. padding: 0 22rpx;
  168. }
  169. // 商品列表
  170. .com{
  171. width: 100%;
  172. overflow: hidden;
  173. .list{
  174. border-radius: 10rpx;
  175. overflow: hidden;
  176. margin: 20rpx 32rpx;
  177. background-color: #FFFFFF;
  178. box-shadow: 0 10rpx 20rpx 0 rgba(0, 0, 0, 0.1);
  179. align-items: flex-start;
  180. .left{
  181. overflow: hidden;
  182. image{
  183. width: 204rpx;
  184. height: 204rpx;
  185. margin: 20rpx;
  186. border-radius: 10rpx;
  187. }
  188. }
  189. .right{
  190. overflow: hidden;
  191. width: 64%;
  192. .title{
  193. margin: 18rpx 20rpx 0 0;
  194. color: #222222;
  195. font-size: 32rpx;
  196. }
  197. .tips{
  198. margin: 16rpx 0;
  199. overflow: hidden;
  200. .u-line-progress{
  201. width: 112rpx;
  202. overflow: hidden;
  203. margin-right:20rpx ;
  204. }
  205. .progress{
  206. color: #777777;
  207. font-size: 24rpx;
  208. }
  209. .bought{
  210. color: #777777;
  211. font-size: 24rpx;
  212. margin-right: 20rpx;
  213. }
  214. }
  215. .price{
  216. overflow: hidden;
  217. color:#FF0000;
  218. // text{
  219. // font-size: 48rpx;
  220. // color:#FF0000;
  221. // font-weight: 500;
  222. // }
  223. // text:nth-child(1){
  224. // color: #FF0000;
  225. // font-size: 28rpx;
  226. // }
  227. // text:nth-child(2){
  228. // color: #FF0000;
  229. // font-size: 48rpx;
  230. // }
  231. // text:nth-child(3){
  232. // color: #FF0000;
  233. // font-size: 28rpx;
  234. // }
  235. // text:nth-child(4){
  236. // color: #777777;
  237. // font-size: 28rpx;
  238. // text-decoration:line-through;
  239. // font-weight: 400;
  240. // }
  241. button{
  242. width: 160rpx;
  243. height: 60rpx;
  244. background: #FE9903;
  245. border-radius: 15px;
  246. font-size: 24rpx;
  247. color: #FFFFFF;
  248. margin: 0rpx 20rpx 0rpx 20rpx;
  249. border: none;
  250. }
  251. }
  252. }
  253. }
  254. }
  255. </style>