12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <template>
- <view class="container all-type-list-wrapper">
- <commodity-list ref="childList" :empty-text="emptyText"></commodity-list>
- </view>
- </template>
- <script>
- import commodityList from '@/components/cm-module/listTemplate/commodityList'
-
- export default{
- components:{
- commodityList
- },
- data(){
- return{
- serverUrl: '',
- emptyText: '',
- lastPageType: '',
- lastPageVal: '',
- }
- },
- onLoad(option) {
- let self = this;
- self.setServerUrl(option);
- },
- methods:{
- setServerUrl(option) {
- let self = this;
- const {type, from: value} = option;
- this.lastPageType = type;
- this.lastPageVal = value;
- uni.setNavigationBarTitle({title:value});
- uni.getStorage({
- key: 'commodity_id',
- success: function (res) {
- const id = res.data;
- const emptyTxt = '正在上架中,敬请期待~';
- const otherTypeUrl = '/product/preferred';
- /**
- *@商品分类列表传参类型
- *@type 首页分类:0,首页商品模块1:1,首页商品模块2:2,首页商品模块3:3,底部导航分类:4
- **/
- switch(type){
- case '0':
- self.serverUrl = `/home/classify?classifyId=${id}`;
- self.emptyText = '该分类暂时还没有商品哟,去逛逛别的吧~';
- break;
- case '1':
- self.serverUrl = `${otherTypeUrl}?preferredFlag=001`;
- self.emptyText = `${self.lastPageVal}商品${emptyTxt}`;
- break;
- case '2':
- self.serverUrl = `${otherTypeUrl}?preferredFlag=010`;
- self.emptyText = `${self.lastPageVal}商品${emptyTxt}`;
- break;
- case '3':
- self.serverUrl = `${otherTypeUrl}?preferredFlag=100`;
- self.emptyText = `${self.lastPageVal}商品${emptyTxt}`;
- break;
- case '4':
- self.serverUrl = `/product/listByTinyTypeID?tinyTypeID=${id}`;
- self.emptyText = '该分类暂时还没有商品哟,去逛逛别的吧~';
- break;
- }
- self.$refs.childList.getListFromServer();
- }
- })
- }
- },
- onShow() {
- let pages = getCurrentPages(),
- thisPage = pages[pages.length - 1];
- if(thisPage.refresh) {
- this.setServerUrl(thisPage.listData);
- }
- }
- }
- </script>
- <style lang="scss">
- page {
- background: $sub-bg-color;
- .all-type-list-wrapper {
- display: flex;
- flex-direction: column;
- }
- }
- </style>
|