|
|
|
|
@ -61,7 +61,8 @@
|
|
|
|
|
<div class="p-2 bg-white">
|
|
|
|
|
<div class="name mb-2 text-xs">服务内容</div>
|
|
|
|
|
<view class="bg-white px-3 py-1 rounded">
|
|
|
|
|
<wd-input type="text" v-model="model.server_project" placeholder="例子: 正品保障,极速发货,7天退换货。多个请使用英文逗号“,”分隔" />
|
|
|
|
|
<wd-input type="text" v-model="model.server_project"
|
|
|
|
|
placeholder="例子: 正品保障,极速发货,7天退换货。多个请使用英文逗号“,”分隔" />
|
|
|
|
|
</view>
|
|
|
|
|
</div>
|
|
|
|
|
</view>
|
|
|
|
|
@ -107,6 +108,48 @@
|
|
|
|
|
:Pdata="{ skuDefault, skuLibrary, skuGroup, use_sku: model.use_sku }">
|
|
|
|
|
</skuEdit>
|
|
|
|
|
|
|
|
|
|
<view class="h-2 bg-gray-100"></view>
|
|
|
|
|
<view>
|
|
|
|
|
<view style="font-size: 36rpx;border-bottom: 1rpx solid #F0F0F0;display: flex;flex-wrap: wrap;align-items: center;">
|
|
|
|
|
<view
|
|
|
|
|
:style="{
|
|
|
|
|
margin: '20rpx',
|
|
|
|
|
fontWeight: formats.bold ? '800' : '400'
|
|
|
|
|
}"
|
|
|
|
|
@click="format('bold', (formats.bold ? false : true))">加粗</view>
|
|
|
|
|
<view
|
|
|
|
|
:style="{
|
|
|
|
|
margin: '20rpx',
|
|
|
|
|
fontWeight: formats.italic ? '800' : '400'
|
|
|
|
|
}"
|
|
|
|
|
@click="format('italic', (formats.italic ? false : true))">斜体</view>
|
|
|
|
|
<view
|
|
|
|
|
:style="{
|
|
|
|
|
margin: '20rpx',
|
|
|
|
|
fontWeight: formats.underline ? '800' : '400'
|
|
|
|
|
}"
|
|
|
|
|
@click="format('underline', (formats.underline ? false : true))">下划线</view>
|
|
|
|
|
<view
|
|
|
|
|
:style="{
|
|
|
|
|
margin: '20rpx',
|
|
|
|
|
fontWeight: formats.align == 'center' ? '800' : '400'
|
|
|
|
|
}"
|
|
|
|
|
@click="format('align', (formats.align == 'center' ? 'left' : 'center'))">居中</view>
|
|
|
|
|
|
|
|
|
|
<view style="margin: 20rpx;" >
|
|
|
|
|
<yUpload :width="40" :height="40" v-model="editor_upload" :size="4"></yUpload>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
</view>
|
|
|
|
|
<view style="padding: 10px;">
|
|
|
|
|
<editor style="min-height: 70vh;" id="editor" class="ql-container"
|
|
|
|
|
placeholder="开始输入..." show-img-size show-img-toolbar
|
|
|
|
|
@statuschange="onStatusChange"
|
|
|
|
|
show-img-resize :read-only="false" @ready="onEditorReady">
|
|
|
|
|
</editor>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
</wd-cell-group>
|
|
|
|
|
<view class="footer mt-4">
|
|
|
|
|
<wd-button @click="saveGoods" type="primary" size="large" block>保存</wd-button>
|
|
|
|
|
@ -116,13 +159,22 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import { ref } from 'vue';
|
|
|
|
|
import { useToast, useMessage } from '@/uni_modules/wot-design-uni';
|
|
|
|
|
import {
|
|
|
|
|
ref,
|
|
|
|
|
watch
|
|
|
|
|
} from 'vue';
|
|
|
|
|
import {
|
|
|
|
|
useToast,
|
|
|
|
|
useMessage
|
|
|
|
|
} from '@/uni_modules/wot-design-uni';
|
|
|
|
|
import goods from '@/api/store/goods.js';
|
|
|
|
|
import system from '@/api/modules/system.js';
|
|
|
|
|
import skuEdit from "./components/skuEdit.vue";
|
|
|
|
|
import yUpload from "@/components/yUpload/index.vue";
|
|
|
|
|
import { onLoad, onShow } from "@dcloudio/uni-app";
|
|
|
|
|
import {
|
|
|
|
|
onLoad,
|
|
|
|
|
onShow
|
|
|
|
|
} from "@dcloudio/uni-app";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @typedef {import('@/api/store/goods').GoodsItem} GoodsItem
|
|
|
|
|
@ -193,11 +245,56 @@ const fileList = ref([]);
|
|
|
|
|
* @param {number} param0.index - 文件索引
|
|
|
|
|
* @returns {void}
|
|
|
|
|
*/
|
|
|
|
|
const beforeRemove = ({ file, resolve, index }) => {
|
|
|
|
|
const beforeRemove = ({
|
|
|
|
|
file,
|
|
|
|
|
resolve,
|
|
|
|
|
index
|
|
|
|
|
}) => {
|
|
|
|
|
fileList.value.splice(index, 1);
|
|
|
|
|
resolve(true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const editorCtx = ref(null);
|
|
|
|
|
const onEditorReady = () => {
|
|
|
|
|
// #ifdef MP-BAIDU
|
|
|
|
|
editorCtx.value = requireDynamicLib('editorLib').createEditorContext('editor');
|
|
|
|
|
// #endif
|
|
|
|
|
|
|
|
|
|
// #ifdef APP-PLUS || MP-WEIXIN || H5
|
|
|
|
|
uni.createSelectorQuery().select('#editor').context((res) => {
|
|
|
|
|
editorCtx.value = res.context
|
|
|
|
|
}).exec()
|
|
|
|
|
// #endif
|
|
|
|
|
}
|
|
|
|
|
const formats = ref({});
|
|
|
|
|
const onStatusChange = (e) => {
|
|
|
|
|
formats.value = e.detail
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const format = (name, value) => {
|
|
|
|
|
editorCtx.value.format(name, value)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const editor_upload = ref([]);
|
|
|
|
|
watch(editor_upload, (newX) => {
|
|
|
|
|
if (newX && newX.length > 0) {
|
|
|
|
|
newX.forEach(item => {
|
|
|
|
|
editorCtx.value.insertImage({
|
|
|
|
|
src: item,
|
|
|
|
|
alt: '图像',
|
|
|
|
|
success: function() {
|
|
|
|
|
console.log('insert image success')
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
editor_upload.value = []
|
|
|
|
|
}
|
|
|
|
|
// console.log(newX, `newX is`)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @type {Ref<Model>} */
|
|
|
|
|
const model = ref({
|
|
|
|
|
classify_list: [], // 商品分类组
|
|
|
|
|
@ -270,7 +367,9 @@ onLoad(async (e) => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
model.value = res.data;
|
|
|
|
|
model.value.pic_list = res.data.pic_list.map(({ pic_url }) => pic_url);
|
|
|
|
|
model.value.pic_list = res.data.pic_list.map(({
|
|
|
|
|
pic_url
|
|
|
|
|
}) => pic_url);
|
|
|
|
|
|
|
|
|
|
if (!model.value.freight_id) {
|
|
|
|
|
model.value.freight_id = 99999999;
|
|
|
|
|
@ -283,6 +382,13 @@ onLoad(async (e) => {
|
|
|
|
|
skuLibrary.value = res.data.goods_sku;
|
|
|
|
|
}
|
|
|
|
|
skuGroup.value = res.data.sku_group ? res.data.sku_group : [];
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
editorCtx.value.setContents({
|
|
|
|
|
html: res.data.detail
|
|
|
|
|
})
|
|
|
|
|
}, 1000)
|
|
|
|
|
|
|
|
|
|
load.value = true;
|
|
|
|
|
} else {
|
|
|
|
|
load.value = true;
|
|
|
|
|
@ -352,7 +458,8 @@ const saveGoods = async () => {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!model.value.sku_list.every(item => Boolean(item.price !== "" && item.stock !== "" && item.original_price !== ""))) {
|
|
|
|
|
if (!model.value.sku_list.every(item => Boolean(item.price !== "" && item.stock !== "" && item
|
|
|
|
|
.original_price !== ""))) {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '规格不完整,请调整!',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
@ -372,7 +479,20 @@ const saveGoods = async () => {
|
|
|
|
|
|
|
|
|
|
const classify_list = model.value.classify_list.map(item => JSON.parse(item));
|
|
|
|
|
|
|
|
|
|
const res = await goods.goodsEdit({ ...model.value, pic_list, freight_id, classify_list });
|
|
|
|
|
let detail = ''
|
|
|
|
|
await editorCtx.value.getContents({
|
|
|
|
|
success(res) {
|
|
|
|
|
detail = res.html
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const res = await goods.goodsEdit({
|
|
|
|
|
...model.value,
|
|
|
|
|
pic_list,
|
|
|
|
|
freight_id,
|
|
|
|
|
classify_list,
|
|
|
|
|
detail
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (res.code == 0) {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
@ -410,7 +530,9 @@ const getClassify = () => {
|
|
|
|
|
flatCategories.push(categoryWithParents);
|
|
|
|
|
|
|
|
|
|
if (category.children && category.children.length > 0) {
|
|
|
|
|
flatCategories = flatCategories.concat(flattenCategories(category.children, [...parentIds, category.id]));
|
|
|
|
|
flatCategories = flatCategories.concat(flattenCategories(category.children, [...parentIds, category
|
|
|
|
|
.id
|
|
|
|
|
]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -423,7 +545,6 @@ const getClassify = () => {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
getClassify();
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss"></style>
|