text.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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: 'page/component/pages/text/text'
  21. }
  22. },
  23. data: {
  24. text: '',
  25. canAdd: true,
  26. canRemove: false
  27. },
  28. extraLine: [],
  29. add() {
  30. this.extraLine.push(texts[this.extraLine.length % 12])
  31. this.setData({
  32. text: this.extraLine.join('\n'),
  33. canAdd: this.extraLine.length < 12,
  34. canRemove: this.extraLine.length > 0
  35. })
  36. setTimeout(() => {
  37. this.setData({
  38. scrollTop: 99999
  39. })
  40. }, 0)
  41. },
  42. remove() {
  43. if (this.extraLine.length > 0) {
  44. this.extraLine.pop()
  45. this.setData({
  46. text: this.extraLine.join('\n'),
  47. canAdd: this.extraLine.length < 12,
  48. canRemove: this.extraLine.length > 0,
  49. })
  50. }
  51. setTimeout(() => {
  52. this.setData({
  53. scrollTop: 99999
  54. })
  55. }, 0)
  56. }
  57. })