result.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. var businessT = require('../../../tools/business-tool.js')
  2. var sysT = require('../../../tools/sys-tool.js')
  3. const average = [7425, 7480, 7706, 7132]
  4. const result = [
  5. { status: '有点寒碜', introductions: '努力提高你的工资吧' },
  6. { status: '衣食无忧', introductions: '不缺吃不缺穿,偶尔下馆子' },
  7. { status: '小资', introductions: '不愁吃不愁穿,还能旅个游' },
  8. { status: '土豪君', introductions: '可随便吃喝玩乐,任性不差钱' }
  9. ]
  10. var app = getApp()
  11. Page({
  12. /**
  13. * 页面的初始数据
  14. */
  15. data: {
  16. isRelay: false,
  17. result: {status: '', introductions: ''},
  18. ui: {
  19. nick: "",
  20. avatar: "",
  21. A: '',
  22. B: '',
  23. C: '',
  24. income: '',
  25. city: ''
  26. },
  27. interval: 0,
  28. medical: {
  29. s: false,
  30. d: ''
  31. },
  32. data: []
  33. },
  34. yearAction: businessT.action(function (sender) {
  35. wx.navigateTo({
  36. url: '../year/year',
  37. })
  38. }),
  39. getResult: function (income, city) {
  40. var a = average[3]
  41. businessT.debugLog(city);
  42. businessT.debugLog(a)
  43. if (income >= a * 1.5) {
  44. return result[3]
  45. } else if (income >= a) {
  46. return result[2]
  47. } else if (income >= a * 3 / 5) {
  48. return result[1]
  49. } else {
  50. return result[0]
  51. }
  52. },
  53. calculatorAction: businessT.action(function (sender) {
  54. wx.reLaunch({
  55. url: '../index',
  56. })
  57. }),
  58. //跳转社保小程序
  59. toPurchase: businessT.action(function (sender) {
  60. wx.navigateToMiniProgram({
  61. appId: 'wxbf3f03f8a7d0cdcf',
  62. })
  63. }),
  64. /**
  65. * 生命周期函数--监听页面加载
  66. */
  67. onLoad: function (options) {
  68. businessT.debugLog(options)
  69. this.data.ui.avatar = options.url
  70. this.data.ui.nick = options.nick
  71. this.data.ui.A = options.A
  72. this.data.ui.B = options.B
  73. this.data.ui.C = options.C
  74. this.data.ui.income = options.income
  75. this.data.ui.city = options.city
  76. this.data.result = this.getResult(options.income, options.city)
  77. if (options.isRelay) {
  78. this.data.isRelay = options.isRelay
  79. }
  80. //年度个税
  81. this.data.data = app.result
  82. this.data.medical.s = app.medical.s
  83. this.data.medical.d = app.medical.rebate.toFixed(2)
  84. this.setData({
  85. ui: this.data.ui,
  86. isRelay: this.data.isRelay,
  87. result: this.data.result,
  88. data: this.data.data,
  89. medical: this.data.medical
  90. })
  91. },
  92. /**
  93. * 生命周期函数--监听页面初次渲染完成
  94. */
  95. onReady: function () {
  96. },
  97. /**
  98. * 生命周期函数--监听页面显示
  99. */
  100. onShow: function () {
  101. },
  102. /**
  103. * 生命周期函数--监听页面隐藏
  104. */
  105. onHide: function () {
  106. },
  107. /**
  108. * 生命周期函数--监听页面卸载
  109. */
  110. onUnload: function () {
  111. },
  112. /**
  113. * 页面相关事件处理函数--监听用户下拉动作
  114. */
  115. onPullDownRefresh: function () {
  116. },
  117. /**
  118. * 页面上拉触底事件的处理函数
  119. */
  120. onReachBottom: function () {
  121. },
  122. /**
  123. * 用户点击右上角分享
  124. */
  125. onShareAppMessage: function () {
  126. return {
  127. title: this.data.ui.nick + ',邀请你PK税后工资',
  128. path: 'page/home/result/result?url=' + this.data.ui.avatar + '&nick=' + this.data.ui.nick + '&A=' + this.data.ui.A + '&B=' + this.data.ui.B + '&C=' + this.data.ui.C + '&income=' + this.data.ui.income + '&city=' + this.data.ui.city + '&isRelay=1'
  129. }
  130. }
  131. })