Skip to content

Commit 00da712

Browse files
committed
增加售后支持
1 parent e8837d0 commit 00da712

7 files changed

Lines changed: 285 additions & 17 deletions

File tree

node_modules/apifm-uniapp/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pages.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@
138138
"style": {
139139
"navigationBarTitleText": "搜一搜"
140140
}
141+
},
142+
{
143+
"path" : "pages/refund/apply",
144+
"style": {
145+
"navigationBarTitleText": "申请售后"
146+
}
141147
}
142148
],
143149
"globalStyle": {

pages/my/index.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</view>
2828
<u-line></u-line>
2929
<u-cell icon="order" title="我的订单" value="更多" isLink clickable url="/pages/order/index"></u-cell>
30-
<u-grid col="3" :border="false" @click="orderGridClick">
30+
<u-grid col="5" :border="false" @click="orderGridClick">
3131
<u-grid-item name="0">
3232
<view class="grid_item">
3333
<u-icon name="rmb-circle" size="52rpx"></u-icon>
@@ -46,18 +46,18 @@
4646
<text class="txt">待收货</text>
4747
</view>
4848
</u-grid-item>
49-
<!-- <u-grid-item name="3">
49+
<u-grid-item name="3">
5050
<view class="grid_item">
5151
<u-icon name="thumb-up" size="52rpx"></u-icon>
5252
<text class="txt">待评价</text>
5353
</view>
54-
</u-grid-item> -->
55-
<!-- <u-grid-item name="99">
54+
</u-grid-item>
55+
<u-grid-item name="99">
5656
<view class="grid_item">
5757
<u-icon name="server-man" size="52rpx"></u-icon>
5858
<text class="txt">售后</text>
5959
</view>
60-
</u-grid-item> -->
60+
</u-grid-item>
6161
</u-grid>
6262
<u-cell icon="grid" title="常用功能"></u-cell>
6363
<u-grid col="4" :border="false" @click="go">

pages/order/index.vue

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,32 @@
2222
<view v-if="item2.property" class="type">{{ item2.property }}</view>
2323
</view>
2424
<view class="right">
25-
<view class="price">
26-
¥{{ item2.amountSingle }}
25+
<view class="price-score">
26+
<view v-if="item2.amountSingle" class="item"><text>¥</text>{{item2.amountSingle}}</view>
27+
<view v-if="item2.score" class="item"><text>∮</text>{{item2.score}}</view>
2728
</view>
2829
<view class="number">x{{ item2.number }}</view>
2930
</view>
3031
</view>
3132
<view class="total">
3233
共{{ item.goodsNumber }}件商品 合计:
33-
<text class="total-price">
34-
¥{{ item.amountReal }}
35-
</text>
34+
<view class="price-score" style="display: inline-flex;">
35+
<view v-if="item.amountReal" class="item"><text>¥</text>{{item.amountReal}}</view>
36+
<view v-if="item.score" class="item"><text>∮</text>{{item.score}}</view>
37+
</view>
3638
</view>
3739
<view v-if="item.status == 0" class="bottom">
3840
<view class="exchange btn" @click="close(item.id)">取消订单</view>
3941
<view class="evaluate btn ml24" @click="pay(index)">立即支付</view>
4042
</view>
43+
<view v-if="item.status > 0 && !item.isEnd" class="bottom">
44+
<view v-if="item.refundStatus == 1" class="btn-box">
45+
<u-button type="error" plain size="small" shape="circle" text="撤销售后" @click="refundCancel(item)"></u-button>
46+
</view>
47+
<view v-else class="btn-box">
48+
<u-button type="error" plain size="small" shape="circle" text="退换货" @click="refund(item)"></u-button>
49+
</view>
50+
</view>
4151
</view>
4252
</view>
4353
</view>
@@ -68,6 +78,14 @@ export default {
6878
name: '待收货',
6979
status: '2'
7080
},
81+
{
82+
name: '待评价',
83+
status: '3'
84+
},
85+
{
86+
name: '售后',
87+
status: '99'
88+
},
7189
],
7290
current: 0,
7391
};
@@ -98,11 +116,17 @@ export default {
98116
async getOrderList() {
99117
const curTab = this.list[this.current]
100118
this.orderList = null
101-
// https://www.yuque.com/apifm/nu0f75/uwggsm
102-
const res = await this.$wxapi.orderList({
119+
const postData = {
103120
token: this.token,
104121
status: curTab.status
105-
})
122+
}
123+
if(curTab.status == 99) {
124+
// 售后订单
125+
postData.refundStatus = 1
126+
postData.status = ''
127+
}
128+
// https://www.yuque.com/apifm/nu0f75/uwggsm
129+
const res = await this.$wxapi.orderList(postData)
106130
if(res.code == 0) {
107131
const goodsMap = res.data.goodsMap
108132
res.data.orderList.forEach(ele => {
@@ -190,6 +214,38 @@ export default {
190214
url: './detail?id=' + orderId
191215
})
192216
},
217+
async refund(item) {
218+
uni.navigateTo({
219+
url: '../refund/apply?orderId=' + item.id
220+
})
221+
},
222+
async refundCancel(item) {
223+
uni.showModal({
224+
title: '请确认',
225+
content: '确定要撤销售后吗?',
226+
success: res => {
227+
if (res.confirm) {
228+
this._refundCancel(item)
229+
}
230+
}
231+
});
232+
},
233+
async _refundCancel(item) {
234+
// https://www.yuque.com/apifm/nu0f75/bq6e6r
235+
const res = await this.$wxapi.refundApplyCancel(this.token, item.id)
236+
if(res.code == 0) {
237+
uni.showToast({
238+
title: '已撤销',
239+
icon: 'none'
240+
})
241+
this.getOrderList();
242+
} else {
243+
uni.showToast({
244+
title: res.msg,
245+
icon: 'none'
246+
})
247+
}
248+
}
193249
}
194250
};
195251
</script>
@@ -312,4 +368,7 @@ page {
312368
.ml24 {
313369
margin-left: 24rpx;
314370
}
371+
.btn-box {
372+
width: 160rpx;
373+
}
315374
</style>

pages/pay/order.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<image :src="item.pic" mode="aspectFill"></image>
88
</view>
99
<view class="content">
10-
<view class="title u-line-2">{{ item.goodsName }}</view>
10+
<view class="title u-line-3">{{ item.goodsName }}</view>
1111
<view class="type">
1212
<text v-for="(item2, index2) in item.sku"
1313
:key="'b' + index2">{{ item2.optionName }}:{{ item2.optionValueName }}/</text>

pages/refund/apply.vue

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
<template>
2+
<view>
3+
<view class="form-box">
4+
<u--form ref="uForm" label-width="130rpx" :model="form">
5+
<u-form-item label="售后类型" prop="type" required>
6+
<u-radio-group v-model="form.type" placement="row">
7+
<u-radio :customStyle="{marginBottom: '8rpx', marginRight: '8rpx'}" label="仅退款" :name="0">
8+
</u-radio>
9+
<u-radio :customStyle="{marginBottom: '8rpx', marginRight: '8rpx'}" label="退款退货" :name="1">
10+
</u-radio>
11+
<u-radio :customStyle="{marginBottom: '8rpx', marginRight: '8rpx'}" label="换货" :name="2">
12+
</u-radio>
13+
</u-radio-group>
14+
</u-form-item>
15+
<u-cell v-if="orderSet && orderSet.afterSaleAddress && (form.type == 1 || form.type == 2)" title="寄回地址" required :label="orderSet.afterSaleAddress" value="复制" isLink clickable @click="cp(orderSet.afterSaleAddress)"></u-cell>
16+
<u-form-item label="收货情况" prop="logisticsStatus" required>
17+
<u-radio-group v-model="form.logisticsStatus" placement="row">
18+
<u-radio :customStyle="{marginBottom: '8rpx', marginRight: '8rpx'}" label="未收到货" :name="0">
19+
</u-radio>
20+
<u-radio :customStyle="{marginBottom: '8rpx', marginRight: '8rpx'}" label="已收到货" :name="1">
21+
</u-radio>
22+
</u-radio-group>
23+
</u-form-item>
24+
<u-form-item label="售后原因" prop="reason" required>
25+
<u-radio-group v-model="form.reason" placement="column">
26+
<u-radio v-for="(item,index) in reasons" :customStyle="{marginBottom: '8rpx', marginRight: '8rpx'}" :label="item" :name="item"></u-radio>
27+
</u-radio-group>
28+
</u-form-item>
29+
<u-form-item label="备注" prop="remark">
30+
<u--textarea v-model="form.remark" placeholder="请输入备注信息" ></u--textarea>
31+
</u-form-item>
32+
<u-form-item label="拍照上传">
33+
<u-upload
34+
uploadText="添加照片"
35+
:fileList="pics"
36+
@afterRead="afterReadPic"
37+
@delete="deletePic"
38+
multiple
39+
></u-upload>
40+
</u-form-item>
41+
</u--form>
42+
</view>
43+
<view class="submit">
44+
<u-button type="success" @click="submit">保存</u-button>
45+
</view>
46+
</view>
47+
</template>
48+
49+
<script>
50+
export default {
51+
data() {
52+
return {
53+
rules: {
54+
type: [{
55+
type: 'number',
56+
required: true,
57+
message: '不能为空',
58+
// 可以单个或者同时写两个触发验证方式
59+
trigger: ['change', 'blur'],
60+
}],
61+
logisticsStatus: [{
62+
type: 'number',
63+
required: true,
64+
message: '不能为空',
65+
// 可以单个或者同时写两个触发验证方式
66+
trigger: ['change', 'blur'],
67+
}],
68+
reason: [{
69+
required: true,
70+
message: '不能为空',
71+
// 可以单个或者同时写两个触发验证方式
72+
trigger: ['change', 'blur'],
73+
}],
74+
address: [{
75+
required: true,
76+
message: '不能为空',
77+
// 可以单个或者同时写两个触发验证方式
78+
trigger: ['change', 'blur'],
79+
}],
80+
},
81+
form: {
82+
type: 0,
83+
logisticsStatus: 0,
84+
orderId: undefined,
85+
reason: undefined,
86+
remark: undefined,
87+
},
88+
reasons: [
89+
"不喜欢/不想要",
90+
"空包裹",
91+
"未按约定时间发货",
92+
"快递/物流一直未送达",
93+
"货物破损已拒签",
94+
"退运费",
95+
"规格尺寸与商品页面描述不符",
96+
"功能/效果不符",
97+
"质量问题",
98+
"少件/漏发",
99+
"包装/商品破损",
100+
"发票问题",
101+
],
102+
pics: [],
103+
orderSet: undefined
104+
};
105+
},
106+
onReady() {
107+
this.$refs.uForm.setRules(this.rules);
108+
},
109+
onLoad(e) {
110+
this.form.orderId = e.orderId
111+
this.form.reason = this.reasons[0]
112+
this._orderSet()
113+
},
114+
mounted() {},
115+
methods: {
116+
async _orderSet() {
117+
const res = await this.$wxapi.orderSet()
118+
if(res.code == 0) {
119+
this.orderSet = res.data
120+
}
121+
},
122+
// 删除图片
123+
deletePic(event) {
124+
this.pics.splice(event.index, 1)
125+
},
126+
// 新增图片
127+
async afterReadPic(event) {
128+
this.pics = this.pics.concat(event.file)
129+
},
130+
submit() {
131+
this.$refs.uForm.validate().then(res => {
132+
this._submit()
133+
}).catch(errors => {
134+
uni.showToast({
135+
title: '表单请填写完整',
136+
icon: 'none'
137+
})
138+
})
139+
},
140+
async _submit() {
141+
uni.showLoading({
142+
title: '',
143+
})
144+
// 上传图片
145+
const pics = []
146+
if(this.pics && this.pics.length > 0) {
147+
for (let i = 0; i < this.pics.length; i++) {
148+
const file = this.pics[i]
149+
// https://www.yuque.com/apifm/nu0f75/ygvqh6
150+
const res = await this.$wxapi.uploadFile(this.token, file.url)
151+
if(res.code != 0) {
152+
uni.hideLoading()
153+
uni.showToast({
154+
title: res.msg,
155+
icon: 'none'
156+
})
157+
return
158+
}
159+
pics.push(res.data.url)
160+
}
161+
}
162+
// https://www.yuque.com/apifm/nu0f75/dg4ggt
163+
const res = await this.$wxapi.refundApply({
164+
token: this.token,
165+
amount: 0,
166+
...this.form,
167+
pic: pics.join()
168+
})
169+
uni.hideLoading()
170+
if (res.code != 0) {
171+
uni.showToast({
172+
title: res.msg,
173+
icon: 'none'
174+
})
175+
} else {
176+
uni.showToast({
177+
title: '提交成功,请耐心等待客服处理',
178+
})
179+
uni.navigateBack()
180+
}
181+
},
182+
cp(v) {
183+
uni.setClipboardData({
184+
data: v,
185+
success: function () {
186+
uni.showToast({
187+
title: '已复制'
188+
})
189+
}
190+
});
191+
}
192+
}
193+
};
194+
</script>
195+
196+
<style lang="scss" scoped>
197+
.form-box {
198+
padding: 0 32rpx;
199+
}
200+
.submit {
201+
padding: 32rpx;
202+
}
203+
</style>

store/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const store = new Vuex.Store({
3737
},
3838
app_show_pic_version: lifeData.app_show_pic_version ? lifeData.app_show_pic_version : '',
3939
referrer: lifeData.referrer ? lifeData.referrer : '',
40-
token: lifeData.token ? lifeData.token : '2830961b-8da6-446a-86fb-5d44e159d8aa',
40+
token: lifeData.token ? lifeData.token : '527dd034-5d36-4d84-9dd7-bf4bfe1e3165',
4141
uid: lifeData.uid ? lifeData.uid : '2518576',
4242
cartNumber: 0
4343
},

0 commit comments

Comments
 (0)