mall.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <view class="content">
  3. <view v-if="type == 1" class="pageThr"><hotgods :flag="1" :list="classList"></hotgods></view>
  4. <view v-if="type == 2" class="pageCon"><collage-list :flag="1" :list="classList"></collage-list></view>
  5. <view v-if="type == 3" class="pageCon"><skill-list :flag="1" :list="classList"></skill-list></view>
  6. </view>
  7. </template>
  8. <script>
  9. import collageList from '../components/collageMall.vue';
  10. import skillList from '../components/skillList.vue';
  11. import hotgods from './componets/hotgodlist.vue';
  12. export default {
  13. components: {
  14. collageList,
  15. skillList,
  16. hotgods
  17. },
  18. data() {
  19. return {
  20. flag:1,
  21. keyword: '',
  22. cat_id: '', //分类id
  23. type: 1, // 1普通订单 2拼团订单 3秒杀订单
  24. classList: [
  25. // { image: '/static/img/pro/indnotice.png', name: '知识过关', path: '/pages/knowledge/knowledge' },
  26. // { image: '/static/img/pro/indnotice.png', name: '知识过关', path: '/pages/knowledge/knowledge' },
  27. ],
  28. status: 'loadmore',
  29. page: 1,
  30. pagenum: 6
  31. };
  32. },
  33. onPullDownRefresh() {
  34. setTimeout(res => {
  35. uni.stopPullDownRefresh();
  36. }, 1000);
  37. },
  38. onReachBottom() {
  39. if (this.status == 'nomore') return;
  40. this.status = 'loadmore';
  41. this.page = ++this.page;
  42. this.getInfoList();
  43. },
  44. onLoad(opt) {
  45. this.flag = opt.flag || 1;
  46. this.type = opt.type || 1;
  47. this.cat_id = opt.id || '';
  48. this.keyword = opt.keyword || '';
  49. if (this.type == 1) {
  50. uni.setNavigationBarTitle({
  51. title: '热门资料'
  52. });
  53. } else if (this.type == 2) {
  54. uni.setNavigationBarTitle({
  55. title: '拼团'
  56. });
  57. } else {
  58. uni.setNavigationBarTitle({
  59. title: '秒杀'
  60. });
  61. }
  62. this.getInfoList();
  63. },
  64. methods: {
  65. getInfoList() {
  66. this.status = 'loadmore';
  67. let url = this.type == 1 ? 'goods/goods_list' : this.type == 2 ? 'grouporder/group_lists' : 'seckillorder/seckill_lists';
  68. this.$api
  69. .request(url, {
  70. type:this.flag||"",
  71. cat_id: this.cat_id || '',
  72. keyword: this.keyword || '',
  73. page: this.page,
  74. pagenum: this.pagenum
  75. })
  76. .then(data => {
  77. console.log(data);
  78. if (data.code == 200) {
  79. if(this.type==1){
  80. let list = data.data.goods;
  81. this.classList = this.classList.concat(list);
  82. if (list.length < this.pagenum) {
  83. this.status = 'nomore';
  84. }
  85. }else{
  86. let list = data.data;
  87. this.classList = this.classList.concat(list);
  88. if (list.length < this.pagenum) {
  89. this.status = 'nomore';
  90. }
  91. }
  92. } else {
  93. this.$api.toast(data.msg);
  94. }
  95. });
  96. },
  97. toNext(url) {
  98. uni.navigateTo({
  99. url: url
  100. });
  101. }
  102. }
  103. };
  104. </script>
  105. <style lang="scss" scoped>
  106. .pageCon {
  107. padding: 20rpx 30rpx;
  108. }
  109. .pageThr {
  110. padding: 20rpx 0;
  111. }
  112. </style>