goods.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <view class="container all-type-list-wrapper">
  3. <commodity-list ref="childList" :empty-text="emptyText"></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. }
  19. },
  20. onLoad(option) {
  21. let self = this;
  22. self.setServerUrl(option);
  23. },
  24. methods:{
  25. setServerUrl(option) {
  26. let self = this;
  27. const {type, from: value} = option;
  28. this.lastPageType = type;
  29. this.lastPageVal = value;
  30. uni.setNavigationBarTitle({title:value});
  31. uni.getStorage({
  32. key: 'commodity_id',
  33. success: function (res) {
  34. const id = res.data;
  35. const emptyTxt = '正在上架中,敬请期待~';
  36. const otherTypeUrl = '/product/preferred';
  37. /**
  38. *@商品分类列表传参类型
  39. *@type 首页分类:0,首页商品模块1:1,首页商品模块2:2,首页商品模块3:3,底部导航分类:4
  40. **/
  41. switch(type){
  42. case '0':
  43. self.serverUrl = `/home/classify?classifyId=${id}`;
  44. self.emptyText = '该分类暂时还没有商品哟,去逛逛别的吧~';
  45. break;
  46. case '1':
  47. self.serverUrl = `${otherTypeUrl}?preferredFlag=001`;
  48. self.emptyText = `${self.lastPageVal}商品${emptyTxt}`;
  49. break;
  50. case '2':
  51. self.serverUrl = `${otherTypeUrl}?preferredFlag=010`;
  52. self.emptyText = `${self.lastPageVal}商品${emptyTxt}`;
  53. break;
  54. case '3':
  55. self.serverUrl = `${otherTypeUrl}?preferredFlag=100`;
  56. self.emptyText = `${self.lastPageVal}商品${emptyTxt}`;
  57. break;
  58. case '4':
  59. self.serverUrl = `/product/listByTinyTypeID?tinyTypeID=${id}`;
  60. self.emptyText = '该分类暂时还没有商品哟,去逛逛别的吧~';
  61. break;
  62. }
  63. self.$refs.childList.getListFromServer();
  64. }
  65. })
  66. }
  67. },
  68. onShow() {
  69. let pages = getCurrentPages(),
  70. thisPage = pages[pages.length - 1];
  71. if(thisPage.refresh) {
  72. this.setServerUrl(thisPage.listData);
  73. }
  74. }
  75. }
  76. </script>
  77. <style lang="scss">
  78. page {
  79. background: $sub-bg-color;
  80. .all-type-list-wrapper {
  81. display: flex;
  82. flex-direction: column;
  83. }
  84. }
  85. </style>