| @@ -12,7 +12,7 @@ App({ | |||
| wx.login({ | |||
| success: res => { | |||
| // 发送 res.code 到后台换取 openId, sessionKey, unionId | |||
| console.log(res) | |||
| // console.log(res) | |||
| if (res.code){ | |||
| wx.request({ | |||
| url: this.globalData.httpUrl+'openid', | |||
| @@ -20,7 +20,7 @@ App({ | |||
| code: res.code | |||
| }, | |||
| success: e => { | |||
| console.log(e) | |||
| // console.log(e) | |||
| if (e.data.code == 200) { | |||
| this.globalData.openId = e.data.data.openid; | |||
| this.globalData.session_key = e.data.data.session_key; | |||
| @@ -40,7 +40,7 @@ App({ | |||
| }else{ | |||
| this.globalData.openid = openid; | |||
| } | |||
| this.getUserType(); | |||
| // this.getUserType(); | |||
| // 获取用户信息 | |||
| // wx.getSetting({ | |||
| // success: res => { | |||
| @@ -76,7 +76,7 @@ App({ | |||
| getUserType:function(){//获取用户注册状态 | |||
| this.wxRequest(this.globalData.httpUrl + 'getinfo',{},e=>{ | |||
| console.log(e) | |||
| // console.log(e) | |||
| if(e.code==201){//未注册跳到注册页面 | |||
| wx.reLaunch({ | |||
| url: '/pages/register/register' | |||
| @@ -98,7 +98,7 @@ App({ | |||
| }, | |||
| wxRequest: function (url, params, callback, thisArg, methods, openid) { | |||
| let that = this; | |||
| console.log(this.globalData.openid) | |||
| // console.log(this.globalData.openid) | |||
| var httpUrl = url; | |||
| var str = ""; | |||
| var count = 0; | |||
| @@ -1,41 +1,26 @@ | |||
| // pages/TicketDetails/TicketDetails.js | |||
| const app = getApp() | |||
| Page({ | |||
| /** | |||
| * 页面的初始数据 | |||
| */ | |||
| data: { | |||
| dataArr: [ | |||
| { | |||
| "code":"11111", | |||
| "name":"80元抵100元优惠券", | |||
| "type":"未使用" | |||
| }, | |||
| { | |||
| "code": "11111", | |||
| "name": "80元抵100元优惠券", | |||
| "type": "未使用" | |||
| }, | |||
| { | |||
| "code": "11111", | |||
| "name": "80元抵100元优惠券", | |||
| "type": "未使用" | |||
| }, | |||
| { | |||
| "code": "11111", | |||
| "name": "80元抵100元优惠券", | |||
| "type": "未使用" | |||
| }, | |||
| ], | |||
| ticketUser: [],//优惠券信息 | |||
| }, | |||
| /** | |||
| * 生命周期函数--监听页面加载 | |||
| */ | |||
| onLoad: function (options) { | |||
| var dataArr = JSON.parse(options.dataArr); | |||
| console.log(dataArr) | |||
| this.setData({ | |||
| ticketUser: dataArr | |||
| }) | |||
| }, | |||
| /** | |||
| * 生命周期函数--监听页面初次渲染完成 | |||
| */ | |||
| @@ -2,14 +2,14 @@ | |||
| <view class="all"> | |||
| <view class="contTop"> | |||
| <view class="imgView"> | |||
| <image mode="aspectFill" class="ticketImg" src="../images/bigTicket.jpg"></image> | |||
| <image mode="aspectFill" class="ticketImg" src="{{ticketUser.coupon_img_large}}"></image> | |||
| <image class="tooth" src="../images/tooth.png"></image> | |||
| </view> | |||
| <view class="buyNum"> | |||
| <view class="ticketName">80元抵100元优惠券</view> | |||
| <view class="ticketName">{{ticketUser.coupon_type}}</view> | |||
| <view class="line"></view> | |||
| <view class="lineRig"> | |||
| <text class="bigWord">50</text> | |||
| <text class="bigWord">{{ticketUser.num}}</text> | |||
| <text class="smaWord">张</text> | |||
| </view> | |||
| </view> | |||
| @@ -22,32 +22,32 @@ | |||
| <image src="../images/circle.png"></image> | |||
| <text>使用期限</text> | |||
| </view> | |||
| <view class="specify">购卖后30日内有效</view> | |||
| <view class="specify">{{ticketUser.coupon_deadline_desc}}</view> | |||
| </view> | |||
| <view> | |||
| <view class="timeLimit"> | |||
| <image src="../images/circle.png"></image> | |||
| <text>使用条件</text> | |||
| </view> | |||
| <view class="specify">点单金额需商于优惠金额,每单限使用一张不可叠加使用,不与其他优惠同享</view> | |||
| <view class="specify">{{ticketUser.coupon_condition_desc}}</view> | |||
| </view> | |||
| <view> | |||
| <view class="timeLimit"> | |||
| <image src="../images/circle.png"></image> | |||
| <text>适用门店</text> | |||
| </view> | |||
| <view class="specify">老门框所有门店</view> | |||
| <view class="specify">{{ticketUser.coupon_allow_shop}}</view> | |||
| </view> | |||
| </view> | |||
| <scroll-view class="scrollY" scroll-y="true"> | |||
| <view class="history" wx:for="{{dataArr}}"> | |||
| <!-- <scroll-view class="scrollY" scroll-y="true"> --> | |||
| <view class="history"> | |||
| <view class="historyLeft"> | |||
| <image class="historyTicketBg" src="../images/historyTicketBg.png"></image> | |||
| <view class="ticketCode">券码:{{item.code}}</view> | |||
| <view class="ticketCode">券码:{{ticketUser.coupon_sell_id}}</view> | |||
| </view> | |||
| <view class="tickName">{{item.name}}</view> | |||
| <view class="tickType">{{item.type}}</view> | |||
| <view class="tickName">{{ticketUser.coupon_type}}</view> | |||
| <view class="tickType">未使用</view> | |||
| </view> | |||
| </scroll-view> | |||
| <!-- </scroll-view> --> | |||
| </view> | |||
| @@ -88,10 +88,10 @@ | |||
| margin-left: 69rpx; | |||
| } | |||
| .scrollY{ | |||
| /* .scrollY{ | |||
| height: 300rpx; | |||
| margin-top: 107rpx; | |||
| } | |||
| } */ | |||
| .historyIcon{ | |||
| width: 30rpx; | |||
| @@ -101,7 +101,7 @@ | |||
| display: flex; | |||
| justify-content: space-between; | |||
| align-items: center; | |||
| margin-top: 20rpx; | |||
| margin-top: 107rpx; | |||
| padding: 0 50rpx; | |||
| } | |||
| .historyLeft{ | |||
| @@ -1,12 +1,17 @@ | |||
| // pages/buyTicket/buyTicket.js | |||
| const app = getApp() | |||
| Page({ | |||
| /** | |||
| * 页面的初始数据 | |||
| */ | |||
| data: { | |||
| buyNumber:1, | |||
| buyNumber:1,//购买数量 | |||
| num : 1, | |||
| ticketUser: [],//优惠券信息 | |||
| orderUser:[],//下单信息 | |||
| sign_num:"",//确认支付参数 | |||
| }, | |||
| /** | |||
| @@ -14,8 +19,19 @@ Page({ | |||
| */ | |||
| onLoad: function (options) { | |||
| console.log(options) | |||
| this.getTicketUser(options.index) | |||
| }, | |||
| getTicketUser:function(index){//获取优惠券信息 | |||
| app.wxRequest(app.globalData.httpUrl + 'couponsell/detail/' + index, {}, e => { | |||
| console.log(e) | |||
| if (e.code == 200) { | |||
| this.setData({ | |||
| ticketUser:e.data | |||
| }) | |||
| } | |||
| }, this) | |||
| }, | |||
| /** | |||
| * 生命周期函数--监听页面初次渲染完成 | |||
| */ | |||
| @@ -80,16 +96,36 @@ Page({ | |||
| }) | |||
| } | |||
| }, | |||
| buySuccess:function(){ | |||
| wx.requestPayment({ | |||
| success:res=>{ | |||
| console.log(res) | |||
| // wx.switchTab({ | |||
| // url: '../index/index' | |||
| // }) | |||
| }, | |||
| }) | |||
| } | |||
| buySuccess:function(){//购买下单 | |||
| app.wxRequest(app.globalData.httpUrl + 'order/set', { coupon_sell_id: this.data.ticketUser.coupon_sell_id, buy_num: this.data.buyNumber}, e => { | |||
| console.log(e) | |||
| if (e.code == 200) { | |||
| this.setData({ | |||
| orderUser: e.data.submit, | |||
| sign_num: e.data.sign_num | |||
| }) | |||
| wx.requestPayment({ | |||
| timeStamp: this.data.orderUser.timeStamp, | |||
| nonceStr: this.data.orderUser.nonceStr, | |||
| package: this.data.orderUser.package, | |||
| signType: this.data.orderUser.signType, | |||
| paySign: this.data.orderUser.paySign, | |||
| success: res => { | |||
| console.log(res) | |||
| this.orderPay() | |||
| }, | |||
| }) | |||
| } | |||
| }, this,"POST") | |||
| }, | |||
| orderPay:function(){ | |||
| app.wxRequest(app.globalData.httpUrl + 'order/paid', { sign_num: this.data.sign_num}, e => { | |||
| console.log(e) | |||
| if (e.code == 200) { | |||
| wx.switchTab({ | |||
| url: '../buyTicket/buyTicket' | |||
| }) | |||
| } | |||
| }, this,"POST") | |||
| }, | |||
| }) | |||
| @@ -2,11 +2,11 @@ | |||
| <view class="all"> | |||
| <view class="contTop"> | |||
| <view class="imgView"> | |||
| <image mode="aspectFill" class="ticketImg" src="../images/bigTicket.jpg"></image> | |||
| <image mode="aspectFill" class="ticketImg" src="{{ticketUser.coupon_img_large}}"></image> | |||
| <image class="tooth" src="../images/tooth.png"></image> | |||
| </view> | |||
| <view class="buyNum"> | |||
| <view class="ticketName">80元抵100元优惠券</view> | |||
| <view class="ticketName">{{ticketUser.coupon_type}}</view> | |||
| <view class="line"></view> | |||
| <view class="chooseNum"> | |||
| <view bindtap="subtractFn" class="subtractView"> | |||
| @@ -6,14 +6,19 @@ Page({ | |||
| */ | |||
| data: { | |||
| buyNumber: 1, | |||
| num: 1, | |||
| ticketNum: 1, | |||
| ticketUser: [],//优惠券信息 | |||
| }, | |||
| /** | |||
| * 生命周期函数--监听页面加载 | |||
| */ | |||
| onLoad: function (options) { | |||
| var dataArr = JSON.parse(options.dataArr); | |||
| console.log(dataArr) | |||
| this.setData({ | |||
| ticketUser: dataArr | |||
| }) | |||
| }, | |||
| /** | |||
| @@ -65,18 +70,18 @@ Page({ | |||
| }, | |||
| addFn: function () { | |||
| if (this.data.num < 5) { | |||
| this.data.num++; | |||
| if (this.data.ticketNum < this.data.ticketUser.num) { | |||
| this.data.ticketNum++; | |||
| this.setData({ | |||
| buyNumber: this.data.num | |||
| buyNumber: this.data.ticketNum | |||
| }) | |||
| } | |||
| }, | |||
| subtractFn: function () { | |||
| if (this.data.num > 1) { | |||
| this.data.num--; | |||
| if (this.data.ticketNum > 1) { | |||
| this.data.ticketNum--; | |||
| this.setData({ | |||
| buyNumber: this.data.num | |||
| buyNumber: this.data.ticketNum | |||
| }) | |||
| } | |||
| }, | |||
| @@ -2,15 +2,15 @@ | |||
| <view class="all"> | |||
| <view class="contTop"> | |||
| <view class="imgView"> | |||
| <image mode="aspectFill" class="ticketImg" src="../images/bigTicket.jpg"></image> | |||
| <image mode="aspectFill" class="ticketImg" src="{{ticketUser.coupon_img_large}}"></image> | |||
| <image class="tooth" src="../images/tooth.png"></image> | |||
| </view> | |||
| <view class="buyNum"> | |||
| <view class="ticketName">80元抵100元优惠券</view> | |||
| <view class="ticketName">{{ticketUser.coupon_type}}</view> | |||
| <view class="line"></view> | |||
| <view class="lineRig"> | |||
| <text class="surplus">剩余</text> | |||
| <text class="bigWord">50</text> | |||
| <text class="bigWord">{{ticketUser.num}}</text> | |||
| <text class="smaWord">张</text> | |||
| </view> | |||
| </view> | |||
| @@ -4,28 +4,28 @@ const app = getApp() | |||
| Page({ | |||
| data: { | |||
| content: ["../images/smallTicket.jpg", "../images/smallTicket.jpg", "../images/smallTicket.jpg"], | |||
| allData:[ | |||
| ] | |||
| dataList:[], | |||
| }, | |||
| //事件处理函数 | |||
| onLoad: function () { | |||
| this.getDataList(); | |||
| }, | |||
| 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 | |||
| }) | |||
| } | |||
| }, this) | |||
| }, | |||
| skipPage:function(){ | |||
| var arr = {"name":"小明","age":20}; | |||
| var option = JSON.stringify(arr); | |||
| skipPage:function(e){ | |||
| // console.log(e) | |||
| var index = e.currentTarget.dataset.index | |||
| wx.navigateTo({ | |||
| url: '../buyTicket/buyTicket?option=' + option | |||
| url: '../buyTicket/buyTicket?index=' + index | |||
| }) | |||
| } | |||
| }, | |||
| }) | |||
| @@ -14,16 +14,16 @@ | |||
| <image class="buyBg" src="../images/buyBg.jpg"></image> | |||
| <swiper duration="500" next-margin="70rpx"> | |||
| <block wx:for="{{content}}" wx:key="*this"> | |||
| <swiper-item bindtap="skipPage"> | |||
| <block wx:for="{{dataList}}" wx:key="*this"> | |||
| <swiper-item data-index="{{item.coupon_sell_id}}" bindtap="skipPage"> | |||
| <view class="botCont"> | |||
| <view class="imgView"> | |||
| <image src="{{item}}"></image> | |||
| <image src="{{item.coupon_img_small}}"></image> | |||
| </view> | |||
| <view class="textView"> | |||
| <text class="nameText">80抵100</text> | |||
| <text class="timeText">优惠券每次限用一张,不可叠加</text> | |||
| <text class="timeText">(有效期:2020.2.18-2020.12.31)</text> | |||
| <text class="nameText">{{item.coupon_name}}</text> | |||
| <text class="timeText">{{item.coupon_memo}}</text> | |||
| <text class="timeText">(有效期:{{item.end_date}})</text> | |||
| </view> | |||
| <view class="buyView">立即购买</view> | |||
| </view> | |||
| @@ -1,4 +1,6 @@ | |||
| // pages/personalCenter/personalCenter.js | |||
| const app = getApp() | |||
| Page({ | |||
| /** | |||
| @@ -8,66 +10,40 @@ Page({ | |||
| myTicketArrows: false, | |||
| historyTicketArrows: false, | |||
| getUser:false, | |||
| getUserArr:[], | |||
| getUserArr: [],//用户信息 | |||
| mydeg: -90, | |||
| historydeg: -90, | |||
| historyArr: [ | |||
| { | |||
| "code": "11111", | |||
| "name": "80元抵100元优惠券", | |||
| "type": "未使用" | |||
| }, | |||
| { | |||
| "code": "11111", | |||
| "name": "80元抵100元优惠券", | |||
| "type": "未使用" | |||
| }, | |||
| { | |||
| "code": "11111", | |||
| "name": "80元抵100元优惠券", | |||
| "type": "未使用" | |||
| }, | |||
| { | |||
| "code": "11111", | |||
| "name": "80元抵100元优惠券", | |||
| "type": "未使用" | |||
| }, | |||
| ], | |||
| myTicketArr: [ | |||
| { | |||
| "image": "../images/ticketImg.jpg", | |||
| "name": "80抵100", | |||
| "time": "2020.2.18-2020.12.31" | |||
| }, | |||
| { | |||
| "image": "../images/ticketImg.jpg", | |||
| "name": "80抵100", | |||
| "time": "2020.2.18-2020.12.31" | |||
| }, | |||
| { | |||
| "image": "../images/ticketImg.jpg", | |||
| "name": "80抵100", | |||
| "time": "2020.2.18-2020.12.31" | |||
| }, | |||
| { | |||
| "image": "../images/ticketImg.jpg", | |||
| "name": "80抵100", | |||
| "time": "2020.2.18-2020.12.31" | |||
| }, | |||
| ], | |||
| historyArr: [],//优惠券使用记录列表 | |||
| myTicketArr: [],//我的优惠券列表 | |||
| }, | |||
| /** | |||
| * 生命周期函数--监听页面加载 | |||
| */ | |||
| onLoad: function (options) { | |||
| // wx.getUserInfo({ | |||
| // success: function (res) { | |||
| // console.log(res) | |||
| // } | |||
| // }) | |||
| this.myTicket(); | |||
| this.historyTicket(); | |||
| }, | |||
| myTicket:function(){//获取我的优惠券列表 | |||
| app.wxRequest(app.globalData.httpUrl + 'couponbuy/buytype', {}, e => { | |||
| console.log(e) | |||
| if (e.code == 200) { | |||
| this.setData({ | |||
| myTicketArr: e.data | |||
| }) | |||
| } | |||
| }, this) | |||
| }, | |||
| historyTicket: function () {//获取优惠券使用列表 | |||
| app.wxRequest(app.globalData.httpUrl + 'couponbuy/history', {}, e => { | |||
| console.log(e) | |||
| if (e.code == 200) { | |||
| this.setData({ | |||
| historyArr: e.data | |||
| }) | |||
| } | |||
| }, this) | |||
| }, | |||
| /** | |||
| * 生命周期函数--监听页面初次渲染完成 | |||
| */ | |||
| @@ -144,20 +120,27 @@ Page({ | |||
| }) | |||
| } | |||
| }, | |||
| lookTicket:function(e){ | |||
| lookTicket: function (e) {//查看优惠券 | |||
| console.log(e) | |||
| var index = e.target.dataset.index; | |||
| console.log(this.data.myTicketArr) | |||
| var index = e.currentTarget.dataset.index; | |||
| var dataArr = this.data.myTicketArr[index]; | |||
| dataArr = JSON.stringify(dataArr); | |||
| console.log(dataArr) | |||
| wx.navigateTo({ | |||
| url: '../TicketDetails/TicketDetails', | |||
| url: '../TicketDetails/TicketDetails?dataArr=' + dataArr, | |||
| }) | |||
| }, | |||
| giveTicket:function(e){ | |||
| giveTicket:function(e){//赠送优惠券 | |||
| var index = e.target.dataset.index; | |||
| var dataArr = this.data.myTicketArr[index]; | |||
| dataArr = JSON.stringify(dataArr); | |||
| console.log(dataArr) | |||
| wx.navigateTo({ | |||
| url: '../givePage/givePage', | |||
| url: '../givePage/givePage?dataArr=' + dataArr, | |||
| }) | |||
| }, | |||
| getUser:function(e){ | |||
| getUser:function(e){//点击登陆获取用户信息 | |||
| console.log(e) | |||
| this.setData({ | |||
| getUserArr: e.detail.userInfo | |||
| @@ -166,7 +149,24 @@ Page({ | |||
| this.setData({ | |||
| getUser: true | |||
| }) | |||
| this.submitUser(); | |||
| } | |||
| console.log(this.data.getUserArr) | |||
| }, | |||
| submitUser:function(){//提交用户信息 | |||
| var params={ | |||
| "province": this.data.getUserArr.province, | |||
| "language": this.data.getUserArr.language, | |||
| "city": this.data.getUserArr.city, | |||
| "gender": this.data.getUserArr.gender, | |||
| "nickname": this.data.getUserArr.nickName, | |||
| "headimgurl": this.data.getUserArr.avatarUrl, | |||
| } | |||
| app.wxRequest(app.globalData.httpUrl + 'submit', params, e => { | |||
| console.log(e) | |||
| if (e.code == 200) { | |||
| } | |||
| }, this,"POST") | |||
| } | |||
| }) | |||
| @@ -23,12 +23,12 @@ | |||
| <view class="contAll" wx:for="{{myTicketArr}}"> | |||
| <view class="ticketCont"> | |||
| <view class="ticketImg"> | |||
| <image class="ticketImg" src="{{item.image}}"></image> | |||
| <image class="ticketImg" src="{{item.coupon_img_small}}"></image> | |||
| </view> | |||
| <view class="rigWord"> | |||
| <view class="name">{{item.name}}</view> | |||
| <view class="time">优惠券每次限用一张,不可叠加</view> | |||
| <view class="time">(有效期:{{item.time}})</view> | |||
| <view class="name">{{item.coupon_name}}</view> | |||
| <view class="time">{{item.coupon_memo}}</view> | |||
| <view class="time">(有效期:{{item.end_date}})</view> | |||
| </view> | |||
| </view> | |||
| <view class="look"> | |||
| @@ -48,10 +48,10 @@ | |||
| <view class="history" wx:for="{{historyArr}}"> | |||
| <view class="historyLeft"> | |||
| <image class="historyTicketBg" src="../images/historyTicketBg.png"></image> | |||
| <view class="ticketCode">券码:{{item.code}}</view> | |||
| <view class="ticketCode">券码:{{item.coupon_sell_id}}</view> | |||
| </view> | |||
| <view class="tickName">{{item.name}}</view> | |||
| <view class="tickType">{{item.type}}</view> | |||
| <view class="tickName">{{item.coupon_type}}</view> | |||
| <view class="tickType">已使用</view> | |||
| </view> | |||
| </scroll-view> | |||
| </view> | |||
| @@ -1,60 +1,65 @@ | |||
| // pages/shop/shop.js | |||
| const app = getApp() | |||
| Page({ | |||
| /** | |||
| * 页面的初始数据 | |||
| */ | |||
| data: { | |||
| provinceArr: [ | |||
| ["全部", "a", "b", "c", "d"], ["1", "2", "3", "4", "5"], | |||
| ], | |||
| cityArr: [["1", "2", "3", "4", "5"], ["1", "2", "3", "4"], ["1", "2", "3"], ["1", "2"], ["1"]], | |||
| provinceCityArr: [],//省份城市为二维数组a[[],[]] | |||
| provinceArr: [],//省 | |||
| cityArr: [],//市 | |||
| index:0, | |||
| provinceIndex:0, | |||
| cityIndex:0, | |||
| inputVal:"", | |||
| initialize:false,//检测是不是通过条件搜索 | |||
| scrollHig:0, | |||
| getDataArr:[ | |||
| { | |||
| "bigImg": "../images/shop.png", | |||
| "name":"北京东城区金宝店", | |||
| "address":"北京市东城区金宝大雅宝59号(鄂尔多斯酒店对面)", | |||
| "phone":"010-8388-6698", | |||
| }, | |||
| { | |||
| "bigImg": "../images/shop.png", | |||
| "name": "北京东城区金宝店", | |||
| "address": "北京市东城区金宝大雅宝59号(鄂尔多斯酒店对面)", | |||
| "phone": "010-8388-6698", | |||
| }, | |||
| { | |||
| "bigImg": "../images/shop.png", | |||
| "name": "北京东城区金宝店", | |||
| "address": "北京市东城区金宝大雅宝59号(鄂尔多斯酒店对面)", | |||
| "phone": "010-8388-6698", | |||
| } | |||
| // { | |||
| // "bigImg": "../images/shop.png", | |||
| // "name":"北京东城区金宝店", | |||
| // "address":"北京市东城区金宝大雅宝59号(鄂尔多斯酒店对面)", | |||
| // "phone":"010-8388-6698", | |||
| // }, | |||
| // { | |||
| // "bigImg": "../images/shop.png", | |||
| // "name": "北京东城区金宝店", | |||
| // "address": "北京市东城区金宝大雅宝59号(鄂尔多斯酒店对面)", | |||
| // "phone": "010-8388-6698", | |||
| // }, | |||
| // { | |||
| // "bigImg": "../images/shop.png", | |||
| // "name": "北京东城区金宝店", | |||
| // "address": "北京市东城区金宝大雅宝59号(鄂尔多斯酒店对面)", | |||
| // "phone": "010-8388-6698", | |||
| // } | |||
| ] | |||
| }, | |||
| bindchange:function(e){ | |||
| console.log("确定") | |||
| wx.pageScrollTo({ | |||
| scrollTop: 0, | |||
| duration: 300 | |||
| this.setData({ | |||
| inputVal:"" | |||
| }) | |||
| this.searchShop(); | |||
| }, | |||
| bindcolumnchange: function (e) { | |||
| console.log(e) | |||
| this.data.initialize = true; | |||
| var clo = e.detail.column;//指移动的哪一列 | |||
| var value = e.detail.value;//指列中的哪一个 | |||
| var activeArr = [this.data.provinceArr[0], this.data.cityArr[value]] | |||
| var activeArr = [this.data.provinceArr, this.data.cityArr[value]] | |||
| if (clo==0){ | |||
| console.log(0) | |||
| this.setData({ | |||
| provinceArr: activeArr, | |||
| provinceCityArr: activeArr, | |||
| index:0, | |||
| provinceIndex: value, | |||
| }) | |||
| }else{ | |||
| this.setData({ | |||
| index: value | |||
| index: value, | |||
| cityIndex:value | |||
| }) | |||
| } | |||
| console.log(activeArr) | |||
| @@ -64,12 +69,74 @@ Page({ | |||
| * 生命周期函数--监听页面加载 | |||
| */ | |||
| onLoad: function (options) { | |||
| // var Hig = wx.getSystemInfoSync().windowHeight; | |||
| // this.setData({ | |||
| // scrollHig: Hig-110+40, | |||
| // }) | |||
| this.getShopList(); | |||
| this.searchShop(); | |||
| }, | |||
| getShopList:function(){//获取所有门店省市 | |||
| app.wxRequest(app.globalData.httpUrl + 'shop/shop_province', {}, e => { | |||
| console.log(e) | |||
| var shopProvince = ["全部"];//省份 | |||
| var shopCity = [];//城市 | |||
| var shopCityAll = ["全部"];//全部城市 | |||
| var provinceCity = [];//省份城市为二维数组 | |||
| if (e.code == 200) { | |||
| for (var i = 0; i < e.data.length;i++){ | |||
| shopProvince.push(e.data[i].shop_province) | |||
| var arr = e.data[i].shop_city.split(",") | |||
| shopCityAll.push(arr) | |||
| shopCity.push(arr) | |||
| } | |||
| shopCityAll = shopCityAll.join(",") | |||
| shopCityAll = shopCityAll.split(",") | |||
| shopCity.unshift(shopCityAll); | |||
| provinceCity.push(shopProvince); | |||
| provinceCity.push(shopCity[0]); | |||
| this.setData({ | |||
| provinceArr: shopProvince, | |||
| cityArr: shopCity, | |||
| provinceCityArr: provinceCity, | |||
| }) | |||
| console.log(this.data.provinceArr) | |||
| console.log(this.data.cityArr) | |||
| console.log(this.data.provinceCityArr) | |||
| } | |||
| }, this) | |||
| }, | |||
| searchShop:function(){//搜索 | |||
| var province = ""; | |||
| var city = ""; | |||
| if (this.data.initialize){ | |||
| if (this.data.provinceCityArr[0][this.data.provinceIndex] == "全部"){ | |||
| this.data.provinceCityArr[0][this.data.provinceIndex] = ""; | |||
| } | |||
| if (this.data.provinceCityArr[1][this.data.cityIndex] == "全部"){ | |||
| this.data.provinceCityArr[1][this.data.cityIndex] = ""; | |||
| } | |||
| province = this.data.provinceCityArr[0][this.data.provinceIndex]; | |||
| city = this.data.provinceCityArr[1][this.data.cityIndex]; | |||
| } | |||
| var params = { | |||
| "shop_province": province, | |||
| "shop_city": city, | |||
| "key": this.data.inputVal, | |||
| "cur_page":1, | |||
| "show_num":10, | |||
| } | |||
| app.wxRequest(app.globalData.httpUrl + 'shop/search', params, e => { | |||
| console.log(e) | |||
| if (e.code == 200) { | |||
| wx.pageScrollTo({ | |||
| scrollTop: 0, | |||
| duration: 300 | |||
| }) | |||
| this.setData({ | |||
| getDataArr:e.data | |||
| }) | |||
| } | |||
| }, this) | |||
| }, | |||
| /** | |||
| * 生命周期函数--监听页面初次渲染完成 | |||
| */ | |||
| @@ -131,6 +198,9 @@ Page({ | |||
| }) | |||
| }, | |||
| searchFn:function(){//点击搜索按钮 | |||
| this.setData({ | |||
| index:0 | |||
| }) | |||
| this.searchShop(); | |||
| }, | |||
| }) | |||
| @@ -2,16 +2,16 @@ | |||
| <view class="all"> | |||
| <view class="searchAll"> | |||
| <view class="chooseCity"> | |||
| <picker mode="multiSelector" range="{{provinceArr}}" bindchange="bindchange" bindcolumnchange="bindcolumnchange" value="{{index}}"> | |||
| <picker mode="multiSelector" range="{{provinceCityArr}}" bindchange="bindchange" bindcolumnchange="bindcolumnchange" value="{{index}}"> | |||
| <view class="clickChoose"> | |||
| <view class="picker">{{provinceArr[1][index]}}</view> | |||
| <view class="picker">{{provinceCityArr[1][index]}}</view> | |||
| <image class="arrows" src="../images/arrows.png"></image> | |||
| </view> | |||
| </picker> | |||
| </view> | |||
| <view class="searchView"> | |||
| <image class="searchIcon" src="../images/searchIcon.png"></image> | |||
| <input class="int" bindinput="getInputVal" placeholder="输入搜索内容" placeholder-class="placeholderInt"></input> | |||
| <input class="int" bindinput="getInputVal" value="{{inputVal}}" placeholder="输入搜索内容" placeholder-class="placeholderInt"></input> | |||
| </view> | |||
| <view class="searchBtn" bindtap="searchFn">搜索</view> | |||
| </view> | |||
| @@ -21,17 +21,17 @@ | |||
| <view> | |||
| <view class="getData" wx:for="{{getDataArr}}"> | |||
| <view class="imgView"> | |||
| <image class="shop" src="{{item.bigImg}}"></image> | |||
| <image 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.name}}</view> | |||
| <view class="shopName">{{item.shop_name}}</view> | |||
| <view class="address"> | |||
| <image class="addressIcon" src="../images/addressIcon.png"></image> | |||
| <view class="iconRig">{{item.address}}</view> | |||
| <view class="iconRig">{{item.shop_addr}}</view> | |||
| </view> | |||
| <view class="phone"> | |||
| <image class="phoneIcon" src="../images/phoneIcon.png"></image> | |||
| <view class="iconRig">{{item.phone}}</view> | |||
| <view class="iconRig">{{item.shop_phone}}</view> | |||
| </view> | |||
| <view class="line"></view> | |||
| </view> | |||