-- 创造无限可能

配送小程序:

2023-07-07 21:53:12
238 人浏览 0 人点赞
有用,点赞支持一下

新增店铺和修改店铺页面内容一样,合并为一个页面

1.新增店铺:
提交按钮点击事件改为:@click=”submit”

传id:

 onLoad(option) {
            if (option.id) {
                // 接口地址
                http.get('/shop/info', {
                    id: option.id
                }).then(res => {
                    this.form = res.data
                })
            }
        }

方法

 methods{
    // 提交表单
    submit() {
        if (this.form.id) {
            this.saveShop()
        } else {
            this.createShop()
        }
     },
    // 创建店铺列表
        createShop() {
            http.post('/shop/create', this.form).then(res => {
                if (res.code == 0) {
                    alert(res.msg)
                    uni.switchTab({
                        url: '/pages/shop/list'
                    });
                }
            })
        },
    // 编辑店铺
        saveShop() {
            http.post('/shop/save', this.form).then(res => {
                if (res.code == 0) {
                    alert(res.msg)
                    uni.switchTab({
                        url: '/pages/shop/list'
                    });
                }
            })
        }
 }

状态切换

HTML代码:<u-tabs :list="list" :is-scroll="false" :current="current" @change="change"></u-tabs>
方法:
methods: {
// 获取订单列表
getOrderList() {
http.post(‘/order/query’, {
word: this.keyword,
// 状态
state: this.list[this.current][‘state’]
}).then(res => {
this.orderList = res.data.lists
})
},
// 状态切换
change(index) {
this.current = index;
this.getOrderList()
},
}