businessHome.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. jump(e) {
  59. const { path, tabvalue = '' } = e.currentTarget.dataset
  60. wx.navigateTo({
  61. url: `/pages/${path}/${path}?tabvalue=${tabvalue}`
  62. })
  63. },
  64. handleNav(e) {
  65. const { item } = e.currentTarget.dataset
  66. const path = item.path
  67. wx.navigateTo({
  68. url: `/pages/${path}/${path}`
  69. })
  70. },
  71. async fetchShopInfo() {
  72. try {
  73. // const { status, data } = await getShopInfo()
  74. const { status, data, msg } = {
  75. 'status': true,
  76. 'data': {
  77. 'products': [
  78. {
  79. 'product_title': '测试商品',
  80. 'product_price': 9000,
  81. 'id': 2,
  82. 'created_at': '2022-09-14 16:45:54'
  83. }
  84. ],
  85. 'user_nickname': 'sd',
  86. 'user_phone': '18768452697',
  87. 'user_head_img_url': 'sdsff',
  88. 'id': 1,
  89. 'product_total': 1
  90. },
  91. 'code': 200,
  92. 'msg': '',
  93. 'url': ''
  94. }
  95. if (status) {
  96. this.setData({
  97. shopInfo: data,
  98. products: data.products
  99. })
  100. } else {
  101. wx.showToast({
  102. title: msg,
  103. icon: 'none'
  104. })
  105. }
  106. } catch (err) {}
  107. }
  108. })