|
@@ -12,6 +12,11 @@ Page({
|
|
|
data: {
|
|
data: {
|
|
|
orders: [],
|
|
orders: [],
|
|
|
date: '',
|
|
date: '',
|
|
|
|
|
+ latitude: 0, //用户当前经度
|
|
|
|
|
+ longitude: 0, //用户当前纬度
|
|
|
|
|
+ stationName:'',//油站名
|
|
|
|
|
+ stationLatitude: 0, //站点经度
|
|
|
|
|
+ stationLongitude: 0, //站点纬度
|
|
|
startDate: '',
|
|
startDate: '',
|
|
|
endDate: '',
|
|
endDate: '',
|
|
|
pageNum: 1,//查询页码
|
|
pageNum: 1,//查询页码
|
|
@@ -152,10 +157,55 @@ Page({
|
|
|
endDate: lastMouthDay
|
|
endDate: lastMouthDay
|
|
|
});
|
|
});
|
|
|
console.log("历史页当前data", this.data)
|
|
console.log("历史页当前data", this.data)
|
|
|
|
|
+ this.getStationInfo();
|
|
|
|
|
+ // this.startCountdow();
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ /** 获取站点信息 */
|
|
|
|
|
+ getStationInfo() {
|
|
|
|
|
+ const that = this;
|
|
|
|
|
+ api.request_GetSiteInfo().then(res => {
|
|
|
|
|
+ if (res.data.statusCode == 203) {
|
|
|
|
|
+ //若为203,证明还未登录,跳转到登录页,这里可能刚从主页跳转过来,频繁的跳转可能会跳转页面超时,故而加上延时
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ wx.navigateTo({
|
|
|
|
|
+ url: '../login/login'
|
|
|
|
|
+ })
|
|
|
|
|
+ }, 500)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ console.log("站点信息", res)
|
|
|
|
|
+ const stationLocation = res.data.data.site.gpsCoordinates.split(",");
|
|
|
|
|
+ const name = res.data.data.site.name;
|
|
|
|
|
+
|
|
|
|
|
+ that.setData({
|
|
|
|
|
+ stationName:name,
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ if (stationLocation.length == 2) {
|
|
|
|
|
+ that.setData({
|
|
|
|
|
+ stationLatitude: stationLocation[0],
|
|
|
|
|
+ stationLongitude: stationLocation[1]
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // this.startCountdow();
|
|
|
|
|
|
|
+ this.getLocation();
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ /** 获取用户经纬度 */
|
|
|
|
|
+ getLocation() {
|
|
|
|
|
+ const that = this;
|
|
|
|
|
+ wx.getLocation({
|
|
|
|
|
+ type: 'wgs84',
|
|
|
|
|
+ success(res) {
|
|
|
|
|
+ console.log("获取经纬度结果", res)
|
|
|
|
|
+ that.setData({
|
|
|
|
|
+ latitude: res.latitude,
|
|
|
|
|
+ longitude: res.longitude
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -214,8 +264,11 @@ Page({
|
|
|
|
|
|
|
|
/** 日期选择器选择时间 */
|
|
/** 日期选择器选择时间 */
|
|
|
bindDateChange(date) {
|
|
bindDateChange(date) {
|
|
|
|
|
+ console.log("日期选择",date)
|
|
|
this.setData({
|
|
this.setData({
|
|
|
date: date.detail.value,
|
|
date: date.detail.value,
|
|
|
|
|
+ pageNum:1,
|
|
|
|
|
+ pageSize:5,
|
|
|
orders: []
|
|
orders: []
|
|
|
});
|
|
});
|
|
|
console.log(date)
|
|
console.log(date)
|
|
@@ -257,6 +310,70 @@ Page({
|
|
|
if (event.detail.event == "重新授权") {
|
|
if (event.detail.event == "重新授权") {
|
|
|
this.toAuthorization(event.detail.order.orderId)
|
|
this.toAuthorization(event.detail.order.orderId)
|
|
|
}
|
|
}
|
|
|
|
|
+ if(event.detail.event == "继续支付") {
|
|
|
|
|
+ this.toPay(event.detail.order.orderId)
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ /** 支付按钮点击事件 */
|
|
|
|
|
+ toPay(orderId) {
|
|
|
|
|
+ wx.showLoading({
|
|
|
|
|
+ title: '支付中',
|
|
|
|
|
+ })
|
|
|
|
|
+ this.subMessage(orderId)
|
|
|
|
|
+ },
|
|
|
|
|
+ /** 订阅消息模板 */
|
|
|
|
|
+ subMessage(orderId) {
|
|
|
|
|
+ const that = this;
|
|
|
|
|
+ wx.requestSubscribeMessage({
|
|
|
|
|
+ tmplIds: ['V0tl-4n-5hwNZc4SrEttvrmawAyM-SB0pQWZNwp54Ks'], // 最多支持3条
|
|
|
|
|
+ success(res) {
|
|
|
|
|
+ that.pay(orderId)
|
|
|
|
|
+ // 'accept'表示用户同意订阅该条id对应的模板消息
|
|
|
|
|
+ if (res['V0tl-4n-5hwNZc4SrEttvrmawAyM-SB0pQWZNwp54Ks'] === 'accept') {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ fail(err) {
|
|
|
|
|
+ that.pay(orderId)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ },
|
|
|
|
|
+ /** 实际支付 */
|
|
|
|
|
+ pay(orderId) {
|
|
|
|
|
+ const that = this;
|
|
|
|
|
+ api.request_wechatPay(orderId)
|
|
|
|
|
+ .then(res => {
|
|
|
|
|
+ wx.requestPayment({
|
|
|
|
|
+ timeStamp: res.data.data.unifiedOrderResult.timeStamp,
|
|
|
|
|
+ nonceStr: res.data.data.unifiedOrderResult.nonceStr,
|
|
|
|
|
+ package: res.data.data.unifiedOrderResult.package,
|
|
|
|
|
+ signType: res.data.data.unifiedOrderResult.signType,
|
|
|
|
|
+ paySign: res.data.data.unifiedOrderResult.paySign,
|
|
|
|
|
+ success: res => {
|
|
|
|
|
+ wx.hideLoading()
|
|
|
|
|
+ that.sendMessage(orderId)
|
|
|
|
|
+ that.refreshOrder()
|
|
|
|
|
+ },
|
|
|
|
|
+ fail: res => {
|
|
|
|
|
+ wx.hideLoading()
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ /** 发送消息模板 */
|
|
|
|
|
+ sendMessage(orderId) {
|
|
|
|
|
+ const message = {
|
|
|
|
|
+ trxid: orderId,
|
|
|
|
|
+ orderType: '支付'
|
|
|
|
|
+ }
|
|
|
|
|
+ api.request_sendMessage(message).then(res => {
|
|
|
|
|
+ console.log("发送消息模板结果", res)
|
|
|
|
|
+ }).catch(err => {
|
|
|
|
|
+ console.log("发送消息模板失败", err)
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
/** 授权 */
|
|
/** 授权 */
|
|
@@ -265,6 +382,13 @@ Page({
|
|
|
wx.showLoading({
|
|
wx.showLoading({
|
|
|
title: '授权中',
|
|
title: '授权中',
|
|
|
})
|
|
})
|
|
|
|
|
+ const distance = util.haversine(this.data.stationLatitude,this.data.stationLongitude,this.data.latitude,this.data.longitude);
|
|
|
|
|
+ if(distance > 500) {
|
|
|
|
|
+ wx.showToast({
|
|
|
|
|
+ title: '您不在油站范围内,请到油站时进行下单',
|
|
|
|
|
+ })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
api.request_NozzleAuthorization(orderId).then(res => {
|
|
api.request_NozzleAuthorization(orderId).then(res => {
|
|
|
console.log("授权", res)
|
|
console.log("授权", res)
|
|
|
wx.hideLoading()
|
|
wx.hideLoading()
|
|
@@ -289,8 +413,10 @@ Page({
|
|
|
title: '获取订单中',
|
|
title: '获取订单中',
|
|
|
})
|
|
})
|
|
|
const that = this;
|
|
const that = this;
|
|
|
- api.request_WXFindOrders(this.data.date, this.data.pageNum, this.data.pageSize).then(res => {
|
|
|
|
|
|
|
+ const findTime = this.data.date != '' ? this.data.date + "T23:59:59" : this.data.date;
|
|
|
|
|
+ api.request_WXFindOrders(findTime, this.data.pageNum, this.data.pageSize).then(res => {
|
|
|
wx.hideLoading()
|
|
wx.hideLoading()
|
|
|
|
|
+ wx.stopPullDownRefresh()
|
|
|
// api.request_WXFindOrders(this.data.date, 3, 5).then(res => {
|
|
// api.request_WXFindOrders(this.data.date, 3, 5).then(res => {
|
|
|
console.log("获取历史订单", res)
|
|
console.log("获取历史订单", res)
|
|
|
let datas = res.data.data;
|
|
let datas = res.data.data;
|
|
@@ -331,7 +457,7 @@ Page({
|
|
|
//获取订单状态
|
|
//获取订单状态
|
|
|
var status = undefined;
|
|
var status = undefined;
|
|
|
//根据不同的模式获取订单状态值
|
|
//根据不同的模式获取订单状态值
|
|
|
- if (that.data.paymentMode == 0) {
|
|
|
|
|
|
|
+ if (order.orderType == 0) {
|
|
|
status = that.data.payStatusValue.find(state => state.orderStatus == order.orderStatus)
|
|
status = that.data.payStatusValue.find(state => state.orderStatus == order.orderStatus)
|
|
|
} else {
|
|
} else {
|
|
|
status = that.data.prepayStatuValue.find(state =>
|
|
status = that.data.prepayStatuValue.find(state =>
|
|
@@ -348,7 +474,7 @@ Page({
|
|
|
stute = status.status
|
|
stute = status.status
|
|
|
stateColor = status.statusColor
|
|
stateColor = status.statusColor
|
|
|
}
|
|
}
|
|
|
- if (that.data.paymentMode == 0) {
|
|
|
|
|
|
|
+ if (order.orderType == 0) {
|
|
|
if (stute == '未支付') bt2 = '重新支付';
|
|
if (stute == '未支付') bt2 = '重新支付';
|
|
|
return {
|
|
return {
|
|
|
order: {
|
|
order: {
|
|
@@ -362,9 +488,11 @@ Page({
|
|
|
discount: order.originalAmount - order.actualPaymentAmount,
|
|
discount: order.originalAmount - order.actualPaymentAmount,
|
|
|
orderId: order.id,
|
|
orderId: order.id,
|
|
|
time: time,
|
|
time: time,
|
|
|
- price: order.price
|
|
|
|
|
|
|
+ price: order.price,
|
|
|
|
|
+ station:that.data.stationName
|
|
|
},
|
|
},
|
|
|
- bottonText2: bt2
|
|
|
|
|
|
|
+ bottonText2: bt2,
|
|
|
|
|
+ orderType:order.orderType
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
if (stute == "授权成功") bt2 = "请尽快提枪"
|
|
if (stute == "授权成功") bt2 = "请尽快提枪"
|
|
@@ -388,10 +516,12 @@ Page({
|
|
|
discount: order.originalAmount - order.actualPaymentAmount,
|
|
discount: order.originalAmount - order.actualPaymentAmount,
|
|
|
refund: order.refundAmount,
|
|
refund: order.refundAmount,
|
|
|
orderId: order.id,
|
|
orderId: order.id,
|
|
|
- time: time
|
|
|
|
|
|
|
+ time: time,
|
|
|
|
|
+ station:that.data.stationName
|
|
|
},
|
|
},
|
|
|
bottonText1: bt1,
|
|
bottonText1: bt1,
|
|
|
- bottonText2: bt2
|
|
|
|
|
|
|
+ bottonText2: bt2,
|
|
|
|
|
+ orderType:order.orderType
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
@@ -403,6 +533,8 @@ Page({
|
|
|
refreshOrder() {
|
|
refreshOrder() {
|
|
|
this.setData({
|
|
this.setData({
|
|
|
date: '',
|
|
date: '',
|
|
|
|
|
+ pageNum:1,
|
|
|
|
|
+ pageSize:5,
|
|
|
orders: []
|
|
orders: []
|
|
|
});
|
|
});
|
|
|
console.log(this.data.date)
|
|
console.log(this.data.date)
|