Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

personalCenter.js 5.9KB

před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
před 5 roky
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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. headerImg:"../images/headerImg.png",//默认头像
  23. userName:"",//昵称
  24. },
  25. /**
  26. * 生命周期函数--监听页面加载
  27. */
  28. onLoad: function (options) {
  29. },
  30. getToRsgisterFn:function(){//未注册点击跳到注册页
  31. wx.navigateTo({
  32. url: '/pages/register/register',
  33. })
  34. },
  35. myTicket:function(){//获取我的优惠券列表
  36. app.wxRequest(app.globalData.httpUrl + 'couponbuy/validtype', {}, e => {
  37. console.log(e)
  38. if (e.code == 200) {
  39. this.setData({
  40. myTicketArr: e.data
  41. })
  42. }
  43. }, this)
  44. },
  45. historyTicket: function () {//获取优惠券使用列表
  46. this.data.getHistory = [];
  47. app.wxRequest(app.globalData.httpUrl + 'couponbuy/historyuse', {cur_page: this.data.pageNum, show_num: this.data.pageCount}, e => {
  48. console.log(e)
  49. if (e.code == 200) {
  50. for(var i=0;i<e.data.length;i++){
  51. this.data.getHistoryArr.push(e.data[i]);
  52. }
  53. this.data.getHistory = e.data
  54. this.setData({
  55. historyArr: this.data.getHistoryArr,
  56. })
  57. }
  58. }, this)
  59. },
  60. lower:function(){//检测上拉是否到底
  61. console.log("到底了")
  62. if (this.data.getHistory.length!=0){
  63. this.data.pageNum++;
  64. this.historyTicket()
  65. }else{
  66. wx.showToast({
  67. title: '没有更多数据了',
  68. icon: "none",
  69. duration: 1000
  70. })
  71. }
  72. },
  73. /**
  74. * 生命周期函数--监听页面初次渲染完成
  75. */
  76. onReady: function () {
  77. },
  78. /**
  79. * 生命周期函数--监听页面显示
  80. */
  81. onShow: function () {
  82. if (!this.data.getUser) {
  83. var state = wx.getStorageSync('state');
  84. if (state == 1) {//已注册
  85. var userInfo = wx.getStorageSync('userInfo');
  86. var state = wx.getStorageSync('state');
  87. if (app.globalData.openId) {
  88. this.myTicket();
  89. this.historyTicket();
  90. } else {
  91. app.globalData.openidSuccessFuc = this.myTicket;
  92. app.globalData.openidSuccessFuc = this.historyTicket;
  93. }
  94. console.log(app.globalData.userInfo)
  95. var userInfo = wx.getStorageSync('userInfo');
  96. var phone = wx.getStorageSync('user_phone');
  97. this.setData({
  98. headerImg: userInfo.avatarUrl,
  99. userName: userInfo.nickName,
  100. userPhone: phone,
  101. getUser: true
  102. })
  103. } else if (state == 0) {//未注册
  104. this.setData({
  105. getUser: false
  106. })
  107. } else if (state == -1) {
  108. app.globalData.userInfoBackFn = res => {//等待结果
  109. console.log(res)
  110. if (res) {
  111. if (app.globalData.openId) {
  112. this.myTicket();
  113. this.historyTicket();
  114. } else {
  115. app.globalData.openidSuccessFuc = this.myTicket;
  116. app.globalData.openidSuccessFuc = this.historyTicket;
  117. }
  118. var userInfo = wx.getStorageSync('userInfo');
  119. var phone = wx.getStorageSync('user_phone');
  120. this.setData({
  121. headerImg: userInfo.avatarUrl,
  122. userName: userInfo.nickName,
  123. userPhone: phone,
  124. getUser: true
  125. })
  126. } else {
  127. this.setData({
  128. getUser: false
  129. })
  130. }
  131. }
  132. }
  133. }
  134. },
  135. /**
  136. * 生命周期函数--监听页面隐藏
  137. */
  138. onHide: function () {
  139. },
  140. /**
  141. * 生命周期函数--监听页面卸载
  142. */
  143. onUnload: function () {
  144. },
  145. /**
  146. * 页面相关事件处理函数--监听用户下拉动作
  147. */
  148. onPullDownRefresh: function () {
  149. },
  150. /**
  151. * 页面上拉触底事件的处理函数
  152. */
  153. onReachBottom: function () {
  154. },
  155. /**
  156. * 用户点击右上角分享
  157. */
  158. onShareAppMessage: function () {
  159. return {
  160. title: "老门框爆肚会员",
  161. path: "/pages/register/register",
  162. success: res => {
  163. console.log(res, "转发成功")
  164. },
  165. }
  166. },
  167. lookMyTicket:function(){
  168. this.setData({
  169. myTicketArrows: !this.data.myTicketArrows,
  170. })
  171. if (this.data.myTicketArrows){
  172. this.setData({
  173. mydeg: 0,
  174. })
  175. }else{
  176. this.setData({
  177. mydeg: -90,
  178. })
  179. }
  180. },
  181. lookHistory:function(){
  182. this.setData({
  183. historyTicketArrows: !this.data.historyTicketArrows,
  184. })
  185. if (this.data.historyTicketArrows) {
  186. this.setData({
  187. historydeg: 0,
  188. })
  189. } else {
  190. this.setData({
  191. historydeg: -90,
  192. })
  193. }
  194. },
  195. lookTicket: function (e) {//查看优惠券
  196. console.log(e)
  197. var id = e.currentTarget.dataset.id;
  198. wx.navigateTo({
  199. url: '../TicketDetails/TicketDetails?id=' + id,
  200. })
  201. },
  202. giveTicket:function(e){//赠送优惠券
  203. var id = e.target.dataset.id;
  204. wx.navigateTo({
  205. url: '../givePage/givePage?id=' + id,
  206. })
  207. },
  208. // getUser:function(e){//点击登陆获取用户信息
  209. // console.log(e)
  210. // wx.setStorageSync('userInfo', e.detail.userInfo);
  211. // var phone = wx.getStorageSync('user_phone');
  212. // var userArr = [];
  213. // userArr.push(e.detail.userInfo.avatarUrl);
  214. // userArr.push(e.detail.userInfo.nickName);
  215. // // phone = app.globalData.user_phone
  216. // console.log(phone)
  217. // this.data.userChuan = e.detail.userInfo;
  218. // this.setData({
  219. // headerImg: userArr,
  220. // getUser: true,
  221. // userPhone: phone
  222. // })
  223. // this.submitUser();
  224. // console.log(this.data.getUserArr)
  225. // },
  226. })