Commit 90b8efd9 by 杨明

fixed

1 parent cabcf0f1
......@@ -268,6 +268,10 @@ const subscribe = [
{
optionId: 8,
optionLabel: '超级营销'
},
{
optionId: 9,
optionLabel: '售后众筹'
}
]
const giftPackage = [
......
.vdr {
touch-action: none;
position: absolute;
box-sizing: border-box;
border: 1px dashed black;
}
.handle {
box-sizing: border-box;
position: absolute;
width: 10px;
height: 10px;
background: #EEE;
border: 1px solid #333;
}
.handle-tl {
top: -10px;
left: -10px;
cursor: nw-resize;
}
.handle-tm {
top: -10px;
left: 50%;
margin-left: -5px;
cursor: n-resize;
}
.handle-tr {
top: -10px;
right: -10px;
cursor: ne-resize;
}
.handle-ml {
top: 50%;
margin-top: -5px;
left: -10px;
cursor: w-resize;
}
.handle-mr {
top: 50%;
margin-top: -5px;
right: -10px;
cursor: e-resize;
}
.handle-bl {
bottom: -10px;
left: -10px;
cursor: sw-resize;
}
.handle-bm {
bottom: -10px;
left: 50%;
margin-left: -5px;
cursor: s-resize;
}
.handle-br {
bottom: -10px;
right: -10px;
cursor: se-resize;
}
@media only screen and (max-width: 768px) {
[class*="handle-"]:before {
content: '';
left: -10px;
right: -10px;
bottom: -10px;
top: -10px;
position: absolute;
}
}
<template>
<div
:style="style"
:class="[
{
[classNameActive]: enabled,
[classNameDragging]: dragging,
[classNameResizing]: resizing,
[classNameDraggable]: draggable,
[classNameResizable]: resizable,
},
className,
]"
@mousedown="elementMouseDown"
@touchstart="elementTouchDown"
>
<div
v-for="handle in actualHandles"
:key="handle"
:class="[classNameHandle, classNameHandle + '-' + handle]"
:style="{ display: enabled ? 'block' : 'none' }"
@mousedown.stop.prevent="handleDown(handle, $event)"
@touchstart.stop.prevent="handleTouchDown(handle, $event)"
>
<slot :name="handle"></slot>
</div>
<slot></slot>
</div>
</template>
<script>
import {
matchesSelectorToParentElements,
getComputedSize,
addEvent,
removeEvent,
} from "@/utils/dom";
import {
computeWidth,
computeHeight,
restrictToBounds,
snapToGrid,
} from "@/utils/fns";
const events = {
mouse: {
start: "mousedown",
move: "mousemove",
stop: "mouseup",
},
touch: {
start: "touchstart",
move: "touchmove",
stop: "touchend",
},
};
const userSelectNone = {
userSelect: "none",
MozUserSelect: "none",
WebkitUserSelect: "none",
MsUserSelect: "none",
};
const userSelectAuto = {
userSelect: "auto",
MozUserSelect: "auto",
WebkitUserSelect: "auto",
MsUserSelect: "auto",
};
let eventsFor = events.mouse;
export default {
replace: true,
name: "vue-draggable-resizable",
props: {
className: {
type: String,
default: "vdr",
},
classNameDraggable: {
type: String,
default: "draggable",
},
classNameResizable: {
type: String,
default: "resizable",
},
classNameDragging: {
type: String,
default: "dragging",
},
classNameResizing: {
type: String,
default: "resizing",
},
classNameActive: {
type: String,
default: "active",
},
classNameHandle: {
type: String,
default: "handle",
},
disableUserSelect: {
type: Boolean,
default: true,
},
enableNativeDrag: {
type: Boolean,
default: false,
},
preventDeactivation: {
type: Boolean,
default: false,
},
active: {
type: Boolean,
default: false,
},
draggable: {
type: Boolean,
default: true,
},
resizable: {
type: Boolean,
default: true,
},
lockAspectRatio: {
type: Boolean,
default: false,
},
w: {
type: [Number, String],
default: 200,
validator: (val) => {
if (typeof val === "number") {
return val > 0;
}
return val === "auto";
},
},
h: {
type: [Number, String],
default: 200,
validator: (val) => {
if (typeof val === "number") {
return val > 0;
}
return val === "auto";
},
},
minWidth: {
type: Number,
default: 0,
validator: (val) => val >= 0,
},
minHeight: {
type: Number,
default: 0,
validator: (val) => val >= 0,
},
maxWidth: {
type: Number,
default: null,
validator: (val) => val >= 0,
},
maxHeight: {
type: Number,
default: null,
validator: (val) => val >= 0,
},
x: {
type: Number,
default: 0,
},
y: {
type: Number,
default: 0,
},
z: {
type: [String, Number],
default: "auto",
validator: (val) => (typeof val === "string" ? val === "auto" : val >= 0),
},
handles: {
type: Array,
default: () => ["tl", "tm", "tr", "mr", "br", "bm", "bl", "ml"],
validator: (val) => {
const s = new Set(["tl", "tm", "tr", "mr", "br", "bm", "bl", "ml"]);
return new Set(val.filter((h) => s.has(h))).size === val.length;
},
},
dragHandle: {
type: String,
default: null,
},
dragCancel: {
type: String,
default: null,
},
axis: {
type: String,
default: "both",
validator: (val) => ["x", "y", "both"].includes(val),
},
grid: {
type: Array,
default: () => [1, 1],
},
customId: {
type: [String, Number],
default: "",
},
parent: {
type: [Boolean,String],
default: false,
},
scale: {
type: [Number, Array],
default: 1,
validator: (val) => {
if (typeof val === "number") {
return val > 0;
}
return val.length === 2 && val[0] > 0 && val[1] > 0;
},
},
onDragStart: {
type: Function,
default: () => true,
},
onDrag: {
type: Function,
default: () => true,
},
onResizeStart: {
type: Function,
default: () => true,
},
onResize: {
type: Function,
default: () => true,
},
},
data: function () {
return {
left: this.x,
top: this.y,
right: null,
bottom: null,
width: null,
height: null,
widthTouched: false,
heightTouched: false,
aspectFactor: null,
parentWidth: null,
parentHeight: null,
minW: this.minWidth,
minH: this.minHeight,
maxW: this.maxWidth,
maxH: this.maxHeight,
handle: null,
enabled: this.active,
resizing: false,
dragging: false,
dragEnable: false,
resizeEnable: false,
zIndex: this.z,
};
},
created: function () {
// eslint-disable-next-line
if (this.maxWidth && this.minWidth > this.maxWidth)
console.warn(
"[Vdr warn]: Invalid prop: minWidth cannot be greater than maxWidth"
);
// eslint-disable-next-line
if (this.maxWidth && this.minHeight > this.maxHeight)
console.warn(
"[Vdr warn]: Invalid prop: minHeight cannot be greater than maxHeight"
);
this.resetBoundsAndMouseState();
},
mounted: function () {
if (!this.enableNativeDrag) {
this.$el.ondragstart = () => false;
}
const [parentWidth, parentHeight] = this.getParentSize();
this.parentWidth = parentWidth;
this.parentHeight = parentHeight;
const [width, height] = getComputedSize(this.$el);
this.aspectFactor =
(this.w !== "auto" ? this.w : width) /
(this.h !== "auto" ? this.h : height);
this.width = this.w !== "auto" ? this.w : width;
this.height = this.h !== "auto" ? this.h : height;
this.right = this.parentWidth - this.width - this.left;
this.bottom = this.parentHeight - this.height - this.top;
if (this.active) {
this.$emit("activated");
}
addEvent(document.documentElement, "mousedown", this.deselect);
addEvent(document.documentElement, "touchend touchcancel", this.deselect);
addEvent(window, "resize", this.checkParentSize);
},
beforeDestroy: function () {
removeEvent(document.documentElement, "mousedown", this.deselect);
removeEvent(document.documentElement, "touchstart", this.handleUp);
removeEvent(document.documentElement, "mousemove", this.move);
removeEvent(document.documentElement, "touchmove", this.move);
removeEvent(document.documentElement, "mouseup", this.handleUp);
removeEvent(
document.documentElement,
"touchend touchcancel",
this.deselect
);
removeEvent(window, "resize", this.checkParentSize);
},
methods: {
resetBoundsAndMouseState() {
this.mouseClickPosition = {
mouseX: 0,
mouseY: 0,
x: 0,
y: 0,
w: 0,
h: 0,
};
this.bounds = {
minLeft: null,
maxLeft: null,
minRight: null,
maxRight: null,
minTop: null,
maxTop: null,
minBottom: null,
maxBottom: null,
};
},
checkParentSize() {
if (this.parent) {
const [newParentWidth, newParentHeight] = this.getParentSize();
this.parentWidth = newParentWidth;
this.parentHeight = newParentHeight;
this.right = this.parentWidth - this.width - this.left;
this.bottom = this.parentHeight - this.height - this.top;
}
},
getParentSize() {
if (this.parent) {
const style = window.getComputedStyle(this.$el.parentNode, null);
return [
parseInt(style.getPropertyValue("width"), 10),
parseInt(style.getPropertyValue("height"), 10),
];
}
return [null, null];
},
elementTouchDown(e) {
eventsFor = events.touch;
this.elementDown(e);
},
elementMouseDown(e) {
eventsFor = events.mouse;
this.elementDown(e);
},
elementDown(e) {
if (e instanceof MouseEvent && e.which !== 1) {
return;
}
const target = e.target || e.srcElement;
if (this.$el.contains(target)) {
if (this.onDragStart(e) === false) {
return;
}
if (
(this.dragHandle &&
!matchesSelectorToParentElements(
target,
this.dragHandle,
this.$el
)) ||
(this.dragCancel &&
matchesSelectorToParentElements(target, this.dragCancel, this.$el))
) {
this.dragging = false;
return;
}
if (!this.enabled) {
this.enabled = true;
this.$emit("activated", this.customId);
this.$emit("update:active", true);
}
if (this.draggable) {
this.dragEnable = true;
}
this.mouseClickPosition.mouseX = e.touches
? e.touches[0].pageX
: e.pageX;
this.mouseClickPosition.mouseY = e.touches
? e.touches[0].pageY
: e.pageY;
this.mouseClickPosition.left = this.left;
this.mouseClickPosition.right = this.right;
this.mouseClickPosition.top = this.top;
this.mouseClickPosition.bottom = this.bottom;
if (this.parent) {
this.bounds = this.calcDragLimits();
}
addEvent(document.documentElement, eventsFor.move, this.move);
addEvent(document.documentElement, eventsFor.stop, this.handleUp);
}
},
calcDragLimits() {
return {
minLeft: this.left % this.grid[0],
maxLeft:
Math.floor(
(this.parentWidth - this.width - this.left) / this.grid[0]
) *
this.grid[0] +
this.left,
minRight: this.right % this.grid[0],
maxRight:
Math.floor(
(this.parentWidth - this.width - this.right) / this.grid[0]
) *
this.grid[0] +
this.right,
minTop: this.top % this.grid[1],
maxTop:
Math.floor(
(this.parentHeight - this.height - this.top) / this.grid[1]
) *
this.grid[1] +
this.top,
minBottom: this.bottom % this.grid[1],
maxBottom:
Math.floor(
(this.parentHeight - this.height - this.bottom) / this.grid[1]
) *
this.grid[1] +
this.bottom,
};
},
deselect(e) {
const target = e.target || e.srcElement;
const regex = new RegExp(this.className + "-([trmbl]{2})", "");
if (!this.$el.contains(target) && !regex.test(target.className)) {
if (this.enabled && !this.preventDeactivation) {
this.enabled = false;
this.$emit("deactivated");
this.$emit("update:active", false);
}
removeEvent(
document.documentElement,
eventsFor.move,
this.handleResize
);
}
this.resetBoundsAndMouseState();
},
handleTouchDown(handle, e) {
eventsFor = events.touch;
this.handleDown(handle, e);
},
handleDown(handle, e) {
if (e instanceof MouseEvent && e.which !== 1) {
return;
}
if (this.onResizeStart(handle, e) === false) {
return;
}
if (e.stopPropagation) e.stopPropagation();
// Here we avoid a dangerous recursion by faking
// corner handles as middle handles
if (this.lockAspectRatio && !handle.includes("m")) {
this.handle = "m" + handle.substring(1);
} else {
this.handle = handle;
}
this.resizeEnable = true;
this.mouseClickPosition.mouseX = e.touches ? e.touches[0].pageX : e.pageX;
this.mouseClickPosition.mouseY = e.touches ? e.touches[0].pageY : e.pageY;
this.mouseClickPosition.left = this.left;
this.mouseClickPosition.right = this.right;
this.mouseClickPosition.top = this.top;
this.mouseClickPosition.bottom = this.bottom;
this.bounds = this.calcResizeLimits();
addEvent(document.documentElement, eventsFor.move, this.handleResize);
addEvent(document.documentElement, eventsFor.stop, this.handleUp);
},
calcResizeLimits() {
let minW = this.minW;
let minH = this.minH;
let maxW = this.maxW;
let maxH = this.maxH;
const aspectFactor = this.aspectFactor;
const [gridX, gridY] = this.grid;
const width = this.width;
const height = this.height;
const left = this.left;
const top = this.top;
const right = this.right;
const bottom = this.bottom;
if (this.lockAspectRatio) {
if (minW / minH > aspectFactor) {
minH = minW / aspectFactor;
} else {
minW = aspectFactor * minH;
}
if (maxW && maxH) {
maxW = Math.min(maxW, aspectFactor * maxH);
maxH = Math.min(maxH, maxW / aspectFactor);
} else if (maxW) {
maxH = maxW / aspectFactor;
} else if (maxH) {
maxW = aspectFactor * maxH;
}
}
maxW = maxW - (maxW % gridX);
maxH = maxH - (maxH % gridY);
const limits = {
minLeft: null,
maxLeft: null,
minTop: null,
maxTop: null,
minRight: null,
maxRight: null,
minBottom: null,
maxBottom: null,
};
if (this.parent) {
limits.minLeft = left % gridX;
limits.maxLeft = left + Math.floor((width - minW) / gridX) * gridX;
limits.minTop = top % gridY;
limits.maxTop = top + Math.floor((height - minH) / gridY) * gridY;
limits.minRight = right % gridX;
limits.maxRight = right + Math.floor((width - minW) / gridX) * gridX;
limits.minBottom = bottom % gridY;
limits.maxBottom = bottom + Math.floor((height - minH) / gridY) * gridY;
if (maxW) {
limits.minLeft = Math.max(
limits.minLeft,
this.parentWidth - right - maxW
);
limits.minRight = Math.max(
limits.minRight,
this.parentWidth - left - maxW
);
}
if (maxH) {
limits.minTop = Math.max(
limits.minTop,
this.parentHeight - bottom - maxH
);
limits.minBottom = Math.max(
limits.minBottom,
this.parentHeight - top - maxH
);
}
if (this.lockAspectRatio) {
limits.minLeft = Math.max(limits.minLeft, left - top * aspectFactor);
limits.minTop = Math.max(limits.minTop, top - left / aspectFactor);
limits.minRight = Math.max(
limits.minRight,
right - bottom * aspectFactor
);
limits.minBottom = Math.max(
limits.minBottom,
bottom - right / aspectFactor
);
}
} else {
limits.minLeft = null;
limits.maxLeft = left + Math.floor((width - minW) / gridX) * gridX;
limits.minTop = null;
limits.maxTop = top + Math.floor((height - minH) / gridY) * gridY;
limits.minRight = null;
limits.maxRight = right + Math.floor((width - minW) / gridX) * gridX;
limits.minBottom = null;
limits.maxBottom = bottom + Math.floor((height - minH) / gridY) * gridY;
if (maxW) {
limits.minLeft = -(right + maxW);
limits.minRight = -(left + maxW);
}
if (maxH) {
limits.minTop = -(bottom + maxH);
limits.minBottom = -(top + maxH);
}
if (this.lockAspectRatio && maxW && maxH) {
limits.minLeft = Math.min(limits.minLeft, -(right + maxW));
limits.minTop = Math.min(limits.minTop, -(maxH + bottom));
limits.minRight = Math.min(limits.minRight, -left - maxW);
limits.minBottom = Math.min(limits.minBottom, -top - maxH);
}
}
return limits;
},
move(e) {
if (this.resizing) {
this.handleResize(e);
} else if (this.dragEnable) {
this.handleDrag(e);
}
},
handleDrag(e) {
const axis = this.axis;
const grid = this.grid;
const bounds = this.bounds;
const mouseClickPosition = this.mouseClickPosition;
const tmpDeltaX =
axis && axis !== "y"
? mouseClickPosition.mouseX -
(e.touches ? e.touches[0].pageX : e.pageX)
: 0;
const tmpDeltaY =
axis && axis !== "x"
? mouseClickPosition.mouseY -
(e.touches ? e.touches[0].pageY : e.pageY)
: 0;
const [deltaX, deltaY] = snapToGrid(
grid,
tmpDeltaX,
tmpDeltaY,
this.scale
);
const left = restrictToBounds(
mouseClickPosition.left - deltaX,
bounds.minLeft,
bounds.maxLeft
);
const top = restrictToBounds(
mouseClickPosition.top - deltaY,
bounds.minTop,
bounds.maxTop
);
if (this.onDrag(left, top) === false) {
return;
}
const right = restrictToBounds(
mouseClickPosition.right + deltaX,
bounds.minRight,
bounds.maxRight
);
const bottom = restrictToBounds(
mouseClickPosition.bottom + deltaY,
bounds.minBottom,
bounds.maxBottom
);
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
this.$emit("dragging", this.left, this.top);
this.dragging = true;
},
moveHorizontally(val) {
// should calculate with scale 1.
const [deltaX, _] = snapToGrid(this.grid, val, this.top, 1);
const left = restrictToBounds(
deltaX,
this.bounds.minLeft,
this.bounds.maxLeft
);
this.left = left;
this.right = this.parentWidth - this.width - left;
},
moveVertically(val) {
// should calculate with scale 1.
const [_, deltaY] = snapToGrid(this.grid, this.left, val, 1);
const top = restrictToBounds(
deltaY,
this.bounds.minTop,
this.bounds.maxTop
);
this.top = top;
this.bottom = this.parentHeight - this.height - top;
},
handleResize(e) {
let left = this.left;
let top = this.top;
let right = this.right;
let bottom = this.bottom;
const mouseClickPosition = this.mouseClickPosition;
const lockAspectRatio = this.lockAspectRatio;
const aspectFactor = this.aspectFactor;
const tmpDeltaX =
mouseClickPosition.mouseX - (e.touches ? e.touches[0].pageX : e.pageX);
const tmpDeltaY =
mouseClickPosition.mouseY - (e.touches ? e.touches[0].pageY : e.pageY);
if (!this.widthTouched && tmpDeltaX) {
this.widthTouched = true;
}
if (!this.heightTouched && tmpDeltaY) {
this.heightTouched = true;
}
const [deltaX, deltaY] = snapToGrid(
this.grid,
tmpDeltaX,
tmpDeltaY,
this.scale
);
if (this.handle.includes("b")) {
bottom = restrictToBounds(
mouseClickPosition.bottom + deltaY,
this.bounds.minBottom,
this.bounds.maxBottom
);
if (this.lockAspectRatio && this.resizingOnY) {
right = this.right - (this.bottom - bottom) * aspectFactor;
}
} else if (this.handle.includes("t")) {
top = restrictToBounds(
mouseClickPosition.top - deltaY,
this.bounds.minTop,
this.bounds.maxTop
);
if (this.lockAspectRatio && this.resizingOnY) {
left = this.left - (this.top - top) * aspectFactor;
}
}
if (this.handle.includes("r")) {
right = restrictToBounds(
mouseClickPosition.right + deltaX,
this.bounds.minRight,
this.bounds.maxRight
);
if (this.lockAspectRatio && this.resizingOnX) {
bottom = this.bottom - (this.right - right) / aspectFactor;
}
} else if (this.handle.includes("l")) {
left = restrictToBounds(
mouseClickPosition.left - deltaX,
this.bounds.minLeft,
this.bounds.maxLeft
);
if (this.lockAspectRatio && this.resizingOnX) {
top = this.top - (this.left - left) / aspectFactor;
}
}
const width = computeWidth(this.parentWidth, left, right);
const height = computeHeight(this.parentHeight, top, bottom);
if (this.onResize(this.handle, left, top, width, height) === false) {
return;
}
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
this.width = width;
this.height = height;
this.$emit("resizing", this.left, this.top, this.width, this.height);
this.resizing = true;
},
changeWidth(val) {
// should calculate with scale 1.
const [newWidth, _] = snapToGrid(this.grid, val, 0, 1);
let right = restrictToBounds(
this.parentWidth - newWidth - this.left,
this.bounds.minRight,
this.bounds.maxRight
);
let bottom = this.bottom;
if (this.lockAspectRatio) {
bottom = this.bottom - (this.right - right) / this.aspectFactor;
}
const width = computeWidth(this.parentWidth, this.left, right);
const height = computeHeight(this.parentHeight, this.top, bottom);
this.right = right;
this.bottom = bottom;
this.width = width;
this.height = height;
},
changeHeight(val) {
// should calculate with scale 1.
const [_, newHeight] = snapToGrid(this.grid, 0, val, 1);
let bottom = restrictToBounds(
this.parentHeight - newHeight - this.top,
this.bounds.minBottom,
this.bounds.maxBottom
);
let right = this.right;
if (this.lockAspectRatio) {
right = this.right - (this.bottom - bottom) * this.aspectFactor;
}
const width = computeWidth(this.parentWidth, this.left, right);
const height = computeHeight(this.parentHeight, this.top, bottom);
this.right = right;
this.bottom = bottom;
this.width = width;
this.height = height;
},
handleUp(e) {
this.handle = null;
this.resetBoundsAndMouseState();
this.dragEnable = false;
this.resizeEnable = false;
if (this.resizing) {
this.resizing = false;
this.$emit("resizestop", this.left, this.top, this.width, this.height);
}
if (this.dragging) {
this.dragging = false;
this.$emit("dragstop", this.left, this.top);
}
removeEvent(document.documentElement, eventsFor.move, this.handleResize);
},
},
computed: {
style() {
return {
transform: `translate(${this.left}px, ${this.top}px)`,
width: this.computedWidth,
height: this.computedHeight,
zIndex: this.zIndex,
...(this.dragging && this.disableUserSelect
? userSelectNone
: userSelectAuto),
};
},
actualHandles() {
if (!this.resizable) return [];
return this.handles;
},
computedWidth() {
if (this.w === "auto") {
if (!this.widthTouched) {
return "auto";
}
}
return this.width + "px";
},
computedHeight() {
if (this.h === "auto") {
if (!this.heightTouched) {
return "auto";
}
}
return this.height + "px";
},
resizingOnX() {
return (
Boolean(this.handle) &&
(this.handle.includes("l") || this.handle.includes("r"))
);
},
resizingOnY() {
return (
Boolean(this.handle) &&
(this.handle.includes("t") || this.handle.includes("b"))
);
},
isCornerHandle() {
return (
Boolean(this.handle) && ["tl", "tr", "br", "bl"].includes(this.handle)
);
},
},
watch: {
active(val) {
this.enabled = val;
if (val) {
this.$emit("activated");
} else {
this.$emit("deactivated");
}
},
z(val) {
if (val >= 0 || val === "auto") {
this.zIndex = val;
}
},
x(val) {
if (this.resizing || this.dragging) {
return;
}
if (this.parent) {
this.bounds = this.calcDragLimits();
}
this.moveHorizontally(val);
},
y(val) {
if (this.resizing || this.dragging) {
return;
}
if (this.parent) {
this.bounds = this.calcDragLimits();
}
this.moveVertically(val);
},
lockAspectRatio(val) {
if (val) {
this.aspectFactor = this.width / this.height;
} else {
this.aspectFactor = undefined;
}
},
minWidth(val) {
if (val > 0 && val <= this.width) {
this.minW = val;
}
},
minHeight(val) {
if (val > 0 && val <= this.height) {
this.minH = val;
}
},
maxWidth(val) {
this.maxW = val;
},
maxHeight(val) {
this.maxH = val;
},
w(val) {
if (this.resizing || this.dragging) {
return;
}
if (this.parent) {
this.bounds = this.calcResizeLimits();
}
this.changeWidth(val);
},
h(val) {
if (this.resizing || this.dragging) {
return;
}
if (this.parent) {
this.bounds = this.calcResizeLimits();
}
this.changeHeight(val);
},
},
};
</script>
......@@ -2,13 +2,14 @@
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-05-19 13:46:20
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-05-31 18:11:57
* @LastEditTime: 2023-07-09 12:59:17
* @FilePath: \scrm-micro-home\src\mixins\gpt.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { mapState, mapActions } from 'vuex'
import apis from '@/api'
import Drawing from '@/utils/drawing'
const WIDTH = 375
export default {
data() {
return {}
......@@ -77,6 +78,43 @@ export default {
} catch (e) {
console.log(e)
}
},
async createMain(h, url, draggableList) {
const style1 = draggableList[0]
const style2 = draggableList[1]
const drawfun = new Drawing(document.getElementById('canvasId'), {
width: WIDTH,
height: h
})
const imageList = [
{
url,
x: 0,
y: 0,
width: WIDTH,
height: h
}
]
const textList = [
{ x: style1.x, y: style1.y, fontSize: style1.size, width: style1.width, text: style1.content },
{ x: style2.x, y: style2.y, fontSize: style2.size, width: style2.width, text: style2.content }
]
console.log(imageList, textList)
const canvasBase64 = await drawfun.begin({
imageList,
textList
})
return new Promise(async resolve => {
resolve(await this.uploadImg(canvasBase64))
})
},
uploadImg(imgFile) {
return new Promise((resolve, reject) => {
const base64 = 'png' + '@' + imgFile.split(',')[1]
apis.common.pictureUpload({ file: base64, fileType: 'image' }).then(res => {
resolve(res)
})
})
}
},
mounted() {}
......
......@@ -2,25 +2,34 @@
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-05-16 17:13:33
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-07-07 18:23:30
* @LastEditTime: 2023-07-09 11:19:44
* @FilePath: \scrm-micro-home\src\store\modules\marketing.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import apis from '@/api'
const subscribeData = { 5: '保险', 2: '定保', 8: '售后众筹' }
const subscribeData = { 5: '保险', 2: '定保', 9: '售后众筹' }
export default {
namespaced: true,
state: {
subscribe: null,
subscribe: 5,
keywords: null,
GPTList: null,
packageList: {},
process: { 0: false, 1: false, 2: false },
activityInfo: {}
activityInfo: null
},
mutations: {
SET_INIT(state, data) {
if (data) {
state.keywords = null
state.GPTList = null
state.packageList = {}
state.process = Object.assign({}, { 0: false, 1: false, 2: false })
state.activityInfo = Object.assign({})
}
},
// 设置场景值
SET_SUBSCRIBE(state, data) {
state.subscribe = data
......@@ -55,19 +64,15 @@ export default {
})
},
//活动活动详情
getActivityInfo({ commit }, data) {
let { id, subscribe } = data,
param = {
activityId: id
},
activityAPi = 'findActivityInfo'
if (subscribe != 8) {
param = {
id
}
activityAPi = 'activityDetail'
}
apis.marketing[activityAPi](param).then(res => {
getActivityInfo({ commit, state }, data) {
apis.marketing.activityDetail({ id: data }).then(res => {
state.subscribe = res.subscribe
commit('SET_ACTIVITY_INFO', res)
})
},
//活动模板详情
getCalendarDetail({ commit }, data) {
apis.marketing.calendarDetail({ id: data }).then(res => {
commit('SET_ACTIVITY_INFO', res)
})
},
......
import { isFunction } from './fns'
export function matchesSelectorToParentElements(el, selector, baseNode) {
let node = el
const matchesSelectorFunc = ['matches', 'webkitMatchesSelector', 'mozMatchesSelector', 'msMatchesSelector', 'oMatchesSelector'].find(func => isFunction(node[func]))
if (!isFunction(node[matchesSelectorFunc])) return false
do {
if (node[matchesSelectorFunc](selector)) return true
if (node === baseNode) return false
node = node.parentNode
} while (node)
return false
}
export function getComputedSize($el) {
const style = window.getComputedStyle($el)
return [parseFloat(style.getPropertyValue('width'), 10), parseFloat(style.getPropertyValue('height'), 10)]
}
export function addEvent(el, event, handler) {
if (!el) {
return
}
if (el.attachEvent) {
el.attachEvent('on' + event, handler)
} else if (el.addEventListener) {
el.addEventListener(event, handler, true)
} else {
el['on' + event] = handler
}
}
export function removeEvent(el, event, handler) {
if (!el) {
return
}
if (el.detachEvent) {
el.detachEvent('on' + event, handler)
} else if (el.removeEventListener) {
el.removeEventListener(event, handler, true)
} else {
el['on' + event] = null
}
}
export function isFunction(func) {
return typeof func === 'function' || Object.prototype.toString.call(func) === '[object Function]'
}
export function snapToGrid(grid, pendingX, pendingY, scale = 1) {
const [scaleX, scaleY] = typeof scale === 'number' ? [scale, scale] : scale
const x = Math.round(pendingX / scaleX / grid[0]) * grid[0]
const y = Math.round(pendingY / scaleY / grid[1]) * grid[1]
return [x, y]
}
export function getSize(el) {
const rect = el.getBoundingClientRect()
return [parseInt(rect.width), parseInt(rect.height)]
}
export function computeWidth(parentWidth, left, right) {
return parentWidth - left - right
}
export function computeHeight(parentHeight, top, bottom) {
return parentHeight - top - bottom
}
export function restrictToBounds(value, min, max) {
if (min !== null && value < min) {
return min
}
if (max !== null && max < value) {
return max
}
return value
}
......@@ -15,7 +15,7 @@
<el-tab-pane label="保 险" name="5"></el-tab-pane>
<el-tab-pane label="定 保" name="2"></el-tab-pane>
<el-tab-pane label="节日关怀" name="6"></el-tab-pane>
<el-tab-pane label="售后众筹" name="4"></el-tab-pane>
<el-tab-pane label="售后众筹" name="9"></el-tab-pane>
</el-tabs>
<div></div>
</div>
......@@ -130,7 +130,7 @@ export default {
//引用
handleUse(row) {
this.caseVisible = false
this.getActivityInfo(row)
this.getActivityInfo(row.id)
},
//预览
handleView(row) {},
......
......@@ -2,7 +2,7 @@
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-06-29 21:24:27
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-07-07 18:29:33
* @LastEditTime: 2023-07-09 12:29:03
* @FilePath: \scrm-micro-link\src\views\activityLink\components\MarketingContent.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
......@@ -60,7 +60,8 @@ export default {
editFormData: [
{
label: '预设模板',
addHtml: 'model'
addHtml: 'model',
isHide: false
},
{
label: '营销标题',
......@@ -207,6 +208,7 @@ export default {
deep: true
},
subscribe(val) {
console.log(val, 999)
if (val == 5) {
this.editRule.detailImage[0].required = false
this.editFormData[0].isHide = false
......@@ -217,6 +219,13 @@ export default {
},
activityInfo: {
handler(info) {
if (Object.keys(info).length == 0) {
return (this.editForm = {})
}
if (info.subTitle) {
this.setDetail(info)
return
}
this.editForm = this.$common.utils.deepClone(info)
if (info.activityName) {
this.$set(this.editForm, 'marketingTitle', info.activityName)
......@@ -242,10 +251,21 @@ export default {
}
},
computed: {
...mapState('marketing', ['GPTList', 'subscribe', 'activityInfo'])
...mapState('marketing', ['GPTList', 'subscribe', 'activityInfo', 'isInit'])
},
methods: {
...mapActions('marketing', ['setProcess']),
setDetail(info) {
const { title, subTitle, startTime, endTime, backgroundImg, captionImg, titleStyle, subTitleStyle, codeId } = this.$common.utils.deepClone(info || {})
this.editForm.codeId = codeId
this.editForm.marketingTitle = title
this.editForm.marketingSubtitle = subTitle
this.editForm.backgroundImage = backgroundImg
this.editForm.detailImage = captionImg
this.editForm.titleStyle = titleStyle
this.editForm.subTitleStyle = subTitleStyle
this.editForm.activityTime = [startTime + ' 00:00:00', endTime + ' 00:00:00']
},
handleSure(val) {
this.modelVisible = false
this.getTemplateInfo(val.id)
......@@ -253,8 +273,9 @@ export default {
getTemplateInfo(id) {
this.$apis.marketing.calendarDetail({ id }).then(res => {
console.log(res)
const { title, subTitle, startTime, endTime, backgroundImg, captionImg } = this.$common.utils.deepClone(res || {})
const { title, subTitle, startTime, endTime, backgroundImg, captionImg, codeId } = this.$common.utils.deepClone(res || {})
this.editForm.templateId = id
this.editForm.codeId = id
this.editForm.marketingTitle = title
this.editForm.marketingSubtitle = subTitle
this.editForm.backgroundImage = backgroundImg
......
......@@ -15,7 +15,7 @@
<div v-show="currentIndex == 1" class="car-table">
<GLTable :hasPage="false" v-loading="loading" ref="carRef" :tableData="carList" :tableParams="carTableParams" @refreshTable="getCarList" @select="handleSelectionCarTable">
<template slot="price" slot-scope="scope">
<el-input v-model="scope.scope.price" placeholder="请输入"></el-input>
<el-input v-model="scope.scope.packageAmount" placeholder="请输入"></el-input>
</template>
</GLTable>
</div>
......@@ -34,7 +34,7 @@
<div class="tab-border" :style="{ left: (serviceIndex == 7 ? 0 : serviceIndex - 1) * 88 + 2 + 'px' }"></div>
</div>
<div v-for="(item, index) in serviceTabList" :key="index">
<GLTable :hasPage="false" v-loading="loading" v-show="serviceIndex == item.type" :ref="'serviceRef' + item.type" :tableData="serviceList" :tableParams="serviceTableParams" @refreshTable="getServiceList" @select="handleSelectionServiceTable">
<GLTable v-loading="loading" v-show="serviceIndex == item.type" :ref="'serviceRef' + item.type" :tableData="serviceList" :tableParams="serviceTableParams" @refreshTable="getServiceList" @select="handleSelectionServiceTable">
<span slot="effectiveType" slot-scope="scope">
<span>{{ toLabelText(scope.scope) }}</span>
</span>
......@@ -98,7 +98,7 @@ export default {
type: 'input'
}
],
giftList: [{ name: 'A礼包' }, { name: 'B礼包' }]
giftList: []
}
},
watch: {
......@@ -120,9 +120,20 @@ export default {
},
activityInfo: {
handler(info) {
if (info.serviceMerchantPackageConfigDTOList && info.serviceMerchantPackageConfigDTOList.length) {
this.selectedCarList = info.serviceMerchantPackageConfigDTOList
let activityCoupon = info.activityCouponBaseInfoDTOS || info.couponList
this.init()
this.$nextTick(() => {
if (info.serviceMerchantPackageConfigDTOList && info.serviceMerchantPackageConfigDTOList.length) {
this.selectedCarList = info.serviceMerchantPackageConfigDTOList.map(item => {
return {
packageCode: item.packageCode,
packageAmount: item.packageAmount
}
})
this.selectedCarList = info.serviceMerchantPackageConfigDTOList
}
let activityCoupon = info.activityCouponBaseInfoDTOS || info.couponList || info.couponItemList
if (activityCoupon && activityCoupon.length) {
activityCoupon.forEach(item => {
item.id = item.couponId
......@@ -131,7 +142,9 @@ export default {
this.selectedGoodsList = activityCoupon.filter(i => i.discountType == 8)
this.selectedServiceList = activityCoupon.filter(i => i.discountType != 8)
}
}
console.log(this.selectedCarList, this.selectedGoodsList, this.selectedServiceList, 11111111)
this.getList()
})
},
deep: true
}
......@@ -141,6 +154,20 @@ export default {
},
methods: {
...mapActions('marketing', ['setPackage', 'setProcess']),
init() {
this.currentIndex = '1'
this.goodsIndex = 1
this.serviceIndex = 7
this.carList = []
this.selectedCarList = []
this.serviceList = []
this.selectedServiceList = []
this.goodsList = []
this.selectedGoodsList = []
this.$refs['carRef'].$refs['listMutiTable'].clearSelection()
this.$refs['goodsRef' + this.goodsIndex][0].$refs['listMutiTable'].clearSelection()
this.$refs['serviceRef' + this.serviceIndex][0].$refs['listMutiTable'].clearSelection()
},
getGiftList(val) {
const { merchantId } = this
let params = {
......@@ -152,6 +179,9 @@ export default {
})
},
handleSaveGift() {
if (!this.editForm.activityPrice) {
this.$message.error('输入活动价格')
}
if (this.selectedGoodsList.length + this.selectedServiceList.length + this.selectedCarList.length == 0) {
this.$message.error('权益服务、平台优惠、门店优惠券至少选一项')
return
......@@ -186,8 +216,9 @@ export default {
})
const equities = {}
selectedCarList.forEach(item => {
equities[item.packageCode] = item.price
equities[item.packageCode] = item.packageAmount
})
console.log(equities, selectedCarList)
let params = {
merchantId,
activitySubscribe: subscribe,
......@@ -225,10 +256,11 @@ export default {
},
// 选择/取消 门店服务
handleSelectionServiceTable(selection, row) {
console.log(selection, row)
if (selection && selection.find(item => item && item.id == row.id)) {
this.addRows(this.selectedServiceList, [row])
this.addRows(this.selectedServiceList, [row], 'id')
} else {
this.deleteRows(this.selectedServiceList, [val])
this.deleteRows(this.selectedServiceList, [row], 'id')
}
console.log(this.selectedServiceList)
// this.selectedServiceList = val
......@@ -301,6 +333,7 @@ export default {
.then(res => {
this.loading = false
this.carList = res.packageConfigs
this.selectedPreExisting(this.selectedCarList, this.carList, 'packageCode', this.$refs['carRef'])
})
.finally(() => {
this.loading = false
......@@ -369,7 +402,7 @@ export default {
this.serviceList = res.list
// this.fnCallBack = true
this.$refs['serviceRef' + this.serviceIndex][0].tableTotal = res.total
this.selectedPreExisting(this.selectedServiceList, this.serviceList, 'id', this.$refs['goodsRef' + this.serviceIndex][0])
this.selectedPreExisting(this.selectedServiceList, this.serviceList, 'id', this.$refs['serviceRef' + this.serviceIndex][0])
})
.finally(() => {
this.loading = false
......@@ -377,8 +410,34 @@ export default {
},
//获取礼包详情
getModel() {
if (!this.giftValue) {
return
}
this.$apis.giftBag.packageDetail({ id: this.giftValue }).then(res => {
console.log(res)
this.init()
this.$nextTick(() => {
if (res.serviceMerchantPackageConfigDTOS && res.serviceMerchantPackageConfigDTOS.length) {
this.selectedCarList = res.serviceMerchantPackageConfigDTOS.map(item => {
return {
packageCode: item.packageCode,
packageAmount: item.packageAmount
}
})
}
let activityCoupon = res.couponList || []
if (activityCoupon && activityCoupon.length) {
activityCoupon.forEach(item => {
item.id = item.couponId
item.denomination = item.couponAnticipatedCost
})
this.selectedGoodsList = activityCoupon.filter(i => i.discountType == 8)
this.selectedServiceList = activityCoupon.filter(i => i.discountType != 8)
}
console.log(this.selectedCarList)
this.getList()
})
})
},
handleClose() {
......
......@@ -23,12 +23,12 @@
<div class="task-box-num">导入客户</div>
<div class="task-num-item flex-column-center">
<label>分配方式:</label>
{{ item.taskType == 1 ? '平均分配' : '上次跟进人' }}
{{ item.assignType == 0 ? '平均分配' : '上次跟进人' }}
</div>
<div class="task-num-item flex">
<label>选择跟进人:</label>
<div class="task-border">
<div class="flow-emp" v-for="(v, k) in item.staffList" :key="k">{{ v.staffName }}({{ v.customerNum }}人)</div>
<div class="flow-emp" v-for="(v, k) in item.staffList" :key="k">{{ v.staffName || v.staffPhone }}({{ v.customerNum }}人)</div>
</div>
</div>
</div>
......@@ -43,27 +43,27 @@
</el-button>
<input type="file" style="opacity: 0" ref="file" accept="*" @change="uploadFile($event, item)" />
</div>
<a>下载数据模板</a>
<a :href="importUrl">下载数据模板</a>
</div>
<div class="task-box-desc">
<div class="task-box-num">导入客户</div>
<div class="task-num-item flex-column-center">
<label>分配方式:</label>
<el-radio-group v-model="item.taskType" @change="handleChange(item)">
<el-radio :label="1">平均分配</el-radio>
<el-radio :label="2">上次跟进人</el-radio>
<el-radio-group v-model="item.assignType" @change="handleChange(item)">
<el-radio :label="0">平均分配</el-radio>
<el-radio :label="1">上次跟进人</el-radio>
</el-radio-group>
</div>
<div class="task-num-item flex">
<label>选择跟进人:</label>
<el-table class="task-tabel" :ref="'form' + item.batchNo" :data="item.taskType == 1 ? tableData : tableData.concat(item.LastFollowStaff)" tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange($event, item)">
<el-table class="task-tabel" :ref="'form' + item.batchNo" :data="item.tableData" tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange($event, item)">
<el-table-column type="selection" width="55"></el-table-column>
<el-table-column label="跟进人" width="220">
<template slot-scope="scope">{{ scope.row.staffName }} {{ scope.row.staffPhone }}</template>
<template slot-scope="scope">{{ scope.row?.staffName }} {{ scope.row?.staffPhone }}</template>
</el-table-column>
<el-table-column label="操作" width="260">
<div class="config-panel flex" slot-scope="scope">
<div class="config-msg" v-if="item.taskType == 2" @click="showRegister">邀请人员注册</div>
<div class="config-msg" v-if="item.assignType == 1" @click="showRegister">邀请人员注册</div>
<div class="config-msg" @click="handleConfig(scope.row)">配置话术 / 短信</div>
</div>
</el-table-column>
......@@ -99,8 +99,7 @@
<el-form ref="configForm" :model="configForm" label-width="200px">
<el-form-item label="AI人工智能外呼:" :size="size">
<el-select v-model="configForm.talkId" placeholder="请选择">
<el-option label="区域一" value="shanghai"></el-option>
<el-option label="区域二" value="beijing"></el-option>
<el-option v-for="item in roobList" :key="item.id" :label="item.label" :value="item.value"></el-option>
</el-select>
</el-form-item>
<el-form-item label="营销短信:" :size="size">
......@@ -113,8 +112,8 @@
</template>
<script>
const taskData = { expand: true, taskType: 1, customerNumTotal: 0, lastFollowStaffList: [], staffList: [], excelUrl: '', isFinish: false }
import { mapActions } from 'vuex'
const taskData = { tableData: [], expand: true, assignType: 0, customerNumTotal: 0, lastFollowStaffList: [], staffList: [], excelUrl: '', isFinish: false }
import { mapActions, mapState } from 'vuex'
export default {
data() {
return {
......@@ -126,12 +125,24 @@ export default {
isQrcodeVisible: false,
configVisible: false,
configForm: {},
tableData: []
tableData: [],
roobList: [{ labe: 3, value: 4 }]
}
},
mounted() {
this.findMerchantStaffList()
},
computed: {
...mapState('marketing', ['subscribe']),
importUrl() {
const url = {
5: 'https://wx.glsx.com.cn/upload/biz/e78dea4b-c55c-4af7-bb42-0f3d99bf27a8.xlsx',
2: 'https://wx.glsx.com.cn/upload/biz/4fec9d20-d685-4cee-8c3e-23f2d22b18ad.xlsx',
6: 'https://wx.glsx.com.cn/upload/biz/980515d5-20df-49a5-90a7-1accb2aed2a6.xlsx'
}
return url[this.subscribe]
}
},
methods: {
...mapActions('marketing', ['setProcess']),
uploadFile(e, item) {
......@@ -169,14 +180,15 @@ export default {
}
this.$apis.marketing.findMerchantStaffList(param).then(res => {
this.tableData = res || []
this.taskList[0].tableData = this.$common.utils.deepClone(this.tableData)
})
},
handleChange(item) {
if (item.taskType == 2) {
if (item.assignType == 1) {
const staffPhone = item.lastFollowStaffList.map(item => item.staffPhone)
this.tableData.forEach(i => {
item.tableData.forEach(i => {
if (staffPhone.includes(i.staffPhone)) {
this.$refs['form' + item.batchNo].toggleRowSelection(i)
this.$refs['form' + item.batchNo][0].toggleRowSelection(i)
}
})
}
......@@ -186,7 +198,7 @@ export default {
console.log(this.customerKeys)
let param = {
merchantId: this.$globalState.session.merchantId,
excelUrl: ['https://wx.glsx.com.cn/upload/biz/ef349845-5332-4bf0-9d5d-255c16afd7e7.xlsx', 'https://wx.glsx.com.cn/upload/biz/72dd6967-c2f9-478b-94a8-f31c955d839a.xlsx'][this.customerKey.length],
excelUrl: url,
customerKeys: this.customerKey
}
this.$apis.marketing.importCustomer(param).then(res => {
......@@ -195,6 +207,17 @@ export default {
item.lastFollowStaffList = res.lastFollowStaffList
item.customerNumTotal = res.customerNumTotal
this.customerKey.push(res.customerKey)
const staffList = [...item.lastFollowStaffList]
const staffPhone = staffList.map(item => item.staffPhone)
const tableData = this.$common.utils.deepClone(item.tableData)
tableData.forEach(item => {
if (!item.lastCustomerNum) item.lastCustomerNum = 0
if (!staffPhone.includes(item.staffPhone)) {
staffList.push(item)
}
})
item.tableData = staffList
console.log(item.tableData)
})
},
handleExpand(item) {
......@@ -202,9 +225,18 @@ export default {
},
handleSelectionChange(val, item) {
item.staffList = val
item.staffList.forEach(item => {
if (item.registerStatus !== 0) {
item.registerStatus = 1
item.staffList = item.staffList.map(item => {
return {
lastStaffFlag: item.lastCustomerNum ? 1 : 0,
lastCustomerNum: item.lastCustomerNum,
merchantId: item.merchantNo,
staffPhone: item.staffPhone,
staffName: item.staffName,
staffUuid: item.uuid,
id: item.id,
messageContent: item.messageContent,
talkId: item.talkId,
createdBy: item.createdBy
}
})
},
......@@ -216,6 +248,10 @@ export default {
handleConfig(row) {
this.configVisible = true
this.selectEmp = row
this.configForm = {
talkId: '',
messageContent: '【门店名称】诚邀您参与{0},请尽快点击链接参与,谨防错过哦! {1} 谨防错过退订回T。'
}
this.$apis.marketing.getRobotList({}).then(res => {
console.log(res)
})
......@@ -229,8 +265,37 @@ export default {
this.setProcess({ 0: true })
},
handleConfirm() {
console.log(this.taskList)
this.setProcess({ 0: { customerRequestList: this.taskList } })
const customerRequestList = this.$common.utils.deepClone(this.taskList)
delete customerRequestList.tableData
if (this.vaildTask()) this.setProcess({ 0: { customerRequestList } })
},
//验证配置任务,及分配人员
vaildTask() {
let len = this.taskList.length
const task = this.taskList[len - 1]
//获取上次跟进人总数
console.log(task.staffList)
let lastCustomerNum = task.staffList.reduce((prev, cur) => {
return prev + cur.lastCustomerNum || 0
}, 0)
if (task.assignType == 0) lastCustomerNum = 0
if (task.excelUrl && task.staffList.length) {
task.isFinish = true
const customerNumTotal = task.customerNumTotal - lastCustomerNum || 0 // 去除上次跟进人总数
const length = task.staffList.length
let avag = Math.ceil(customerNumTotal / length)
let residue = customerNumTotal
task.staffList.forEach((item, i) => {
const lastNum = task.assignType == 0 ? 0 : item.lastCustomerNum
this.$set(item, 'customerNum', residue > avag ? lastNum || 0 + avag : lastNum || 0 + residue)
residue = residue - avag
avag = Math.ceil(residue / (length - i - 1))
})
return true
} else {
this.$message.error('请配置营销任务')
return false
}
},
addTask() {
let len = this.taskList.length
......@@ -238,25 +303,12 @@ export default {
this.$message.error('营销任务不能超过10个')
return
}
const task = this.taskList[len - 1]
if (task.excelUrl && task.staffList.length) {
task.isFinish = true
if (task.taskType == 1) {
const customerNumTotal = task.customerNumTotal
const length = task.staffList.length
let avag = Math.ceil(customerNumTotal / length)
let residue = customerNumTotal
task.staffList.forEach(item => {
this.$set(item, 'customerNum', residue > avag ? avag : residue)
residue = residue - avag
})
console.log(task.staffList)
}
if (this.vaildTask())
this.taskList.push({
batchNo: ++len,
...taskData
...taskData,
tableData: this.$common.utils.deepClone(this.tableData)
})
}
}
}
}
......
......@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2023-05-15 15:08:32
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-07-07 12:17:20
* @LastEditTime: 2023-07-09 12:39:02
* @FilePath: \scrm-micro-home\src\views\home\components\Marketing\MarketingRight.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
......@@ -13,69 +13,93 @@
<img src="@/assets/seckillActivity/phone.png" class="review-phone" />
<div class="review-title_top">{{ detail.marketingTitle || detail.activityName }}</div>
<div class="review-content">
<div class="review-main">
<div class="review-main" v-if="backgroundHeight" :style="{ height: backgroundHeight + 'px' }">
<template v-for="item in draggableList">
<vue-draggable-resizable
:customId="item.customId"
:key="item.customId"
v-if="item.type == 'text'"
:w="item.width"
:h="item.height"
:x="item.x"
:y="item.y"
:style="{
'font-size': item.size + 'px',
color: item.color
}"
class="img_cl"
parent=".review-main"
@dragging="onDrag"
@resizing="onResize"
@activated="onActivated"
>
{{ item.content }}
</vue-draggable-resizable>
</template>
<div class="review-bg-img">
<img :src="detail.backgroundImg" v-if="detail.backgroundImg" />
</div>
<div class="main-body" style="background: #DEEAF2;">
<template v-if="modelNum == 1">
<!-- 权益服务 -->
<equity-one :detail="detail"></equity-one>
<!-- 商品券 -->
<goods-one :detail="detail"></goods-one>
<!-- 服务券 -->
<coupon-one :detail="detail"></coupon-one>
</template>
<template v-if="modelNum == 2">
<!-- 权益服务 -->
<equity-two :detail="detail"></equity-two>
<!-- 商品券 -->
<goods-two :detail="detail"></goods-two>
<!-- 服务券 -->
<coupon-two :detail="detail"></coupon-two>
</template>
<template v-if="modelNum == 3">
<!-- 权益服务 -->
<equity-three :detail="detail"></equity-three>
<!-- 商品券 -->
<goods-three :detail="detail"></goods-three>
<!-- 服务券 -->
<coupon-three :detail="detail"></coupon-three>
</template>
<template v-if="modelNum == 4">
<!-- 权益服务 -->
<equity-four :detail="detail"></equity-four>
<!-- 商品券 -->
<goods-four :detail="detail"></goods-four>
<!-- 服务券 -->
<coupon-four :detail="detail"></coupon-four>
</template>
<img :src="detail.backgroundImage" v-if="detail.backgroundImage" />
</div>
<div class="review-address" v-if="detail.merchantname">
<div class="navigation">
<div class="title">
<div class="title-l">活动举办方</div>
<div class="title-r">
<span>官方合作</span>
<span>品牌授权</span>
</div>
</div>
<div class="address">
<div class="info">
<div class="store">
{{ detail.merchantname }}
<div>
<div class="main-body" style="background: #DEEAF2;">
<template v-if="modelNum == 1">
<!-- 权益服务 -->
<equity-one :detail="detail"></equity-one>
<!-- 商品券 -->
<goods-one :detail="detail"></goods-one>
<!-- 服务券 -->
<coupon-one :detail="detail"></coupon-one>
</template>
<template v-if="modelNum == 2">
<!-- 权益服务 -->
<equity-two :detail="detail"></equity-two>
<!-- 商品券 -->
<goods-two :detail="detail"></goods-two>
<!-- 服务券 -->
<coupon-two :detail="detail"></coupon-two>
</template>
<template v-if="modelNum == 3">
<!-- 权益服务 -->
<equity-three :detail="detail"></equity-three>
<!-- 商品券 -->
<goods-three :detail="detail"></goods-three>
<!-- 服务券 -->
<coupon-three :detail="detail"></coupon-three>
</template>
<template v-if="modelNum == 4">
<!-- 权益服务 -->
<equity-four :detail="detail"></equity-four>
<!-- 商品券 -->
<goods-four :detail="detail"></goods-four>
<!-- 服务券 -->
<coupon-four :detail="detail"></coupon-four>
</template>
</div>
<div class="review-address" v-if="detail.merchantname">
<div class="navigation">
<div class="title">
<div class="title-l">活动举办方</div>
<div class="title-r">
<span>官方合作</span>
<span>品牌授权</span>
</div>
<div class="detail">
{{ detail.merchantAddress }}
</div>
<div class="address">
<div class="info">
<div class="store">
{{ detail.merchantname }}
</div>
<div class="detail">
{{ detail.merchantAddress }}
</div>
</div>
</div>
</div>
</div>
</div>
<div class="review-line" v-if="detail.serviceHotline">
<img src="https://img02.glsx.com.cn/weapp/resource/miniprogram/expandedGold/service.png" />
<span>服务热线</span>
<i class="el-icon-arrow-right"></i>
<div class="review-line" v-if="detail.serviceHotline">
<img src="https://img02.glsx.com.cn/weapp/resource/miniprogram/expandedGold/service.png" />
<span>服务热线</span>
<i class="el-icon-arrow-right"></i>
</div>
</div>
</div>
</div>
......@@ -165,6 +189,8 @@
</div>
</template>
<script>
const WIDTH = 244
const RATIO = RATIO / 375
import PhoneViewA from './PhoneViewA'
import draw from '@/mixins/draw'
import equityOne from './model/model_1/equity'
......@@ -180,14 +206,46 @@ import equityFour from './model/model_4/equity'
import goodsFour from './model/model_4/goods'
import couponFour from './model/model_4/coupon'
import { mapState } from 'vuex'
import VueDraggableResizable from '@/components/draggable/vue-draggable-resizable'
import '@/components/draggable/vue-draggable-resizable.css'
export default {
mixins: [draw],
data() {
return {
backgroundHeight: 0,
currentIndex: 0,
draggableList: [
{
type: 'text',
x: 0,
y: 0,
width: 40,
height: 20,
content: '默认',
remark: '文字',
size: 20,
color: '',
customId: '1'
},
{
type: 'text',
x: 0,
y: 0,
width: 40,
height: 20,
content: '默认',
remark: '文字',
size: 20,
color: '',
customId: '2'
}
],
isModel: true,
modelNum: 4,
activityInfo: {},
detail: {},
detail: {
backgroundImg: ''
},
logoInfo: {},
textList: [],
discount: {
......@@ -199,6 +257,7 @@ export default {
}
},
components: {
VueDraggableResizable,
PhoneViewA,
equityOne,
goodsOne,
......@@ -214,7 +273,7 @@ export default {
couponFour
},
computed: {
...mapState('marketing', ['packageList'])
...mapState('marketing', ['packageList', 'process'])
},
props: {
// activityInfo: {
......@@ -271,10 +330,54 @@ export default {
packageList: {
handler(val) {
console.log(val, 8888)
this.detail = val
this.detail = { ...this.detail, ...val }
},
deep: true,
immediate: true
},
process: {
async handler(val) {
this.detail = { ...this.detail, ...val[2] }
console.log(this.detail)
this.backgroundHeight = await this.getImgWH(this.detail.backgroundImage)
try {
const style1 = JSON.parse(this.detail.titleStyle)
const style2 = JSON.parse(this.detail.subTitleStyle)
Object.assign(this.draggableList[0], { content: this.detail.marketingTitle, ...style1, color: style1.style.color })
Object.assign(this.draggableList[1], { content: this.detail.marketingSubtitle, ...style1, color: style2.style.color })
} catch (e) {
console.log(e)
}
},
deep: true
}
},
methods: {
//获取图片宽度高度
getImgWH(src) {
return new Promise(resolve => {
const img = new Image()
img.src = src
img.onload = () => {
console.log(WIDTH, img.height, img.width)
resolve(Math.floor((WIDTH * img.height) / img.width))
}
})
},
onDrag(x, y) {
this.draggableList[this.currentIndex].x = x
this.draggableList[this.currentIndex].y = y
},
onActivated(index) {
const idx = this.draggableList.findIndex(item => item.customId == index)
this.currentIndex = idx
},
onResize(x, y, width, height) {
this.draggableList[this.currentIndex].x = x
this.draggableList[this.currentIndex].y = y
this.draggableList[this.currentIndex].width = width
this.draggableList[this.currentIndex].height = height
this.draggableList[this.currentIndex].size = height
}
}
}
......@@ -322,6 +425,12 @@ export default {
.review-main {
position: relative;
height: 300px;
.review-bg-img {
width: 100%;
img {
width: 100%;
}
}
.main-title {
position: absolute;
width: 100%;
......
......@@ -10,7 +10,7 @@
</div>
<div class="case-container">
<div class="case-container-title">预览营销方案</div>
<phoneView></phoneView>
<phoneView ref="viewForm"></phoneView>
</div>
</div>
</template>
......@@ -18,7 +18,9 @@
<script>
import { mapState } from 'vuex'
import phoneView from './PhoneView'
import draw from '@/mixins/draw'
export default {
mixins: [draw],
components: {
phoneView
},
......@@ -44,7 +46,13 @@ export default {
}
},
methods: {
handleSave() {
async handleSave() {
const {
backgroundHeight,
detail: { backgroundImage },
draggableList
} = this.$refs.viewForm
const url = await this.createMain(backgroundHeight, backgroundImage, draggableList)
let params = { merchantId: this.$globalState.session.merchantId }
for (let k in this.process) {
if (!this.process[k]) {
......@@ -53,6 +61,8 @@ export default {
}
params = { ...params, ...this.process[k] }
}
params.subscribe = this.subscribe
params.backgroundImage = url
this.loading = true
this.$apis.marketing
.createSuperMarketing(params)
......@@ -68,7 +78,7 @@ export default {
}
},
computed: {
...mapState('marketing', ['process'])
...mapState('marketing', ['process', 'subscribe'])
}
}
</script>
......
......@@ -4,7 +4,19 @@
<div class="choseRow">
<div class="choseItem" :class="{ active: currentIndex == item.type }" v-for="(item, index) in tabList" :key="index" @click="tabClick(item.type)">{{ item.label }}</div>
</div>
<div class="fes-box">
<div class="fes-item" v-for="item in festivalList" :key="item.id">{{ item.title }}</div>
<div class="fes-waiting">不断更新中……</div>
</div>
<div class="scene-content">
<!-- <div class="scene-card">
<div class="scene-card-img">
<img src="" />
</div>
<div class="scene-card-content">
请扫码添加【XXXX】小管家,并组群获得支持
</div>
</div> -->
<div class="scene-item" v-for="(item, index) in sceneList" :key="index">
<div class="scene-item-box">
<div class="scene-item-title">
......@@ -22,11 +34,18 @@
</template>
<script>
import { mapActions } from 'vuex'
import { mapActions, mapMutations, mapState } from 'vuex'
export default {
data() {
return {
tabList: [{ label: '保险', type: 5 }, { label: '定保', type: 2 }, { label: '节日关怀', type: 6 }, { label: '售后众筹' }],
routeInfo: {},
tabList: [
{ label: '保险', type: 5 },
{ label: '定保', type: 2 },
{ label: '节日关怀', type: 6 },
{ label: '售后众筹', type: 9 }
],
festivalList: [],
currentIndex: 5,
sceneList: [
{
......@@ -56,13 +75,41 @@ export default {
]
}
},
mounted() {
this.calendarPage()
this.routeInfo = this.$route.query
if (this.routeInfo.addOrEdit == 'edit') {
this.getInfo()
} else {
this.setSubscribe(this.routeInfo.subscribe)
}
},
computed: {
...mapState('marketing', ['subscribe'])
},
watch: {
subscribe(val) {
this.currentIndex = val
}
},
methods: {
...mapActions('marketing', ['setSubscribe']),
handleAdd() {},
...mapActions('marketing', ['setSubscribe', 'getActivityInfo']),
...mapMutations('marketing', ['SET_INIT']),
handleAdd() {
this.SET_INIT(true)
},
getInfo() {
this.getActivityInfo(this.routeInfo.id)
},
tabClick(index) {
this.currentIndex = index
console.log(index)
this.setSubscribe(index)
},
calendarPage() {
this.$apis.marketing.calendarPage({ pageSize: 100, pageNum: 1 }).then(res => {
this.festivalList = (res.data || []).filter(item => item.marketingType == 6)
})
}
}
}
......@@ -75,6 +122,29 @@ export default {
background: #fff;
padding: 16px;
display: flex;
position: relative;
.scene-card {
position: absolute;
width: 178px;
height: 169px;
background: #ffffff;
border: 1px solid #e5e5e5;
box-shadow: 0 4px 12px 0 #00000014;
top: -160px;
left: 16px;
padding: 10px;
&-img {
width: 82px;
height: 82px;
margin: 10px auto;
}
&-content {
font-size: 12px;
color: #666666;
text-align: center;
line-height: 18px;
}
}
.scene-item {
width: 16.7%;
display: flex;
......@@ -117,6 +187,28 @@ export default {
}
}
}
.fes-box {
display: flex;
height: 70px;
background: #ffffff;
border-radius: 0 4px 4px 4px;
padding: 20px;
box-sizing: border-box;
.fes-item {
padding: 0px 16px;
background: #f9f9f9;
height: 30px;
line-height: 30px;
font-size: 12px;
color: #666666;
margin-right: 10px;
}
.fes-waiting {
font-size: 12px;
color: #666666;
line-height: 30px;
}
}
.choseRow {
margin-top: 10px;
display: flex;
......
......@@ -16,6 +16,7 @@
</GLDialog>
</template>
<script>
import { mapActions } from 'vuex'
export default {
data() {
return {
......@@ -31,6 +32,7 @@ export default {
}
},
methods: {
...mapActions('marketing', ['getCalendarDetail']),
calendarPage() {
this.$apis.marketing.calendarPage({ pageSize: 100, pageNum: 1 }).then(res => {
this.modelList = (res.data || []).filter(item => item.marketingType == 5)
......@@ -38,7 +40,8 @@ export default {
})
},
handleConfirm() {
this.$emit('handleSure', this.selectObj)
this.getCalendarDetail(this.selectObj.id)
this.$emit('handleClose')
},
handleModelClose() {
this.$emit('handleClose')
......
<template>
<div class="wrap" v-if="serviceList.length>0">
<div class="wrap" v-if="serviceList.length > 0">
<div class="container-panel">
<img class="angle" src="https://img02.glsx.com.cn/weapp/resource/miniprogram/expandedGold/deliver.png?v=1.0.2" />
<div class="title">
......@@ -30,23 +30,24 @@ export default {
4: '兑换券',
7: '服务券'
},
serviceList:[]
serviceList: []
}
},
props: {
detail: {
type: Object,
default:()=> {}
default: () => {}
}
},
watch: {
detail: {
handler(n) {
const serviceList = n.selectedGoodsList
serviceList.length>0&&serviceList.forEach(item=>{
item.couponAnticipatedCost = (item.denomination/100).toFixed(2).replace(/\.[0]+$/,'')
})
this.serviceList =serviceList
const serviceList = n.selectedGoodsList || []
serviceList.length > 0 &&
serviceList.forEach(item => {
item.couponAnticipatedCost = (item.denomination / 100).toFixed(2).replace(/\.[0]+$/, '')
})
this.serviceList = serviceList
},
deep: true,
immediate: true
......@@ -99,7 +100,7 @@ export default {
background-image: linear-gradient(-83deg, #fe6a7545 0%, #fcf0ee00 96%);
border-radius: 10px;
margin-top: 10px;
padding:8px;
padding: 8px;
box-sizing: border-box;
&:last-child {
......
<template>
<div class="wrap" v-if="serviceList.length>0">
<div class="wrap" v-if="serviceList.length > 0">
<div class="container-panel">
<img class="header-panel" src="https://img02.glsx.com.cn/weapp/resource/miniprogram/expandedGold/model_4/delivery.png" />
<div class="service-item" v-for="(item, index) in serviceList" :key="index">
<div class="service-logo"> </div>
<div class="service-desc">
<div class="service-title">{{item.brandName}}{{item.goodsName}}</div>
<div class="service-content">x{{item.couponAmount}} 抵扣券</div>
</div>
<div class="service-price">{{item.couponAnticipatedCost}}<span>元</span> </div>
<div class="service-item" v-for="(item, index) in serviceList" :key="index">
<div class="service-logo"></div>
<div class="service-desc">
<div class="service-title">{{ item.brandName }}{{ item.goodsName }}</div>
<div class="service-content">x{{ item.couponAmount }} 抵扣券</div>
</div>
<div class="service-price">
{{ item.couponAnticipatedCost }}
<span>元</span>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
......@@ -23,23 +26,24 @@ export default {
4: '兑换券',
7: '服务券'
},
serviceList:[]
serviceList: []
}
},
props: {
detail: {
type: Object,
default:()=> {}
default: () => {}
}
},
watch: {
detail: {
handler(n) {
const serviceList = n.selectedGoodsList
serviceList.length>0&&serviceList.forEach(item=>{
item.couponAnticipatedCost = (item.denomination/100).toFixed(2).replace(/\.[0]+$/,'')
})
this.serviceList =serviceList
const serviceList = n.selectedGoodsList || []
serviceList.length > 0 &&
serviceList.forEach(item => {
item.couponAnticipatedCost = (item.denomination / 100).toFixed(2).replace(/\.[0]+$/, '')
})
this.serviceList = serviceList
},
deep: true,
immediate: true
......
......@@ -44,7 +44,7 @@ export default {
watch: {
detail: {
handler(n) {
const serviceList = n.selectedGoodsList
const serviceList = n.selectedGoodsList || []
serviceList.length > 0 &&
serviceList.forEach(item => {
item.couponAnticipatedCost = (item.denomination / 100).toFixed(2).replace(/\.[0]+$/, '')
......
<template>
<div class="wrap" v-if="serviceList.length>0">
<div class="wrap" v-if="serviceList && serviceList.length > 0">
<div class="container-panel">
<img class="header-panel" src="https://img02.glsx.com.cn/weapp/resource/miniprogram/expandedGold/model_8/rob.png" />
<div class="service-item" v-for="(item, index) in serviceList" :key="index">
......@@ -16,20 +16,20 @@
export default {
data() {
return {
serviceList:[]
serviceList: []
}
},
props: {
detail: {
type: Object,
default:()=> {}
default: () => {}
}
},
watch: {
detail: {
handler(n) {
const serviceList = n.selectedCarList
this.serviceList =serviceList
this.serviceList = serviceList
},
deep: true,
immediate: true
......@@ -82,7 +82,7 @@ export default {
text-align: center;
font-size: 16px;
color: #fe455d;
width:63px;
width: 63px;
span {
font-size: 12px;
......
<template>
<div class="wrap" v-if="serviceList.length>0">
<div class="wrap" v-if="serviceList.length > 0">
<div class="container-panel">
<img class="header-panel" src="https://img02.glsx.com.cn/weapp/resource/miniprogram/expandedGold/model_8/deliver.png" />
<div class="service-item" v-for="(item, index) in serviceList" :key="index">
......@@ -38,7 +38,7 @@ export default {
watch: {
detail: {
handler(n) {
const serviceList = n.selectedGoodsList
const serviceList = n.selectedGoodsList || []
serviceList.length > 0 &&
serviceList.forEach(item => {
item.couponAnticipatedCost = (item.denomination / 100).toFixed(2).replace(/\.[0]+$/, '')
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!