index.tsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. import { defineComponent, onMounted, reactive, ref } from 'vue';
  2. import styles from './index.module.less';
  3. import { NImage, NModal } from 'naive-ui';
  4. import defultHeade from '@/components/layout/images/teacherIcon.png';
  5. import teacherMan from './img/teacher-man.png';
  6. import teacherWoman from './img/teacher-woman.png';
  7. import iconEchats from './img/icon-echats.png';
  8. import t1 from './img/t1.png';
  9. import t11 from './img/t1-1.png';
  10. import t12 from './img/t1-4.png';
  11. import t2 from './img/t2.png';
  12. import t21 from './img/t2-1.png';
  13. import t22 from './img/t2-4.png';
  14. import f1 from './img/f1.png';
  15. import f11 from './img/f1-1.png';
  16. import f2 from './img/f2.png';
  17. import f21 from './img/f2-1.png';
  18. import f3 from './img/f3.png';
  19. import f31 from './img/f3-1.png';
  20. import f4 from './img/f4.png';
  21. import f41 from './img/f4-1.png';
  22. import { useRouter } from 'vue-router';
  23. import { useUserStore } from '/src/store/modules/users';
  24. // import SelectClass from './modals/selectClass';
  25. import dayjs from 'dayjs';
  26. import UpdatePassword from '/src/components/layout/modals/update-password';
  27. import AttendClass from '../prepare-lessons/model/attend-class';
  28. import { useResizeObserver } from '@vueuse/core';
  29. import PlaceholderTone from '/src/components/layout/modals/placeholderTone';
  30. import PreviewWindow from '../preview-window';
  31. import { state } from '/src/state';
  32. import SubjectModal from './modals/subject-modal';
  33. // import { state } from '/src/state';
  34. export const formatDateToDay = () => {
  35. const hours = dayjs().hour();
  36. if (hours < 12) {
  37. return '早上好'; //如果小时数小于12则输出“早上好!”
  38. } else if (hours > 12 && hours < 18) {
  39. return '下午好'; //如果小时数大于12并且小于18,输入“下午好!”
  40. } else {
  41. return '晚上好'; //如果上面两个条件都不符合,则输出“晚上好!”
  42. }
  43. };
  44. export default defineComponent({
  45. name: 'home-page',
  46. setup() {
  47. const router = useRouter();
  48. const userStore = useUserStore();
  49. const showUpdatePassword = ref(false);
  50. const showModalTone = ref(false);
  51. const forms = reactive({
  52. previewModal: false,
  53. previewParams: {} as any,
  54. showAttendClass: false,
  55. loading: false,
  56. message: '',
  57. list: [] as any,
  58. unit: null,
  59. classLoading: false,
  60. showGuide: false,
  61. homeLeftHeight: 'auto',
  62. subjectSyncVisiable: false
  63. });
  64. onMounted(async () => {
  65. useResizeObserver(
  66. document.querySelector('#homeInfoLeft-home') as any,
  67. (entries: any) => {
  68. const entry = entries[0];
  69. const { height } = entry.contentRect;
  70. forms.homeLeftHeight = height + 'px';
  71. }
  72. );
  73. forms.classLoading = true;
  74. if (!userStore.getUserInfo.account.updatePasswordFlag) {
  75. showUpdatePassword.value = true;
  76. } else {
  77. forms.showGuide = true;
  78. }
  79. forms.classLoading = false;
  80. });
  81. return () => (
  82. <div class={styles.homeWrap}>
  83. <div class={styles.homeSection}>
  84. <div class={styles.homeLeft}>
  85. <i class={styles.homeWindow}></i>
  86. <div class={styles.homeUserInfo}>
  87. <i class={styles.homeTag}></i>
  88. <div class={styles.homeUsers}>
  89. <NImage
  90. src={userStore.getUserInfo?.avatar || defultHeade}
  91. class={styles.userImg}
  92. />
  93. <p class={styles.userName}>
  94. Hi,{userStore.getUserInfo?.nickname} {formatDateToDay()}~
  95. </p>
  96. </div>
  97. <p class={styles.desc}>
  98. 点击下方按钮,您可以根据声部进行备课或是直接选择班级开始上课,更好的规划教学哦!
  99. </p>
  100. <div class={styles.homeBtnGroup}>
  101. <div
  102. class={styles.btnBk}
  103. onClick={() => {
  104. // 备课
  105. router.push({
  106. path: '/prepare-lessons'
  107. });
  108. }}></div>
  109. <div
  110. class={styles.btnClass}
  111. onClick={() => {
  112. forms.showAttendClass = true;
  113. }}></div>
  114. </div>
  115. <img src={iconEchats} class={styles.homeEchats} />
  116. </div>
  117. {userStore.getUserInfo.gender === 1 ? (
  118. <img src={teacherMan} class={styles.teacherMan} />
  119. ) : (
  120. <img src={teacherWoman} class={styles.teacherWoman} />
  121. )}
  122. </div>
  123. <div class={styles.homeRight}>
  124. <div class={styles.rightTop}>
  125. <div
  126. class={[styles.topSection, styles.topSection1]}
  127. onClick={() => {
  128. forms.subjectSyncVisiable = true;
  129. }}>
  130. <img src={t1} class={styles.tFun} />
  131. <img src={t11} class={styles.tTxt} />
  132. <img src={t12} class={styles.tTitle} />
  133. </div>
  134. <div
  135. class={[styles.topSection, styles.topSection2]}
  136. onClick={() => {
  137. const origin = /(localhost|192)/.test(location.host)
  138. ? 'https://test.lexiaoya.cn'
  139. : location.origin;
  140. const src = `${origin}/classroom-app/#/tempo-practice?Authorization=${userStore.getToken}&win=pc`;
  141. if (window.matchMedia('(display-mode: standalone)').matches) {
  142. state.application = window.matchMedia(
  143. '(display-mode: standalone)'
  144. ).matches;
  145. forms.previewModal = true;
  146. forms.previewParams.src = src + '&platform=microapp';
  147. } else {
  148. window.open(src);
  149. }
  150. }}>
  151. <img src={t2} class={styles.tFun} />
  152. <img src={t21} class={styles.tTxt} />
  153. <img src={t22} class={styles.tTitle} />
  154. </div>
  155. </div>
  156. <div class={styles.rightBottom}>
  157. <div
  158. class={styles.bottomSection}
  159. onClick={() => {
  160. router.push('/content-instruments');
  161. }}>
  162. <img src={f1} class={styles.bFun} />
  163. <img src={f11} class={styles.bTxt} />
  164. </div>
  165. <div
  166. class={styles.bottomSection}
  167. onClick={() => {
  168. router.push('/content-music');
  169. }}>
  170. <img src={f2} class={styles.bFun} />
  171. <img src={f21} class={styles.bTxt} />
  172. </div>
  173. <div
  174. class={styles.bottomSection}
  175. onClick={() => {
  176. router.push('/content-musician');
  177. }}>
  178. <img src={f3} class={styles.bFun} />
  179. <img src={f31} class={[styles.bTxt, styles.bTxt2]} />
  180. </div>
  181. <div
  182. class={styles.bottomSection}
  183. onClick={() => {
  184. router.push('/content-knowledge');
  185. }}>
  186. <img src={f4} class={styles.bFun} />
  187. <img src={f41} class={[styles.bTxt, styles.bTxt3]} />
  188. </div>
  189. </div>
  190. </div>
  191. </div>
  192. {/* {forms.showGuide ? <HomeGuide></HomeGuide> : null} */}
  193. <NModal class={['background']} v-model:show={showModalTone.value}>
  194. <div>
  195. <PlaceholderTone
  196. message={forms.message}
  197. onClose={() => {
  198. showModalTone.value = false;
  199. }}></PlaceholderTone>
  200. </div>
  201. </NModal>
  202. <NModal
  203. v-model:show={showUpdatePassword.value}
  204. class={['modalTitle', styles.showUpdatePassword]}
  205. style="--n-title-font-weight: 600;"
  206. preset="card"
  207. title={'修改密码'}
  208. closable={false}
  209. maskClosable={false}
  210. closeOnEsc={false}>
  211. <UpdatePassword
  212. onSubmit={() => {
  213. // 密码更新成功
  214. showUpdatePassword.value = true;
  215. forms.showGuide = true;
  216. userStore.logout().then(() => {
  217. // 移除标签页
  218. router
  219. .replace({
  220. name: 'login'
  221. })
  222. .finally(() => location.reload());
  223. });
  224. }}
  225. />
  226. </NModal>
  227. <NModal
  228. v-model:show={forms.showAttendClass}
  229. preset="card"
  230. showIcon={false}
  231. class={['modalTitle background', styles.attendClassModal]}
  232. title={'选择班级'}
  233. blockScroll={false}>
  234. <AttendClass
  235. onClose={() => (forms.showAttendClass = false)}
  236. type="change"
  237. onConfirm={(item: any) => {
  238. router.push({
  239. path: '/prepare-lessons',
  240. query: {
  241. ...item
  242. }
  243. });
  244. }}
  245. />
  246. </NModal>
  247. <PreviewWindow
  248. v-model:show={forms.previewModal}
  249. type="music"
  250. params={forms.previewParams}
  251. />
  252. {/* 完成编辑时,选择声部 */}
  253. <NModal
  254. v-model:show={forms.subjectSyncVisiable}
  255. preset="card"
  256. class={['modalTitle background', styles.subjectSyncModal]}
  257. title={'请选择乐器'}>
  258. <SubjectModal
  259. onClose={() => (forms.subjectSyncVisiable = false)}
  260. onConfirm={async (item: any) => {
  261. // musicsrc = `${origin}/instrument?modelType=practise&id=${
  262. // data.list[data.listActive].xmlFileUrl
  263. // }&Authorization=${userStore.getToken}/#/preview`;
  264. const origin = /(localhost|192)/.test(location.host)
  265. ? 'https://test.lexiaoya.cn'
  266. : location.origin;
  267. // view-figner?subjectCode=pan-flute
  268. const src = `${origin}/instrument/#/view-figner?Authorization=${userStore.getToken}&code=${item.code}&platform=pc&type=listenMode`;
  269. // const src = `http://192.168.3.220:3000/instrument.html#/view-figner?Authorization=${userStore.getToken}&code=${item.code}`;
  270. if (window.matchMedia('(display-mode: standalone)').matches) {
  271. state.application = window.matchMedia(
  272. '(display-mode: standalone)'
  273. ).matches;
  274. forms.previewModal = true;
  275. forms.previewParams.src = src;
  276. } else {
  277. window.open(src);
  278. }
  279. forms.subjectSyncVisiable = false;
  280. }}
  281. />
  282. </NModal>
  283. </div>
  284. );
  285. }
  286. });