businessHome.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. const { getShopInfo } = require('./api/index')
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. nav: [
  8. {
  9. icon: 'goods_release.png',
  10. name: '产品发布',
  11. path: 'businessGoodsEdit'
  12. },
  13. {
  14. icon: 'goods_manage.png',
  15. name: '产品管理',
  16. path: 'businessGoodsManage'
  17. },
  18. // {
  19. // icon: 'video_manage.png',
  20. // name: '视频管理',
  21. // path: 'businessVideoManage'
  22. // },
  23. {
  24. icon: 'message.png',
  25. name: '互动消息',
  26. path: 'businessLeavingAMessage'
  27. }
  28. ],
  29. shopInfo: {},
  30. products: []
  31. },
  32. /**
  33. * 生命周期函数--监听页面加载
  34. */
  35. onLoad(options) {
  36. this.fetchShopInfo()
  37. },
  38. /**
  39. * 生命周期函数--监听页面初次渲染完成
  40. */
  41. onReady() {
  42. },
  43. /**
  44. * 生命周期函数--监听页面显示
  45. */
  46. onShow() {
  47. },
  48. /**
  49. * 生命周期函数--监听页面隐藏
  50. */
  51. onHide() {
  52. },
  53. /**
  54. * 生命周期函数--监听页面卸载
  55. */
  56. onUnload() {
  57. },
  58. handleNav(e) {
  59. const { item } = e.currentTarget.dataset
  60. const path = item.path
  61. wx.navigateTo({
  62. url: `/pages/${path}/${path}`
  63. })
  64. },
  65. async fetchShopInfo() {
  66. try {
  67. // const { status, data } = await getShopInfo()
  68. const { status, data, msg } = {
  69. 'status': true,
  70. 'data': {
  71. 'products': [
  72. {
  73. 'product_title': '测试商品',
  74. 'product_price': 9000,
  75. 'id': 2,
  76. 'created_at': '2022-09-14 16:45:54'
  77. }
  78. ],
  79. 'user_nickname': 'sd',
  80. 'user_phone': '18768452697',
  81. 'user_head_img_url': 'sdsff',
  82. 'id': 1,
  83. 'product_total': 1
  84. },
  85. 'code': 200,
  86. 'msg': '',
  87. 'url': ''
  88. }
  89. if (status) {
  90. this.setData({
  91. shopInfo: data,
  92. products: data.products
  93. })
  94. } else {
  95. wx.showToast({
  96. title: msg,
  97. icon: 'none'
  98. })
  99. }
  100. } catch (err) {}
  101. }
  102. })