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.

пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. userChuan:[],
  13. userPhone:"",//用户手机号
  14. mydeg: -90,
  15. historydeg: -90,
  16. pageNum:1,
  17. pageCount:5,
  18. historyArr: [],//优惠券使用记录列表
  19. getHistory: [],//每次接口拉取的数据
  20. getHistoryArr: [],//全部使用数据
  21. myTicketArr: [],//我的优惠券列表
  22. },
  23. /**
  24. * 生命周期函数--监听页面加载
  25. */
  26. onLoad: function (options) {
  27. if (app.globalData.openId) {
  28. this.myTicket();
  29. this.historyTicket();
  30. } else {
  31. app.globalData.openidSuccessFuc = this.myTicket;
  32. app.globalData.openidSuccessFuc = this.historyTicket;
  33. }
  34. console.log(app.globalData.userInfo)
  35. if (app.globalData.userInfo.item_state == 2) {
  36. var userArr = [];
  37. var phone="";
  38. userArr.push(app.globalData.userInfo.headimgurl);
  39. userArr.push(app.globalData.userInfo.nickname);
  40. phone = app.globalData.userInfo.user_phone
  41. console.log(phone)
  42. this.setData({
  43. getUserArr: userArr,
  44. getUser: true,
  45. userPhone: phone
  46. })
  47. }
  48. console.log(this.data.getUserArr)
  49. },
  50. myTicket:function(){//获取我的优惠券列表
  51. app.wxRequest(app.globalData.httpUrl + 'couponbuy/validtype', {}, e => {
  52. console.log(e)
  53. if (e.code == 200) {
  54. this.setData({
  55. myTicketArr: e.data
  56. })
  57. }
  58. }, this)
  59. },
  60. historyTicket: function () {//获取优惠券使用列表
  61. this.data.getHistory = [];
  62. app.wxRequest(app.globalData.httpUrl + 'couponbuy/historyuse', {cur_page: this.data.pageNum, show_num: this.data.pageCount}, e => {
  63. console.log(e)
  64. if (e.code == 200) {
  65. for(var i=0;i<e.data.length;i++){
  66. this.data.getHistoryArr.push(e.data[i]);
  67. }
  68. this.data.getHistory = e.data
  69. this.setData({
  70. historyArr: this.data.getHistoryArr,
  71. })
  72. }
  73. }, this)
  74. },
  75. lower:function(){//检测上拉是否到底
  76. console.log("到底了")
  77. if (this.data.getHistory.length!=0){
  78. this.data.pageNum++;
  79. this.historyTicket()
  80. }else{
  81. wx.showToast({
  82. title: '没有更多数据了',
  83. icon: "none",
  84. duration: 1000
  85. })
  86. }
  87. },
  88. /**
  89. * 生命周期函数--监听页面初次渲染完成
  90. */
  91. onReady: function () {
  92. },
  93. /**
  94. * 生命周期函数--监听页面显示
  95. */
  96. onShow: function () {
  97. },
  98. /**
  99. * 生命周期函数--监听页面隐藏
  100. */
  101. onHide: function () {
  102. },
  103. /**
  104. * 生命周期函数--监听页面卸载
  105. */
  106. onUnload: function () {
  107. },
  108. /**
  109. * 页面相关事件处理函数--监听用户下拉动作
  110. */
  111. onPullDownRefresh: function () {
  112. },
  113. /**
  114. * 页面上拉触底事件的处理函数
  115. */
  116. onReachBottom: function () {
  117. },
  118. /**
  119. * 用户点击右上角分享
  120. */
  121. onShareAppMessage: function () {
  122. },
  123. lookMyTicket:function(){
  124. this.setData({
  125. myTicketArrows: !this.data.myTicketArrows,
  126. })
  127. if (this.data.myTicketArrows){
  128. this.setData({
  129. mydeg: 0,
  130. })
  131. }else{
  132. this.setData({
  133. mydeg: -90,
  134. })
  135. }
  136. },
  137. lookHistory:function(){
  138. this.setData({
  139. historyTicketArrows: !this.data.historyTicketArrows,
  140. })
  141. if (this.data.historyTicketArrows) {
  142. this.setData({
  143. historydeg: 0,
  144. })
  145. } else {
  146. this.setData({
  147. historydeg: -90,
  148. })
  149. }
  150. },
  151. lookTicket: function (e) {//查看优惠券
  152. console.log(e)
  153. var id = e.currentTarget.dataset.id;
  154. wx.navigateTo({
  155. url: '../TicketDetails/TicketDetails?id=' + id,
  156. })
  157. },
  158. giveTicket:function(e){//赠送优惠券
  159. var id = e.target.dataset.id;
  160. wx.navigateTo({
  161. url: '../givePage/givePage?id=' + id,
  162. })
  163. },
  164. getUser:function(e){//点击登陆获取用户信息
  165. console.log(e)
  166. var userArr = [];
  167. var phone = "";
  168. userArr.push(e.detail.userInfo.avatarUrl);
  169. userArr.push(e.detail.userInfo.nickName);
  170. phone = app.globalData.user_phone
  171. console.log(phone)
  172. this.data.userChuan = e.detail.userInfo;
  173. this.setData({
  174. getUserArr: userArr,
  175. getUser: true,
  176. userPhone: phone
  177. })
  178. this.submitUser();
  179. console.log(this.data.getUserArr)
  180. },
  181. submitUser:function(){//提交用户信息
  182. var params={
  183. "province": this.data.userChuan.province,
  184. "language": this.data.userChuan.language,
  185. "city": this.data.userChuan.city,
  186. "gender": this.data.userChuan.gender,
  187. "nickname": this.data.userChuan.nickName,
  188. "headimgurl": this.data.userChuan.avatarUrl,
  189. }
  190. app.wxRequest(app.globalData.httpUrl + 'submit', params, e => {
  191. console.log(e)
  192. if (e.code == 200) {
  193. }
  194. }, this,"POST")
  195. }
  196. })