| // logs.unshift(Date.now()) | // logs.unshift(Date.now()) | ||||
| // wx.setStorageSync('logs', logs) | // wx.setStorageSync('logs', logs) | ||||
| var openid = wx.getStorageSync('openid') || ""; | var openid = wx.getStorageSync('openid') || ""; | ||||
| wx.setStorageSync('state',-1); | |||||
| // 登录 | // 登录 | ||||
| if (!openid){ | if (!openid){ | ||||
| wx.login({ | wx.login({ | ||||
| this.wxRequest(this.globalData.httpUrl + 'getinfo', {},e=>{ | this.wxRequest(this.globalData.httpUrl + 'getinfo', {},e=>{ | ||||
| console.log(e) | console.log(e) | ||||
| if(e.code==201){//未注册跳到注册页面 | if(e.code==201){//未注册跳到注册页面 | ||||
| this.globalData.state = 0 | |||||
| wx.getStorageSync('state', 0); | |||||
| } else if (e.code == 202) {//已注册 | } else if (e.code == 202) {//已注册 | ||||
| this.globalData.state = 1 | |||||
| wx.getStorageSync('state', 1); | |||||
| this.globalData.userInfo = e.data; | this.globalData.userInfo = e.data; | ||||
| } | } | ||||
| if(this.globalData.userInfoBackFn){ | if(this.globalData.userInfoBackFn){ | ||||
| },this) | },this) | ||||
| }, | }, | ||||
| globalData: { | globalData: { | ||||
| state:-1, | |||||
| openidSuccessFuc: null,//方法回调 | openidSuccessFuc: null,//方法回调 | ||||
| userInfoSuccessFuc: null,//方法回调 | userInfoSuccessFuc: null,//方法回调 | ||||
| userInfo: null, | userInfo: null, |
| ticketUser: [],//优惠券信息 | ticketUser: [],//优惠券信息 | ||||
| orderUser:[],//下单信息 | orderUser:[],//下单信息 | ||||
| sign_num:"",//确认支付参数 | sign_num:"",//确认支付参数 | ||||
| id:"" | |||||
| id:"", | |||||
| yesClick:false,//防止购买按钮多次点击 | |||||
| }, | }, | ||||
| /** | /** | ||||
| } | } | ||||
| }, | }, | ||||
| buySuccess:function(){//购买下单 | buySuccess:function(){//购买下单 | ||||
| if (this.data.yesClick){ | |||||
| return; | |||||
| } | |||||
| app.wxRequest(app.globalData.httpUrl + 'order/set', { coupon_sell_id: this.data.ticketUser.coupon_sell_id, buy_num: this.data.buyNumber}, e => { | app.wxRequest(app.globalData.httpUrl + 'order/set', { coupon_sell_id: this.data.ticketUser.coupon_sell_id, buy_num: this.data.buyNumber}, e => { | ||||
| this.data.yesClick = true; | |||||
| console.log(e) | console.log(e) | ||||
| if (e.code == 200) { | if (e.code == 200) { | ||||
| this.setData({ | this.setData({ | ||||
| } else if (e.code == -3003){ | } else if (e.code == -3003){ | ||||
| wx.showToast({ | wx.showToast({ | ||||
| title: e.message, | title: e.message, | ||||
| icon:"none", | |||||
| duration:500 | duration:500 | ||||
| }) | }) | ||||
| } | } | ||||
| app.wxRequest(app.globalData.httpUrl + 'order/paid', { sign_num: this.data.sign_num}, e => { | app.wxRequest(app.globalData.httpUrl + 'order/paid', { sign_num: this.data.sign_num}, e => { | ||||
| console.log(e) | console.log(e) | ||||
| if (e.code == 200) { | if (e.code == 200) { | ||||
| this.data.yesClick = false; | |||||
| wx.reLaunch({ | wx.reLaunch({ | ||||
| url: '/pages/personalCenter/personalCenter' | url: '/pages/personalCenter/personalCenter' | ||||
| }) | }) |
| }) | }) | ||||
| } else{ | } else{ | ||||
| wx.showToast({ | wx.showToast({ | ||||
| title: "您赠送数量太大", | |||||
| duration:1000 | |||||
| title: "您赠送数量不能大于您已有数量", | |||||
| icon: "none", | |||||
| duration:2000 | |||||
| }) | }) | ||||
| setTimeout(() => { | setTimeout(() => { | ||||
| this.setData({ | this.setData({ |
| <view class="line" style="margin-top:40rpx"></view> | <view class="line" style="margin-top:40rpx"></view> | ||||
| <view class="myTicketTop" bindtap="lookHistory"> | <view class="myTicketTop" bindtap="lookHistory"> | ||||
| <image class="historyIcon" src="../images/historyIcon.png"></image> | <image class="historyIcon" src="../images/historyIcon.png"></image> | ||||
| <view class="myTicket" style="margin-left:-310rpx;">优惠券使用记录</view> | |||||
| <view class="myTicket" style="margin-right: 310rpx;">优惠券使用记录</view> | |||||
| <image class="ticketArrows" src="../images/ticketArrows.png" style="transform:rotate({{historydeg}}deg)"></image> | <image class="ticketArrows" src="../images/ticketArrows.png" style="transform:rotate({{historydeg}}deg)"></image> | ||||
| </view> | </view> | ||||
| height: 19rpx; | height: 19rpx; | ||||
| } | } | ||||
| .myTicket{ | .myTicket{ | ||||
| margin-left: -350rpx; | |||||
| margin-right: 350rpx; | |||||
| font-size:30rpx; | font-size:30rpx; | ||||
| font-family:SourceHanSansCN; | font-family:SourceHanSansCN; | ||||
| font-weight:bold; | font-weight:bold; |
| }) | }) | ||||
| if (app.globalData.state == 1) {//已注册 | |||||
| var state = wx.getStorageSync('state'); | |||||
| if (state == 1) {//已注册 | |||||
| if (app.globalData.openId) { | if (app.globalData.openId) { | ||||
| this.getTicketUser(); | this.getTicketUser(); | ||||
| } else { | } else { | ||||
| this.setData({ | this.setData({ | ||||
| showAll:true | showAll:true | ||||
| }) | }) | ||||
| } else if (app.globalData.state == 0) {//未注册 | |||||
| } else if (state == 0) {//未注册 | |||||
| wx.switchTab({ | wx.switchTab({ | ||||
| url: '/pages/register/register' | url: '/pages/register/register' | ||||
| }) | }) | ||||
| } else if (app.globalData.state == -1) { | |||||
| } else if (state == -1) { | |||||
| app.globalData.userInfoBackFn = res => {//等待结果 | app.globalData.userInfoBackFn = res => {//等待结果 | ||||
| if (res) { | if (res) { | ||||
| if (app.globalData.openId) { | if (app.globalData.openId) { |
| * 生命周期函数--监听页面加载 | * 生命周期函数--监听页面加载 | ||||
| */ | */ | ||||
| onLoad: function (options) { | onLoad: function (options) { | ||||
| if (app.globalData.state==1){//已注册 | |||||
| var state = wx.getStorageSync('state'); | |||||
| if (state==1){//已注册 | |||||
| wx.switchTab({ | wx.switchTab({ | ||||
| url: '/pages/index/index' | url: '/pages/index/index' | ||||
| }) | }) | ||||
| } else if (app.globalData.state == 0){//未注册 | |||||
| } else if (state == 0){//未注册 | |||||
| this.setData({ | this.setData({ | ||||
| showAll:true | showAll:true | ||||
| }) | }) | ||||
| } else if (app.globalData.state == -1){ | |||||
| } else if (state == -1){ | |||||
| app.globalData.userInfoBackFn = res=>{//等待结果 | app.globalData.userInfoBackFn = res=>{//等待结果 | ||||
| console.log(res) | console.log(res) | ||||
| if (res){ | if (res){ |
| app.globalData.openidSuccessFuc = this.getShopList; | app.globalData.openidSuccessFuc = this.getShopList; | ||||
| // app.globalData.openidSuccessFuc = this.searchShop; | // app.globalData.openidSuccessFuc = this.searchShop; | ||||
| } | } | ||||
| var hig = wx.getSystemInfoSync().windowHeight; | |||||
| this.setData({ | |||||
| scrollHig: hig-70 | |||||
| }) | |||||
| }, | }, | ||||
| getShopList:function(){//获取所有门店省市 | getShopList:function(){//获取所有门店省市 | ||||
| * 页面上拉触底事件的处理函数 | * 页面上拉触底事件的处理函数 | ||||
| */ | */ | ||||
| onReachBottom: function () { | onReachBottom: function () { | ||||
| }, | |||||
| lower:function(){ | |||||
| console.log("到底了") | console.log("到底了") | ||||
| if (this.data.getDataArr!=""){ | |||||
| if (this.data.getDataArr != "") { | |||||
| this.data.pageNum++; | this.data.pageNum++; | ||||
| this.searchShop(); | this.searchShop(); | ||||
| }else{ | |||||
| } else { | |||||
| wx.showToast({ | wx.showToast({ | ||||
| title: '没有更多数据了', | title: '没有更多数据了', | ||||
| icon:"none", | |||||
| duration:1000 | |||||
| icon: "none", | |||||
| duration: 1000 | |||||
| }) | }) | ||||
| } | } | ||||
| }, | }, | ||||
| /** | /** | ||||
| * 用户点击右上角分享 | * 用户点击右上角分享 | ||||
| */ | */ |
| <view class="searchBtn" bindtap="searchFn">搜索</view> | <view class="searchBtn" bindtap="searchFn">搜索</view> | ||||
| </view> | </view> | ||||
| <view class="content"> | |||||
| <!-- <scroll-view scroll-y="true" style="height:{{scrollHig}}px" bindtouchend=""> --> | |||||
| <!-- <view class="content"> --> | |||||
| <scroll-view scroll-y="true" style="height:{{scrollHig}}px" bindscrolltolower="lower"> | |||||
| <view> | <view> | ||||
| <view class="getData" wx:for="{{showDataArr}}"> | <view class="getData" wx:for="{{showDataArr}}"> | ||||
| <view class="imgView"> | <view class="imgView"> | ||||
| <view class="line"></view> | <view class="line"></view> | ||||
| </view> | </view> | ||||
| </view> | </view> | ||||
| <!-- </scroll-view> --> | |||||
| </view> | |||||
| </scroll-view> | |||||
| <!-- </view> --> | |||||
| </view> | </view> | ||||
| .searchAll{ | .searchAll{ | ||||
| width: 686rpx; | width: 686rpx; | ||||
| padding-bottom: 50rpx; | padding-bottom: 50rpx; | ||||
| position: fixed; | |||||
| top: 0; | |||||
| background: #ffffff; | |||||
| z-index: 9; | |||||
| display: flex; | display: flex; | ||||
| justify-content: space-between; | justify-content: space-between; | ||||
| align-items: center; | align-items: center; |