Commit 4f5f1b64 authored by gengshaojing's avatar gengshaojing

fix: 合并hotfix

parents 354158d0 c9861793
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -16,6 +16,8 @@
<% for (let i in htmlWebpackPlugin.options.cdn && htmlWebpackPlugin.options.cdn.js) { %>
<script src="<%= htmlWebpackPlugin.options.cdn.js[i] %>"></script>
<% } %>
<script src="//webapi.amap.com/maps?v=1.3&key=bb057625545d8cf77df1379e7aaae0b5"></script>
<script src="//webapi.amap.com/ui/1.0/main.js"></script>
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
......
const fs = require("fs");
const API_INTERNAL_URI = require("../config.js").API_INTERNAL_URI;
const reqOther = require("../utils/request").httpReqOther;
const FormData = require("form-data");
const http = require("http");
const GROUPMEAL_URI = require("../config.js").GROUPMEAL_URI;
exports.uploadPic = async (ctx, next) => {
const url = `${API_INTERNAL_URI}/ksy/ks3apiunencrypt/ks3api_upload`;
const {
body: { type },
files,
} = ctx.request;
console.log("type", type);
const filePath = files.file.path;
const file = fs.createReadStream(filePath);
const form = new FormData();
form.append("file", file);
form.append("type", type);
const opts = {
method: "post",
url: url,
body: form,
headers: form.getHeaders(),
};
ctx.body = await reqOther(opts);
};
exports.oldOrderExport = async (ctx) => {
const { marketing_id, type } = ctx.query;
// `${ENV}order/oldbackground/order_export?marketing_id=${eventId}&type=${type}`;
const url = `${GROUPMEAL_URI}/order/oldbackground/order_export?marketing_id=${marketing_id}&type=${type}`;
console.log("url", url);
const options = new URL(url);
let { buffer, res } = await requestPromise(options);
const fileName = res.headers["content-disposition"].split("=")[1];
ctx.set("Content-Type", "application/octet-stream");
ctx.set("Content-Disposition", `attachment; filename=${fileName}`);
ctx.body = buffer;
};
exports.orderExport = async (ctx) => {
const { marketing_id, type } = ctx.query;
const url = `${GROUPMEAL_URI}/order/background/order_export?marketing_id=${marketing_id}&type=${type}`;
console.log("url", url);
const options = new URL(url);
let { buffer, res } = await requestPromise(options);
const fileName = res.headers["content-disposition"].split("=")[1];
ctx.set("Content-Type", "application/octet-stream");
ctx.set("Content-Disposition", `attachment; filename=${fileName}`);
ctx.body = buffer;
};
function requestPromise(options) {
return new Promise(function (resolve, reject) {
const req = http.request(options, function (res) {
let { statusCode } = res;
//返回不是200
if (statusCode !== 200) {
return reject(new Error("error"));
}
let arr = [];
let len = 0;
res.on("data", (chunk) => {
len += chunk.length;
arr.push(Buffer.from(chunk));
});
res.on("end", () => {
//正确 success
return resolve({
buffer: Buffer.concat(arr, len),
res,
});
});
});
//请求出错
req.on("error", (err) => {
return reject(err);
});
req.end();
});
}
......@@ -10,6 +10,7 @@ const activity = require("./controllers/activity");
const withdrawal = require("./controllers/withdrawal");
const groupmeal = require("./controllers/groupmeal");
const qr_code = require("./controllers/qr-code");
const relay = require("./controllers/relay");
const router = Router();
const API_VERSION = "/api/v1";
......@@ -130,4 +131,9 @@ router.post(`${API_VERSION}/get_reblack_list`, withdrawal.getReblackList);
router.get(`${API_VERSION}/get_wallet_account_status`, withdrawal.getWalletAccountStatus);
router.post(`${API_VERSION}/reset_wallet_account_status`, withdrawal.resetAccountStatus);
// 图片上传
router.post(`${API_VERSION}/relay/ks3api_upload`, relay.uploadPic);
router.get(`${API_VERSION}/relay/order_export`, relay.orderExport);
router.get(`${API_VERSION}/relay/old_order_export`, relay.oldOrderExport);
module.exports = router;
const request = require("request");
exports.httpReq = (ctx, opts) => {
opts.timeout = opts.timeout || 10000;
return new Promise((resolve, reject) => {
var time_start = +new Date();
opts.timeout = opts.timeout || 10000;
return new Promise((resolve, reject) => {
var time_start = +new Date();
const defaultQs = {
appid: "merchant-op",
cv: "1.0.0",
version: "999999",
distribution: "op",
net: "wifi",
platform: "2"
};
const defaultQs = {
appid: "merchant-op",
cv: "1.0.0",
version: "999999",
distribution: "op",
net: "wifi",
platform: "2",
};
opts.qs = { ...defaultQs, ...ctx.request.query, ...opts.qs };
opts.qs = { ...defaultQs, ...ctx.request.query, ...opts.qs };
request(opts, (err, res, body) => {
console.info(
`[Api] httpReq (${opts.url}, user:[${
opts.qs.op_cur_user
}]) spent: ${+new Date() - time_start}ms`
);
request(opts, (err, res, body) => {
console.info(`[Api] httpReq (${opts.url}, user:[${opts.qs.op_cur_user}]) spent: ${+new Date() - time_start}ms`);
if (!err) {
resolve(body);
} else {
reject(err);
console.error(opts.url, err);
}
if (!err) {
resolve(body);
} else {
reject(err);
console.error(opts.url, err);
}
});
});
};
exports.httpReqOther = (opts) => {
opts.timeout = opts.timeout || 10000;
return new Promise((resolve, reject) => {
request(opts, (err, res, body) => {
if (!err) {
resolve(body);
} else {
reject(err);
console.error(opts.url, err);
}
});
});
});
};
<template>
<div
class="wrapper"
v-loading="pageLoading"
element-loading-text="拼命加载中"
element-loading-spinner="el-icon-loading"
element-loading-background="rgba(0, 0, 0, 0.8)"
>
<!-- 商品详情信息 -->
<div class="activityInfo-wrapper">
<el-card class="activityInfo">
<div class="infoItem">
<p class="infoItemText">{{ detailInfo.sumOrder }}</p>
<p>订单数量</p>
<div
class="wrapper"
v-loading="pageLoading"
element-loading-text="拼命加载中"
element-loading-spinner="el-icon-loading"
element-loading-background="rgba(0, 0, 0, 0.8)"
>
<!-- 商品详情信息 -->
<div class="activityInfo-wrapper">
<el-card class="activityInfo">
<div class="infoItem">
<p class="infoItemText">{{ detailInfo.sumOrder }}</p>
<p>订单数量</p>
</div>
<div class="infoItem">
<p class="infoItemText">{{ detailInfo.sumGoods }}</p>
<p>已售商品数量</p>
</div>
<div class="infoItem">
<p class="infoItemText">{{ detailInfo.payAmount }}</p>
<p>支付金额</p>
</div>
<div class="infoItem">
<p class="infoItemText">{{ detailInfo.sumCouponAmount }}</p>
<p>优惠金额</p>
</div>
<div class="infoItem">
<p class="infoItemText">{{ detailInfo.refundAmount }}</p>
<p>退款</p>
</div>
<div class="infoItem">
<p class="infoItemText">{{ detailInfo.income }}</p>
<p>实际收入</p>
</div>
</el-card>
</div>
<div class="infoItem">
<p class="infoItemText">{{ detailInfo.sumGoods }}</p>
<p>已售商品数量</p>
</div>
<div class="infoItem">
<p class="infoItemText">{{ detailInfo.payAmount }}</p>
<p>支付金额</p>
</div>
<div class="infoItem">
<p class="infoItemText">{{ detailInfo.sumCouponAmount }}</p>
<p>优惠金额</p>
</div>
<div class="infoItem">
<p class="infoItemText">{{ detailInfo.refundAmount }}</p>
<p>退款</p>
</div>
<div class="infoItem">
<p class="infoItemText">{{ detailInfo.income }}</p>
<p>实际收入</p>
</div>
</el-card>
</div>
<!-- 商品详情 -->
<div class="activityDetail">
<section class="content">
<!-- 商品列表 -->
<el-card class="activityGoods box-card">
<div class="my-header">
<h3>{{ marketingInfo.marketing_name }}</h3>
<!-- 查看参与字段待确认 -->
<p>
<span>{{ detailInfo.lookUserCount }}人查看</span><span
>{{ detailInfo.haveBuyGoodsUserCount }}人参与</span
>
</p>
<p class="endTime">{{ showTimer }}</p>
</div>
<!-- <p class="title">拼单商品</p> -->
<!-- <div class="images-wrapper">
<!-- 商品详情 -->
<div class="activityDetail">
<section class="content">
<!-- 商品列表 -->
<el-card class="activityGoods box-card">
<div class="my-header">
<h3>{{ marketingInfo.marketing_name }}</h3>
<!-- 查看参与字段待确认 -->
<p>
<span>{{ detailInfo.lookUserCount }}人查看</span>
<span>{{ detailInfo.haveBuyGoodsUserCount }}人参与</span>
</p>
<p class="endTime">{{ showTimer }}</p>
</div>
<!-- <p class="title">拼单商品</p> -->
<!-- <div class="images-wrapper">
<div
class="image-block"
v-for="picItem in goodsList"
......@@ -66,263 +66,235 @@
<span class="goodsPrice">{{ `¥${picItem.price}` }}</span>
</div>
</div> -->
</el-card>
<!-- 商品描述 -->
<el-card class="activityIntroduce box-card">
<p class="introduceText">
{{ marketingInfo.pindan_desc }}
</p>
<el-image
v-for="(picItem, index) in marketingInfo.pindan_pic_url"
:key="index"
class="activityImage"
style="width: 100%; height: 400px"
:src="picItem"
fit="contain"
></el-image>
</el-card>
<el-card class="activities box-card">
<div
v-for="goodsItem in goodsList"
:key="goodsItem.goods_sku_id"
class="activityItem"
>
<el-image
class="activityImage"
style="width: 100px; height: 100px"
:src="goodsItem.desc_pic_url_list[0]"
fit="fit"
></el-image>
<div class="itemIntroduce">
<p>{{ goodsItem.goods_name }}</p>
<p class="price">
<span class="nowPrice">{{ `¥${goodsItem.price}` }}</span>
<span class="originPrice">{{
`¥${goodsItem.original_price} `
}}</span>
<span class="sold" v-if="goodsItem.inventory_rest == 0"
>抢光了</span
>
<span class="sold" v-else
>已售{{ goodsItem.all_have_buy_goods_count }}</span
>
</p>
</div>
</div>
</el-card>
</section>
</div>
<div class="button-close">
<el-button
class="button-block"
size="medium"
type="primary"
@click="closePage"
> </el-button
>
</el-card>
<!-- 商品描述 -->
<el-card class="activityIntroduce box-card">
<p class="introduceText">
{{ marketingInfo.pindan_desc }}
</p>
<el-image
v-for="(picItem, index) in marketingInfo.pindan_pic_url"
:key="index"
class="activityImage"
style="width: 100%; height: 400px"
:src="picItem"
fit="contain"
></el-image>
</el-card>
<el-card class="activities box-card">
<div v-for="goodsItem in goodsList" :key="goodsItem.goods_sku_id" class="activityItem">
<el-image
class="activityImage"
style="width: 100px; height: 100px"
:src="goodsItem.desc_pic_url_list[0]"
fit="fit"
></el-image>
<div class="itemIntroduce">
<p>{{ goodsItem.goods_name }}</p>
<p class="price">
<span class="nowPrice">{{ `¥${goodsItem.price}` }}</span>
<span class="originPrice">{{ `¥${goodsItem.original_price} ` }}</span>
<span class="sold">已售{{ goodsItem.all_have_buy_goods_count }}</span>
</p>
</div>
</div>
</el-card>
</section>
</div>
<div class="button-close">
<el-button class="button-block" size="medium" type="primary" @click="closePage"> </el-button>
</div>
</div>
</div>
</template>
<script>
import ActivityService from "@/service/Activity/index";
import { ElMessage } from "element-plus";
import dayJs from "dayjs";
import ActivityService from "@/service/Activity/index";
import { ElMessage } from "element-plus";
import dayJs from "dayjs";
export default {
props: {},
data() {
return {
pageLoading: false,
goodsList: [],
marketingInfo: {},
endTime: "",
showTimer: "",
detailInfo: {}
};
},
watch: {},
computed: {},
methods: {
async checkActivityDetail() {
try {
this.pageLoading = true;
let dataArr = await Promise.all([
ActivityService.checkActivityDetail({
marketing_id: this.$route.query.marketing_id,
marketing_type: this.$route.query.marketing_type
}),
ActivityService.checkActivityDetailInfo({
marketing_id: this.$route.query.marketing_id
})
]);
this.pageLoading = false;
this.goodsList = dataArr[0].result.goods_list;
this.marketingInfo = dataArr[0].result.marketing_info;
this.endTime = dataArr[0].result.marketing_info.end_time;
this.detailInfo = dataArr[1].result;
} catch {
this.pageLoading = false;
ElMessage.error("加载失败");
}
},
export default {
props: {},
data() {
return {
pageLoading: false,
goodsList: [],
marketingInfo: {},
endTime: "",
showTimer: "",
detailInfo: {},
};
},
watch: {},
computed: {},
methods: {
async checkActivityDetail() {
try {
this.pageLoading = true;
let dataArr = await Promise.all([
ActivityService.checkActivityDetail({
marketing_id: this.$route.query.marketing_id,
marketing_type: this.$route.query.marketing_type,
}),
ActivityService.checkActivityDetailInfo({
marketing_id: this.$route.query.marketing_id,
}),
]);
this.pageLoading = false;
this.goodsList = dataArr[0].result.goods_list;
this.marketingInfo = dataArr[0].result.marketing_info;
this.endTime = dataArr[0].result.marketing_info.end_time;
this.detailInfo = dataArr[1].result;
} catch {
this.pageLoading = false;
ElMessage.error("加载失败");
}
},
// 时间差转时分秒
getTimeout(timeCount) {
if (timeCount > 0) {
var days = parseInt(timeCount / (1000 * 60 * 60 * 24));
var hours = parseInt(
(timeCount % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)
);
var minutes = parseInt((timeCount % (1000 * 60 * 60)) / (1000 * 60));
var seconds = parseInt((timeCount % (1000 * 60)) / 1000);
this.showTimer =
"距结束:" +
days +
" 天 " +
hours +
" 小时 " +
minutes +
" 分钟 " +
seconds +
" 秒 ";
} else {
this.showTimer = "已结束";
}
},
// 时间差转时分秒
getTimeout(timeCount) {
if (timeCount > 0) {
var days = parseInt(timeCount / (1000 * 60 * 60 * 24));
var hours = parseInt((timeCount % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = parseInt((timeCount % (1000 * 60 * 60)) / (1000 * 60));
var seconds = parseInt((timeCount % (1000 * 60)) / 1000);
this.showTimer = "距结束:" + days + " 天 " + hours + " 小时 " + minutes + " 分钟 " + seconds + " 秒 ";
} else {
this.showTimer = "已结束";
}
},
// 定时器
myTimer() {
let dateNow = dayJs();
this.timer = setInterval(() => {
dateNow = dayJs().subtract(1, "minute");
let myTime = dayJs(this.endTime).diff(dateNow); // 时间差
this.getTimeout(myTime);
if (this.myTime <= 0) {
clearInterval(this.timer);
}
}, 1000);
},
// 定时器
myTimer() {
let dateNow = dayJs();
this.timer = setInterval(() => {
dateNow = dayJs().subtract(1, "minute");
let myTime = dayJs(this.endTime).diff(dateNow); // 时间差
this.getTimeout(myTime);
if (this.myTime <= 0) {
clearInterval(this.timer);
}
}, 1000);
},
closePage() {
this.$router.go(-1);
}
},
async created() {
await this.checkActivityDetail();
this.myTimer();
},
beforeUnmount() {
clearInterval(this.timer);
}
};
closePage() {
this.$router.go(-1);
},
},
async created() {
await this.checkActivityDetail();
this.myTimer();
},
beforeUnmount() {
clearInterval(this.timer);
},
};
</script>
<style lang="less" scoped>
.wrapper {
height: 100%;
display: flex;
overflow-y: scroll;
flex-direction: column;
justify-content: flex-start;
align-items: center;
padding: 45px 10px 0;
.activityInfo {
width: 500px;
/deep/ .el-card__body {
width: 100%;
display: flex;
flex-wrap: wrap;
}
.infoItem {
width: 33%;
text-align: center;
margin-bottom: 20px;
.infoItemText {
font-weight: bolder;
}
}
}
.activityDetail {
width: 500px;
.content {
.my-header {
.endTime {
margin: 5px 0;
font-size: 15px;
color: red;
}
}
.box-card {
margin: 10px 0;
}
.activityGoods {
.images-wrapper {
display: flex;
flex-wrap: wrap;
.image-block {
margin: 0 5px 0 0px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.goodsPrice {
color: red;
font-size: 18px;
.wrapper {
height: 100%;
display: flex;
overflow-y: scroll;
flex-direction: column;
justify-content: flex-start;
align-items: center;
padding: 45px 10px 0;
.activityInfo {
width: 500px;
/deep/ .el-card__body {
width: 100%;
display: flex;
flex-wrap: wrap;
}
.infoItem {
width: 33%;
text-align: center;
margin-bottom: 20px;
.infoItemText {
font-weight: bolder;
}
}
}
.image-block:nth-child(4n + 0) {
margin-right: 0;
}
}
.activityImage {
margin: 10px 10px 0 0;
}
}
.activityIntroduce {
padding: 5px 0;
.introduceText {
margin-bottom: 20px;
}
}
.activities {
.activityItem {
display: flex;
margin: 15px 0;
.itemIntroduce {
position: relative;
display: flex;
width: 100%;
flex-direction: column;
justify-content: space-around;
margin-left: 10px;
> p {
width: 200px;
.activityDetail {
width: 500px;
.content {
.my-header {
.endTime {
margin: 5px 0;
font-size: 15px;
color: red;
}
}
.box-card {
margin: 10px 0;
}
.activityGoods {
.images-wrapper {
display: flex;
flex-wrap: wrap;
.image-block {
margin: 0 5px 0 0px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.goodsPrice {
color: red;
font-size: 18px;
}
}
.image-block:nth-child(4n + 0) {
margin-right: 0;
}
}
.activityImage {
margin: 10px 10px 0 0;
}
}
.activityIntroduce {
padding: 5px 0;
.introduceText {
margin-bottom: 20px;
}
}
.activities {
.activityItem {
display: flex;
margin: 15px 0;
.itemIntroduce {
position: relative;
display: flex;
width: 100%;
flex-direction: column;
justify-content: space-around;
margin-left: 10px;
> p {
width: 200px;
}
.price {
.nowPrice {
color: red;
padding-right: 10px;
}
.originPrice {
text-decoration: line-through;
}
}
}
.sold {
position: absolute;
right: 20px;
color: #d44549;
font-weight: 500;
}
}
}
}
.price {
.nowPrice {
color: red;
padding-right: 10px;
}
.originPrice {
text-decoration: line-through;
}
}
.button-close {
margin: 10px 0 30px;
.button-block {
width: 200px;
}
}
.sold {
position: absolute;
right: 20px;
color: #d44549;
font-weight: 500;
}
}
}
}
}
.button-close {
margin: 10px 0 30px;
.button-block {
width: 200px;
}
}
}
</style>
<template>
<div class="addProduc">
<!-- 按钮组 -->
<div class="btnGroup">
<el-button class="addCommodityBtn" @click="commodity('add', '')"
>添加商品</el-button
>
<!-- <el-button class="commodLibraryAdd" @click="commodLibraryAdd"
<div class="addProduc">
<!-- 按钮组 -->
<div class="btnGroup">
<el-button class="addCommodityBtn" @click="commodity('add', '')">添加商品</el-button>
<!-- <el-button class="commodLibraryAdd" @click="commodLibraryAdd"
>从商品库添加</el-button
> -->
</div>
<!-- Tab -->
<el-table
:data="comTableData"
border
style="width: 100%;margin-bottom:80px;"
:header-cell-style="cellClass"
>
<el-table-column label="显示顺序" align="center" width="50px">
<el-table-column label="" align="center" width="50px">
<template #default="scope">
<i
class="el-icon-top"
@click="upMove(scope.$index, scope.row)"
style="margin-right:15px;"
></i>
</template>
</el-table-column>
<el-table-column label="" align="center" width="50px">
<template #default="scope">
<i
class="el-icon-bottom"
@click="upDown(scope.$index, scope.row)"
></i>
</template>
</el-table-column>
</el-table-column>
<el-table-column
prop="goods_sku_id"
label="商品ID"
width="180"
></el-table-column>
<el-table-column
prop="goods_name"
label="商品标题"
width="180"
></el-table-column>
<el-table-column prop="price" label="售价"> </el-table-column>
<el-table-column prop="ota_name" label="商家"> </el-table-column>
<el-table-column prop="inventory_total" label="库存"> </el-table-column>
<el-table-column prop="total_amount_sold" label="已售数量">
</el-table-column>
<el-table-column prop="inventory_rest" label="剩余库存"></el-table-column>
<el-table-column label="操作" width="120" fixed="right">
<template #default="scope">
<div class="buttons_actions">
<el-button
type="text"
size="small"
@click="commodity('update', scope.row)"
>修改</el-button
>
<el-button type="text" size="small" @click="removeCom(scope.row)"
>移除</el-button
>
</div>
</template>
</el-table-column>
</el-table>
<!-- 添加商品 -->
<el-dialog
:title="addCommodityTitle"
v-model="addCommodityPopup"
width="50%"
custom-class="add_goods_dialog"
>
<el-form
:inline="true"
:model="commodityForm"
ref="infoForm"
class="demo-form-inline infoForm"
label-width="100px"
>
<el-form-item label="图片:">
<el-upload
:class="{ hide: hideUpload }"
:data="{ type: 1 }"
:action="uploadUrl"
:on-preview="previewImage"
:on-success="handleDetailSuccess"
:on-change="handleDetailChange"
:before-remove="removeDetailFiles"
:file-list="picUrlList"
auto-upload
ref="picUpload"
:limit="limitCount"
list-type="picture-card"
multiple
>
<template #default>
<i class="el-icon-plus"></i>
</template>
</el-upload>
</el-form-item>
<el-form-item
label="商品标题:"
prop="goods_name"
style="width:90%;"
:rules="[{ required: true, message: '请输入商品标题' }]"
>
<el-input
v-model="commodityForm.goods_name"
maxlength="30"
></el-input>
</el-form-item>
<el-form-item
label="售价:"
prop="price"
:rules="[{ required: true, message: '请输入售价' }]"
>
<el-input-number
class="price"
v-model="commodityForm.price"
:min="0"
:controls="false"
:precision="2"
placeholder=""
></el-input-number>
</el-form-item>
<el-form-item label="划线价:" prop="original_price">
<el-input-number
v-model="commodityForm.original_price"
class="price"
:min="0"
:controls="false"
:precision="2"
placeholder=""
></el-input-number>
</el-form-item>
<br />
<el-form-item
label="库存:"
prop="inventory_total"
:rules="[{ required: true, message: '请输入库存' }]"
>
<el-input
v-model="commodityForm.inventory_total"
placeholder=""
@input="inventoryIpt"
:rules="[{ required: true, message: '请输入库存' }]"
></el-input>
</el-form-item>
<div style="display: inline-block; height: 42px; margin-left: 33px">
已售:<span style="margin-right: 10px">{{
commodityForm.total_amount_sold
}}</span>
<!-- 剩余库存:<span>{{ commodityForm.inventory_total }}</span> -->
</div>
<el-form-item
prop="checkedRadio"
:rules="[
{
required: true,
message: '请选择购买限制',
trigger: 'change'
}
]"
class="limit_radio"
label="购买限制"
>
<el-radio-group v-model="commodityForm.checkedRadio">
<el-radio label="不限制"></el-radio>
<el-radio label="每人最多买"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
prop="num_limit"
:show-message="
commodityForm.checkedRadio === '每人最多买' ? true : false
"
:rules="[
{
validator:
commodityForm.checkedRadio === '每人最多买'
? checkPurseLimit
: checkPurseLimitNull,
trigger: 'blur'
}
]"
>
<el-input
v-model="commodityForm.num_limit"
:disabled="
commodityForm.checkedRadio === '' ||
commodityForm.checkedRadio === '不限制' ||
commodityForm.checkedRadio === undefined
? true
: false
"
:min="0"
:controls="false"
></el-input>
</el-form-item>
<el-form-item
label="商家:"
prop="business1"
:rules="[{ required: true, message: '请选择商家' }]"
>
<el-select v-model="commodityForm.business1" placeholder="请选择">
<el-option
v-for="item in businessOpt"
:key="item.ota_id"
:label="item.ota_name"
:value="item.ota_id"
></el-option>
</el-select>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="commodityCancel">取 消</el-button>
<el-button type="primary" @click="commoditySave('infoForm')"
>保存</el-button
>
</span>
</template>
</el-dialog>
<!-- 展示缩略图 -->
<el-dialog width="40%" v-model="isShowPopver">
<el-image :src="popoverImage" fit="fill" style="width: 100%"></el-image>
</el-dialog>
<!-- 从商品库添加 -->
<el-dialog
title="选择商品"
v-model="selCommodityPopup"
width="80%"
top="2%"
>
<div>
<span>商家:</span>
<el-select
v-model="business2"
placeholder="请选择"
@change="business2Sel"
>
<el-option
v-for="item in businessOpt"
:key="item.ota_id"
:label="item.ota_name"
:value="item.ota_id"
></el-option>
</el-select>
</div>
<span class="dioFor">已选:{{ multipleSelection.length }}件</span>
<el-table
:data="comLibTableData"
class="comLibTableData"
@selection-change="selectGoodsChange"
>
<el-table-column type="selection" width="55"> </el-table-column>
<el-table-column
prop="goods_sku_id"
label="商品ID"
width="150"
></el-table-column>
<el-table-column
prop="goods_name"
label="名称"
width="200"
></el-table-column>
<el-table-column prop="price" label="售价"></el-table-column>
<el-table-column prop="ota_name" label="商家"></el-table-column>
<el-table-column prop="inventory_total" label="库存"></el-table-column>
<el-table-column
prop="total_amount_sold"
label="已售数量"
></el-table-column>
<el-table-column
prop="inventory_rest"
label="剩余库存"
></el-table-column>
<el-table-column label="操作" fixed="right">
<template #default="scope">
<el-button
@click="commodity('update', scope.row)"
type="text"
size="small"
>修改</el-button
>
</template>
</el-table-column>
</el-table>
<template #footer>
<span class="dialog-footer">
<el-button @click="selCommodityPopup = false">取 消</el-button>
<el-button type="primary" @click="comLibrarySave">保存</el-button>
</span>
</template>
</el-dialog>
</div>
<!-- Tab -->
<el-table :data="comTableData" border style="width: 100%; margin-bottom: 80px" :header-cell-style="cellClass">
<el-table-column label="显示顺序" align="center" width="50px">
<el-table-column label="" align="center" width="50px">
<template #default="scope">
<i class="el-icon-top" @click="upMove(scope.$index, scope.row)" style="margin-right: 15px"></i>
</template>
</el-table-column>
<el-table-column label="" align="center" width="50px">
<template #default="scope">
<i class="el-icon-bottom" @click="upDown(scope.$index, scope.row)"></i>
</template>
</el-table-column>
</el-table-column>
<el-table-column prop="goods_sku_id" label="商品ID" width="180"></el-table-column>
<el-table-column prop="goods_name" label="商品标题" width="180"></el-table-column>
<el-table-column prop="price" label="售价"></el-table-column>
<el-table-column prop="ota_name" label="商家"></el-table-column>
<el-table-column prop="inventory_total" label="库存"></el-table-column>
<el-table-column prop="total_amount_sold" label="已售数量"></el-table-column>
<el-table-column prop="inventory_rest" label="剩余库存"></el-table-column>
<el-table-column label="操作" width="120" fixed="right">
<template #default="scope">
<div class="buttons_actions">
<el-button type="text" size="small" @click="commodity('update', scope.row)">修改</el-button>
<el-button type="text" size="small" @click="removeCom(scope.row)">移除</el-button>
</div>
</template>
</el-table-column>
</el-table>
<!-- 添加商品 -->
<el-dialog :title="addCommodityTitle" v-model="addCommodityPopup" width="50%" custom-class="add_goods_dialog">
<el-form :inline="true" :model="commodityForm" ref="infoForm" class="demo-form-inline infoForm" label-width="100px">
<el-form-item label="图片:">
<el-upload
:class="{ hide: hideUpload }"
:data="{ type: 1 }"
:action="uploadUrl"
:on-preview="previewImage"
:on-success="handleDetailSuccess"
:on-change="handleDetailChange"
:before-remove="removeDetailFiles"
:file-list="picUrlList"
auto-upload
ref="picUpload"
:limit="limitCount"
list-type="picture-card"
multiple
>
<template #default>
<i class="el-icon-plus"></i>
</template>
</el-upload>
</el-form-item>
<el-form-item label="商品标题:" prop="goods_name" style="width: 90%" :rules="[{ required: true, message: '请输入商品标题' }]">
<el-input v-model="commodityForm.goods_name" maxlength="30"></el-input>
</el-form-item>
<el-form-item label="售价:" prop="price" :rules="[{ required: true, message: '请输入售价' }]">
<el-input-number
class="price"
v-model="commodityForm.price"
:min="0"
:controls="false"
:precision="2"
placeholder=""
></el-input-number>
</el-form-item>
<el-form-item label="划线价:" prop="original_price">
<el-input-number
v-model="commodityForm.original_price"
class="price"
:min="0"
:controls="false"
:precision="2"
placeholder=""
></el-input-number>
</el-form-item>
<br />
<el-form-item label="库存:" prop="inventory_total" :rules="[{ required: true, message: '请输入库存' }]">
<el-input
v-model="commodityForm.inventory_total"
placeholder=""
@input="inventoryIpt"
:rules="[{ required: true, message: '请输入库存' }]"
></el-input>
</el-form-item>
<div style="display: inline-block; height: 42px; margin-left: 33px">
已售:
<span style="margin-right: 10px">{{ commodityForm.total_amount_sold }}</span>
<!-- 剩余库存:<span>{{ commodityForm.inventory_total }}</span> -->
</div>
<el-form-item
prop="checkedRadio"
:rules="[
{
required: true,
message: '请选择购买限制',
trigger: 'change',
},
]"
class="limit_radio"
label="购买限制"
>
<el-radio-group v-model="commodityForm.checkedRadio">
<el-radio label="不限制"></el-radio>
<el-radio label="每人最多买"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
prop="num_limit"
:show-message="commodityForm.checkedRadio === '每人最多买' ? true : false"
:rules="[
{
validator: commodityForm.checkedRadio === '每人最多买' ? checkPurseLimit : checkPurseLimitNull,
trigger: 'blur',
},
]"
>
<el-input
v-model="commodityForm.num_limit"
:disabled="
commodityForm.checkedRadio === '' || commodityForm.checkedRadio === '不限制' || commodityForm.checkedRadio === undefined
? true
: false
"
:min="0"
:controls="false"
></el-input>
</el-form-item>
<el-form-item label="商家:" prop="business1" :rules="[{ required: true, message: '请选择商家' }]">
<el-select v-model="commodityForm.business1" placeholder="请选择">
<el-option v-for="item in businessOpt" :key="item.ota_id" :label="item.ota_name" :value="item.ota_id"></el-option>
</el-select>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="commodityCancel">取 消</el-button>
<el-button type="primary" @click="commoditySave('infoForm')">保存</el-button>
</span>
</template>
</el-dialog>
<!-- 展示缩略图 -->
<el-dialog width="40%" v-model="isShowPopver">
<el-image :src="popoverImage" fit="fill" style="width: 100%"></el-image>
</el-dialog>
<!-- 从商品库添加 -->
<el-dialog title="选择商品" v-model="selCommodityPopup" width="80%" top="2%">
<div>
<span>商家:</span>
<el-select v-model="business2" placeholder="请选择" @change="business2Sel">
<el-option v-for="item in businessOpt" :key="item.ota_id" :label="item.ota_name" :value="item.ota_id"></el-option>
</el-select>
</div>
<span class="dioFor">已选:{{ multipleSelection.length }}件</span>
<el-table :data="comLibTableData" class="comLibTableData" @selection-change="selectGoodsChange">
<el-table-column type="selection" width="55"></el-table-column>
<el-table-column prop="goods_sku_id" label="商品ID" width="150"></el-table-column>
<el-table-column prop="goods_name" label="名称" width="200"></el-table-column>
<el-table-column prop="price" label="售价"></el-table-column>
<el-table-column prop="ota_name" label="商家"></el-table-column>
<el-table-column prop="inventory_total" label="库存"></el-table-column>
<el-table-column prop="total_amount_sold" label="已售数量"></el-table-column>
<el-table-column prop="inventory_rest" label="剩余库存"></el-table-column>
<el-table-column label="操作" fixed="right">
<template #default="scope">
<el-button @click="commodity('update', scope.row)" type="text" size="small">修改</el-button>
</template>
</el-table-column>
</el-table>
<template #footer>
<span class="dialog-footer">
<el-button @click="selCommodityPopup = false">取 消</el-button>
<el-button type="primary" @click="comLibrarySave">保存</el-button>
</span>
</template>
</el-dialog>
</div>
</template>
<script>
import { GOODS_URI } from "../../../../../server/config";
import { ElMessage } from "element-plus";
import { getCookie } from "@/utils/util";
import {
addGoods,
getBusinessList,
pindanGoods,
markGoodsInfo,
editGoods
} from "../../../../service/Activity/index";
// 当选择(每人最多买时 添加验证(非空))
let checkPurseLimit = (rule, value, callback) => {
let str = /^[1-9]\d*$/;
if (value === "" || value === undefined || value === 0) {
return callback(new Error("请添加限制购买数量"));
} else if (!str.test(value)) {
return callback(new Error("请输入正确的购买数量"));
} else {
callback();
}
};
let checkPurseLimitNull = (rule, value, callback) => {
callback();
};
var addProduct = {
props: {
editInfo: {
type: Object,
required: () => {}
},
addProduc: {
type: Array,
required: () => {}
},
stepTwoTitle: {
type: String,
default: ""
}
},
data() {
return {
// 校验规则函数
checkPurseLimit: checkPurseLimit,
checkPurseLimitNull: checkPurseLimitNull,
// 商品列表
comTableData: [],
// 商品库列表
comLibTableData: [],
businessOpt: [], // 商家数据
addCommodityPopup: false, // 添加商品弹窗状态
addCommodityTitle: "", // 标题
commodityForm: {
goods_name: "",
price: 0,
original_price: 0,
inventory_total: "",
total_amount_order: "",
business1: "",
num_limit: "", // 购买限制数量
checkedRadio: "" // 购买限制radio
},
picStr: "",
picUrlList: [],
picUploadList: [], // 上传详情图片列表
isShowPopver: false, // 是否展示图片框
uploadUrl: `${GOODS_URI}/ksy/ks3apiunencrypt/ks3api_upload`, // 金山云上传地址
hideUpload: false,
limitCount: 1,
// 商品库添加
selCommodityPopup: false, // 商品库添加弹窗状态
business2: "", // 商家
multipleSelection: [], // 勾选的数据
goodsSkuID: "",
inventoryTotal: 0, // 总库存
inventoryRest: 0, // 剩余库存
inventory: 0, // 添加库存
};
},
methods: {
cellClass() {
if (arguments.rowIndex === 1) {
return { display: "none" };
}
},
// 上移
upMove(index) {
if (index <= 0) {
this.$message.error("不能继续向上移动");
} else {
const upData = this.comTableData[index - 1];
this.comTableData.splice(index - 1, 1);
this.comTableData.splice(index, 0, upData);
}
},
// 下移
upDown(index) {
if (index === this.comTableData.length - 1) {
this.$message.error("不能继续向下移动");
} else {
const downData = this.comTableData[index + 1];
this.comTableData.splice(index + 1, 1);
this.comTableData.splice(index, 0, downData);
}
},
// 库存计算
inventoryIpt(val) {
if(val < 0) return this.commodityForm.inventory_total = 0;
var pattern = /^-?[1-9]\d*$|^0$/g;
if (!pattern.test(this.commodityForm.inventory_total)) {
this.commodityForm.inventory_total = "";
this.inventoryRest =
this.inventoryTotal - this.commodityForm.total_amount_order;
} else {
this.inventoryRest =
Number(val) +
this.inventoryTotal -
this.commodityForm.total_amount_order;
}
},
// 展示商品大图
previewImage(file) {
this.popoverImage = file.url;
this.isShowPopver = true;
},
handleDetailChange() {
this.hideUpload = this.picUploadList.length >= this.limitCount;
},
// 图片上传成功时
handleDetailSuccess(res) {
this.picStr = res.result.image_id;
this.picUploadList.push(res.result.image_id);
},
// 图片删除后
removeDetailFiles() {
this.picStr = "";
this.picUrlList = [];
this.picUploadList = [];
// this.hideUpload = this.picUploadList.length >= this.limitCount;
},
// 获取商家
async getBusinessListMet() {
let params = { ota_name: "", offset: "", limit: "" };
try {
const res = await getBusinessList(params);
this.businessOpt = [
{ ota_id: "", ota_name: "全部" },
...res.result.list
];
} catch (error) {
this.$message.error("发生未知错误,请稍后再试一下吧~~~");
console.error(error);
}
},
// 查看商品详情(api)
async markGoodsInfoMet(goodSkuID) {
let params = { goods_sku_id: goodSkuID, marketing_type: "4" };
const res = await markGoodsInfo(params);
this.inventoryRest = res.result.goods_info.inventory_rest;
this.inventoryTotal = res.result.goods_info.inventory_total;
this.inventory = res.result.goods_info.inventory_total;
this.commodityForm = res.result.goods_info;
this.commodityForm.num_limit =
res.result.goods_info.rule_limit === 0
? ""
: res.result.goods_info.rule_limit; // 购买限制的数量
this.commodityForm.checkedRadio =
res.result.goods_info.rule_limit === 0 ||
res.result.goods_info.rule_limit === undefined
? "不限制"
: "每人最多买"; // 购买限制按钮选择
this.commodityForm.business1 = res.result.goods_info.ota_id;
this.picUrlList = [];
for (var i in res.result.goods_info.desc_pic_url_list) {
this.picUrlList.push({
url: res.result.goods_info.desc_pic_url_list[i]
});
}
this.picStr = this.getUrlParms(
res.result.goods_info.desc_pic_url_list[0],
"url"
);
},
getUrlParms(path, name) {
var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i");
if (reg.test(path)) return unescape(RegExp.$2.replace(/\+/g, " "));
return "";
},
// 修改商品详情(api)
async editGoodsMet(goodsSkuID) {
const res = await editGoods({
goods_name: this.commodityForm.goods_name,
desc_pic_url: this.picStr,
desc: "",
inventory_add: this.commodityForm.inventory_total - this.inventory,
original_price: this.commodityForm.original_price,
price: this.commodityForm.price,
marketing_name: this.editInfo.marketing_name,
marketing_type: "4",
ota_id: this.commodityForm.business1,
op_cur_user: getCookie("username"),
// op_cur_user: store.state.userInfo.email,
goods_sku_id: goodsSkuID,
rule_limit:
this.commodityForm.checkedRadio === "不限制" ||
this.commodityForm.checkedRadio === "" ||
this.commodityForm.checkedRadio === undefined
? 0
: this.commodityForm.num_limit
});
if (res.code == 0) {
ElMessage.success({
message: "修改成功",
type: "success"
});
await this.pindanGoodsMet();
let result = null;
for (var j in this.comLibTableData) {
if (this.comLibTableData[j].goods_sku_id == goodsSkuID) {
result = this.comLibTableData[j];
}
}
for (var i in this.comTableData) {
if (this.comTableData[i].goods_sku_id == result.goods_sku_id) {
this.comTableData.splice(i, 1, result);
}
}
this.addCommodityPopup = false;
} else {
ElMessage.error(res.reason);
}
},
// 获取商品库列表
async pindanGoodsMet(otaID, goodsName) {
let params = { ota_id: otaID, goods_name: goodsName };
const res = await pindanGoods(params);
this.comLibTableData = res.result.list;
},
// 添加+修改商品
commodity(type, val) {
// 清楚图片
this.$refs.picUpload &&
this.$refs.picUpload.clearFiles &&
this.$refs.picUpload.clearFiles();
this.picUrlList = [];
this.picStr = "";
this.addCommodityPopup = true;
// this.commodityForm = {};
this.$nextTick(() => {
this.$refs.infoForm.resetFields(); // 清空表单数据
});
if (type == "add") {
this.hideUpload = false;
this.inventoryRest = 0;
this.commodityForm.total_amount_order = 0;
this.addCommodityTitle = "商品添加";
} else {
this.addCommodityTitle = "商品编辑";
this.goodsSkuID = val.goods_sku_id;
this.markGoodsInfoMet(this.goodsSkuID); // 查看商品详情(api)
}
},
// 添加商品(api)
async addGoodsMet() {
const res = await addGoods({
marketing_name: this.stepTwoTitle,
goods_name: this.commodityForm.goods_name,
desc_pic_url: this.picStr,
desc: "",
inventory: this.commodityForm.inventory_total - this.inventory,
original_price: this.commodityForm.original_price,
marketing_type: "4",
price: this.commodityForm.price,
ota_id: this.commodityForm.business1,
op_cur_user: getCookie("username"),
// op_cur_user: store.state.userInfo.email,
rule_limit:
this.commodityForm.checkedRadio === "不限制" ||
this.commodityForm.checkedRadio === "" ||
this.commodityForm.checkedRadio === undefined
? 0
: this.commodityForm.num_limit
});
if (res.code == 0) {
ElMessage.success({
message: "添加商品成功",
type: "success"
});
this.comTableData.push(res.result.goods_info);
this.addCommodityPopup = false;
} else {
ElMessage.error(res.reason);
}
},
// 添加商品取消
commodityCancel() {
this.addCommodityPopup = false;
this.$refs.infoForm.clearValidate();
},
// 添加商品保存(操作)
commoditySave(infoForm) {
this.$refs[infoForm].validate(valid => {
if (valid) {
if (this.addCommodityTitle == "商品添加") {
this.addGoodsMet();
} else {
this.editGoodsMet(this.goodsSkuID);
}
import { ElMessage } from "element-plus";
import { getCookie, UploadPicUrl } from "@/utils/util";
import { addGoods, getBusinessList, pindanGoods, markGoodsInfo, editGoods } from "../../../../service/Activity/index";
// 当选择(每人最多买时 添加验证(非空))
let checkPurseLimit = (rule, value, callback) => {
let str = /^[1-9]\d*$/;
if (value === "" || value === undefined || value === 0) {
return callback(new Error("请添加限制购买数量"));
} else if (!str.test(value)) {
return callback(new Error("请输入正确的购买数量"));
} else {
return false;
}
});
},
// commoditySave(infoForm) {
// console.log("baocun");
// this.$refs[infoForm].validate(valid => {
// console.log("00");
// if (valid) {
// console.log("add");
// if (this.addCommodityTitle == "商品添加") {
// this.addGoodsMet();
// } else {
// console.log("xiugai");
// this.editGoodsMet(this.goodsSkuID);
// }
// } else {
// console.log("validate");
// return false;
// }
// });
// },
// 从商品库添加
async commodLibraryAdd() {
this.selCommodityPopup = true;
this.pindanGoodsMet();
},
// 商家选择(选择商品)
business2Sel(val) {
this.pindanGoodsMet(val, "");
},
// 商品库中选择商品
selectGoodsChange(val) {
this.multipleSelection = val;
},
// 商品库选择商品保存
comLibrarySave() {
if (this.multipleSelection.length == 0) {
ElMessage.error("请选择商品");
return;
}
this.selCommodityPopup = false;
if (this.comTableData.length == 0) {
this.comTableData.push(...this.multipleSelection);
} else {
this.multipleSelection.forEach(item => {
let num = 0;
this.comTableData.some(val => {
num++;
if (val.goods_sku_id === item.goods_sku_id) {
val.goods_sku_id = item.goods_sku_id;
if (num == 1) {
ElMessage.error("商品添加重复,已过滤掉重复选项");
}
return true;
} else if (num === this.comTableData.length) {
this.comTableData.push(Object.assign({}, item));
}
});
});
}
},
// 移除
removeCom(val) {
for (var i in this.comTableData) {
if (this.comTableData[i].goods_sku_id == val.goods_sku_id) {
this.comTableData.splice(i, 1);
callback();
}
}
}
},
watch: {
addProduc: function(newVal) {
let marketingId = this.$route.query.marketing_id;
if (marketingId == undefined) {
return;
}
this.comTableData = newVal;
},
picUrlList: function() {
if (this.picUrlList.length >= this.limitCount) {
this.hideUpload = true;
} else {
this.hideUpload = false;
}
},
},
created() {
this.getBusinessListMet();
}
};
export default addProduct;
};
let checkPurseLimitNull = (rule, value, callback) => {
callback();
};
var addProduct = {
props: {
editInfo: {
type: Object,
required: () => {},
},
addProduc: {
type: Array,
required: () => {},
},
stepTwoTitle: {
type: String,
default: "",
},
},
data() {
return {
// 校验规则函数
checkPurseLimit: checkPurseLimit,
checkPurseLimitNull: checkPurseLimitNull,
// 商品列表
comTableData: [],
// 商品库列表
comLibTableData: [],
businessOpt: [], // 商家数据
addCommodityPopup: false, // 添加商品弹窗状态
addCommodityTitle: "", // 标题
commodityForm: {
goods_name: "",
price: 0,
original_price: 0,
inventory_total: "",
total_amount_order: "",
business1: "",
num_limit: "", // 购买限制数量
checkedRadio: "", // 购买限制radio
},
picStr: "",
picUrlList: [],
picUploadList: [], // 上传详情图片列表
isShowPopver: false, // 是否展示图片框
uploadUrl: UploadPicUrl, // 金山云上传地址
hideUpload: false,
limitCount: 1,
// 商品库添加
selCommodityPopup: false, // 商品库添加弹窗状态
business2: "", // 商家
multipleSelection: [], // 勾选的数据
goodsSkuID: "",
inventoryTotal: 0, // 总库存
inventoryRest: 0, // 剩余库存
inventory: 0, // 添加库存
};
},
methods: {
cellClass() {
if (arguments.rowIndex === 1) {
return { display: "none" };
}
},
// 上移
upMove(index) {
if (index <= 0) {
this.$message.error("不能继续向上移动");
} else {
const upData = this.comTableData[index - 1];
this.comTableData.splice(index - 1, 1);
this.comTableData.splice(index, 0, upData);
}
},
// 下移
upDown(index) {
if (index === this.comTableData.length - 1) {
this.$message.error("不能继续向下移动");
} else {
const downData = this.comTableData[index + 1];
this.comTableData.splice(index + 1, 1);
this.comTableData.splice(index, 0, downData);
}
},
// 库存计算
inventoryIpt(val) {
if (val < 0) return (this.commodityForm.inventory_total = 0);
var pattern = /^-?[1-9]\d*$|^0$/g;
if (!pattern.test(this.commodityForm.inventory_total)) {
this.commodityForm.inventory_total = "";
this.inventoryRest = this.inventoryTotal - this.commodityForm.total_amount_order;
} else {
this.inventoryRest = Number(val) + this.inventoryTotal - this.commodityForm.total_amount_order;
}
},
// 展示商品大图
previewImage(file) {
this.popoverImage = file.url;
this.isShowPopver = true;
},
handleDetailChange() {
this.hideUpload = this.picUploadList.length >= this.limitCount;
},
// 图片上传成功时
handleDetailSuccess(res) {
this.picStr = res.result.image_id;
this.picUploadList.push(res.result.image_id);
},
// 图片删除后
removeDetailFiles() {
this.picStr = "";
this.picUrlList = [];
this.picUploadList = [];
// this.hideUpload = this.picUploadList.length >= this.limitCount;
},
// 获取商家
async getBusinessListMet() {
let params = { ota_name: "", offset: "", limit: "" };
try {
const res = await getBusinessList(params);
this.businessOpt = [{ ota_id: "", ota_name: "全部" }, ...res.result.list];
} catch (error) {
this.$message.error("发生未知错误,请稍后再试一下吧~~~");
console.error(error);
}
},
// 查看商品详情(api)
async markGoodsInfoMet(goodSkuID) {
let params = { goods_sku_id: goodSkuID, marketing_type: "4" };
const res = await markGoodsInfo(params);
this.inventoryRest = res.result.goods_info.inventory_rest;
this.inventoryTotal = res.result.goods_info.inventory_total;
this.inventory = res.result.goods_info.inventory_total;
this.commodityForm = res.result.goods_info;
this.commodityForm.num_limit = res.result.goods_info.rule_limit === 0 ? "" : res.result.goods_info.rule_limit; // 购买限制的数量
this.commodityForm.checkedRadio =
res.result.goods_info.rule_limit === 0 || res.result.goods_info.rule_limit === undefined ? "不限制" : "每人最多买"; // 购买限制按钮选择
this.commodityForm.business1 = res.result.goods_info.ota_id;
this.picUrlList = [];
for (var i in res.result.goods_info.desc_pic_url_list) {
this.picUrlList.push({
url: res.result.goods_info.desc_pic_url_list[i],
});
}
this.picStr = this.getUrlParms(res.result.goods_info.desc_pic_url_list[0], "url");
},
getUrlParms(path, name) {
var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i");
if (reg.test(path)) return unescape(RegExp.$2.replace(/\+/g, " "));
return "";
},
// 修改商品详情(api)
async editGoodsMet(goodsSkuID) {
const res = await editGoods({
goods_name: this.commodityForm.goods_name,
desc_pic_url: this.picStr,
desc: "",
inventory_add: this.commodityForm.inventory_total - this.inventory,
original_price: this.commodityForm.original_price,
price: this.commodityForm.price,
marketing_name: this.editInfo.marketing_name,
marketing_type: "4",
ota_id: this.commodityForm.business1,
op_cur_user: getCookie("username"),
// op_cur_user: store.state.userInfo.email,
goods_sku_id: goodsSkuID,
rule_limit:
this.commodityForm.checkedRadio === "不限制" ||
this.commodityForm.checkedRadio === "" ||
this.commodityForm.checkedRadio === undefined
? 0
: this.commodityForm.num_limit,
});
if (res.code == 0) {
ElMessage.success({
message: "修改成功",
type: "success",
});
await this.pindanGoodsMet();
let result = null;
for (var j in this.comLibTableData) {
if (this.comLibTableData[j].goods_sku_id == goodsSkuID) {
result = this.comLibTableData[j];
}
}
for (var i in this.comTableData) {
if (this.comTableData[i].goods_sku_id == result.goods_sku_id) {
this.comTableData.splice(i, 1, result);
}
}
this.addCommodityPopup = false;
} else {
ElMessage.error(res.reason);
}
},
// 获取商品库列表
async pindanGoodsMet(otaID, goodsName) {
let params = { ota_id: otaID, goods_name: goodsName };
const res = await pindanGoods(params);
this.comLibTableData = res.result.list;
},
// 添加+修改商品
commodity(type, val) {
// 清楚图片
this.$refs.picUpload && this.$refs.picUpload.clearFiles && this.$refs.picUpload.clearFiles();
this.picUrlList = [];
this.picStr = "";
this.addCommodityPopup = true;
// this.commodityForm = {};
this.$nextTick(() => {
this.$refs.infoForm.resetFields(); // 清空表单数据
});
if (type == "add") {
this.hideUpload = false;
this.inventoryRest = 0;
this.commodityForm.total_amount_order = 0;
this.addCommodityTitle = "商品添加";
} else {
this.addCommodityTitle = "商品编辑";
this.goodsSkuID = val.goods_sku_id;
this.markGoodsInfoMet(this.goodsSkuID); // 查看商品详情(api)
}
},
// 添加商品(api)
async addGoodsMet() {
const res = await addGoods({
marketing_name: this.stepTwoTitle,
goods_name: this.commodityForm.goods_name,
desc_pic_url: this.picStr,
desc: "",
inventory: this.commodityForm.inventory_total - this.inventory,
original_price: this.commodityForm.original_price,
marketing_type: "4",
price: this.commodityForm.price,
ota_id: this.commodityForm.business1,
op_cur_user: getCookie("username"),
// op_cur_user: store.state.userInfo.email,
rule_limit:
this.commodityForm.checkedRadio === "不限制" ||
this.commodityForm.checkedRadio === "" ||
this.commodityForm.checkedRadio === undefined
? 0
: this.commodityForm.num_limit,
});
if (res.code == 0) {
ElMessage.success({
message: "添加商品成功",
type: "success",
});
this.comTableData.push(res.result.goods_info);
this.addCommodityPopup = false;
} else {
ElMessage.error(res.reason);
}
},
// 添加商品取消
commodityCancel() {
this.addCommodityPopup = false;
this.$refs.infoForm.clearValidate();
},
// 添加商品保存(操作)
commoditySave(infoForm) {
this.$refs[infoForm].validate((valid) => {
if (valid) {
if (this.addCommodityTitle == "商品添加") {
this.addGoodsMet();
} else {
this.editGoodsMet(this.goodsSkuID);
}
} else {
return false;
}
});
},
// commoditySave(infoForm) {
// console.log("baocun");
// this.$refs[infoForm].validate(valid => {
// console.log("00");
// if (valid) {
// console.log("add");
// if (this.addCommodityTitle == "商品添加") {
// this.addGoodsMet();
// } else {
// console.log("xiugai");
// this.editGoodsMet(this.goodsSkuID);
// }
// } else {
// console.log("validate");
// return false;
// }
// });
// },
// 从商品库添加
async commodLibraryAdd() {
this.selCommodityPopup = true;
this.pindanGoodsMet();
},
// 商家选择(选择商品)
business2Sel(val) {
this.pindanGoodsMet(val, "");
},
// 商品库中选择商品
selectGoodsChange(val) {
this.multipleSelection = val;
},
// 商品库选择商品保存
comLibrarySave() {
if (this.multipleSelection.length == 0) {
ElMessage.error("请选择商品");
return;
}
this.selCommodityPopup = false;
if (this.comTableData.length == 0) {
this.comTableData.push(...this.multipleSelection);
} else {
this.multipleSelection.forEach((item) => {
let num = 0;
this.comTableData.some((val) => {
num++;
if (val.goods_sku_id === item.goods_sku_id) {
val.goods_sku_id = item.goods_sku_id;
if (num == 1) {
ElMessage.error("商品添加重复,已过滤掉重复选项");
}
return true;
} else if (num === this.comTableData.length) {
this.comTableData.push(Object.assign({}, item));
}
});
});
}
},
// 移除
removeCom(val) {
for (var i in this.comTableData) {
if (this.comTableData[i].goods_sku_id == val.goods_sku_id) {
this.comTableData.splice(i, 1);
}
}
},
},
watch: {
addProduc: function (newVal) {
let marketingId = this.$route.query.marketing_id;
if (marketingId == undefined) {
return;
}
this.comTableData = newVal;
},
picUrlList: function () {
if (this.picUrlList.length >= this.limitCount) {
this.hideUpload = true;
} else {
this.hideUpload = false;
}
},
},
created() {
this.getBusinessListMet();
},
};
export default addProduct;
</script>
<style scoped lang="less">
.addProduc {
width: 90%;
margin: 0 auto;
}
.buttons_actions {
display: flex;
justify-content: space-around;
align-items: center;
}
.btnGroup {
margin-bottom: 15px;
}
.addCommodityBtn {
margin: 0 20px 0 0;
}
.infoForm /deep/.el-form-item:nth-child(1),
.infoForm /deep/.el-form-item:nth-child(2) {
width: 100%;
}
.dioFor {
display: block;
margin: 10px 0;
}
.comLibTableData /deep/ .el-table__body-wrapper {
height: 550px;
overflow: scroll;
}
.price /deep/ .el-input__inner {
text-align: left;
}
.hide /deep/ .el-upload--picture-card {
display: none;
}
// 商品添加修改dialog-form表单
/deep/ .add_goods_dialog {
min-width: 370px;
}
.addProduc {
width: 90%;
margin: 0 auto;
}
.buttons_actions {
display: flex;
justify-content: space-around;
align-items: center;
}
.btnGroup {
margin-bottom: 15px;
}
.addCommodityBtn {
margin: 0 20px 0 0;
}
.infoForm /deep/.el-form-item:nth-child(1),
.infoForm /deep/.el-form-item:nth-child(2) {
width: 100%;
}
.dioFor {
display: block;
margin: 10px 0;
}
.comLibTableData /deep/ .el-table__body-wrapper {
height: 550px;
overflow: scroll;
}
.price /deep/ .el-input__inner {
text-align: left;
}
.hide /deep/ .el-upload--picture-card {
display: none;
}
// 商品添加修改dialog-form表单
/deep/ .add_goods_dialog {
min-width: 370px;
}
</style>
<template>
<div class="infoEditing">
<el-form
ref="infoEditForm"
:model="infoEditForm"
label-width="80px"
@submit.prevent
>
<el-form-item label="标题:">
<el-input v-model="infoEditForm.title" maxlength="30"></el-input>
</el-form-item>
<el-form-item label="介绍:">
<el-input
type="textarea"
v-model="infoEditForm.desc"
maxlength="1000"
rows="4"
></el-input>
</el-form-item>
<el-form-item label="图片:">
<el-upload
:class="{ hide: hideUpload }"
:data="{ type: 1 }"
:action="uploadUrl"
:on-preview="previewImage"
:on-success="handleDetailSuccess"
:on-change="handleDetailChange"
:before-remove="removeDetailFiles"
:file-list="infoEditForm.picUrlList"
auto-upload
ref="picUpload"
:limit="limitCount"
list-type="picture-card"
multiple
>
<template #default>
<i class="el-icon-plus"></i>
</template>
</el-upload>
</el-form-item>
</el-form>
<!-- 展示缩略图 -->
<el-dialog width="40%" v-model="isShowPopver">
<el-image :src="popoverImage" fit="fill" style="width: 100%"></el-image>
</el-dialog>
</div>
<div class="infoEditing">
<el-form ref="infoEditForm" :model="infoEditForm" label-width="80px" @submit.prevent>
<el-form-item label="标题:">
<el-input v-model="infoEditForm.title" maxlength="30"></el-input>
</el-form-item>
<el-form-item label="介绍:">
<el-input type="textarea" v-model="infoEditForm.desc" maxlength="1000" rows="4"></el-input>
</el-form-item>
<el-form-item label="图片:">
<el-upload
:class="{ hide: hideUpload }"
:data="{ type: 1 }"
:action="uploadUrl"
:on-preview="previewImage"
:on-success="handleDetailSuccess"
:on-change="handleDetailChange"
:before-remove="removeDetailFiles"
:file-list="infoEditForm.picUrlList"
auto-upload
ref="picUpload"
:limit="limitCount"
list-type="picture-card"
multiple
>
<template #default>
<i class="el-icon-plus"></i>
</template>
</el-upload>
</el-form-item>
</el-form>
<!-- 展示缩略图 -->
<el-dialog width="40%" v-model="isShowPopver">
<el-image :src="popoverImage" fit="fill" style="width: 100%"></el-image>
</el-dialog>
</div>
</template>
<script>
import { GOODS_URI } from "../../../../../server/config";
export default {
props: {
infoEditArr: {
type: Object,
default: () => {
return {
pindan_pic_url: []
};
},
require: true
}
},
data() {
return {
infoEditForm: {
title: "", // 标题
desc: "", // 介绍
picUploadList: [], // 上传详情图片列表
picUrlList: [] // 图片回显列表
},
picSubmitList: [], // 发布功能需要的图片列表
propData: {},
isShowPopver: false, // 是否展示图片框
uploadUrl: `${GOODS_URI}/ksy/ks3apiunencrypt/ks3api_upload`, // 金山云上传地址
hideUpload: false,
limitCount: 9
};
},
watch: {
infoEditArr: {
// 监听props属性 展示自提点列表
handler: function(newVal) {
if (this.$route.query.marketing_id) {
this.propData = newVal;
this.infoEditForm.title = this.propData.marketing_name;
this.infoEditForm.desc = this.propData.pindan_desc;
for (var i in this.propData.pindan_pic_url) {
this.infoEditForm.picUrlList.push({
url: this.propData.pindan_pic_url[i]
});
this.picSubmitList.push({
url: this.propData.pindan_pic_url[i]
});
}
this.hideUpload = this.picSubmitList.length >= this.limitCount; // 大于9 隐藏
}
},
deep: true,
immediate: true
}
},
methods: {
// 展示商品大图
previewImage(file) {
this.popoverImage = file.url;
this.isShowPopver = true;
},
import { UploadPicUrl } from "@/utils/util";
handleDetailChange() {
this.hideUpload = this.picSubmitList.length >= this.limitCount;
},
export default {
props: {
infoEditArr: {
type: Object,
default: () => {
return {
pindan_pic_url: [],
};
},
require: true,
},
},
data() {
return {
infoEditForm: {
title: "", // 标题
desc: "", // 介绍
picUploadList: [], // 上传详情图片列表
picUrlList: [], // 图片回显列表
},
picSubmitList: [], // 发布功能需要的图片列表
propData: {},
isShowPopver: false, // 是否展示图片框
uploadUrl: UploadPicUrl, // 金山云上传地址
hideUpload: false,
limitCount: 9,
};
},
watch: {
infoEditArr: {
// 监听props属性 展示自提点列表
handler: function (newVal) {
if (this.$route.query.marketing_id) {
this.propData = newVal;
this.infoEditForm.title = this.propData.marketing_name;
this.infoEditForm.desc = this.propData.pindan_desc;
for (var i in this.propData.pindan_pic_url) {
this.infoEditForm.picUrlList.push({
url: this.propData.pindan_pic_url[i],
});
this.picSubmitList.push({
url: this.propData.pindan_pic_url[i],
});
}
this.hideUpload = this.picSubmitList.length >= this.limitCount; // 大于9 隐藏
}
},
deep: true,
immediate: true,
},
},
methods: {
// 展示商品大图
previewImage(file) {
this.popoverImage = file.url;
this.isShowPopver = true;
},
// 图片上传成功时
handleDetailSuccess(res) {
this.infoEditForm.picUploadList.push(res.result.image_id); // 上传成功图片的id
this.picSubmitList.push({
// 发布功能需要的图片列表
url: res.result.url
});
this.hideUpload = this.picSubmitList.length >= this.limitCount;
},
handleDetailChange() {
this.hideUpload = this.picSubmitList.length >= this.limitCount;
},
// 图片删除后
removeDetailFiles(file, fileList) {
for (let i = 0; i < fileList.length; i++) {
if (fileList[i].uid == file.uid) {
this.picSubmitList.splice(i, 1);
}
}
this.hideUpload = this.picSubmitList.length >= this.limitCount;
},
// 图片上传成功时
handleDetailSuccess(res) {
this.infoEditForm.picUploadList.push(res.result.image_id); // 上传成功图片的id
this.picSubmitList.push({
// 发布功能需要的图片列表
url: res.result.url,
});
this.hideUpload = this.picSubmitList.length >= this.limitCount;
},
// 获取营销活动详情
marketingInfoMet() {
let marketingId = this.$route.query.marketing_id;
if (marketingId == undefined) {
return;
}
this.propData = JSON.parse(localStorage.getItem("propData"));
this.infoEditForm.title = this.propData.marketing_name;
this.infoEditForm.desc = this.propData.pindan_desc;
for (var i in this.propData.pindan_pic_url) {
this.infoEditForm.picUrlList.push({
url: this.propData.pindan_pic_url[i]
});
}
}
},
created() {
// this.marketingInfoMet();
}
};
// 图片删除后
removeDetailFiles(file, fileList) {
for (let i = 0; i < fileList.length; i++) {
if (fileList[i].uid == file.uid) {
this.picSubmitList.splice(i, 1);
}
}
this.hideUpload = this.picSubmitList.length >= this.limitCount;
},
// 获取营销活动详情
marketingInfoMet() {
let marketingId = this.$route.query.marketing_id;
if (marketingId == undefined) {
return;
}
this.propData = JSON.parse(localStorage.getItem("propData"));
this.infoEditForm.title = this.propData.marketing_name;
this.infoEditForm.desc = this.propData.pindan_desc;
for (var i in this.propData.pindan_pic_url) {
this.infoEditForm.picUrlList.push({
url: this.propData.pindan_pic_url[i],
});
}
},
},
created() {
// this.marketingInfoMet();
},
};
</script>
<style scoped>
.infoEditing {
width: 64%;
margin: 0 auto;
}
.hide /deep/ .el-upload--picture-card {
display: none;
}
.infoEditing {
width: 64%;
margin: 0 auto;
}
.hide /deep/ .el-upload--picture-card {
display: none;
}
</style>
<template>
<div id="map" class="mapContainer">
<div class="mapWrapper">
<div class="search">
<el-form ref="form" @submit.prevent>
<el-form-item label-position="left">
<el-button @click="handleSearch">搜索</el-button>
<el-input
class="dialog-input"
v-model="searchKey"
placeholder="请输入关键字"
autocomplete="on"
>
<template #suffix>
<i
@click="searchKey = ''"
class="el-input__icon el-icon-close"
></i>
</template>
</el-input>
</el-form-item>
</el-form>
<div id="js-result" v-show="searchKey" class="result"></div>
</div>
<div id="js-container" class="myMap">
正在加载数据 ...
</div>
</div>
<div id="map" class="mapContainer">
<div class="mapWrapper">
<div class="search">
<el-form ref="form" @submit.prevent>
<el-form-item label-position="left">
<el-button @click="handleSearch">搜索</el-button>
<el-input class="dialog-input" v-model="searchKey" placeholder="请输入关键字" autocomplete="on">
<template #suffix>
<i @click="searchKey = ''" class="el-input__icon el-icon-close"></i>
</template>
</el-input>
</el-form-item>
</el-form>
<div id="js-result" v-show="searchKey" class="result"></div>
</div>
<div id="js-container" class="myMap">正在加载数据 ...</div>
</div>
<div class="mapInfo">
<div class="infoAll">
<h3 class="title">拖拽选址</h3>
<ul class="info">
<li><span>经度:</span>{{ dragData.lng }}</li>
<li><span>纬度:</span>{{ dragData.lat }}</li>
<li><span>地址:</span>{{ dragData.address }}</li>
</ul>
</div>
<div class="confirmButton">
<el-button class="button_pre" @click="cancel">取 消</el-button>
<el-button class="button_next" type="primary" @click="confirm"
>确 定</el-button
>
</div>
</div>
<!-- <div class="confirmButton">
<div class="mapInfo">
<div class="infoAll">
<h3 class="title">拖拽选址</h3>
<ul class="info">
<li>
<span>经度:</span>
{{ dragData.lng }}
</li>
<li>
<span>纬度:</span>
{{ dragData.lat }}
</li>
<li>
<span>地址:</span>
{{ dragData.address }}
</li>
</ul>
</div>
<div class="confirmButton">
<el-button class="button_pre" @click="cancel">取 消</el-button>
<el-button class="button_next" type="primary" @click="confirm">确 定</el-button>
</div>
</div>
<!-- <div class="confirmButton">
<el-button @click="cancel">取 消</el-button>
<el-button type="primary" @click="confirm">确 定</el-button>
</div> -->
</div>
</div>
</template>
<script>
import remoteLoad from "@/utils/remoteLoad.js";
export default {
name: "app",
data() {
return {
dialogVisible: true,
MapCityName: "北京",
searchKey: "",
dragData: {
lng: null,
lat: null,
address: null,
nearestJunction: null,
nearestRoad: null,
nearestPOI: null
}
};
},
methods: {
// 取消
cancel() {
this.$emit("hideMapDialog", false);
},
// 确认
confirm() {
this.$emit("getMapInfo", this.dragData);
this.$emit("hideMapDialog", false);
},
// 搜索
handleSearch() {
if (this.searchKey) {
this.placeSearch.search(this.searchKey);
}
},
dragMap(data) {
this.dragData = {
lng: data.position.lng,
lat: data.position.lat,
address: data.address,
province: data.regeocode.addressComponent.province,
city: data.regeocode.addressComponent.city,
area: data.regeocode.addressComponent.district
};
},
import remoteLoad from "@/utils/remoteLoad.js";
export default {
name: "app",
data() {
return {
dialogVisible: true,
MapCityName: "北京",
searchKey: "",
dragData: {
lng: null,
lat: null,
address: null,
nearestJunction: null,
nearestRoad: null,
nearestPOI: null,
},
};
},
methods: {
// 取消
cancel() {
this.$emit("hideMapDialog", false);
},
// 确认
confirm() {
this.$emit("getMapInfo", this.dragData);
this.$emit("hideMapDialog", false);
},
// 搜索
handleSearch() {
if (this.searchKey) {
this.placeSearch.search(this.searchKey);
}
},
dragMap(data) {
this.dragData = {
lng: data.position.lng,
lat: data.position.lat,
address: data.address,
province: data.regeocode.addressComponent.province,
city: data.regeocode.addressComponent.city,
area: data.regeocode.addressComponent.district,
};
},
// 初始化地图
initMap() {
// 加载PositionPicker,loadUI的路径参数为模块名中 'ui/' 之后的部分
let AMapUI = (this.AMapUI = window.AMapUI);
let AMap = (this.AMap = window.AMap);
// 初始化地图
initMap() {
// 加载PositionPicker,loadUI的路径参数为模块名中 'ui/' 之后的部分
let AMapUI = (this.AMapUI = window.AMapUI);
let AMap = (this.AMap = window.AMap);
AMapUI.loadUI(["misc/PositionPicker"], PositionPicker => {
let mapConfig = {
zoom: 16
// cityName: this.MapCityName
};
if (this.lat && this.lng) {
mapConfig.center = [this.lng, this.lat];
}
let map = new AMap.Map("js-container", mapConfig);
AMapUI.loadUI(["misc/PositionPicker"], (PositionPicker) => {
let mapConfig = {
zoom: 16,
// cityName: this.MapCityName
};
if (this.lat && this.lng) {
mapConfig.center = [this.lng, this.lat];
}
let map = new AMap.Map("js-container", mapConfig);
let _this = this;
// 加载地图搜索插件
AMap.service("AMap.PlaceSearch", () => {
this.placeSearch = new AMap.PlaceSearch({
pageSize: 5,
pageIndex: 1,
citylimit: true,
// city: this.MapCityName,
map: map,
panel: "js-result"
});
});
// 加载地图搜索插件
AMap.service("AMap.PlaceSearch", () => {
this.placeSearch = new AMap.PlaceSearch({
pageSize: 5,
pageIndex: 1,
citylimit: true,
// city: this.MapCityName,
map: map,
panel: "js-result",
});
// 启用工具条
AMap.plugin(["AMap.ToolBar"], function() {
map.addControl(
new AMap.ToolBar({
position: "RB"
})
);
});
this.placeSearch.on("selectChanged", function ({ selected }) {
console.log(selected);
const { address, location, pname, cityname, adname } = selected.data;
// 地图地图定位
AMap.plugin("AMap.Geolocation", function() {
var geolocation = new AMap.Geolocation({
// 是否使用高精度定位,默认:true
enableHighAccuracy: true,
// 设置定位超时时间,默认:无穷大
timeout: 10000,
// 定位按钮的停靠位置的偏移量,默认:Pixel(10, 20)
buttonOffset: new AMap.Pixel(10, 20),
// 定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
zoomToAccuracy: true,
// 定位按钮的排放位置, RB表示右下
buttonPosition: "RB"
});
map.addControl(geolocation);
geolocation.getCurrentPosition();
AMap.event.addListener(geolocation, "complete", onComplete);
AMap.event.addListener(geolocation, "error", onError);
_this.dragData = {
lng: location.lng,
lat: location.lat,
address: address,
province: pname,
city: cityname,
area: adname,
};
function onComplete(data) {
console.log(data);
// data是具体的定位信息
}
_this.searchKey = "";
});
});
function onError(data) {
console.log(data);
// 定位出错
}
});
// 启用工具条
AMap.plugin(["AMap.ToolBar"], function () {
map.addControl(
new AMap.ToolBar({
position: "RB",
}),
);
});
// 创建地图拖拽
let positionPicker = new PositionPicker({
mode: "dragMap", // 设定为拖拽地图模式,可选'dragMap'、'dragMarker',默认为'dragMap'
map: map, // 依赖地图对象
iconStyle: {
//自定义外观
url: "//webapi.amap.com/ui/1.0/assets/position-picker2.png", //图片地址
size: [50, 50], //要显示的点大小,将缩放图片
ancher: [24, 40] //锚点的位置,即被size缩放之后,图片的什么位置作为选中的位置
}
});
// 地图地图定位
AMap.plugin("AMap.Geolocation", function () {
var geolocation = new AMap.Geolocation({
// 是否使用高精度定位,默认:true
enableHighAccuracy: true,
// 设置定位超时时间,默认:无穷大
timeout: 10000,
// 定位按钮的停靠位置的偏移量,默认:Pixel(10, 20)
buttonOffset: new AMap.Pixel(10, 20),
// 定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
zoomToAccuracy: true,
// 定位按钮的排放位置, RB表示右下
buttonPosition: "RB",
});
map.addControl(geolocation);
geolocation.getCurrentPosition();
AMap.event.addListener(geolocation, "complete", onComplete);
AMap.event.addListener(geolocation, "error", onError);
// 拖拽完成发送自定义 drag 事件
positionPicker.on("success", positionResult => {
this.dragMap(positionResult);
});
// 启动拖放
positionPicker.start();
});
}
},
async mounted() {
// 已载入高德地图API,则直接初始化地图
if (window.AMap && window.AMapUI) {
this.initMap();
// 未载入高德地图API,则先载入API再初始化
} else {
await remoteLoad(
`http://webapi.amap.com/maps?v=1.3&key=bb057625545d8cf77df1379e7aaae0b5`
);
await remoteLoad("http://webapi.amap.com/ui/1.0/main.js");
this.initMap();
}
}
};
function onComplete(data) {
console.log(data);
// data是具体的定位信息
}
function onError(data) {
console.log(data);
// 定位出错
}
});
// 创建地图拖拽
let positionPicker = new PositionPicker({
mode: "dragMap", // 设定为拖拽地图模式,可选'dragMap'、'dragMarker',默认为'dragMap'
map: map, // 依赖地图对象
iconStyle: {
//自定义外观
url: "//webapi.amap.com/ui/1.0/assets/position-picker2.png", //图片地址
size: [50, 50], //要显示的点大小,将缩放图片
ancher: [24, 40], //锚点的位置,即被size缩放之后,图片的什么位置作为选中的位置
},
});
// 拖拽完成发送自定义 drag 事件
positionPicker.on("success", (positionResult) => {
this.dragMap(positionResult);
});
// 启动拖放
positionPicker.start();
});
},
},
async mounted() {
// 已载入高德地图API,则直接初始化地图
if (window.AMap && window.AMapUI) {
this.initMap();
// 未载入高德地图API,则先载入API再初始化
} else {
await remoteLoad(`http://webapi.amap.com/maps?v=1.3&key=bb057625545d8cf77df1379e7aaae0b5`);
await remoteLoad("http://webapi.amap.com/ui/1.0/main.js");
this.initMap();
}
},
};
</script>
<style lang="less" scoped>
.mapContainer {
height: 100%;
width: 100%;
// display: flex;
// flex-direction: column;
.mapWrapper {
position: relative;
width: 80%;
height: 30vh;
.search {
position: absolute;
top: 10px;
left: 20px;
z-index: 100000;
.dialog-input {
width: 250px;
}
}
.myMap {
height: 100%;
height: 100%;
.mapContainer {
height: 100%;
width: 100%;
// display: flex;
// flex-direction: column;
.mapWrapper {
position: relative;
width: 80%;
height: 30vh;
.search {
position: absolute;
top: 10px;
left: 20px;
z-index: 100000;
.dialog-input {
width: 250px;
}
}
.myMap {
height: 100%;
height: 100%;
}
}
.mapInfo {
width: 20%;
padding-left: 20px;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: flex-start;
.infoAll {
flex-direction: column;
justify-content: start;
align-items: flex-start;
.info {
text-align: left;
}
}
.confirmButton {
display: flex;
flex-wrap: wrap;
.button_pre {
margin-right: 15px;
}
.button_next {
margin-left: 0;
}
}
}
}
}
.mapInfo {
width: 20%;
padding-left: 20px;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: flex-start;
.infoAll {
flex-direction: column;
justify-content: start;
align-items: flex-start;
.info {
text-align: left;
}
.m-map .search {
position: absolute;
top: 10px;
left: 10px;
width: 285px;
z-index: 1;
}
.confirmButton {
display: flex;
flex-wrap: wrap;
.button_pre {
margin-right: 15px;
}
.button_next {
margin-left: 0;
}
.m-map .search input {
width: 180px;
border: 1px solid #ccc;
line-height: 20px;
padding: 5px;
outline: none;
}
}
}
.m-map .search {
position: absolute;
top: 10px;
left: 10px;
width: 285px;
z-index: 1;
}
.m-map .search input {
width: 180px;
border: 1px solid #ccc;
line-height: 20px;
padding: 5px;
outline: none;
}
</style>
<template>
<el-card class="detail">
<!-- 状态区域 -->
<el-card class="state">
<h2 class="some_state">{{ status }}</h2>
<h2
class="some_state"
style="margin-left:20px"
>{{ onlineStatus }}</h2>
<span class="update_time">上次更新时间:{{ goodsObj.update_time }}</span>
<span>创建时间:{{ goodsObj.create_time }}</span>
</el-card>
<!-- 基本信息 -->
<el-card class="message_border">
<section class="message">
<!-- 商品列表修改区 -->
<section class="width50p">
<el-form
label-position="left"
label-width="140px"
>
<h3>基本信息</h3>
<el-form-item label="生活号名称:">
<!-- <el-input
<el-card class="detail">
<!-- 状态区域 -->
<el-card class="state">
<h2 class="some_state">{{ status }}</h2>
<h2 class="some_state" style="margin-left: 20px">{{ onlineStatus }}</h2>
<span class="update_time">上次更新时间:{{ goodsObj.update_time }}</span>
<span>创建时间:{{ goodsObj.create_time }}</span>
</el-card>
<!-- 基本信息 -->
<el-card class="message_border">
<section class="message">
<!-- 商品列表修改区 -->
<section class="width50p">
<el-form label-position="left" label-width="140px">
<h3>基本信息</h3>
<el-form-item label="生活号名称:">
<!-- <el-input
v-if="$route.params.operation === 'EDIT'"
disabled
:readonly="true"
v-model="goodsObj.life_account_name"
></el-input> -->
<span>{{ goodsObj.life_account_name }}</span>
</el-form-item>
<el-form-item label="生活号类型:">
<!-- <el-select
<span>{{ goodsObj.life_account_name }}</span>
</el-form-item>
<el-form-item label="生活号类型:">
<!-- <el-select
aria-readonly="true"
disabled
v-if="$route.params.operation === 'EDIT'"
......@@ -43,84 +37,84 @@
:value="item.value"
></el-option>
</el-select> -->
<span v-if="goodsObj.life_account_type === 1">个人生活号</span>
<span v-if="goodsObj.life_account_type === 2">企业生活号</span>
</el-form-item>
<el-form-item label="生活号认证状态:">
<span v-if="goodsObj.life_account_auth_status === 1">未认证</span>
<span v-if="goodsObj.life_account_auth_status === 2">已认证</span>
</el-form-item>
<el-form-item label="商品id:">
<!-- <el-input
<span v-if="goodsObj.life_account_type === 1">个人生活号</span>
<span v-if="goodsObj.life_account_type === 2">企业生活号</span>
</el-form-item>
<el-form-item label="生活号认证状态:">
<span v-if="goodsObj.life_account_auth_status === 1">未认证</span>
<span v-if="goodsObj.life_account_auth_status === 2">已认证</span>
</el-form-item>
<el-form-item label="商品id:">
<!-- <el-input
v-if="$route.params.operation === 'EDIT'"
v-model="goodsObj.goods_spu_id"
></el-input> -->
<span>{{ goodsObj.goods_spu_id }}</span>
</el-form-item>
<el-form-item label="商品名称:">
<el-input
maxlength="50"
show-word-limit
v-if="$route.params.operation === 'EDIT'"
v-model="goodsObj.goods_name"
@input="checkHaveExpression"
@blur="checkSameName"
></el-input>
<span v-else>{{ goodsObj.goods_name }}</span>
</el-form-item>
<el-form-item label="分类:">
<el-cascader
:disabled="$route.params.operation !== 'EDIT'"
v-model="optionsValue"
class="options"
:options="optionList"
:props="optionsProps"
@change="optionsChange"
clearable
></el-cascader>
</el-form-item>
<el-form-item label="说明:">
<el-input
v-if="$route.params.operation === 'EDIT'"
type="textarea"
maxlength="50"
show-word-limit
:autosize="{ minRows: 4 }"
v-model="goodsObj.desc"
></el-input>
<span v-else>{{ goodsObj.desc }}</span>
</el-form-item>
</el-form>
</section>
<!-- 商品详情图 -->
<section class="width50p">
<h4 style="margin-bottom:20px">商品详情图</h4>
<el-upload
:data="{ type: 1 }"
:action="uploadUrl"
:on-preview="previewImage"
:on-success="handleDetailSuccess"
:before-remove="removeDetailFiles"
:file-list="descPicUrlList"
auto-upload
:disabled="$route.params.operation !== 'EDIT'"
ref="detailUpload"
:limit="9"
list-type="picture-card"
multiple
>
<template #default>
<i class="el-icon-plus"></i>
</template>
</el-upload>
</section>
</section>
</el-card>
<!-- 商品详情 -->
<el-card class="message_border">
<h3>商品详情</h3>
<section class="message">
<!-- <section class="width50p">
<span>{{ goodsObj.goods_spu_id }}</span>
</el-form-item>
<el-form-item label="商品名称:">
<el-input
maxlength="50"
show-word-limit
v-if="$route.params.operation === 'EDIT'"
v-model="goodsObj.goods_name"
@input="checkHaveExpression"
@blur="checkSameName"
></el-input>
<span v-else>{{ goodsObj.goods_name }}</span>
</el-form-item>
<el-form-item label="分类:">
<el-cascader
:disabled="$route.params.operation !== 'EDIT'"
v-model="optionsValue"
class="options"
:options="optionList"
:props="optionsProps"
@change="optionsChange"
clearable
></el-cascader>
</el-form-item>
<el-form-item label="说明:">
<el-input
v-if="$route.params.operation === 'EDIT'"
type="textarea"
maxlength="50"
show-word-limit
:autosize="{ minRows: 4 }"
v-model="goodsObj.desc"
></el-input>
<span v-else>{{ goodsObj.desc }}</span>
</el-form-item>
</el-form>
</section>
<!-- 商品详情图 -->
<section class="width50p">
<h4 style="margin-bottom: 20px">商品详情图</h4>
<el-upload
:data="{ type: 1 }"
:action="uploadUrl"
:on-preview="previewImage"
:on-success="handleDetailSuccess"
:before-remove="removeDetailFiles"
:file-list="descPicUrlList"
auto-upload
:disabled="$route.params.operation !== 'EDIT'"
ref="detailUpload"
:limit="9"
list-type="picture-card"
multiple
>
<template #default>
<i class="el-icon-plus"></i>
</template>
</el-upload>
</section>
</section>
</el-card>
<!-- 商品详情 -->
<el-card class="message_border">
<h3>商品详情</h3>
<section class="message">
<!-- <section class="width50p">
<h4>套餐商品</h4>
<el-table>
<el-table-column
......@@ -141,27 +135,27 @@
></el-table-column>
</el-table>
</section> -->
<section class="width50p">
<h4 style="margin-bottom:20px">商品介绍图</h4>
<el-upload
:data="{ type: 1 }"
:disabled="$route.params.operation !== 'EDIT'"
:action="uploadUrl"
auto-upload
:limit="9"
:on-preview="previewImage"
list-type="picture-card"
multiple
ref="intrUpload"
:on-success="introduceSuccess"
:before-remove="intrRemove"
:file-list="introducePicUrlList"
>
<template #default>
<i class="el-icon-plus"></i>
</template>
</el-upload>
<!-- <h4 style="margin-top:20px">商品介绍:</h4>
<section class="width50p">
<h4 style="margin-bottom: 20px">商品介绍图</h4>
<el-upload
:data="{ type: 1 }"
:disabled="$route.params.operation !== 'EDIT'"
:action="uploadUrl"
auto-upload
:limit="9"
:on-preview="previewImage"
list-type="picture-card"
multiple
ref="intrUpload"
:on-success="introduceSuccess"
:before-remove="intrRemove"
:file-list="introducePicUrlList"
>
<template #default>
<i class="el-icon-plus"></i>
</template>
</el-upload>
<!-- <h4 style="margin-top:20px">商品介绍:</h4>
<el-input
v-if="$route.params.operation === 'EDIT'"
type="textarea"
......@@ -171,1169 +165,976 @@
show-word-limit
></el-input>
<span v-else>{{ goodsObj.introduce }}</span> -->
</section>
</section>
</el-card>
<!-- 可用门店 -->
<el-card class="message_border">
<section class="message">
<section class="width50p">
<h3>可用门店</h3>
<el-table :data="goodsObj.sub_shop">
<el-table-column
label="门店名称"
align="center"
prop="shop_name"
></el-table-column>
<el-table-column
label="联系电话"
align="center"
prop="phone"
></el-table-column>
<el-table-column
label="地址"
align="center"
prop="address"
></el-table-column>
<el-table-column
label="地理定位"
align="center"
>
<template #default="scope">
<span>经度:{{ scope.row.longitude }}</span>
<br />
<span>纬度:{{ scope.row.latitude }}</span>
</template>
</el-table-column>
<el-table-column
v-if="$route.params.operation === 'EDIT'"
label="操作"
align="center"
fixed="right"
>
<template #default="scope">
<el-button
type="text"
@click="deleteShops(scope.row.sub_shop_id)"
>删除
</el-button>
</template>
</el-table-column>
</el-table>
<el-popover
v-if="$route.params.operation === 'EDIT'"
placement="bottom"
:width="800"
trigger="click"
v-model:visible="shopListShow"
>
<template #reference>
<el-button
@click="getShops"
type="primary"
style="border-radius:20px;margin:20px 0 0 50%;transform: translate(-50%,0);"
>门店列表
</el-button>
</template>
<!-- 门店列表 -->
<el-table
ref="shopListRef"
:data="shopsList"
@selection-change="handleShopsChange"
row-key="sub_shop_id"
>
<!-- :selectable="canChooseShop"↓ -->
<el-table-column
type="selection"
width="55"
aria-checked="true"
:reserve-selection="true"
>
</el-table-column>
<el-table-column
align="center"
prop="shop_name"
label="门店名称"
></el-table-column>
<el-table-column
align="center"
prop="phone"
label="联系电话"
></el-table-column>
<el-table-column
align="center"
prop="address"
label="地址"
></el-table-column>
<el-table-column
align="center"
label="地理定位"
>
<template #default="scope">
<span>经度:{{ scope.row.longitude }}</span>
<br />
<span>纬度:{{ scope.row.latitude }}</span>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<el-pagination
style="margin-top:20px;"
background
@current-change="changeShopListPage"
v-model:currentPage="shopCurrentPage"
:page-size="5"
layout="total, prev, pager, next"
:total="shopsCount"
>
</el-pagination>
<section style="display:flex;justify-content:center;">
<el-button
type="primary"
style="border-radius:20px;"
@click="handleChooseShops"
>确定</el-button>
<!-- 添加门店弹窗 -->
<el-popover
placement="bottom"
:width="600"
trigger="click"
:visible="addShopShow"
>
<template #reference>
<el-button
@click="addShopShow = true"
type="primary"
style="border-radius:20px;"
>添加门店
</el-button>
</template>
<!-- 添加门店表单 -->
<el-form
label-position="right"
label-width="100px"
:model="shopForm"
>
<el-form-item label="门店名称:">
<el-input
v-model="shopForm.shop_name"
maxlength="20"
show-word-limit
></el-input>
</el-form-item>
<el-form-item label="联系电话:">
<el-input
v-model="shopForm.connect_phone"
maxlength="11"
show-word-limit
></el-input>
</el-form-item>
<el-form-item label="地址:">
<el-input v-model="shopForm.address"></el-input>
</el-form-item>
<el-form-item
label="地理定位:"
class="deep_place"
>
<el-input v-model="shopForm.deep_place"></el-input>
<a
style=""
target="_blank"
href="https://lbs.amap.com/tools/picker"
>高德获取定位</a>
</el-form-item>
</el-form>
<section style="display:flex;justify-content:center;">
<el-button
type="primary"
@click="addShop"
>保存</el-button>
<el-button @click="closeAddShops">取消</el-button>
</section>
</el-popover>
</section>
</el-popover>
</section>
<section class="width50p">
<h4 style="margin-bottom:20px">价格信息</h4>
<el-form label-width="100px">
<!-- <el-form-item label="秒杀价">
</el-card>
<!-- 可用门店 -->
<el-card class="message_border">
<section class="message">
<section class="width50p">
<h3>可用门店</h3>
<el-table :data="goodsObj.sub_shop">
<el-table-column label="门店名称" align="center" prop="shop_name"></el-table-column>
<el-table-column label="联系电话" align="center" prop="phone"></el-table-column>
<el-table-column label="地址" align="center" prop="address"></el-table-column>
<el-table-column label="地理定位" align="center">
<template #default="scope">
<span>经度:{{ scope.row.longitude }}</span>
<br />
<span>纬度:{{ scope.row.latitude }}</span>
</template>
</el-table-column>
<el-table-column v-if="$route.params.operation === 'EDIT'" label="操作" align="center" fixed="right">
<template #default="scope">
<el-button type="text" @click="deleteShops(scope.row.sub_shop_id)">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-popover
v-if="$route.params.operation === 'EDIT'"
placement="bottom"
:width="800"
trigger="click"
v-model:visible="shopListShow"
>
<template #reference>
<el-button
@click="getShops"
type="primary"
style="border-radius: 20px; margin: 20px 0 0 50%; transform: translate(-50%, 0)"
>
门店列表
</el-button>
</template>
<!-- 门店列表 -->
<el-table ref="shopListRef" :data="shopsList" @selection-change="handleShopsChange" row-key="sub_shop_id">
<!-- :selectable="canChooseShop"↓ -->
<el-table-column type="selection" width="55" aria-checked="true" :reserve-selection="true"></el-table-column>
<el-table-column align="center" prop="shop_name" label="门店名称"></el-table-column>
<el-table-column align="center" prop="phone" label="联系电话"></el-table-column>
<el-table-column align="center" prop="address" label="地址"></el-table-column>
<el-table-column align="center" label="地理定位">
<template #default="scope">
<span>经度:{{ scope.row.longitude }}</span>
<br />
<span>纬度:{{ scope.row.latitude }}</span>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<el-pagination
style="margin-top: 20px"
background
@current-change="changeShopListPage"
v-model:currentPage="shopCurrentPage"
:page-size="5"
layout="total, prev, pager, next"
:total="shopsCount"
></el-pagination>
<section style="display: flex; justify-content: center">
<el-button type="primary" style="border-radius: 20px" @click="handleChooseShops">确定</el-button>
<!-- 添加门店弹窗 -->
<el-popover placement="bottom" :width="600" trigger="click" :visible="addShopShow">
<template #reference>
<el-button @click="addShopShow = true" type="primary" style="border-radius: 20px">添加门店</el-button>
</template>
<!-- 添加门店表单 -->
<el-form label-position="right" label-width="100px" :model="shopForm">
<el-form-item label="门店名称:">
<el-input v-model="shopForm.shop_name" maxlength="20" show-word-limit></el-input>
</el-form-item>
<el-form-item label="联系电话:">
<el-input v-model="shopForm.connect_phone" maxlength="11" show-word-limit></el-input>
</el-form-item>
<el-form-item label="地址:">
<el-input v-model="shopForm.address"></el-input>
</el-form-item>
<el-form-item label="地理定位:" class="deep_place">
<el-input v-model="shopForm.deep_place"></el-input>
<a style="" target="_blank" href="https://lbs.amap.com/tools/picker">高德获取定位</a>
</el-form-item>
</el-form>
<section style="display: flex; justify-content: center">
<el-button type="primary" @click="addShop">保存</el-button>
<el-button @click="closeAddShops">取消</el-button>
</section>
</el-popover>
</section>
</el-popover>
</section>
<section class="width50p">
<h4 style="margin-bottom: 20px">价格信息</h4>
<el-form label-width="100px">
<!-- <el-form-item label="秒杀价">
<el-input
:readonly="true"
disabled
></el-input>
</el-form-item> -->
<el-form-item label="售价">
<el-input
v-if="$route.params.operation === 'EDIT'"
v-model="goodsObj.price"
@change="salePrice"
></el-input>
<span v-else>{{ goodsObj.price }}</span>
</el-form-item>
<el-form-item label="原价">
<el-input
v-if="$route.params.operation === 'EDIT'"
v-model="goodsObj.original_price"
@change="perPrice"
></el-input>
<span v-else>{{ goodsObj.original_price }}</span>
</el-form-item>
<el-form-item label="结算价">
<!-- oninput="value=value.toString().match(/^\d+(?:\.\d{0,2})?/)" -->
<el-input
oninput="value=value.toString().match(/^\d+(?:\.\d{0,2})?/)"
@input="changeValue($event, 'clear_price')"
v-if="$route.params.operation === 'EDIT'"
v-model="goodsObj.clear_price"
@change="perPrice"
></el-input>
<span v-else>{{ goodsObj.clear_price }}</span>
</el-form-item>
<h4 style="margin:20px 0">库存信息</h4>
<el-form-item label="剩余库存量:">
<span>{{ goodsObj.inventory_rest }}</span>
</el-form-item>
<el-form-item label="库存增减:">
<el-input-number
v-if="$route.params.operation === 'EDIT'"
v-model="inventoryAdd"
@change="hasNumberChange"
:precision="0"
></el-input-number>
<span v-else>{{ goodsObj.inventory_rest }}</span>
</el-form-item>
<el-form-item label="已下单量:">
<span>{{ goodsObj.total_amount_order }}</span>
</el-form-item>
<el-form-item label="已卖出总数:">
<span>{{ goodsObj.total_amount_sold }}</span>
</el-form-item>
<el-form-item label="总库存量:">
<span>{{ goodsObj.inventory_total }}</span>
</el-form-item>
</el-form>
<el-form-item label="售价">
<el-input v-if="$route.params.operation === 'EDIT'" v-model="goodsObj.price" @change="salePrice"></el-input>
<span v-else>{{ goodsObj.price }}</span>
</el-form-item>
<el-form-item label="原价">
<el-input v-if="$route.params.operation === 'EDIT'" v-model="goodsObj.original_price" @change="perPrice"></el-input>
<span v-else>{{ goodsObj.original_price }}</span>
</el-form-item>
<el-form-item label="结算价">
<!-- oninput="value=value.toString().match(/^\d+(?:\.\d{0,2})?/)" -->
<el-input
oninput="value=value.toString().match(/^\d+(?:\.\d{0,2})?/)"
@input="changeValue($event, 'clear_price')"
v-if="$route.params.operation === 'EDIT'"
v-model="goodsObj.clear_price"
@change="perPrice"
></el-input>
<span v-else>{{ goodsObj.clear_price }}</span>
</el-form-item>
<h4 style="margin: 20px 0">库存信息</h4>
<el-form-item label="剩余库存量:">
<span>{{ goodsObj.inventory_rest }}</span>
</el-form-item>
<el-form-item label="库存增减:">
<el-input-number
v-if="$route.params.operation === 'EDIT'"
v-model="inventoryAdd"
@change="hasNumberChange"
:precision="0"
></el-input-number>
<span v-else>{{ goodsObj.inventory_rest }}</span>
</el-form-item>
<el-form-item label="已下单量:">
<span>{{ goodsObj.total_amount_order }}</span>
</el-form-item>
<el-form-item label="已卖出总数:">
<span>{{ goodsObj.total_amount_sold }}</span>
</el-form-item>
<el-form-item label="总库存量:">
<span>{{ goodsObj.inventory_total }}</span>
</el-form-item>
</el-form>
</section>
</section>
</el-card>
<!-- 使用规则 -->
<el-card class="message_border">
<h3 style="margin-bottom: 30px">使用规则</h3>
<el-form style="width: 480px" :model="rulesForm" label-position="left" label-width="120px">
<el-form-item label="单人可买上限:">
<el-input-number
v-if="$route.params.operation === 'EDIT'"
:min="0"
:precision="0"
v-model="goodsObj.rule_limit"
@change="handleLimitChange"
@blur="handleLimitChange"
></el-input-number>
<span v-else>{{ goodsObj.rule_limit }}</span>
</el-form-item>
<el-form-item label="退款规则:">
<el-select
v-if="$route.params.operation === 'EDIT'"
v-model="goodsObj.rule_refund"
placeholder="请选择"
:disabled="goodsObj.audit_status === 1"
>
<el-option v-for="item in rulesForm.rulesOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
</el-select>
<span v-else-if="$route.params.operation !== 'EDIT' && goodsObj.rule_refund === 1">到期后自动退款</span>
<span v-else-if="$route.params.operation !== 'EDIT' && goodsObj.rule_refund === 2">购买后不允许退款</span>
<span v-else-if="$route.params.operation !== 'EDIT' && goodsObj.rule_refund === 3">到期后不退款</span>
</el-form-item>
<el-form-item label="使用日期:">
<el-radio-group v-model="goodsObj.rule_date_type" v-if="$route.params.operation === 'EDIT'">
<el-radio :label="1">周末、节假日通用</el-radio>
<el-radio :label="2">仅工作日可用</el-radio>
</el-radio-group>
<span v-else-if="$route.params.operation !== 'EDIT' && goodsObj.rule_date_type === 1">周末、节假日通用</span>
<span v-else-if="$route.params.operation !== 'EDIT' && goodsObj.rule_date_type === 2">仅工作日可用</span>
</el-form-item>
<el-form-item label="使用开始时间:">
<el-time-picker
arrow-control
v-if="$route.params.operation === 'EDIT'"
v-model="rulesForm.useStartTime"
@change="pickerStartTime"
></el-time-picker>
<span v-else>{{ goodsObj.rule_start_time }}</span>
</el-form-item>
<el-form-item label="使用结束时间:">
<el-time-picker
arrow-control
v-if="$route.params.operation === 'EDIT'"
v-model="rulesForm.useEndTime"
@change="pickerEndTime"
></el-time-picker>
<span v-else>{{ goodsObj.rule_end_time }}</span>
</el-form-item>
<el-form-item label="过期时间">
<el-date-picker
v-if="$route.params.operation === 'EDIT'"
:disabledDate="disableExpirDate"
v-model="expirationTime"
type="datetime"
@change="expirDateChange"
placeholder="选择日期时间"
></el-date-picker>
<span v-else>{{ expirationTime }}</span>
</el-form-item>
<el-form-item label="使用规则:">
<el-input
v-if="$route.params.operation === 'EDIT'"
type="textarea"
maxlength="100"
:autosize="{ minRows: 4 }"
show-word-limit
v-model="goodsObj.rule_desc"
></el-input>
<span v-else>{{ goodsObj.rule_desc }}</span>
</el-form-item>
</el-form>
</el-card>
<!-- 操作记录 -->
<el-card class="message_border">
<h3 style="margin-bottom: 30px">操作记录</h3>
<el-table border stripe :data="recordLits">
<el-table-column label="状态" prop="state" align="center">
<template #default="scope">
<span v-if="scope.row.status === 0">待审核</span>
<span v-else-if="scope.row.status === 1">审核通过</span>
<span v-else>审核失败</span>
&nbsp;&nbsp;&nbsp;
<span v-if="scope.row.online_status === 0">未上架</span>
<span v-else-if="scope.row.online_status === 1">已上架</span>
<span v-else>已下架</span>
</template>
</el-table-column>
<el-table-column label="操作者" prop="operator_name" align="center"></el-table-column>
<el-table-column label="更新时间" prop="create_time" align="center"></el-table-column>
<el-table-column label="更新描述" prop="note" align="center"></el-table-column>
</el-table>
</el-card>
<!-- 审核保存返回 -->
<section class="operationButton">
<el-button type="primary" v-if="$route.params.operation === 'AUDIT'" @click="onSuccess">通过</el-button>
<el-popover v-if="$route.params.operation === 'AUDIT'" placement="top" :width="600" trigger="click" v-model:visible="rejectVisible">
<template #reference>
<el-button type="danger">驳回</el-button>
</template>
<el-form :model="rejectReason">
<el-form-item label="驳回原因:">
<el-input show-word-limit :maxlength="200" type="textarea" style="width: 100%" v-model.trim="rejectReason.reason"></el-input>
</el-form-item>
</el-form>
<section style="display: flex; justify-content: center">
<el-button type="danger" @click="onDefault">驳回</el-button>
<el-button type="primary" @click="rejectVisible = false">取消</el-button>
</section>
</el-popover>
<el-button v-if="$route.params.operation === 'EDIT'" type="primary" @click="saveDetailMessage">保存</el-button>
<el-button @click="backToDetail">返回</el-button>
</section>
</section>
</el-card>
<!-- 使用规则 -->
<el-card class="message_border">
<h3 style="margin-bottom:30px;">使用规则</h3>
<el-form
style="width:480px"
:model="rulesForm"
label-position="left"
label-width="120px"
>
<el-form-item label="单人可买上限:">
<el-input-number
v-if="$route.params.operation === 'EDIT'"
:min="0"
:precision="0"
v-model="goodsObj.rule_limit"
@change="handleLimitChange"
@blur="handleLimitChange"
></el-input-number>
<span v-else>{{ goodsObj.rule_limit }}</span>
</el-form-item>
<el-form-item label="退款规则:">
<el-select
v-if="$route.params.operation === 'EDIT'"
v-model="goodsObj.rule_refund"
placeholder="请选择"
:disabled="goodsObj.audit_status===1"
>
<el-option
v-for="item in rulesForm.rulesOptions"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
<span v-else-if="
$route.params.operation !== 'EDIT' && goodsObj.rule_refund === 1
">到期后自动退款</span>
<span v-else-if="
$route.params.operation !== 'EDIT' && goodsObj.rule_refund === 2
">购买后不允许退款</span>
<span v-else-if="
$route.params.operation !== 'EDIT' && goodsObj.rule_refund === 3
">到期后不退款</span>
</el-form-item>
<el-form-item label="使用日期:">
<el-radio-group
v-model="goodsObj.rule_date_type"
v-if="$route.params.operation === 'EDIT'"
>
<el-radio :label="1">周末、节假日通用</el-radio>
<el-radio :label="2">仅工作日可用</el-radio>
</el-radio-group>
<span v-else-if="
$route.params.operation !== 'EDIT' &&
goodsObj.rule_date_type === 1
">周末、节假日通用</span>
<span v-else-if="
$route.params.operation !== 'EDIT' &&
goodsObj.rule_date_type === 2
">仅工作日可用</span>
</el-form-item>
<el-form-item label="使用开始时间:">
<el-time-picker
arrow-control
v-if="$route.params.operation === 'EDIT'"
v-model="rulesForm.useStartTime"
@change="pickerStartTime"
>
</el-time-picker>
<span v-else>{{ goodsObj.rule_start_time }}</span>
</el-form-item>
<el-form-item label="使用结束时间:">
<el-time-picker
arrow-control
v-if="$route.params.operation === 'EDIT'"
v-model="rulesForm.useEndTime"
@change="pickerEndTime"
>
</el-time-picker>
<span v-else>{{ goodsObj.rule_end_time }}</span>
</el-form-item>
<el-form-item label="过期时间">
<el-date-picker
v-if="$route.params.operation === 'EDIT'"
:disabledDate="disableExpirDate"
v-model="expirationTime"
type="datetime"
@change="expirDateChange"
placeholder="选择日期时间"
>
</el-date-picker>
<span v-else>{{ expirationTime }}</span>
</el-form-item>
<el-form-item label="使用规则:">
<el-input
v-if="$route.params.operation === 'EDIT'"
type="textarea"
maxlength="100"
:autosize="{ minRows: 4 }"
show-word-limit
v-model="goodsObj.rule_desc"
></el-input>
<span v-else>{{ goodsObj.rule_desc }}</span>
</el-form-item>
</el-form>
</el-card>
<!-- 操作记录 -->
<el-card class="message_border">
<h3 style="margin-bottom:30px;">操作记录</h3>
<el-table
border
stripe
:data="recordLits"
>
<el-table-column
label="状态"
prop="state"
align="center"
>
<template #default="scope">
<span v-if="scope.row.status === 0">待审核</span>
<span v-else-if="scope.row.status === 1">审核通过</span>
<span v-else>审核失败</span>
&nbsp;&nbsp;&nbsp;
<span v-if="scope.row.online_status === 0">未上架</span>
<span v-else-if="scope.row.online_status === 1">已上架</span>
<span v-else>已下架</span>
</template>
</el-table-column>
<el-table-column
label="操作者"
prop="operator_name"
align="center"
></el-table-column>
<el-table-column
label="更新时间"
prop="create_time"
align="center"
></el-table-column>
<el-table-column
label="更新描述"
prop="note"
align="center"
></el-table-column>
</el-table>
</el-card>
<!-- 审核保存返回 -->
<section class="operationButton">
<el-button
type="primary"
v-if="$route.params.operation === 'AUDIT'"
@click="onSuccess"
>通过
</el-button>
<el-popover
v-if="$route.params.operation === 'AUDIT'"
placement="top"
:width="600"
trigger="click"
v-model:visible="rejectVisible"
>
<template #reference>
<el-button type="danger">驳回</el-button>
</template>
<el-form :model="rejectReason">
<el-form-item label="驳回原因:">
<el-input
show-word-limit
:maxlength="200"
type="textarea"
style="width:100%"
v-model.trim="rejectReason.reason"
></el-input>
</el-form-item>
</el-form>
<section style="display:flex;justify-content:center;">
<el-button
type="danger"
@click="onDefault"
>驳回</el-button>
<el-button
type="primary"
@click="rejectVisible = false"
>取消
</el-button>
</section>
</el-popover>
<el-button
v-if="$route.params.operation === 'EDIT'"
type="primary"
@click="saveDetailMessage"
>保存
</el-button>
<el-button @click="backToDetail">返回</el-button>
</section>
</el-card>
<!-- 展示缩略图 -->
<el-dialog
width="40%"
v-model="isShowPopver"
>
<el-image
:src="popoverImage"
fit="fill"
style="width:100%"
></el-image>
</el-dialog>
<!-- 展示缩略图 -->
<el-dialog width="40%" v-model="isShowPopver">
<el-image :src="popoverImage" fit="fill" style="width: 100%"></el-image>
</el-dialog>
</template>
<style lang="less" src="./index.less" scope></style>
<script>
import {
getGoodsInfo,
getGoodsList,
postSuccess,
auditReject,
checkGoodsName,
getShopsList,
postAddShop,
editGoods
} from "@/service/Goods/goods";
import { GOODS_URI } from "../../../../server/config.js";
import filterInput from "../utils/filterInput";
export default {
name: "GoodsDetail",
beforeRouteEnter (to, from, next) {
if (!to.params.operation) {
next({ name: "GoodsList" });
} else if (!to.params.spuId) {
next({ name: "GoodsList" });
} else {
next();
}
},
created () {
this.getOptions();
this.getGoodsDetailList(this.$route.params.spuId);
},
computed: {
// 审核状态
status () {
if (this.goodsObj.audit_status === 0) {
return "待审核";
} else if (this.goodsObj.audit_status === 1) {
return "审核通过";
} else {
return "审核驳回";
}
},
// 上下架状态
onlineStatus () {
if (this.goodsObj.online_status === 0) {
return "未上架";
} else if (this.goodsObj.online_status === 1) {
return "已上架";
} else {
return "已下架";
}
}
},
watch: {
goodsObj (val) {
this.optionsValue = [val.category_1_id, val.category_2_id];
this.rulesForm.useStartTime = this.formatDate(val.rule_start_time);
this.rulesForm.useEndTime = this.formatDate(val.rule_end_time);
console.log(val.original_price);
this.goodsObj.original_price = Number(val.original_price)
if (!val.original_price) {
this.$nextTick(() => {
this.goodsObj.original_price = "";
})
}
},
rejectVisible (val) {
if (!val) {
this.rejectReason.reason = "";
}
},
},
data () {
return {
// 商品分类选项
optionsProps: {
value: "category_id",
label: "name",
children: "sub_list"
},
lifeList: [
{ value: 1, options: "个人生活号" },
{ value: 2, options: "企业生活号" }
],
optionList: [], // 商品分类选项
optionsValue: [], // 商品分类的值
// 商品回显信息
goodsObj: {
introduce: "" // 商品介绍
},
inventoryAdd: 0, // 库存增减
originalGoodsName: "", // 原商品名
isGoodsNameRepeat: false, // 商品名称是否重复
descPicUrlList: [], // 商品详情图回显列表
introducePicUrlList: [], // 商品介绍图回显列表
recordList: [], // 提交记录
detailUploadList: [], // 上传详情图片列表
introduceUploadList: [], // 上传详情图片列表
inventoryNumber: 0, // 库存数量
isAllowStockChange: true, // 是否允许更改库存
// 使用规则表单
rulesForm: {
// 退款选项
rulesOptions: [
{ value: 1, label: "到期自动退款" },
{ value: 2, label: "购买后不允许退款" },
{ value: 3, label: "到期后不退款" }
],
useStartTime: "", // 使用开始时间
useEndTime: "", // 使用结束时间
rule_desc: "" // 使用描述
},
// 操作记录列表
recordLits: [],
// 驳回原因表单
rejectReason: {
reason: ""
},
shopsList: [], // 门店列表
shopListShow: false, // 门店列表是否展示
shopId: [], // 门店id数组
chooseShopsList: [], // 已选门店列表
shopsCount: 0,
shopCurrentPage: 1, // 门店列表当前页
// 新增门店表单
shopForm: {
shop_name: "",
connect_phone: "",
address: "",
deep_place: ""
},
shopList: [], // 门店列表
addShopDialog: false, // 添加门店弹框
showShopDialog: false, // 是否展示门店列表
popoverImage: "", // 放大显示图
rejectVisible: false, // 驳回原因弹框展示状态
isShowPopver: false, // 是否展示图片框
activeStartTime: "", // 活动开始时间
activeEndTime: "", // 活动结束时间
uploadUrl: `${GOODS_URI}/ksy/ks3apiunencrypt/ks3api_upload`, // 金山云上传地址
addShopShow: false, // 添加门店弹框显示
expirationTime: "", // 过期时间
shopIds: "" // 已选商店id
import {
getGoodsInfo,
getGoodsList,
postSuccess,
auditReject,
checkGoodsName,
getShopsList,
postAddShop,
editGoods,
} from "@/service/Goods/goods";
import { UploadPicUrl } from "@/utils/util";
import filterInput from "../utils/filterInput";
export default {
name: "GoodsDetail",
beforeRouteEnter(to, from, next) {
if (!to.params.operation) {
next({ name: "GoodsList" });
} else if (!to.params.spuId) {
next({ name: "GoodsList" });
} else {
next();
}
},
created() {
this.getOptions();
this.getGoodsDetailList(this.$route.params.spuId);
},
computed: {
// 审核状态
status() {
if (this.goodsObj.audit_status === 0) {
return "待审核";
} else if (this.goodsObj.audit_status === 1) {
return "审核通过";
} else {
return "审核驳回";
}
},
// 上下架状态
onlineStatus() {
if (this.goodsObj.online_status === 0) {
return "未上架";
} else if (this.goodsObj.online_status === 1) {
return "已上架";
} else {
return "已下架";
}
},
},
watch: {
goodsObj(val) {
this.optionsValue = [val.category_1_id, val.category_2_id];
this.rulesForm.useStartTime = this.formatDate(val.rule_start_time);
this.rulesForm.useEndTime = this.formatDate(val.rule_end_time);
console.log(val.original_price);
this.goodsObj.original_price = Number(val.original_price);
if (!val.original_price) {
this.$nextTick(() => {
this.goodsObj.original_price = "";
});
}
},
rejectVisible(val) {
if (!val) {
this.rejectReason.reason = "";
}
},
},
data() {
return {
// 商品分类选项
optionsProps: {
value: "category_id",
label: "name",
children: "sub_list",
},
lifeList: [
{ value: 1, options: "个人生活号" },
{ value: 2, options: "企业生活号" },
],
optionList: [], // 商品分类选项
optionsValue: [], // 商品分类的值
// 商品回显信息
goodsObj: {
introduce: "", // 商品介绍
},
inventoryAdd: 0, // 库存增减
originalGoodsName: "", // 原商品名
isGoodsNameRepeat: false, // 商品名称是否重复
descPicUrlList: [], // 商品详情图回显列表
introducePicUrlList: [], // 商品介绍图回显列表
recordList: [], // 提交记录
detailUploadList: [], // 上传详情图片列表
introduceUploadList: [], // 上传详情图片列表
inventoryNumber: 0, // 库存数量
isAllowStockChange: true, // 是否允许更改库存
// 使用规则表单
rulesForm: {
// 退款选项
rulesOptions: [
{ value: 1, label: "到期自动退款" },
{ value: 2, label: "购买后不允许退款" },
{ value: 3, label: "到期后不退款" },
],
useStartTime: "", // 使用开始时间
useEndTime: "", // 使用结束时间
rule_desc: "", // 使用描述
},
// 操作记录列表
recordLits: [],
// 驳回原因表单
rejectReason: {
reason: "",
},
shopsList: [], // 门店列表
shopListShow: false, // 门店列表是否展示
shopId: [], // 门店id数组
chooseShopsList: [], // 已选门店列表
shopsCount: 0,
shopCurrentPage: 1, // 门店列表当前页
// 新增门店表单
shopForm: {
shop_name: "",
connect_phone: "",
address: "",
deep_place: "",
},
shopList: [], // 门店列表
addShopDialog: false, // 添加门店弹框
showShopDialog: false, // 是否展示门店列表
popoverImage: "", // 放大显示图
rejectVisible: false, // 驳回原因弹框展示状态
isShowPopver: false, // 是否展示图片框
activeStartTime: "", // 活动开始时间
activeEndTime: "", // 活动结束时间
uploadUrl: UploadPicUrl, // 金山云上传地址
addShopShow: false, // 添加门店弹框显示
expirationTime: "", // 过期时间
shopIds: "", // 已选商店id
};
},
methods: {
//结算价两位小数校验
// changeValue(value, level) {
// if (value && value.indexOf(".") !== value.length - 1 && (parseFloat(value)|| value==='0'))
// this.goodsObj[level] = parseFloat(value);
// else if (value && value.indexOf(".") === value.length - 1) return;
// else this.goodsObj[level] = "";
// },
// 获取级联选择商品列表
async getOptions() {
try {
const res = await getGoodsList();
if (res.code !== 0) return this.$message.error(res.reason);
this.optionList = res.result;
} catch (error) {
console.error(error);
}
},
// 获取详情列表
async getGoodsDetailList(params) {
try {
const res = await getGoodsInfo({ goods_spu_id: params });
if (res.code !== 0) {
return this.$message.error(res.reason);
}
console.log("商品详情列表", res);
const { goods_info, record_list } = res.result;
this.goodsObj = goods_info;
this.recordLits = record_list;
// 初始商品名称
this.originalGoodsName = goods_info.goods_name;
// 渲染过期时间
this.expirationTime = goods_info.expiration_time;
// 初始化门店id
this.shopId = goods_info.sub_shop.map((item) => {
return item.sub_shop_id;
});
this.shopIds = this.shopId.join(",");
// 初始化规则开始时间
this.activeStartTime = goods_info.rule_start_time;
// 初始化规则结束时间
this.activeEndTime = goods_info.rule_end_time;
// 回显图片
this.formatInitPicture(goods_info.desc_pic_url_list, this.descPicUrlList);
this.formatInitPicture(goods_info.introduce_pic_url_list, this.introducePicUrlList);
this.detailUploadList = this.formatUploadPictureList(goods_info.desc_pic_url);
this.introduceUploadList = this.formatUploadPictureList(goods_info.introduce_pic_url);
} catch (error) {
console.error(error);
}
},
// 初始化照片
formatInitPicture(pictureList, storeList) {
pictureList.forEach((element) => {
let obj = new Object();
obj.url = element;
storeList.push(obj);
});
},
// 初始化上传照片列表
formatUploadPictureList(fileStr) {
if (!fileStr) {
return [];
} else {
return fileStr.split(",");
}
},
// 上传图片的公共方法
uploadPicture(response, storageList) {
const responseURL = response.result.image_id;
storageList.push(responseURL);
},
// 删除图片的公共方法
deletePicture(file, fileList, storageList) {
for (let i = 0; i < fileList.length; i++) {
if (fileList[i].uid == file.uid) {
storageList.splice(i, 1);
}
}
},
// 格式化日期
formatDate(time) {
const nowTime = new Date();
const nowYear = nowTime.getFullYear();
const nowMonth = nowTime.getMonth() + 1;
const nowDate = nowTime.getDate();
const timeArray = time.split(":");
const Hour = parseInt(timeArray[0]);
const Minute = parseInt(timeArray[1]);
const Second = parseInt(timeArray[2]);
return new Date(nowYear, nowMonth, nowDate, Hour, Minute, Second);
},
// 检查输入是否带有表情符号
checkHaveExpression(value) {
if (!filterInput.checkString(value)) {
this.$nextTick(() => {
this.goodsObj.goods_name = "";
});
return this.$message.error("商品名称中不可有表情符号");
}
},
// 获取门店列表
async getShops() {
const query = {
life_account_id: this.goodsObj.life_account_id,
page: this.shopCurrentPage,
page_size: 5,
};
const res = await getShopsList(query);
if (res.code !== 0) return this.$message.error(res.reason);
console.log(res);
this.shopsList = res.result;
this.shopsCount = res.count;
this.$nextTick(() => {
this.shopsList.forEach((row) => {
if (this.shopId.indexOf(row.sub_shop_id) !== -1) {
this.$refs.shopListRef.toggleRowSelection(row, true);
} else {
this.$refs.shopListRef.toggleRowSelection(row, false);
}
});
});
},
// 删除已选择门店
deleteShops(subShopId) {
this.goodsObj.sub_shop = this.goodsObj.sub_shop.filter((item) => {
return item.sub_shop_id !== subShopId;
});
this.shopId = this.goodsObj.sub_shop.map((item) => {
return item.sub_shop_id;
});
this.shopIds = this.shopId.join(",");
},
// 门店列表更改时操作
handleShopsChange(value) {
this.chooseShopsList = [];
this.chooseShopsList = value;
console.log("已选择列表的长度", this.chooseShopsList.length);
const shopList = value.map((item) => {
return item.sub_shop_id;
});
this.shopIds = "";
this.shopIds = shopList.join(",");
},
// 商品列表换页
changeShopListPage(page) {
this.shopCurrentPage = page;
this.getShops();
},
// 确认选择的店铺
handleChooseShops() {
this.goodsObj.sub_shop = this.chooseShopsList;
this.shopId = this.goodsObj.sub_shop.map((item) => {
return item.sub_shop_id;
});
this.shopListShow = false;
},
// 添加新门店
async addShop() {
const deepPlace = this.shopForm.deep_place.split(",");
const longitude = deepPlace[0];
const latitude = deepPlace[1];
const query = {
life_account_id: this.goodsObj.life_account_id,
phone: this.shopForm.connect_phone,
shop_name: this.shopForm.shop_name,
longitude, // 经度
latitude, // 纬度
address: this.shopForm.address,
};
if (!query.shop_name) {
return this.$message.error("请填写门店名称");
}
if (!query.address) {
return this.$message.error("请填写门店地址");
}
if (!query.phone) {
return this.$message.error("请填写联系电话");
}
if (!query.longitude || !query.latitude) {
return this.$message.error("请填写地理定位");
}
if (!/([0-9]{3,4}-)?[0-9]{7,8}/.test(query.phone) && !/^[1][3,4,5,7,8,9][0-9]{9}$/.test(query.phone)) {
return this.$message.error("联系电话格式不正确");
}
const res = await postAddShop(query);
if (res.code !== 0) return this.$message.error(res.reason);
this.$message.success("添加门店成功!");
this.addShopShow = false;
},
// 是否可选门店
// canChooseShop (row) {
// if (
// this.chooseShopsList.length === 0 ||
// this.shopIds === row.sub_shop_id
// ) {
// return true;
// } else {
// return false;
// }
// },
// 取消新建门店
closeAddShops() {
this.shopForm.shop_name = "";
this.shopForm.address = "";
this.shopForm.connect_phone = "";
this.shopForm.deep_place = "";
this.addShopShow = false;
},
// 商品分类列表变化
optionsChange(value) {
this.optionsValue = value;
},
// 检查商品名称是否重复
async checkSameName() {
const res = await checkGoodsName({
life_account_id: this.goodsObj.life_account_id,
goods_name: this.goodsObj.goods_name,
goods_spu_id: this.goodsObj.goods_spu_id,
});
if (res.code !== 0) return this.$message.error(res.reason);
if (res.result.can_use) {
this.isGoodsNameRepeat = true;
} else if (this.originalGoodsName === this.goodsObj.goods_name) {
this.isGoodsNameRepeat = true;
} else {
this.isGoodsNameRepeat = false;
}
},
// 商品详情图上传成功时
handleDetailSuccess(res) {
console.log(res);
this.uploadPicture(res, this.detailUploadList);
},
// 商品详情图删除完成后的钩子
removeDetailFiles(file, fileList) {
this.deletePicture(file, fileList, this.detailUploadList);
},
// 商品介绍图上传成功钩子
introduceSuccess(res) {
this.uploadPicture(res, this.introduceUploadList);
},
// 商品介绍图删除后的钩子
intrRemove(file, fileList) {
this.deletePicture(file, fileList, this.introduceUploadList);
},
// 展示商品大图
previewImage(file) {
this.popoverImage = file.url;
this.isShowPopver = true;
},
// 库存增减更改
hasNumberChange() {
if (!this.inventoryAdd) {
this.$nextTick(() => {
this.inventoryAdd = 0;
});
}
if (this.inventoryAdd + this.goodsObj.inventory_rest < 1) {
this.$nextTick(() => {
this.isAllowStockChange = false;
});
return this.$message.error("剩余库存量不得小于1");
} else {
this.isAllowStockChange = true;
}
},
// 单人可购买上限的修改
handleLimitChange() {
if (!this.goodsObj.rule_limit) {
this.$nextTick(() => {
this.goodsObj.rule_limit = 0;
});
}
},
// 时间校验器
timePicker(time) {
let Hours = time.getHours() + "";
let Minutes = time.getMinutes() + "";
let Seconds = time.getSeconds() + "";
if (Hours < 10) {
Hours = "0" + Hours;
}
if (Minutes < 10) {
Minutes = "0" + Minutes;
}
if (Seconds < 10) {
Seconds = "0" + Seconds;
}
return `${Hours}:${Minutes}:${Seconds}`;
},
// 选择规则开始时间
pickerStartTime(time) {
this.activeStartTime = this.timePicker(time);
},
// 选择规则结束时间
pickerEndTime(time) {
this.activeEndTime = this.timePicker(time);
},
// 过期时间更改
expirDateChange(time) {
let YYYY = time.getFullYear();
let MM = time.getMonth() + 1;
let DD = time.getDate();
let HH = time.getHours();
let mm = time.getMinutes();
let ss = time.getSeconds();
if (MM < 10) {
MM = "0" + MM;
}
if (DD < 10) {
DD = "0" + DD;
}
if (HH < 10) {
HH = "0" + HH;
}
if (mm < 10) {
mm = "0" + mm;
}
if (ss < 10) {
ss = "0" + ss;
}
this.expirationTime = `${YYYY}-${MM}-${DD} ${HH}:${mm}:${ss}`;
},
// 禁用时间
disableExpirDate(time) {
const timeMs = time.getTime();
if (timeMs > Date.now() - 86400000) {
return false;
} else {
return true;
}
},
// 更改售价
salePrice() {
if (!this.goodsObj.price) {
this.$nextTick(() => {
this.goodsObj.price = "";
});
}
const parseFloatValue = Number(this.goodsObj.price).toFixed(2);
this.goodsObj.price = Number(parseFloatValue);
if (typeof this.goodsObj.price === "number" && isNaN(this.goodsObj.price)) {
this.goodsObj.price = "";
return this.$message.error("售价价格必须为数字");
}
},
// 更改原价
perPrice(val) {
let reg = /^\d+(\.\d{1,2})?$/;
if (!reg.test(val)) {
return this.$message.error("请输入两位小数");
}
if (val.length === 0) val = 0;
// const parseOriginalPrice = Number(val).toFixed(2);
// val = Number(parseOriginalPrice);
if (typeof val === "number" && isNaN(val)) {
val = 0;
return this.$message.error("原价价格必为数字");
}
const parseOriginalPrice = Number(this.goodsObj.original_price).toFixed(2);
this.goodsObj.original_price = Number(parseOriginalPrice);
// if (
// typeof this.goodsObj.original_price === "number" &&
// isNaN(this.goodsObj.original_price)
// ) {
// this.goodsObj.original_price = "";
// return this.$message.error("原价价格必为数字");
// }
},
// 审核通过
async onSuccess() {
const res = await postSuccess(this.$route.params.spuId);
if (res.code !== 0) return this.$message.error(res.reason);
this.$message.success("审核通过");
this.$router.replace({ name: "GoodsList" });
},
// 审核拒绝
async onDefault() {
const query = {
goods_spu_id: this.goodsObj.goods_spu_id,
rejected_reason: this.rejectReason.reason,
};
console.log(query.rejected_reason);
if (query.rejected_reason !== "0" && !query.rejected_reason) {
return this.$message.error("审核驳回时,审核原因不可为空");
}
const res = await auditReject(query);
if (res.code !== 0) {
return this.$message.error(res.reason);
}
this.$message.warning("审核驳回成功!");
this.$router.replace({ name: "GoodsList" });
},
// 返回主页面
backToDetail() {
this.$router.replace({ name: "GoodsList" });
},
// 保存修改信息
async saveDetailMessage() {
await this.checkSameName(); // 检验商品名称是否可用
if (!this.optionsValue) {
return this.$message.error("请选择商品分类");
}
const query = {
goods_spu_id: this.goodsObj.goods_spu_id, // 商品id
category_1_id: this.optionsValue[0], // 商品一级分类id
category_2_id: this.optionsValue[1], // 商品二级分类id
goods_name: this.goodsObj.goods_name, // 商品名称
desc_pic_url: this.detailUploadList.join(","), // 商品详情图片
desc: this.goodsObj.desc, // 商品详情描述
introduce: this.goodsObj.introduce, // 商品介绍
introduce_pic_url: this.introduceUploadList.join(","), // 商品介绍图片
expiration_time: this.expirationTime, // 过期时间
rule_limit: this.goodsObj.rule_limit, // 单人可购买上限
rule_desc: this.goodsObj.rule_desc, // 规则描述
rule_refund: this.goodsObj.rule_refund, // 退款规则
rule_start_time: this.activeStartTime, // 规则开始时间
rule_end_time: this.activeEndTime, // 规则结束时间
inventory_add: this.inventoryAdd, // 库存增减
original_price: this.goodsObj.original_price, // 原价
clear_price: +this.goodsObj.clear_price, // 结算价
price: this.goodsObj.price, // 现价
sub_shop_ids: this.shopIds, // 门店id
rule_date_type: this.goodsObj.rule_date_type, // 使用日期类型(周末/工作日)
};
console.log(111222333, query.original_price);
// 必填校验
if (!this.goodsObj.goods_spu_id) {
return this.$message.error("未传入商品id");
}
if (!query.goods_name) {
return this.$message.error("请填写商品名称");
}
if (!this.isGoodsNameRepeat) {
return this.$message.error("商品名称被占用,请重新更换商品名称");
}
console.log(this.isAllowStockChange);
if (!this.isAllowStockChange) {
return this.$message.error("剩余库存量不得小于1");
}
if (!query.expiration_time) {
return this.$message.error("过期时间未填写,请填写后再提交");
}
if (query.rule_limit === "") {
return this.$message.error("请填写单人可购买上限");
}
if (typeof this.goodsObj.rule_limit !== "number") {
return this.$message.error("单人可购买上限只能为数字格式");
}
if (typeof query.rule_limit !== "number") {
return this.$message.error("单人可购上线只可为数值");
}
if (!query.rule_refund) {
return this.$message.error("请填写退款规则");
}
if (query.original_price === "0") {
return this.$message.error("原价价格不得为0");
}
if (query.price.length === 0) {
return this.$message.error("请填写售价(保留两位小数)");
}
if (query.price == 0) {
return this.$message.error("售价价格不得为0");
}
// if (query.original_price && typeof query.original_price !== "number") {
// return this.$message.error("原价价格必须为数字");
// }
if (typeof query.price !== "number") {
return this.$message.error("售价价格必须为数字格式");
}
if (!query.sub_shop_ids) {
return this.$message.error("请至少选择一个门店");
}
console.log(query);
const res = await editGoods(query);
if (res.code !== 0) {
return this.$message.error(res.reason);
}
this.$message.success("商品编辑成功!");
this.$router.replace({ name: "GoodsList" });
},
},
};
},
methods: {
//结算价两位小数校验
// changeValue(value, level) {
// if (value && value.indexOf(".") !== value.length - 1 && (parseFloat(value)|| value==='0'))
// this.goodsObj[level] = parseFloat(value);
// else if (value && value.indexOf(".") === value.length - 1) return;
// else this.goodsObj[level] = "";
// },
// 获取级联选择商品列表
async getOptions () {
try {
const res = await getGoodsList();
if (res.code !== 0) return this.$message.error(res.reason);
this.optionList = res.result;
} catch (error) {
console.error(error);
}
},
// 获取详情列表
async getGoodsDetailList (params) {
try {
const res = await getGoodsInfo({ goods_spu_id: params });
if (res.code !== 0) {
return this.$message.error(res.reason);
}
console.log("商品详情列表", res);
const { goods_info, record_list } = res.result;
this.goodsObj = goods_info;
this.recordLits = record_list;
// 初始商品名称
this.originalGoodsName = goods_info.goods_name;
// 渲染过期时间
this.expirationTime = goods_info.expiration_time;
// 初始化门店id
this.shopId = goods_info.sub_shop.map(item => {
return item.sub_shop_id;
});
this.shopIds = this.shopId.join(",");
// 初始化规则开始时间
this.activeStartTime = goods_info.rule_start_time;
// 初始化规则结束时间
this.activeEndTime = goods_info.rule_end_time;
// 回显图片
this.formatInitPicture(
goods_info.desc_pic_url_list,
this.descPicUrlList
);
this.formatInitPicture(
goods_info.introduce_pic_url_list,
this.introducePicUrlList
);
this.detailUploadList = this.formatUploadPictureList(goods_info.desc_pic_url);
this.introduceUploadList = this.formatUploadPictureList(goods_info.introduce_pic_url);
} catch (error) {
console.error(error);
}
},
// 初始化照片
formatInitPicture (pictureList, storeList) {
pictureList.forEach(element => {
let obj = new Object();
obj.url = element;
storeList.push(obj);
});
},
// 初始化上传照片列表
formatUploadPictureList (fileStr) {
if (!fileStr) {
return [];
} else {
return fileStr.split(",");
}
},
// 上传图片的公共方法
uploadPicture (response, storageList) {
const responseURL = response.result.image_id;
storageList.push(responseURL);
},
// 删除图片的公共方法
deletePicture (file, fileList, storageList) {
for (let i = 0; i < fileList.length; i++) {
if (fileList[i].uid == file.uid) {
storageList.splice(i, 1);
}
}
},
// 格式化日期
formatDate (time) {
const nowTime = new Date();
const nowYear = nowTime.getFullYear();
const nowMonth = nowTime.getMonth() + 1;
const nowDate = nowTime.getDate();
const timeArray = time.split(":");
const Hour = parseInt(timeArray[0]);
const Minute = parseInt(timeArray[1]);
const Second = parseInt(timeArray[2]);
return new Date(nowYear, nowMonth, nowDate, Hour, Minute, Second);
},
// 检查输入是否带有表情符号
checkHaveExpression (value) {
if (!filterInput.checkString(value)) {
this.$nextTick(() => {
this.goodsObj.goods_name = "";
});
return this.$message.error("商品名称中不可有表情符号");
}
},
// 获取门店列表
async getShops () {
const query = {
life_account_id: this.goodsObj.life_account_id,
page: this.shopCurrentPage,
page_size: 5
};
const res = await getShopsList(query);
if (res.code !== 0) return this.$message.error(res.reason);
console.log(res);
this.shopsList = res.result;
this.shopsCount = res.count;
this.$nextTick(() => {
this.shopsList.forEach(row => {
if (this.shopId.indexOf(row.sub_shop_id) !== -1) {
this.$refs.shopListRef.toggleRowSelection(row, true);
} else {
this.$refs.shopListRef.toggleRowSelection(row, false);
}
});
});
},
// 删除已选择门店
deleteShops (subShopId) {
this.goodsObj.sub_shop = this.goodsObj.sub_shop.filter(item => {
return item.sub_shop_id !== subShopId;
});
this.shopId = this.goodsObj.sub_shop.map(item => {
return item.sub_shop_id;
});
this.shopIds = this.shopId.join(",");
},
// 门店列表更改时操作
handleShopsChange (value) {
this.chooseShopsList = [];
this.chooseShopsList = value;
console.log("已选择列表的长度", this.chooseShopsList.length);
const shopList = value.map(item => {
return item.sub_shop_id;
});
this.shopIds = "";
this.shopIds = shopList.join(",");
},
// 商品列表换页
changeShopListPage (page) {
this.shopCurrentPage = page;
this.getShops();
},
// 确认选择的店铺
handleChooseShops () {
this.goodsObj.sub_shop = this.chooseShopsList;
this.shopId = this.goodsObj.sub_shop.map(item => {
return item.sub_shop_id;
});
this.shopListShow = false;
},
// 添加新门店
async addShop () {
const deepPlace = this.shopForm.deep_place.split(",");
const longitude = deepPlace[0];
const latitude = deepPlace[1];
const query = {
life_account_id: this.goodsObj.life_account_id,
phone: this.shopForm.connect_phone,
shop_name: this.shopForm.shop_name,
longitude, // 经度
latitude, // 纬度
address: this.shopForm.address
};
if (!query.shop_name) {
return this.$message.error("请填写门店名称");
}
if (!query.address) {
return this.$message.error("请填写门店地址");
}
if (!query.phone) {
return this.$message.error("请填写联系电话");
}
if (!query.longitude || !query.latitude) {
return this.$message.error("请填写地理定位");
}
if (
!/([0-9]{3,4}-)?[0-9]{7,8}/.test(query.phone) &&
!/^[1][3,4,5,7,8,9][0-9]{9}$/.test(query.phone)
) {
return this.$message.error("联系电话格式不正确");
}
const res = await postAddShop(query);
if (res.code !== 0) return this.$message.error(res.reason);
this.$message.success("添加门店成功!");
this.addShopShow = false;
},
// 是否可选门店
// canChooseShop (row) {
// if (
// this.chooseShopsList.length === 0 ||
// this.shopIds === row.sub_shop_id
// ) {
// return true;
// } else {
// return false;
// }
// },
// 取消新建门店
closeAddShops () {
this.shopForm.shop_name = "";
this.shopForm.address = "";
this.shopForm.connect_phone = "";
this.shopForm.deep_place = "";
this.addShopShow = false;
},
// 商品分类列表变化
optionsChange (value) {
this.optionsValue = value;
},
// 检查商品名称是否重复
async checkSameName () {
const res = await checkGoodsName({
life_account_id: this.goodsObj.life_account_id,
goods_name: this.goodsObj.goods_name,
goods_spu_id: this.goodsObj.goods_spu_id
});
if (res.code !== 0) return this.$message.error(res.reason);
if (res.result.can_use) {
this.isGoodsNameRepeat = true;
} else if (this.originalGoodsName === this.goodsObj.goods_name) {
this.isGoodsNameRepeat = true;
} else {
this.isGoodsNameRepeat = false;
}
},
// 商品详情图上传成功时
handleDetailSuccess (res) {
console.log(res);
this.uploadPicture(res, this.detailUploadList);
},
// 商品详情图删除完成后的钩子
removeDetailFiles (file, fileList) {
this.deletePicture(file, fileList, this.detailUploadList);
},
// 商品介绍图上传成功钩子
introduceSuccess (res) {
this.uploadPicture(res, this.introduceUploadList);
},
// 商品介绍图删除后的钩子
intrRemove (file, fileList) {
this.deletePicture(file, fileList, this.introduceUploadList);
},
// 展示商品大图
previewImage (file) {
this.popoverImage = file.url;
this.isShowPopver = true;
},
// 库存增减更改
hasNumberChange () {
if (!this.inventoryAdd) {
this.$nextTick(() => {
this.inventoryAdd = 0;
});
}
if (this.inventoryAdd + this.goodsObj.inventory_rest < 1) {
this.$nextTick(() => {
this.isAllowStockChange = false;
});
return this.$message.error("剩余库存量不得小于1");
} else {
this.isAllowStockChange = true;
}
},
// 单人可购买上限的修改
handleLimitChange () {
if (!this.goodsObj.rule_limit) {
this.$nextTick(() => {
this.goodsObj.rule_limit = 0;
});
}
},
// 时间校验器
timePicker (time) {
let Hours = time.getHours() + "";
let Minutes = time.getMinutes() + "";
let Seconds = time.getSeconds() + "";
if (Hours < 10) {
Hours = "0" + Hours;
}
if (Minutes < 10) {
Minutes = "0" + Minutes;
}
if (Seconds < 10) {
Seconds = "0" + Seconds;
}
return `${Hours}:${Minutes}:${Seconds}`;
},
// 选择规则开始时间
pickerStartTime (time) {
this.activeStartTime = this.timePicker(time);
},
// 选择规则结束时间
pickerEndTime (time) {
this.activeEndTime = this.timePicker(time);
},
// 过期时间更改
expirDateChange (time) {
let YYYY = time.getFullYear();
let MM = time.getMonth() + 1;
let DD = time.getDate();
let HH = time.getHours();
let mm = time.getMinutes();
let ss = time.getSeconds();
if (MM < 10) {
MM = "0" + MM;
}
if (DD < 10) {
DD = "0" + DD;
}
if (HH < 10) {
HH = "0" + HH;
}
if (mm < 10) {
mm = "0" + mm;
}
if (ss < 10) {
ss = "0" + ss;
}
this.expirationTime = `${YYYY}-${MM}-${DD} ${HH}:${mm}:${ss}`;
},
// 禁用时间
disableExpirDate (time) {
const timeMs = time.getTime();
if (timeMs > Date.now() - 86400000) {
return false;
} else {
return true;
}
},
// 更改售价
salePrice () {
if (!this.goodsObj.price) {
this.$nextTick(() => {
this.goodsObj.price = "";
})
}
const parseFloatValue = Number(this.goodsObj.price).toFixed(2);
this.goodsObj.price = Number(parseFloatValue);
if (
typeof this.goodsObj.price === "number" &&
isNaN(this.goodsObj.price)
) {
this.goodsObj.price = "";
return this.$message.error("售价价格必须为数字");
}
},
// 更改原价
perPrice (val) {
let reg = /^\d+(\.\d{1,2})?$/;
if(!reg.test(val)) {
return this.$message.error("请输入两位小数");
}
if (val.length === 0) val = 0;
// const parseOriginalPrice = Number(val).toFixed(2);
// val = Number(parseOriginalPrice);
if (typeof val === "number" &&isNaN(val)) {
val = 0;
return this.$message.error("原价价格必为数字");
}
const parseOriginalPrice = Number(this.goodsObj.original_price).toFixed(
2
);
this.goodsObj.original_price = Number(parseOriginalPrice);
// if (
// typeof this.goodsObj.original_price === "number" &&
// isNaN(this.goodsObj.original_price)
// ) {
// this.goodsObj.original_price = "";
// return this.$message.error("原价价格必为数字");
// }
},
// 审核通过
async onSuccess () {
const res = await postSuccess(this.$route.params.spuId);
if (res.code !== 0) return this.$message.error(res.reason);
this.$message.success("审核通过");
this.$router.replace({ name: "GoodsList" });
},
// 审核拒绝
async onDefault () {
const query = {
goods_spu_id: this.goodsObj.goods_spu_id,
rejected_reason: this.rejectReason.reason
};
console.log(query.rejected_reason);
if (query.rejected_reason !== "0" && !query.rejected_reason) {
return this.$message.error("审核驳回时,审核原因不可为空");
}
const res = await auditReject(query);
if (res.code !== 0) {
return this.$message.error(res.reason);
}
this.$message.warning("审核驳回成功!");
this.$router.replace({ name: "GoodsList" });
},
// 返回主页面
backToDetail () {
this.$router.replace({ name: "GoodsList" });
},
// 保存修改信息
async saveDetailMessage () {
await this.checkSameName(); // 检验商品名称是否可用
if (!this.optionsValue) {
return this.$message.error("请选择商品分类");
}
const query = {
goods_spu_id: this.goodsObj.goods_spu_id, // 商品id
category_1_id: this.optionsValue[0], // 商品一级分类id
category_2_id: this.optionsValue[1], // 商品二级分类id
goods_name: this.goodsObj.goods_name, // 商品名称
desc_pic_url: this.detailUploadList.join(","), // 商品详情图片
desc: this.goodsObj.desc, // 商品详情描述
introduce: this.goodsObj.introduce, // 商品介绍
introduce_pic_url: this.introduceUploadList.join(","), // 商品介绍图片
expiration_time: this.expirationTime, // 过期时间
rule_limit: this.goodsObj.rule_limit, // 单人可购买上限
rule_desc: this.goodsObj.rule_desc, // 规则描述
rule_refund: this.goodsObj.rule_refund, // 退款规则
rule_start_time: this.activeStartTime, // 规则开始时间
rule_end_time: this.activeEndTime, // 规则结束时间
inventory_add: this.inventoryAdd, // 库存增减
original_price: this.goodsObj.original_price, // 原价
clear_price: +this.goodsObj.clear_price, // 结算价
price: this.goodsObj.price, // 现价
sub_shop_ids: this.shopIds, // 门店id
rule_date_type: this.goodsObj.rule_date_type // 使用日期类型(周末/工作日)
};
console.log(111222333, query.original_price);
// 必填校验
if (!this.goodsObj.goods_spu_id) {
return this.$message.error("未传入商品id");
}
if (!query.goods_name) {
return this.$message.error("请填写商品名称");
}
if (!this.isGoodsNameRepeat) {
return this.$message.error("商品名称被占用,请重新更换商品名称");
}
console.log(this.isAllowStockChange);
if (!this.isAllowStockChange) {
return this.$message.error("剩余库存量不得小于1");
}
if (!query.expiration_time) {
return this.$message.error("过期时间未填写,请填写后再提交");
}
if (query.rule_limit === "") {
return this.$message.error("请填写单人可购买上限");
}
if (typeof this.goodsObj.rule_limit !== "number") {
return this.$message.error("单人可购买上限只能为数字格式");
}
if (typeof query.rule_limit !== "number") {
return this.$message.error("单人可购上线只可为数值");
}
if (!query.rule_refund) {
return this.$message.error("请填写退款规则");
}
if (query.original_price === "0") {
return this.$message.error("原价价格不得为0");
}
if (query.price.length === 0) {
return this.$message.error("请填写售价(保留两位小数)");
}
if (query.price == 0) {
return this.$message.error("售价价格不得为0");
}
// if (query.original_price && typeof query.original_price !== "number") {
// return this.$message.error("原价价格必须为数字");
// }
if (typeof query.price !== "number") {
return this.$message.error("售价价格必须为数字格式");
}
if (!query.sub_shop_ids) {
return this.$message.error("请至少选择一个门店");
}
console.log(query);
const res = await editGoods(query);
if (res.code !== 0) {
return this.$message.error(res.reason);
}
this.$message.success("商品编辑成功!");
this.$router.replace({ name: "GoodsList" });
}
}
};
</script>
......@@ -112,15 +112,21 @@ export async function orderRefundReject(params) {
// 导出订单
export function getOrderExportURL(eventId, type) {
var ENV;
if (process.env.NODE_ENV == "development") {
ENV = "http://bp-dev.ini.yidian-inc.com/";
} else if (process.env.NODE_ENV == "test") {
ENV = "http://bp-test.ini.yidian-inc.com/";
// var ENV;
// if(process.env.NODE_ENV == "development"){
// ENV = "http://bp-dev.ini.yidian-inc.com/"
// }else if(process.env.NODE_ENV == "test"){
// ENV = "http://bp-test.ini.yidian-inc.com/"
// }else{
// ENV = "http://bp.int.yidian-inc.com/"
// }
// return `${ENV}order/oldbackground/order_export?marketing_id=${eventId}&type=${type}`;
if (process.env.NODE_ENV === "development") {
return `http://127.0.0.1:8055/api/v1/relay/old_order_export?marketing_id=${eventId}&type=${type}`;
} else {
ENV = "http://bp.int.yidian-inc.com/";
return `/api/v1/relay/old_order_export?marketing_id=${eventId}&type=${type}`;
}
return `${ENV}order/oldbackground/order_export?marketing_id=${eventId}&type=${type}`;
}
// 新订单管理
......@@ -191,13 +197,10 @@ export async function newOrderRefundReject(params) {
// 导出订单
export function newGetOrderExportURL(eventId, type) {
var ENV;
if (process.env.NODE_ENV == "development") {
ENV = "http://bp-dev.ini.yidian-inc.com/";
} else if (process.env.NODE_ENV == "test") {
ENV = "http://bp-test.ini.yidian-inc.com/";
if (process.env.NODE_ENV === "development") {
return `http://127.0.0.1:8055/api/v1/relay/order_export?marketing_id=${eventId}&type=${type}`;
} else {
ENV = "http://bp.int.yidian-inc.com/";
return `/api/v1/relay/order_export?marketing_id=${eventId}&type=${type}`;
}
return `${ENV}order/background/order_export?marketing_id=${eventId}&type=${type}`;
// return `/api/v1/relay/order_export?marketing_id=${eventId}&type=${type}`;
}
......@@ -21,49 +21,52 @@ import router from "@/router";
// }
export function redirectToLogin() {
let hasCallback = window.location.href.match(/\?callback/);
if(hasCallback) return;
let isLogin = window.location.pathname.match(/op\/login/);
router.push(`/op/login${!isLogin ? '?callback=' + window.encodeURIComponent(window.location.pathname) : ''}`)
let hasCallback = window.location.href.match(/\?callback/);
if (hasCallback) return;
let isLogin = window.location.pathname.match(/op\/login/);
router.push(`/op/login${!isLogin ? "?callback=" + window.encodeURIComponent(window.location.pathname) : ""}`);
}
export function redirectPage() {
let url = window.location.search.split('?callback=')[1] || window.location.pathname;
router.push(window.decodeURIComponent(url))
let url = window.location.search.split("?callback=")[1] || window.location.pathname;
router.push(window.decodeURIComponent(url));
}
export function isYdUser(email) {
return email.match(/yidian-inc/) || false
return email.match(/yidian-inc/) || false;
}
export function setCookie(name, value) {
var hour = 8;
var exp = new Date();
exp.setTime(exp.getTime() + hour*60*60*1000);
document.cookie = name + "="+ value + ";expires=" + exp.toGMTString()+";path=/";
var hour = 8;
var exp = new Date();
exp.setTime(exp.getTime() + hour * 60 * 60 * 1000);
document.cookie = name + "=" + value + ";expires=" + exp.toGMTString() + ";path=/";
}
//获取cookie
export function getCookie(NameOfCookie) {
if (document.cookie.length > 0) {
let begin = document.cookie.indexOf(NameOfCookie + "=");
if (begin !== -1) {
begin += NameOfCookie.length + 1;
let end = document.cookie.indexOf(";", begin);
if (end === -1) end = document.cookie.length;
return document.cookie.substring(begin, end);
}
}
return null;
if (document.cookie.length > 0) {
let begin = document.cookie.indexOf(NameOfCookie + "=");
if (begin !== -1) {
begin += NameOfCookie.length + 1;
let end = document.cookie.indexOf(";", begin);
if (end === -1) end = document.cookie.length;
return document.cookie.substring(begin, end);
}
}
return null;
}
export function delCookie() {
var keys = document.cookie.match(/[^ =;]+(?==)/g)
if (keys) {
for (var i = keys.length; i--;) {
document.cookie = keys[i] + '=0;path=/;expires=' + new Date(0).toUTCString()
document.cookie = keys[i] + '=0;path=/;domain=' + document.domain + ';expires=' + new Date(0).toUTCString()
document.cookie = keys[i] + '=0;path=/;domain=yidian-inc.com;expires=' + new Date(0).toUTCString()
var keys = document.cookie.match(/[^ =;]+(?==)/g);
if (keys) {
for (var i = keys.length; i--; ) {
document.cookie = keys[i] + "=0;path=/;expires=" + new Date(0).toUTCString();
document.cookie = keys[i] + "=0;path=/;domain=" + document.domain + ";expires=" + new Date(0).toUTCString();
document.cookie = keys[i] + "=0;path=/;domain=yidian-inc.com;expires=" + new Date(0).toUTCString();
}
}
}
}
\ No newline at end of file
}
export const UploadPicUrl =
process.env.NODE_ENV === "development" ? `http://127.0.0.1:8055/api/v1/relay/ks3api_upload` : "/api/v1/relay/ks3api_upload";
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment