0
点赞
收藏
分享

微信扫一扫

查查表:纯js代码记录

飞鸟不急 2022-03-12 阅读 47

 封装网络请求

获取且定义变量的写法

设置值的方式

      getSalesStatistics() {
                let apiName = "salesStatistics";
                let { paramsForSort } = this.data;

                statictisService[apiName](paramsForSort)
                    .then(({ result }) => {
                        let { grossProfitMargin, saleStatisticsDOPage, totalGrossProfit, totalSales, totalSalesPrice } = result;

                        this.setData({
                            grossProfitMargin: this.toPercent(grossProfitMargin),
                            totalGrossProfit,
                            totalSales,
                            totalSalesPrice,
                            saleListWrapper: saleStatisticsDOPage,
                            saleList: saleStatisticsDOPage.list,
                        });
                    })
                    .finally(() => {
                        this.setData({
                            loading: false,
                        });
                    });
            },

定义条件查询的请求参数

使用Component构造页面 



const app = getApp();

// 请统一使用Component构造页面
Component(
    app.beforeEnter({
        options: {},
        properties: {},
        data: {
           
        },
        computed: {},
        pageLifetimes: {
            show() {
               
            },
        },
        lifetimes: {
            attached() {},
        },

        methods: {
        },
    })
);
举报

相关推荐

0 条评论