您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

177 行
4.3KB

  1. // pages/personalCenter/personalCenter.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. myTicketArrows: false,
  9. historyTicketArrows: false,
  10. getUser:false,
  11. getUserArr: [],//用户信息
  12. userPhone:"",//用户手机号
  13. mydeg: -90,
  14. historydeg: -90,
  15. historyArr: [],//优惠券使用记录列表
  16. myTicketArr: [
  17. // { "coupon_img_small": "../images/smallTicket.jpg", "coupon_sell_id": 1, "coupon_name": "哈哈哈", "coupon_memo": "嘻嘻嘻","end_date":"2020/3/5"},
  18. // { "coupon_img_small": "../images/smallTicket.jpg", "coupon_sell_id": 1, "coupon_name": "哈哈哈", "coupon_memo": "嘻嘻嘻", "end_date": "2020/3/5" },
  19. // { "coupon_img_small": "../images/smallTicket.jpg", "coupon_sell_id": 1, "coupon_name": "哈哈哈", "coupon_memo": "嘻嘻嘻", "end_date": "2020/3/5" },
  20. // { "coupon_img_small": "../images/smallTicket.jpg", "coupon_sell_id": 1, "coupon_name": "哈哈哈", "coupon_memo": "嘻嘻嘻", "end_date": "2020/3/5" },
  21. // { "coupon_img_small": "../images/smallTicket.jpg", "coupon_sell_id": 1, "coupon_name": "哈哈哈", "coupon_memo": "嘻嘻嘻", "end_date": "2020/3/5" },
  22. ],//我的优惠券列表
  23. },
  24. /**
  25. * 生命周期函数--监听页面加载
  26. */
  27. onLoad: function (options) {
  28. this.myTicket();
  29. this.historyTicket();
  30. },
  31. myTicket:function(){//获取我的优惠券列表
  32. app.wxRequest(app.globalData.httpUrl + 'couponbuy/validtype', {}, e => {
  33. console.log(e)
  34. if (e.code == 200) {
  35. this.setData({
  36. myTicketArr: e.data
  37. })
  38. }
  39. }, this)
  40. },
  41. historyTicket: function () {//获取优惠券使用列表
  42. app.wxRequest(app.globalData.httpUrl + 'couponbuy/history', {}, e => {
  43. console.log(e)
  44. if (e.code == 200) {
  45. this.setData({
  46. historyArr: e.data
  47. })
  48. }
  49. }, this)
  50. },
  51. lower:function(){//检测上拉是否到底
  52. console.log("到底了")
  53. },
  54. /**
  55. * 生命周期函数--监听页面初次渲染完成
  56. */
  57. onReady: function () {
  58. },
  59. /**
  60. * 生命周期函数--监听页面显示
  61. */
  62. onShow: function () {
  63. },
  64. /**
  65. * 生命周期函数--监听页面隐藏
  66. */
  67. onHide: function () {
  68. },
  69. /**
  70. * 生命周期函数--监听页面卸载
  71. */
  72. onUnload: function () {
  73. },
  74. /**
  75. * 页面相关事件处理函数--监听用户下拉动作
  76. */
  77. onPullDownRefresh: function () {
  78. },
  79. /**
  80. * 页面上拉触底事件的处理函数
  81. */
  82. onReachBottom: function () {
  83. },
  84. /**
  85. * 用户点击右上角分享
  86. */
  87. onShareAppMessage: function () {
  88. },
  89. lookMyTicket:function(){
  90. this.setData({
  91. myTicketArrows: !this.data.myTicketArrows,
  92. })
  93. if (this.data.myTicketArrows){
  94. this.setData({
  95. mydeg: 0,
  96. })
  97. }else{
  98. this.setData({
  99. mydeg: -90,
  100. })
  101. }
  102. },
  103. lookHistory:function(){
  104. this.setData({
  105. historyTicketArrows: !this.data.historyTicketArrows,
  106. })
  107. if (this.data.historyTicketArrows) {
  108. this.setData({
  109. historydeg: 0,
  110. })
  111. } else {
  112. this.setData({
  113. historydeg: -90,
  114. })
  115. }
  116. },
  117. lookTicket: function (e) {//查看优惠券
  118. console.log(e)
  119. var id = e.currentTarget.dataset.id;
  120. wx.navigateTo({
  121. url: '../TicketDetails/TicketDetails?id=' + id,
  122. })
  123. },
  124. giveTicket:function(e){//赠送优惠券
  125. var id = e.target.dataset.id;
  126. wx.navigateTo({
  127. url: '../givePage/givePage?id=' + id,
  128. })
  129. },
  130. getUser:function(e){//点击登陆获取用户信息
  131. console.log(e)
  132. console.log(app.globalData.userInfo)
  133. this.setData({
  134. getUserArr: e.detail.userInfo
  135. })
  136. if (this.data.getUserArr){
  137. this.setData({
  138. getUser: true,
  139. userPhone: app.globalData.userInfo
  140. })
  141. this.submitUser();
  142. }
  143. console.log(this.data.getUserArr)
  144. },
  145. submitUser:function(){//提交用户信息
  146. var params={
  147. "province": this.data.getUserArr.province,
  148. "language": this.data.getUserArr.language,
  149. "city": this.data.getUserArr.city,
  150. "gender": this.data.getUserArr.gender,
  151. "nickname": this.data.getUserArr.nickName,
  152. "headimgurl": this.data.getUserArr.avatarUrl,
  153. }
  154. app.wxRequest(app.globalData.httpUrl + 'submit', params, e => {
  155. console.log(e)
  156. if (e.code == 200) {
  157. }
  158. }, this,"POST")
  159. }
  160. })