@@ -67,7 +67,6 @@ App({ | |||
globalData: { | |||
openidSuccessFuc: null,//方法回调 | |||
userInfoSuccessFuc: null,//方法回调 | |||
userInfo: null, | |||
present_id:"",//判断用户是通过领取优惠券进来的还是直接进的 | |||
number:"",//赠送优惠券的数量 | |||
openId:"", |
@@ -1,7 +1,7 @@ | |||
{ | |||
"pages":[ | |||
"pages/register/register", | |||
"pages/index/index", | |||
"pages/register/register", | |||
"pages/shop/shop", | |||
"pages/personalCenter/personalCenter", | |||
"pages/buyTicket/buyTicket", |
@@ -110,6 +110,28 @@ Page({ | |||
} | |||
}, | |||
buySuccess:function(){//购买下单 | |||
var state = wx.getStorageSync('state'); | |||
if (state == 1) {//已注册 | |||
} else if (state == 0) {//未注册 | |||
wx.navigateTo({ | |||
url: '/pages/register/register', | |||
}) | |||
return; | |||
} else if (state == -1) { | |||
app.globalData.userInfoBackFn = res => {//等待结果 | |||
console.log(res) | |||
if (res) { | |||
} else { | |||
wx.navigateTo({ | |||
url: '/pages/register/register', | |||
}) | |||
return; | |||
} | |||
} | |||
} | |||
if (!this.data.buyNumber) { | |||
wx.showToast({ | |||
title: '请先输入购买优惠券的数量', | |||
@@ -125,6 +147,7 @@ Page({ | |||
}) | |||
return; | |||
} | |||
console.log(this.data.yesClick) | |||
if (this.data.yesClick){ | |||
return; | |||
} | |||
@@ -146,8 +169,15 @@ Page({ | |||
console.log(res) | |||
this.orderPay() | |||
}, | |||
fail: res => { | |||
this.data.yesClick = false; | |||
}, | |||
complete: res => { | |||
this.data.yesClick = false; | |||
} | |||
}) | |||
} else if (e.code == -3003){ | |||
} else if (e.code == -3003) { | |||
this.data.yesClick = false; | |||
wx.showToast({ | |||
title: e.message, | |||
icon:"none", | |||
@@ -160,7 +190,6 @@ Page({ | |||
app.wxRequest(app.globalData.httpUrl + 'order/paid', { sign_num: this.data.sign_num}, e => { | |||
console.log(e) | |||
if (e.code == 200) { | |||
this.data.yesClick = false; | |||
wx.reLaunch({ | |||
url: '/pages/personalCenter/personalCenter' | |||
}) |
@@ -17,7 +17,7 @@ Page({ | |||
}, | |||
getDataList:function(){ | |||
app.wxRequest(app.globalData.httpUrl + 'couponsell/list', {}, e => { | |||
// console.log(e) | |||
console.log(e) | |||
if (e.code == 200) { | |||
this.setData({ | |||
dataList:e.data[0] |
@@ -21,35 +21,22 @@ Page({ | |||
getHistory: [],//每次接口拉取的数据 | |||
getHistoryArr: [],//全部使用数据 | |||
myTicketArr: [],//我的优惠券列表 | |||
headerImg:"../images/headerImg.png",//默认头像 | |||
userName:"",//昵称 | |||
}, | |||
/** | |||
* 生命周期函数--监听页面加载 | |||
*/ | |||
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) | |||
}, | |||
getToRsgisterFn:function(){//未注册点击跳到注册页 | |||
wx.navigateTo({ | |||
url: '/pages/register/register', | |||
}) | |||
}, | |||
myTicket:function(){//获取我的优惠券列表 | |||
app.wxRequest(app.globalData.httpUrl + 'couponbuy/validtype', {}, e => { | |||
@@ -100,7 +87,59 @@ Page({ | |||
* 生命周期函数--监听页面显示 | |||
*/ | |||
onShow: function () { | |||
if (!this.data.getUser) { | |||
var state = wx.getStorageSync('state'); | |||
if (state == 1) {//已注册 | |||
var userInfo = wx.getStorageSync('userInfo'); | |||
var state = wx.getStorageSync('state'); | |||
if (app.globalData.openId) { | |||
this.myTicket(); | |||
this.historyTicket(); | |||
} else { | |||
app.globalData.openidSuccessFuc = this.myTicket; | |||
app.globalData.openidSuccessFuc = this.historyTicket; | |||
} | |||
console.log(app.globalData.userInfo) | |||
var userInfo = wx.getStorageSync('userInfo'); | |||
var phone = wx.getStorageSync('user_phone'); | |||
this.setData({ | |||
headerImg: userInfo.avatarUrl, | |||
userName: userInfo.nickName, | |||
userPhone: phone, | |||
getUser: true | |||
}) | |||
} else if (state == 0) {//未注册 | |||
this.setData({ | |||
getUser: false | |||
}) | |||
} else if (state == -1) { | |||
app.globalData.userInfoBackFn = res => {//等待结果 | |||
console.log(res) | |||
if (res) { | |||
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'); | |||
this.setData({ | |||
headerImg: userInfo.avatarUrl, | |||
userName: userInfo.nickName, | |||
userPhone: phone, | |||
getUser: true | |||
}) | |||
} else { | |||
this.setData({ | |||
getUser: false | |||
}) | |||
} | |||
} | |||
} | |||
} | |||
}, | |||
/** | |||
@@ -184,39 +223,24 @@ Page({ | |||
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") | |||
} | |||
// 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({ | |||
// headerImg: userArr, | |||
// getUser: true, | |||
// userPhone: phone | |||
// }) | |||
// this.submitUser(); | |||
// console.log(this.data.getUserArr) | |||
// }, | |||
}) |
@@ -5,10 +5,11 @@ | |||
<image class="userCircle" src="../images/userCircle.png"></image> | |||
<view class="userAll"> | |||
<view class="userHeader"> | |||
<image class="userImg" src="{{getUserArr[0]}}"></image> | |||
<image class="userImg" src="{{headerImg}}"></image> | |||
</view> | |||
<button wx:if="{{!getUser}}" plain="true" size="mini" class="getUser" open-type="getUserInfo" bindgetuserinfo="getUser">登陆</button> | |||
<view class="userName">{{getUserArr[1]}}</view> | |||
<!-- <button wx:if="{{!getUser}}" plain="true" size="mini" class="getUser" open-type="getUserInfo" bindgetuserinfo="getUser">登陆</button> --> | |||
<image wx:if="{{!getUser}}" bindtap="getToRsgisterFn" class="getToRsgister" src="../images/getToRsgister.png"></image> | |||
<view wx:if="{{getUser}}" class="userName">{{userName}}</view> | |||
<view wx:if="{{getUser}}" class="userPhone">{{userPhone}}</view> | |||
</view> | |||
@@ -192,4 +192,10 @@ page{ | |||
} | |||
.contAll{ | |||
box-shadow: 50rpx 10rpx 20rpx #d4d2d2; | |||
} | |||
.getToRsgister{ | |||
width: 318rpx; | |||
height: 38rpx; | |||
margin-top: 20rpx; | |||
} |
@@ -14,36 +14,14 @@ Page({ | |||
phone: "",//手机号 | |||
phoneCode: "",//验证码 | |||
yesRegister:false,//防止重复点击注册 | |||
showAll:false, | |||
userInfo:[],//用户信息 | |||
}, | |||
/** | |||
* 生命周期函数--监听页面加载 | |||
*/ | |||
onLoad: function (options) { | |||
var state = wx.getStorageSync('state'); | |||
if (state==1){//已注册 | |||
wx.switchTab({ | |||
url: '/pages/index/index' | |||
}) | |||
} else if (state == 0){//未注册 | |||
this.setData({ | |||
showAll:true | |||
}) | |||
} else if (state == -1){ | |||
app.globalData.userInfoBackFn = res=>{//等待结果 | |||
console.log(res) | |||
if (res){ | |||
wx.switchTab({ | |||
url: '/pages/index/index' | |||
}) | |||
}else{ | |||
this.setData({ | |||
showAll: true | |||
}) | |||
} | |||
} | |||
} | |||
}, | |||
/** | |||
@@ -175,7 +153,25 @@ Page({ | |||
}) | |||
console.log(this.data.minter) | |||
}, | |||
registerBtn:function(){//点击按钮注册 | |||
submitUser: function () {//提交用户信息 | |||
var params = { | |||
"province": this.data.userInfo.province, | |||
"language": this.data.userInfo.language, | |||
"city": this.data.userInfo.city, | |||
"gender": this.data.userInfo.gender, | |||
"nickname": this.data.userInfo.nickName, | |||
"headimgurl": this.data.userInfo.avatarUrl, | |||
} | |||
app.wxRequest(app.globalData.httpUrl + 'submit', params, e => { | |||
console.log(e) | |||
if (e.code == 200) { | |||
} | |||
}, this, "POST") | |||
}, | |||
getUserFn:function(e){//点击按钮注册 | |||
console.log(e) | |||
this.data.userInfo = e.detail.userInfo; | |||
if (app.globalData.openId) { | |||
this.registerFn(); | |||
} else { | |||
@@ -217,27 +213,24 @@ Page({ | |||
if (e.code == 200) { | |||
clearInterval(time); | |||
wx.setStorageSync('user_phone', e.data.user_phone); | |||
wx.setStorageSync("userInfo", this.data.userInfo) | |||
wx.setStorageSync('state', 1); | |||
app.globalData.userInfo = e.data; | |||
this.submitUser(); | |||
this.setData({ | |||
minter: 60, | |||
num: 60 | |||
}) | |||
wx.showToast({ | |||
title: '注册成功', | |||
icon: 'success', | |||
duration: 500 | |||
}) | |||
setTimeout(function () { | |||
if (app.globalData.present_id){ | |||
wx.reLaunch({ | |||
url: '/pages/receiveTicket/receiveTicket?shareId=' + app.globalData.present_id + "&number=" + app.globalData.number | |||
}) | |||
} else { | |||
wx.switchTab({ | |||
url: '../index/index' | |||
}) | |||
} | |||
}, 1000) | |||
if (app.globalData.present_id){ | |||
wx.reLaunch({ | |||
url: '/pages/receiveTicket/receiveTicket?shareId=' + app.globalData.present_id + "&number=" + app.globalData.number | |||
}) | |||
} else { | |||
console.log(5555) | |||
wx.switchTab({ | |||
url: '../index/index' | |||
}) | |||
} | |||
} else { | |||
this.data.yesRegister = false; | |||
wx.showToast({ |
@@ -1,5 +1,5 @@ | |||
<!--pages/register/register.wxml--> | |||
<view class="all" wx:if="{{showAll}}"> | |||
<view class="all"> | |||
<image class="registerBg" src="../images/registerBg.jpg"></image> | |||
<view class="import"> | |||
<view class="phoneView"> | |||
@@ -10,6 +10,8 @@ | |||
<view class="sendBtn" wx:if="{{yesSend}}">{{minter}}</view> | |||
<input class="codeInt" type="number" bindinput="getCode" placeholder="验证码" placeholder-class="placeholderClass"></input> | |||
</view> | |||
<image bindtap="registerBtn" class="registerBtn" src="../images/registerBtn.png"></image> | |||
<button class="getUser" open-type="getUserInfo" bindgetuserinfo="getUserFn"> | |||
<image class="registerBtn" src="../images/registerBtn.png"></image> | |||
</button> | |||
</view> | |||
</view> |
@@ -65,7 +65,18 @@ page{ | |||
.registerBtn{ | |||
width: 600rpx; | |||
height: 98rpx; | |||
/* bottom: 246rpx; */ | |||
margin-left: 75rpx; | |||
} | |||
.getUser::after{ | |||
border: none | |||
} | |||
.getUser{ | |||
margin-top: 130rpx; | |||
padding: 0; | |||
width: 600rpx; | |||
height: 98rpx; | |||
border: none; | |||
border-color: transparent; | |||
border-radius: 0; | |||
background-color: transparent; | |||
} |
@@ -50,6 +50,7 @@ Page({ | |||
provinceIndex: value, | |||
cityIndex:0, | |||
}) | |||
console.log(this.data.changeCity) | |||
}else{ | |||
this.setData({ | |||
index: value, | |||
@@ -104,9 +105,6 @@ Page({ | |||
}) | |||
this.searchShop(); | |||
// console.log(this.data.provinceArr) | |||
// console.log(this.data.cityArr) | |||
// console.log(this.data.provinceCityArr) | |||
} | |||
}, this) | |||
}, |