Skip to content

Commit 8c4cb8a

Browse files
committed
售后申请优化
1 parent 4980eb4 commit 8c4cb8a

4 files changed

Lines changed: 75 additions & 31 deletions

File tree

pages/login/resetpwd.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,12 @@
150150
}
151151
// https://www.yuque.com/apifm/nu0f75/iu8731
152152
const res = await this.$wxapi.resetPwdUseMobileCode(this.form.mobile, this.form.pwd, this.form.code)
153+
if(res.code == 10000) {
154+
uni.$u.toast('当前用户不存在,请先注册');
155+
return
156+
}
153157
if(res.code != 0) {
154-
uni.showToast({
155-
title: res.msg,
156-
icon: 'none'
157-
})
158+
uni.$u.toast(res.msg);
158159
return
159160
}
160161
uni.navigateBack()

pages/refund/apply.vue

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<view class="form-box">
44
<u--form ref="uForm" label-width="130rpx" :model="form">
55
<u-form-item v-if="orderType == 5" label="售后类型" prop="type" required>
6-
<u-radio-group v-model="form.type" placement="row">
6+
<u-radio-group v-model="form.type" placement="row" @change="typeChange">
77
<u-radio v-for="item in supportAfsTypeList" :key="item" :customStyle="{marginBottom: '8rpx', marginRight: '8rpx'}" :label="item == 10 ? '退货' : '换货'" :name="item">
88
</u-radio>
99
</u-radio-group>
@@ -93,6 +93,7 @@
9393
type: 0,
9494
logisticsStatus: 0,
9595
orderId: undefined,
96+
reasonId: undefined,
9697
reason: undefined,
9798
remark: undefined,
9899
},
@@ -140,6 +141,10 @@
140141
this.orderSet = res.data
141142
}
142143
},
144+
typeChange(e) {
145+
this._joycityPointsSearchAfsApplyReasonList()
146+
this.form.reason = null
147+
},
143148
async _joycityPointsSearchAfsApplyReasonList(afsType) {
144149
const res = await this.$wxapi.joycityPointsSearchAfsApplyReasonList({
145150
token: this.token,
@@ -152,6 +157,7 @@
152157
title: res.msg,
153158
icon: 'none'
154159
})
160+
this.joycityPointsSearchAfsApplyReasonList = null
155161
return
156162
}
157163
this.joycityPointsSearchAfsApplyReasonList = res.data
@@ -165,6 +171,27 @@
165171
this.pics = this.pics.concat(event.file)
166172
},
167173
submit() {
174+
if(this.orderType == 5) {
175+
// 京东权益订单
176+
const reasonItem = this.joycityPointsSearchAfsApplyReasonList.find(ele => {
177+
return ele.applyReasonName == this.form.reason
178+
})
179+
if(!reasonItem) {
180+
uni.showToast({
181+
title: '请选择售后原因',
182+
icon: 'none'
183+
})
184+
return
185+
}
186+
this.form.reasonId = reasonItem.applyReasonId
187+
if(!this.form.remark) {
188+
uni.showToast({
189+
title: '备注信息不能为空',
190+
icon: 'none'
191+
})
192+
return
193+
}
194+
}
168195
this.$refs.uForm.validate().then(res => {
169196
this._submit()
170197
}).catch(errors => {

uni_modules/uview-ui/components/u-form/u-form.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,6 @@
123123
},
124124
// 对部分表单字段进行校验
125125
async validateField(value, callback, event = null) {
126-
// 开发环境才提示,生产环境不会提示
127-
if (process.env.NODE_ENV === 'development' && Object.keys(this.formRules).length === 0) {
128-
uni.$u.error('未设置rules,请看文档说明!如果已经设置,请刷新页面。');
129-
return;
130-
}
131126
// $nextTick是必须的,否则model的变更,可能会延后于此方法的执行
132127
this.$nextTick(() => {
133128
// 校验错误信息,返回给回调方法,用于存放所有form-item的错误信息
@@ -187,6 +182,11 @@
187182
},
188183
// 校验全部数据
189184
validate(callback) {
185+
// 开发环境才提示,生产环境不会提示
186+
if (process.env.NODE_ENV === 'development' && Object.keys(this.formRules).length === 0) {
187+
uni.$u.error('未设置rules,请看文档说明!如果已经设置,请刷新页面。');
188+
return;
189+
}
190190
return new Promise((resolve, reject) => {
191191
// $nextTick是必须的,否则model的变更,可能会延后于validate方法
192192
this.$nextTick(() => {

uni_modules/uview-ui/libs/function/index.js

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -278,29 +278,45 @@ if (!String.prototype.padStart) {
278278
* @param {String} fmt 格式化规则 yyyy:mm:dd|yyyy:mm|yyyy年mm月dd日|yyyy年mm月dd日 hh时MM分等,可自定义组合 默认yyyy-mm-dd
279279
* @returns {string} 返回格式化后的字符串
280280
*/
281-
function timeFormat(dateTime = null, fmt = 'yyyy-mm-dd') {
282-
// 如果为null,则格式化当前时间
283-
if (!dateTime) dateTime = Number(new Date())
284-
// 如果dateTime长度为10或者13,则为秒和毫秒的时间戳,如果超过13位,则为其他的时间格式
285-
if (dateTime.toString().length == 10) dateTime *= 1000
286-
const date = new Date(dateTime)
287-
let ret
288-
const opt = {
289-
'y+': date.getFullYear().toString(), // 年
290-
'm+': (date.getMonth() + 1).toString(), // 月
291-
'd+': date.getDate().toString(), // 日
292-
'h+': date.getHours().toString(), // 时
293-
'M+': date.getMinutes().toString(), // 分
294-
's+': date.getSeconds().toString() // 秒
281+
function timeFormat(dateTime = null, formatStr = 'yyyy-mm-dd') {
282+
let date
283+
// 若传入时间为假值,则取当前时间
284+
if (!dateTime) {
285+
date = new Date()
286+
}
287+
// 若为unix秒时间戳,则转为毫秒时间戳(逻辑有点奇怪,但不敢改,以保证历史兼容)
288+
else if (/^\d{10}$/.test(dateTime?.toString().trim())) {
289+
date = new Date(dateTime * 1000)
290+
}
291+
// 若用户传入字符串格式时间戳,new Date无法解析,需做兼容
292+
else if (typeof dateTime === 'string' && /^\d+$/.test(dateTime.trim())) {
293+
date = new Date(Number(dateTime))
294+
}
295+
// 其他都认为符合 RFC 2822 规范
296+
else {
297+
date = new Date(dateTime)
298+
}
299+
300+
const timeSource = {
301+
'y': date.getFullYear().toString(), // 年
302+
'm': (date.getMonth() + 1).toString().padStart(2, '0'), // 月
303+
'd': date.getDate().toString().padStart(2, '0'), // 日
304+
'h': date.getHours().toString().padStart(2, '0'), // 时
305+
'M': date.getMinutes().toString().padStart(2, '0'), // 分
306+
's': date.getSeconds().toString().padStart(2, '0') // 秒
295307
// 有其他格式化字符需求可以继续添加,必须转化成字符串
296308
}
297-
for (const k in opt) {
298-
ret = new RegExp(`(${k})`).exec(fmt)
299-
if (ret) {
300-
fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, '0')))
301-
}
302-
}
303-
return fmt
309+
310+
for (const key in timeSource) {
311+
const [ret] = new RegExp(`${key}+`).exec(formatStr) || []
312+
if (ret) {
313+
// 年可能只需展示两位
314+
const beginIndex = key === 'y' && ret.length === 2 ? 2 : 0
315+
formatStr = formatStr.replace(ret, timeSource[key].slice(beginIndex))
316+
}
317+
}
318+
319+
return formatStr
304320
}
305321

306322
/**

0 commit comments

Comments
 (0)