goods.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view class="container all-type-list-wrapper">
  3. <commodity-list ref="childList" :empty-text="emptyText" :serverUrl="serverUrl" :typeId="typeId" v-if="isRequest"></commodity-list>
  4. </view>
  5. </template>
  6. <script>
  7. import commodityList from '@/components/cm-module/listTemplate/commodityList'
  8. export default{
  9. components:{
  10. commodityList
  11. },
  12. data(){
  13. return{
  14. serverUrl: '',
  15. emptyText: '',
  16. lastPageType: '',
  17. lastPageVal: '',
  18. isRequest:false,
  19. typeId:null
  20. }
  21. },
  22. onLoad(option) {
  23. this.setServerUrl(option);
  24. },
  25. methods:{
  26. setServerUrl(option) {
  27. let self = this;
  28. const {type, from: value} = option;
  29. this.lastPageType = type;
  30. this.lastPageVal = value;
  31. uni.setNavigationBarTitle({title:value});
  32. uni.getStorage({
  33. key: 'commodity_id',
  34. success: function (res) {
  35. const emptyTxt = '正在上架中,敬请期待~';
  36. /**
  37. *@商品分类列表传参类型
  38. *@type 首页分类:0,首页商品模块1:1,首页商品模块2:2,首页商品模块3:3,底部导航分类:4
  39. **/
  40. switch(type){
  41. case '0':
  42. self.typeId = res.data;
  43. self.serverUrl = '/search/query/product/classify';
  44. self.emptyText = '该分类暂时还没有商品哟,去逛逛别的吧~';
  45. break;
  46. case '1':
  47. self.typeId = 1;
  48. self.serverUrl = '/search/query/product/preferred';
  49. self.emptyText = `${self.lastPageVal}商品${emptyTxt}`;
  50. break;
  51. case '2':
  52. self.typeId = 10;
  53. self.serverUrl = '/search/query/product/preferred';
  54. self.emptyText = `${self.lastPageVal}商品${emptyTxt}`;
  55. break;
  56. case '3':
  57. self.typeId = 100;
  58. self.serverUrl = '/search/query/product/preferred';
  59. self.emptyText = `${self.lastPageVal}${emptyTxt}`;
  60. break;
  61. case '4':
  62. self.typeId = res.data;
  63. self.serverUrl = '/search/query/product/tinyType';
  64. self.emptyText = '该分类暂时还没有商品哟,去逛逛别的吧~';
  65. break;
  66. }
  67. self.isRequest = true
  68. }
  69. })
  70. }
  71. },
  72. onShow() {
  73. let pages = getCurrentPages(),
  74. thisPage = pages[pages.length - 1];
  75. if(thisPage.refresh) {
  76. this.setServerUrl(thisPage.listData);
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="scss">
  82. page {
  83. background: $sub-bg-color;
  84. .all-type-list-wrapper {
  85. display: flex;
  86. flex-direction: column;
  87. }
  88. }
  89. </style>