goods.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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/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. onShow() {
  21. let pages = getCurrentPages(),
  22. thisPage = pages[pages.length - 1];
  23. if(thisPage.refresh) {
  24. this.setServerUrl(thisPage.listData);
  25. }
  26. },
  27. onLoad(option) {
  28. let self = this;
  29. self.setServerUrl(option);
  30. },
  31. methods:{
  32. setServerUrl(option) {
  33. let self = this;
  34. console.log(option)
  35. const {type, from: value} = option;
  36. this.lastPageType = type;
  37. this.lastPageVal = value;
  38. uni.setNavigationBarTitle({title:value});
  39. uni.getStorage({
  40. key: 'commodity_id',
  41. success: function (res) {
  42. const id = res.data;
  43. if(type === '商品分类') {
  44. self.serverUrl = `/product/listByTinyTypeID?tinyTypeID=${id}`;
  45. self.emptyText = '该分类暂时还没有商品哟,去逛逛别的吧~';
  46. self.$refs.childList.getListFromServer();
  47. }
  48. }
  49. })
  50. if(type !== '商品分类') {
  51. // 空内容文案
  52. const emptyTxt = '正在上架中,敬请期待~',
  53. otherTypeUrl = '/product/preferred';
  54. if(type === '1') {
  55. this.serverUrl = `${otherTypeUrl}?preferredFlag=001`;
  56. this.emptyText = `${this.lastPageVal}商品${emptyTxt}`;
  57. } else if(type === '2') {
  58. this.serverUrl = `${otherTypeUrl}?preferredFlag=010`;
  59. this.emptyText = `${this.lastPageVal}商品${emptyTxt}`;
  60. } else if(type === '3') {
  61. this.serverUrl = `${otherTypeUrl}?preferredFlag=100`;
  62. this.emptyText = `${this.lastPageVal}商品${emptyTxt}`;
  63. }
  64. this.$refs.childList.getListFromServer();
  65. }
  66. }
  67. }
  68. }
  69. </script>
  70. <style lang="scss">
  71. page {
  72. background: $sub-bg-color;
  73. .all-type-list-wrapper {
  74. display: flex;
  75. flex-direction: column;
  76. }
  77. }
  78. </style>