detail.tsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. import {
  2. Image,
  3. Cell,
  4. Tag,
  5. Button,
  6. Popup,
  7. showToast,
  8. Form,
  9. Field,
  10. CountDown,
  11. RadioGroup,
  12. Radio,
  13. Picker,
  14. closeToast,
  15. Popover,
  16. Area,
  17. CellGroup,
  18. showConfirmDialog
  19. } from 'vant';
  20. import {
  21. computed,
  22. defineComponent,
  23. nextTick,
  24. onMounted,
  25. onUnmounted,
  26. reactive,
  27. ref
  28. } from 'vue';
  29. import styles from './detail.module.less';
  30. import MSticky from '@/components/m-sticky';
  31. // import MVideo from '@/components/m-video';
  32. import { useRoute, useRouter } from 'vue-router';
  33. import request from '@/helpers/request';
  34. import loginSuccess from './images/login-success.png';
  35. import SelectStudent from '@/views/student-register/modal/select-student';
  36. const classList: any = [];
  37. for (let i = 1; i <= 40; i++) {
  38. classList.push({ text: i + '班', value: i });
  39. }
  40. const GRADE_ENUM = {
  41. '1': '一年级',
  42. '2': '二年级',
  43. '3': '三年级',
  44. '4': '四年级',
  45. '5': '五年级',
  46. '6': '六年级',
  47. '7': '七年级',
  48. '8': '八年级',
  49. '9': '九年级'
  50. } as any;
  51. const getGradeList = (gradeYear?: string, instrumentCode?: string) => {
  52. let tempList: any = [];
  53. const five = [
  54. { text: '一年级', value: 1, instrumentCode },
  55. { text: '二年级', value: 2, instrumentCode },
  56. { text: '三年级', value: 3, instrumentCode },
  57. { text: '四年级', value: 4, instrumentCode },
  58. { text: '五年级', value: 5, instrumentCode }
  59. ];
  60. const one = [{ text: '六年级', value: 6, instrumentCode }];
  61. const three = [
  62. { text: '七年级', value: 7, instrumentCode },
  63. { text: '八年级', value: 8, instrumentCode },
  64. { text: '九年级', value: 9, instrumentCode }
  65. ];
  66. if (gradeYear === 'FIVE_YEAR_SYSTEM') {
  67. tempList.push(...[...five]);
  68. } else if (gradeYear === 'SIX_YEAR_SYSTEM') {
  69. tempList.push(...[...five, ...one]);
  70. } else if (gradeYear === 'THREE_YEAR_SYSTEM') {
  71. tempList.push(...[...three]);
  72. } else if (gradeYear === 'FORE_YEAR_SYSTEM') {
  73. tempList.push(...[...one, ...three]);
  74. } else {
  75. tempList.push(...[...five, ...one, ...three]);
  76. }
  77. return tempList;
  78. };
  79. export default defineComponent({
  80. name: 'activation-register',
  81. setup() {
  82. const route = useRoute();
  83. const forms = reactive({
  84. activationCodeRecordId: route.query.activationCodeRecordId,
  85. statusShow: false,
  86. schoolId: null as any,
  87. schoolAreaId: null, // 学校区域编号
  88. activationCode: route.query.code as any, // 互通码
  89. paymentType: '', // 支付类型
  90. paymentChannel: '',
  91. multi_user_limit: 1, // 限制注册学生数量
  92. // popupShow: false,
  93. registerDetails: {} as any,
  94. details: [] as any[],
  95. // schoolType: '', // 学校类型
  96. gradeYear: '', // 学制
  97. schoolInstrumentSetType: null as any,
  98. submitLoading: false,
  99. showSelectStudent: false, // 选择学生
  100. studentList: [], // 手机号关联学生列表
  101. studentItem: {} as any, // 选择的学生
  102. registerAllFlag: false // 是否全部登记
  103. });
  104. const studentInfo = reactive({
  105. nickname: '',
  106. areaName: '',
  107. schoolName: '',
  108. currentGradeNum: '' as any,
  109. gender: 1 as any,
  110. registerType: null as any // 报名类型
  111. });
  112. const btnText = computed(() => {
  113. if (forms.registerAllFlag) {
  114. return '该账号学生已全部登记';
  115. }
  116. if (forms.studentItem?.registerFlag) {
  117. return '该学生已登记';
  118. }
  119. return '登记';
  120. });
  121. const getDetail = async () => {
  122. try {
  123. const { data } = await request.post(
  124. '/edu-app/open/instrumentRegister/getStudentActivationRecord',
  125. {
  126. requestType: 'form',
  127. data: {
  128. mobile: route.query.mobile
  129. }
  130. }
  131. );
  132. const result = data || [];
  133. result.forEach((item: any) => {
  134. item.userId = item.activationCodeRecordId;
  135. });
  136. forms.studentList = result;
  137. let count = 0;
  138. forms.studentList.forEach((item: any) => {
  139. if (!item.registerFlag && !forms.studentItem?.userId) {
  140. forms.studentItem = item;
  141. }
  142. if (item.registerFlag) {
  143. count++;
  144. }
  145. });
  146. if (forms.studentList.length === count) {
  147. forms.registerAllFlag = true;
  148. forms.studentItem = forms.studentList[0];
  149. }
  150. formatData(forms.studentItem);
  151. } catch {
  152. //
  153. }
  154. };
  155. const formatData = (item: any) => {
  156. studentInfo.nickname = item.nickname;
  157. studentInfo.gender = item.gender;
  158. const tempArea = [] as any;
  159. if (item.provinceName) {
  160. tempArea.push(item.provinceName);
  161. }
  162. if (item.cityName) {
  163. tempArea.push(item.cityName);
  164. }
  165. if (item.regionName) {
  166. tempArea.push(item.regionName);
  167. }
  168. studentInfo.areaName = tempArea.join(' ');
  169. studentInfo.schoolName = item.schoolName;
  170. studentInfo.currentGradeNum =
  171. item.currentGradeNum + '年级' + item.currentClass + '班';
  172. };
  173. const onSubmit = async () => {
  174. forms.submitLoading = true;
  175. try {
  176. const { data } = await request.post(
  177. '/edu-app/open/instrumentRegister/instrumentUseRegister',
  178. {
  179. requestType: 'form',
  180. data: {
  181. activationCodeRecordId: forms.studentItem.activationCodeRecordId
  182. }
  183. }
  184. );
  185. forms.statusShow = true;
  186. } catch {}
  187. forms.submitLoading = false;
  188. };
  189. onMounted(() => {
  190. getDetail();
  191. });
  192. return () => (
  193. <div class={styles['student-register']}>
  194. <div class={styles.studentRegisterContainer}>
  195. <div class={[styles.studentSection]}>
  196. <Form labelAlign="left" class={styles.registerForm}>
  197. <Field
  198. clearable={false}
  199. required
  200. inputAlign="right"
  201. label="学生姓名"
  202. placeholder="请输入学生姓名"
  203. autocomplete="off"
  204. readonly
  205. maxlength={14}
  206. v-model={studentInfo.nickname}>
  207. {{
  208. extra: () =>
  209. forms.studentList.length > 1 && (
  210. <div
  211. class={[styles.selectStudentGroup]}
  212. onClick={() => (forms.showSelectStudent = true)}>
  213. <span>切换学生</span>
  214. </div>
  215. )
  216. }}
  217. </Field>
  218. <Field
  219. clearable={false}
  220. required
  221. inputAlign="right"
  222. label="学生性别"
  223. placeholder="请选择性别"
  224. autocomplete="off">
  225. {{
  226. input: () => (
  227. <RadioGroup
  228. checked-color="linear-gradient( 135deg, #31C7FF 0%, #007AFE 100%)"
  229. v-model={studentInfo.gender}
  230. direction="horizontal"
  231. disabled>
  232. <Tag
  233. size="large"
  234. type="primary"
  235. color={
  236. !(studentInfo.gender === 1)
  237. ? '#F5F6FA'
  238. : 'linear-gradient( 135deg, #31C7FF 0%, #007AFE 100%)'
  239. }
  240. textColor={
  241. !(studentInfo.gender === 1) ? '#626264' : '#fff'
  242. }
  243. class={styles.radioSection}>
  244. <Radio class={styles.radioItem} name={1}></Radio>男
  245. </Tag>
  246. <Tag
  247. size="large"
  248. type="primary"
  249. color={
  250. !(studentInfo.gender === 0)
  251. ? '#F5F6FA'
  252. : 'linear-gradient( 135deg, #31C7FF 0%, #007AFE 100%)'
  253. }
  254. textColor={
  255. !(studentInfo.gender === 0) ? '#626264' : '#fff'
  256. }
  257. class={styles.radioSection}>
  258. <Radio class={styles.radioItem} name={0}></Radio>女
  259. </Tag>
  260. </RadioGroup>
  261. )
  262. }}
  263. </Field>
  264. <Field
  265. clearable={false}
  266. required
  267. inputAlign="right"
  268. label="所在地区"
  269. placeholder="请选择地区"
  270. readonly
  271. clickable={false}
  272. modelValue={studentInfo.areaName}
  273. />
  274. <Field
  275. clearable={false}
  276. required
  277. inputAlign="right"
  278. label="互通学校"
  279. placeholder="请选择互通学校"
  280. readonly
  281. clickable={false}
  282. modelValue={studentInfo.schoolName}
  283. />
  284. <Field
  285. clearable={false}
  286. required
  287. inputAlign="right"
  288. label="所在班级"
  289. placeholder="请选择班级"
  290. readonly
  291. clickable={false}
  292. modelValue={studentInfo.currentGradeNum}
  293. />
  294. </Form>
  295. </div>
  296. <MSticky position="bottom">
  297. <div class={styles.paymentContainer}>
  298. <Button
  299. onClick={() => {
  300. onSubmit();
  301. }}
  302. round
  303. block
  304. disabled={
  305. forms.submitLoading ||
  306. forms.registerAllFlag ||
  307. forms.studentItem.registerFlag
  308. }
  309. loading={forms.submitLoading}>
  310. {btnText.value}
  311. </Button>
  312. </div>
  313. </MSticky>
  314. </div>
  315. <Popup
  316. v-model:show={forms.showSelectStudent}
  317. round
  318. position="bottom"
  319. safeAreaInsetBottom
  320. closeable>
  321. <SelectStudent
  322. showAdd={false}
  323. studentItem={forms.studentItem}
  324. list={forms.studentList}
  325. onClose={() => (forms.showSelectStudent = false)}
  326. onConfirm={(val: any) => {
  327. console.log(val, 'val');
  328. formatData(val);
  329. forms.studentItem = val;
  330. }}
  331. />
  332. </Popup>
  333. <Popup
  334. show={forms.statusShow}
  335. style={{
  336. background: 'transparent',
  337. overflow: 'visible !important'
  338. }}>
  339. <div class={styles.popupContainer}>
  340. <img class={styles.title} src={loginSuccess} />
  341. <div class={styles.content}>
  342. <span>{forms.studentItem.nickname}</span>
  343. 已登记成功,乐器将在开课时发至学生
  344. </div>
  345. <div class={styles.pBtnGroup}>
  346. <Button
  347. round
  348. block
  349. onClick={() => {
  350. forms.statusShow = false;
  351. forms.studentItem.registerFlag = true;
  352. forms.studentList.forEach((item: any) => {
  353. if (item.userId === forms.studentItem?.userId) {
  354. item.registerFlag = true;
  355. }
  356. });
  357. }}
  358. color="linear-gradient( 305deg, #007AFE 0%, #31C7FF 100%)">
  359. 我知道了
  360. </Button>
  361. </div>
  362. </div>
  363. </Popup>
  364. </div>
  365. );
  366. }
  367. });