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.

personalCenter.js 4.5KB

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