| @@ -6,7 +6,7 @@ App({ | |||
| // logs.unshift(Date.now()) | |||
| // wx.setStorageSync('logs', logs) | |||
| var openid = wx.getStorageSync('openid') || ""; | |||
| wx.setStorageSync('state',-1); | |||
| wx.setStorageSync('state', -1); | |||
| // 登录 | |||
| if (!openid){ | |||
| wx.login({ | |||
| @@ -55,15 +55,26 @@ App({ | |||
| console.log(e) | |||
| if(e.code==201){//未注册跳到注册页面 | |||
| wx.setStorageSync('state', 0); | |||
| wx.setStorageSync("noUser", 0) | |||
| } else if (e.code == 202) {//已注册 | |||
| wx.setStorageSync('state', 1); | |||
| this.globalData.userInfo = e.data; | |||
| e.data.avatarUrl = e.data.headimgurl; | |||
| e.data.nickName = e.data.nickname; | |||
| wx.setStorageSync('user_phone', e.data.user_phone); | |||
| wx.setStorageSync("userInfo", e.data) | |||
| if (e.data.item_state == 1) { | |||
| wx.setStorageSync("noUser", 0) | |||
| } else { | |||
| wx.setStorageSync("noUser", 1) | |||
| } | |||
| } | |||
| if(this.globalData.userInfoBackFn){ | |||
| this.globalData.userInfoBackFn(wx.getStorageSync('state')); | |||
| } | |||
| },this) | |||
| }, | |||
| globalData: { | |||
| openidSuccessFuc: null,//方法回调 | |||
| userInfoSuccessFuc: null,//方法回调 | |||
| @@ -39,5 +39,10 @@ | |||
| "text": "个人中心" | |||
| } | |||
| ] | |||
| }, | |||
| "permission": { | |||
| "scope.userLocation": { | |||
| "desc": "你的位置信息将用于小程序位置接口的效果展示" | |||
| } | |||
| } | |||
| } | |||
| @@ -27,6 +27,25 @@ Page({ | |||
| app.globalData.openidSuccessFuc = this.getTicketUser; | |||
| app.globalData.openidSuccessFuc = this.getCodeFn; | |||
| } | |||
| if (state == 1) {//已注册 | |||
| } else if (state == 0) {//未注册 | |||
| wx.navigateTo({ | |||
| url: '/pages/register/register', | |||
| }) | |||
| } else if (state == -1) { | |||
| app.globalData.userInfoBackFn = res => {//等待结果 | |||
| console.log(res) | |||
| if (res) { | |||
| } else { | |||
| wx.navigateTo({ | |||
| url: '/pages/register/register', | |||
| }) | |||
| } | |||
| } | |||
| } | |||
| }, | |||
| getTicketUser: function () {//获取优惠券信息 | |||
| app.wxRequest(app.globalData.httpUrl + 'couponsell/detail', { coupon_sell_id: this.data.id, from: 1}, e => { | |||
| @@ -101,7 +120,6 @@ Page({ | |||
| onShareAppMessage: function () { | |||
| return { | |||
| title: "老门框爆肚会员", | |||
| path: "/pages/register/register", | |||
| success: res => { | |||
| console.log(res, "转发成功") | |||
| }, | |||
| @@ -7,7 +7,7 @@ | |||
| </view> | |||
| <view class="buyNum"> | |||
| <view class="circleLeft"></view> | |||
| <view class="ticketName">{{ticketUser.coupon_type}}</view> | |||
| <view class="ticketName">{{ticketUser.coupon_name}}{{ticketUser.type_name}}</view> | |||
| <view class="line"></view> | |||
| <view class="lineRig"> | |||
| <text class="bigWord">{{ticketUser.num}}</text> | |||
| @@ -27,6 +27,8 @@ Page({ | |||
| } else { | |||
| app.globalData.openidSuccessFuc = this.getTicketUser; | |||
| } | |||
| }, | |||
| getTicketUser:function(){//获取优惠券信息 | |||
| @@ -87,7 +89,6 @@ Page({ | |||
| onShareAppMessage: function () { | |||
| return { | |||
| title: "老门框爆肚会员", | |||
| path: "/pages/register/register", | |||
| success: res => { | |||
| console.log(res, "转发成功") | |||
| }, | |||
| @@ -181,7 +182,7 @@ Page({ | |||
| wx.showToast({ | |||
| title: e.message, | |||
| icon:"none", | |||
| duration:500 | |||
| duration:2000 | |||
| }) | |||
| } | |||
| }, this,"POST") | |||
| @@ -190,7 +191,7 @@ Page({ | |||
| app.wxRequest(app.globalData.httpUrl + 'order/paid', { sign_num: this.data.sign_num}, e => { | |||
| console.log(e) | |||
| if (e.code == 200) { | |||
| wx.reLaunch({ | |||
| wx.switchTab({ | |||
| url: '/pages/personalCenter/personalCenter' | |||
| }) | |||
| } | |||
| @@ -7,7 +7,7 @@ | |||
| </view> | |||
| <view class="buyNum"> | |||
| <view class="circleLeft"></view> | |||
| <view class="ticketName">{{ticketUser.coupon_type}}</view> | |||
| <view class="ticketName">{{ticketUser.coupon_name}}{{ticketUser.type_name}}</view> | |||
| <view class="line"></view> | |||
| <view class="chooseNum"> | |||
| <view bindtap="subtractFn" class="subtractView"> | |||
| @@ -68,7 +68,7 @@ page{ | |||
| background: #ffffff; | |||
| } | |||
| .ticketName{ | |||
| font-size:36rpx; | |||
| font-size:30rpx; | |||
| font-family:SourceHanSansCN; | |||
| font-weight:bold; | |||
| color:rgba(51,51,51,1); | |||
| @@ -30,6 +30,8 @@ Page({ | |||
| } else { | |||
| app.globalData.openidSuccessFuc = this.getTicketUser; | |||
| } | |||
| }, | |||
| getTicketUser: function () {//获取优惠券信息 | |||
| app.wxRequest(app.globalData.httpUrl + 'couponsell/detail', { coupon_sell_id: this.data.sellId, from: 2 }, e => { | |||
| @@ -141,10 +143,10 @@ Page({ | |||
| var shareImg = "";//分享图 | |||
| if (options.from === "button"){ | |||
| shareUrl = '/pages/receiveTicket/receiveTicket?shareId=' + this.data.shareId + "&number=" + this.data.buyNumber | |||
| titleWord = "赠送给好友" | |||
| shareImg = this.data.ticketUser.coupon_img_small; | |||
| titleWord = "您的好友分享给您一张老门框爆肚涮肉的代金券,请您查收" | |||
| shareImg = "../images/shareImg.png"; | |||
| }else{ | |||
| shareUrl = "/pages/register/register"; | |||
| shareUrl = ""; | |||
| titleWord = "老门框爆肚会员" | |||
| shareImg = ""; | |||
| } | |||
| @@ -7,7 +7,7 @@ | |||
| </view> | |||
| <view class="buyNum"> | |||
| <view class="circleLeft"></view> | |||
| <view class="ticketName">{{ticketUser.coupon_type}}</view> | |||
| <view class="ticketName">{{ticketUser.coupon_name}}{{ticketUser.type_name}}</view> | |||
| <view class="line"></view> | |||
| <view class="lineRig"> | |||
| <text class="surplus">剩余</text> | |||
| @@ -14,6 +14,8 @@ Page({ | |||
| }else{ | |||
| app.globalData.openidSuccessFuc = this.getDataList; | |||
| } | |||
| }, | |||
| getDataList:function(){ | |||
| app.wxRequest(app.globalData.httpUrl + 'couponsell/list', {}, e => { | |||
| @@ -48,7 +50,6 @@ Page({ | |||
| onShareAppMessage: function () { | |||
| return { | |||
| title: "老门框爆肚会员", | |||
| path: "/pages/register/register", | |||
| success: res => { | |||
| console.log(res, "转发成功") | |||
| }, | |||
| @@ -58,7 +58,7 @@ page{ | |||
| display: block; | |||
| } | |||
| .nameText{ | |||
| font-size:60rpx; | |||
| font-size:50rpx; | |||
| font-family:DINPro; | |||
| font-weight:bold; | |||
| color:rgba(106,10,14,1); | |||
| @@ -7,13 +7,13 @@ Page({ | |||
| * 页面的初始数据 | |||
| */ | |||
| data: { | |||
| myTicketArrows: false, | |||
| myTicketArrows: true, | |||
| historyTicketArrows: false, | |||
| getUser:false, | |||
| getUserArr: [],//用户信息 | |||
| userChuan:[], | |||
| userPhone:"",//用户手机号 | |||
| mydeg: -90, | |||
| mydeg: 0, | |||
| historydeg: -90, | |||
| pageNum:1, | |||
| pageCount:5, | |||
| @@ -23,6 +23,8 @@ Page({ | |||
| myTicketArr: [],//我的优惠券列表 | |||
| headerImg:"../images/headerImg.png",//默认头像 | |||
| userName:"",//昵称 | |||
| noUser:false, | |||
| topNum:0, | |||
| }, | |||
| /** | |||
| @@ -31,7 +33,6 @@ Page({ | |||
| onLoad: function (options) { | |||
| }, | |||
| getToRsgisterFn:function(){//未注册点击跳到注册页 | |||
| wx.navigateTo({ | |||
| @@ -61,6 +62,7 @@ Page({ | |||
| historyArr: this.data.getHistoryArr, | |||
| }) | |||
| } | |||
| console.log(this.data.getHistoryArr) | |||
| }, this) | |||
| }, | |||
| lower:function(){//检测上拉是否到底 | |||
| @@ -87,59 +89,93 @@ Page({ | |||
| * 生命周期函数--监听页面显示 | |||
| */ | |||
| onShow: function () { | |||
| this.setData({ | |||
| topNum:0 | |||
| }) | |||
| this.data.pageNum = 1; | |||
| this.data.getHistoryArr = []; | |||
| if (app.globalData.openId) { | |||
| this.myTicket(); | |||
| this.historyTicket(); | |||
| } else { | |||
| app.globalData.openidSuccessFuc = this.myTicket; | |||
| app.globalData.openidSuccessFuc = this.historyTicket; | |||
| } | |||
| 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 | |||
| }) | |||
| if (!userInfo.avatarUrl){ | |||
| this.setData({ | |||
| headerImg: "../images/headerImg.png", | |||
| userName: userInfo.nickName, | |||
| userPhone: phone, | |||
| getUser: true | |||
| }) | |||
| }else{ | |||
| this.setData({ | |||
| headerImg: userInfo.avatarUrl, | |||
| userName: userInfo.nickName, | |||
| userPhone: phone, | |||
| getUser: true | |||
| }) | |||
| } | |||
| console.log(wx.getStorageSync('noUser')) | |||
| if (wx.getStorageSync('noUser')==0) { | |||
| this.setData({ | |||
| noUser: true | |||
| }) | |||
| } else if (wx.getStorageSync('noUser') == 1) { | |||
| this.setData({ | |||
| noUser: false | |||
| }) | |||
| } | |||
| } else if (state == 0) {//未注册 | |||
| console.log(app.globalData.noUser) | |||
| this.setData({ | |||
| getUser: false | |||
| getUser: false, | |||
| noUser: 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 | |||
| }) | |||
| if (!userInfo.avatarUrl) { | |||
| this.setData({ | |||
| headerImg: "../images/headerImg.png", | |||
| userName: userInfo.nickName, | |||
| userPhone: phone, | |||
| getUser: true | |||
| }) | |||
| } else { | |||
| this.setData({ | |||
| headerImg: userInfo.avatarUrl, | |||
| userName: userInfo.nickName, | |||
| userPhone: phone, | |||
| getUser: true | |||
| }) | |||
| } | |||
| if (wx.getStorageSync('noUser') == 0) { | |||
| this.setData({ | |||
| noUser: true | |||
| }) | |||
| } else if (wx.getStorageSync('noUser') == 1) { | |||
| this.setData({ | |||
| noUser: false | |||
| }) | |||
| } | |||
| } else { | |||
| this.setData({ | |||
| getUser: false | |||
| getUser: false, | |||
| noUser: false | |||
| }) | |||
| } | |||
| } | |||
| } | |||
| } | |||
| }, | |||
| /** | |||
| @@ -176,7 +212,6 @@ Page({ | |||
| onShareAppMessage: function () { | |||
| return { | |||
| title: "老门框爆肚会员", | |||
| path: "/pages/register/register", | |||
| success: res => { | |||
| console.log(res, "转发成功") | |||
| }, | |||
| @@ -223,24 +258,38 @@ 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({ | |||
| // headerImg: userArr, | |||
| // getUser: true, | |||
| // userPhone: phone | |||
| // }) | |||
| // this.submitUser(); | |||
| // console.log(this.data.getUserArr) | |||
| // }, | |||
| getUser:function(e){//点击登陆获取用户信息 | |||
| console.log(e) | |||
| if (e.detail.userInfo) { | |||
| this.data.userChuan = e.detail.userInfo; | |||
| wx.setStorageSync('noUser', 1); | |||
| wx.setStorageSync("userInfo", e.detail.userInfo) | |||
| this.setData({ | |||
| headerImg: e.detail.userInfo.avatarUrl, | |||
| userName: e.detail.userInfo.nickName, | |||
| getUser: true, | |||
| noUser: false | |||
| }) | |||
| this.submitUser(); | |||
| } | |||
| }, | |||
| submitUser: function () {//提交用户信息 | |||
| if (this.data.userChuan) { | |||
| 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") | |||
| } | |||
| }, | |||
| }) | |||
| @@ -4,11 +4,16 @@ | |||
| <view class="userMess"> | |||
| <image class="userCircle" src="../images/userCircle.png"></image> | |||
| <view class="userAll"> | |||
| <view class="userHeader"> | |||
| <view wx:if="{{!noUser}}" class="userHeader" bindtap="getToRsgisterFn"> | |||
| <image class="userImg" src="{{headerImg}}"></image> | |||
| </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> | |||
| <button wx:if="{{noUser}}" class="userHeaderBtn" open-type="getUserInfo" bindgetuserinfo="getUser"> | |||
| <image class="userImg" src="{{headerImg}}"></image> | |||
| </button> | |||
| <button wx:if="{{noUser}}" class="noUserBtn" open-type="getUserInfo" bindgetuserinfo="getUser"> | |||
| <image class="getHeader" src="../images/getHeader.png"></image> | |||
| </button> | |||
| <image wx:if="{{!getUser}}" bindtap="getToRsgisterFn" class="getToRsgister" src="../images/getHeader.png"></image> | |||
| <view wx:if="{{getUser}}" class="userName">{{userName}}</view> | |||
| <view wx:if="{{getUser}}" class="userPhone">{{userPhone}}</view> | |||
| </view> | |||
| @@ -48,13 +53,13 @@ | |||
| <image class="ticketArrows" src="../images/ticketArrows.png" style="transform:rotate({{historydeg}}deg)"></image> | |||
| </view> | |||
| <scroll-view class="scrollY2" scroll-y="true" wx:if="{{historyTicketArrows}}" bindscrolltolower="lower"> | |||
| <scroll-view class="scrollY2" scroll-y="true" scroll-top='{{topNum}}' wx:if="{{historyTicketArrows}}" bindscrolltolower="lower"> | |||
| <view class="history" wx:for="{{historyArr}}"> | |||
| <view class="historyLeft"> | |||
| <!-- <image class="historyTicketBg" src="../images/historyTicketBg.png"></image> --> | |||
| <view class="ticketCode">{{item.coupon_code}}</view> | |||
| </view> | |||
| <view class="tickName">{{item.coupon_type}}</view> | |||
| <view class="tickName">{{item.coupon_name}}{{item.type_name}}</view> | |||
| <view class="tickType">已使用</view> | |||
| </view> | |||
| </scroll-view> | |||
| @@ -1,6 +1,7 @@ | |||
| /* pages/personalCenter/personalCenter.wxss */ | |||
| page{ | |||
| height: 100%; | |||
| width: 100%; | |||
| } | |||
| .all{ | |||
| height: 100%; | |||
| @@ -29,6 +30,29 @@ page{ | |||
| overflow: hidden; | |||
| border-radius: 50%; | |||
| } | |||
| .userHeaderBtn{ | |||
| width: 200rpx; | |||
| height: 200rpx; | |||
| overflow: hidden; | |||
| border-radius: 50%; | |||
| margin: 0; | |||
| padding: 0; | |||
| background-color: transparent; | |||
| } | |||
| .noUserBtn{ | |||
| margin-top: 20rpx; | |||
| width: 230rpx; | |||
| height: 64rpx; | |||
| border: none; | |||
| border-color: transparent; | |||
| border-radius: 0; | |||
| padding: 0; | |||
| background-color: transparent; | |||
| } | |||
| .noUserBtn::after{ | |||
| border: none | |||
| } | |||
| .userImg{ | |||
| width: 200rpx; | |||
| height: 200rpx; | |||
| @@ -173,7 +197,7 @@ page{ | |||
| display: none; | |||
| } | |||
| .tickName{ | |||
| font-size:24rpx; | |||
| font-size:20rpx; | |||
| color:rgba(102,102,102,1); | |||
| margin-left: 75rpx; | |||
| } | |||
| @@ -195,7 +219,11 @@ page{ | |||
| } | |||
| .getToRsgister{ | |||
| width: 318rpx; | |||
| height: 38rpx; | |||
| width: 230rpx; | |||
| height: 64rpx; | |||
| margin-top: 20rpx; | |||
| } | |||
| .getHeader{ | |||
| width: 230rpx; | |||
| height: 64rpx; | |||
| } | |||
| @@ -154,7 +154,6 @@ Page({ | |||
| onShareAppMessage: function () { | |||
| return { | |||
| title: "老门框爆肚会员", | |||
| path: "/pages/register/register", | |||
| success: res => { | |||
| console.log(res, "转发成功") | |||
| }, | |||
| @@ -183,7 +182,8 @@ Page({ | |||
| this.data.moreClick = false; | |||
| wx.showToast({ | |||
| title: e.message, | |||
| duration: 500 | |||
| icon:"none", | |||
| duration: 1000 | |||
| }) | |||
| } | |||
| }, this, "POST") | |||
| @@ -10,7 +10,7 @@ | |||
| <text class="textNum">{{ticketNum}}</text> | |||
| <text class="text">张</text> | |||
| </view> | |||
| <view class="ticketType">{{ticketUser.coupon_type}}</view> | |||
| <view class="ticketType">{{ticketUser.coupon_name}}{{ticketUser.type_name}}</view> | |||
| <view class="line"></view> | |||
| </view> | |||
| <view class="contBot"> | |||
| @@ -90,7 +90,7 @@ page{ | |||
| display: block; | |||
| } | |||
| .nameText{ | |||
| font-size:60rpx; | |||
| font-size:50rpx; | |||
| font-family:DINPro; | |||
| font-weight:bold; | |||
| color:rgba(106,10,14,1); | |||
| @@ -74,7 +74,6 @@ Page({ | |||
| onShareAppMessage: function () { | |||
| return { | |||
| title: "老门框爆肚会员", | |||
| path: "/pages/register/register", | |||
| success: res => { | |||
| console.log(res, "转发成功") | |||
| }, | |||
| @@ -154,7 +153,7 @@ Page({ | |||
| console.log(this.data.minter) | |||
| }, | |||
| submitUser: function () {//提交用户信息 | |||
| if(this.data.userInfo && this.data.userInfo.province){ | |||
| if(this.data.userInfo){ | |||
| var params = { | |||
| "province": this.data.userInfo.province, | |||
| "language": this.data.userInfo.language, | |||
| @@ -174,9 +173,12 @@ Page({ | |||
| }, | |||
| getUserFn:function(e){//点击按钮注册 | |||
| console.log(e) | |||
| this.data.userInfo = e.detail.userInfo; | |||
| if(e.detail.userInfo){ | |||
| if (e.detail.userInfo) { | |||
| this.data.userInfo = e.detail.userInfo; | |||
| wx.setStorageSync('noUser', 1); | |||
| app.globalData.userInfo = e.detail.userInfo | |||
| } else { | |||
| wx.setStorageSync('noUser', 0); | |||
| } | |||
| this.registerFn(); | |||
| // if (app.globalData.openId) { | |||
| @@ -186,9 +188,7 @@ Page({ | |||
| // } | |||
| }, | |||
| registerFn:function(){//注册接口 | |||
| if (this.data.yesRegister){ | |||
| return; | |||
| } | |||
| if(this.data.phone){ | |||
| if (!(/^1[3456789]\d{9}$/.test(this.data.phone))) { | |||
| wx.showToast({ | |||
| @@ -214,9 +214,12 @@ Page({ | |||
| }) | |||
| return; | |||
| } | |||
| if (this.data.yesRegister) { | |||
| return; | |||
| } | |||
| this.data.yesRegister = true; | |||
| app.wxRequest(app.globalData.httpUrl + 'register', { user_phone: this.data.phone, code_num: this.data.phoneCode }, e => { | |||
| console.log(e) | |||
| this.data.yesRegister = true; | |||
| if (e.code == 200) { | |||
| clearInterval(time); | |||
| wx.setStorageSync('user_phone', e.data.user_phone); | |||
| @@ -20,6 +20,8 @@ Page({ | |||
| dataArr: [],//搜索的数据列表 | |||
| getDataArr:[],//每次下拉获取的数据 | |||
| topNum:0,//滚动条位置 | |||
| latitude: 0, | |||
| longitude: 0, | |||
| }, | |||
| bindchange:function(e){ | |||
| this.data.pageNum = 1; | |||
| @@ -50,7 +52,6 @@ Page({ | |||
| provinceIndex: value, | |||
| cityIndex:0, | |||
| }) | |||
| console.log(this.data.changeCity) | |||
| }else{ | |||
| this.setData({ | |||
| index: value, | |||
| @@ -66,13 +67,18 @@ Page({ | |||
| */ | |||
| onLoad: function (options) { | |||
| console.log(options) | |||
| this.data.latitude = wx.getStorageSync('latitude'); | |||
| this.data.longitude = wx.getStorageSync('longitude'); | |||
| if (app.globalData.openId) { | |||
| this.getShopList(); | |||
| } else { | |||
| app.globalData.openidSuccessFuc = this.getShopList; | |||
| // app.globalData.openidSuccessFuc = this.searchShop; | |||
| } | |||
| if (!wx.getStorageSync('latitude')) { | |||
| this.getNowAddress(); | |||
| } | |||
| var hig = wx.getSystemInfoSync().windowHeight; | |||
| this.setData({ | |||
| scrollHig: hig-70 | |||
| @@ -105,6 +111,9 @@ Page({ | |||
| }) | |||
| this.searchShop(); | |||
| // console.log(this.data.provinceArr) | |||
| // console.log(this.data.cityArr) | |||
| // console.log(this.data.provinceCityArr) | |||
| } | |||
| }, this) | |||
| }, | |||
| @@ -120,14 +129,23 @@ Page({ | |||
| } | |||
| province = this.data.provinceCityArr[0][this.data.provinceIndex]; | |||
| city = this.data.provinceCityArr[1][this.data.cityIndex]; | |||
| var locationIndex; | |||
| if (this.data.longitude){ | |||
| locationIndex = 2 | |||
| }else{ | |||
| locationIndex = 1 | |||
| } | |||
| var params = { | |||
| "shop_province": province, | |||
| "shop_city": city, | |||
| "key": this.data.inputVal, | |||
| "cur_page": this.data.pageNum, | |||
| "show_num":this.data.count, | |||
| "location": locationIndex, | |||
| "lng": this.data.longitude, | |||
| "lat": this.data.latitude, | |||
| } | |||
| app.wxRequest(app.globalData.httpUrl + 'shop/search', params, e => { | |||
| app.wxRequest(app.globalData.httpUrl + 'shop/shopsearch', params, e => { | |||
| console.log(e) | |||
| if (e.code == 200) { | |||
| for (var i = 0; i < e.data.length;i++){ | |||
| @@ -208,7 +226,6 @@ Page({ | |||
| onShareAppMessage: function () { | |||
| return { | |||
| title: "老门框爆肚会员", | |||
| path: "/pages/register/register", | |||
| success: res => { | |||
| console.log(res, "转发成功") | |||
| }, | |||
| @@ -248,7 +265,8 @@ Page({ | |||
| this.setData({ | |||
| inputVal:"" | |||
| }) | |||
| // this.data.provinceCityArr[0][this.data.provinceIndex] = ""; | |||
| // this.data.provinceCityArr[1][this.data.cityIndex] = ""; | |||
| this.data.pageNum = 1; | |||
| this.data.dataArr = []; | |||
| this.searchShop(); | |||
| @@ -267,5 +285,22 @@ Page({ | |||
| scale: 18, | |||
| name: addressName | |||
| }) | |||
| } | |||
| }, | |||
| getNowAddress: function () {//获取当前城市经纬度 | |||
| wx.getLocation({ | |||
| type: 'wgs84', | |||
| success: res => { | |||
| console.log(res) | |||
| wx.setStorageSync('latitude', res.latitude); | |||
| wx.setStorageSync('longitude', res.longitude); | |||
| this.data.latitude = wx.getStorageSync('latitude'); | |||
| this.data.longitude = wx.getStorageSync('longitude'); | |||
| this.data.dataArr=[]; | |||
| if (this.data.provinceCityArr[0] && this.data.provinceCityArr[1]){ | |||
| this.searchShop(); | |||
| } | |||
| } | |||
| }) | |||
| }, | |||
| }) | |||