@@ -62,6 +62,7 @@ App({ | |||
this.requestGet('getinfo', "", res => { | |||
if (res.code == 200) { | |||
this.globalData.userState = 1; | |||
this.globalData.storeData=res.data; | |||
} else { | |||
this.globalData.userState = 0; | |||
} | |||
@@ -102,6 +103,7 @@ App({ | |||
globalData: { | |||
userInfo: null, | |||
userState: -1, //-1未获取 -0未注册 1已注册 | |||
storeData:null,//店铺信息 | |||
apiUrl: 'https://laomenkuang.jiyou-tech.com/apiWxAdmin/', | |||
baseInfo: null, | |||
couponData:null,//优惠券信息 |
@@ -9,11 +9,14 @@ Page({ | |||
type: 2, //1券码核销 2手机号核销 | |||
user_phone: '', //手机号 | |||
state: 0, //0核销未完成 1核销中 2核销已完成 | |||
totalNums: 50, //总数量 | |||
totalNums: 1, //总数量 | |||
nums: 1, //核销数量 | |||
coupon_name: '', //优惠券名称 | |||
couponTime: '', //优惠券购买时间 | |||
code_num: '', //核销短信验证码 | |||
couponCode:'',//券号 | |||
couponType:'',//券类型 | |||
duration:'',//券期间 | |||
}, | |||
/** | |||
* 验证码修改 | |||
@@ -30,44 +33,59 @@ Page({ | |||
if (this.data.state == 1) { | |||
return | |||
} | |||
if (this.data.code_num.length != 6) { | |||
wx.showToast({ | |||
title: '验证码错误', | |||
icon: 'none', | |||
duration: 2000 | |||
}) | |||
} else { | |||
this.setData({ | |||
state: 1 | |||
}) | |||
var data = { | |||
var data; | |||
if (this.data.type==1){//券核销 | |||
data = { | |||
check_type: 1, | |||
coupon_code: this.data.couponCode, | |||
check_num: 1 | |||
} | |||
}else{//手机号核销 | |||
if (this.data.code_num.length != 6) { | |||
wx.showToast({ | |||
title: '验证码错误', | |||
icon: 'none', | |||
duration: 2000 | |||
}) | |||
return | |||
} | |||
data = { | |||
check_type: 2, | |||
user_phone: this.data.user_phone, | |||
code_num: this.data.code_num, | |||
coupon_sell_id: app.globalData.couponData.coupon_sell_id, | |||
coupon_code: '', | |||
check_num: this.data.nums | |||
} | |||
app.requestPost('couponbuy/check', data, res => { | |||
var state; | |||
if (res.code == 200) { | |||
state = 2; | |||
} | |||
data.coupon_sell_id = app.globalData.couponData.coupon_sell_id; | |||
console.log(data); | |||
this.setData({ | |||
state: 1 | |||
}) | |||
var that=this; | |||
app.requestPost('couponbuy/check', data, res => { | |||
var state; | |||
if (res.code == 200) { | |||
state = 2; | |||
if (that.data.type == 2) {//手机号核销 | |||
wx.switchTab({ | |||
url: '../record/record' | |||
}) | |||
} else { | |||
state = 0; | |||
wx.showToast({ | |||
title: res.message, | |||
icon: 'none', | |||
duration: 2000 | |||
}) | |||
} | |||
this.setData({ | |||
state: state | |||
} else { | |||
state = 0; | |||
wx.showToast({ | |||
title: res.message, | |||
icon: 'none', | |||
duration: 2000 | |||
}) | |||
} | |||
that.setData({ | |||
state: state | |||
}) | |||
} | |||
}) | |||
}, | |||
/** | |||
* 添加优惠券 | |||
@@ -89,6 +107,14 @@ Page({ | |||
}) | |||
} | |||
}, | |||
/** | |||
* 返回核销大厅 | |||
*/ | |||
goHome(){ | |||
wx.switchTab({ | |||
url: '../home/home' | |||
}) | |||
}, | |||
/** | |||
* 生命周期函数--监听页面加载 | |||
@@ -97,20 +123,24 @@ Page({ | |||
wx.hideShareMenu(); | |||
var code = options.code; | |||
var pohone = options.phone; | |||
var couponData = app.globalData.couponData; | |||
if (code) { //券码查询 | |||
this.setData({ | |||
type: 1 | |||
type: 1, | |||
couponCode:code, | |||
coupon_name: couponData.coupon_name, | |||
couponTime: couponData.buy_date, | |||
couponType: couponData.coupon_type, | |||
duration: couponData.duration | |||
}) | |||
} | |||
if (pohone) { //手机号查询 | |||
console.log(app.globalData.couponData) | |||
var couponData = app.globalData.couponData; | |||
this.setData({ | |||
type: 2, | |||
user_phone: pohone, | |||
totalNums: couponData.num, | |||
coupon_name: couponData.coupon_name, | |||
couponTime: couponData.cdate | |||
couponTime: couponData.buy_date | |||
}) | |||
/** | |||
* 发送验证码 |
@@ -8,14 +8,14 @@ | |||
<text class="txt1">{{coupon_name}}</text> | |||
<text class="txt2">购买时间:{{couponTime}}</text> | |||
</view> | |||
<view class="detailsRight" wx:if="{{type==2}}">{{totalNums}}<text class="company">张</text> | |||
<view class="detailsRight" wx:if="{{type==2}}"><image class="txt" src="../../static/coupon/txt.png"></image>{{totalNums}}<text class="company">张</text> | |||
</view> | |||
<image class="logo" src="../../static/coupon/logo.png" wx:if="{{type==1}}"></image> | |||
</view> | |||
<view class="middleContent shadow"> | |||
<view id="couponCheck" class="relative clearfix" wx:if="{{type==1&&state!=2}}"> | |||
<image class="couponIcon" src="../../static/coupon/couponIcon.png"></image> | |||
<text class="number">078657</text> | |||
<text class="number">券码:{{couponCode}}</text> | |||
<view class="txt">此券有效</view> | |||
</view> | |||
<view id="couponDetails" class="relative clearfix" wx:if="{{type==1&&state==2}}"> | |||
@@ -23,17 +23,17 @@ | |||
<view class="detailsItem"> | |||
<view class="sign"></view> | |||
<text class="itemTitle">券码</text> | |||
<text class="itemContent">H0001</text> | |||
<text class="itemContent">{{couponCode}}</text> | |||
</view> | |||
<view class="detailsItem"> | |||
<view class="sign"></view> | |||
<text class="itemTitle">类型</text> | |||
<text class="itemContent">80元抵100元券</text> | |||
<text class="itemContent">{{couponType}}</text> | |||
</view> | |||
<view class="detailsItem"> | |||
<view class="sign"></view> | |||
<text class="itemTitle">时间</text> | |||
<text class="itemContent">2020年02月25日</text> | |||
<text class="itemContent">{{duration}}</text> | |||
</view> | |||
<view class="state">核销成功</view> | |||
</view> | |||
@@ -48,5 +48,6 @@ | |||
</view> | |||
</view> | |||
</view> | |||
<button class="btn shadow {{state==1?'select':''}}" bindtap="writeOff">核销</button> | |||
<button class="btn shadow {{state==1?'select':''}}" bindtap="writeOff" wx:if="{{state!=2}}">核销</button> | |||
<button class="btn shadow" bindtap="goHome" wx:else>确定</button> | |||
</view> |
@@ -75,13 +75,19 @@ | |||
text-align: center; | |||
color: #eb6100; | |||
font-size: 100rpx; | |||
font-weight: bold; | |||
font-weight: 550; | |||
} | |||
.detailsBox>.detailsRight>.txt{ | |||
display: inline-block; | |||
width: 34rpx; | |||
height: 70rpx; | |||
margin-right: 5rpx; | |||
} | |||
.detailsBox>.detailsRight>.company { | |||
color: #333; | |||
font-size: 30rpx; | |||
margin-left: 10rpx; | |||
margin-left: 5rpx; | |||
} | |||
.detailsBox>.logo { | |||
@@ -107,21 +113,20 @@ | |||
} | |||
#couponCheck>.number { | |||
position: absolute; | |||
top: 144rpx; | |||
left: 470rpx; | |||
color: #eb6100; | |||
font-size: 30rpx; | |||
position: relative; | |||
color: #666666; | |||
font-size: 24rpx; | |||
font-weight: 700; | |||
margin-left: 128rpx; | |||
} | |||
#couponCheck>.txt { | |||
width: 100%; | |||
text-align: center; | |||
color: #eb6100; | |||
color: #333333; | |||
font-size: 40rpx; | |||
font-weight: 550; | |||
margin-top: 50rpx; | |||
margin-top: 20rpx; | |||
} | |||
#couponDetails>.title { |
@@ -7,6 +7,7 @@ Page({ | |||
*/ | |||
data: { | |||
isQuerying: false, | |||
storeName: '', //店名 | |||
}, | |||
/** | |||
* 核销查询 | |||
@@ -16,57 +17,21 @@ Page({ | |||
return | |||
} | |||
var data = e.detail.value; | |||
if (data.code == '' && data.phone == '') { | |||
if (data.phone.length != 11) { | |||
wx.showToast({ | |||
title: '请输入内容后再查询', | |||
icon: 'none', | |||
duration: 2000 | |||
}) | |||
} else if (data.code != '' && data.phone != '') { | |||
wx.showToast({ | |||
title: '仅可选择一项查询', | |||
title: '输入的手机号码有误', | |||
icon: 'none', | |||
duration: 2000 | |||
}) | |||
return | |||
} else { | |||
var type; | |||
if (data.code != '') { //券码查询 | |||
type = 1; | |||
if (data.code.length != 6) { | |||
wx.showToast({ | |||
title: '券码格式错误', | |||
icon: 'none', | |||
duration: 2000 | |||
}) | |||
return | |||
} | |||
} | |||
if (data.phone != '') { //手机号查询 | |||
type = 2; | |||
if (data.phone.length != 11) { | |||
wx.showToast({ | |||
title: '输入的手机号码有误', | |||
icon: 'none', | |||
duration: 2000 | |||
}) | |||
return | |||
} | |||
} | |||
this.setData({ | |||
isQuerying: true | |||
}) | |||
this.query(data, type); | |||
this.query(data); | |||
} | |||
}, | |||
query(data, type) { | |||
var key, value; | |||
if (type == 1) { //券码查询 | |||
key = 'code'; | |||
value = data.code; | |||
} else { //手机号查询 | |||
key = 'phone'; | |||
value = data.phone; | |||
} | |||
query(data) { | |||
app.requestGet('couponbuy/searchbyphone', { | |||
user_phone: data.phone | |||
}, res => { | |||
@@ -77,7 +42,7 @@ Page({ | |||
app.globalData.couponData = res.data[0]; | |||
app.globalData.couponToken = res.token; | |||
wx.navigateTo({ | |||
url: '../coupon/coupon?' + key + '=' + value | |||
url: '../coupon/coupon?phone=' + data.phone | |||
}) | |||
} else { | |||
wx.showToast({ | |||
@@ -88,12 +53,42 @@ Page({ | |||
} | |||
}) | |||
}, | |||
/** | |||
* 扫码 | |||
*/ | |||
scanCode() { | |||
wx.scanCode({ | |||
onlyFromCamera: true, | |||
success(res) { | |||
var result = res.result; | |||
app.requestGet('couponbuy/searchbycouponcode', { | |||
coupon_code: result | |||
}, res => { | |||
if (res.code == 200) { | |||
app.globalData.couponData = res.data; | |||
app.globalData.couponToken = res.token; | |||
wx.navigateTo({ | |||
url: '../coupon/coupon?code=' + result | |||
}) | |||
} else { | |||
wx.showToast({ | |||
title: res.message, | |||
icon: 'none', | |||
duration: 2000 | |||
}) | |||
} | |||
}) | |||
} | |||
}) | |||
}, | |||
/** | |||
* 生命周期函数--监听页面加载 | |||
*/ | |||
onLoad: function(options) { | |||
wx.hideShareMenu(); | |||
this.setData({ | |||
storeName: app.globalData.storeData.shop_name | |||
}) | |||
}, | |||
/** |
@@ -2,11 +2,14 @@ | |||
<view class="container"> | |||
<image class="bg" src="../../static/home/bg.jpg" mode="aspectFill"></image> | |||
<image class="logo" src="../../static/home/logo.png"></image> | |||
<view class="storeName">欢迎登录{{storeName}}</view> | |||
<view class="fromBox"> | |||
<image class="arrow" src="../../static/home/arrow.png"></image> | |||
<form bindsubmit="check"> | |||
<input name="code" maxlength="6" placeholder="请输入券码" placeholder-class="inputPlaceholder" style="margin-top:138rpx;" disabled="true"/> | |||
<input name="phone" maxlength="11" placeholder="手机号核销" placeholder-class="inputPlaceholder" type="number" /> | |||
<button class="query {{isQuerying?'select':''}}" form-type="submit">查询</button> | |||
<!-- <input name="code" maxlength="6" placeholder="请输入券码" placeholder-class="inputPlaceholder" style="margin-top:138rpx;" disabled="true" /> --> | |||
<input name="phone" maxlength="11" placeholder="手机号核销" placeholder-class="inputPlaceholder" style="margin-top:132rpx;" type="number" /> | |||
<button class="btn query {{isQuerying?'select':''}}" form-type="submit">查询</button> | |||
<button class="btn scanning" bindtap="scanCode">点击扫描核销</button> | |||
</form> | |||
</view> | |||
</view> |
@@ -13,12 +13,28 @@ | |||
margin-top: 74rpx; | |||
} | |||
.storeName { | |||
color: #fffefe; | |||
font-size: 40rpx; | |||
font-weight: 600; | |||
margin-top: 85rpx; | |||
} | |||
.fromBox { | |||
position: relative; | |||
width: 600rpx; | |||
height: 676rpx; | |||
background-color: rgba(255, 255, 255, 0.9); | |||
height: 666rpx; | |||
background-color: rgba(255, 255, 255, 0.95); | |||
border-radius: 30rpx; | |||
margin-top: 116rpx; | |||
margin-top: 30rpx; | |||
} | |||
.fromBox>.arrow { | |||
position: absolute; | |||
width: 33rpx; | |||
height: 12rpx; | |||
top: -11rpx; | |||
left: 140rpx; | |||
} | |||
.fromBox input { | |||
@@ -35,18 +51,27 @@ | |||
color: #fff; | |||
font-size: 30rpx; | |||
} | |||
.query { | |||
.btn{ | |||
width: 522rpx; | |||
height: 98rpx; | |||
background: linear-gradient(-72deg, rgba(235, 97, 0, 1), rgba(255, 137, 42, 1)); | |||
border-radius: 49rpx; | |||
color: #ffffff; | |||
color: #fff; | |||
text-align: center; | |||
line-height: 98rpx; | |||
box-sizing: border-box; | |||
margin: 26rpx auto 0 auto; | |||
font-size: 36rpx; | |||
} | |||
.query { | |||
background: linear-gradient(-72deg, rgba(235, 97, 0, 1), rgba(255, 137, 42, 1)); | |||
margin: 32rpx auto 0 auto; | |||
} | |||
.query.select { | |||
background: #ccc; | |||
} | |||
.query.select{ | |||
background: #cccccc; | |||
.scanning { | |||
background: linear-gradient(-72deg, rgba(235, 0, 0, 1), rgba(255, 82, 42, 1)); | |||
margin: 64rpx auto 0 auto; | |||
} |
@@ -47,6 +47,7 @@ Page({ | |||
isLoginIng: false | |||
}) | |||
if(res.code==200){ | |||
app.globalData.storeData = res.data; | |||
wx.switchTab({ | |||
url: '../home/home' | |||
}) |
@@ -3,7 +3,7 @@ | |||
<image class="bg" src="../../static/record/bg.jpg"></image> | |||
<view class="content"> | |||
<view class="headBox"> | |||
<button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo" style="width:100%;height:100%;font-size:36rpx;line-height:200rpx;"> 获取头像 </button> | |||
<button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo" style="width:100%;height:100%;font-size:34rpx;line-height:200rpx;"> 获取头像 </button> | |||
<image wx:else src="{{userInfo.avatarUrl}}" mode="aspectFill"></image> | |||
</view> | |||
<view class="userName" wx:if="{{userInfo}}">{{userInfo.nickName}}</view> | |||
@@ -24,7 +24,7 @@ | |||
<view class="details" wx:if="{{showIndex == 1}}" wx:for="{{data}}" wx:key="id"> | |||
<text class="time">{{item.cdate}}</text> | |||
<view class="infoBox"> | |||
<text>券码:{{item.coupon_code}}</text> | |||
<text>券码:{{item.coupon_code}}</text> | |||
<text>{{item.coupon_type}}</text> | |||
</view> | |||
</view> |
@@ -89,7 +89,7 @@ | |||
} | |||
.item>.details>.infoBox{ | |||
color: #999999; | |||
font-size: 24rpx; | |||
font-size: 23rpx; | |||
display: flex; | |||
justify-content: space-between; | |||
margin-top: 5rpx; |
@@ -74,6 +74,14 @@ Page({ | |||
//获取省份信息 | |||
app.requestGet('shop/shop_province', '', res => { | |||
if (res.code == 200) { | |||
var city='全部'; | |||
for(var i=0;i<res.data.length;i++){ | |||
city += "," + res.data[i].shop_city | |||
} | |||
res.data.unshift({ | |||
shop_city:city, | |||
shop_province:'全部' | |||
}) | |||
this.setData({ | |||
multiData: res.data, | |||
}) | |||
@@ -129,9 +137,9 @@ Page({ | |||
this.setData({ | |||
storeList: [] | |||
}) | |||
var city = this.data.showMultArray[1][this.data.multiIndex[1]] == '全部' ? '' : this.data.showMultArray[1][this.data.multiIndex[1]]; | |||
var data = { | |||
'shop_province': this.data.showMultArray[0][this.data.multiIndex[0]], | |||
'shop_city': this.data.showMultArray[1][this.data.multiIndex[1]], | |||
'shop_city': city, | |||
'key': this.data.key, | |||
'cur_page': this.data.cur_page, | |||
'show_num': this.data.show_num |