Commit 8a6c0bca authored by 黄奎's avatar 黄奎

11

parent 839cd538
......@@ -443,7 +443,7 @@
</view>
<view style="display: flex; margin-top: -2px">
<button class="jz_OrderReNow" @click="goPay()" :disabled="submit" :loading="submit">
立即支付
立即预定
</button>
</view>
</view>
......
<style>
.jz_SureOrder {
.jz_SureOrder {
position: relative;
}
.jz_SureTop {
......@@ -329,660 +329,559 @@
}
</style>
<template>
<view class="jz_Reserve" v-if="orderData">
<view class="jz_ReserTop">
<view class="flex" style="margin-bottom: 30rpx">
<u-icon
customPrefix="iconfont"
name="icondaizhifu-"
size="52"
color="#DFBE6E"
v-if="orderStatus.code == 0"
></u-icon>
<u-icon
customPrefix="iconfont"
name="iconquxiao"
size="52"
color="#f26c6c"
v-if="orderStatus.code == -1"
></u-icon>
<u-icon
customPrefix="iconfont"
name="iconshenhezhong"
size="52"
color="#86d9a5"
v-if="orderStatus.code == -2"
></u-icon>
<u-icon
customPrefix="iconfont"
name="iconzhengchang"
size="52"
color="#111"
v-if="orderStatus.code == 1"
></u-icon>
<text
style="
<view class="jz_Reserve" v-if="orderData">
<view class="jz_ReserTop">
<view class="flex" style="margin-bottom: 30rpx">
<u-icon customPrefix="iconfont" name="icondaizhifu-" size="52" color="#DFBE6E" v-if="orderStatus.code == 0"></u-icon>
<u-icon customPrefix="iconfont" name="iconquxiao" size="52" color="#f26c6c" v-if="orderStatus.code == -1"></u-icon>
<u-icon customPrefix="iconfont" name="iconshenhezhong" size="52" color="#86d9a5" v-if="orderStatus.code == -2"></u-icon>
<u-icon customPrefix="iconfont" name="iconzhengchang" size="52" color="#111" v-if="orderStatus.code == 1"></u-icon>
<text style="
margin-left: 26rpx;
font-size: 40rpx;
font-weight: 600;
color: #111;
"
>
{{ orderStatus.text }}
</text>
</view>
<view
style="margin-bottom: 30rpx"
v-if="
">
{{ orderStatus.text }}
</text>
</view>
<view style="margin-bottom: 30rpx" v-if="
orderData.model.RejectRemark && orderData.model.RejectRemark != ''
"
>
<u-alert-tips
type="error"
title="订单取消失败"
:description="orderData.model.RejectRemark"
></u-alert-tips>
</view>
<view class="o-timer flex">
<view class="time-item"
>{{ getDate(orderData.model.StartDate) }}
{{ getWeek(orderData.model.StartDate) }}</view
>
<view class="time-split">
<view>{{ orderData.model.DayNum }}</view>
</view>
<view
class="time-item"
style="font-size: 26rpx; font-weight: 500; flex: 1"
>
<text v-if="orderData.model.ManNum > 0"
>{{ orderData.model.ManNum }}成人</text
>
<text v-if="orderData.model.ChirdNum > 0"
>{{ orderData.model.ChirdNum }}儿童</text
>
<text v-if="orderData.model.BabyNum > 0"
>{{ orderData.model.BabyNum }}婴儿</text
>
</view>
<view class="update">
<!-- <text style="margin-right: 8rpx;">修改</text>
">
<u-alert-tips type="error" title="订单取消失败" :description="orderData.model.RejectRemark"></u-alert-tips>
</view>
<view class="o-timer flex">
<view class="time-item">{{ getDate(orderData.model.StartDate) }}
{{ getWeek(orderData.model.StartDate) }}</view>
<view class="time-split">
<view>{{ orderData.model.DayNum }}</view>
</view>
<view class="time-item" style="font-size: 26rpx; font-weight: 500; flex: 1">
<text v-if="orderData.model.ManNum > 0">{{ orderData.model.ManNum }}成人</text>
<text v-if="orderData.model.ChirdNum > 0">{{ orderData.model.ChirdNum }}儿童</text>
<text v-if="orderData.model.BabyNum > 0">{{ orderData.model.BabyNum }}婴儿</text>
</view>
<view class="update">
<!-- <text style="margin-right: 8rpx;">修改</text>
<u-icon name="arrow" size="20" /> -->
</view>
</view>
<view class="jz_ReserTitle">
{{ orderData.model.Title }}
</view>
<view class="jz_ReserIn" style="margin: 33rpx 0 18rpx 0">
<!-- {{currentPriceInfo.startCityName}}出发 {{currentPriceInfo.startDate}} -->
{{ orderData.model.LtName }}
</view>
<view class="big-title" v-if="orderData.model.StartCityName">
<text>{{ orderData.model.StartCityName }}出发</text>
</view>
<view class="jz_ReseQue">
<img
src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/CustomizedCar/zuanshi.png"
/>即时确认:本产品付款后可快速确认,放心期待您的旅行
</view>
</view>
</view>
</view>
<view class="jz_ReserTitle">
{{ orderData.model.Title }}
</view>
<view class="jz_ReserIn" style="margin: 33rpx 0 18rpx 0">
<!-- {{currentPriceInfo.startCityName}}出发 {{currentPriceInfo.startDate}} -->
{{ orderData.model.LtName }}
</view>
<view class="big-title" v-if="orderData.model.StartCityName">
<text>{{ orderData.model.StartCityName }}出发</text>
</view>
<view class="jz_ReseQue">
<img src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/CustomizedCar/zuanshi.png" />即时确认:本产品付款后可快速确认,放心期待您的旅行
</view>
</view>
<view class="jz_form">
<view class="form-items">
<view class="label">订单编号</view>
<view class="jz_SureVal">
{{ orderData.model.OrderId }}
</view>
</view>
<view class="form-items">
<view class="label">下单日期</view>
<view class="jz_SureVal">
{{ orderData.model.CreateDate.replace("T", " ") }}
</view>
</view>
<view class="form-items">
<view class="label">下单日期</view>
<view class="jz_SureVal">
{{ orderData.model.CreateDate.replace("T", " ") }}
</view>
</view>
</view>
<view class="empty-block"></view>
<view
class="jz_form jz_MyGuestList"
v-for="(subItem, subIndex) in orderData.model.GuestList"
:key="subIndex"
>
<view style="margin: 10rpx 0 20rpx 0"> 游客{{ subIndex + 1 }} </view>
<view class="form-items">
<view class="label">游客姓名</view>
<view class="jz_SureVal">{{ subItem.SurName }}{{ subItem.Name }}</view>
</view>
<view class="form-items">
<view class="label">联系电话</view>
<view class="jz_SureVal">{{ subItem.MobilePhone }}</view>
</view>
<view class="form-items">
<view class="label">身份证</view>
<view class="jz_SureVal">{{ subItem.IdCard }}</view>
</view>
<view class="form-items">
<view class="label">学生</view>
<view class="jz_SureVal">
{{ subItem.IsHightSchool == 1 ? "是" : "否" }}
</view>
</view>
</view>
<view class="empty-block"></view>
<view class="jz_form" v-if="orderData.model.Remarks">
<view class="form-items" style="border-bottom: 0">
<view class="label">备注</view>
<view class="jz_SureVal">{{ orderData.model.Remarks }}</view>
</view>
</view>
<view class="empty-block"></view>
<view style="padding: 50rpx 40rpx">
<view class="big-title">
<text>费用明细</text>
</view>
<view class="jz_form" style="margin: 40rpx 0; padding: 0">
<view class="form-items">
<view class="label"> 在线支付 </view>
<view class="val f14 regular" style="text-align: right">
<text style="margin-right: 30rpx"
>{{ orderData.model.GuestNum }}</text
>
<text class="red">{{ orderData.model.PreferPrice }}</text>
</view>
</view>
<view class="form-items" style="border-bottom: none">
<view class="label"> 明细 </view>
</view>
<view class="flex f12 grey" style="margin-bottom: 40rpx" :key="index">
<view style="flex: 1">
<text style="margin-right: 30rpx">成人</text>
</view>
<view style="text-align: right"
>{{ orderData.model.ManNum }}人 × ¥{{
<view class="jz_form">
<view class="form-items">
<view class="label">订单编号</view>
<view class="jz_SureVal">
{{ orderData.model.OrderId }}
</view>
</view>
<view class="form-items">
<view class="label">下单日期</view>
<view class="jz_SureVal">
{{ orderData.model.CreateDate.replace("T", " ") }}
</view>
</view>
<view class="form-items">
<view class="label">下单日期</view>
<view class="jz_SureVal">
{{ orderData.model.CreateDate.replace("T", " ") }}
</view>
</view>
</view>
<view class="empty-block"></view>
<view class="jz_form jz_MyGuestList" v-for="(subItem, subIndex) in orderData.model.GuestList" :key="subIndex">
<view style="margin: 10rpx 0 20rpx 0"> 游客{{ subIndex + 1 }} </view>
<view class="form-items">
<view class="label">游客姓名</view>
<view class="jz_SureVal">{{ subItem.SurName }}{{ subItem.Name }}</view>
</view>
<view class="form-items">
<view class="label">联系电话</view>
<view class="jz_SureVal">{{ subItem.MobilePhone }}</view>
</view>
<view class="form-items">
<view class="label">身份证</view>
<view class="jz_SureVal">{{ subItem.IdCard }}</view>
</view>
<view class="form-items">
<view class="label">学生</view>
<view class="jz_SureVal">
{{ subItem.IsHightSchool == 1 ? "是" : "否" }}
</view>
</view>
</view>
<view class="empty-block"></view>
<view class="jz_form" v-if="orderData.model.Remarks">
<view class="form-items" style="border-bottom: 0">
<view class="label">备注</view>
<view class="jz_SureVal">{{ orderData.model.Remarks }}</view>
</view>
</view>
<view class="empty-block"></view>
<view style="padding: 50rpx 40rpx">
<view class="big-title">
<text>费用明细</text>
</view>
<view class="jz_form" style="margin: 40rpx 0; padding: 0">
<view class="form-items">
<view class="label"> 在线支付 </view>
<view class="val f14 regular" style="text-align: right">
<text style="margin-right: 30rpx">{{ orderData.model.GuestNum }}</text>
<text class="red">{{ orderData.model.PreferPrice }}</text>
</view>
</view>
<view class="form-items" style="border-bottom: none">
<view class="label"> 明细 </view>
</view>
<view class="flex f12 grey" style="margin-bottom: 40rpx" :key="index">
<view style="flex: 1">
<text style="margin-right: 30rpx">成人</text>
</view>
<view style="text-align: right">{{ orderData.model.ManNum }}人 × ¥{{
orderData.model.Unit_Price
}}</view
>
</view>
<view
class="flex f12 grey"
style="margin-bottom: 40rpx"
:key="index"
v-if="orderData.model.ChirdNeedBedNum > 0"
>
<view style="flex: 1">
<text style="margin-right: 30rpx">儿童(占床)</text>
</view>
<view style="text-align: right"
>{{ orderData.model.ChirdNeedBedNum }}人 × ¥{{
}}</view>
</view>
<view class="flex f12 grey" style="margin-bottom: 40rpx" :key="index" v-if="orderData.model.ChirdNeedBedNum > 0">
<view style="flex: 1">
<text style="margin-right: 30rpx">儿童(占床)</text>
</view>
<view style="text-align: right">{{ orderData.model.ChirdNeedBedNum }}人 × ¥{{
orderData.model.Unit_Price +
(orderData.modelPrice.ChildNeedPrice
? orderData.modelPrice.ChildNeedPrice
: 0)
}}</view
>
</view>
<view
class="flex f12 grey"
style="margin-bottom: 40rpx"
:key="index"
v-if="orderData.model.ChirdNum - orderData.model.ChirdNeedBedNum > 0"
>
<view style="flex: 1">
<text style="margin-right: 30rpx">儿童(不占床)</text>
</view>
<view style="text-align: right"
>{{ orderData.model.ChirdNum - orderData.model.ChirdNeedBedNum }}
× ¥{{
}}</view>
</view>
<view class="flex f12 grey" style="margin-bottom: 40rpx" :key="index" v-if="orderData.model.ChirdNum - orderData.model.ChirdNeedBedNum > 0">
<view style="flex: 1">
<text style="margin-right: 30rpx">儿童(不占床)</text>
</view>
<view style="text-align: right">{{ orderData.model.ChirdNum - orderData.model.ChirdNeedBedNum }}
× ¥{{
orderData.model.Unit_Price -
(orderData.modelPrice.ChildNoNeedPrice
? orderData.modelPrice.ChildNoNeedPrice
: 0)
}}</view
>
</view>
<view
class="flex f12 grey"
style="margin-bottom: 40rpx"
:key="index"
v-if="orderData.model.BabyNum > 0"
>
<view style="flex: 1">
<text style="margin-right: 30rpx">婴儿</text>
</view>
<view style="text-align: right">
{{ orderData.model.BabyNum }}人 × ¥{{
}}</view>
</view>
<view class="flex f12 grey" style="margin-bottom: 40rpx" :key="index" v-if="orderData.model.BabyNum > 0">
<view style="flex: 1">
<text style="margin-right: 30rpx">婴儿</text>
</view>
<view style="text-align: right">
{{ orderData.model.BabyNum }}人 × ¥{{
orderData.modelPrice.BabyPrice
? orderData.modelPrice.BabyPrice
: 0
}}</view
>
</view>
<view
class="flex f12 grey"
style="margin-bottom: 40rpx"
:key="index"
v-if="
}}</view>
</view>
<view class="flex f12 grey" style="margin-bottom: 40rpx" :key="index" v-if="
orderData.model.ChirdNum > 0 &&
orderData.modelPrice.BabyChargePrice &&
orderData.modelPrice.BabyChargePrice > 0
"
>
<view style="flex: 1">
<text style="margin-right: 30rpx">儿童(附加费)</text>
</view>
<view style="text-align: right">
{{ orderData.model.ChirdNum }}人 × ¥{{
">
<view style="flex: 1">
<text style="margin-right: 30rpx">儿童(附加费)</text>
</view>
<view style="text-align: right">
{{ orderData.model.ChirdNum }}人 × ¥{{
orderData.modelPrice.BabyChargePrice
}}</view
>
</view>
</view>
</view>
<view class="empty-block"></view>
<view
style="padding: 50rpx 40rpx"
v-if="Refund > 0 && orderStatus.code == -1"
>
<view class="big-title">
<text>取消订单</text>
</view>
<view class="jz_form" style="margin: 40rpx 0; padding: 0">
<view class="form-items">
<view class="label"> 已退款总额 </view>
<view class="val f14 regular" style="text-align: right">
<text style="margin-right: 30rpx"
>{{ orderData.model.GuestNum }}</text
>
<text class="red">{{ orderData.model.PreferPrice }}</text>
</view>
</view>
</view>
</view>
<view class="jz_orderbox flex">
<view style="display: flex" v-if="showPayBtn">
<view
class="jz_OrderReNow"
@click="goCancel"
style="background: #fff; color: #111; border: 1px solid #111"
>
<text v-if="!submitCancel">取消</text>
<u-loading v-if="submitCancel" size="32" color="#111"></u-loading>
</view>
<!-- 返回上一页 -->
<!-- <view
}}</view>
</view>
</view>
</view>
<view class="empty-block"></view>
<view style="padding: 50rpx 40rpx" v-if="Refund > 0 && orderStatus.code == -1">
<view class="big-title">
<text>取消订单</text>
</view>
<view class="jz_form" style="margin: 40rpx 0; padding: 0">
<view class="form-items">
<view class="label"> 已退款总额 </view>
<view class="val f14 regular" style="text-align: right">
<text style="margin-right: 30rpx">{{ orderData.model.GuestNum }}</text>
<text class="red">{{ orderData.model.PreferPrice }}</text>
</view>
</view>
</view>
</view>
<view class="jz_orderbox flex">
<view style="display: flex" v-if="showPayBtn">
<view class="jz_OrderReNow" @click="goCancel" style="background: #fff; color: #111; border: 1px solid #111">
<text v-if="!submitCancel">取消</text>
<u-loading v-if="submitCancel" size="32" color="#111"></u-loading>
</view>
<!-- 返回上一页 -->
<!-- <view
class="jz_OrderReNow"
@click="goback"
style="background: #fff; color: #111; border: 1px solid #111"
v-if="!showPayBtn"
>关闭
</view> -->
</view>
<view style="display: flex; margin-left: 30rpx">
<!-- #ifdef MP-WEIXIN -->
<button
class="jz_OrderReNow"
@click="goFukuan"
v-if="showPayBtn"
:disabled="submit"
>
立即支付
</button>
<!-- #endif -->
<!-- #ifdef MP-ALIPAY -->
<button
class="jz_OrderReNow"
@click="goZhifuAli"
v-if="showPayBtn"
:disabled="submit"
>
立即支付
</button>
<!-- #endif -->
</view>
</view>
<!-- #ifdef MP-ALIPAY -->
<subscribe-msg />
<!-- #endif -->
</view>
</view>
<view style="display: flex; margin-left: 30rpx">
<!-- #ifdef MP-WEIXIN -->
<!-- <button class="jz_OrderReNow" @click="goFukuan" v-if="showPayBtn" :disabled="submit">
立即支付
</button> -->
<!-- #endif -->
<!-- #ifdef MP-ALIPAY -->
<!-- <button class="jz_OrderReNow" @click="goZhifuAli" v-if="showPayBtn" :disabled="submit">
立即支付
</button> -->
<!-- #endif -->
</view>
</view>
<!-- #ifdef MP-ALIPAY -->
<subscribe-msg />
<!-- #endif -->
</view>
</template>
<script>
</script>
<script>
export default {
components: {},
data() {
return {
pageTitle: "订单详情",
msg: {
pageIndex: 1,
pageSize: 15,
MiniAppUserId: 0,
},
orderData: null,
orderStatus: {},
submit: false,
submitCancel: false,
showPayBtn: true,
};
},
created() {},
onLoad(option) {
if (option.orderData) {
this.orderData = JSON.parse(decodeURIComponent(option.orderData));
} else if (option.orderId) {
this.initOrderInfo(option.orderId);
}
},
methods: {
goback() {
uni.navigateBack({
delta: 1,
});
},
goCancel() {
if (this.submit || this.submitCancel) return;
//未付款-调用后台取消
if (this.orderData.model.OrderState == 2) {
this.apipost(
"sellorder_post_B2BRemoveOrder",
{
ID: this.orderData.model.OrderId,
},
(res) => {
if (res.resultCode == 1) {
uni.showToast({
title: "操作成功",
icon: "success",
});
uni.navigateTo({
url: "/pages/jiuzhai/jz_MyOrder",
});
}
},
(err) => {}
);
} else {
let msg = {
OrderId: this.orderData.model.OrderId,
UserId: uni.getStorageSync("mall_UserInfo").UserId,
};
//已付款取消申请
this.apipost(
"sellorder_post_AppletUserCancelOrder",
msg,
(res) => {
if (res.resultCode == 1) {
uni.showToast({
title: "操作成功",
icon: "success",
});
uni.navigateTo({
url: "/pages/jiuzhai/jz_MyOrder",
});
} else {
}
},
null
);
}
},
getWeek(date) {
var weekArray = new Array("日", "一", "二", "三", "四", "五", "六");
var week = weekArray[new Date(date).getDay()]; //注意此处必须是先new一个Date
return "周" + week;
},
getDate(date) {
if (date) {
let arr = date.split("-");
return arr[1] + "月" + arr[2] + "日";
}
},
initOrderInfo(orderId) {
let msg = {
ID: orderId,
IsGetGuest: 1,
};
this.apipost(
"sellorder_post_GetOrderEntity",
msg,
(res) => {
if (res.resultCode == 1) {
this.orderData = res.data;
this.formatStatus(
this.orderData.model.OrderState,
this.orderData.model.IsChargeLossOrders,
this.orderData.model.IsApplyForCancel
);
} else {
this.orderData = {
result: -1,
};
}
console.log(res);
},
(e) => {}
);
},
formatStatus(status, loss, isCancel) {
loss = loss ? loss : -1;
//1、已申请;!=1未申请
if (loss == 1 || status == 4) {
this.orderStatus.code = -1;
this.orderStatus.text = "已取消";
this.showPayBtn = false;
} else if (status == 2 && isCancel != 1) {
this.orderStatus.code = 0;
this.orderStatus.text = "待付款";
this.showPayBtn = true;
} else if (status == 2 && isCancel == 1) {
this.orderStatus.code = -2;
this.orderStatus.text = "审核中";
this.showPayBtn = false;
} else if (status == 1) {
this.orderStatus.code = 1;
this.orderStatus.text = "正常";
this.showPayBtn = false;
}
},
// #ifdef MP-WEIXIN
goFukuan() {
if (this.submit || this.submitCancel) return;
var that = this;
var tempObj = uni.getStorageSync("basedata")?.mall?.wechatmessage ?? [];
var tmplIds = [];
if (tempObj && tempObj.length > 0) {
tempObj.forEach((x) => {
if (x.Name == "下单成功提醒" || x.Name == "订单取消提醒") {
tmplIds.push(x.MessageId);
}
});
}
uni.requestSubscribeMessage({
tmplIds: tmplIds,
complete(res) {
that.goZhifu();
},
});
},
//支付
goZhifu() {
this.submit = true;
let url = "/api/WeChatPay/GetTravlePayInfo";
let GoodsName = this.orderData.model.Title;
GoodsName = GoodsName.slice(0, 10);
this.request2(
{
url: url,
data: {
OrderId: this.orderData.model.OrderId,
GoodsName: GoodsName,
OrderPayType: 1,
OpenId: uni.getStorageSync("mall_UserInfo").OpenId,
},
},
(res) => {
try{
let orderInfo = JSON.parse(res.data);
console.log(orderInfo);
this.goPay(orderInfo);
}catch(e){
uni.showToast({
title:'无法正常拉取微信支付,你可以稍后重试或联系销售人员线下转款',
icon:'none'
})
setTimeout(()=>{
this.submit = false;
}, 2000);
export default {
components: {},
data() {
return {
pageTitle: "订单详情",
msg: {
pageIndex: 1,
pageSize: 15,
MiniAppUserId: 0,
},
orderData: null,
orderStatus: {},
submit: false,
submitCancel: false,
showPayBtn: true,
};
},
created() {},
onLoad(option) {
if (option.orderData) {
this.orderData = JSON.parse(decodeURIComponent(option.orderData));
} else if (option.orderId) {
this.initOrderInfo(option.orderId);
}
}
);
},
goPay(orderInfo) {
let that = this;
uni.requestPayment({
provider: "wxpay",
timeStamp: orderInfo.timeStamp,
nonceStr: orderInfo.nonceStr,
package: orderInfo.package,
signType: orderInfo.signType,
paySign: orderInfo.sign,
success: function (res) {
console.log("success", res);
uni.showToast({
title: "支付成功",
});
that.submit = false;
//todo
that.initOrderInfo(that.orderData.model.OrderId);
},
fail: function (err) {
console.log("fail:", err);
uni.showToast({
title: "支付失败",
icon: "none",
});
that.submit = false;
that.initOrderInfo(that.orderData.model.OrderId);
},
});
},
// #endif
// #ifdef MP-ALIPAY
//支付宝支付
goZhifuAli() {
this.submit = true;
let that = this;
uni.showLoading({
title: "支付中",
});
let url = "/api/WeChatPay/GetTravlePayInfo";
let GoodsName = this.orderData.model.Title;
this.request2(
{
url: url,
data: {
OrderId: this.orderData.model.OrderId,
GoodsName: GoodsName,
OrderPayType: 2,
OpenId: uni.getStorageSync("mall_UserInfo").OpenId,
},
},
(res) => {
if (res.data) {
this.$utils.SubscribeMsgAli(() => {
that.goPayAli(res.data);
});
} else {
uni.hideLoading();
uni.showToast({
title: "获取交易号失败",
duration: 2000,
});
}
}
);
},
goPayAli(tradeNO) {
let that = this;
my.tradePay({
tradeNO: tradeNO,
success: function (res) {
console.log("success", res);
const list = ["9000"];
if (list.includes(res.resultCode)) {
let obj = {
TradeNo: tradeNO,
OrderNo: that.orderData.model.OrderNo,
OrderId: that.orderData.model.OrderId,
preferPrice: that.orderData.model.PreferPrice,
};
that.payAliCallback(obj);
} else {
uni.hideLoading();
uni.showToast({
title: "支付失败",
icon: "none",
});
}
},
fail: function (err) {
console.log("fail:", err);
uni.hideLoading();
uni.showToast({
title: "支付失败",
icon: "none",
});
that.submit = false;
that.initOrderInfo(that.orderData.model.OrderId);
},
});
},
payAliCallback(obj) {
let that = this;
this.request2(
{
url: "/api/AliPay/ALiPayCallBackDmcNotify",
data: {
OrderNo: obj.OrderNo,
OrderId: obj.OrderId,
UserId: uni.getStorageSync("mall_UserInfo").UserId,
TradeNo: obj.TradeNo,
ProjectType: 2,
PreferPrice: obj.preferPrice,
},
},
(res) => {
that.submit = false;
uni.redirectTo({
url:
"/pages/jiuzhai/paysuccess?PreferPrice=" +
obj.preferPrice +
"&isFrom=1",
});
uni.hideLoading();
},
(err) => {
console.log("err", err);
uni.hideLoading();
that.submit = false;
uni.showToast({
title: "支付失败",
icon: "none",
});
that.initOrderInfo(that.orderData.model.OrderId);
}
);
},
// #endif
},
};
},
methods: {
goback() {
uni.navigateBack({
delta: 1,
});
},
goCancel() {
if (this.submit || this.submitCancel) return;
//未付款-调用后台取消
if (this.orderData.model.OrderState == 2) {
this.apipost(
"sellorder_post_B2BRemoveOrder", {
ID: this.orderData.model.OrderId,
},
(res) => {
if (res.resultCode == 1) {
uni.showToast({
title: "操作成功",
icon: "success",
});
uni.navigateTo({
url: "/pages/jiuzhai/jz_MyOrder",
});
}
},
(err) => {}
);
} else {
let msg = {
OrderId: this.orderData.model.OrderId,
UserId: uni.getStorageSync("mall_UserInfo").UserId,
};
//已付款取消申请
this.apipost(
"sellorder_post_AppletUserCancelOrder",
msg,
(res) => {
if (res.resultCode == 1) {
uni.showToast({
title: "操作成功",
icon: "success",
});
uni.navigateTo({
url: "/pages/jiuzhai/jz_MyOrder",
});
} else {}
},
null
);
}
},
getWeek(date) {
var weekArray = new Array("日", "一", "二", "三", "四", "五", "六");
var week = weekArray[new Date(date).getDay()]; //注意此处必须是先new一个Date
return "周" + week;
},
getDate(date) {
if (date) {
let arr = date.split("-");
return arr[1] + "月" + arr[2] + "日";
}
},
initOrderInfo(orderId) {
let msg = {
ID: orderId,
IsGetGuest: 1,
};
this.apipost(
"sellorder_post_GetOrderEntity",
msg,
(res) => {
if (res.resultCode == 1) {
this.orderData = res.data;
this.formatStatus(
this.orderData.model.OrderState,
this.orderData.model.IsChargeLossOrders,
this.orderData.model.IsApplyForCancel
);
} else {
this.orderData = {
result: -1,
};
}
console.log(res);
},
(e) => {}
);
},
formatStatus(status, loss, isCancel) {
loss = loss ? loss : -1;
//1、已申请;!=1未申请
if (loss == 1 || status == 4) {
this.orderStatus.code = -1;
this.orderStatus.text = "已取消";
this.showPayBtn = false;
} else if (status == 2 && isCancel != 1) {
this.orderStatus.code = 0;
this.orderStatus.text = "待付款";
this.showPayBtn = true;
} else if (status == 2 && isCancel == 1) {
this.orderStatus.code = -2;
this.orderStatus.text = "审核中";
this.showPayBtn = false;
} else if (status == 1) {
this.orderStatus.code = 1;
this.orderStatus.text = "正常";
this.showPayBtn = false;
}
},
// #ifdef MP-WEIXIN
goFukuan() {
if (this.submit || this.submitCancel) return;
var that = this;
var tempData = uni.getStorageSync("basedata");
var tempObj = [];
if (tempData && tempData.mall && tempData.mall.wechatmessage) {
tempObj = tempData.mall.wechatmessage;
}
var tmplIds = [];
if (tempObj && tempObj.length > 0) {
tempObj.forEach((x) => {
if (x.Name == "下单成功提醒" || x.Name == "订单取消提醒") {
tmplIds.push(x.MessageId);
}
});
}
uni.requestSubscribeMessage({
tmplIds: tmplIds,
complete(res) {
that.goZhifu();
},
});
},
//支付
goZhifu() {
this.submit = true;
let url = "/api/WeChatPay/GetTravlePayInfo";
let GoodsName = this.orderData.model.Title;
GoodsName = GoodsName.slice(0, 10);
this.request2({
url: url,
data: {
OrderId: this.orderData.model.OrderId,
GoodsName: GoodsName,
OrderPayType: 1,
OpenId: uni.getStorageSync("mall_UserInfo").OpenId,
},
},
(res) => {
try {
let orderInfo = JSON.parse(res.data);
console.log(orderInfo);
this.goPay(orderInfo);
} catch (e) {
uni.showToast({
title: '无法正常拉取微信支付,你可以稍后重试或联系销售人员线下转款',
icon: 'none'
})
setTimeout(() => {
this.submit = false;
}, 2000);
}
}
);
},
goPay(orderInfo) {
let that = this;
uni.requestPayment({
provider: "wxpay",
timeStamp: orderInfo.timeStamp,
nonceStr: orderInfo.nonceStr,
package: orderInfo.package,
signType: orderInfo.signType,
paySign: orderInfo.sign,
success: function(res) {
console.log("success", res);
uni.showToast({
title: "支付成功",
});
that.submit = false;
//todo
that.initOrderInfo(that.orderData.model.OrderId);
},
fail: function(err) {
console.log("fail:", err);
uni.showToast({
title: "支付失败",
icon: "none",
});
that.submit = false;
that.initOrderInfo(that.orderData.model.OrderId);
},
});
},
// #endif
// #ifdef MP-ALIPAY
//支付宝支付
goZhifuAli() {
this.submit = true;
let that = this;
uni.showLoading({
title: "支付中",
});
let url = "/api/WeChatPay/GetTravlePayInfo";
let GoodsName = this.orderData.model.Title;
this.request2({
url: url,
data: {
OrderId: this.orderData.model.OrderId,
GoodsName: GoodsName,
OrderPayType: 2,
OpenId: uni.getStorageSync("mall_UserInfo").OpenId,
},
},
(res) => {
if (res.data) {
this.$utils.SubscribeMsgAli(() => {
that.goPayAli(res.data);
});
} else {
uni.hideLoading();
uni.showToast({
title: "获取交易号失败",
duration: 2000,
});
}
}
);
},
goPayAli(tradeNO) {
let that = this;
my.tradePay({
tradeNO: tradeNO,
success: function(res) {
console.log("success", res);
const list = ["9000"];
if (list.includes(res.resultCode)) {
let obj = {
TradeNo: tradeNO,
OrderNo: that.orderData.model.OrderNo,
OrderId: that.orderData.model.OrderId,
preferPrice: that.orderData.model.PreferPrice,
};
that.payAliCallback(obj);
} else {
uni.hideLoading();
uni.showToast({
title: "支付失败",
icon: "none",
});
}
},
fail: function(err) {
console.log("fail:", err);
uni.hideLoading();
uni.showToast({
title: "支付失败",
icon: "none",
});
that.submit = false;
that.initOrderInfo(that.orderData.model.OrderId);
},
});
},
payAliCallback(obj) {
let that = this;
this.request2({
url: "/api/AliPay/ALiPayCallBackDmcNotify",
data: {
OrderNo: obj.OrderNo,
OrderId: obj.OrderId,
UserId: uni.getStorageSync("mall_UserInfo").UserId,
TradeNo: obj.TradeNo,
ProjectType: 2,
PreferPrice: obj.preferPrice,
},
},
(res) => {
that.submit = false;
uni.redirectTo({
url: "/pages/jiuzhai/paysuccess?PreferPrice=" +
obj.preferPrice +
"&isFrom=1",
});
uni.hideLoading();
},
(err) => {
console.log("err", err);
uni.hideLoading();
that.submit = false;
uni.showToast({
title: "支付失败",
icon: "none",
});
that.initOrderInfo(that.orderData.model.OrderId);
}
);
},
// #endif
},
};
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment