選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

174 行
4.2KB

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