|
@@ -1,6 +1,7 @@
|
|
|
-// pages/order-detail/order-detail.js
|
|
|
-
|
|
|
+// pages/DetailsOfRefund/DetailsOfRefund.js
|
|
|
var http = require('../../utils/http.js');
|
|
|
+var util = require('../../utils/util.js');
|
|
|
+
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
@@ -22,12 +23,14 @@ Page({
|
|
|
orderItemDtos: [],
|
|
|
remarks: "",
|
|
|
actualTotal: 0,
|
|
|
+ canRefund:false,
|
|
|
userAddrDto: null,
|
|
|
orderNumber: "",
|
|
|
createTime: "",
|
|
|
status: 0,
|
|
|
productTotalAmount: '',
|
|
|
transfee: '',
|
|
|
+ totalNum:0,
|
|
|
reduceAmount: '',
|
|
|
prodid: '',
|
|
|
orderType: 0,
|
|
@@ -41,6 +44,74 @@ Page({
|
|
|
orderNumSend:''
|
|
|
},
|
|
|
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面加载
|
|
|
+ */
|
|
|
+ onLoad(options) {
|
|
|
+ this.setData({
|
|
|
+ orderNumSend:options.orderNum
|
|
|
+ })
|
|
|
+ this.loadOrderDetail(options.orderNum);
|
|
|
+
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 加载订单数据
|
|
|
+ */
|
|
|
+ loadOrderDetail: function(orderNum) {
|
|
|
+ var ths = this;
|
|
|
+ wx.showLoading();
|
|
|
+ //加载订单详情
|
|
|
+ var params = {
|
|
|
+ url: "/p/myOrder/orderDetail",
|
|
|
+ method: "GET",
|
|
|
+ data: {
|
|
|
+ orderNumber: orderNum
|
|
|
+ },
|
|
|
+ callBack: function(res) {
|
|
|
+ let img=''
|
|
|
+ res.orderItemDtos.forEach(e=>{
|
|
|
+ img=e.pic.split(',')
|
|
|
+ e.pic=img[0]
|
|
|
+ })
|
|
|
+
|
|
|
+ var dvyType
|
|
|
+ if(res.dvyType == 1){
|
|
|
+ dvyType = '运费(快递)'
|
|
|
+ }else if(res.dvyType == 3){
|
|
|
+ dvyType = '配送费(即时配送)'
|
|
|
+ }else{
|
|
|
+ dvyType = '自提'
|
|
|
+ }
|
|
|
+ ths.setData({
|
|
|
+ totalUsableScore:res.totalUsableScore,
|
|
|
+ dvyType:dvyType,
|
|
|
+ orderNumber: orderNum,
|
|
|
+ actualTotal: res.actualTotal, //实际支付总额(商品总额+运费)
|
|
|
+ canRefund:res.canRefund,
|
|
|
+ userAddrDto: res.userAddrDto,
|
|
|
+ remarks: res.remarks,
|
|
|
+ orderItemDtos: res.orderItemDtos,
|
|
|
+ createTime: res.createTime,
|
|
|
+ status: res.status,
|
|
|
+ // status: res.status,//海博订单状态
|
|
|
+ productTotalAmount: res.total, //所有商品总额
|
|
|
+ transfee: res.transfee, //运费
|
|
|
+ totalNum:res.totalNum,
|
|
|
+ reduceAmount: res.reduceAmount,
|
|
|
+ orderType: res.orderType,
|
|
|
+ shopName: res.shopName,
|
|
|
+ canRefund: res.canRefund,
|
|
|
+ canAllRefund: res.canAllRefund,
|
|
|
+ orderScore: res.orderScore, // 整单使用积分
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ wx.hideLoading();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ http.request(params);
|
|
|
+
|
|
|
+ },
|
|
|
//跳转商品详情页
|
|
|
toProdPage: function(e) {
|
|
|
var prodid = e.currentTarget.dataset.prodid;
|
|
@@ -57,40 +128,6 @@ Page({
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
- * 是否最后一个商品在执行单个商品退款事件
|
|
|
- */
|
|
|
- applyLastProdRefund: function() {
|
|
|
- if(this.data.status==2) { //待发货状态下
|
|
|
- // 遍历商品list
|
|
|
- if(this.data.orderItemDtos.length > 1) { //如果商品列表长度大于1
|
|
|
- let sum = []
|
|
|
- this.data.orderItemDtos.forEach((el,index) => {
|
|
|
- if (el.refundSn) { //如果拥有退款单号
|
|
|
- sum.push(el)
|
|
|
- this.setData({
|
|
|
- sum
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- console.log(this.data.sum)
|
|
|
- if(this.data.sum.length == this.data.orderItemDtos.length-1) {
|
|
|
- // 如果拥有退款单号的item等于商品列表数据长度-1,那么点击的这件商品就是最后意见商品
|
|
|
- this.setData({
|
|
|
- isLastProd: true
|
|
|
- })
|
|
|
- }else if(this.data.sum.length == this.data.orderItemDtos.length) {
|
|
|
- // 如果拥有退款单号的item等于商品列表数据长度,那么不可撤销申请
|
|
|
- this.setData({
|
|
|
- irrevocable: true //不可撤销
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- console.log('isLastProd:',this.data.isLastProd)
|
|
|
- console.log('irrevocable:',this.data.irrevocable)
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
* 付款
|
|
|
*/
|
|
|
onPayAgain: function (e) {
|
|
@@ -131,8 +168,8 @@ Page({
|
|
|
http.request(params);
|
|
|
},
|
|
|
|
|
|
- //删除已完成||已取消的订单
|
|
|
- delOrderList: function (e) {
|
|
|
+ //删除已完成||已取消的订单
|
|
|
+ delOrderList: function (e) {
|
|
|
var ths = this
|
|
|
wx.showModal({
|
|
|
title: '',
|
|
@@ -198,222 +235,84 @@ Page({
|
|
|
* 申请退款
|
|
|
*/
|
|
|
applyRefund: function(e) {
|
|
|
- var item = {}
|
|
|
- item.orderNumber = this.data.orderNumber;
|
|
|
- item.actualTotal = this.data.actualTotal;
|
|
|
- item.transfee = this.data.transfee;
|
|
|
- item.status = this.data.status; //订单状态
|
|
|
- item.orderItemDtos = this.data.orderItemDtos;
|
|
|
- item.orderScore = this.data.orderScore, // 整单积分
|
|
|
- item.userAddrDto = this.data.userAddrDto, // 用户信息
|
|
|
- //拿到存储在本地的订单项数据
|
|
|
- wx.setStorageSync("refundItem", item);
|
|
|
-
|
|
|
- wx.redirectTo({ //通过wx.redirectTo实现跳转(关闭当前页面,跳转到应用内某个页面)
|
|
|
- url: '/pages/applyRefund/applyRefund',
|
|
|
- })
|
|
|
-
|
|
|
- },
|
|
|
- // applyRefund: function(e) {
|
|
|
- // var refundType = e.currentTarget.dataset.refundtype // 退款类型 1整单 2单个物品
|
|
|
- // var status = this.data.status
|
|
|
- // this.loadOrderDetail(this.data.orderNumber) //请求订单详情数据
|
|
|
- // if (e.currentTarget.dataset.refundtype == 1) { //整单退款
|
|
|
- // var item = {}
|
|
|
- // item.orderNumber = this.data.orderNumber;
|
|
|
- // item.actualTotal = this.data.actualTotal;
|
|
|
- // item.transfee = this.data.transfee;
|
|
|
- // item.status = this.data.status; //订单状态
|
|
|
- // item.orderItemDtos = this.data.orderItemDtos;
|
|
|
- // item.orderScore = this.data.orderScore, // 整单积分
|
|
|
- // item.userAddrDto = this.data.userAddrDto, // 用户信息
|
|
|
- // //拿到存储在本地的订单项数据
|
|
|
- // wx.setStorageSync("refundItem", item);
|
|
|
- // // console.log('订单详情页获取到的整单退item:',item)
|
|
|
- // } else if(e.currentTarget.dataset.refundtype == 2) { //单个商品退款
|
|
|
- // this.applyLastProdRefund() //是否最后一个商品执行单个商品退款
|
|
|
- // console.log('isLastProd:',this.data.isLastProd)
|
|
|
- // // 将数据存储到本地
|
|
|
- // var item = e.currentTarget.dataset.item;
|
|
|
- // if(this.data.orderItemDtos.length == 1) {
|
|
|
- // item.addTransfee = true
|
|
|
- // }else {
|
|
|
- // item.addTransfee = false
|
|
|
- // }
|
|
|
- // item.orderNumber = this.data.orderNumber;
|
|
|
- // item.transfee = this.data.transfee;
|
|
|
- // item.status = this.data.status; //订单状态
|
|
|
- // item.isLastProd = this.data.isLastProd?this.data.isLastProd:undefined //是否最后一款商品
|
|
|
- // //拿到存储在本地的订单项数据
|
|
|
- // wx.setStorageSync("refundItem", item);
|
|
|
- // console.log(item)
|
|
|
- // console.log(item.actualTotal)
|
|
|
- // }
|
|
|
- // /**
|
|
|
- // * 判断跳转页面(根据订单是否已发货)
|
|
|
- // */
|
|
|
- // var type = e.currentTarget.dataset.type;
|
|
|
-
|
|
|
- // // if (status == 2) { //待发货,直接跳转到申请页,不需要选择退货方式
|
|
|
- // wx.redirectTo({ //通过wx.redirectTo实现跳转(关闭当前页面,跳转到应用内某个页面)
|
|
|
- // url: '/pages/applyRefund/applyRefund?type=' + type + '&refundType=' + refundType,
|
|
|
- // })
|
|
|
- // // } else { //已发货,跳转到选择退货方式页
|
|
|
- // // wx.redirectTo({
|
|
|
- // // url: '/pages/chooseRefundWay/chooseRefundWay?refundType=' + refundType
|
|
|
- // // })
|
|
|
- // // }
|
|
|
- // },
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 查看退款
|
|
|
- */
|
|
|
- viewRefund: function(e) {
|
|
|
- var refundSn = e.currentTarget.dataset.refundsn;
|
|
|
- this.applyLastProdRefund() //是否最后一个商品执行单个商品退款
|
|
|
- console.log(this.data.irrevocable)
|
|
|
- wx.navigateTo({
|
|
|
- url: '/pages/DetailsOfRefund/DetailsOfRefund?refundSn=' + refundSn + '&irrevocable=' + this.data.irrevocable+'&userAddrDto='+JSON.stringify(this.data.userAddrDto) +'&orderNumber=' + this.data.orderNumSend
|
|
|
+ var item = {}
|
|
|
+ item.orderNumber = this.data.orderNumber;
|
|
|
+ item.actualTotal = this.data.actualTotal;
|
|
|
+ item.transfee = this.data.transfee;
|
|
|
+ item.status = this.data.status; //订单状态
|
|
|
+ item.orderItemDtos = this.data.orderItemDtos;
|
|
|
+ item.totalNum = this.data.totalNum
|
|
|
+ item.orderScore = this.data.orderScore, // 整单积分
|
|
|
+ item.userAddrDto = this.data.userAddrDto, // 用户信息
|
|
|
+ //拿到存储在本地的订单项数据
|
|
|
+ wx.setStorageSync("refundItem", item);
|
|
|
+
|
|
|
+ wx.redirectTo({ //通过wx.redirectTo实现跳转(关闭当前页面,跳转到应用内某个页面)
|
|
|
+ url: '/pages/applyRefund/applyRefund',
|
|
|
})
|
|
|
- },
|
|
|
|
|
|
- /**
|
|
|
- * 生命周期函数--监听页面加载
|
|
|
- */
|
|
|
- onLoad: function(options) {
|
|
|
- this.setData({
|
|
|
- orderNumSend:options.orderNum
|
|
|
- })
|
|
|
- this.loadOrderDetail(options.orderNum);
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 加载订单数据
|
|
|
- */
|
|
|
- loadOrderDetail: function(orderNum) {
|
|
|
- var ths = this;
|
|
|
- wx.showLoading();
|
|
|
- //加载订单详情
|
|
|
- var params = {
|
|
|
- url: "/p/myOrder/orderDetail",
|
|
|
- method: "GET",
|
|
|
- data: {
|
|
|
- orderNumber: orderNum
|
|
|
- },
|
|
|
- callBack: function(res) {
|
|
|
- let img=''
|
|
|
- res.orderItemDtos.forEach(e=>{
|
|
|
- img=e.pic.split(',')
|
|
|
- e.pic=img[0]
|
|
|
- })
|
|
|
-
|
|
|
- var dvyType
|
|
|
- if(res.dvyType == 1){
|
|
|
- dvyType = '运费(快递)'
|
|
|
- }else if(res.dvyType == 3){
|
|
|
- dvyType = '配送费(即时配送)'
|
|
|
- }else{
|
|
|
- dvyType = '自提'
|
|
|
- }
|
|
|
- ths.setData({
|
|
|
- totalUsableScore:res.totalUsableScore,
|
|
|
- dvyType:dvyType,
|
|
|
- orderNumber: orderNum,
|
|
|
- actualTotal: res.actualTotal, //实际支付总额(商品总额+运费)
|
|
|
- userAddrDto: res.userAddrDto,
|
|
|
- remarks: res.remarks,
|
|
|
- orderItemDtos: res.orderItemDtos,
|
|
|
- createTime: res.createTime,
|
|
|
- status: res.status,
|
|
|
- // status: res.status,//海博订单状态
|
|
|
- productTotalAmount: res.total, //所有商品总额
|
|
|
- transfee: res.transfee, //运费
|
|
|
- reduceAmount: res.reduceAmount,
|
|
|
- orderType: res.orderType,
|
|
|
- shopName: res.shopName,
|
|
|
- canRefund: res.canRefund,
|
|
|
- canAllRefund: res.canAllRefund,
|
|
|
- orderScore: res.orderScore, // 整单使用积分
|
|
|
+},
|
|
|
|
|
|
+ // 一键复制事件
|
|
|
+ copyBtn: function(e) {
|
|
|
+ let data = e.currentTarget.dataset.value
|
|
|
+ wx.setClipboardData({
|
|
|
+ //准备复制的数据
|
|
|
+ data,
|
|
|
+ success: function(res) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '复制成功',
|
|
|
});
|
|
|
-
|
|
|
- wx.hideLoading();
|
|
|
}
|
|
|
- };
|
|
|
- http.request(params);
|
|
|
-
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
|
- onReady: function() {
|
|
|
+ onReady() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
- onShow: function() {
|
|
|
+ onShow() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
*/
|
|
|
- onHide: function() {
|
|
|
+ onHide() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
*/
|
|
|
- onUnload: function() {
|
|
|
+ onUnload() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
*/
|
|
|
- onPullDownRefresh: function() {
|
|
|
+ onPullDownRefresh() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
- onReachBottom: function() {
|
|
|
+ onReachBottom() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 用户点击右上角分享
|
|
|
*/
|
|
|
- onShareAppMessage: function() {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- toGroupDetails: function(e) {
|
|
|
- wx.navigateTo({
|
|
|
- url: '/pages/spellGroupDetails/spellGroupDetails?orderNumber=' + e.currentTarget.dataset.ordernumber,
|
|
|
- })
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
- // 一键复制事件
|
|
|
- copyBtn: function(e) {
|
|
|
- var ths = this;
|
|
|
- wx.setClipboardData({
|
|
|
- //准备复制的数据
|
|
|
- data: ths.data.orderNumber,
|
|
|
- success: function(res) {
|
|
|
- wx.showToast({
|
|
|
- title: '复制成功',
|
|
|
- });
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
+ onShareAppMessage() {
|
|
|
|
|
|
+ }
|
|
|
})
|