接口对接
This commit is contained in:
parent
83ffcf10c8
commit
701d63672d
|
|
@ -7,9 +7,9 @@ export default {
|
||||||
uni.addInterceptor('request', {
|
uni.addInterceptor('request', {
|
||||||
invoke(args) {
|
invoke(args) {
|
||||||
// request 触发前拼接 url
|
// request 触发前拼接 url
|
||||||
// args.url = 'https://www.opsoul.com' + args.url;
|
args.url = 'https://www.opsoul.com' + args.url;
|
||||||
args.url = 'http://127.0.0.1:80' + args.url;
|
// args.url = 'http://127.0.0.1:80' + args.url;
|
||||||
// args.url = 'http://10.45.137.214:80' + args.url;
|
// args.url = 'http://10.45.111.215:80' + args.url;
|
||||||
if (args.data) {
|
if (args.data) {
|
||||||
args.data.deptId = globalData.deptId;
|
args.data.deptId = globalData.deptId;
|
||||||
args.data.from = globalData.from;
|
args.data.from = globalData.from;
|
||||||
|
|
@ -224,11 +224,22 @@ export default {
|
||||||
name: 'uploadFile'
|
name: 'uploadFile'
|
||||||
})
|
})
|
||||||
let resStr = res[1].data;
|
let resStr = res[1].data;
|
||||||
let resObj = {};
|
let resObj = null;
|
||||||
if (resStr != null && resStr.length > 0) {
|
if (resStr != null && resStr.length > 0) {
|
||||||
resObj = JSON.parse(resStr);
|
try {
|
||||||
|
resObj = JSON.parse(resStr);
|
||||||
|
} catch(e) {
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return resObj;
|
if (!resObj || resObj.code !== 0) {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'error',
|
||||||
|
title: '上传失败'
|
||||||
|
})
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return resObj.url;
|
||||||
},
|
},
|
||||||
async listByStep(params = {goodsCategoryId : null}) {
|
async listByStep(params = {goodsCategoryId : null}) {
|
||||||
let res = await uni.request({
|
let res = await uni.request({
|
||||||
|
|
@ -261,5 +272,13 @@ export default {
|
||||||
data: params
|
data: params
|
||||||
})
|
})
|
||||||
return res[1].data;
|
return res[1].data;
|
||||||
|
},
|
||||||
|
async addGoods(params) {
|
||||||
|
let res = await uni.request({
|
||||||
|
url: '/goods/goods/addGoods',
|
||||||
|
method: 'POST',
|
||||||
|
data: params
|
||||||
|
})
|
||||||
|
return res[1].data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -404,10 +404,8 @@
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
// 上传图片
|
// 上传图片
|
||||||
this.$request.uploadFile(res.tempFilePaths[0]).then((uploadRes) => {
|
this.$request.uploadFile(res.tempFilePaths[0]).then((uploadRes) => {
|
||||||
// 成功后才存入缓存
|
// 存入缓存
|
||||||
if (uploadRes.code === 0) {
|
imgList.push(uploadRes.url);
|
||||||
imgList.push(uploadRes.url);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,11 @@
|
||||||
<form @submit="submit">
|
<form @submit="submit">
|
||||||
<view class="cu-form-group">
|
<view class="cu-form-group">
|
||||||
<view class="title">服务名称</view>
|
<view class="title">服务名称</view>
|
||||||
<input name="servName" :value="formData.servName" :v-model="formData.servName" placeholder="请编辑上架标题(供客户搜索)"></input>
|
<input name="servName" v-model="formData.servName" placeholder="请编辑上架标题(供客户搜索)"></input>
|
||||||
</view>
|
</view>
|
||||||
<view class="cu-form-group">
|
<view class="cu-form-group">
|
||||||
<view class="title">服务描述</view>
|
<view class="title">服务描述</view>
|
||||||
<input name="servDesc" :value="formData.servDesc" :v-model="formData.servDesc" placeholder="让客户更清晰的上架内容描述"></input>
|
<input name="servDesc" v-model="formData.servDesc" placeholder="让客户更清晰的上架内容描述"></input>
|
||||||
</view>
|
</view>
|
||||||
<view class="solid-top">
|
<view class="solid-top">
|
||||||
<view class="cu-form-group">
|
<view class="cu-form-group">
|
||||||
|
|
@ -29,15 +29,15 @@
|
||||||
<view class="flex">
|
<view class="flex">
|
||||||
<view class="flex-sub">
|
<view class="flex-sub">
|
||||||
<checkbox style="transform:scale(1)" class="main-color margin-right-xs" :value="index" :checked="item.checked"></checkbox>
|
<checkbox style="transform:scale(1)" class="main-color margin-right-xs" :value="index" :checked="item.checked"></checkbox>
|
||||||
<text>{{item.name}}</text>
|
<text>{{item.goodsCategoryName}}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="flex-sub">
|
<view class="flex-sub">
|
||||||
<input class="radius-input" @input="inputSpecs($event, index, 'title')" :value="item.title" placeholder="自编辑购买标题"></input>
|
<input class="radius-input" @input="inputSpecs($event, index, 'goodsStandardName')" :value="item.goodsStandardName" placeholder="自编辑购买标题"></input>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="flex margin-top-xs">
|
<view class="flex margin-top-xs">
|
||||||
<view class="flex-sub">
|
<view class="flex-sub">
|
||||||
<input class="radius-input" @input="inputSpecs($event, index, 'price')" :value="item.price" placeholder="价格(平6%+¥5销10%+¥18)"></input>
|
<input class="radius-input" @input="inputSpecs($event, index, 'goodsPrice')" :value="item.goodsPrice" placeholder="价格(平6%+¥5销10%+¥18)"></input>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="flex margin-top-xs">
|
<view class="flex margin-top-xs">
|
||||||
|
|
@ -105,6 +105,25 @@
|
||||||
<view class="title">上门费</view>
|
<view class="title">上门费</view>
|
||||||
<input type="digit" name="doorPrice" :value="formData.doorPrice" :v-model="formData.doorPrice" placeholder="单位:元/次"></input>
|
<input type="digit" name="doorPrice" :value="formData.doorPrice" :v-model="formData.doorPrice" placeholder="单位:元/次"></input>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="cu-bar bg-white solid-top">
|
||||||
|
<view class="action text-black">
|
||||||
|
商品封面图上传
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="cu-form-group">
|
||||||
|
<view class="grid col-4 grid-square flex-sub">
|
||||||
|
<view class="bg-img" v-for="(item,index) in formData.coverImgList" :key="index" @tap="viewImage($event, formData.coverImgList)"
|
||||||
|
:data-url="item">
|
||||||
|
<image :src="item" mode="aspectFill"></image>
|
||||||
|
<view class="cu-tag bg-red" @tap.stop="delImg($event, formData.coverImgList)" :data-index="index">
|
||||||
|
<text class='cuIcon-close'></text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="solids" @tap="chooseImgList($event, 'coverImgList')" v-if="formData.coverImgList.length === 0">
|
||||||
|
<text class='cuIcon-cameraadd'></text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
<view class="cu-bar bg-white solid-top">
|
<view class="cu-bar bg-white solid-top">
|
||||||
<view class="action text-black">
|
<view class="action text-black">
|
||||||
详情图上传
|
详情图上传
|
||||||
|
|
@ -187,7 +206,8 @@
|
||||||
imgList: [],
|
imgList: [],
|
||||||
detailDesc: '',
|
detailDesc: '',
|
||||||
descImgList: [],
|
descImgList: [],
|
||||||
video: {}
|
coverImgList: [],
|
||||||
|
video: ''
|
||||||
},
|
},
|
||||||
categoryList: [],
|
categoryList: [],
|
||||||
categoryMultiIndex: [0, 0, 0],
|
categoryMultiIndex: [0, 0, 0],
|
||||||
|
|
@ -269,7 +289,9 @@
|
||||||
}
|
}
|
||||||
this.formData.category = chosenCategory;
|
this.formData.category = chosenCategory;
|
||||||
|
|
||||||
this.formData.specsList = await this.$api.data('specsList');
|
// 查询最后一级品类
|
||||||
|
let res = await this.$request.listByStep({goodsCategoryId: chosenCategory[2].goodsCategoryId});
|
||||||
|
this.formData.specsList = res.data;
|
||||||
},
|
},
|
||||||
async categoryColChange(e) {
|
async categoryColChange(e) {
|
||||||
let colObj = e.detail;
|
let colObj = e.detail;
|
||||||
|
|
@ -308,7 +330,7 @@
|
||||||
async regionColChange(e) {
|
async regionColChange(e) {
|
||||||
let colObj = e.detail;
|
let colObj = e.detail;
|
||||||
if (colObj.column == 0) {
|
if (colObj.column == 0) {
|
||||||
// 通过二级查三级
|
// 通过一级查二级
|
||||||
let subAreaList = await this.$request.areaListByStep({parentCode: this.regionList[0][colObj.value].areaCode});
|
let subAreaList = await this.$request.areaListByStep({parentCode: this.regionList[0][colObj.value].areaCode});
|
||||||
subAreaList = subAreaList.data;
|
subAreaList = subAreaList.data;
|
||||||
this.regionList.pop();
|
this.regionList.pop();
|
||||||
|
|
@ -348,11 +370,18 @@
|
||||||
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
|
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
|
||||||
sourceType: ['album'], //从相册选择
|
sourceType: ['album'], //从相册选择
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (this.formData[imgListField].length != 0) {
|
uni.showLoading({
|
||||||
this.formData[imgListField] = this.formData[imgListField].concat(res.tempFilePaths)
|
title: '上传中',
|
||||||
} else {
|
mask:true
|
||||||
this.formData[imgListField] = res.tempFilePaths
|
});
|
||||||
}
|
res.tempFilePaths.forEach((tmpUrl, index) => {
|
||||||
|
this.$request.uploadFile(tmpUrl).then((url) => {
|
||||||
|
this.formData[imgListField].push(url);
|
||||||
|
if (index === res.tempFilePaths.length - 1) {
|
||||||
|
uni.hideLoading();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
@ -376,13 +405,62 @@
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
async selectVideo(e) {
|
async selectVideo(e) {
|
||||||
let res = await this.$request.uploadFile(e.tempFilePaths[0]);
|
uni.showLoading({
|
||||||
if (res.code === 0) {
|
title: '上传中',
|
||||||
this.formData.video = res.url;
|
mask:true
|
||||||
}
|
});
|
||||||
|
this.formData.video = await this.$request.uploadFile(e.tempFilePaths[0]);
|
||||||
|
uni.hideLoading();
|
||||||
},
|
},
|
||||||
submit() {
|
async submit() {
|
||||||
console.log(this.formData)
|
console.log(this.formData)
|
||||||
|
let goodsStandardList = this.formData.specsList.filter((item) => {
|
||||||
|
if (item.checked) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let goodsAreaList = this.formData.districtList.filter((item) => {
|
||||||
|
if (item.checked) {
|
||||||
|
item.countryAreaId = item.areaId;
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 0是轮播图,1是详情图
|
||||||
|
let goodsImgsList = [];
|
||||||
|
this.formData.imgList.forEach((url) => {
|
||||||
|
goodsImgsList.push({
|
||||||
|
imgUrl: url,
|
||||||
|
imgType: 0
|
||||||
|
});
|
||||||
|
});
|
||||||
|
this.formData.descImgList.forEach((url) => {
|
||||||
|
goodsImgsList.push({
|
||||||
|
imgUrl: url,
|
||||||
|
imgType: 1
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
let params = {
|
||||||
|
goodsName: this.formData.servName,
|
||||||
|
deptGoodsCategoryId: this.formData.category[2].goodsCategoryId,
|
||||||
|
goodsStandardList: goodsStandardList,
|
||||||
|
goodsAreaList: goodsAreaList,
|
||||||
|
goodsImgUrl: this.formData.coverImgList[0],
|
||||||
|
goodsImgsList: goodsImgsList,
|
||||||
|
goodsVideoUrl: this.formData.video,
|
||||||
|
status: 0,
|
||||||
|
remark: this.formData.detailDesc
|
||||||
|
}
|
||||||
|
console.log("格式化后的请求参数:" + params)
|
||||||
|
let res = await this.$request.addGoods(params);
|
||||||
|
if (res.code === 0) {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'success'
|
||||||
|
})
|
||||||
|
uni.navigateBack({
|
||||||
|
delta: -1
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -393,7 +471,7 @@
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.certern-height {
|
.certern-height {
|
||||||
height: 520rpx;
|
max-height: 520rpx;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
.long-btn{
|
.long-btn{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue