const { getShopInfo } = require('./api/index') Page({ /** * 页面的初始数据 */ data: { nav: [ { icon: 'goods_release.png', name: '产品发布', path: 'businessGoodsEdit' }, { icon: 'goods_manage.png', name: '产品管理', path: 'businessGoodsManage' }, // { // icon: 'video_manage.png', // name: '视频管理', // path: 'businessVideoManage' // }, { icon: 'message.png', name: '互动消息', path: 'businessLeavingAMessage' } ], shopInfo: {}, products: [] }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.fetchShopInfo() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, jump(e) { const { path, tabvalue = '' } = e.currentTarget.dataset wx.navigateTo({ url: `/pages/${path}/${path}?tabvalue=${tabvalue}` }) }, handleNav(e) { const { item } = e.currentTarget.dataset const path = item.path wx.navigateTo({ url: `/pages/${path}/${path}` }) }, async fetchShopInfo() { try { // const { status, data } = await getShopInfo() const { status, data, msg } = { 'status': true, 'data': { 'products': [ { 'product_title': '测试商品', 'product_price': 9000, 'id': 2, 'created_at': '2022-09-14 16:45:54' } ], 'user_nickname': 'sd', 'user_phone': '18768452697', 'user_head_img_url': 'sdsff', 'id': 1, 'product_total': 1 }, 'code': 200, 'msg': '', 'url': '' } if (status) { this.setData({ shopInfo: data, products: data.products }) } else { wx.showToast({ title: msg, icon: 'none' }) } } catch (err) {} } })