index.js 815 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. //index.js
  2. //获取应用实例
  3. var app = getApp()
  4. var calc = require("../../utils/calc")
  5. Page({
  6. data: {
  7. calc: {},
  8. tapped: {}
  9. },
  10. showAbout: function(e){
  11. wx.showModal({
  12. title: '关于',
  13. content: '一个简单的计算器 @V1.0',
  14. showCancel: false
  15. })
  16. },
  17. btnClicked: function(e){
  18. var code = e.target.dataset.op
  19. calc.addOp(code)
  20. console.log(calc.getVars())
  21. this.setData({calc: calc.getVars()})
  22. },
  23. btnTouchStart: function(e){
  24. var code = e.target.dataset.op
  25. var tapped = {[code]: 'active'}
  26. this.setData({tapped: tapped})
  27. },
  28. btnTouchEnd: function(e){
  29. var code = e.target.dataset.op
  30. var tapped = {}
  31. this.setData({tapped: tapped})
  32. },
  33. onLoad: function () {
  34. console.log('onLoad')
  35. calc.reset()
  36. var that = this
  37. }
  38. })