fix:投放
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
import request from '@/utils/request';
|
||||
|
||||
// 投放问卷
|
||||
export function publishSurvey(data) {
|
||||
return request({
|
||||
url: `/console/survey_publishes`,
|
||||
method: 'post',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
// 问卷详情
|
||||
export function getSurveyInfo(sn) {
|
||||
return request({
|
||||
url: `/console/surveys/${sn}`,
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
// 查看二维码
|
||||
export function getQrcode(sn) {
|
||||
return request({
|
||||
url: `/console/survey_publishes/${sn}/qrcode`,
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
// 获取问卷测试是否弹层
|
||||
export function getCheckSurvey(sn) {
|
||||
return request({
|
||||
url: `/console/check_survey_test/${sn}`,
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
/* 获取问题列表 */
|
||||
export function getQuestionList(params, code) {
|
||||
return request({
|
||||
headers: {
|
||||
'survey-invite-code': code || ''
|
||||
},
|
||||
url: `/console/surveys/${params}/questions`,
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
@@ -32,3 +32,14 @@ export function getCheckSurvey(sn) {
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
/* 获取问题列表 */
|
||||
export function getQuestionList(params, code) {
|
||||
return request({
|
||||
headers: {
|
||||
'survey-invite-code': code || ''
|
||||
},
|
||||
url: `/console/surveys/${params}/questions`,
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
BIN
src/assets/img/publish/copy_icon.png
Normal file
BIN
src/assets/img/publish/copy_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.8 KiB |
BIN
src/assets/img/publish/download_icon.png
Normal file
BIN
src/assets/img/publish/download_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.9 KiB |
BIN
src/assets/img/publish/share_icon.png
Normal file
BIN
src/assets/img/publish/share_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.6 KiB |
@@ -54,32 +54,25 @@ const table = [
|
||||
}
|
||||
];
|
||||
function tabPath(path) {
|
||||
router.push({
|
||||
path
|
||||
});
|
||||
// if (utils.getParameter('digitalYiliToken')) {
|
||||
// const appToken = utils.getParameter('digitalYiliToken');
|
||||
// getUserInfo(appToken)
|
||||
// .then((res) => {
|
||||
// if (res.data) {
|
||||
// utils.setSessionStorage('userInfo', res.data.data);
|
||||
// router.push({
|
||||
// path
|
||||
// });
|
||||
// } else {
|
||||
// showFailToast(
|
||||
// error.response.data?.message || error.data?.message || error.message || '服务器错误'
|
||||
// );
|
||||
// }
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// showFailToast(error?.response?.data?.message || error?.message || '服务器错误');
|
||||
// });
|
||||
// } else {
|
||||
// router.push({
|
||||
// path
|
||||
// });
|
||||
// }
|
||||
if (utils.getParameter('digitalYiliToken')) {
|
||||
const appToken = utils.getParameter('digitalYiliToken');
|
||||
getUserInfo(appToken).then((res) => {
|
||||
if (res.data) {
|
||||
utils.setSessionStorage('userInfo', res.data.data);
|
||||
router.push({
|
||||
path
|
||||
});
|
||||
} else {
|
||||
showFailToast(error.response.data?.message || error.data?.message || error.message || '服务器错误');
|
||||
}
|
||||
}).catch((error) => {
|
||||
showFailToast(error?.response?.data?.message || error?.message || '服务器错误');
|
||||
});
|
||||
} else {
|
||||
router.push({
|
||||
path
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -91,16 +84,10 @@ function tabPath(path) {
|
||||
}
|
||||
|
||||
.header {
|
||||
.header-nav {
|
||||
background: var(--primary-color) !important;
|
||||
}
|
||||
|
||||
.header-search {
|
||||
padding: 13px;
|
||||
|
||||
//.input-class {
|
||||
//}
|
||||
}
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1000;
|
||||
background-color: #a5d380;
|
||||
|
||||
.title {
|
||||
display: flex;
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// import { getQuesByPages } from '@/views/planetDesign/Design/js/util';
|
||||
// import { A_COMMON_SET_ACTIVEQUESTION } from '@store/constance/constance.common'
|
||||
// import { createVNode } from 'vue';
|
||||
import { showConfirmDialog } from 'vant';
|
||||
import { getQuestionList, getCheckSurvey } from '@/api/publish';
|
||||
// import store from '@/store';
|
||||
// import Scroll from '@views/planetDesign/Design/js/scroll'
|
||||
|
||||
import { showConfirmDialog, showDialog } from 'vant';
|
||||
import { getQuestionList, getCheckSurvey } from '@/api/survey';
|
||||
// /**
|
||||
// * 统一的弹窗
|
||||
// * @param options
|
||||
@@ -19,11 +15,11 @@ function showModal(options) {
|
||||
if (options.onOk) {
|
||||
options.onOk(...rest);
|
||||
}
|
||||
// const firstQuestion = options.incompleteQuestionList[0];
|
||||
const firstQuestion = options.incompleteQuestionList[0];
|
||||
// store.commit(`common/${A_COMMON_SET_ACTIVEQUESTION}`, JSON.stringify(firstQuestion));
|
||||
// const el = document.getElementById(firstQuestion.id);
|
||||
const el = document.getElementById(firstQuestion.id);
|
||||
|
||||
// new Scroll(el).animate();
|
||||
new Scroll(el).animate();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -36,9 +32,7 @@ function showModal(options) {
|
||||
.then(() => {
|
||||
confirm();
|
||||
})
|
||||
.catch(() => {
|
||||
/**/
|
||||
});
|
||||
.catch(() => {});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,7 +133,7 @@ const canPlanetPublish3D = function(data) {
|
||||
qSteams.push(`(${s.title})`);
|
||||
}
|
||||
} catch (error) {
|
||||
// console.warn(error);
|
||||
console.warn(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -167,11 +161,11 @@ const canPlanetPublish3D = function(data) {
|
||||
try {
|
||||
if (s.config.is_three_dimensions && s.config.is_binding_goods) {
|
||||
const wares = [];
|
||||
const _sceneInformation = s.config.scene_information;
|
||||
const scene_information = s.config.scene_information;
|
||||
const sceneInformation
|
||||
= typeof _sceneInformation === 'string'
|
||||
? JSON.parse(_sceneInformation)
|
||||
: _sceneInformation;
|
||||
= typeof scene_information === 'string'
|
||||
? JSON.parse(scene_information)
|
||||
: scene_information;
|
||||
sceneInformation.shelves.forEach((shelf) => {
|
||||
shelf.wares.forEach((ware) => {
|
||||
if (!ware.option_index) return;
|
||||
@@ -181,9 +175,7 @@ const canPlanetPublish3D = function(data) {
|
||||
|
||||
const options = s.options.flat();
|
||||
s.associate.forEach((ass) => {
|
||||
const question = data.questions.find(
|
||||
(q) => q.question_index === ass.question_index
|
||||
);
|
||||
const question = data.questions.find((q) => q.question_index == ass.question_index);
|
||||
if (!question) return;
|
||||
options.push(...question.options.flat());
|
||||
});
|
||||
@@ -197,7 +189,7 @@ const canPlanetPublish3D = function(data) {
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
// console.warn(error);
|
||||
console.warn(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -229,14 +221,14 @@ const canPlanetPublishImage = function(data) {
|
||||
let title = '';
|
||||
data.questions
|
||||
&& data.questions.forEach((s) => {
|
||||
if (s.question_type === 13) {
|
||||
if (s.question_type == 13) {
|
||||
try {
|
||||
if (s.options.length <= 0 || s.options.some((y) => y.length <= 0)) {
|
||||
canFB = false;
|
||||
qSteams.push(`(${s.title})`);
|
||||
}
|
||||
} catch (error) {
|
||||
// 错误返回
|
||||
console.warn(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -301,7 +293,7 @@ function canPublishRandom(data, publishType) {
|
||||
const errors = [];
|
||||
const randomList = data?.survey?.group_pages || [];
|
||||
|
||||
randomList.forEach((random /* randomIndex */) => {
|
||||
randomList.forEach((random, randomIndex) => {
|
||||
const list = random.list || [];
|
||||
|
||||
// 每一个随机,至少要有两个随机题组
|
||||
@@ -347,36 +339,36 @@ function canPublishRandom(data, publishType) {
|
||||
* @param data
|
||||
* @param publishType
|
||||
*/
|
||||
// function isLoopingLogicValid(data, publishType) {
|
||||
// const publishStr = ['', '预览', '投放'][publishType] || '投放';
|
||||
//
|
||||
// if (
|
||||
// (data?.cycle_pages || []).every((i) => {
|
||||
// return (
|
||||
// i.question_index
|
||||
// && i.relation_type !== undefined
|
||||
// && i.relation_type !== null
|
||||
// && i.first_page
|
||||
// && i.last_page
|
||||
// );
|
||||
// })
|
||||
// ) {
|
||||
// return loopingAvailable({
|
||||
// cycles: data.cycle_pages || [],
|
||||
// questions: getQuesByPages(data.questions || [], data.survey.pages),
|
||||
// logics: data.logics || [],
|
||||
// isPerPage: data.survey?.is_one_page_one_question
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// showDialog({
|
||||
// class: 'custom-modal custom-modal-title-notice show-icon',
|
||||
// title: '修改循环',
|
||||
// content: `循环题组不完全,请前往循环列表修改后${publishStr}`
|
||||
// });
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
function isLoopingLogicValid(data, publishType) {
|
||||
const publishStr = ['', '预览', '投放'][publishType] || '投放';
|
||||
|
||||
if (
|
||||
(data?.cycle_pages || []).every((i) => {
|
||||
return (
|
||||
i.question_index
|
||||
&& i.relation_type !== undefined
|
||||
&& i.relation_type !== null
|
||||
&& i.first_page
|
||||
&& i.last_page
|
||||
);
|
||||
})
|
||||
) {
|
||||
return loopingAvailable({
|
||||
cycles: data.cycle_pages || [],
|
||||
questions: getQuesByPages(data.questions || [], data.survey.pages),
|
||||
logics: data.logics || [],
|
||||
isPerPage: data.survey?.is_one_page_one_question
|
||||
});
|
||||
}
|
||||
|
||||
showDialog({
|
||||
class: 'custom-modal custom-modal-title-notice show-icon',
|
||||
title: '修改循环',
|
||||
content: `循环题组不完全,请前往循环列表修改后${publishStr}`
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export const canPlanetPublish = async function(sn, publishType) {
|
||||
const parsedPublishType = !publishType ? 2 : publishType;
|
||||
@@ -395,7 +387,7 @@ export const canPlanetPublish = async function(sn, publishType) {
|
||||
if (!canPlanetPublishImage(data)) return false;
|
||||
if (!canPublishMultiCompletion(data, parsedPublishType)) return false;
|
||||
if (!canPublishRandom(data, parsedPublishType)) return false;
|
||||
// if (!isLoopingLogicValid(data, parsedPublishType)) return false;
|
||||
if (!isLoopingLogicValid(data, parsedPublishType)) return false;
|
||||
|
||||
if (parsedPublishType === 2) {
|
||||
const qrcodeRes = await getCheckSurvey(sn);
|
||||
|
||||
@@ -2,19 +2,16 @@
|
||||
<div class="container">
|
||||
<van-nav-bar :title="surveyTitle" left-arrow @click-left="$router.go(-1)" />
|
||||
<div class="content">
|
||||
<!-- <van-cell-group v-if="status === 1" inset style="padding-top: 15px"> -->
|
||||
<van-cell-group inset style="padding-top: 15px">
|
||||
<van-cell-group v-if="status === 1" inset style="padding-top: 15px">
|
||||
<div>
|
||||
<img
|
||||
width="100%"
|
||||
<img width="100%"
|
||||
src="https://files.axshare.com/gsc/DR6075/44/1a/03/441a03a8b1004755a7a392b311acf97f/images/%E6%8A%95%E6%94%BE/u14.jpg?pageId=2f9ba10c-92b8-4c9b-b40b-04e65a0b4333"
|
||||
alt=""
|
||||
/>
|
||||
alt="" />
|
||||
</div>
|
||||
<div class="qrcode">
|
||||
<img :src="publishInfo.img_url" alt="" width="100px" height="100px" />
|
||||
<img :src="publishInfo?.img_url" alt="" width="100px" height="100px" />
|
||||
<div class="tit">
|
||||
<div>液态奶产品研究标准化问卷</div>
|
||||
<div>{{ publishInfo?.download_url?.title || '' }}</div>
|
||||
<div>扫码填写问卷</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -26,7 +23,7 @@
|
||||
</span>
|
||||
</div>
|
||||
</van-cell-group>
|
||||
<!-- <div v-if="status === 0 || status === 2" class="pulish-container">
|
||||
<div v-if="status === 0 || status === 2" class="pulish-container">
|
||||
<img class="not-publish-icon" src="@/assets/img/publish/not_pulish.png" alt="" />
|
||||
<div class="text">点击"启用"按钮后,问卷才可以开始回收数据</div>
|
||||
<van-button type="primary" style="margin-top: 20px" class="publish-btn" color="#70b936"
|
||||
@@ -34,9 +31,9 @@
|
||||
<template #icon>
|
||||
<i class="iconfont icon-fabu3" style="margin-right: 6px"></i>
|
||||
</template>
|
||||
启用
|
||||
</van-button>
|
||||
</div> -->
|
||||
启用
|
||||
</van-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -47,31 +44,35 @@ import { onMounted, reactive, ref, watch } from 'vue';
|
||||
import { showFailToast, showToast } from 'vant';
|
||||
import utils from '@/assets/js/common';
|
||||
import appBridge from '@/assets/js/appBridge';
|
||||
import { getQrcode } from '@/api/publish';
|
||||
// import { canPlanetPublish } from '@/layouts/utils.js';
|
||||
import configUrl from '../../../../config';
|
||||
import { getQrcode, getSurveyInfo, publishSurvey } from '@/api/survey';
|
||||
import { canPlanetPublish } from '@/layouts/utils.js';
|
||||
// import configUrl from '../../../../config';
|
||||
import copyIcon from '@/assets/img/publish/copy_icon.png';
|
||||
import shareIcon from '@/assets/img/publish/share_icon.png';
|
||||
import downloadIcon from '@/assets/img/publish/download_icon.png';
|
||||
|
||||
const route = useRoute();
|
||||
const surveyTitle = route.meta.title as string;
|
||||
appBridge.setTitle(surveyTitle);
|
||||
const sn = route.query.sn;
|
||||
const status = ref<number>(0); // `0`: 编辑中 `1`: 投放中 `2`: 已结束
|
||||
// const publishType = ref(0);
|
||||
const publishType = ref(0);
|
||||
const operateList = reactive([
|
||||
{
|
||||
title: '复制链接',
|
||||
type: 'copyLink',
|
||||
icon: 'https://files.axshare.com/gsc/DR6075/44/1a/03/441a03a8b1004755a7a392b311acf97f/images/%E6%8A%95%E6%94%BE/u21.png?pageId=2f9ba10c-92b8-4c9b-b40b-04e65a0b4333'
|
||||
icon: copyIcon
|
||||
// icon: 'https://files.axshare.com/gsc/DR6075/44/1a/03/441a03a8b1004755a7a392b311acf97f/images/%E6%8A%95%E6%94%BE/u21.png?pageId=2f9ba10c-92b8-4c9b-b40b-04e65a0b4333'
|
||||
},
|
||||
{
|
||||
title: '转发到微信',
|
||||
type: 'shareLink',
|
||||
icon: 'https://files.axshare.com/gsc/DR6075/44/1a/03/441a03a8b1004755a7a392b311acf97f/images/%E6%8A%95%E6%94%BE/u21.png?pageId=2f9ba10c-92b8-4c9b-b40b-04e65a0b4333'
|
||||
icon: shareIcon
|
||||
},
|
||||
{
|
||||
title: '下载二维码',
|
||||
type: 'qrCode',
|
||||
icon: 'https://files.axshare.com/gsc/DR6075/44/1a/03/441a03a8b1004755a7a392b311acf97f/images/%E6%8A%95%E6%94%BE/u21.png?pageId=2f9ba10c-92b8-4c9b-b40b-04e65a0b4333'
|
||||
icon: downloadIcon
|
||||
}
|
||||
]);
|
||||
|
||||
@@ -87,82 +88,24 @@ interface PublishInfo {
|
||||
|
||||
const publishInfo = ref<PublishInfo>({} as PublishInfo);
|
||||
type OperateItem = (typeof operateList)[0];
|
||||
// function handlePublish() {
|
||||
// publishSurvey({
|
||||
// sn,
|
||||
// publish_type: publishType.value
|
||||
// })
|
||||
// .then(() => {
|
||||
// // store.commit('common/M_COMMON_SET_SURVEY_STATUS', 1);
|
||||
// fetchInfo();
|
||||
// })
|
||||
// .catch(() => {
|
||||
// // emitter.emit('app-loading', false);
|
||||
// });
|
||||
// }
|
||||
|
||||
// async function openPublishModal() {
|
||||
// const res = await canPlanetPublish(route.query.sn);
|
||||
// if (res) {
|
||||
// handlePublish();
|
||||
// } else {
|
||||
// emitter.emit('app-loading', false);
|
||||
// }
|
||||
// }
|
||||
|
||||
function getCode() {
|
||||
publishInfo.value.img_url
|
||||
= 'https://test-cxp-pubcos.yili.com/uat-yls//survey-api/publish/202503130938138261340.png';
|
||||
publishInfo.value.url = `${configUrl.proxyDomain}/publish?sn=${sn && sn !== undefined ? sn : ''}`;
|
||||
publishInfo.value.download_url = {
|
||||
title: '问卷下载',
|
||||
url: 'https://test-cxp-pubcos.yili.com/uat-yls//survey-api/publish/202503130938138261340.png'
|
||||
};
|
||||
getQrcode(sn)
|
||||
.then((res) => {
|
||||
if (res.data) {
|
||||
publishInfo.value = res.data.data || {};
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
showFailToast(error.data?.message || error.message || '服务器错误');
|
||||
});
|
||||
}
|
||||
// function fetchInfo() {
|
||||
// getSurveyInfo(sn)
|
||||
// .then((res) => {
|
||||
// status.value = Number(res.data.data.status);
|
||||
// })
|
||||
// .finally(() => {
|
||||
// /**/
|
||||
// });
|
||||
// }
|
||||
watch(status, (val) => {
|
||||
if (val === 1) {
|
||||
getCode();
|
||||
}
|
||||
});
|
||||
onMounted(async() => {
|
||||
// fetchInfo();
|
||||
getCode();
|
||||
});
|
||||
const operateBtn = (item: OperateItem) => {
|
||||
switch (item.type) {
|
||||
case 'shareLink':
|
||||
shareLink();
|
||||
break;
|
||||
case 'copyLink':
|
||||
copyLink();
|
||||
break;
|
||||
case 'qrCode':
|
||||
downLoadImg();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case 'shareLink':
|
||||
shareLink();
|
||||
break;
|
||||
case 'copyLink':
|
||||
copyLink();
|
||||
break;
|
||||
case 'qrCode':
|
||||
downLoadImg();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
// 复制链接
|
||||
function copyLink() {
|
||||
function copyLink () {
|
||||
const input = document.createElement('input');
|
||||
input.value = publishInfo.value.url;
|
||||
document.body.appendChild(input);
|
||||
@@ -172,7 +115,7 @@ function copyLink() {
|
||||
showToast('复制成功');
|
||||
}
|
||||
// 分享链接
|
||||
function shareLink() {
|
||||
function shareLink () {
|
||||
const params = {
|
||||
type: 'shareToWx',
|
||||
title: publishInfo.value.download_url.title,
|
||||
@@ -186,7 +129,7 @@ function shareLink() {
|
||||
}
|
||||
|
||||
// 下载二维码
|
||||
function downLoadImg() {
|
||||
function downLoadImg () {
|
||||
const { title, url } = publishInfo.value.download_url;
|
||||
if (utils.getSessionStorage('xToken')) {
|
||||
appBridge.save2Album(url, () => {
|
||||
@@ -201,6 +144,61 @@ function downLoadImg() {
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
}
|
||||
function handlePublish () {
|
||||
publishSurvey({
|
||||
sn,
|
||||
publish_type: publishType.value
|
||||
})
|
||||
.then(() => {
|
||||
fetchInfo();
|
||||
})
|
||||
.catch((error) => {
|
||||
showFailToast(error.data?.message || error.message || '服务器错误');
|
||||
});
|
||||
}
|
||||
async function openPublishModal () {
|
||||
const res = await canPlanetPublish(route.query.sn as string);
|
||||
if (res) {
|
||||
handlePublish();
|
||||
}
|
||||
}
|
||||
|
||||
function getCode () {
|
||||
getQrcode(sn)
|
||||
.then((res) => {
|
||||
if (res.data) {
|
||||
publishInfo.value = res.data.data || {};
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
showFailToast(error.data?.message || error.message || '服务器错误');
|
||||
});
|
||||
}
|
||||
function fetchInfo () {
|
||||
getSurveyInfo(sn)
|
||||
.then((res) => {
|
||||
status.value = Number(res.data.data.status);
|
||||
})
|
||||
.catch((error) => {
|
||||
showFailToast(error.data?.message || error.message || '服务器错误');
|
||||
});
|
||||
}
|
||||
watch(status, (val) => {
|
||||
if (val === 1) {
|
||||
getCode();
|
||||
}
|
||||
});
|
||||
onMounted(async () => {
|
||||
status.value = 1;
|
||||
// publishInfo.value.img_url
|
||||
// = 'https://test-cxp-pubcos.yili.com/uat-yls//survey-api/publish/202503130938138261340.png';
|
||||
// publishInfo.value.url = `${configUrl.proxyDomain}/publish?sn=${sn && sn !== undefined ? sn : ''}`;
|
||||
// publishInfo.value.download_url = {
|
||||
// title: '问卷下载dadad阿萨法发是否反反复复烦烦烦烦烦阿三大苏打烦烦烦烦',
|
||||
// url: 'https://test-cxp-pubcos.yili.com/uat-yls//survey-api/publish/202503130938138261340.png'
|
||||
// };
|
||||
fetchInfo();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user