this.globalData.openId = openid; | this.globalData.openId = openid; | ||||
this.getUserType(); | 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 () {//获取用户注册状态 | getUserType: function () {//获取用户注册状态 | ||||
console.log(this.globalData.openId) | console.log(this.globalData.openId) | ||||
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){//未注册跳到注册页面 | ||||
wx.reLaunch({ | |||||
url: '/pages/register/register' | |||||
}) | |||||
this.globalData.state = 0 | |||||
} else if (e.code == 202) {//已注册 | } else if (e.code == 202) {//已注册 | ||||
this.globalData.state = 1 | |||||
this.globalData.userInfo = e.data; | 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) | },this) | ||||
}, | }, | ||||
globalData: { | globalData: { | ||||
state:-1, | |||||
openidSuccessFuc: null,//方法回调 | openidSuccessFuc: null,//方法回调 | ||||
userInfoSuccessFuc: null,//方法回调 | userInfoSuccessFuc: null,//方法回调 | ||||
userInfo: null, | userInfo: null, | ||||
token:"", | token:"", | ||||
userInfo:"", | userInfo:"", | ||||
httpUrl:"https://laomenkuang.jiyou-tech.com/apiWx/", | httpUrl:"https://laomenkuang.jiyou-tech.com/apiWx/", | ||||
getUserArr:[],//用户信息 | |||||
user_phone:"",//用户手机号 | |||||
}, | }, | ||||
wxRequest: function (url, params, callback, thisArg, methods, openid) { | wxRequest: function (url, params, callback, thisArg, methods, openid) { | ||||
let that = this; | let that = this; |
{ | { | ||||
"pages":[ | "pages":[ | ||||
"pages/index/index", | |||||
"pages/register/register", | "pages/register/register", | ||||
"pages/index/index", | |||||
"pages/shop/shop", | "pages/shop/shop", | ||||
"pages/personalCenter/personalCenter", | "pages/personalCenter/personalCenter", | ||||
"pages/buyTicket/buyTicket", | "pages/buyTicket/buyTicket", |
padding-left: 75rpx; | padding-left: 75rpx; | ||||
padding-bottom: 53rpx; | padding-bottom: 53rpx; | ||||
position: absolute; | |||||
position: fixed; | |||||
left: 0; | left: 0; | ||||
bottom: 0; | bottom: 0; | ||||
} | } | ||||
.ruleBtn{ | .ruleBtn{ | ||||
width: 117rpx; | width: 117rpx; | ||||
height: 37rpx; | height: 37rpx; | ||||
position: absolute; | |||||
position: fixed; | |||||
right: 30rpx; | right: 30rpx; | ||||
bottom: 485rpx; | bottom: 485rpx; | ||||
z-index: 10; | z-index: 10; |
userArr.push(app.globalData.userInfo.headimgurl); | userArr.push(app.globalData.userInfo.headimgurl); | ||||
userArr.push(app.globalData.userInfo.nickname); | userArr.push(app.globalData.userInfo.nickname); | ||||
phone = app.globalData.userInfo.user_phone | phone = app.globalData.userInfo.user_phone | ||||
console.log(phone) | |||||
this.setData({ | this.setData({ | ||||
getUserArr: userArr, | getUserArr: userArr, | ||||
getUser: true, | getUser: true, | ||||
var phone = ""; | var phone = ""; | ||||
userArr.push(e.detail.userInfo.avatarUrl); | userArr.push(e.detail.userInfo.avatarUrl); | ||||
userArr.push(e.detail.userInfo.nickName); | 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.data.userChuan = e.detail.userInfo; | ||||
this.setData({ | this.setData({ | ||||
getUserArr: userArr, | getUserArr: userArr, |
/* pages/personalCenter/personalCenter.wxss */ | /* pages/personalCenter/personalCenter.wxss */ | ||||
page{ | |||||
height: 100%; | |||||
} | |||||
.all{ | .all{ | ||||
position: relative; | |||||
height: 100%; | |||||
width: 100%; | |||||
position: fixed; | |||||
top: 0; | |||||
left: 0; | |||||
} | } | ||||
.centerBg{ | .centerBg{ | ||||
width: 100%; | width: 100%; |
presentId:"",//接受的id | presentId:"",//接受的id | ||||
ticketNum:0, | ticketNum:0, | ||||
moreClick:false,//防止重复点击领取 | moreClick:false,//防止重复点击领取 | ||||
showAll:false, | |||||
}, | }, | ||||
/** | /** | ||||
ticketNum: options.number | 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 () {//获取赠送优惠券信息 | getTicketUser: function () {//获取赠送优惠券信息 |
<!--pages/receiveTicket/receiveTicket.wxml--> | <!--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> | ||||
<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> | </view> | ||||
<image bindtap="getTicketFn" class="getTicket" src="../images/getTicket.png"></image> | |||||
</view> | </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> | </view> | ||||
phone: "",//手机号 | phone: "",//手机号 | ||||
phoneCode: "",//验证码 | phoneCode: "",//验证码 | ||||
yesRegister:false,//防止重复点击注册 | yesRegister:false,//防止重复点击注册 | ||||
showAll:false, | |||||
}, | }, | ||||
/** | /** | ||||
* 生命周期函数--监听页面加载 | * 生命周期函数--监听页面加载 | ||||
*/ | */ | ||||
onLoad: function (options) { | 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 | |||||
}) | |||||
} | |||||
} | |||||
} | |||||
}, | }, | ||||
/** | /** | ||||
this.data.yesRegister = true; | this.data.yesRegister = true; | ||||
if (e.code == 200) { | if (e.code == 200) { | ||||
clearInterval(time); | clearInterval(time); | ||||
app.globalData.userInfo = e.data.user_phone | |||||
app.globalData.user_phone = e.data.user_phone | |||||
this.setData({ | this.setData({ | ||||
minter: 60, | minter: 60, | ||||
num: 60 | num: 60 |
<!--pages/register/register.wxml--> | <!--pages/register/register.wxml--> | ||||
<view class="all"> | |||||
<view class="all" wx:if="{{showAll}}"> | |||||
<image class="registerBg" src="../images/registerBg.jpg"></image> | <image class="registerBg" src="../images/registerBg.jpg"></image> | ||||
<view class="import"> | <view class="import"> | ||||
<view class="phoneView"> | <view class="phoneView"> |
provinceCityArr: provinceCity, | provinceCityArr: provinceCity, | ||||
}) | }) | ||||
this.searchShop(true); | |||||
this.searchShop(); | |||||
// console.log(this.data.provinceArr) | // console.log(this.data.provinceArr) | ||||
// console.log(this.data.cityArr) | // console.log(this.data.cityArr) | ||||
// console.log(this.data.provinceCityArr) | // console.log(this.data.provinceCityArr) | ||||
}, this) | }, 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 province = ""; | ||||
var city = ""; | 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] == "全部") { | if (this.data.provinceCityArr[0][this.data.provinceIndex] == "全部") { | ||||
this.data.provinceCityArr[0][this.data.provinceIndex] = ""; | this.data.provinceCityArr[0][this.data.provinceIndex] = ""; | ||||
} | } | ||||
} | } | ||||
province = this.data.provinceCityArr[0][this.data.provinceIndex]; | province = this.data.provinceCityArr[0][this.data.provinceIndex]; | ||||
city = this.data.provinceCityArr[1][this.data.cityIndex]; | city = this.data.provinceCityArr[1][this.data.cityIndex]; | ||||
} | |||||
var params = { | var params = { | ||||
"shop_province": province, | "shop_province": province, | ||||
"shop_city": city, | "shop_city": city, | ||||
wx.showModal({ | wx.showModal({ | ||||
title: '没有搜索到匹配的门店', | title: '没有搜索到匹配的门店', | ||||
}) | }) | ||||
this.setData({ | |||||
inputVal: "" | |||||
}) | |||||
// this.setData({ | |||||
// inputVal: "" | |||||
// }) | |||||
} | } | ||||
}, this) | }, this) | ||||
}, | }, | ||||
this.setData({ | this.setData({ | ||||
inputVal:e.detail.value | inputVal:e.detail.value | ||||
}) | }) | ||||
if (this.data.inputVal == "") { | |||||
this.data.pageNum = 1; | |||||
this.data.dataArr = []; | |||||
this.searchShop(); | |||||
} | |||||
}, | }, | ||||
searchFn:function(){//点击搜索按钮 | searchFn:function(){//点击搜索按钮 | ||||
wx.pageScrollTo({ | wx.pageScrollTo({ | ||||
console.log(this.data.index) | console.log(this.data.index) | ||||
this.data.pageNum = 1; | this.data.pageNum = 1; | ||||
this.data.dataArr = []; | this.data.dataArr = []; | ||||
this.searchShop(true); | |||||
this.searchShop(); | |||||
}, | }, | ||||
deleteVal:function(){//清空搜索框 | deleteVal:function(){//清空搜索框 | ||||
this.setData({ | this.setData({ | ||||
this.data.pageNum = 1; | this.data.pageNum = 1; | ||||
this.data.dataArr = []; | this.data.dataArr = []; | ||||
this.searchShop(true); | |||||
this.searchShop(); | |||||
}, | }, | ||||
openAddress:function(e){//打开地图 | openAddress:function(e){//打开地图 | ||||
var index = e.target.dataset.index; | var index = e.target.dataset.index; |
<view class="content"> | <view class="content"> | ||||
<!-- <scroll-view scroll-y="true" style="height:{{scrollHig}}px" bindtouchend=""> --> | <!-- <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> | ||||
<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> | ||||
</view> | |||||
<!-- </scroll-view> --> | |||||
</view> | </view> | ||||
</view> | </view> | ||||