beefast-mini-merchant/pages/index/index/index.js
2025-03-31 20:29:13 +08:00

106 lines
1.6 KiB
JavaScript

import userApi from '../../../api/user';
import orderApi from '../../../api/order';
Page({
/**
* 页面的初始数据
*/
data: {
isShowVerify:false,
verifyData:{},
verifyCode:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
userApi.summary()
},
scanQRCode(){
wx.scanCode({
onlyFromCamera:true,
scanType:'qrCode',
success:(res)=>{
if(res.scanType=='QR_CODE'){
orderApi.queryVerifyCode(res.result).then((data)=>{
if(data.order){
this.setData({
verifyData:data,
verifyCode:res.result,
isShowVerify:true
})
}
})
}else{
wx.showToast({
icon:'none',
title: '核销码错误'
})
}
}
})
},
verify(){
orderApi.verify(this.data.verifyCode).then((data)=>{
this.setData({
isShowVerify:false
});
wx.showToast({
title: '核销成功'
});
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})