wx.login({ | wx.login({ | ||||
success: res => { | success: res => { | ||||
// 发送 res.code 到后台换取 openId, sessionKey, unionId | // 发送 res.code 到后台换取 openId, sessionKey, unionId | ||||
console.log(res) | |||||
// console.log(res) | |||||
if (res.code){ | if (res.code){ | ||||
wx.request({ | wx.request({ | ||||
url: this.globalData.httpUrl+'openid', | url: this.globalData.httpUrl+'openid', | ||||
code: res.code | code: res.code | ||||
}, | }, | ||||
success: e => { | success: e => { | ||||
console.log(e) | |||||
// console.log(e) | |||||
if (e.data.code == 200) { | if (e.data.code == 200) { | ||||
this.globalData.openId = e.data.data.openid; | this.globalData.openId = e.data.data.openid; | ||||
this.globalData.session_key = e.data.data.session_key; | this.globalData.session_key = e.data.data.session_key; | ||||
}else{ | }else{ | ||||
this.globalData.openid = openid; | this.globalData.openid = openid; | ||||
} | } | ||||
this.getUserType(); | |||||
// this.getUserType(); | |||||
// 获取用户信息 | // 获取用户信息 | ||||
// wx.getSetting({ | // wx.getSetting({ | ||||
// success: res => { | // success: res => { | ||||
getUserType:function(){//获取用户注册状态 | getUserType:function(){//获取用户注册状态 | ||||
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({ | wx.reLaunch({ | ||||
url: '/pages/register/register' | url: '/pages/register/register' | ||||
}, | }, | ||||
wxRequest: function (url, params, callback, thisArg, methods, openid) { | wxRequest: function (url, params, callback, thisArg, methods, openid) { | ||||
let that = this; | let that = this; | ||||
console.log(this.globalData.openid) | |||||
// console.log(this.globalData.openid) | |||||
var httpUrl = url; | var httpUrl = url; | ||||
var str = ""; | var str = ""; | ||||
var count = 0; | var count = 0; |
// pages/TicketDetails/TicketDetails.js | // pages/TicketDetails/TicketDetails.js | ||||
const app = getApp() | |||||
Page({ | Page({ | ||||
/** | /** | ||||
* 页面的初始数据 | * 页面的初始数据 | ||||
*/ | */ | ||||
data: { | 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) { | onLoad: function (options) { | ||||
var dataArr = JSON.parse(options.dataArr); | |||||
console.log(dataArr) | |||||
this.setData({ | |||||
ticketUser: dataArr | |||||
}) | |||||
}, | }, | ||||
/** | /** | ||||
* 生命周期函数--监听页面初次渲染完成 | * 生命周期函数--监听页面初次渲染完成 | ||||
*/ | */ |
<view class="all"> | <view class="all"> | ||||
<view class="contTop"> | <view class="contTop"> | ||||
<view class="imgView"> | <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> | <image class="tooth" src="../images/tooth.png"></image> | ||||
</view> | </view> | ||||
<view class="buyNum"> | <view class="buyNum"> | ||||
<view class="ticketName">80元抵100元优惠券</view> | |||||
<view class="ticketName">{{ticketUser.coupon_type}}</view> | |||||
<view class="line"></view> | <view class="line"></view> | ||||
<view class="lineRig"> | <view class="lineRig"> | ||||
<text class="bigWord">50</text> | |||||
<text class="bigWord">{{ticketUser.num}}</text> | |||||
<text class="smaWord">张</text> | <text class="smaWord">张</text> | ||||
</view> | </view> | ||||
</view> | </view> | ||||
<image src="../images/circle.png"></image> | <image src="../images/circle.png"></image> | ||||
<text>使用期限</text> | <text>使用期限</text> | ||||
</view> | </view> | ||||
<view class="specify">购卖后30日内有效</view> | |||||
<view class="specify">{{ticketUser.coupon_deadline_desc}}</view> | |||||
</view> | </view> | ||||
<view> | <view> | ||||
<view class="timeLimit"> | <view class="timeLimit"> | ||||
<image src="../images/circle.png"></image> | <image src="../images/circle.png"></image> | ||||
<text>使用条件</text> | <text>使用条件</text> | ||||
</view> | </view> | ||||
<view class="specify">点单金额需商于优惠金额,每单限使用一张不可叠加使用,不与其他优惠同享</view> | |||||
<view class="specify">{{ticketUser.coupon_condition_desc}}</view> | |||||
</view> | </view> | ||||
<view> | <view> | ||||
<view class="timeLimit"> | <view class="timeLimit"> | ||||
<image src="../images/circle.png"></image> | <image src="../images/circle.png"></image> | ||||
<text>适用门店</text> | <text>适用门店</text> | ||||
</view> | </view> | ||||
<view class="specify">老门框所有门店</view> | |||||
<view class="specify">{{ticketUser.coupon_allow_shop}}</view> | |||||
</view> | </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"> | <view class="historyLeft"> | ||||
<image class="historyTicketBg" src="../images/historyTicketBg.png"></image> | <image class="historyTicketBg" src="../images/historyTicketBg.png"></image> | ||||
<view class="ticketCode">券码:{{item.code}}</view> | |||||
<view class="ticketCode">券码:{{ticketUser.coupon_sell_id}}</view> | |||||
</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> | </view> | ||||
</scroll-view> | |||||
<!-- </scroll-view> --> | |||||
</view> | </view> |
margin-left: 69rpx; | margin-left: 69rpx; | ||||
} | } | ||||
.scrollY{ | |||||
/* .scrollY{ | |||||
height: 300rpx; | height: 300rpx; | ||||
margin-top: 107rpx; | margin-top: 107rpx; | ||||
} | |||||
} */ | |||||
.historyIcon{ | .historyIcon{ | ||||
width: 30rpx; | width: 30rpx; | ||||
display: flex; | display: flex; | ||||
justify-content: space-between; | justify-content: space-between; | ||||
align-items: center; | align-items: center; | ||||
margin-top: 20rpx; | |||||
margin-top: 107rpx; | |||||
padding: 0 50rpx; | padding: 0 50rpx; | ||||
} | } | ||||
.historyLeft{ | .historyLeft{ |
// pages/buyTicket/buyTicket.js | // pages/buyTicket/buyTicket.js | ||||
const app = getApp() | |||||
Page({ | Page({ | ||||
/** | /** | ||||
* 页面的初始数据 | * 页面的初始数据 | ||||
*/ | */ | ||||
data: { | data: { | ||||
buyNumber:1, | |||||
buyNumber:1,//购买数量 | |||||
num : 1, | num : 1, | ||||
ticketUser: [],//优惠券信息 | |||||
orderUser:[],//下单信息 | |||||
sign_num:"",//确认支付参数 | |||||
}, | }, | ||||
/** | /** | ||||
*/ | */ | ||||
onLoad: function (options) { | onLoad: function (options) { | ||||
console.log(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) | |||||
}, | |||||
/** | /** | ||||
* 生命周期函数--监听页面初次渲染完成 | * 生命周期函数--监听页面初次渲染完成 | ||||
*/ | */ | ||||
}) | }) | ||||
} | } | ||||
}, | }, | ||||
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") | |||||
}, | |||||
}) | }) |
<view class="all"> | <view class="all"> | ||||
<view class="contTop"> | <view class="contTop"> | ||||
<view class="imgView"> | <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> | <image class="tooth" src="../images/tooth.png"></image> | ||||
</view> | </view> | ||||
<view class="buyNum"> | <view class="buyNum"> | ||||
<view class="ticketName">80元抵100元优惠券</view> | |||||
<view class="ticketName">{{ticketUser.coupon_type}}</view> | |||||
<view class="line"></view> | <view class="line"></view> | ||||
<view class="chooseNum"> | <view class="chooseNum"> | ||||
<view bindtap="subtractFn" class="subtractView"> | <view bindtap="subtractFn" class="subtractView"> |
*/ | */ | ||||
data: { | data: { | ||||
buyNumber: 1, | buyNumber: 1, | ||||
num: 1, | |||||
ticketNum: 1, | |||||
ticketUser: [],//优惠券信息 | |||||
}, | }, | ||||
/** | /** | ||||
* 生命周期函数--监听页面加载 | * 生命周期函数--监听页面加载 | ||||
*/ | */ | ||||
onLoad: function (options) { | onLoad: function (options) { | ||||
var dataArr = JSON.parse(options.dataArr); | |||||
console.log(dataArr) | |||||
this.setData({ | |||||
ticketUser: dataArr | |||||
}) | |||||
}, | }, | ||||
/** | /** | ||||
}, | }, | ||||
addFn: function () { | addFn: function () { | ||||
if (this.data.num < 5) { | |||||
this.data.num++; | |||||
if (this.data.ticketNum < this.data.ticketUser.num) { | |||||
this.data.ticketNum++; | |||||
this.setData({ | this.setData({ | ||||
buyNumber: this.data.num | |||||
buyNumber: this.data.ticketNum | |||||
}) | }) | ||||
} | } | ||||
}, | }, | ||||
subtractFn: function () { | subtractFn: function () { | ||||
if (this.data.num > 1) { | |||||
this.data.num--; | |||||
if (this.data.ticketNum > 1) { | |||||
this.data.ticketNum--; | |||||
this.setData({ | this.setData({ | ||||
buyNumber: this.data.num | |||||
buyNumber: this.data.ticketNum | |||||
}) | }) | ||||
} | } | ||||
}, | }, |
<view class="all"> | <view class="all"> | ||||
<view class="contTop"> | <view class="contTop"> | ||||
<view class="imgView"> | <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> | <image class="tooth" src="../images/tooth.png"></image> | ||||
</view> | </view> | ||||
<view class="buyNum"> | <view class="buyNum"> | ||||
<view class="ticketName">80元抵100元优惠券</view> | |||||
<view class="ticketName">{{ticketUser.coupon_type}}</view> | |||||
<view class="line"></view> | <view class="line"></view> | ||||
<view class="lineRig"> | <view class="lineRig"> | ||||
<text class="surplus">剩余</text> | <text class="surplus">剩余</text> | ||||
<text class="bigWord">50</text> | |||||
<text class="bigWord">{{ticketUser.num}}</text> | |||||
<text class="smaWord">张</text> | <text class="smaWord">张</text> | ||||
</view> | </view> | ||||
</view> | </view> |
Page({ | Page({ | ||||
data: { | data: { | ||||
content: ["../images/smallTicket.jpg", "../images/smallTicket.jpg", "../images/smallTicket.jpg"], | |||||
allData:[ | |||||
] | |||||
dataList:[], | |||||
}, | }, | ||||
//事件处理函数 | //事件处理函数 | ||||
onLoad: function () { | onLoad: function () { | ||||
this.getDataList(); | |||||
}, | }, | ||||
getDataList:function(){ | getDataList:function(){ | ||||
app.wxRequest(app.globalData.httpUrl + 'couponsell/list', {}, e => { | app.wxRequest(app.globalData.httpUrl + 'couponsell/list', {}, e => { | ||||
console.log(e) | |||||
// console.log(e) | |||||
if (e.code == 200) { | if (e.code == 200) { | ||||
this.setData({ | |||||
dataList:e.data | |||||
}) | |||||
} | } | ||||
}, this) | }, 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({ | wx.navigateTo({ | ||||
url: '../buyTicket/buyTicket?option=' + option | |||||
url: '../buyTicket/buyTicket?index=' + index | |||||
}) | }) | ||||
} | |||||
}, | |||||
}) | }) |
<image class="buyBg" src="../images/buyBg.jpg"></image> | <image class="buyBg" src="../images/buyBg.jpg"></image> | ||||
<swiper duration="500" next-margin="70rpx"> | <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="botCont"> | ||||
<view class="imgView"> | <view class="imgView"> | ||||
<image src="{{item}}"></image> | |||||
<image src="{{item.coupon_img_small}}"></image> | |||||
</view> | </view> | ||||
<view class="textView"> | <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> | ||||
<view class="buyView">立即购买</view> | <view class="buyView">立即购买</view> | ||||
</view> | </view> |
// pages/personalCenter/personalCenter.js | // pages/personalCenter/personalCenter.js | ||||
const app = getApp() | |||||
Page({ | Page({ | ||||
/** | /** | ||||
myTicketArrows: false, | myTicketArrows: false, | ||||
historyTicketArrows: false, | historyTicketArrows: false, | ||||
getUser:false, | getUser:false, | ||||
getUserArr:[], | |||||
getUserArr: [],//用户信息 | |||||
mydeg: -90, | mydeg: -90, | ||||
historydeg: -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) { | 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) | |||||
}, | }, | ||||
/** | /** | ||||
* 生命周期函数--监听页面初次渲染完成 | * 生命周期函数--监听页面初次渲染完成 | ||||
*/ | */ | ||||
}) | }) | ||||
} | } | ||||
}, | }, | ||||
lookTicket:function(e){ | |||||
lookTicket: function (e) {//查看优惠券 | |||||
console.log(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({ | wx.navigateTo({ | ||||
url: '../TicketDetails/TicketDetails', | |||||
url: '../TicketDetails/TicketDetails?dataArr=' + dataArr, | |||||
}) | }) | ||||
}, | }, | ||||
giveTicket:function(e){ | |||||
giveTicket:function(e){//赠送优惠券 | |||||
var index = e.target.dataset.index; | var index = e.target.dataset.index; | ||||
var dataArr = this.data.myTicketArr[index]; | |||||
dataArr = JSON.stringify(dataArr); | |||||
console.log(dataArr) | |||||
wx.navigateTo({ | wx.navigateTo({ | ||||
url: '../givePage/givePage', | |||||
url: '../givePage/givePage?dataArr=' + dataArr, | |||||
}) | }) | ||||
}, | }, | ||||
getUser:function(e){ | |||||
getUser:function(e){//点击登陆获取用户信息 | |||||
console.log(e) | console.log(e) | ||||
this.setData({ | this.setData({ | ||||
getUserArr: e.detail.userInfo | getUserArr: e.detail.userInfo | ||||
this.setData({ | this.setData({ | ||||
getUser: true | getUser: true | ||||
}) | }) | ||||
this.submitUser(); | |||||
} | } | ||||
console.log(this.data.getUserArr) | 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") | |||||
} | } | ||||
}) | }) |
<view class="contAll" wx:for="{{myTicketArr}}"> | <view class="contAll" wx:for="{{myTicketArr}}"> | ||||
<view class="ticketCont"> | <view class="ticketCont"> | ||||
<view class="ticketImg"> | <view class="ticketImg"> | ||||
<image class="ticketImg" src="{{item.image}}"></image> | |||||
<image class="ticketImg" src="{{item.coupon_img_small}}"></image> | |||||
</view> | </view> | ||||
<view class="rigWord"> | <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> | </view> | ||||
<view class="look"> | <view class="look"> | ||||
<view class="history" wx:for="{{historyArr}}"> | <view class="history" wx:for="{{historyArr}}"> | ||||
<view class="historyLeft"> | <view class="historyLeft"> | ||||
<image class="historyTicketBg" src="../images/historyTicketBg.png"></image> | <image class="historyTicketBg" src="../images/historyTicketBg.png"></image> | ||||
<view class="ticketCode">券码:{{item.code}}</view> | |||||
<view class="ticketCode">券码:{{item.coupon_sell_id}}</view> | |||||
</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> | </view> | ||||
</scroll-view> | </scroll-view> | ||||
</view> | </view> |
// pages/shop/shop.js | // pages/shop/shop.js | ||||
const app = getApp() | |||||
Page({ | Page({ | ||||
/** | /** | ||||
* 页面的初始数据 | * 页面的初始数据 | ||||
*/ | */ | ||||
data: { | 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, | index:0, | ||||
provinceIndex:0, | |||||
cityIndex:0, | |||||
inputVal:"", | inputVal:"", | ||||
initialize:false,//检测是不是通过条件搜索 | |||||
scrollHig:0, | scrollHig:0, | ||||
getDataArr:[ | 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){ | bindchange:function(e){ | ||||
console.log("确定") | console.log("确定") | ||||
wx.pageScrollTo({ | |||||
scrollTop: 0, | |||||
duration: 300 | |||||
this.setData({ | |||||
inputVal:"" | |||||
}) | }) | ||||
this.searchShop(); | |||||
}, | }, | ||||
bindcolumnchange: function (e) { | bindcolumnchange: function (e) { | ||||
console.log(e) | console.log(e) | ||||
this.data.initialize = true; | |||||
var clo = e.detail.column;//指移动的哪一列 | var clo = e.detail.column;//指移动的哪一列 | ||||
var value = e.detail.value;//指列中的哪一个 | 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){ | if (clo==0){ | ||||
console.log(0) | console.log(0) | ||||
this.setData({ | this.setData({ | ||||
provinceArr: activeArr, | |||||
provinceCityArr: activeArr, | |||||
index:0, | index:0, | ||||
provinceIndex: value, | |||||
}) | }) | ||||
}else{ | }else{ | ||||
this.setData({ | this.setData({ | ||||
index: value | |||||
index: value, | |||||
cityIndex:value | |||||
}) | }) | ||||
} | } | ||||
console.log(activeArr) | console.log(activeArr) | ||||
* 生命周期函数--监听页面加载 | * 生命周期函数--监听页面加载 | ||||
*/ | */ | ||||
onLoad: function (options) { | 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) | |||||
}, | |||||
/** | /** | ||||
* 生命周期函数--监听页面初次渲染完成 | * 生命周期函数--监听页面初次渲染完成 | ||||
*/ | */ | ||||
}) | }) | ||||
}, | }, | ||||
searchFn:function(){//点击搜索按钮 | searchFn:function(){//点击搜索按钮 | ||||
this.setData({ | |||||
index:0 | |||||
}) | |||||
this.searchShop(); | |||||
}, | }, | ||||
}) | }) |
<view class="all"> | <view class="all"> | ||||
<view class="searchAll"> | <view class="searchAll"> | ||||
<view class="chooseCity"> | <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="clickChoose"> | ||||
<view class="picker">{{provinceArr[1][index]}}</view> | |||||
<view class="picker">{{provinceCityArr[1][index]}}</view> | |||||
<image class="arrows" src="../images/arrows.png"></image> | <image class="arrows" src="../images/arrows.png"></image> | ||||
</view> | </view> | ||||
</picker> | </picker> | ||||
</view> | </view> | ||||
<view class="searchView"> | <view class="searchView"> | ||||
<image class="searchIcon" src="../images/searchIcon.png"></image> | <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> | ||||
<view class="searchBtn" bindtap="searchFn">搜索</view> | <view class="searchBtn" bindtap="searchFn">搜索</view> | ||||
</view> | </view> | ||||
<view> | <view> | ||||
<view class="getData" wx:for="{{getDataArr}}"> | <view class="getData" wx:for="{{getDataArr}}"> | ||||
<view class="imgView"> | <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> | <image bindtap="callPhone" data-index="{{index}}" class="ringUp" src="../images/ringUp.png" ></image> | ||||
</view> | </view> | ||||
<view class="shopName">{{item.name}}</view> | |||||
<view class="shopName">{{item.shop_name}}</view> | |||||
<view class="address"> | <view class="address"> | ||||
<image class="addressIcon" src="../images/addressIcon.png"></image> | <image class="addressIcon" src="../images/addressIcon.png"></image> | ||||
<view class="iconRig">{{item.address}}</view> | |||||
<view class="iconRig">{{item.shop_addr}}</view> | |||||
</view> | </view> | ||||
<view class="phone"> | <view class="phone"> | ||||
<image class="phoneIcon" src="../images/phoneIcon.png"></image> | <image class="phoneIcon" src="../images/phoneIcon.png"></image> | ||||
<view class="iconRig">{{item.phone}}</view> | |||||
<view class="iconRig">{{item.shop_phone}}</view> | |||||
</view> | </view> | ||||
<view class="line"></view> | <view class="line"></view> | ||||
</view> | </view> |