this.requestGet('getinfo', "", res => { | this.requestGet('getinfo', "", res => { | ||||
if (res.code == 200) { | if (res.code == 200) { | ||||
this.globalData.userState = 1; | this.globalData.userState = 1; | ||||
this.globalData.storeData=res.data; | |||||
} else { | } else { | ||||
this.globalData.userState = 0; | this.globalData.userState = 0; | ||||
} | } | ||||
globalData: { | globalData: { | ||||
userInfo: null, | userInfo: null, | ||||
userState: -1, //-1未获取 -0未注册 1已注册 | userState: -1, //-1未获取 -0未注册 1已注册 | ||||
storeData:null,//店铺信息 | |||||
apiUrl: 'https://laomenkuang.jiyou-tech.com/apiWxAdmin/', | apiUrl: 'https://laomenkuang.jiyou-tech.com/apiWxAdmin/', | ||||
baseInfo: null, | baseInfo: null, | ||||
couponData:null,//优惠券信息 | couponData:null,//优惠券信息 |
type: 2, //1券码核销 2手机号核销 | type: 2, //1券码核销 2手机号核销 | ||||
user_phone: '', //手机号 | user_phone: '', //手机号 | ||||
state: 0, //0核销未完成 1核销中 2核销已完成 | state: 0, //0核销未完成 1核销中 2核销已完成 | ||||
totalNums: 50, //总数量 | |||||
totalNums: 1, //总数量 | |||||
nums: 1, //核销数量 | nums: 1, //核销数量 | ||||
coupon_name: '', //优惠券名称 | coupon_name: '', //优惠券名称 | ||||
couponTime: '', //优惠券购买时间 | couponTime: '', //优惠券购买时间 | ||||
code_num: '', //核销短信验证码 | code_num: '', //核销短信验证码 | ||||
couponCode:'',//券号 | |||||
couponType:'',//券类型 | |||||
duration:'',//券期间 | |||||
}, | }, | ||||
/** | /** | ||||
* 验证码修改 | * 验证码修改 | ||||
if (this.data.state == 1) { | if (this.data.state == 1) { | ||||
return | 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, | check_type: 2, | ||||
user_phone: this.data.user_phone, | user_phone: this.data.user_phone, | ||||
code_num: this.data.code_num, | code_num: this.data.code_num, | ||||
coupon_sell_id: app.globalData.couponData.coupon_sell_id, | |||||
coupon_code: '', | coupon_code: '', | ||||
check_num: this.data.nums | 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({ | wx.switchTab({ | ||||
url: '../record/record' | 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 | |||||
}) | }) | ||||
} | |||||
}) | |||||
}, | }, | ||||
/** | /** | ||||
* 添加优惠券 | * 添加优惠券 | ||||
}) | }) | ||||
} | } | ||||
}, | }, | ||||
/** | |||||
* 返回核销大厅 | |||||
*/ | |||||
goHome(){ | |||||
wx.switchTab({ | |||||
url: '../home/home' | |||||
}) | |||||
}, | |||||
/** | /** | ||||
* 生命周期函数--监听页面加载 | * 生命周期函数--监听页面加载 | ||||
wx.hideShareMenu(); | wx.hideShareMenu(); | ||||
var code = options.code; | var code = options.code; | ||||
var pohone = options.phone; | var pohone = options.phone; | ||||
var couponData = app.globalData.couponData; | |||||
if (code) { //券码查询 | if (code) { //券码查询 | ||||
this.setData({ | 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) { //手机号查询 | if (pohone) { //手机号查询 | ||||
console.log(app.globalData.couponData) | |||||
var couponData = app.globalData.couponData; | |||||
this.setData({ | this.setData({ | ||||
type: 2, | type: 2, | ||||
user_phone: pohone, | user_phone: pohone, | ||||
totalNums: couponData.num, | totalNums: couponData.num, | ||||
coupon_name: couponData.coupon_name, | coupon_name: couponData.coupon_name, | ||||
couponTime: couponData.cdate | |||||
couponTime: couponData.buy_date | |||||
}) | }) | ||||
/** | /** | ||||
* 发送验证码 | * 发送验证码 |
<text class="txt1">{{coupon_name}}</text> | <text class="txt1">{{coupon_name}}</text> | ||||
<text class="txt2">购买时间:{{couponTime}}</text> | <text class="txt2">购买时间:{{couponTime}}</text> | ||||
</view> | </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> | </view> | ||||
<image class="logo" src="../../static/coupon/logo.png" wx:if="{{type==1}}"></image> | <image class="logo" src="../../static/coupon/logo.png" wx:if="{{type==1}}"></image> | ||||
</view> | </view> | ||||
<view class="middleContent shadow"> | <view class="middleContent shadow"> | ||||
<view id="couponCheck" class="relative clearfix" wx:if="{{type==1&&state!=2}}"> | <view id="couponCheck" class="relative clearfix" wx:if="{{type==1&&state!=2}}"> | ||||
<image class="couponIcon" src="../../static/coupon/couponIcon.png"></image> | <image class="couponIcon" src="../../static/coupon/couponIcon.png"></image> | ||||
<text class="number">078657</text> | |||||
<text class="number">券码:{{couponCode}}</text> | |||||
<view class="txt">此券有效</view> | <view class="txt">此券有效</view> | ||||
</view> | </view> | ||||
<view id="couponDetails" class="relative clearfix" wx:if="{{type==1&&state==2}}"> | <view id="couponDetails" class="relative clearfix" wx:if="{{type==1&&state==2}}"> | ||||
<view class="detailsItem"> | <view class="detailsItem"> | ||||
<view class="sign"></view> | <view class="sign"></view> | ||||
<text class="itemTitle">券码</text> | <text class="itemTitle">券码</text> | ||||
<text class="itemContent">H0001</text> | |||||
<text class="itemContent">{{couponCode}}</text> | |||||
</view> | </view> | ||||
<view class="detailsItem"> | <view class="detailsItem"> | ||||
<view class="sign"></view> | <view class="sign"></view> | ||||
<text class="itemTitle">类型</text> | <text class="itemTitle">类型</text> | ||||
<text class="itemContent">80元抵100元券</text> | |||||
<text class="itemContent">{{couponType}}</text> | |||||
</view> | </view> | ||||
<view class="detailsItem"> | <view class="detailsItem"> | ||||
<view class="sign"></view> | <view class="sign"></view> | ||||
<text class="itemTitle">时间</text> | <text class="itemTitle">时间</text> | ||||
<text class="itemContent">2020年02月25日</text> | |||||
<text class="itemContent">{{duration}}</text> | |||||
</view> | </view> | ||||
<view class="state">核销成功</view> | <view class="state">核销成功</view> | ||||
</view> | </view> | ||||
</view> | </view> | ||||
</view> | </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> | </view> |
text-align: center; | text-align: center; | ||||
color: #eb6100; | color: #eb6100; | ||||
font-size: 100rpx; | 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 { | .detailsBox>.detailsRight>.company { | ||||
color: #333; | color: #333; | ||||
font-size: 30rpx; | font-size: 30rpx; | ||||
margin-left: 10rpx; | |||||
margin-left: 5rpx; | |||||
} | } | ||||
.detailsBox>.logo { | .detailsBox>.logo { | ||||
} | } | ||||
#couponCheck>.number { | #couponCheck>.number { | ||||
position: absolute; | |||||
top: 144rpx; | |||||
left: 470rpx; | |||||
color: #eb6100; | |||||
font-size: 30rpx; | |||||
position: relative; | |||||
color: #666666; | |||||
font-size: 24rpx; | |||||
font-weight: 700; | font-weight: 700; | ||||
margin-left: 128rpx; | |||||
} | } | ||||
#couponCheck>.txt { | #couponCheck>.txt { | ||||
width: 100%; | width: 100%; | ||||
text-align: center; | text-align: center; | ||||
color: #eb6100; | |||||
color: #333333; | |||||
font-size: 40rpx; | font-size: 40rpx; | ||||
font-weight: 550; | font-weight: 550; | ||||
margin-top: 50rpx; | |||||
margin-top: 20rpx; | |||||
} | } | ||||
#couponDetails>.title { | #couponDetails>.title { |
*/ | */ | ||||
data: { | data: { | ||||
isQuerying: false, | isQuerying: false, | ||||
storeName: '', //店名 | |||||
}, | }, | ||||
/** | /** | ||||
* 核销查询 | * 核销查询 | ||||
return | return | ||||
} | } | ||||
var data = e.detail.value; | var data = e.detail.value; | ||||
if (data.code == '' && data.phone == '') { | |||||
if (data.phone.length != 11) { | |||||
wx.showToast({ | wx.showToast({ | ||||
title: '请输入内容后再查询', | |||||
icon: 'none', | |||||
duration: 2000 | |||||
}) | |||||
} else if (data.code != '' && data.phone != '') { | |||||
wx.showToast({ | |||||
title: '仅可选择一项查询', | |||||
title: '输入的手机号码有误', | |||||
icon: 'none', | icon: 'none', | ||||
duration: 2000 | duration: 2000 | ||||
}) | }) | ||||
return | |||||
} else { | } 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({ | this.setData({ | ||||
isQuerying: true | 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', { | app.requestGet('couponbuy/searchbyphone', { | ||||
user_phone: data.phone | user_phone: data.phone | ||||
}, res => { | }, res => { | ||||
app.globalData.couponData = res.data[0]; | app.globalData.couponData = res.data[0]; | ||||
app.globalData.couponToken = res.token; | app.globalData.couponToken = res.token; | ||||
wx.navigateTo({ | wx.navigateTo({ | ||||
url: '../coupon/coupon?' + key + '=' + value | |||||
url: '../coupon/coupon?phone=' + data.phone | |||||
}) | }) | ||||
} else { | } else { | ||||
wx.showToast({ | wx.showToast({ | ||||
} | } | ||||
}) | }) | ||||
}, | }, | ||||
/** | |||||
* 扫码 | |||||
*/ | |||||
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) { | onLoad: function(options) { | ||||
wx.hideShareMenu(); | wx.hideShareMenu(); | ||||
this.setData({ | |||||
storeName: app.globalData.storeData.shop_name | |||||
}) | |||||
}, | }, | ||||
/** | /** |
<view class="container"> | <view class="container"> | ||||
<image class="bg" src="../../static/home/bg.jpg" mode="aspectFill"></image> | <image class="bg" src="../../static/home/bg.jpg" mode="aspectFill"></image> | ||||
<image class="logo" src="../../static/home/logo.png"></image> | <image class="logo" src="../../static/home/logo.png"></image> | ||||
<view class="storeName">欢迎登录{{storeName}}</view> | |||||
<view class="fromBox"> | <view class="fromBox"> | ||||
<image class="arrow" src="../../static/home/arrow.png"></image> | |||||
<form bindsubmit="check"> | <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> | </form> | ||||
</view> | </view> | ||||
</view> | </view> |
margin-top: 74rpx; | margin-top: 74rpx; | ||||
} | } | ||||
.storeName { | |||||
color: #fffefe; | |||||
font-size: 40rpx; | |||||
font-weight: 600; | |||||
margin-top: 85rpx; | |||||
} | |||||
.fromBox { | .fromBox { | ||||
position: relative; | |||||
width: 600rpx; | 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; | border-radius: 30rpx; | ||||
margin-top: 116rpx; | |||||
margin-top: 30rpx; | |||||
} | |||||
.fromBox>.arrow { | |||||
position: absolute; | |||||
width: 33rpx; | |||||
height: 12rpx; | |||||
top: -11rpx; | |||||
left: 140rpx; | |||||
} | } | ||||
.fromBox input { | .fromBox input { | ||||
color: #fff; | color: #fff; | ||||
font-size: 30rpx; | font-size: 30rpx; | ||||
} | } | ||||
.query { | |||||
.btn{ | |||||
width: 522rpx; | width: 522rpx; | ||||
height: 98rpx; | height: 98rpx; | ||||
background: linear-gradient(-72deg, rgba(235, 97, 0, 1), rgba(255, 137, 42, 1)); | |||||
border-radius: 49rpx; | border-radius: 49rpx; | ||||
color: #ffffff; | |||||
color: #fff; | |||||
text-align: center; | text-align: center; | ||||
line-height: 98rpx; | line-height: 98rpx; | ||||
box-sizing: border-box; | 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; | |||||
} | } |
isLoginIng: false | isLoginIng: false | ||||
}) | }) | ||||
if(res.code==200){ | if(res.code==200){ | ||||
app.globalData.storeData = res.data; | |||||
wx.switchTab({ | wx.switchTab({ | ||||
url: '../home/home' | url: '../home/home' | ||||
}) | }) |
<image class="bg" src="../../static/record/bg.jpg"></image> | <image class="bg" src="../../static/record/bg.jpg"></image> | ||||
<view class="content"> | <view class="content"> | ||||
<view class="headBox"> | <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> | <image wx:else src="{{userInfo.avatarUrl}}" mode="aspectFill"></image> | ||||
</view> | </view> | ||||
<view class="userName" wx:if="{{userInfo}}">{{userInfo.nickName}}</view> | <view class="userName" wx:if="{{userInfo}}">{{userInfo.nickName}}</view> | ||||
<view class="details" wx:if="{{showIndex == 1}}" wx:for="{{data}}" wx:key="id"> | <view class="details" wx:if="{{showIndex == 1}}" wx:for="{{data}}" wx:key="id"> | ||||
<text class="time">{{item.cdate}}</text> | <text class="time">{{item.cdate}}</text> | ||||
<view class="infoBox"> | <view class="infoBox"> | ||||
<text>券码:{{item.coupon_code}}</text> | |||||
<text>券码:{{item.coupon_code}}</text> | |||||
<text>{{item.coupon_type}}</text> | <text>{{item.coupon_type}}</text> | ||||
</view> | </view> | ||||
</view> | </view> |
} | } | ||||
.item>.details>.infoBox{ | .item>.details>.infoBox{ | ||||
color: #999999; | color: #999999; | ||||
font-size: 24rpx; | |||||
font-size: 23rpx; | |||||
display: flex; | display: flex; | ||||
justify-content: space-between; | justify-content: space-between; | ||||
margin-top: 5rpx; | margin-top: 5rpx; |
//获取省份信息 | //获取省份信息 | ||||
app.requestGet('shop/shop_province', '', res => { | app.requestGet('shop/shop_province', '', res => { | ||||
if (res.code == 200) { | 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({ | this.setData({ | ||||
multiData: res.data, | multiData: res.data, | ||||
}) | }) | ||||
this.setData({ | this.setData({ | ||||
storeList: [] | storeList: [] | ||||
}) | }) | ||||
var city = this.data.showMultArray[1][this.data.multiIndex[1]] == '全部' ? '' : this.data.showMultArray[1][this.data.multiIndex[1]]; | |||||
var data = { | 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, | 'key': this.data.key, | ||||
'cur_page': this.data.cur_page, | 'cur_page': this.data.cur_page, | ||||
'show_num': this.data.show_num | 'show_num': this.data.show_num |