dingdong-master/pages/my/new-serv.vue

1095 lines
38 KiB
Vue
Raw Normal View History

2022-06-22 17:40:50 +08:00
<template>
<view>
<!-- 顶部操作条 -->
<cu-custom :bgColor="'bg-main-color'" :isBack="true">
<block slot="backText">返回</block>
<block slot="content">服务上架</block>
</cu-custom>
<!-- 表单内容 -->
2023-02-15 22:30:59 +08:00
<form @submit="submit" style="position: relative; z-index: 1;">
2022-06-22 17:40:50 +08:00
<view class="cu-form-group">
2022-07-26 22:37:31 +08:00
<view class="title">服务名称<text class="text-red">*</text></view>
2022-06-22 17:40:50 +08:00
<input name="servName" v-model="formData.servName" placeholder="请编辑上架标题(供客户搜索)"></input>
</view>
<view class="cu-form-group">
2023-02-15 22:30:59 +08:00
<view class="title">搜索关键词<text class="text-red">*</text></view>
2023-02-14 23:44:16 +08:00
<input name="servDesc" v-model="formData.servDesc" placeholder="多个关键词用#分隔"></input>
2022-06-22 17:40:50 +08:00
</view>
<view class="solid-top">
<view class="cu-form-group">
2022-07-26 22:37:31 +08:00
<view class="title">选择类目<text class="text-red">*</text></view>
2022-06-22 17:40:50 +08:00
<picker :mode="'multiSelector'" @change="categoryChange" @columnchange="categoryColChange"
2023-04-01 18:56:30 +08:00
:value="categoryMultiIndex" :range-key="'goodsCategoryName'" :range="categoryList"
:disabled="goodsId">
2023-02-15 22:30:59 +08:00
<input v-if="formData.category" disabled class="line-input radius-input"
:value="formData.category && formData.category.length ? formData.category[0].goodsCategoryName + '-' + formData.category[1].goodsCategoryName + '-' + formData.category[2].goodsCategoryName : ''"
2023-04-01 18:56:30 +08:00
placeholder="请选择类目"/>
2023-02-15 22:30:59 +08:00
<input v-else-if="formData.categoryConcatName" disabled class="line-input radius-input"
2023-04-01 18:56:30 +08:00
:value="formData.categoryConcatName" placeholder="请选择类目" :class="goodsId ? 'bg-gray' : ''"/>
2022-06-22 17:40:50 +08:00
</picker>
</view>
<view v-if="formData.specsList && formData.specsList.length > 0">
<checkbox-group class="padding-lr bg-white" @change="checkSpecs"
:class="isShowAllSpecs ? '' : 'certern-height'">
2024-03-04 10:04:10 +08:00
<view v-for="(item, index) in formData.specsList" :key="index" class="padding-tb-sm">
2022-06-22 17:40:50 +08:00
<view class="flex">
<view class="flex-sub">
2023-04-01 18:56:30 +08:00
<checkbox style="transform:scale(1)" class="margin-right-xs"
:value="index" :checked="item.checked" :class="goodsId && item.checked ? 'grey' : 'main-color'" :disabled="goodsId && item.checked"></checkbox>
2022-06-22 17:40:50 +08:00
<text>{{item.goodsCategoryName}}</text>
2023-02-12 04:15:15 +08:00
</view>`
2022-06-22 17:40:50 +08:00
<view class="flex-sub">
2022-09-11 14:44:24 +08:00
<input class="sm radius-input"
@input="inputSpecs($event, index, 'goodsStandardName')"
:value="item.goodsStandardName" maxlength="20"
placeholder="自编辑购买标题(限20字符)"></input>
2022-06-22 17:40:50 +08:00
</view>
</view>
<view class="flex margin-top-xs">
2023-02-15 22:30:59 +08:00
<view class="margin-right-xs">
<view class='text-red' style="position: absolute; z-index: 0;">*</view>
<zb-tooltip
:content="'平' + parseInt(item.deptRate * 100) + '%+¥' + $calcUtil.curNumPlaces(item.deptMoney, 3) + '销' + parseInt((Number(item.oneRate) + Number(item.twoRate) + Number(item.threeRate) + Number(item.retainRate)) * 100) + '%+¥' + $calcUtil.curNumPlaces(item.retainMoney, 3)"
placement="right" ref="goodsPriceTip">
2023-03-18 23:59:22 +08:00
<input type="number" class="radius-input xs" @input="inputSpecs($event, index, 'goodsPrice')"
2023-02-15 22:30:59 +08:00
:value="item.goodsPrice" placeholder="价格"
@blur="hideTips('goodsPriceTip', index)"></input>
2022-09-11 14:44:24 +08:00
</zb-tooltip>
2022-06-22 17:40:50 +08:00
</view>
2022-09-11 14:44:24 +08:00
<view class="margin-right-xs" style="flex-basis: 21%;">
2023-03-18 23:59:22 +08:00
<input type="number" class="radius-input xs" @input="inputSpecs($event, index, 'extMoney')"
:value="item.extMoney" placeholder="追加提成额"></input>
2022-06-22 17:40:50 +08:00
</view>
2022-09-11 14:44:24 +08:00
<view class="margin-right-xs" style="flex-basis: 14%;">
2023-03-18 23:59:22 +08:00
<input type="number" class="radius-input xs" @input="inputSpecs($event, index, 'groupPrice')"
:value="item.groupPrice" placeholder="团购价"></input>
</view>
2022-09-11 14:44:24 +08:00
<view class="margin-right-xs" style="flex-basis: 11%;">
<input class="radius-input xs" @input="inputSpecs($event, index, 'goodsUnit')"
:value="item.goodsUnit" placeholder="单位"></input>
</view>
2023-02-15 22:30:59 +08:00
<view style="flex-basis: 14%;">
<view class='text-red' style="position: absolute; absolute; z-index: 0;">*</view>
2023-03-18 23:59:22 +08:00
<input type="number" class="radius-input xs" @input="inputSpecs($event, index, 'goodsNum')"
2022-09-11 14:44:24 +08:00
:value="item.goodsNum" placeholder="库存数"></input>
</view>
2022-06-22 17:40:50 +08:00
</view>
</view>
</checkbox-group>
<view class="text-bold text-gray text-lg text-center bg-white padding-tb-sm"
@click="showAllSpecs()"><text :class="'cuIcon-' + (isShowAllSpecs ? 'fold' : 'unfold')"></text>
</view>
</view>
<!-- <view class="solid-top"> -->
<!-- <view class="padding-lr flex align-center">
2022-06-22 17:40:50 +08:00
<view class="flex-twice flex justify-start align-center">
<view style="width: 20%;">单位</view>
<my-uni-combox :candidates="productUnits" placeholder="请选择" v-model="formData.productUnit">
</my-uni-combox>
</view>
<view class="flex-sub margin-left">
优惠券+
</view>
</view> -->
<!-- <view class="padding-lr flex align-center padding-tb-xs"> -->
<!-- <view class="cu-form-group"> -->
<!-- <checkbox style="transform:scale(1)" class="main-color margin-right-xs" :value="true"
:v-model="formData.isGoldenServ" :checked="formData.isGoldenServ"></checkbox> -->
<!-- <view class="title">金牌服务<text class="margin-left-xs text-red">*</text></view> -->
<!-- <my-uni-combox :candidates="servHonorTitle" placeholder="请选择" v-model="formData.servHonorTitle"> -->
<!-- </my-uni-combox> -->
<!-- </view> -->
<!-- <view class="flex-twice flex justify-start align-center">
2022-06-22 17:40:50 +08:00
<view style="width: 25%;">质保期</view>
<my-uni-combox :candidates="productProtectTimes" placeholder="请选择"
v-model="formData.productProtectTime"></my-uni-combox>
</view> -->
<!-- </view> -->
<!-- </view> -->
</view>
2023-02-15 22:30:59 +08:00
<view class="cu-form-group solid-top justify-start">
<view class="title">商品单位<text class="text-red">*</text></view>
<my-uni-combox class="form-val-area" :candidates="goodsUnitList" placeholder="上方已填单位则以上方所填为准"
v-model="formData.goodsUnit">
</my-uni-combox>
</view>
<view class="cu-form-group justify-start">
<view class="title">质保期<text class="text-red">*</text></view>
<my-uni-combox class="form-val-area" :candidates="warrantyPeriodList" placeholder="请选择"
v-model="formData.warrantyPeriod">
</my-uni-combox>
</view>
<view class="cu-form-group justify-start">
<!-- <checkbox style="transform:scale(1)" class="main-color margin-right-xs" :value="true"
:v-model="formData.isGoldenServ" :checked="formData.isGoldenServ"></checkbox> -->
2023-02-15 22:30:59 +08:00
<view class="title">服务活动<text class="text-red">*</text></view>
2023-02-12 04:15:15 +08:00
<my-uni-combox class="form-val-area" :candidates="servActivityList" placeholder="请选择"
v-model="formData.servActivity">
</my-uni-combox>
2023-02-15 22:30:59 +08:00
</view>
<view class="cu-form-group justify-start">
<!-- <checkbox style="transform:scale(1)" class="main-color margin-right-xs" :value="true"
:v-model="formData.isGoldenServ" :checked="formData.isGoldenServ"></checkbox> -->
<view class="title">服务时效<text class="text-red">*</text></view>
<my-uni-combox class="form-val-area" :candidates="expectDurationList" placeholder="请选择"
v-model="formData.expectDuration">
</my-uni-combox>
2022-06-22 17:40:50 +08:00
</view>
<view class="solid-top">
<view class="cu-form-group">
2022-07-26 22:37:31 +08:00
<view class="title">上架区域<text class="text-red">*</text></view>
2022-06-22 17:40:50 +08:00
<picker :mode="'multiSelector'" @change="regionChange" @columnchange="regionColChange"
:value="regionMultiIndex" :range-key="'areaName'" :range="regionList">
2023-02-12 04:15:15 +08:00
<input disabled class="line-input radius-input" v-if="formData.region"
2022-06-22 17:40:50 +08:00
:value="formData.region && formData.region.length ? formData.region[0].areaName + '-' + formData.region[1].areaName : ''"
placeholder="请选择区域"></input>
2023-02-15 22:30:59 +08:00
<input disabled class="line-input radius-input" v-else-if="formData.areaConcatName"
:value="formData.areaConcatName" placeholder="请选择区域"></input>
2022-06-22 17:40:50 +08:00
</picker>
</view>
<view class="padding-lr bg-white">
<checkbox-group @change="checkDistirct" class="grid col-3">
2024-03-04 10:04:10 +08:00
<view v-for="(item, index) in formData.districtList" :key="index" class="margin-tb-xs">
2022-06-22 17:40:50 +08:00
<checkbox style="transform:scale(1)" class="main-color margin-right-xs" :value="index"
:checked="item.checked"></checkbox>
<text>{{item.areaName}}</text>
</view>
</checkbox-group>
</view>
</view>
<view class="cu-bar bg-white">
2022-08-25 00:13:48 +08:00
<view class="action text-black">区域描述<text class="text-red">*</text></view>
2023-02-15 22:30:59 +08:00
</view>
<view class="padding-lr-sm padding-bottom-sm bg-white">
<textarea name="areaDesc" style="width: 100%; height: 150rpx;" class="solid radius text-left padding-sm"
v-model="formData.areaDesc" maxlength="-1" placeholder="如XX区XX街道未覆盖或XX区仅服务XX街道"></textarea>
</view>
<!-- 多城市 -->
2024-03-04 10:04:10 +08:00
<view v-for="(item,index) in servArea" :key="index" class="bg-white">
2023-02-15 22:30:59 +08:00
<view class="solid-top">
<view @click="delServArea(index)">
<button class="cu-btn bg-red light">
<text class="margin-right-xs"><text class="cuIcon-close"></text></text>
<text>删除</text>
</button>
</view>
<view class="cu-form-group">
<view class="title">上架区域<text class="text-red">*</text></view>
<picker :mode="'multiSelector'" @change="multiRegionChange($event, index)"
@columnchange="multiRegionColChange($event, index)"
2024-03-04 10:04:10 +08:00
:value="item.regionMultiIndex" :range-key="'areaName'"
:range="item.regionList">
<input disabled class="line-input radius-input" v-if="item.region"
:value="item.region && item.region.length ? item.region[0].areaName + '-' + item.region[1].areaName : ''"
2023-02-15 22:30:59 +08:00
placeholder="请选择区域"></input>
</picker>
</view>
<view class="padding-lr bg-white">
2024-03-04 10:04:10 +08:00
<checkbox-group @change="multiAreaCheckDistirct($event, index)" class="grid col-3">
<view v-for="(item1, index1) in item.districtList" :key="item1.id" class="margin-tb-xs">
2023-02-15 22:30:59 +08:00
<checkbox style="transform:scale(1)" class="main-color margin-right-xs" :value="index1"
2024-03-04 10:04:10 +08:00
:checked="item1.checked"></checkbox>
<text>{{item1.areaName}}</text>
2023-02-15 22:30:59 +08:00
</view>
</checkbox-group>
</view>
</view>
<view class="cu-bar">
<view class="action text-black">区域描述<text class="text-red">*</text></view>
</view>
<view class="padding-lr-sm padding-bottom-sm">
<textarea name="areaDesc" style="width: 100%; height: 150rpx;"
class="solid radius text-left padding-sm" v-model="servArea[index].areaDesc" maxlength="-1"
placeholder="如XX区XX街道未覆盖或XX区仅服务XX街道"></textarea>
</view>
</view>
<view class="text-center padding-bottom bg-white">
<button class="cu-btn bg-main-color light" @click="addServArea">
<text class="margin-right-xs"><text class="cuIcon-add"></text></text>
<text>继续添加上架城市</text>
</button>
2022-06-22 17:40:50 +08:00
</view>
<!-- <view class="cu-form-group">
2022-06-22 17:40:50 +08:00
<view class="title">上门费</view>
<input type="digit" name="doorPrice" :value="formData.doorPrice" :v-model="formData.doorPrice"
placeholder="单位:元/次"></input>
</view> -->
2022-06-22 17:40:50 +08:00
<view class="cu-bar bg-white solid-top">
<view class="action text-black">
2023-02-15 22:30:59 +08:00
商品封面图上传<text class="text-red">*</text>只能一张一张上传
2022-06-22 17:40:50 +08:00
</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>
2023-03-18 23:59:22 +08:00
<view class="solids" @tap="chooseImgList($event, 'coverImgList', 800, 800)"
2022-06-22 17:40:50 +08:00
v-if="formData.coverImgList.length === 0">
<text class='cuIcon-cameraadd'></text>
</view>
</view>
</view>
<view class="cu-bar bg-white solid-top">
<view class="action text-black">
2023-02-15 22:30:59 +08:00
详情图上传<text class="text-red">*</text>可多张勾选同时上传
2022-06-22 17:40:50 +08:00
</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.descImgList" :key="index"
@tap="viewImage($event, formData.descImgList)" :data-url="item">
<image :src="item" mode="aspectFill"></image>
<view class="cu-tag bg-red" @tap.stop="delImg($event, formData.descImgList)"
:data-index="index">
<text class='cuIcon-close'></text>
</view>
</view>
2022-08-25 00:13:48 +08:00
<view class="solids" @tap="chooseImgNoCrop($event, 'descImgList')"
2022-06-22 17:40:50 +08:00
v-if="formData.descImgList.length<9">
<text class='cuIcon-cameraadd'></text>
</view>
</view>
</view>
<view class="cu-bar bg-white solid-top">
<view class="action text-black">
2023-02-15 22:30:59 +08:00
轮播图上传<text class="text-red">*</text>只能一张一张上传
2022-06-22 17:40:50 +08:00
</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.imgList" :key="index"
@tap="viewImage($event, formData.imgList)" :data-url="item">
<image :src="item" mode="aspectFill"></image>
<view class="cu-tag bg-red" @tap.stop="delImg($event, formData.imgList)" :data-index="index">
<text class='cuIcon-close'></text>
</view>
</view>
<view class="solids" @tap="chooseImgList($event, 'imgList')" v-if="formData.imgList.length<9">
<text class='cuIcon-cameraadd'></text>
</view>
</view>
2022-08-25 00:13:48 +08:00
</view>
<ksp-cropper mode="fixed" :width="cropWidth" :height="cropHeight" :maxWidth="cropWidth"
:maxHeight="cropHeight" :url="url2Crop" @cancel="oncancel" @ok="onok"></ksp-cropper>
2022-06-22 17:40:50 +08:00
<view class="cu-bar bg-white solid-top">
<view class="action text-black">
2023-02-15 22:30:59 +08:00
视频上传一分钟内的视频最佳
2022-06-22 17:40:50 +08:00
</view>
</view>
<!-- <view class="bg-white padding-lr padding-bottom-sm">
<uni-file-picker limit="1" file-mediatype="video" return-type="object" @select="selectVideo">
<button class="cu-btn bg-main-color shadow-blur">选择文件</button>
</uni-file-picker>
</view> -->
<view class="cu-form-group">
<view class="grid col-4 grid-square flex-sub" v-if="formData.videoList.length === 0">
<view class="solids" @tap="chooseVideo()">
<text class='cuIcon-cameraadd'></text>
</view>
</view>
<view class="grid grid-square flex-sub" v-else>
<view class="bg-img" v-for="(item,index) in formData.videoList" :key="index" :data-url="item">
<video :src="item" controls></video>
<view class="cu-tag bg-red" @tap.stop="delImg($event, formData.videoList)" :data-index="index">
<text class='cuIcon-close'></text>
</view>
</view>
2022-06-22 17:40:50 +08:00
</view>
</view>
<view class="padding-sm bg-white solid-top">
<textarea style="width: 100%;" class="solid radius text-left padding-sm" v-model="formData.detailDesc"
maxlength="-1" placeholder="请输入详情介绍"></textarea>
</view>
<view class="padding-bottom-lg padding-top bg-white text-center">
<button class="cu-btn bg-main-color shadow-blur long-btn" @click="submit">确定</button>
</view>
</form>
<!-- 账户及实名弹窗 -->
<!-- <vertify-bank-bind ref="vertifyBankBind"></vertify-bank-bind> -->
<vertify-certify ref="vertifyCertify"></vertify-certify>
2022-06-22 17:40:50 +08:00
</view>
</template>
<script>
import myUniCombox from '@/components/uni-combox/my-uni-combox.vue';
export default {
components: {
myUniCombox
},
data() {
2023-02-15 22:30:59 +08:00
return {
2023-02-12 04:15:15 +08:00
goodsId: null,
2022-06-22 17:40:50 +08:00
formData: {
servName: '',
servDesc: '',
specsList: [],
category: [],
productUnit: '',
isGoldenServ: false,
region: [],
districtList: [],
areaDesc: '',
doorPrice: '',
imgList: [],
detailDesc: '',
descImgList: [],
coverImgList: [],
videoList: []
2023-02-15 22:30:59 +08:00
},
2023-02-14 23:44:16 +08:00
servArea: [],
2022-08-25 00:13:48 +08:00
sysInfo: null,
url2Crop: '',
cropWidth: 0,
cropHeight: 0,
curImgListField: '',
2022-06-22 17:40:50 +08:00
categoryList: [],
categoryMultiIndex: [0, 0, 0],
2022-06-22 17:40:50 +08:00
regionList: [],
regionMultiIndex: [0, 0],
isShowAllSpecs: false,
2023-02-12 04:15:15 +08:00
goodsUnitList: [{
2022-06-22 17:40:50 +08:00
code: 1,
name: '台'
}, {
code: 2,
name: '件'
}, {
code: 3,
2023-02-12 04:15:15 +08:00
name: '个'
2022-06-22 17:40:50 +08:00
}, {
code: 4,
2023-02-12 04:15:15 +08:00
name: '套'
2022-06-22 17:40:50 +08:00
}, {
code: 5,
2023-02-12 04:15:15 +08:00
name: '㎡'
}, {
code: 6,
name: '只'
}, {
2023-02-12 04:15:15 +08:00
code: 7,
name: '张'
}, {
code: 8,
name: '条'
}, {
code: 9,
name: '顶'
}, {
code: 10,
name: '支'
}, {
code: 11,
name: '根'
}],
servActivityList: [{
code: 1,
name: '金牌服务'
2023-02-12 04:15:15 +08:00
}, {
code: 2,
name: '定制预售'
}, {
code: 3,
name: '特惠团购'
}, {
code: 4,
name: '分享0元购'
2022-06-22 17:40:50 +08:00
}],
2023-02-12 04:15:15 +08:00
warrantyPeriodList: [{
2022-06-22 17:40:50 +08:00
code: 1,
name: '15天'
}, {
code: 2,
name: '30天'
}, {
code: 3,
name: '45天'
2023-02-12 04:15:15 +08:00
}, {
code: 4,
name: '3个月'
}, {
code: 5,
name: '6个月'
}, {
code: 6,
name: '12个月'
2023-02-15 22:30:59 +08:00
}],
expectDurationList: [{
name: '12点前下单预计当天下午上门/服务'
}, {
name: '17点前下单预计次日上门/服务'
}, {
name: '现时下单,预计次日上门/服务'
}, {
name: '现时下单,预计后日上门/服务'
}],
curUserInfo: {},
bankCard: null,
certifyInfo: null
2022-06-22 17:40:50 +08:00
}
},
onLoad(options) {
if (options && options.goodId) {
2023-02-12 04:15:15 +08:00
this.goodsId = options.goodId;
2022-06-22 17:40:50 +08:00
}
2023-02-12 04:15:15 +08:00
this.loadData(this.goodsId);
2022-06-22 17:40:50 +08:00
},
methods: {
2022-08-25 00:13:48 +08:00
async loadData(goodId) {
this.sysInfo = uni.getSystemInfoSync();
2023-02-15 22:30:59 +08:00
this.curUserInfo = this.$request.getCurUserInfo();
if (goodId) {
this.getCurGoodsInfo(goodId);
2023-02-12 04:15:15 +08:00
}
this.checkBankAndCertify();
2022-06-22 17:40:50 +08:00
this.loadCategoryList();
this.loadRegionList();
// TODO 如果存在goodId说明是修改需要查询good信息进行回显
// this.categoryList = await this.$api.data('categoryList');
// this.regionList = await this.$api.data('regionList');
2023-02-15 22:30:59 +08:00
},
async getCurGoodsInfo(goodsId) {
let res1 = await this.$request.qryProductDetail({
goodsId: goodsId
});
let goods = res1.data;
// 选中规则转map
let chosenGoodsStandardMap = new Map();
goods.goodsStandardList.forEach(o => {
chosenGoodsStandardMap.set(o.deptGoodsCategoryId, o);
});
// 查询选中的第三级类目下的所有规格
let res2 = await this.$request.listByStep({
type: 1,
goodsCategoryId: goods.deptGoodsCategoryId
});
let specsList = res2.data;
let newSpecsList = [];
specsList.forEach(o => {
if (chosenGoodsStandardMap.has(o.deptGoodsCategoryId)) {
o = chosenGoodsStandardMap.get(o.deptGoodsCategoryId);
o.checked = true;
}
newSpecsList.push(o);
});
// 选中地区转map
let chosenAreaMap = new Map();
goods.goodsAreaList.forEach(o => {
chosenAreaMap.set(o.countryAreaId, o);
});
// 查询选中的第二级区域下的第三级区域
let res3 = await this.$request.areaListByStep({
parentCode: goods.parentAreaId
});
let areaList = res3.data;
let newAreaList = [];
areaList.forEach(o => {
if (chosenAreaMap.has(o.areaId)) {
o = chosenAreaMap.get(o.areaId);
2023-02-27 22:57:29 +08:00
o.checked = true;
o.areaId = o.countryAreaId;
o.areaCode = o.countryAreaId;
2023-02-15 22:30:59 +08:00
}
newAreaList.push(o);
2023-02-27 22:57:29 +08:00
});
console.log(newAreaList)
2023-02-15 22:30:59 +08:00
this.formData = {
servName: goods.goodsName,
servDesc: goods.goodsDesc,
categoryConcatName: goods.categoryConcatName,
deptGoodsCategoryId: goods.deptGoodsCategoryId,
specsList: newSpecsList,
goodsUnit: {
name: goods.goodsUnit
},
warrantyPeriod: {
name: goods.warrantyPeriod
},
servActivity: {
name: goods.servActivity
},
expectDuration: {
name: goods.expectDuration
},
areaConcatName: goods.areaConcatName,
districtList: newAreaList,
detailDesc: goods.remark,
areaDesc: goods.areaDesc,
coverImgList: [goods.goodsImgUrl],
imgList: goods.lbUrl,
descImgList: goods.detailUrl,
videoList: goods.goodsVideoUrl ? [goods.goodsVideoUrl] : [],
// status: 0,
}
},
async checkBankAndCertify() {
// 查询账户绑定信息
// let bankCardRes = await this.$request.getBindBankCardByWorkerId({
// workerId: this.curUserInfo.workerId
// });
// this.bankCard = bankCardRes.data;
// 查询实名信息
let certifyInfoRes = await this.$request.getWorkerCertify();
this.certifyInfo = certifyInfoRes.data;
// if (!this.bankCard || !this.bankCard.bankNum) {
// this.$refs.vertifyBankBind.showModal();
// return false;
if (!this.certifyInfo || !this.certifyInfo.workerCertificationId) {
this.$refs.vertifyCertify.showModal();
return false;
}
return true;
2022-06-22 17:40:50 +08:00
},
async loadCategoryList(idArr) {
let typeList = await this.$request.listByStep({
type: 1
});
2022-06-22 17:40:50 +08:00
typeList = typeList.data;
let col1Id = idArr ? idArr[0] : typeList[0].goodsCategoryId;
let subTypeList = await this.$request.listByStep({
type: 1,
2022-06-22 17:40:50 +08:00
goodsCategoryId: col1Id
});
subTypeList = subTypeList.data;
let col2Id = idArr ? idArr[1] : subTypeList[0].goodsCategoryId;
let subSubTypeList = await this.$request.listByStep({
type: 1,
2022-06-22 17:40:50 +08:00
goodsCategoryId: col2Id
});
2022-08-25 00:13:48 +08:00
subSubTypeList = subSubTypeList.data;
let col3Id = idArr ? idArr[2] : subSubTypeList[0].goodsCategoryId;
let thirdTypeList = await this.$request.listByStep({
type: 1,
goodsCategoryId: col3Id
});
thirdTypeList = thirdTypeList.data;
// this.categoryList.push(typeList);
2022-06-22 17:40:50 +08:00
this.categoryList.push(subTypeList);
2022-08-25 00:13:48 +08:00
this.categoryList.push(subSubTypeList);
this.categoryList.push(thirdTypeList);
2022-06-22 17:40:50 +08:00
},
async loadRegionList() {
let regionList = await this.$request.areaListByStep();
regionList = regionList.data;
let subRegionList = [];
if (regionList && regionList.length > 0) {
subRegionList = await this.$request.areaListByStep({
parentCode: regionList[0].areaCode
});
subRegionList = subRegionList.data;
}
this.regionList.push(regionList);
this.regionList.push(subRegionList);
},
async categoryChange(e) {
this.categoryMultiIndex = e.detail.value;
let chosenCategory = [];
for (let i = 0; i < this.categoryList.length; i++) {
chosenCategory.push(this.categoryList[i][this.categoryMultiIndex[i]]);
}
2023-02-15 22:30:59 +08:00
this.formData.category = chosenCategory;
this.formData.deptGoodsCategoryId = this.formData.category[this.formData.category.length - 1]
.goodsCategoryId;
2022-06-22 17:40:50 +08:00
// 查询最后一级品类
let res = await this.$request.listByStep({
type: 1,
goodsCategoryId: chosenCategory[chosenCategory.length - 1].goodsCategoryId
2022-06-22 17:40:50 +08:00
});
this.formData.specsList = res.data;
},
async categoryColChange(e) {
let colObj = e.detail;
if (colObj.column == 0) {
// 通过一级查询二级,通过二级查三级
let subTypeList = await this.$request.listByStep({
type: 1,
goodsCategoryId: this.categoryList[0][colObj.value].goodsCategoryId
});
2022-08-25 00:13:48 +08:00
subTypeList = subTypeList.data;
let subSubTypeList = [];
if (subTypeList && subTypeList.length) {
subSubTypeList = await this.$request.listByStep({
type: 1,
goodsCategoryId: subTypeList[0].goodsCategoryId
});
subSubTypeList = subSubTypeList.data;
}
this.categoryList.pop();
this.categoryList.pop();
this.categoryList.push(subTypeList);
this.categoryList.push(subSubTypeList);
this.categoryMultiIndex = [colObj.value, 0, 0];
} else if (colObj.column == 1) {
2022-06-22 17:40:50 +08:00
// 通过二级查三级
let subSubTypeList = await this.$request.listByStep({
type: 1,
goodsCategoryId: this.categoryList[1][colObj.value].goodsCategoryId
2022-06-22 17:40:50 +08:00
});
subSubTypeList = subSubTypeList.data;
this.categoryList.pop();
this.categoryList.push(subSubTypeList);
this.categoryMultiIndex = [this.categoryMultiIndex[0], colObj.value, 0];
2022-06-22 17:40:50 +08:00
}
},
async regionChange(e) {
this.regionMultiIndex = e.detail.value;
let chosenRegion = [];
for (let i = 0; i < this.regionList.length; i++) {
chosenRegion.push(this.regionList[i][this.regionMultiIndex[i]]);
}
this.formData.region = chosenRegion;
// 查询最后一级区域
let areaList = await this.$request.areaListByStep({
parentCode: chosenRegion[1].areaCode
});
this.formData.districtList = areaList.data;
2023-02-15 22:30:59 +08:00
},
async multiRegionChange(e, regionIndex) {
this.servArea[regionIndex].regionMultiIndex = e.detail.value;
let chosenRegion = [];
for (let i = 0; i < this.servArea[regionIndex].regionList.length; i++) {
chosenRegion.push(this.servArea[regionIndex].regionList[i][this.servArea[regionIndex]
.regionMultiIndex[i]
]);
}
this.servArea[regionIndex].region = chosenRegion;
// 查询最后一级区域
let areaList = await this.$request.areaListByStep({
parentCode: chosenRegion[1].areaCode
});
this.servArea[regionIndex].districtList = areaList.data;
2022-06-22 17:40:50 +08:00
},
async regionColChange(e) {
let colObj = e.detail;
if (colObj.column == 0) {
// 通过一级查二级
let subAreaList = await this.$request.areaListByStep({
parentCode: this.regionList[0][colObj.value].areaCode
});
2023-02-15 22:30:59 +08:00
subAreaList = subAreaList.data;
this.regionList.pop();
this.regionList.push(subAreaList);
2022-06-22 17:40:50 +08:00
this.regionMultiIndex = [colObj.value, 0];
}
2023-02-15 22:30:59 +08:00
},
async multiRegionColChange(e, regionIndex) {
let colObj = e.detail;
if (colObj.column == 0) {
// 通过一级查二级
let subAreaList = await this.$request.areaListByStep({
parentCode: this.regionList[0][colObj.value].areaCode
});
subAreaList = subAreaList.data;
this.servArea[regionIndex].regionList.pop();
this.servArea[regionIndex].regionList.push(subAreaList);
this.servArea[regionIndex].regionMultiIndex = [colObj.value, 0];
}
2022-06-22 17:40:50 +08:00
},
checkSpecs(e) {
let checkedIndexArr = e.detail.value;
for (let i = 0; i < this.formData.specsList.length; i++) {
if (checkedIndexArr.indexOf(String(i)) !== -1) {
this.formData.specsList[i].checked = true;
} else {
this.formData.specsList[i].checked = false;
}
}
},
inputSpecs(e, index, field) {
this.formData.specsList[index][field] = e.detail.value;
},
showAllSpecs() {
this.isShowAllSpecs = !this.isShowAllSpecs;
2023-02-15 22:30:59 +08:00
},
hideTips(tipName, index) {
if (typeof index === 'number' && index >= 0) {
this.$refs[tipName][index].close();
} else {
this.$refs[tipName].close();
}
2022-06-22 17:40:50 +08:00
},
checkDistirct(e) {
let checkedIndexArr = e.detail.value;
for (let i = 0; i < this.formData.districtList.length; i++) {
if (checkedIndexArr.indexOf(String(i)) !== -1) {
this.formData.districtList[i].checked = true;
} else {
this.formData.districtList[i].checked = false;
}
}
2023-02-15 22:30:59 +08:00
},
multiAreaCheckDistirct(e, index) {
let checkedIndexArr = e.detail.value;
for (let i = 0; i < this.servArea[index].districtList.length; i++) {
if (checkedIndexArr.indexOf(String(i)) !== -1) {
this.servArea[index].districtList[i].checked = true;
} else {
this.servArea[index].districtList[i].checked = false;
}
}
2022-06-22 17:40:50 +08:00
},
2022-08-25 00:13:48 +08:00
chooseImgList(e, imgListField, cropWidth, cropHeight) {
this.cropWidth = cropWidth && cropWidth > 0 ? cropWidth : this.sysInfo.windowWidth * 2;
this.cropHeight = cropHeight && cropHeight > 0 ? cropHeight : this.sysInfo.windowWidth * 2 * 1.15;
2023-11-29 22:05:04 +08:00
uni.chooseMedia({
count: 1, //默认9
mediaType: ['image'],
2022-06-22 17:40:50 +08:00
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album'], //从相册选择
success: (res) => {
2023-11-29 22:05:04 +08:00
res.tempFiles.forEach((fileObj, index) => {
this.url2Crop = fileObj.tempFilePath;
this.curImgListField = imgListField;
2022-06-22 17:40:50 +08:00
});
}
});
},
2022-08-25 00:13:48 +08:00
onok(ev) {
uni.showLoading({
title: '上传中',
mask: true
});
this.$request.uploadFile(ev.path).then((url) => {
this.formData[this.curImgListField].push(url);
uni.hideLoading();
});
// url设置为空隐藏控件
this.url2Crop = "";
},
oncancel() {
// url设置为空隐藏控件
this.url2Crop = "";
},
2022-08-25 00:13:48 +08:00
chooseImgNoCrop(e, imgListField) {
2023-11-29 22:05:04 +08:00
uni.chooseMedia({
count: 9, //默认9
mediaType: ['image'],
2022-08-25 00:13:48 +08:00
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album'], //从相册选择
success: (res) => {
uni.showLoading({
title: '上传中',
mask: true
});
2023-11-29 22:05:04 +08:00
res.tempFiles.forEach((fileObj, index) => {
this.$request.uploadFile(fileObj.tempFilePath).then((url) => {
2022-08-25 00:13:48 +08:00
this.formData[imgListField].push(url);
2023-11-29 22:05:04 +08:00
if (index === res.tempFiles.length - 1) {
2022-08-25 00:13:48 +08:00
uni.hideLoading();
}
});
});
}
});
},
2022-06-22 17:40:50 +08:00
viewImage(e, imgList) {
uni.previewImage({
urls: imgList,
current: e.currentTarget.dataset.url
});
},
delImg(e, imgList) {
uni.showModal({
title: '',
content: '确定要删除这张图片吗?',
cancelText: '取消',
confirmText: '确定',
success: res => {
if (res.confirm) {
imgList.splice(e.currentTarget.dataset.index, 1)
}
}
})
},
chooseVideo() {
2022-06-22 17:40:50 +08:00
let _this = this;
uni.chooseVideo({
sourceType: ['camera', 'album'],
success: function(res) {
uni.showLoading({
title: '上传中',
mask: true
});
_this.$request.uploadFile(res.tempFilePath).then((url) => {
uni.hideLoading();
_this.formData.videoList.push(url);
2022-06-22 17:40:50 +08:00
});
}
});
},
// async selectVideo(e) {
// uni.showLoading({
// title: '上传中',
// mask: true
// });
// this.formData.video = await this.$request.uploadFile(e.tempFilePaths[0]);
// uni.hideLoading();
// },
validData(data) {
let errMsg = "";
if (!data.servName) {
errMsg = '服务名称不能为空';
2022-09-11 14:44:24 +08:00
} else if (!data.servDesc) {
2023-02-15 22:30:59 +08:00
errMsg = '搜索关键词不能为空';
2023-02-12 04:15:15 +08:00
} else if ((!data.category || !data.category.length) && (!data.categoryConcatName)) {
2022-09-11 14:44:24 +08:00
errMsg = '请选择类目';
} else if (!data.goodsStandardList || !data.goodsStandardList.length) {
2022-08-25 00:13:48 +08:00
errMsg = '至少勾选一个规格';
} else if (!this.validSpecData(data.goodsStandardList)) {
return false;
} else if (!data.goodsUnit) {
errMsg = '商品单位不能为空';
2023-02-15 22:30:59 +08:00
} else if (!data.warrantyPeriod) {
errMsg = '质保期不能为空';
} else if (!data.servActivity) {
errMsg = '服务活动不能为空';
} else if (!data.expectDuration) {
errMsg = '服务时效不能为空';
} else if (!data.goodsAreaList || !data.goodsAreaList.length) {
2023-02-15 22:30:59 +08:00
errMsg = '上架区域填写不完整';
2022-09-11 14:44:24 +08:00
} else if (!data.areaDesc) {
errMsg = '区域描述不能为空';
} else if (!data.coverImgList || !data.coverImgList.length) {
2022-08-25 00:13:48 +08:00
errMsg = '封面图不能为空';
} else if (!data.descImgList || !data.descImgList.length) {
2022-08-25 00:13:48 +08:00
errMsg = '详情图不能为空';
} else if (!data.imgList || !data.imgList.length) {
2022-08-25 00:13:48 +08:00
errMsg = '轮播图不能为空';
}
if (errMsg) {
uni.showToast({
icon: 'none',
2022-09-11 14:44:24 +08:00
title: errMsg,
2022-08-25 00:13:48 +08:00
duration: 2500
})
return false;
}
return true;
},
validSpecData(goodsStandardList) {
let errMsg = "";
for (let i = 0; i < goodsStandardList.length; i++) {
let spec = goodsStandardList[i];
2022-08-25 00:13:48 +08:00
if (!spec.goodsPrice) {
errMsg = '已勾选规格的价格不能为空';
} else if (!spec.goodsNum) {
2022-08-25 00:13:48 +08:00
errMsg = '已勾选规格的库存不能为空';
}
if (errMsg) {
uni.showToast({
icon: 'none',
2022-09-11 14:44:24 +08:00
title: errMsg,
2022-08-25 00:13:48 +08:00
duration: 2500
})
break;
}
}
if (errMsg) {
return false;
}
return true;
},
2023-02-15 22:30:59 +08:00
validMultiAreaList(data) {
let errMsg = null;
if (!data.goodsAreaList || !data.goodsAreaList.length || !data.areaDesc) {
errMsg = '上架区域填写不完整';
}
if (errMsg) {
uni.showToast({
icon: 'none',
title: errMsg,
duration: 2500
})
return false;
}
return true;
},
async submit() {
// 多城市上架区域校验
let multiServAreaChecked = true;
let multiServAreaList = [];
for (let x of this.servArea) {
let oneCheckedAreaList = null;
if (x && x.districtList && x.districtList.length) {
oneCheckedAreaList = x.districtList.filter((item) => {
if (item.checked) {
item.countryAreaId = item.areaId;
return item;
}
});
}
let oneServAreaObj = {
goodsAreaList: oneCheckedAreaList,
areaDesc: x.areaDesc
}
if (!this.validMultiAreaList(oneServAreaObj)) {
multiServAreaChecked = false;
break;
}
multiServAreaList.push(oneServAreaObj);
}
if (!multiServAreaChecked) {
return;
}
let goodsStandardList = this.formData.specsList.filter((item) => {
2022-09-11 14:44:24 +08:00
if (item.checked) {
if (!item.goodsStandardName) {
item.goodsStandardName = item.goodsCategoryName;
2022-08-25 00:13:48 +08:00
}
2023-02-15 22:30:59 +08:00
return item;
}
});
let goodsAreaList = this.formData.districtList.filter((item) => {
if (item.checked) {
item.countryAreaId = item.areaId;
return item;
}
});
let data2Valid = {
...this.formData,
goodsStandardList: goodsStandardList,
goodsAreaList: goodsAreaList
}
if (!this.validData(data2Valid)) {
return;
}
// let checkRes = await this.checkBankAndCertify();
// if (!checkRes) {
// return;
// }
2022-07-04 17:00:52 +08:00
// 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 goodsVideoUrl = this.formData.videoList.length ? this.formData.videoList[0] : '';
2022-07-04 17:00:52 +08:00
let params = {
goodsName: this.formData.servName,
goodsDesc: this.formData.servDesc,
2023-02-15 22:30:59 +08:00
goodsUnit: this.formData.goodsUnit.name,
warrantyPeriod: this.formData.warrantyPeriod.name,
servActivity: this.formData.servActivity.name,
2023-02-12 04:15:15 +08:00
expectDuration: this.formData.expectDuration.name,
deptGoodsCategoryId: this.formData.deptGoodsCategoryId,
2022-07-04 17:00:52 +08:00
goodsStandardList: goodsStandardList,
goodsAreaList: goodsAreaList,
goodsImgUrl: this.formData.coverImgList[0],
goodsImgsList: goodsImgsList,
goodsVideoUrl: goodsVideoUrl,
status: 0,
2023-02-15 22:30:59 +08:00
remark: this.formData.detailDesc,
2023-02-12 04:15:15 +08:00
areaDesc: this.formData.areaDesc
2023-02-15 22:30:59 +08:00
}
let res = null;
if (this.goodsId) {
res = await this.$request.editGoods({
...params,
goodsId: this.goodsId
});
} else {
res = await this.$request.addGoods(params);
}
// 如果选了多城市,添加多个服务
let index = 0;
while (index < multiServAreaList.length && res && res.code === 0) {
res = await this.$request.addGoods({
...params,
goodsAreaList: multiServAreaList[index].goodsAreaList,
areaDesc: multiServAreaList[index].areaDesc
});
index++;
2022-07-04 17:00:52 +08:00
}
if (res && res.code === 0) {
2022-06-22 17:40:50 +08:00
uni.showToast({
icon: 'success'
})
uni.reLaunch({
url: '/pages/index/index?menuCode=supplyChainPage'
2022-06-22 17:40:50 +08:00
})
2022-07-04 17:00:52 +08:00
}
2023-02-15 22:30:59 +08:00
},
async addServArea() {
let subRegionList = await this.$request.areaListByStep({
parentCode: this.regionList[0][0].areaCode
});
subRegionList = subRegionList.data;
this.servArea.push({
region: [],
districtList: [],
areaDesc: null,
regionList: [this.regionList[0], subRegionList],
regionMultiIndex: [0, 0]
});
},
delServArea(index) {
this.servArea.splice(index, 1);
2022-06-22 17:40:50 +08:00
}
},
}
</script>
<style scoped>
.cu-form-group picker::after {
display: none;
}
2023-02-15 22:30:59 +08:00
.cu-form-group .title {
flex-basis: 26%;
text-align: justify;
padding-right: 10rpx;
font-size: 30rpx;
position: relative;
height: 60rpx;
line-height: 60rpx;
}
2022-06-22 17:40:50 +08:00
.certern-height {
max-height: 520rpx;
overflow: hidden;
}
.long-btn {
width: 95%;
}
.form-val-area {
flex-basis: 75% !important;
2022-06-22 17:40:50 +08:00
}
2022-09-11 14:44:24 +08:00
.radius-input.xs {
font-size: 23rpx;
2023-02-15 22:30:59 +08:00
}
.radius-input.sm {
font-size: 25rpx;
2022-09-11 14:44:24 +08:00
}
2022-05-15 01:46:26 +08:00
</style>