Commit d783678e authored by Morson's avatar Morson

feat(parts):申请配件模块调整

parent f1c8af0f
...@@ -142,6 +142,8 @@ export default { ...@@ -142,6 +142,8 @@ export default {
this.$u.route({ this.$u.route({
url: "pages/parts/addParts", url: "pages/parts/addParts",
params: { params: {
type: 1,
brandId: this.order.brandId,
categaryId: this.order.categoryId categaryId: this.order.categoryId
} }
}) })
...@@ -192,8 +194,7 @@ export default { ...@@ -192,8 +194,7 @@ export default {
} }
const address = this.addressInfo const address = this.addressInfo
let params = { let params = {
workOrderId: this.orderId, applyType: '1',
applyType: this.applyType,
remark: this.remark, remark: this.remark,
parts: JSON.stringify(this.parts), parts: JSON.stringify(this.parts),
name: address.name, name: address.name,
...@@ -202,12 +203,17 @@ export default { ...@@ -202,12 +203,17 @@ export default {
city: address.region[1], city: address.region[1],
district: address.region[2], district: address.region[2],
address: address.address, address: address.address,
images: null,
} }
this.$u.api.applyParts(params).then((res) => { this.$u.api.createParts(params).then((res) => {
if (res.code == 200) { if (res.code == 200 && res.data) {
this.$u.route({ this.$u.route({
type: 'redirect', type: 'redirect',
url: "pages/parts/nodes" url: "pages/parts/nodes",
params: {
type: 1,
returnNo: res.data.orderNumber
}
}) })
} else { } else {
console.log(res.message, "配件申请失败!"); console.log(res.message, "配件申请失败!");
......
...@@ -76,6 +76,48 @@ const imageCache = async function (vm, src, host) { ...@@ -76,6 +76,48 @@ const imageCache = async function (vm, src, host) {
return image_url return image_url
} }
} }
/*
fromData 多文件提交
@params url 请求的地址
@params data 请求所带参数
*/
const submitFormData = (url, data = null) => new Promise((resolve) => {
/* 规定上传文件的键值做参数处理 */
// 比如
// data = {
// files : [],
// ...params,
// }
/* 把对应的数据处理归位 */
/* 这里有个要注意
虽然 填写了 files uniapp不会去拿 name 和filePath
但 uploadFile 的 name 和 filePath 必填 不然会报错
*/
let files = [];
for (let key in data.files) {
files.push({
name: key,
uri: data.files[key]
});
}
delete data.files;
options.formData = data;
options.files = files;
uni.uploadFile({
success: ({
statusCode,
data
}) => resolve(success(statusCode, data)),
fail: ({
errMsg
}) => resolve(fail(errMsg)),
filePath: '',
name: '',
...options
})
})
module.exports = { module.exports = {
formatTime: function (n) { formatTime: function (n) {
var e = n.getFullYear(), r = n.getMonth() + 1, o = n.getDate(), i = n.getHours(), u = n.getMinutes(), a = n.getSeconds(); var e = n.getFullYear(), r = n.getMonth() + 1, o = n.getDate(), i = n.getHours(), u = n.getMinutes(), a = n.getSeconds();
...@@ -102,4 +144,5 @@ module.exports = { ...@@ -102,4 +144,5 @@ module.exports = {
getOpenid, getOpenid,
setOpenid, setOpenid,
imageCache, imageCache,
submitFormData,
}; };
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment