123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <template>
- <view class="container all-type-list-wrapper">
- <commodity-list ref="childList" :empty-text="emptyText"></commodity-list>
- </view>
- </template>
- <script>
- import commodityList from '@/components/module/listTemplate/commodityList'
-
- export default{
- components:{
- commodityList
- },
- data(){
- return{
- serverUrl: '',
- emptyText: '',
- lastPageType: '',
- lastPageVal: '',
- userID:'',
- }
- },
- 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;
- if(type === '商品分类') {
- self.serverUrl = `/product/listByTinyTypeID?tinyTypeID=${id}`;
- self.emptyText = '该分类暂时还没有商品哟,去逛逛别的吧~';
- self.$refs.childList.getListFromServer();
- }
- }
- })
- if(type !== '商品分类') {
- // 空内容文案
- const emptyTxt = '正在上架中,敬请期待~',
- otherTypeUrl = '/product/preferred';
- if(type === '1') {
- this.serverUrl = `${otherTypeUrl}?preferredFlag=001`;
- this.emptyText = `${this.lastPageVal}商品${emptyTxt}`;
- } else if(type === '2') {
- this.serverUrl = `${otherTypeUrl}?preferredFlag=010`;
- this.emptyText = `${this.lastPageVal}商品${emptyTxt}`;
- } else if(type === '3') {
- this.serverUrl = `${otherTypeUrl}?preferredFlag=100`;
- this.emptyText = `${this.lastPageVal}商品${emptyTxt}`;
- }
- this.$refs.childList.getListFromServer();
- }
- }
- },
- onShow() {
- let pages = getCurrentPages(),
- thisPage = pages[pages.length - 1];
- if(thisPage.refresh) {
- this.setServerUrl(thisPage.listData);
- }
- this.$api.getStorage().then((resolve) =>{
- this.userID = resolve.userID
- })
- }
- }
- </script>
- <style lang="scss">
- page {
- background: $sub-bg-color;
- .all-type-list-wrapper {
- display: flex;
- flex-direction: column;
- }
- }
- </style>
|