You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
2.9KB

  1. // pages/personal/personal.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. userInfo: null,
  9. canIUse: wx.canIUse('button.open-type.getUserInfo'),
  10. hasUserInfo: false,
  11. userNo: '', //员工编号
  12. record:{
  13. check_cash:0,
  14. check_dish:0,
  15. sum_check_point:0,
  16. sum_add_point:0
  17. }
  18. },
  19. /**
  20. * 生命周期函数--监听页面加载
  21. */
  22. onLoad: function (options) {
  23. wx.hideShareMenu();
  24. if (app.globalData.userInfo) {
  25. this.setData({
  26. userInfo: app.globalData.userInfo,
  27. hasUserInfo: true
  28. })
  29. } else if (this.data.canIUse) {
  30. // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
  31. // 所以此处加入 callback 以防止这种情况
  32. app.userInfoReadyCallback = res => {
  33. this.setData({
  34. userInfo: res.userInfo,
  35. hasUserInfo: true
  36. })
  37. }
  38. } else {
  39. // 在没有 open-type=getUserInfo 版本的兼容处理
  40. wx.getUserInfo({
  41. success: res => {
  42. app.globalData.userInfo = res.userInfo
  43. this.setData({
  44. userInfo: res.userInfo,
  45. hasUserInfo: true
  46. })
  47. }
  48. })
  49. }
  50. this.setData({
  51. userNo: app.globalData.storeData.account_id
  52. })
  53. },
  54. /**
  55. * 获取头像昵称
  56. */
  57. getUserInfo: function (e) {
  58. app.globalData.userInfo = e.detail.userInfo
  59. if (e.detail.userInfo) {
  60. wx.setStorageSync('laomenkuangUserInfo', e.detail.userInfo);//老门框用户信息-头像昵称
  61. this.setData({
  62. userInfo: e.detail.userInfo,
  63. hasUserInfo: true
  64. })
  65. var userInfo = app.setUserInfo(e.detail.userInfo)
  66. app.requestPost('submit', userInfo, res => {
  67. console.log(res)
  68. })
  69. }
  70. },
  71. /**
  72. * 显示记录
  73. */
  74. showVecords: function(e){
  75. var code = e.currentTarget.dataset.index;
  76. wx.navigateTo({
  77. url: '../record/record?code=' + code
  78. })
  79. },
  80. /**
  81. * 获取记录数据
  82. */
  83. getRecordNums(){
  84. app.requestGet('admin/self/typenum',{},res=>{
  85. if(res.code==200){
  86. var {check_cash,check_dish,sum_check_point,sum_add_point}=res.data;
  87. this.setData({
  88. record:{check_cash,check_dish,sum_check_point,sum_add_point}
  89. })
  90. }
  91. })
  92. },
  93. /**
  94. * 生命周期函数--监听页面初次渲染完成
  95. */
  96. onReady: function () {
  97. },
  98. /**
  99. * 生命周期函数--监听页面显示
  100. */
  101. onShow: function () {
  102. this.getRecordNums()
  103. },
  104. /**
  105. * 生命周期函数--监听页面隐藏
  106. */
  107. onHide: function () {
  108. },
  109. /**
  110. * 生命周期函数--监听页面卸载
  111. */
  112. onUnload: function () {
  113. },
  114. /**
  115. * 页面相关事件处理函数--监听用户下拉动作
  116. */
  117. onPullDownRefresh: function () {
  118. },
  119. /**
  120. * 页面上拉触底事件的处理函数
  121. */
  122. onReachBottom: function () {
  123. },
  124. /**
  125. * 用户点击右上角分享
  126. */
  127. onShareAppMessage: function () {
  128. }
  129. })