| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689 |
- import MHeader from '@/components/m-header';
- import {
- Cell,
- CellGroup,
- Col,
- Icon,
- Row,
- Tag,
- Image,
- showToast,
- showFailToast,
- showLoadingToast,
- showSuccessToast,
- Popup,
- Grid,
- GridItem
- } from 'vant';
- import { defineComponent, nextTick, onMounted, reactive, ref } from 'vue';
- import styles from './detail.module.less';
- import { browser, toChinesNum } from '@/helpers/utils';
- import SOLO from './images/SOLO.png';
- import REPRISE from './images/REPRISE.png';
- import ENSEMBLE from './images/ENSEMBLE.png';
- import UNISON from './images/UNISON.png';
- import MImagePreview from '@/components/m-image-preview';
- import SkeletionIndexModal from './skeletion-index-modal';
- import SkeletionDetailModal from './skeletion-detail-modal';
- import request from '@/helpers/request';
- import { useRoute, useRouter } from 'vue-router';
- import { activeStatus, activityStatus } from '@/helpers/constant';
- import dayjs from 'dayjs';
- import { formatterTimer } from './operation';
- import MPopup from '@/components/m-popup';
- import CastModal from './components/cast-modal';
- import iconEdit from './images/icon-edit.png';
- import html2canvas from 'html2canvas';
- import { postMessage, promisefiyPostMessage } from '@/helpers/native-message';
- import backIcon from './images/back-icon.png';
- import eidtIcon from './images/eidt-icon.png';
- import shareIcon from './images/share-icon.png';
- import jiemuIcon from './images/jiemu-icon.png';
- import hornIcon from './images/horn-icon.png';
- import noteIcon from './images/note-icon.png';
- import colorBg from './images/colorBg.png';
- import dieIcon from './images/die-icon.png';
- import dBall from './images/d-ball.png';
- import qBall from './images/q-ball.png';
- import cBall from './images/c-ball.png';
- import hBall from './images/h-ball.png';
- import dotIcon from './images/dot-icon.png';
- import Detailswiper from './detail-swiper';
- import bottomBg from './images/bottomBg.png';
- import logo from './images/logo.png';
- import MQrcode from '@/components/m-qrcode';
- import { state } from '@/state';
- import { useRect } from '@vant/use';
- import iconWechat from './images/iconWechat.png';
- import iconSaveImage from './images/iconSaveImage.png';
- import shareBg from './images/shareBg.png';
- import schoolIcon from './images/schoolIcon.png';
- import popupQrcodeBg from './images/popupQrcodeBg.png';
- import shareBottom from './images/shareBottom.png';
- import popupShareBg from './images/popup-share-bg.png';
- import { vaildTeachingUrl } from '@/helpers/utils';
- export default defineComponent({
- name: 'detail-page',
- setup() {
- const route = useRoute();
- const router = useRouter();
- // console.log(toChinesNum(11));
- const forms = reactive({
- id: route.query.id,
- imageShow: false,
- imagePreview: [] as any,
- startPosition: 0,
- headerLoading: true,
- detailLoading: true,
- detail: [] as any[],
- headerDetail: {} as any,
- castStatus: false,
- studentAllList: [] as any,
- navBarHeight: state.navBarHeight
- });
- const shareForms = reactive({
- id: route.query.id,
- share: route.query.share as any,
- showQrcode: false,
- url:
- vaildTeachingUrl() +
- '/school/#/activity-record-detail' +
- `?id=${route.query.id}`,
- width: 0,
- height: 0
- });
- const getDetail = async () => {
- try {
- const { data } = await request.get(
- '/api-web/schoolActivity/detail/' + forms.id
- );
- const { detail, ...res } = data || {};
- detail.forEach((item: any) => {
- item.attachmentUrl = item.attachmentUrl
- ? item.attachmentUrl.split(',')
- : [];
- });
- forms.detail = detail;
- forms.headerDetail = { ...res };
- } catch {
- //
- } finally {
- forms.headerLoading = false;
- forms.detailLoading = false;
- }
- };
- const formatterStudentList = (list: any[]) => {
- const tempList: any[] = [];
- list.map((student: any) => {
- let count = 0;
- const students: any[] = [];
- student.studentList.forEach((item: any) => {
- if (item.selected) {
- count++;
- students.push(item);
- }
- });
- if (count > 0) {
- tempList.push({
- studentCount: count,
- subjectId: student.subjectId,
- subjectName: student.subjectName,
- studentList: students
- });
- }
- });
- forms.studentAllList = tempList;
- forms.castStatus = true;
- };
- const formatterImage = (name: string) => {
- let image: string = '';
- switch (name) {
- case 'SOLO':
- image = dBall;
- break;
- case 'REPRISE':
- image = cBall;
- break;
- case 'ENSEMBLE':
- image = hBall;
- break;
- case 'UNISON':
- image = qBall;
- break;
- default:
- image = SOLO;
- break;
- }
- return image;
- };
- onMounted(() => {
- // setTimeout(() => {
- // // forms.headerLoading = false;
- // // forms.detailLoading = false;
- // }, 1000);
- getDetail();
- });
- const imgs = reactive({
- saveLoading: false,
- image: null as any,
- shareLoading: false
- });
- const onSaveImg = async () => {
- // 判断是否在保存中...
- if (imgs.saveLoading) {
- return;
- }
- imgs.saveLoading = true;
- // 判断是否已经生成图片
- console.log(imgs.image);
- if (imgs.image) {
- saveImg();
- } else {
- const container: any = document.getElementById(`preview-container`);
- html2canvas(container, {
- allowTaint: true,
- useCORS: true,
- backgroundColor: null
- })
- .then(async canvas => {
- const url = canvas.toDataURL('image/png');
- imgs.image = url;
- console.log(url, 'html2canvas');
- saveImg();
- })
- .catch(() => {
- // closeToast();
- imgs.saveLoading = false;
- });
- }
- };
- const showImageToas = (obj: any) => {
- forms.imagePreview = obj.imagePreview;
- forms.imageShow = obj.imageShow;
- forms.startPosition = obj.startPosition;
- console.log(forms.imagePreview, 'showImageToas', obj);
- };
- const onShare = () => {
- console.log('onShare');
- if (imgs.shareLoading) {
- return;
- }
- imgs.shareLoading = true;
- if (imgs.image) {
- openShare();
- console.log('onShareimgs.image');
- } else {
- const container: any = document.getElementById(`preview-container`);
- html2canvas(container, {
- allowTaint: true,
- useCORS: true,
- backgroundColor: null
- })
- .then(async canvas => {
- const url = canvas.toDataURL('image/png');
- imgs.image = url;
- openShare();
- console.log('onShareimgs.Noimage');
- })
- .catch(e => {
- // closeToast();
- console.log(e);
- imgs.shareLoading = false;
- });
- }
- };
- const openShare = () => {
- const image = imgs.image;
- setTimeout(() => {
- imgs.shareLoading = false;
- }, 100);
- if (image) {
- console.log('postMessage', 'shareTripartite');
- postMessage(
- {
- api: 'shareTripartite',
- content: {
- title: '',
- desc: '',
- image,
- video: '',
- type: 'image',
- // button: ['copy']
- shareType: 'wechat'
- }
- },
- (res: any) => {
- if (res && res.content) {
- showToast(
- res.content.message ||
- (res.content.status ? '分享成功' : '分享失败')
- );
- }
- }
- );
- }
- };
- const saveImg = async () => {
- showLoadingToast({ message: '图片生成中...', forbidClick: true });
- setTimeout(() => {
- imgs.saveLoading = false;
- }, 100);
- const res = await promisefiyPostMessage({
- api: 'savePicture',
- content: {
- base64: imgs.image
- }
- });
- if (res?.content?.status === 'success') {
- showSuccessToast('已保存到相册');
- } else {
- showFailToast('保存失败');
- }
- };
- return () => (
- <div class={styles.detail}>
- {/* <MHeader>
- {{
- right: () => (
- <>
- <Icon
- name={iconEdit}
- class={styles.iconEdit}
- onClick={() => {
- router.push({
- path: '/activity-record-operation',
- query: {
- id: forms.id
- }
- });
- }}
- />
- <Icon
- name={iconEdit}
- class={styles.iconEdit}
- onClick={() => onShare()}
- />
- </>
- )
- }}
- </MHeader> */}
- <div
- class={styles.detailTop}
- style={{
- '--bar-height': state.navBarHeight + 'px'
- }}>
- {!browser().isApp ? (
- <>
- <div
- class={styles.fixWrap}
- style={{ top: state.navBarHeight + 20 + 'px' }}>
- <div class={styles.fixWrapLeft}>
- <Image
- src={backIcon}
- onClick={() => {
- if (browser().isApp) {
- postMessage({
- api: 'goBack'
- });
- } else {
- router.back();
- }
- }}></Image>
- </div>
- <div class={styles.fixWrapRight}>
- <Image
- src={eidtIcon}
- class={styles.editIcon}
- onClick={() => {
- router.push({
- path: '/activity-record-operation',
- query: {
- id: forms.id
- }
- });
- }}></Image>
- <Image
- src={shareIcon}
- onClick={() => {
- shareForms.showQrcode = true;
- nextTick(() => {
- const previewContainer = document.querySelector(
- '#preview-container'
- ) as HTMLElement;
- const share = useRect(previewContainer);
- shareForms.width = share.width;
- shareForms.height = share.height;
- if (share.width > 0 && share.height > 0) {
- previewContainer.style.width =
- Math.round(share.width) + 'px';
- previewContainer.style.height =
- Math.round(share.height) + 'px';
- }
- });
- }}></Image>
- </div>
- </div>
- </>
- ) : null}
- <div class={styles.wall}> </div>
- <Image src={jiemuIcon} class={styles.jiemuIcon}></Image>
- <div class={styles.typeCard}>
- {' '}
- {activityStatus[forms.headerDetail.type]}
- </div>
- <SkeletionIndexModal
- v-model:show={forms.headerLoading}
- showCount={[1]}
- isLink={false}>
- {/* <CellGroup inset class={styles.cellGroup}>
- <Cell center class={styles.cellTitle}>
- {{
- icon: () => (
- <Tag plain type="primary" class={styles.tag}>
- {activityStatus[forms.headerDetail.type]}
- </Tag>
- ),
- title: () => (
- <div class={[styles.title, 'van-ellipsis']}>
- {forms.headerDetail.name}
- </div>
- )
- }}
- </Cell>
- <Cell
- class={styles.cellTimer}
- center
- title={`活动日期:${dayjs(forms.headerDetail.startTime).format(
- 'YYYY年MM月DD日'
- )}`}
- value={activeStatus[forms.headerDetail.status]}
- valueClass={
- forms.headerDetail.status === 'PROCESSING' ? styles.ing : ''
- }></Cell>
- </CellGroup> */}
- <div class={styles.activeInfo}>
- <Image src={hornIcon} class={styles.hornIcon}></Image>
- <h4 class={styles.headerName}> {forms.headerDetail.name}</h4>
- <p class={styles.headerTimes}>{`活动日期:${dayjs(
- forms.headerDetail.startTime
- ).format('YYYY年MM月DD日')}`}</p>
- <Image src={noteIcon} class={styles.noteIcon}></Image>
- </div>
- </SkeletionIndexModal>
- </div>
- <SkeletionDetailModal
- v-model:show={forms.detailLoading}
- showCount={[1, 2]}>
- <div class={styles.programWrap}>
- <div class={styles.programList}>
- {forms.detail.map((item: any, index: number) => (
- <div class={styles.programItem}>
- <Image src={colorBg} class={styles.colorBg}></Image>
- <div class={styles.pTitle}>节目{toChinesNum(index + 1)}</div>
- <div class={styles.programInfo}>
- <Image
- class={styles.ballIcon}
- src={formatterImage(item.type)}></Image>
- <div class={styles.programInfoTitleWrap}>
- <Image class={styles.dieIcon} src={dieIcon}></Image>
- <div class={styles.programInfoTitle}> {item.name}</div>
- <Image class={styles.dotIcon} src={dotIcon}></Image>
- </div>
- <Row class={styles.itemRow}>
- <Col span={6} class={styles.label}>
- 表演乐团:
- </Col>
- <Col span={18} class={styles.content}>
- {item.musicGroupName}
- <span
- onClick={() => {
- if (item.studentNum <= 0) return;
- formatterStudentList(item.studentList);
- }}>
- 共{item.studentNum}名 <Icon name="arrow" />
- </span>
- </Col>
- </Row>
- <Row class={styles.itemRow} style={{ marginBottom: '0' }}>
- <Col span={6} class={styles.label}>
- 表演团队:
- </Col>
- <Col span={18} class={styles.content}>
- {item.subjectNameList}
- </Col>
- </Row>
- <Row class={styles.itemRow} style={{ marginBottom: '0' }}>
- <Col span={6} class={styles.label}>
- 节目时长:
- </Col>
- <Col span={18} class={styles.content}>
- {formatterTimer(item.time).minute}分
- {formatterTimer(item.time).secord}秒
- </Col>
- </Row>
- </div>
- <Detailswiper
- item={item}
- onShowImageToas={showImageToas}></Detailswiper>
- {/* <CellGroup inset class={styles.pCellGroup}>
- <Cell center>
- {{
- icon: () => (
- <img
- src={formatterImage(item.type)}
- class={styles.imgType}
- />
- ),
- title: () => (
- <div class={[styles.title, 'van-ellipsis']}>
- {item.name}
- </div>
- ),
- value: () => {
- const timer = formatterTimer(item.time);
- return (
- <span class={styles.time}>
- {timer.minute}分{timer.secord}秒
- </span>
- );
- }
- }}
- </Cell>
- <Cell
- center
- class={styles.moreCell}
- valueClass={styles.valueClass}>
- <Row class={styles.item}>
- <Col span={6} class={styles.label}>
- 表演乐团
- </Col>
- <Col span={18} class={styles.content}>
- {item.musicGroupName}
- <span
- onClick={() => {
- if (item.studentNum <= 0) return;
- formatterStudentList(item.studentList);
- }}>
- 共{item.studentNum}名 <Icon name="arrow" />
- </span>
- </Col>
- </Row>
- <Row class={styles.item} style={{ marginBottom: '0' }}>
- <Col span={6} class={styles.label}>
- 表演团队
- </Col>
- <Col span={18} class={styles.content}>
- {item.subjectNameList}
- </Col>
- </Row>
- {item.attachmentUrl ? (
- <div class={styles.photoList}>
- {item.attachmentUrl.map(
- (i: any, index: number) =>
- index <= 3 && (
- <div
- class={styles.photo}
- onClick={() => {
- forms.imagePreview = item.attachmentUrl;
- forms.imageShow = true;
- forms.startPosition = index;
- }}>
- {checkFile(i, 'image') ? (
- <Image
- src={i}
- fit="cover"
- />
- ) : (
- <video
- style={{ backgroundColor: '#F8F8F8' }}
- poster={iconVideoDefault}
- src={i + '#t=1,4'}
- />
- )}
- {item.attachmentUrl.length > 4 &&
- index === 3 ? (
- <div class={styles.photoMore}>
- +{item.attachmentUrl.length - 4}
- </div>
- ) : (
- ''
- )}
- </div>
- )
- )}
- </div>
- ) : (
- ''
- )}
- </Cell>
- </CellGroup> */}
- </div>
- ))}
- </div>
- <div class={styles.bottomWrap}>
- {browser().isApp ? null : (
- <Image class={styles.logo} src={logo}></Image>
- )}
- <Image class={styles.bottomBg} src={bottomBg}></Image>
- </div>
- </div>
- </SkeletionDetailModal>
- <MImagePreview
- v-model:show={forms.imageShow}
- images={forms.imagePreview}
- startPosition={forms.startPosition}
- />
- {/* 演员名单 */}
- <MPopup v-model:modelValue={forms.castStatus}>
- <CastModal
- type="look"
- subjectAllList={forms.studentAllList}
- onClose={() => (forms.castStatus = false)}
- />
- </MPopup>
- <Popup
- v-model:show={shareForms.showQrcode}
- position="bottom"
- style={{ background: 'transparent' }}>
- <div class={styles.codeContainer}>
- <div
- class={[styles.codeImg, styles.teacherCodeImg]}
- id="preview-container">
- <Image src={popupShareBg} class={styles.popupWeekBanner} />
- <div class={styles.timerBg}>
- {dayjs(forms.headerDetail.startTime).format('YYYY年MM月DD日')}
- </div>
- <div class={styles.codeContent}>
- {/* <Image
- class={styles.schoolLogo}
- fit="cover"
- src={
- forms.headerDetail?.cooperationOrganLogo
- ? forms.headerDetail?.cooperationOrganLogo
- : schoolIcon
- }></Image> */}
- <img
- class={[styles.schoolLogo]}
- src={
- forms.headerDetail?.cooperationOrganLogo
- ? forms.headerDetail?.cooperationOrganLogo +
- '?t=' +
- Date.now()
- : schoolIcon
- }
- crossorigin="anonymous"
- style={{
- objectFit: 'cover'
- }}
- />
- <div class={[styles.schoolName, 'van-multi-ellipsis--l2']}>
- {forms.headerDetail?.cooperationOrganName || '--'}
- 武昌学校武昌学校武昌学校武昌学校武昌学校武昌学校武昌学校武昌学校武昌学校武昌学校武昌学校武昌学校武昌学校武昌学校武昌学校武昌学校武昌学校武昌学校
- </div>
- <div class={[styles.shareName, 'van-ellipsis']}>
- {forms.headerDetail.name}
- </div>
- <div class={styles.codeQr}>
- <Image src={popupQrcodeBg} class={styles.popupQrcodeBg} />
- <MQrcode
- text={shareForms.url}
- size={'100%'}
- logoSize="small"
- />
- </div>
- <Image src={shareBottom} class={styles.shareBottom}></Image>
- </div>
- </div>
- <div class={styles.codeBottom}>
- <Icon
- name="cross"
- size={22}
- class={styles.close}
- color="#666"
- onClick={() => (shareForms.showQrcode = false)}
- />
- <h3 class={styles.title}>
- <i></i>分享方式
- </h3>
- <Grid columnNum={2} border={false}>
- <GridItem onClick={onSaveImg}>
- {{
- icon: () => (
- <Image class={styles.shareImg} src={iconSaveImage} />
- ),
- text: () => <div class={styles.shareText}>保存图片</div>
- }}
- </GridItem>
- <GridItem onClick={onShare}>
- {{
- icon: () => (
- <Image class={styles.shareImg} src={iconWechat} />
- ),
- text: () => <div class={styles.shareText}>微信</div>
- }}
- </GridItem>
- </Grid>
- </div>
- </div>
- </Popup>
- </div>
- );
- }
- });
|