detail.tsx 10 KB

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