personal.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // pages/welfareMall/personal/personal.js
  2. import WelfareMall from '../../../api/welfareMall'
  3. import {getMobileCache, getPhoneNumber as getPhoneNumberSync} from '../../../utils/user'
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. isLogin: false,
  10. mobileTop: 'TONY WU',
  11. countNum: 0,
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: async function (options) {
  17. this.setData({
  18. isLogin: getMobileCache() != '',
  19. mobileTop: getMobileCache(),
  20. })
  21. if(this.data.isLogin){
  22. let nums = await this.getCountNum();
  23. this.setData({
  24. countNum: nums,
  25. })
  26. }
  27. },
  28. getCountNum: async function(){
  29. /**
  30. * 福利社
  31. */
  32. let resBuy = await WelfareMall.getUserBuyCouponNum({
  33. mobile: getMobileCache(),
  34. });
  35. let resAward = await WelfareMall.getUserAwardCouponNum({
  36. mobile: getMobileCache(),
  37. });
  38. let resDraw = await WelfareMall.getUserDrawCouponNum({
  39. mobile: getMobileCache(),
  40. });
  41. let nums = Number(resBuy.data.notUseNum)+Number(resAward.data.notUseNum)+Number(resDraw.data.notUseNum)
  42. return nums;
  43. },
  44. // 授权手机号
  45. getPhoneNumber(e) {
  46. getPhoneNumberSync(e, async () => {
  47. let nums = await this.getCountNum();
  48. this.setData({
  49. isLogin: true,
  50. mobileTop: getMobileCache(),
  51. countNum: nums,
  52. })
  53. })
  54. },
  55. toHistorical(e) {
  56. const url = "../historical/historical?id=" + e.currentTarget.dataset.id
  57. wx.navigateTo({
  58. url
  59. })
  60. },
  61. toFeedback(e) {
  62. const url = "../feedback/feedback?id=" + e.currentTarget.dataset.id
  63. wx.navigateTo({
  64. url: url,
  65. })
  66. },
  67. /**
  68. * 生命周期函数--监听页面初次渲染完成
  69. */
  70. onReady: function () {
  71. },
  72. /**
  73. * 生命周期函数--监听页面显示
  74. */
  75. onShow: function () {
  76. },
  77. /**
  78. * 生命周期函数--监听页面隐藏
  79. */
  80. onHide: function () {
  81. },
  82. /**
  83. * 生命周期函数--监听页面卸载
  84. */
  85. onUnload: function () {
  86. },
  87. /**
  88. * 页面相关事件处理函数--监听用户下拉动作
  89. */
  90. onPullDownRefresh: function () {
  91. },
  92. /**
  93. * 页面上拉触底事件的处理函数
  94. */
  95. onReachBottom: function () {
  96. },
  97. /**
  98. * 用户点击右上角分享
  99. */
  100. onShareAppMessage: function () {
  101. }
  102. })