Skip to content

Commit

Permalink
'增加订单退货功能'
Browse files Browse the repository at this point in the history
  • Loading branch information
fancyecommerce committed May 15, 2020
1 parent 84646ee commit 449d075
Show file tree
Hide file tree
Showing 19 changed files with 937 additions and 56 deletions.
5 changes: 4 additions & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
"pages/search/search",
"pages/order-review/order-review",
"pages/liveplayer",
"pages/live-player/live-player"
"pages/live-player/live-player",
"pages/aftersale/aftersale",
"pages/aftersale-return/aftersale-return",
"pages/aftersale-returnstatus/aftersale-returnstatus"
],
"window": {
"navigationStyle": "custom",
Expand Down
179 changes: 179 additions & 0 deletions pages/aftersale-return/aftersale-return.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
//index.js
//获取应用实例
var app = getApp()
// 语言
var util = require('../../utils/util.js')
import event from '../../utils/event'

Page({
data: {
//语言 - begin
language: '',
orderId: '',
itemId: '',
products:[],
order_info: {},
symbol: '',
//语言 - end
delBtnWidth: 120,
},
onLoad: function (e) {
var that = this;
var orderId = e.order_id;
var itemId = e.item_id;
that.setData({
orderId: orderId,
itemId: itemId
});
// 语言
// 设置当前页面的language变量 - 每个页面都要有
this.setLanguage();
event.on("languageChanged", this, this.changeLanguage); // (2)
// 设置当前页面的language Index - 每个页面都要有
wx.T.setLocaleByIndex(wx.T.langIndex);
// 语言 - 结束
that.getAftersaleReturn();
},
toDetailsTap: function (e) {
wx.navigateTo({
url: "/pages/goods-detail/goods-detail?id=" + e.currentTarget.dataset.id
})
},
home: function () {
wx.switchTab({
url: "/pages/index/index"
})
},
// 语言
// 设置language变量(翻译Object)
setLanguage() {
var lang = wx.T.getLanguage()
this.setData({
language: lang,
selectSize: lang.select_attribute
});
},
changeLanguage() {
var lang = wx.T.getLanguage()
this.setData({
language: lang,
selectSize: lang.select_attribute
});
this.getAftersaleReturn()
},

afterSaleReturn: function (e) {
var itemId = e.currentTarget.dataset.itemid;
var orderId = e.currentTarget.dataset.orderid;
wx.navigateTo({
url: "/pages/aftersale-return/aftersale-return?item_id=" + itemId + "&order_id=" + orderId
})
},
getAftersaleReturn: function () {
var that = this;
if (app.globalData.iphone == true) { that.setData({ iphone: 'iphone' }) }
wx.request({
url: app.globalData.urls + '/customer/order/returnview',
data: {
order_id: that.data.orderId,
item_id: that.data.itemId,
},
header: app.getRequestHeader(),
success: function (res) {
if (res.data.code == 200) {

that.setData({
products: res.data.data.order_info.products,
order_info: res.data.data.order_info
});

var favList = [];
var products = res.data.data.order_info.products
var ii = 0;
for (var x in products) {
var product = products[x]
favList.push({
goodsName: product.name,
goodsId: product.product_id,
itemId: product.item_id,
pic: product.imgUrl,
price: product.price,
qty: product.qty,
custom_option_info_str: product.custom_option_info_str,
isReviewed: product.is_reviewed
})
ii++
}
if (ii == 0) {
that.setData({
favList: null,
loadingMoreHidden: false
});
return
}

that.setData({
favList: favList,
loadingMoreHidden: true
});

} else if (res.data.code == 2000010){
var as_id = res.data.data.as_id;
wx.navigateTo({
url: "/pages/aftersale-returnstatus/aftersale-returnstatus?as_id=" + as_id
})
} else {
that.setData({
favList: null,
loadingMoreHidden: false
});
}
}
})
},
bindSave: function (e) {
var that = this;
var return_qty = e.detail.value.return_qty;

if (return_qty == "") {
wx.showModal({
title: '提示',
content: '请填写退货个数',
showCancel: false
})
return
}
wx.request({
url: app.globalData.urls + '/customer/order/returnsubmit',
header: app.getPostRequestHeader(),
method: 'POST',
data: {
return_qty: return_qty,
order_id: that.data.orderId,
item_id: that.data.itemId
},
success: function (res) {
if (res.data.code != 200) {
// 登录错误
wx.hideLoading();
wx.showModal({
title: '失败',
content: '提交退货失败',
showCancel: false
})
return;
}
app.saveReponseHeader(res);
// 跳转到提交成功页面

var as_id = res.data.data.as_id;
wx.navigateTo({
url: "/pages/aftersale-returnstatus/aftersale-returnstatus?as_id=" + as_id
})
}
})
}



})
5 changes: 5 additions & 0 deletions pages/aftersale-return/aftersale-return.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"usingComponents": {
"navigation": "/components/navigation/navigation"
}
}
35 changes: 35 additions & 0 deletions pages/aftersale-return/aftersale-return.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<navigation id='Navigation' show-icon="{{true}}" title="{{language.product_return}}" show-title="{{true}}" class=""></navigation>
<view class="goods-container">

<view class="ordertop" style="padding: 50rpx 30rpx;font-size: 26rpx;">
<view style="margin-bottom: 10rpx;">订单编号:{{order_info.increment_id}}</view>
<view>订单时间:{{order_info.created_at}}</view>
</view>

<view class="goods-box" wx:for-items="{{favList}}" wx:key="{{index}}" data-id="{{item.goodsId}}">
<view class="img-box">
<image src="{{item.pic}}" class="image" mode="aspectFill" lazy-load="true" />
</view>
<view class="goods-title" style="height:35px;overflow:hidden;font-size:25rpx;">
{{item.goodsName}} {{item.custom_option_info_str}}
</view>

<view style="width:50%;height:30px;overflow:hidden;font-size:25rpx;">
{{symbol}}{{item.price}}
<view style="width:30rpx;height:35px;overflow:hidden;font-size:25rpx;float:right;color:#777;">×{{item.qty}}</view>
</view>
</view>
<form bindsubmit="bindSave">
<view class="row-wrap">
<view class="label">退货个数:</view>
<view class="label-right">
<input name="return_qty" class="input" maxlength="11" type="text" placeholder="" value="{{favList[0].qty}}" />
</view>
</view>

<view class="ordertop" style="padding: 50rpx 30rpx;font-size: 26rpx;">
<view><button type="warn" class="save-btn" formType="submit" >退货提交</button></view>
</view>
</form>

</view>
103 changes: 103 additions & 0 deletions pages/aftersale-return/aftersale-return.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/* pages/aftersale-return/aftersale-return.wxss */page {
background-color: #f5f5f5;
}

.goods-container {
width: 100%;
}
.goods-box {
width: 100%;
height: 100px;
background-color: #fff;
border-bottom: 1px solid #f5f5f5;
}

.img-box {
background-color: #f5f5f5;
margin-top: 10px;
margin-left: 10px;
margin-right: 10px;
margin-bottom: 10px;
width: 80px;
height: 80px;
border-radius: 3px;
float: left;
}

.img-box image {
width: 80px;
height: 80px;
display: inline-block;
}

.goods-title {
display: inline-block;
font-size: 30rpx;
margin-top: 15px;
width: 50%;
color: #333;
}

.good-money {
font-size: 22rpx;
color: #999;
margin-top: 4px;
}

.title-opacity {
float: right;
font-size: 22rpx;
margin-right: 10px;
border: 1px solid #777;
color: #555;
padding: 4px 8px;
border-radius: 3px;
margin-top: 80rpx;

}

.no-more-goods {
text-align: center;
margin-top: 50%;
}

.no-order-img {
width: 110px;
height: 110px;
}

.no-more-goods .text {
font-size: 28rpx;
color: #999;
margin-top: -5px;
}


.row-wrap {
width: 690rpx;
height: 88rpx;
line-height: 88rpx;
margin-left: 30rpx;
border-bottom: 1rpx solid #eee;
display: flex;
font-size: 28rpx;

}

.row-wrap .label {
width: 160rpx;
color: #000;

}
.row-wrap .label-right {
flex: 1;
height: 88rpx;
line-height: 88rpx;

}
.row-wrap .label-right input {
height: 100%;
font-size: 28rpx;
padding-right: 30rpx;

}
Loading

0 comments on commit 449d075

Please sign in to comment.