Authored by yyq

reason choose

... ... @@ -8,7 +8,6 @@ export default {
*/
getOrders(params) {
return api.get({
url: '',
data: {
...params,
method: 'app.SpaceOrders.get'
... ... @@ -22,7 +21,6 @@ export default {
*/
delOrder(params) {
return api.get({
url: '',
data: {
...params,
method: 'app.SpaceOrders.delOrderByCode'
... ... @@ -36,7 +34,6 @@ export default {
*/
cancelOrder(params) {
return api.get({
url: '',
data: {
...params,
method: 'app.SpaceOrders.close'
... ... @@ -44,13 +41,24 @@ export default {
});
},
/**
* 申请退款
* @param params
* @returns {*}
*/
refundOrder() {
return api.get({
data: {
method: 'app.SpaceOrders.refundApply'
}
});
},
/**
* 确认收货
* @param params
* @returns {*}
*/
confirmReceive(params) {
return api.get({
url: '',
data: {
...params,
method: 'app.SpaceOrders.confirm'
... ... @@ -64,14 +72,12 @@ export default {
*/
expressDetail (params) {
return api.get({
url: '',
data: {
...params,
method: 'app.express.li'
}
});
},
/**
* 订单详情
* @param params
... ... @@ -79,11 +85,23 @@ export default {
*/
getOrderDetail(orderCode) {
return api.get({
url: '',
data: {
method: 'app.SpaceOrders.detail',
order_code: orderCode
}
});
},
/**
* 退款理由
* @param params
* @returns {*}
*/
getRefundSeason() {
return api.get({
data: {
method: 'app.SpaceOrders.refundApplyReasons',
fromPage: 'aFP_MineOrderContent'
}
});
},
};
... ...
<template name="addressEditer">
<view class="edit-wrap">
<view class="edit-row">
<text class="left-cell">收货人</text>
<input data-name="consignee" class="right-cell" placeholder="姓名" maxlength="20" bindinput="onInputChanged" value="{{consignee}}"/>
</view>
<view class="edit-row">
<text class="left-cell">手机号码</text>
<input type="number" data-name="mobile" class="right-cell" placeholder="手机号码" maxlength="18" bindinput="onInputChanged" value="{{mobile}}"/>
</view>
<view class="edit-row" bindtap="chooseArea">
<text class="left-cell">选择地区</text>
<input class="right-cell" disabled="disabled" placeholder="地区信息" value="{{area}}"/>
</view>
<view class="edit-row">
<text class="left-cell">详细地址</text>
<input data-name="address" class="right-cell" placeholder="详细街道地址" maxlength="50" bindinput="onInputChanged" value="{{address}}"/>
</view>
</view>
<button class="option-btn save-btn" catchtap="saveAddr">确认</button>
<button wx:if="{{address_id}}" class="option-btn delete-btn" data-key="{{index}}" data-id="{{address_id}}" catchtap="deleteAddr">删除地址</button>
<view class="aaa">{{editeAddressPage}}</view>
<view wx:if="{{areaPicker}}" class="picker-mask" catchtap="hideAreaPicker"></view>
<picker-view wx:if="{{areaPicker}}" class="picker-view" indicator-style="height: 50px;" style="width: 100%; height: 300px;" value="{{areaValue}}" bindchange="areaPickerChange">
<picker-view-column data-type="provice1">
<view wx:for="{{pickerProvice}}" wx:key="unique" class="picker-item">
<text class="picker-text">{{item.caption}}</text>
</view>
</picker-view-column>
<picker-view-column>
<view wx:for="{{pickerCity}}" wx:key="unique" class="picker-item">
<text class="picker-text">{{item.caption}}</text>
</view>
</picker-view-column>
<picker-view-column>
<view wx:for="{{pickerArea}}" wx:key="unique" class="picker-item">
<text class="picker-text">{{item.caption}}</text>
</view>
</picker-view-column>
</picker-view>
</template>
.edit-wrap {
background-color: #fff;
padding-left: 30rpx;
margin-bottom: 50rpx;
}
.edit-wrap .edit-row {
border-bottom: 1rpx solid #e0e0e0;
padding: 10rpx 0;
}
.edit-wrap .edit-row:last-child {
border-bottom: 0;
}
.edit-wrap .edit-row .left-cell,
.edit-wrap .edit-row .right-cell {
height: 80rpx;
line-height: 80rpx;
display: inline-block;
vertical-align: middle;
}
.edit-wrap .edit-row .right-cell {
float: right;
width: 540rpx;
margin-right: 30rpx;
}
.option-btn {
height: 80rpx;
line-height: 80rpx;
margin: 20rpx 30rpx;
color: #fff;
background-color: #444;
}
.option-btn.delete-btn {
background-color: #aaa;
}
.picker-mask {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: 10;
}
.picker-view {
position: fixed;
left: 0;
bottom: 0;
z-index: 20;
}
.picker-view .picker-item {
line-height: 92rpx;
text-align: center;
}
.picker-view .picker-text {
max-width: 60%;
margin: 0 auto;
display: block;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
<import src="./editor.wxml"/>
<import src="./template/editor/editor.wxml"/>
<view wx:if="{{showEditAddrPage}}" class="container">
<template is="addressEditer" data="{{...editAddrPageData, areaPicker, pickerProvice, pickerCity, pickerArea, areaValue}}"/>
... ...
@import "./editor.wxss";
@import "./template/editor/editor.wxss";
page {
display: block;
... ...
... ... @@ -10,7 +10,8 @@ const yas = new Yas(app);
Page({
data: {
receiveAddress: {}
receiveAddress: {},
reason: []
},
onLoad(options) {
if (!options.orderCode || !app.getUid()) {
... ... @@ -33,6 +34,8 @@ Page({
this.timeCountDown(parseInt(data.pay_lefttime));
}
let links = data.links || [];
this.setData({
pageLoaded: true,
receiveAddress: {
... ... @@ -49,10 +52,24 @@ Page({
promotionList: data.promotion_formulas || [],
paymentAmount: data.payment_amount,
attribute: data.attribute,
links: data.links
links: links
});
if (links.indexOf('refundApply') > -1) {
this.loadRefundReason(); // 获取退款理由
}
}
})
});
},
loadRefundReason() {
if (this.hasSetReason) {
return;
}
orderHandle.getRefundReason(res => {
this.setData({reason: res});
this.hasSetReason = true;
});
},
timeCountDown(second) {
const that = this;
... ... @@ -119,7 +136,37 @@ Page({
confirmOrder() {
orderHandle.confirmReceive(this.orderCode);
},
refundNow() {
orderHandle.confirmReceive(this.orderCode);
refundOrder() {
let that = this;
wx.showModal({
content: '申请退款后,本单享有的优惠可能会一并取消,确定申请吗?',
cancelText: '取消',
confirmText: '确定',
confirmColor: '#FF0000',
success(res) {
if (res.confirm) {
that.loadRefundReason();
that.setData({showReason: true});
}
}
});
},
hidePicker(e) {
if (e.target.id === 'reason-picker') {
this.setData({showReason: false});
}
},
reasonChange(e) {
this.reasonIndex = e.detail.value[0];
},
reasonSure() {
orderHandle.refundNow(this.orderCode, this.data.reason[this.reasonIndex || 0], res => {
if (res && res.code == 200) {
wx.navigateBack({delta:1});
}
});
this.setData({showReason: false});
}
});
... ...
<import src="./template/reason/reason.wxml"/>
<view wx:if="{{pageLoaded}}" class="container">
<view class="address-wrap">
<address-card address="{{receiveAddress}}"></address-card>
... ... @@ -39,9 +41,11 @@
<view wx:if="{{link === 'delOrder'}}" class="option-btn" catchtap="deleteOrder">删除订单</view>
<view wx:if="{{link === 'getExpress'}}" class="option-btn" catchtap="viewExpress">查看物流</view>
<button wx:if="{{link === 'confirm'}}" formType="submit" class="option-btn red-btn" catchtap="confirmOrder">确认收货</button>
<button wx:if="{{link === 'refundApply'}}" formType="submit" class="option-btn" catchtap="refundNow">申请退款</button>
<button wx:if="{{link === 'refundApply'}}" formType="submit" class="option-btn" catchtap="refundOrder">申请退款</button>
</block>
</form>
</view>
</view>
<template is="reason" data="{{reason, showReason}}"></template>
</view>
... ...
@import "./template/reason/reason.wxss";
page {
background-color: #f0f0f0;
}
... ...
<template name="orderItem">
<view class="order" data-order_code="{{item.order_code}}" bindtap="navToOrderDetail">
<view class="header">
订单编号:{{item.order_code}}
<view class="order-status">{{item.status_str}}</view>
</view>
<view class="order-goods">
<block wx:for="{{item.order_goods}}" wx:for-item="good" wx:key="product_id">
<view class="order-good" data-id="">
<view class="thumb-wrap">
<image class="thumb" src="{{good.goods_image}}"></image>
<image wx:if="{{good.goods_type=='gift' || good.goods_type=='price_gift'}}"class='productTag' src="{{good.goods_type=='gift'?'images/zp-lab@2x.png':'images/jjg-lab@2x.png'}}"></image>
</view>
<view class="deps">
<view class="name row">{{good.product_name}}</view>
<view class="row">
<view class="color">
颜色:{{good.color_name}}
</view>
<view class="size">
尺码:{{good.size_name}}
</view>
</view>
<view class="row price-wrap">
<view class="price">
¥{{good.real_pay_price}}
</view>
<view wx:if="{{good.sales_price}}" class="count" style='text-decoration:line-through;'>
¥{{good.sales_price}}
</view>
<view class="count">
× {{good.buy_number}}
</view>
</view>
</view>
<block wx:if="{{good.expect_arrival_time}}">
<text class="order-tip" >上市期:{{good.expect_arrival_time}}</text>
</block>
</view>
</block>
</view>
<view class="footer">
共{{item.buy_total}}件商品 实付
<view class="sum-cost">¥{{item.amount}}</view>
(含运费¥{{item.shipping_cost}})
</view>
<view wx:if="{{item.attribute == 9}}" class="order-opt" style='font-size:28rpx;color:#444444'>*此订单只能在APP端操作</view>
<view wx:elif="{{item.links.length > 0}}" class="order-opt">
<block wx:if="{{item.counter_flag == 'Y' && item.is_cancel != 'Y' && item.pay_lefttime > 0}}">
<view class="counterView">
<image class="timeIcon" src='../../../static/images/shijian@3x.png'></image>
<text class="counter">剩余 {{item.time_left}}</text>
</view>
</block>
<block wx:for="{{item.links}}" wx:for-item="link" wx:key="order_code">
<block wx:if="{{link == 'closeOrder'}}">
<view class="btn" formType="submit" type="default" size="{{defaultSize}}" plain='true'
catchtap="cancelOrder" data-code="{{item.order_code}}">取消订单</view>
</block>
<block wx:if="{{link == 'buyNow'}}">
<view class="btn pay" catchtap="payNow" data-code="{{item.order_code}}"
data-amount="{{item.amount}}">立即付款
</view>
</block>
<block wx:if="{{link == 'delOrder'}}">
<view class="btn cancel" catchtap="delOrder" data-code="{{item.order_code}}">删除订单</view>
</block>
<block wx:if="{{link == 'getExpress'}}">
<view class="btn cancel" catchtap="expressDetail" data-code="{{item.order_code}}">查看物流</view>
</block>
<block wx:if="{{link == 'confirm'}}">
<view class="button pay" catchtap="confirmReceive" data-code="{{item.order_code}}">确认收货
</view>
</block>
</block>
</view>
</view>
</template>
.order:last-child {
margin-bottom: 0;
}
.order {
position: relative;
display: block;
background: #fff;
margin-bottom: 20rpx;
border-top: 1rpx solid #e0e0e0;
border-bottom: 1rpx solid #e0e0e0;
}
.order .header {
border-bottom: 1rpx solid #e0e0e0;
}
.order .footer, .order .header {
height: 91rpx;
line-height: 90rpx;
font-size: 28rpx;
padding: 0 28rpx;
color: #444444;
}
.order .order-status {
float: right;
font-family: PingFang-SC-Medium;
font-size: 28rpx;
color: #D0021B;
letter-spacing: -0.39px;
}
.order-good {
position: relative;
margin: 18rpx 0;
margin-left: 30.6rpx;
height: 144rpx;
border-bottom: 1rpx solid #e0e0e0;
font-size: 23.4rpx;
}
.order-tip {
font-size: 25.2rpx;
margin-left: 15rpx;
color: red;
margin-top: 10rpx;
}
.order-good:last-child {
border-bottom: none;
margin-bottom: 0rpx;
}
.order-good .thumb-wrap {
position: relative;
float: left;
width: 100rpx;
height: 132rpx;
top: -9rpx;
}
.productTag{
width: 100%;
height: 20rpx;
bottom: 0;
left: 0;
position: absolute;
}
.order-good .thumb {
width: 100%;
height: 100%;
}
image {
display: block;
margin: 0 auto;
max-width: 100%;
border: 0;
}
.order-good .deps {
margin-left: 121.5rpx;
}
.order-good .name {
max-width: 70%;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
font-family: PingFang-SC-Regular;
font-size: 28rpx;
color: #444;
letter-spacing: -0.4rpx;
line-height: 34rpx;
min-height: 68rpx;
}
.order-good .row:nth-child(2) {
height: 40.5rpx;
line-height: 40.5rpx;
width: 90%;
}
.order-good .row .color {
display: inline-block;
max-width: 200rpx;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
vertical-align: bottom;
font-family: PingFang-SC-Regular;
font-size: 24rpx;
color: #B0B0B0;
letter-spacing: -0.34rpx;
}
.order-good .row .size {
display: inline-block;
vertical-align: bottom;
padding-left: 20rpx;
font-family: PingFang-SC-Regular;
font-size: 24rpx;
color: #B0B0B0;
letter-spacing: -0.34rpx;
}
.order-good .color, .order-good .size {
color: #b6b6b6;
}
.order-good .price-wrap {
position: absolute;
top: 0rpx;
right: 27rpx;
text-align: right;
}
.order-good .price {
color: #d0021b;
}
.order-good .count {
display: block;
text-align: right;
font-family: PingFang-SC-Regular;
font-size: 24rpx;
color: #B0B0B0;
letter-spacing: -0.34rpx;
margin-top: 40rpx;
}
.order .footer {
text-align: right;
border-top: 1rpx solid #e0e0e0;
}
.order .sum-cost {
color: #e01;
margin-left: 4.5rpx;
display: inline-block;
}
.order .order-opt {
padding: 27rpx 0;
padding-right: 27rpx;
border-top: 1rpx solid #e0e0e0;
text-align: right;
margin-right: 20rpx;
display: flex;
flex-direction:row;
justify-content:flex-end;
}
.order .order-opt .counterView{
position: absolute;
left: 33rpx;
height: 108rpx;
bottom: 0rpx;
display: flex;
flex-direction:row;
align-items: center;
}
.order .order-opt .counterView .timeIcon{
height: 24rpx;
width: 24rpx;
}
.order .order-opt .counterView .counter{
margin-left: 10rpx;
font-size: 24rpx;
text-align: center;
}
.order .order-opt .btn {
display: inline-block;
height: 60rpx;
line-height: 60rpx;
width: 140rpx;
font-size: 25rpx;
text-align: center;
border: 1rpx solid #444444;
color: #444444;
border-radius: 4rpx;
}
.button {
height: 54rpx;
line-height: 54rpx;
width: 130rpx;
padding-left: 1rpx;
padding-right: 1rpx;
font-size: 25rpx;
text-align: center;
margin-right: 1rpx;
}
a {
outline: none;
color: #444444;
text-decoration: none;
}
.order .order-opt .pay {
background: #d0021b;
color: #fff;
border: none;
font-size: 25rpx;
margin-left: 20rpx;
line-height: 58rpx;
border: 1rpx solid #d0021b;
}
\ No newline at end of file
... ... @@ -2,6 +2,8 @@ import wx from '../../../utils/wx';
import orderModel from '../../../models/home/order';
import { wechatPay } from '../../../utils/wechat-pay';
const REASON_CACHE_KEY = 'refund_reason_cache';
let app = getApp();
let router = global.router;
... ... @@ -19,7 +21,7 @@ export default {
}).then(res => {
if (res.confirm) {
orderModel.delOrder({order_code: orderCode}).then(json => {
callback(json);
callback && callback(json);
});
}
})
... ... @@ -38,7 +40,7 @@ export default {
}).then(res => {
if (res.confirm) {
orderModel.confirmReceive({order_code: orderCode, miniapp_type: app.getMiniappType()}).then(json => {
callback(json);
callback && callback(json);
});
}
});
... ... @@ -61,7 +63,7 @@ export default {
wx.showModal({title: json.message, showCancel: false});
}
callback(json);
callback && callback(json);
});
}
});
... ... @@ -79,7 +81,42 @@ export default {
wechatPay(data, callback)
},
refundNow() {
refundNow(orderCode, reason, callback) {
orderModel.refundOrder({
order_code: orderCode,
reason_id: reason.reason_id,
reason: reason.reason,
fromPage: 'aFP_MineOrderContent'
}).then(json => {
callback && callback(json);
})
},
getRefundReason(callback) {
let reason;
try {
reason = wx.getStorageSync(REASON_CACHE_KEY);
if (reason) {
reason = JSON.parse(reason);
}
} catch (e) {
console.log(JSON.stringify(e))
}
}
if (reason) {
return callback && callback(reason);
}
orderModel.getRefundSeason().then(res => {
if (res.code === 200) {
return callback && callback(res.data);
wx.setStorage({
key: REASON_CACHE_KEY,
data: JSON.stringify(res.data)
});
}
});
},
}
... ...
... ... @@ -12,9 +12,10 @@ let timer;
Page({
data: {
windowHeight: windowHeight + 48,
windowHeight: windowHeight + 48,
orderType: 1,
ordersList: []
ordersList: [],
reason: []
},
onLoad: function (options) {
let type = options.type || 1;
... ... @@ -132,6 +133,16 @@ Page({
}
});
},
loadRefundReason() {
if (this.hasSetReason) {
return;
}
orderHandle.getRefundReason(res => {
this.setData({reason: res});
this.hasSetReason = true;
});
},
navToOrderDetail(e) {
let code = e.currentTarget.dataset.order_code;
... ... @@ -179,5 +190,38 @@ Page({
orderType: type
});
this.getOrders(type);
},
refundOrder() {
let that = this;
wx.showModal({
content: '申请退款后,本单享有的优惠可能会一并取消,确定申请吗?',
cancelText: '取消',
confirmText: '确定',
confirmColor: '#FF0000',
success(res) {
if (res.confirm) {
that.loadRefundReason();
that.setData({showReason: true});
}
}
});
},
hidePicker(e) {
if (e.target.id === 'reason-picker') {
this.setData({showReason: false});
}
},
reasonChange(e) {
this.reasonIndex = e.detail.value[0];
},
reasonSure() {
orderHandle.refundNow(this.orderCode, this.data.reason[this.reasonIndex || 0], res => {
if (res && res.code == 200) {
wx.navigateBack({delta:1});
}
});
this.setData({showReason: false});
}
});
... ...
<import src="./item/item.wxml"/>
<import src="./template/item/item.wxml"/>
<import src="./template/reason/reason.wxml"/>
<scroll-view class="page-container">
<view class="order-types">
<view class="type {{orderType == 1 ? 'active' : ''}}" data-type="1" bindtap="changeType">
... ... @@ -27,6 +29,8 @@
<button bindtap="goShopping" class="loginBtn">去逛逛</button>
</view>
</view>
<copyright class="copyright"></copyright>
<copyright class="copyright"></copyright>
</view>
</scroll-view>
\ No newline at end of file
</scroll-view>
<template is="reason" data="{{reason, showReason}}"></template>
... ...
@import "./item/item.wxss";
@import "./template/item/item.wxss";
@import "./template/reason/reason.wxss";
.page-container {
background-color: #f2f2f2;
... ... @@ -258,4 +259,4 @@ a {
bottom: 340rpx;
right: 0;
z-index: 1101;
}
\ No newline at end of file
}
... ...