index.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. // 跳转菜单
  17. tabPath(e) {
  18. let { route } = e.detail.detail;
  19. if (route) wx.redirectTo({ url: `/${route}` })
  20. },
  21. // 返回上一页
  22. back: function () {
  23. wx.navigateBack({ delta: 1 })
  24. },
  25. // 上传图片
  26. imgUpl: function (e) {
  27. const that = this;
  28. let data = that.data.img_url;
  29. data.push(e.detail)
  30. that.setData({ img_url: data })
  31. },
  32. // 删除图片
  33. imgDel: function (e) {
  34. const that = this;
  35. let list = that.data.img_url;
  36. let arr = list.filter((i, index) => index != e.detail.index)
  37. that.setData({ img_url: arr })
  38. },
  39. // 打开弹框
  40. toDialog: function () {
  41. const that = this;
  42. that.setData({ dialog: { title: '弹框标题', show: true, type: '1' } })
  43. },
  44. // 关闭弹框
  45. toClose: function () {
  46. const that = this;
  47. that.setData({ dialog: { title: '弹框标题', show: false, type: '1' } })
  48. },
  49. /**
  50. * 生命周期函数--监听页面加载
  51. */
  52. onLoad: function (options) { },
  53. /**
  54. * 生命周期函数--监听页面初次渲染完成
  55. */
  56. onReady: function () {
  57. },
  58. /**
  59. * 生命周期函数--监听页面显示
  60. */
  61. onShow: function () {
  62. },
  63. /**
  64. * 生命周期函数--监听页面隐藏
  65. */
  66. onHide: function () {
  67. },
  68. /**
  69. * 生命周期函数--监听页面卸载
  70. */
  71. onUnload: function () {
  72. },
  73. /**
  74. * 页面相关事件处理函数--监听用户下拉动作
  75. */
  76. onPullDownRefresh: function () {
  77. },
  78. /**
  79. * 页面上拉触底事件的处理函数
  80. */
  81. onReachBottom: function () {
  82. },
  83. /**
  84. * 用户点击右上角分享
  85. */
  86. onShareAppMessage: function () {
  87. }
  88. })