@@ -44,63 +44,27 @@ App({ | |||
this.globalData.openId = openid; | |||
this.getUserType(); | |||
} | |||
// 获取用户信息 | |||
// wx.getSetting({ | |||
// success: res => { | |||
// console.log(res) | |||
// if (res.authSetting['scope.userInfo']) { | |||
// // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 | |||
// wx.getUserInfo({ | |||
// success: e => { | |||
// // 可以将 res 发送给后台解码出 unionId | |||
// this.globalData.userInfo = e.userInfo | |||
// // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 | |||
// // 所以此处加入 callback 以防止这种情况 | |||
// if (this.userInfoReadyCallback) { | |||
// this.userInfoReadyCallback(res) | |||
// } | |||
// } | |||
// }) | |||
// }else{ | |||
// wx.authorize({ | |||
// scope: 'scope.record', | |||
// success() { | |||
// wx.getUserInfo({ | |||
// success: e => { | |||
// console.log(e) | |||
// } | |||
// }) | |||
// } | |||
// }) | |||
// } | |||
// } | |||
// }) | |||
}, | |||
onShow:function(){ | |||
this.getUserType(); | |||
}, | |||
// onShow:function(){ | |||
// this.getUserType(); | |||
// }, | |||
getUserType: function () {//获取用户注册状态 | |||
console.log(this.globalData.openId) | |||
this.wxRequest(this.globalData.httpUrl + 'getinfo', {},e=>{ | |||
console.log(e) | |||
if(e.code==201){//未注册跳到注册页面 | |||
wx.reLaunch({ | |||
url: '/pages/register/register' | |||
}) | |||
this.globalData.state = 0 | |||
} else if (e.code == 202) {//已注册 | |||
this.globalData.state = 1 | |||
this.globalData.userInfo = e.data; | |||
console.log(this.globalData.userInfo) | |||
if (this.globalData.present_id){ | |||
} else { | |||
wx.switchTab({ | |||
url: '/pages/index/index' | |||
}) | |||
} | |||
} | |||
if(this.globalData.userInfoBackFn){ | |||
this.globalData.userInfoBackFn(this.globalData.state); | |||
} | |||
},this) | |||
}, | |||
globalData: { | |||
state:-1, | |||
openidSuccessFuc: null,//方法回调 | |||
userInfoSuccessFuc: null,//方法回调 | |||
userInfo: null, | |||
@@ -111,7 +75,7 @@ App({ | |||
token:"", | |||
userInfo:"", | |||
httpUrl:"https://laomenkuang.jiyou-tech.com/apiWx/", | |||
getUserArr:[],//用户信息 | |||
user_phone:"",//用户手机号 | |||
}, | |||
wxRequest: function (url, params, callback, thisArg, methods, openid) { | |||
let that = this; |
@@ -1,7 +1,7 @@ | |||
{ | |||
"pages":[ | |||
"pages/index/index", | |||
"pages/register/register", | |||
"pages/index/index", | |||
"pages/shop/shop", | |||
"pages/personalCenter/personalCenter", | |||
"pages/buyTicket/buyTicket", |
@@ -32,7 +32,7 @@ page{ | |||
padding-left: 75rpx; | |||
padding-bottom: 53rpx; | |||
position: absolute; | |||
position: fixed; | |||
left: 0; | |||
bottom: 0; | |||
} | |||
@@ -82,7 +82,7 @@ page{ | |||
.ruleBtn{ | |||
width: 117rpx; | |||
height: 37rpx; | |||
position: absolute; | |||
position: fixed; | |||
right: 30rpx; | |||
bottom: 485rpx; | |||
z-index: 10; |
@@ -41,6 +41,7 @@ Page({ | |||
userArr.push(app.globalData.userInfo.headimgurl); | |||
userArr.push(app.globalData.userInfo.nickname); | |||
phone = app.globalData.userInfo.user_phone | |||
console.log(phone) | |||
this.setData({ | |||
getUserArr: userArr, | |||
getUser: true, | |||
@@ -182,7 +183,8 @@ Page({ | |||
var phone = ""; | |||
userArr.push(e.detail.userInfo.avatarUrl); | |||
userArr.push(e.detail.userInfo.nickName); | |||
phone = app.globalData.userInfo.user_phone | |||
phone = app.globalData.user_phone | |||
console.log(phone) | |||
this.data.userChuan = e.detail.userInfo; | |||
this.setData({ | |||
getUserArr: userArr, |
@@ -1,6 +1,13 @@ | |||
/* pages/personalCenter/personalCenter.wxss */ | |||
page{ | |||
height: 100%; | |||
} | |||
.all{ | |||
position: relative; | |||
height: 100%; | |||
width: 100%; | |||
position: fixed; | |||
top: 0; | |||
left: 0; | |||
} | |||
.centerBg{ | |||
width: 100%; |
@@ -13,6 +13,7 @@ Page({ | |||
presentId:"",//接受的id | |||
ticketNum:0, | |||
moreClick:false,//防止重复点击领取 | |||
showAll:false, | |||
}, | |||
/** | |||
@@ -26,12 +27,38 @@ Page({ | |||
ticketNum: options.number | |||
}) | |||
if (app.globalData.openId) { | |||
this.getTicketUser(); | |||
} else { | |||
app.globalData.openidSuccessFuc = this.getTicketUser; | |||
} | |||
if (app.globalData.state == 1) {//已注册 | |||
if (app.globalData.openId) { | |||
this.getTicketUser(); | |||
} else { | |||
app.globalData.openidSuccessFuc = this.getTicketUser; | |||
} | |||
this.setData({ | |||
showAll:true | |||
}) | |||
} else if (app.globalData.state == 0) {//未注册 | |||
wx.switchTab({ | |||
url: '/pages/register/register' | |||
}) | |||
} else if (app.globalData.state == -1) { | |||
app.globalData.userInfoBackFn = res => {//等待结果 | |||
if (res) { | |||
if (app.globalData.openId) { | |||
this.getTicketUser(); | |||
} else { | |||
app.globalData.openidSuccessFuc = this.getTicketUser; | |||
} | |||
this.setData({ | |||
showAll: true | |||
}) | |||
} else { | |||
wx.switchTab({ | |||
url: '/pages/register/register' | |||
}) | |||
} | |||
} | |||
} | |||
}, | |||
getTicketUser: function () {//获取赠送优惠券信息 |
@@ -1,36 +1,38 @@ | |||
<!--pages/receiveTicket/receiveTicket.wxml--> | |||
<image class="getBg" src="../images/getBg.png"></image> | |||
<view class="all" wx:if="{{yesGet}}"> | |||
<view class="content"> | |||
<view class="userName">你的好友{{ticketUser.nickname}}</view> | |||
<view class="userPhone">{{userPhone}}</view> | |||
<view class="giveTo">赠送给您</view> | |||
<view class="giveNum"> | |||
<text class="textNum">{{ticketNum}}</text> | |||
<text class="text">张</text> | |||
</view> | |||
<view class="ticketType">{{ticketUser.coupon_type}}</view> | |||
<view class="line"></view> | |||
</view> | |||
<view class="contBot"> | |||
<view class="picView"> | |||
<image class="smallTicket" src="{{ticketUser.coupon_img_small}}"></image> | |||
<view class="viewAll" wx:if="{{showAll}}"> | |||
<image class="getBg" src="../images/getBg.png"></image> | |||
<view class="all" wx:if="{{yesGet}}"> | |||
<view class="content"> | |||
<view class="userName">你的好友{{ticketUser.nickname}}</view> | |||
<view class="userPhone">{{userPhone}}</view> | |||
<view class="giveTo">赠送给您</view> | |||
<view class="giveNum"> | |||
<text class="textNum">{{ticketNum}}</text> | |||
<text class="text">张</text> | |||
</view> | |||
<view class="ticketType">{{ticketUser.coupon_type}}</view> | |||
<view class="line"></view> | |||
</view> | |||
<view class="textView"> | |||
<text class="nameText">{{ticketUser.coupon_name}}</text> | |||
<text class="timeText">{{ticketUser.coupon_condition_desc}}</text> | |||
<text class="timeText">(有效期:{{ticketUser.duration}})</text> | |||
<view class="contBot"> | |||
<view class="picView"> | |||
<image class="smallTicket" src="{{ticketUser.coupon_img_small}}"></image> | |||
</view> | |||
<view class="textView"> | |||
<text class="nameText">{{ticketUser.coupon_name}}</text> | |||
<text class="timeText">{{ticketUser.coupon_condition_desc}}</text> | |||
<text class="timeText">(有效期:{{ticketUser.duration}})</text> | |||
</view> | |||
</view> | |||
<image bindtap="getTicketFn" class="getTicket" src="../images/getTicket.png"></image> | |||
</view> | |||
<image bindtap="getTicketFn" class="getTicket" src="../images/getTicket.png"></image> | |||
</view> | |||
<view wx:if="{{!yesGet}}"> | |||
<view class="errorTitle">领取失败</view> | |||
<view class="ticketState">{{titleWord}}</view> | |||
<view class="question">如有疑问请联系</view> | |||
<view class="wx">{{ticketUser.nickname}}</view> | |||
<view class="phone">{{userPhone}}</view> | |||
<image bindtap="backIndex" class="sureTicket" src="../images/sureTicket.png"></image> | |||
<view wx:if="{{!yesGet}}"> | |||
<view class="errorTitle">领取失败</view> | |||
<view class="ticketState">{{titleWord}}</view> | |||
<view class="question">如有疑问请联系</view> | |||
<view class="wx">{{ticketUser.nickname}}</view> | |||
<view class="phone">{{userPhone}}</view> | |||
<image bindtap="backIndex" class="sureTicket" src="../images/sureTicket.png"></image> | |||
</view> | |||
</view> | |||
@@ -14,13 +14,35 @@ Page({ | |||
phone: "",//手机号 | |||
phoneCode: "",//验证码 | |||
yesRegister:false,//防止重复点击注册 | |||
showAll:false, | |||
}, | |||
/** | |||
* 生命周期函数--监听页面加载 | |||
*/ | |||
onLoad: function (options) { | |||
if (app.globalData.state==1){//已注册 | |||
wx.switchTab({ | |||
url: '/pages/index/index' | |||
}) | |||
} else if (app.globalData.state == 0){//未注册 | |||
this.setData({ | |||
showAll:true | |||
}) | |||
} else if (app.globalData.state == -1){ | |||
app.globalData.userInfoBackFn = res=>{//等待结果 | |||
console.log(res) | |||
if (res){ | |||
wx.switchTab({ | |||
url: '/pages/index/index' | |||
}) | |||
}else{ | |||
this.setData({ | |||
showAll: true | |||
}) | |||
} | |||
} | |||
} | |||
}, | |||
/** | |||
@@ -187,7 +209,7 @@ Page({ | |||
this.data.yesRegister = true; | |||
if (e.code == 200) { | |||
clearInterval(time); | |||
app.globalData.userInfo = e.data.user_phone | |||
app.globalData.user_phone = e.data.user_phone | |||
this.setData({ | |||
minter: 60, | |||
num: 60 |
@@ -1,5 +1,5 @@ | |||
<!--pages/register/register.wxml--> | |||
<view class="all"> | |||
<view class="all" wx:if="{{showAll}}"> | |||
<image class="registerBg" src="../images/registerBg.jpg"></image> | |||
<view class="import"> | |||
<view class="phoneView"> |
@@ -100,7 +100,7 @@ Page({ | |||
provinceCityArr: provinceCity, | |||
}) | |||
this.searchShop(true); | |||
this.searchShop(); | |||
// console.log(this.data.provinceArr) | |||
// console.log(this.data.cityArr) | |||
// console.log(this.data.provinceCityArr) | |||
@@ -108,27 +108,9 @@ Page({ | |||
}, this) | |||
}, | |||
searchShop: function (search){//搜索 | |||
if (search) { | |||
console.log(this.data.provinceCityArr) | |||
if (this.data.provinceCityArr[0][0] == "") { | |||
this.data.provinceCityArr[0][0] = "全部" | |||
} | |||
if (this.data.provinceCityArr[1][0] == "") { | |||
this.data.provinceCityArr[1][0] = "全部"; | |||
} | |||
searchShop: function (){//搜索 | |||
var province = ""; | |||
var city = ""; | |||
var activeArr = [this.data.provinceArr, this.data.cityArr[0]]; | |||
this.setData({ | |||
provinceIndex: 0, | |||
cityIndex: 0, | |||
index: 0, | |||
provinceCityArr: activeArr, | |||
}) | |||
}else{ | |||
console.log(222) | |||
if (this.data.provinceCityArr[0][this.data.provinceIndex] == "全部") { | |||
this.data.provinceCityArr[0][this.data.provinceIndex] = ""; | |||
} | |||
@@ -137,7 +119,6 @@ Page({ | |||
} | |||
province = this.data.provinceCityArr[0][this.data.provinceIndex]; | |||
city = this.data.provinceCityArr[1][this.data.cityIndex]; | |||
} | |||
var params = { | |||
"shop_province": province, | |||
"shop_city": city, | |||
@@ -160,9 +141,9 @@ Page({ | |||
wx.showModal({ | |||
title: '没有搜索到匹配的门店', | |||
}) | |||
this.setData({ | |||
inputVal: "" | |||
}) | |||
// this.setData({ | |||
// inputVal: "" | |||
// }) | |||
} | |||
}, this) | |||
}, | |||
@@ -236,6 +217,11 @@ Page({ | |||
this.setData({ | |||
inputVal:e.detail.value | |||
}) | |||
if (this.data.inputVal == "") { | |||
this.data.pageNum = 1; | |||
this.data.dataArr = []; | |||
this.searchShop(); | |||
} | |||
}, | |||
searchFn:function(){//点击搜索按钮 | |||
wx.pageScrollTo({ | |||
@@ -247,7 +233,7 @@ Page({ | |||
console.log(this.data.index) | |||
this.data.pageNum = 1; | |||
this.data.dataArr = []; | |||
this.searchShop(true); | |||
this.searchShop(); | |||
}, | |||
deleteVal:function(){//清空搜索框 | |||
this.setData({ | |||
@@ -256,7 +242,7 @@ Page({ | |||
this.data.pageNum = 1; | |||
this.data.dataArr = []; | |||
this.searchShop(true); | |||
this.searchShop(); | |||
}, | |||
openAddress:function(e){//打开地图 | |||
var index = e.target.dataset.index; |
@@ -19,24 +19,25 @@ | |||
<view class="content"> | |||
<!-- <scroll-view scroll-y="true" style="height:{{scrollHig}}px" bindtouchend=""> --> | |||
<view> | |||
<view class="getData" wx:for="{{showDataArr}}"> | |||
<view class="imgView"> | |||
<image mode="widthFix" class="shop" src="{{item.shop_img}}"></image> | |||
<image bindtap="callPhone" data-index="{{index}}" class="ringUp" src="../images/ringUp.png" ></image> | |||
<view> | |||
<view class="getData" wx:for="{{showDataArr}}"> | |||
<view class="imgView"> | |||
<image mode="widthFix" class="shop" src="{{item.shop_img}}"></image> | |||
<image bindtap="callPhone" data-index="{{index}}" class="ringUp" src="../images/ringUp.png" ></image> | |||
</view> | |||
<view class="shopName">{{item.shop_name}}</view> | |||
<view class="address" bindtap="openAddress"> | |||
<image class="addressIcon" src="../images/addressIcon.png"></image> | |||
<view class="iconRig" data-index="{{index}}">{{item.shop_addr}}</view> | |||
</view> | |||
<view class="phone"> | |||
<image class="phoneIcon" src="../images/phoneIcon.png"></image> | |||
<view class="iconRig" data-index="{{index}}" bindtap="callPhone">{{item.shop_phone}}</view> | |||
</view> | |||
<view class="line"></view> | |||
</view> | |||
<view class="shopName">{{item.shop_name}}</view> | |||
<view class="address" bindtap="openAddress"> | |||
<image class="addressIcon" src="../images/addressIcon.png"></image> | |||
<view class="iconRig" data-index="{{index}}">{{item.shop_addr}}</view> | |||
</view> | |||
<view class="phone"> | |||
<image class="phoneIcon" src="../images/phoneIcon.png"></image> | |||
<view class="iconRig" data-index="{{index}}" bindtap="callPhone">{{item.shop_phone}}</view> | |||
</view> | |||
<view class="line"></view> | |||
</view> | |||
</view> | |||
<!-- </scroll-view> --> | |||
</view> | |||
</view> | |||