goods.vue 2.1 KB

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