|
|
|
|
// pages/user/order/sceneOrderInfo/index.js
|
|
|
|
|
import commonApi from "../../../../utils/https/common"
|
|
|
|
|
import QRCode from '../../../../utils/weapp-qrcode.js'
|
|
|
|
|
import util from "../../../../utils/util"
|
|
|
|
|
let app = getApp(),timer;
|
|
|
|
|
Page({
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面的初始数据
|
|
|
|
|
*/
|
|
|
|
|
data: {
|
|
|
|
|
info:null,
|
|
|
|
|
orderState:app.globalData.orderState,
|
|
|
|
|
productState:app.globalData.productState,
|
|
|
|
|
product_model:null,
|
|
|
|
|
isRefund:false,
|
|
|
|
|
feeInfoFlag:false,
|
|
|
|
|
codeIndex:0,
|
|
|
|
|
codeImgs:[],
|
|
|
|
|
id:null,
|
|
|
|
|
minute:"",
|
|
|
|
|
second:"",
|
|
|
|
|
ids:[],
|
|
|
|
|
|
|
|
|
|
showKeFuFlag: false,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
|
*/
|
|
|
|
|
onLoad: function (options) {
|
|
|
|
|
this.setData({
|
|
|
|
|
id:options.id
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
getCodeImg:function(){
|
|
|
|
|
let that = this,sys =wx.getSystemInfoSync(),radio = sys.screenWidth / 750,qrcode=this.data.info.order_product_list[0].qrcode,codeImgs=[];
|
|
|
|
|
qrcode.map((item,index)=>{
|
|
|
|
|
if(item.use_url){
|
|
|
|
|
codeImgs.push(item.use_url);
|
|
|
|
|
if(codeImgs.length==qrcode.length){
|
|
|
|
|
that.setData({
|
|
|
|
|
codeImgs:codeImgs
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
new QRCode('damocode'+index,{
|
|
|
|
|
text: item.use_code,
|
|
|
|
|
width: 300 * radio,
|
|
|
|
|
height: 300 * radio,
|
|
|
|
|
padding: 12, // 生成二维码四周自动留边宽度,不传入默认为0
|
|
|
|
|
correctLevel: QRCode.CorrectLevel.L, // 二维码可辨识度
|
|
|
|
|
callback: (res) => {
|
|
|
|
|
codeImgs.push(res.path);
|
|
|
|
|
if(codeImgs.length==qrcode.length){
|
|
|
|
|
that.setData({
|
|
|
|
|
codeImgs:codeImgs
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
prevCodeImg:function(){
|
|
|
|
|
let qrcode=this.data.info.order_product_list[0].qrcode,codeIndex = this.data.codeIndex;
|
|
|
|
|
if(codeIndex==0){
|
|
|
|
|
this.setData({
|
|
|
|
|
codeIndex:qrcode.length-1
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this.setData({
|
|
|
|
|
codeIndex:codeIndex-1
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
nextCodeImg:function(){
|
|
|
|
|
let qrcode=this.data.info.order_product_list[0].qrcode,codeIndex = this.data.codeIndex;
|
|
|
|
|
codeIndex = codeIndex + 1;
|
|
|
|
|
if(codeIndex==qrcode.length){
|
|
|
|
|
codeIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
this.setData({
|
|
|
|
|
codeIndex:codeIndex
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
showFeeInfo:function(){
|
|
|
|
|
this.setData({
|
|
|
|
|
feeInfoFlag:!this.data.feeInfoFlag
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
showKeFu: function(){
|
|
|
|
|
this.setData({
|
|
|
|
|
showKeFuFlag:!this.data.showKeFuFlag
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
close:function(){
|
|
|
|
|
let _this = this,info = _this.data.info;
|
|
|
|
|
wx.showModal({
|
|
|
|
|
title:'提示',
|
|
|
|
|
content:"确定取消吗",
|
|
|
|
|
success:function(res){
|
|
|
|
|
if(res.confirm){
|
|
|
|
|
commonApi.user_post("order/close",{
|
|
|
|
|
order_id:info.order_id
|
|
|
|
|
}).then(res=>{
|
|
|
|
|
if(res.code==1){
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '取消成功',
|
|
|
|
|
icon:'success'
|
|
|
|
|
})
|
|
|
|
|
info.state = "CLOSED";
|
|
|
|
|
info.order_product_list.map(item=>{
|
|
|
|
|
item.state='CLOSED'
|
|
|
|
|
})
|
|
|
|
|
_this.setData({
|
|
|
|
|
info:info
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
refund:function(){
|
|
|
|
|
let _this = this,info = _this.data.info;
|
|
|
|
|
wx.showModal({
|
|
|
|
|
title:'提示',
|
|
|
|
|
content:"确定取消吗",
|
|
|
|
|
success:function(res){
|
|
|
|
|
if(res.confirm){
|
|
|
|
|
commonApi.user_post("order/refund",{
|
|
|
|
|
order_id:info.order_id
|
|
|
|
|
}).then(res=>{
|
|
|
|
|
if(res.code==1){
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '取消成功',
|
|
|
|
|
icon:'success'
|
|
|
|
|
})
|
|
|
|
|
info.state = "WAIT_REFUND";
|
|
|
|
|
info.order_product_list.map(item=>{
|
|
|
|
|
item.state='WAIT_REFUND'
|
|
|
|
|
})
|
|
|
|
|
_this.setData({
|
|
|
|
|
info:info
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 查看苏康码
|
|
|
|
|
gotoSku:function(){
|
|
|
|
|
commonApi.user_post("pbservice/Ztfw/sukangCode").then(res=>{
|
|
|
|
|
console.log(res)
|
|
|
|
|
app.globalData.weburl = res.data.url;
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/pbService/web/index'
|
|
|
|
|
})
|
|
|
|
|
return;
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
|
*/
|
|
|
|
|
onReady: function () {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
|
*/
|
|
|
|
|
onShow: function () {
|
|
|
|
|
commonApi.user_post("order/query",{
|
|
|
|
|
order_id:this.data.id
|
|
|
|
|
}).then(res=>{
|
|
|
|
|
if(res.data.create_time && res.data.auto_close_time && res.data.state=='UNPAID'){
|
|
|
|
|
let time = (new Date(res.data.create_time.replace(/-/g,'/')).getTime() + Number(res.data.auto_close_time) * 1000);
|
|
|
|
|
this.daojishi(time);
|
|
|
|
|
}
|
|
|
|
|
let proId = []
|
|
|
|
|
res.data.order_product_list.forEach(item => {
|
|
|
|
|
proId.push(item.product_id)
|
|
|
|
|
})
|
|
|
|
|
let state = ""
|
|
|
|
|
res.data.order_product_list.map(order=>{
|
|
|
|
|
order.qrcode.map(item=>{
|
|
|
|
|
item.stateText = app.globalData.codeState[item.state];
|
|
|
|
|
})
|
|
|
|
|
order.contacts_info = order.contacts_info?JSON.parse(order.contacts_info):[];
|
|
|
|
|
state = state + order.state;
|
|
|
|
|
})
|
|
|
|
|
this.setData({
|
|
|
|
|
isRefund:state.indexOf("REFUND")!=-1,
|
|
|
|
|
info:res.data,
|
|
|
|
|
product_model:res.data.order_product_list[0].product_model,
|
|
|
|
|
ids: proId.join(",")
|
|
|
|
|
})
|
|
|
|
|
this.getCodeImg()
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
daojishi:function(time){
|
|
|
|
|
let now = new Date().getTime();
|
|
|
|
|
if(now>time){
|
|
|
|
|
clearTimeout(timer);
|
|
|
|
|
timer = null;
|
|
|
|
|
util.back();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let times = time - now,minute = Math.floor(times / (60 * 1000)),second = Math.round((times - minute * 60 * 1000) / 1000);
|
|
|
|
|
this.setData({
|
|
|
|
|
minute:util.formatNumber(minute),
|
|
|
|
|
second:util.formatNumber(second)
|
|
|
|
|
})
|
|
|
|
|
timer = setTimeout(()=>{
|
|
|
|
|
this.daojishi(time);
|
|
|
|
|
},1000)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
|
*/
|
|
|
|
|
onHide: function () {
|
|
|
|
|
clearTimeout(timer);
|
|
|
|
|
timer = null
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
|
*/
|
|
|
|
|
onUnload: function () {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
|
*/
|
|
|
|
|
onPullDownRefresh: function () {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
|
*/
|
|
|
|
|
onReachBottom: function () {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|