| wx.setStorageSync('openid', e.data.data.openid) | wx.setStorageSync('openid', e.data.data.openid) | ||||
| wx.setStorageSync('session_key', e.data.data.session_key) | wx.setStorageSync('session_key', e.data.data.session_key) | ||||
| wx.setStorageSync('token', e.data.data.token) | wx.setStorageSync('token', e.data.data.token) | ||||
| // if (this.globalData.openidSuccessFuc) { | |||||
| // this.globalData.openidSuccessFuc(); | |||||
| // } | |||||
| if (this.globalData.openidSuccessFuc) { | |||||
| this.globalData.openidSuccessFuc(); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| }) | }) |
| */ | */ | ||||
| onLoad: function (options) { | onLoad: function (options) { | ||||
| console.log(options.id) | console.log(options.id) | ||||
| this.getTicketUser(options.id, 1) | |||||
| this.getCodeFn(options.id) | |||||
| if (app.globalData.openid) { | |||||
| this.getTicketUser(options.id, 1) | |||||
| this.getCodeFn(options.id) | |||||
| } else { | |||||
| this.globalData.openidSuccessFuc = this.getTicketUser; | |||||
| this.globalData.openidSuccessFuc = this.getCodeFn; | |||||
| } | |||||
| }, | }, | ||||
| getTicketUser: function (id,from) {//获取优惠券信息 | getTicketUser: function (id,from) {//获取优惠券信息 | ||||
| app.wxRequest(app.globalData.httpUrl + 'couponsell/detail', { coupon_sell_id: id, from: from}, e => { | app.wxRequest(app.globalData.httpUrl + 'couponsell/detail', { coupon_sell_id: id, from: from}, e => { |
| */ | */ | ||||
| onLoad: function (options) { | onLoad: function (options) { | ||||
| console.log(options) | console.log(options) | ||||
| this.getTicketUser(options.index,1) | |||||
| if (app.globalData.openid) { | |||||
| this.getTicketUser(options.index, 1) | |||||
| } else { | |||||
| this.globalData.openidSuccessFuc = this.getTicketUser; | |||||
| } | |||||
| }, | }, | ||||
| getTicketUser:function(index,from){//获取优惠券信息 | getTicketUser:function(index,from){//获取优惠券信息 |
| */ | */ | ||||
| onLoad: function (options) { | onLoad: function (options) { | ||||
| console.log(options.id) | console.log(options.id) | ||||
| if (app.globalData.openid) { | |||||
| this.getTicketUser(options.id, 2) | |||||
| } else { | |||||
| this.globalData.openidSuccessFuc = this.getTicketUser; | |||||
| } | |||||
| this.data.sellId = options.id; | this.data.sellId = options.id; | ||||
| this.getTicketUser(options.id,2) | |||||
| }, | }, | ||||
| getTicketUser: function (id, from) {//获取优惠券信息 | getTicketUser: function (id, from) {//获取优惠券信息 | ||||
| app.wxRequest(app.globalData.httpUrl + 'couponsell/detail', { coupon_sell_id: id, from: from }, e => { | app.wxRequest(app.globalData.httpUrl + 'couponsell/detail', { coupon_sell_id: id, from: from }, e => { |
| }, | }, | ||||
| //事件处理函数 | //事件处理函数 | ||||
| onLoad: function () { | onLoad: function () { | ||||
| this.getDataList(); | |||||
| if (app.globalData.openid){ | |||||
| this.getDataList(); | |||||
| }else{ | |||||
| this.globalData.openidSuccessFuc = this.getDataList; | |||||
| } | |||||
| }, | }, | ||||
| getDataList:function(){ | getDataList:function(){ | ||||
| app.wxRequest(app.globalData.httpUrl + 'couponsell/list', {}, e => { | app.wxRequest(app.globalData.httpUrl + 'couponsell/list', {}, e => { |
| * 生命周期函数--监听页面加载 | * 生命周期函数--监听页面加载 | ||||
| */ | */ | ||||
| onLoad: function (options) { | onLoad: function (options) { | ||||
| this.myTicket(); | |||||
| this.historyTicket(); | |||||
| if (app.globalData.openid) { | |||||
| this.myTicket(); | |||||
| this.historyTicket(); | |||||
| } else { | |||||
| this.globalData.openidSuccessFuc = this.myTicket; | |||||
| this.globalData.openidSuccessFuc = this.historyTicket; | |||||
| } | |||||
| }, | }, | ||||
| myTicket:function(){//获取我的优惠券列表 | myTicket:function(){//获取我的优惠券列表 | ||||
| app.wxRequest(app.globalData.httpUrl + 'couponbuy/validtype', {}, e => { | app.wxRequest(app.globalData.httpUrl + 'couponbuy/validtype', {}, e => { |
| this.setData({ | this.setData({ | ||||
| ticketNum: options.number | ticketNum: options.number | ||||
| }) | }) | ||||
| this.getTicketUser(options.shareId, options.number); | |||||
| // wx.showModal({ | |||||
| // title: "options.shareId=" + options.shareId + "&options.number=" + options.number, | |||||
| // content: '', | |||||
| // }) | |||||
| if (app.globalData.openid) { | |||||
| this.getTicketUser(options.shareId, options.number); | |||||
| } else { | |||||
| this.globalData.openidSuccessFuc = this.getTicketUser; | |||||
| } | |||||
| }, | }, | ||||
| getTicketUser: function (id,number) {//获取赠送优惠券信息 | getTicketUser: function (id,number) {//获取赠送优惠券信息 | ||||
| yesGet: true | yesGet: true | ||||
| }) | }) | ||||
| } else if (e.code == 202){ | } else if (e.code == 202){ | ||||
| wx.showModal({ | |||||
| title: this.data.ticketUser.nickname + this.data.ticketUser.user_phone, | |||||
| content: '', | |||||
| }) | |||||
| this.setData({ | this.setData({ | ||||
| yesGet: false, | yesGet: false, | ||||
| titleWord:"此券已被领取" | titleWord:"此券已被领取" |
| }, | }, | ||||
| yesCodeFn:function(){//验证码接口 | |||||
| app.wxRequest(app.globalData.httpUrl + 'smscode', { user_phone: this.data.phone }, e => { | |||||
| console.log(e) | |||||
| if (e.code == 200) { | |||||
| wx.showToast({ | |||||
| title: e.message, | |||||
| icon: 'success', | |||||
| duration: 500 | |||||
| }) | |||||
| } | |||||
| }, this) | |||||
| }, | |||||
| sendTouch:function(){//发送验证码 | sendTouch:function(){//发送验证码 | ||||
| if (!(/^1[3456789]\d{9}$/.test(this.data.phone))) { | if (!(/^1[3456789]\d{9}$/.test(this.data.phone))) { | ||||
| wx.showToast({ | wx.showToast({ | ||||
| if (this.data.yesSend) { | if (this.data.yesSend) { | ||||
| time = setInterval(this.setIntervalFn,1000) | time = setInterval(this.setIntervalFn,1000) | ||||
| } | } | ||||
| app.wxRequest(app.globalData.httpUrl + 'smscode', { user_phone:this.data.phone}, e => { | |||||
| console.log(e) | |||||
| if(e.code==200){ | |||||
| wx.showToast({ | |||||
| title: e.message, | |||||
| icon: 'success', | |||||
| duration: 500 | |||||
| }) | |||||
| } | |||||
| }, this) | |||||
| if (app.globalData.openid) { | |||||
| this.yesCodeFn(); | |||||
| } else { | |||||
| this.globalData.openidSuccessFuc = this.yesCodeFn; | |||||
| } | |||||
| }, | }, | ||||
| setIntervalFn:function(){//定时器 | setIntervalFn:function(){//定时器 | ||||
| if (this.data.num > 0) { | if (this.data.num > 0) { | ||||
| }) | }) | ||||
| console.log(this.data.minter) | console.log(this.data.minter) | ||||
| }, | }, | ||||
| registerFn:function(){//注册 | |||||
| registerBtn:function(){//点击按钮注册 | |||||
| if (app.globalData.openid) { | |||||
| this.registerFn(); | |||||
| } else { | |||||
| this.globalData.openidSuccessFuc = this.registerFn; | |||||
| } | |||||
| }, | |||||
| registerFn:function(){//注册接口 | |||||
| app.wxRequest(app.globalData.httpUrl + 'register', { user_phone: this.data.phone, code_num: this.data.phoneCode }, e => { | app.wxRequest(app.globalData.httpUrl + 'register', { user_phone: this.data.phone, code_num: this.data.phoneCode }, e => { | ||||
| console.log(e) | console.log(e) | ||||
| if (e.code == 200) { | if (e.code == 200) { |
| <view class="sendBtn" wx:if="{{yesSend}}">{{minter}}</view> | <view class="sendBtn" wx:if="{{yesSend}}">{{minter}}</view> | ||||
| <input class="codeInt" type="number" bindinput="getCode" placeholder="验证码" placeholder-class="placeholderClass"></input> | <input class="codeInt" type="number" bindinput="getCode" placeholder="验证码" placeholder-class="placeholderClass"></input> | ||||
| </view> | </view> | ||||
| <image bindtap="registerFn" class="registerBtn" src="../images/registerBtn.png"></image> | |||||
| <image bindtap="registerBtn" class="registerBtn" src="../images/registerBtn.png"></image> | |||||
| </view> | </view> | ||||
| </view> | </view> |
| * 生命周期函数--监听页面加载 | * 生命周期函数--监听页面加载 | ||||
| */ | */ | ||||
| onLoad: function (options) { | onLoad: function (options) { | ||||
| this.getShopList(); | |||||
| this.searchShop(true); | |||||
| console.log(options) | |||||
| if (app.globalData.openid) { | |||||
| this.getShopList(); | |||||
| this.searchShop(true); | |||||
| } else { | |||||
| this.globalData.openidSuccessFuc = this.getShopList; | |||||
| this.globalData.openidSuccessFuc = this.searchShop; | |||||
| } | |||||
| }, | }, | ||||
| getShopList:function(){//获取所有门店省市 | getShopList:function(){//获取所有门店省市 |