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

268 lines
6.3 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
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 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 original-price">{{ 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 = false;
  122. tab_item.loadingText = '没有更多数据啦~';
  123. }
  124. if(tab_item.page == 1){
  125. tab_item.list = res.data.items;
  126. }else{
  127. tab_item.list.push(...res.data.items);
  128. }
  129. })
  130. },
  131. // 去到详情页
  132. toDetail(item){
  133. this.$url('/pages/goodsDetail/index?id='+ item.id);
  134. }
  135. },
  136. onReachBottom(){
  137. let tab_item = this.tab_list[this.current];
  138. if(tab_item.isPage){
  139. tab_item.page = tab_item.page + 1;
  140. this.getGoodsList();
  141. }
  142. },
  143. onPullDownRefresh(){
  144. let tab_item = this.tab_list[this.current];
  145. tab_item.page = 1;
  146. tab_item.isPage = true;
  147. tab_item.loadingClass = true;
  148. tab_item.loadingText = '正在加载中';
  149. this.getGoodsList();
  150. uni.stopPullDownRefresh()
  151. },
  152. // onShareAppMessage(){
  153. // }
  154. }
  155. </script>
  156. <style lang="scss" scoped>
  157. .title {
  158. font-size: 28rpx;
  159. color: $u-content-color;
  160. height: 88rpx;
  161. }
  162. // tab
  163. .ctab{
  164. width: 100%;
  165. margin: 20rpx 0 0rpx 0rpx;
  166. padding: 0 22rpx;
  167. }
  168. // 商品列表
  169. .com{
  170. width: 100%;
  171. overflow: hidden;
  172. .list{
  173. border-radius: 10rpx;
  174. overflow: hidden;
  175. margin: 20rpx 32rpx;
  176. background-color: #FFFFFF;
  177. box-shadow: 0 10rpx 20rpx 0 rgba(0, 0, 0, 0.1);
  178. align-items: flex-start;
  179. .left{
  180. overflow: hidden;
  181. image{
  182. width: 204rpx;
  183. height: 204rpx;
  184. margin: 20rpx;
  185. border-radius: 10rpx;
  186. }
  187. }
  188. .right{
  189. overflow: hidden;
  190. width: 64%;
  191. .title{
  192. margin: 18rpx 20rpx 0 0;
  193. color: #222222;
  194. font-size: 32rpx;
  195. }
  196. .tips{
  197. margin: 16rpx 0;
  198. overflow: hidden;
  199. .u-line-progress{
  200. width: 112rpx;
  201. overflow: hidden;
  202. margin-right:20rpx ;
  203. }
  204. .progress{
  205. color: #777777;
  206. font-size: 24rpx;
  207. }
  208. .bought{
  209. color: #777777;
  210. font-size: 24rpx;
  211. margin-right: 20rpx;
  212. }
  213. }
  214. .price{
  215. overflow: hidden;
  216. color:#FF0000;
  217. .original-price{
  218. text-decoration: line-through;
  219. color: #777777;
  220. }
  221. // text{
  222. // font-size: 48rpx;
  223. // color:#FF0000;
  224. // font-weight: 500;
  225. // }
  226. // text:nth-child(1){
  227. // color: #FF0000;
  228. // font-size: 28rpx;
  229. // }
  230. // text:nth-child(2){
  231. // color: #FF0000;
  232. // font-size: 48rpx;
  233. // }
  234. // text:nth-child(3){
  235. // color: #FF0000;
  236. // font-size: 28rpx;
  237. // }
  238. // text:nth-child(4){
  239. // color: #777777;
  240. // font-size: 28rpx;
  241. // text-decoration:line-through;
  242. // font-weight: 400;
  243. // }
  244. button{
  245. width: 160rpx;
  246. height: 60rpx;
  247. background: #FE9903;
  248. border-radius: 15px;
  249. font-size: 24rpx;
  250. color: #FFFFFF;
  251. margin: 0rpx 20rpx 0rpx 20rpx;
  252. border: none;
  253. }
  254. }
  255. }
  256. }
  257. }
  258. </style>