index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // pagesCommon/test/index.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. form: {
  8. imgList: []
  9. },
  10. // 弹框
  11. dialog: { title: '弹框标题', show: false, type: '1' },
  12. // 日期时间选择
  13. dateform: {},
  14. // 选项卡
  15. tabs: {
  16. active: 'a',
  17. menu: [
  18. { title: '选项卡一', active: 'a' },
  19. { title: '选项卡二', active: 'b' },
  20. { title: '选项卡三', active: 'c' },
  21. { title: '选项卡四', active: 'd' },
  22. { title: '选项卡五', active: 'e' },
  23. ],
  24. },
  25. // 富文本
  26. content: ''
  27. },
  28. // 上传图片
  29. imgUpl: function (e) {
  30. const that = this;
  31. let data = that.data.form[e.detail.name];
  32. data.push(e.detail.data)
  33. that.setData({ [`form.${e.detail.name}`]: data })
  34. },
  35. // 删除图片
  36. imgDel: function (e) {
  37. const that = this;
  38. let data = that.data.form[e.detail.name];
  39. let arr = data.filter((i, index) => index != e.detail.data.index)
  40. that.setData({ [`form.${e.detail.name}`]: arr })
  41. },
  42. // 打开弹框
  43. toDialog: function () {
  44. const that = this;
  45. that.setData({ dialog: { title: '弹框标题', show: true, type: '1' } })
  46. },
  47. // 关闭弹框
  48. toClose: function () {
  49. const that = this;
  50. that.setData({ dialog: { title: '弹框标题', show: false, type: '1' } })
  51. },
  52. // 日期时间选择
  53. datetimeChange: function (e) {
  54. const that = this;
  55. that.setData({ [`dateform.${e.detail.name}`]: e.detail.datetime });
  56. },
  57. // 选择选项卡
  58. tabsChange: function (e) {
  59. const that = this;
  60. const { title, active } = e.detail;
  61. that.setData({ 'tabs.active': active });
  62. },
  63. // 监听富文本输入
  64. bindInput: function (e) {
  65. const that = this;
  66. const { html, text, name } = e.detail;
  67. that.setData({ [`${name}`]: html })
  68. },
  69. /**
  70. * 生命周期函数--监听页面加载
  71. */
  72. onLoad(options) {
  73. },
  74. /**
  75. * 生命周期函数--监听页面初次渲染完成
  76. */
  77. onReady() {
  78. },
  79. /**
  80. * 生命周期函数--监听页面显示
  81. */
  82. onShow() {
  83. },
  84. /**
  85. * 生命周期函数--监听页面隐藏
  86. */
  87. onHide() {
  88. },
  89. /**
  90. * 生命周期函数--监听页面卸载
  91. */
  92. onUnload() {
  93. },
  94. /**
  95. * 页面相关事件处理函数--监听用户下拉动作
  96. */
  97. onPullDownRefresh() {
  98. },
  99. /**
  100. * 页面上拉触底事件的处理函数
  101. */
  102. onReachBottom() {
  103. },
  104. /**
  105. * 用户点击右上角分享
  106. */
  107. onShareAppMessage() {
  108. }
  109. })