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

271 lines
6.4 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 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. return {
  154. title: '分享小程序',
  155. path: '/pages/route/index'
  156. }
  157. }
  158. }
  159. </script>
  160. <style lang="scss" scoped>
  161. .title {
  162. font-size: 28rpx;
  163. color: $u-content-color;
  164. height: 88rpx;
  165. }
  166. // tab
  167. .ctab{
  168. width: 100%;
  169. margin: 20rpx 0 0rpx 0rpx;
  170. padding: 0 22rpx;
  171. }
  172. // 商品列表
  173. .com{
  174. width: 100%;
  175. overflow: hidden;
  176. .list{
  177. border-radius: 10rpx;
  178. overflow: hidden;
  179. margin: 20rpx 32rpx;
  180. background-color: #FFFFFF;
  181. box-shadow: 0 10rpx 20rpx 0 rgba(0, 0, 0, 0.1);
  182. align-items: flex-start;
  183. .left{
  184. overflow: hidden;
  185. image{
  186. width: 204rpx;
  187. height: 204rpx;
  188. margin: 20rpx;
  189. border-radius: 10rpx;
  190. }
  191. }
  192. .right{
  193. overflow: hidden;
  194. width: 64%;
  195. .title{
  196. margin: 18rpx 20rpx 0 0;
  197. color: #222222;
  198. font-size: 32rpx;
  199. }
  200. .tips{
  201. margin: 16rpx 0;
  202. overflow: hidden;
  203. .u-line-progress{
  204. width: 112rpx;
  205. overflow: hidden;
  206. margin-right:20rpx ;
  207. }
  208. .progress{
  209. color: #777777;
  210. font-size: 24rpx;
  211. }
  212. .bought{
  213. color: #777777;
  214. font-size: 24rpx;
  215. margin-right: 20rpx;
  216. }
  217. }
  218. .price{
  219. overflow: hidden;
  220. color:#FF0000;
  221. .original-price{
  222. text-decoration: line-through;
  223. color: #777777;
  224. }
  225. // text{
  226. // font-size: 48rpx;
  227. // color:#FF0000;
  228. // font-weight: 500;
  229. // }
  230. // text:nth-child(1){
  231. // color: #FF0000;
  232. // font-size: 28rpx;
  233. // }
  234. // text:nth-child(2){
  235. // color: #FF0000;
  236. // font-size: 48rpx;
  237. // }
  238. // text:nth-child(3){
  239. // color: #FF0000;
  240. // font-size: 28rpx;
  241. // }
  242. // text:nth-child(4){
  243. // color: #777777;
  244. // font-size: 28rpx;
  245. // text-decoration:line-through;
  246. // font-weight: 400;
  247. // }
  248. button{
  249. width: 160rpx;
  250. height: 60rpx;
  251. background: #FE9903;
  252. border-radius: 15px;
  253. font-size: 24rpx;
  254. color: #FFFFFF;
  255. margin: 0rpx 20rpx 0rpx 20rpx;
  256. border: none;
  257. }
  258. }
  259. }
  260. }
  261. }
  262. </style>