goods-classify.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <view class="container all-type-list-wrapper">
  3. <product-list ref="childList" :empty-text="emptyText" :serverUrl="serverUrl" :classifyID="classifyID" v-if="isRequest"></product-list>
  4. </view>
  5. </template>
  6. <script>
  7. import productList from '@/components/cm-module/listTemplate/classifyProductList'
  8. export default{
  9. components:{
  10. productList
  11. },
  12. data(){
  13. return{
  14. serverUrl: '',
  15. emptyText: '该分类暂时还没有商品哟,去逛逛别的吧~',
  16. lastPageType: '',
  17. lastPageVal: '',
  18. isRequest:false,
  19. classifyID:null
  20. }
  21. },
  22. onLoad(option) {
  23. let self = this;
  24. self.setServerUrl(option);
  25. },
  26. methods:{
  27. setServerUrl(option) {
  28. let self = this;
  29. const {type, from: value} = option;
  30. this.lastPageType = type;
  31. this.lastPageVal = value;
  32. uni.setNavigationBarTitle({title:value});
  33. uni.getStorage({
  34. key: 'commodity_id',
  35. success: function (res) {
  36. self.classifyID = res.data;
  37. self.isRequest = true
  38. }
  39. })
  40. }
  41. },
  42. onShow() {
  43. let pages = getCurrentPages(),
  44. thisPage = pages[pages.length - 1];
  45. if(thisPage.refresh) {
  46. this.setServerUrl(thisPage.listData);
  47. }
  48. }
  49. }
  50. </script>
  51. <style lang="scss">
  52. page {
  53. background: $sub-bg-color;
  54. .all-type-list-wrapper {
  55. display: flex;
  56. flex-direction: column;
  57. }
  58. }
  59. </style>