index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. // pages/test/index.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. frameStyle: { useTop: true, name: '测试页面', leftArrow: true, useBar: true },
  9. // 主体高度
  10. infoHeight: '',
  11. // 图片
  12. img_url: [],
  13. // dialog弹框
  14. dialog: { title: '弹框标题', show: false, type: '1' },
  15. // 选项卡
  16. tabs: {
  17. active: 'a',
  18. list: [
  19. { title: '选项卡一', name: 'a' },
  20. { title: '选项卡二', name: 'b' },
  21. { title: '选项卡三', name: 'c' },
  22. ],
  23. },
  24. // 侧导航
  25. sidebar: {
  26. active: 0,
  27. list: [
  28. { title: '标签一', disabled: false },
  29. { title: '标签二', disabled: false },
  30. { title: '标签三', disabled: false },
  31. ]
  32. }
  33. },
  34. // 侧导航选择
  35. sidebarChange: function (e) {
  36. const that = this;
  37. that.setData({ 'sidebar.active': e.detail })
  38. },
  39. // 跳转菜单
  40. tabPath(e) {
  41. let { route } = e.detail.detail;
  42. if (route) wx.redirectTo({ url: `/${route}` })
  43. },
  44. // 返回上一页
  45. back: function () {
  46. wx.navigateBack({ delta: 1 })
  47. },
  48. // 上传图片
  49. imgUpl: function (e) {
  50. const that = this;
  51. let data = that.data.img_url;
  52. data.push(e.detail)
  53. that.setData({ img_url: data })
  54. },
  55. // 删除图片
  56. imgDel: function (e) {
  57. const that = this;
  58. let list = that.data.img_url;
  59. let arr = list.filter((i, index) => index != e.detail.index)
  60. that.setData({ img_url: arr })
  61. },
  62. // 打开弹框
  63. toDialog: function () {
  64. const that = this;
  65. that.setData({ dialog: { title: '弹框标题', show: true, type: '1' } })
  66. },
  67. // 关闭弹框
  68. toClose: function () {
  69. const that = this;
  70. that.setData({ dialog: { title: '弹框标题', show: false, type: '1' } })
  71. },
  72. // 选项卡
  73. tabsChange: function (e) {
  74. const that = this;
  75. that.setData({ 'tabs.active': e.detail.name });
  76. },
  77. /**
  78. * 生命周期函数--监听页面加载
  79. */
  80. onLoad: function (options) {
  81. const that = this;
  82. },
  83. /**
  84. * 生命周期函数--监听页面初次渲染完成
  85. */
  86. onReady: function () {
  87. },
  88. /**
  89. * 生命周期函数--监听页面显示
  90. */
  91. onShow: function () {
  92. },
  93. /**
  94. * 生命周期函数--监听页面隐藏
  95. */
  96. onHide: function () {
  97. },
  98. /**
  99. * 生命周期函数--监听页面卸载
  100. */
  101. onUnload: function () {
  102. },
  103. /**
  104. * 页面相关事件处理函数--监听用户下拉动作
  105. */
  106. onPullDownRefresh: function () {
  107. },
  108. /**
  109. * 页面上拉触底事件的处理函数
  110. */
  111. onReachBottom: function () {
  112. },
  113. /**
  114. * 用户点击右上角分享
  115. */
  116. onShareAppMessage: function () {
  117. }
  118. })