text.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. const texts = [
  2. '2011年1月,微信1.0发布',
  3. '同年5月,微信2.0语音对讲发布',
  4. '10月,微信3.0新增摇一摇功能',
  5. '2012年3月,微信用户突破1亿',
  6. '4月份,微信4.0朋友圈发布',
  7. '同年7月,微信4.2发布公众平台',
  8. '2013年8月,微信5.0发布微信支付',
  9. '2014年9月,企业号发布',
  10. '同月,发布微信卡包',
  11. '2015年1月,微信第一条朋友圈广告',
  12. '2016年1月,企业微信发布',
  13. '2017年1月,小程序发布',
  14. '......'
  15. ]
  16. Page({
  17. onShareAppMessage() {
  18. return {
  19. title: 'text',
  20. path: 'packageComponent/pages/content/text/text'
  21. }
  22. },
  23. data: {
  24. theme: 'light',
  25. text: '',
  26. canAdd: true,
  27. canRemove: false
  28. },
  29. extraLine: [],
  30. add() {
  31. this.extraLine.push(texts[this.extraLine.length % 12])
  32. this.setData({
  33. text: this.extraLine.join('\n'),
  34. canAdd: this.extraLine.length < 12,
  35. canRemove: this.extraLine.length > 0
  36. })
  37. setTimeout(() => {
  38. this.setData({
  39. scrollTop: 99999
  40. })
  41. }, 0)
  42. },
  43. remove() {
  44. if (this.extraLine.length > 0) {
  45. this.extraLine.pop()
  46. this.setData({
  47. text: this.extraLine.join('\n'),
  48. canAdd: this.extraLine.length < 12,
  49. canRemove: this.extraLine.length > 0,
  50. })
  51. }
  52. setTimeout(() => {
  53. this.setData({
  54. scrollTop: 99999
  55. })
  56. }, 0)
  57. },
  58. onLoad() {
  59. this.setData({
  60. theme: wx.getSystemInfoSync().theme || 'light'
  61. })
  62. if (wx.onThemeChange) {
  63. wx.onThemeChange(({theme}) => {
  64. this.setData({theme})
  65. })
  66. }
  67. }
  68. })