// pages/personalCenter/personalCenter.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { myTicketArrows: false, historyTicketArrows: false, getUser:false, getUserArr: [],//用户信息 userChuan:[], userPhone:"",//用户手机号 mydeg: -90, historydeg: -90, pageNum:1, pageCount:5, historyArr: [],//优惠券使用记录列表 getHistory: [],//每次接口拉取的数据 getHistoryArr: [],//全部使用数据 myTicketArr: [],//我的优惠券列表 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { if (app.globalData.openId) { this.myTicket(); this.historyTicket(); } else { app.globalData.openidSuccessFuc = this.myTicket; app.globalData.openidSuccessFuc = this.historyTicket; } var userInfo = wx.getStorageSync('userInfo'); var phone = wx.getStorageSync('user_phone'); console.log(userInfo) if (userInfo) { var userArr = []; userArr.push(userInfo.avatarUrl); userArr.push(userInfo.nickName); phone = app.globalData.userInfo.user_phone console.log(phone) this.setData({ getUserArr: userArr, getUser: true, userPhone: phone }) } console.log(this.data.getUserArr) }, myTicket:function(){//获取我的优惠券列表 app.wxRequest(app.globalData.httpUrl + 'couponbuy/validtype', {}, e => { console.log(e) if (e.code == 200) { this.setData({ myTicketArr: e.data }) } }, this) }, historyTicket: function () {//获取优惠券使用列表 this.data.getHistory = []; app.wxRequest(app.globalData.httpUrl + 'couponbuy/historyuse', {cur_page: this.data.pageNum, show_num: this.data.pageCount}, e => { console.log(e) if (e.code == 200) { for(var i=0;i { console.log(res, "转发成功") }, } }, lookMyTicket:function(){ this.setData({ myTicketArrows: !this.data.myTicketArrows, }) if (this.data.myTicketArrows){ this.setData({ mydeg: 0, }) }else{ this.setData({ mydeg: -90, }) } }, lookHistory:function(){ this.setData({ historyTicketArrows: !this.data.historyTicketArrows, }) if (this.data.historyTicketArrows) { this.setData({ historydeg: 0, }) } else { this.setData({ historydeg: -90, }) } }, lookTicket: function (e) {//查看优惠券 console.log(e) var id = e.currentTarget.dataset.id; wx.navigateTo({ url: '../TicketDetails/TicketDetails?id=' + id, }) }, giveTicket:function(e){//赠送优惠券 var id = e.target.dataset.id; wx.navigateTo({ url: '../givePage/givePage?id=' + id, }) }, getUser:function(e){//点击登陆获取用户信息 console.log(e) wx.setStorageSync('userInfo', e.detail.userInfo); var phone = wx.getStorageSync('user_phone'); var userArr = []; userArr.push(e.detail.userInfo.avatarUrl); userArr.push(e.detail.userInfo.nickName); // phone = app.globalData.user_phone console.log(phone) this.data.userChuan = e.detail.userInfo; this.setData({ getUserArr: userArr, getUser: true, userPhone: phone }) this.submitUser(); console.log(this.data.getUserArr) }, submitUser:function(){//提交用户信息 var params={ "province": this.data.userChuan.province, "language": this.data.userChuan.language, "city": this.data.userChuan.city, "gender": this.data.userChuan.gender, "nickname": this.data.userChuan.nickName, "headimgurl": this.data.userChuan.avatarUrl, } app.wxRequest(app.globalData.httpUrl + 'submit', params, e => { console.log(e) if (e.code == 200) { } }, this,"POST") } })