personal.js 3.3 KB

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