teacher_authentication_add.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. <template>
  2. <view class="auth-Container">
  3. <uni-forms ref="baseForm" :modelValue="baseFormData" labelWidth="75px" :rules="rules" validateTrigger="bind">
  4. <uni-forms-item label="真实姓名" name="name" required>
  5. <uni-easyinput v-model="baseFormData.name" placeholder="请输入姓名" maxlength="6" trim="both" />
  6. </uni-forms-item>
  7. <uni-forms-item label="手机号" name="phone" required>
  8. <uni-row>
  9. <uni-col :span="14">
  10. <uni-easyinput v-model="baseFormData.phone" placeholder="请输入手机号" :disabled="disabledPhone" trim="both" />
  11. </uni-col>
  12. <uni-col :span="8" :offset="2">
  13. <view class="phoneClass">
  14. <button class="getPhone" open-type="getPhoneNumber"
  15. @getphonenumber="getPhoneNumber">自动获取</button>
  16. </view>
  17. </uni-col>
  18. </uni-row>
  19. </uni-forms-item>
  20. <uni-forms-item label="微信号" name="weixinId" required>
  21. <uni-easyinput v-model="baseFormData.weixinId" placeholder="微信号(不便接听电话时微信沟通)" maxlength="25"
  22. trim="both" />
  23. </uni-forms-item>
  24. <uni-forms-item label="英文名" name="englishName">
  25. <uni-easyinput v-model="baseFormData.englishName" placeholder="请输入你的英文名" maxlength="25" trim="both" />
  26. </uni-forms-item>
  27. <uni-forms-item label="身份证号" name="idCard" required>
  28. <uni-easyinput v-model="baseFormData.idCard" type="idcard" placeholder="请输入你的身份证号" />
  29. </uni-forms-item>
  30. <uni-forms-item label="性别" name="sex" required>
  31. <uni-data-checkbox v-model="baseFormData.sex" :localdata="sexs" />
  32. </uni-forms-item>
  33. <uni-forms-item label="身份" name="identify" required>
  34. <uni-data-checkbox v-model="baseFormData.identify" :localdata="identifies"/>
  35. </uni-forms-item>
  36. <uni-forms-item label="身份证照片" required>
  37. <text style="color: blue;">(说明:需要能看清楚证件号码、日期及头像)</text>
  38. <uni-file-picker fileMediatype="image" :sizeType="sizeType" :imageStyles="listStyle" v-model="idCardFrontByte" :fileExtname="fileExtname" limit="1" title="身份证正面" @select="selectPhoto('idCardFront', $event)" @delete="deletePhoto('idCardFront', $event)" />
  39. <uni-file-picker fileMediatype="image" :sizeType="sizeType" :imageStyles="listStyle" v-model="idCardBackByte" :fileExtname="fileExtname" limit="1" title="身份证背面" @select="selectPhoto('idCardBack', $event)" @delete="deletePhoto('idCardBack', $event)" />
  40. </uni-forms-item>
  41. <uni-forms-item label="学生/毕业证" required>
  42. <text style="color: blue;">(已毕业的需要上传毕业证)</text>
  43. <uni-file-picker fileMediatype="image" :sizeType="sizeType" :imageStyles="listStyle" v-model="diplomaPhotoByte" :fileExtname="fileExtname" limit="1" @select="selectPhoto('diplomaPhoto', $event)" @delete="deletePhoto('diplomaPhoto', $event)" />
  44. </uni-forms-item>
  45. <uni-forms-item label="头像" required>
  46. <text style="color: blue;">(说明:只能上传证件照,上传其他照片审核不予通过)</text>
  47. <uni-file-picker fileMediatype="image" :sizeType="sizeType" :imageStyles="listStyle" v-model="teacherPhotoByte" :fileExtname="fileExtname" limit="1" @select="selectPhoto('teacherPhoto', $event)" @delete="deletePhoto('teacherPhoto', $event)" />
  48. </uni-forms-item>
  49. <uni-forms-item label="毕业/就读学校" name="school" required>
  50. <uni-easyinput v-model="baseFormData.school" placeholder="请输入学校全称" maxlength="30" trim="both" />
  51. </uni-forms-item>
  52. <uni-forms-item label="所学专业" name="major" required>
  53. <uni-easyinput v-model="baseFormData.major" placeholder="请输入专业名称" maxlength="20" trim="both" />
  54. </uni-forms-item>
  55. <uni-forms-item label="学历" name="education" required>
  56. <uni-data-select v-model="baseFormData.education" :localdata="educations" />
  57. </uni-forms-item>
  58. <uni-forms-item label="毕业年月" name="graduateMonth" required>
  59. <picker mode="date" fields="month" :value="baseFormData.graduateMonth" @change="bindDateChange">
  60. <uni-easyinput v-model="baseFormData.graduateMonth" placeholder="请选择全日制学历毕业年月" />
  61. </picker>
  62. </uni-forms-item>
  63. <uni-forms-item label="籍贯" name="nativePlace" required>
  64. <uni-easyinput v-model="baseFormData.nativePlace" placeholder="xx省xx市xx区" maxlength="30" trim="both" />
  65. </uni-forms-item>
  66. </uni-forms>
  67. <!-- <canvas canvas-id="idCardFront" class="idCardFrontClass" :style="{width:idCardFrontWidth, height:idCardFrontHeight}"></canvas>
  68. <canvas canvas-id="idCardBack" class="idCardBackClass" :style="{width:idCardBackWidth, height:idCardBackHeight}"></canvas>
  69. <canvas canvas-id="diplomaPhoto" class="diplomaPhotoClass" :style="{width:diplomaPhotoWidth, height:diplomaPhotoHeight}"></canvas>
  70. <canvas canvas-id="teacherPhoto" class="profilePhotoClass" :style="{width:profilePhotoWidth, height:profilePhotoHeight}"></canvas> -->
  71. <view class="submitBtnWrapper">
  72. <button class="submitBtn" type="primary" @click="submit">{{buttonMessage}}</button>
  73. </view>
  74. <!-- 裁剪图片的插件 -->
  75. <ksp-cropper mode="free" :width="1024" :height="1024" :maxWidth="1024" :maxHeight="1024" :url="idCardFrontUrl" @cancel="urloncancel('idCardFront')" @ok="urlonok('idCardFront', $event)"></ksp-cropper>
  76. <ksp-cropper mode="free" :width="1024" :height="1024" :maxWidth="1024" :maxHeight="1024" :url="idCardBackUrl" @cancel="urloncancel('idCardBack')" @ok="urlonok('idCardBack', $event)"></ksp-cropper>
  77. <ksp-cropper mode="free" :width="1024" :height="1024" :maxWidth="1600" :maxHeight="1600" :url="diplomaPhotoUrl" @cancel="urloncancel('diplomaPhoto')" @ok="urlonok('diplomaPhoto', $event)"></ksp-cropper>
  78. <ksp-cropper mode="fixed" :width="160" :height="160" :maxWidth="1024" :maxHeight="1024" :url="teacherPhotoUrl" @cancel="urloncancel('teacherPhoto')" @ok="urlonok('teacherPhoto', $event)"></ksp-cropper>
  79. </view>
  80. </template>
  81. <script>
  82. import { mapState, mapMutations } from 'vuex'
  83. export default {
  84. computed: {
  85. ...mapState('m_user', ['authentication']),
  86. },
  87. data() {
  88. return {
  89. disabledPhone: true,
  90. listStyle: {
  91. "height": 100, // 边框高度
  92. "width": 100, // 边框宽度
  93. "border":{ // 如果为 Boolean 值,可以控制边框显示与否
  94. "color":"#ccc", // 边框颜色
  95. "width":"1px", // 边框宽度
  96. "style":"solid", // 边框样式
  97. }
  98. },
  99. idCardFrontUrl: '',
  100. idCardBackUrl: '',
  101. diplomaPhotoUrl: '',
  102. teacherPhotoUrl: '',
  103. // idCardFrontWidth: 0,
  104. // idCardFrontHeight: 0,
  105. // idCardBackWidth: 0,
  106. // idCardBackHeight: 0,
  107. // diplomaPhotoWidth: 0,
  108. // diplomaPhotoHeight: 0,
  109. // profilePhotoWidth: 0,
  110. // profilePhotoHeight: 0,
  111. fileExtname: 'png,jpg',
  112. sizeType: ['compressed'],
  113. idCardFrontByte: [{
  114. url: '',
  115. extname: '',
  116. name: ''
  117. }],
  118. idCardBackByte: [{
  119. url: '',
  120. extname: '',
  121. name: ''
  122. }],
  123. teacherPhotoByte: [{
  124. url: '',
  125. extname: '',
  126. name: ''
  127. }],
  128. diplomaPhotoByte: [{
  129. url: '',
  130. extname: '',
  131. name: ''
  132. }],
  133. buttonMessage: '申请认证',
  134. isLoading: false, // 节流阀
  135. baseFormData: {
  136. name: '',
  137. weixinId: '',
  138. phone: '',
  139. idCard: '',
  140. sex: '男',
  141. identify: '专职老师',
  142. school: '',
  143. major: '',
  144. education: '',
  145. nativePlace: '',
  146. education: '本科在读',
  147. idCardFront: '',
  148. idCardBack: '',
  149. diplomaPhoto: '',
  150. teacherPhoto: '',
  151. graduateMonth: '',
  152. teacherPhotoTemp: ''
  153. },
  154. sexs: [{
  155. text: '男',
  156. value: '男'
  157. }, {
  158. text: '女',
  159. value: '女'
  160. }],
  161. // 单选老师身份
  162. identifies: [{
  163. text: '专职老师',
  164. value: '专职老师'
  165. }, {
  166. text: '在校大学生',
  167. value: '在校大学生'
  168. }],
  169. educations:[ {
  170. value: '专科毕业',
  171. text: '专科毕业'
  172. }, {
  173. value: '本科毕业',
  174. text: '本科毕业'
  175. }, {
  176. value: '硕士毕业',
  177. text: '硕士毕业'
  178. }, {
  179. value: '博士毕业',
  180. text: '博士毕业'
  181. }, {
  182. value: '专科在读',
  183. text: '专科在读'
  184. }, {
  185. value: '本科在读',
  186. text: '本科在读'
  187. }, {
  188. value: '硕士在读',
  189. text: '硕士在读'
  190. }, {
  191. value: '博士在读',
  192. text: '博士在读'
  193. }],
  194. rules: {
  195. name: {
  196. rules: [{
  197. required: true,
  198. errorMessage: '请输入姓名',
  199. }]
  200. },
  201. weixinId: {
  202. rules: [{
  203. required: true,
  204. errorMessage: '请输入微信号',
  205. }, {
  206. errorMessage: '请输入正确的微信号',
  207. pattern: '^[a-zA-Z][a-zA-Z\\d_-]{5,19}$',
  208. }]
  209. },
  210. phone: {
  211. rules: [{
  212. required: true,
  213. errorMessage: '请输入手机号',
  214. }, {
  215. errorMessage: '请输入正确的手机号',
  216. pattern: '^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\\d{8}$',
  217. }]
  218. },
  219. idCard: {
  220. rules: [{
  221. required: true,
  222. errorMessage: '请输入身份证号',
  223. }, {
  224. errorMessage: '请输入正确的身份证号',
  225. pattern: '^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$',
  226. }]
  227. },
  228. school: {
  229. rules: [{
  230. required: true,
  231. errorMessage: '请输入学校全称',
  232. }]
  233. },
  234. major: {
  235. rules: [{
  236. required: true,
  237. errorMessage: '请输入专业名称',
  238. }]
  239. },
  240. graduateMonth: {
  241. rules: [{
  242. required: true,
  243. errorMessage: '请选择全日制学历毕业年月',
  244. }]
  245. },
  246. nativePlace: {
  247. rules: [{
  248. required: true,
  249. errorMessage: '请输入籍贯',
  250. },
  251. {
  252. pattern: '[\\u4e00-\\u9fa5]+[\\u7701]{1}[\\u4e00-\\u9fa5]+[\\u5E02]{1}[\\u4e00-\\u9fa5]+[\\u53BF|\\u533A]{1}',
  253. errorMessage: '请输入正确的格式:xx省xx市xx区/县',
  254. }
  255. ]
  256. }
  257. }
  258. };
  259. },
  260. onLoad(option) {
  261. if (option.item) {
  262. this.baseFormData = JSON.parse(decodeURIComponent(option.item))
  263. this.buttonMessage = '修改认证'
  264. this.getPhotoes()
  265. } else {
  266. this.idCardFrontByte = [],
  267. this.idCardBackByte = [],
  268. this.teacherPhotoByte = [],
  269. this.diplomaPhotoByte = [],
  270. this.buttonMessage = '申请认证'
  271. }
  272. },
  273. methods: {
  274. ...mapMutations('m_user', ['updateAuthentication']),
  275. bindDateChange: function(e) {
  276. this.baseFormData.graduateMonth = e.target.value
  277. },
  278. getCurrentMonth () {
  279. const date = new Date()
  280. let year = date.getFullYear()
  281. let month = date.getMonth() + 1
  282. month = month > 9 ? month : '0' + month
  283. console.log(`${year}-${month}`)
  284. return `${year}-${month}`
  285. },
  286. // 获取图片
  287. async getPhotoes() {
  288. this.diplomaPhotoByte[0].url = this.baseFormData.diplomaPhoto
  289. this.diplomaPhotoByte[0].name = 'diplomaPhoto'
  290. this.idCardBackByte[0].url = this.baseFormData.idCardBack
  291. this.idCardBackByte[0].name = 'idCardBack'
  292. if(this.baseFormData.verifyStatus == "审核中"){
  293. this.teacherPhotoByte[0].url = this.baseFormData.teacherPhotoTemp
  294. }else{
  295. this.teacherPhotoByte[0].url = this.baseFormData.teacherPhoto
  296. }
  297. this.teacherPhotoByte[0].name = 'teacherPhoto'
  298. this.idCardFrontByte[0].url = this.baseFormData.idCardFront
  299. this.idCardFrontByte[0].name = 'idCardFront'
  300. },
  301. // 手机号
  302. async getPhoneNumber(e) {
  303. if (e.detail.code === undefined) return uni.$showMsg('获取手机号失败!')
  304. const query = {
  305. code: e.detail.code
  306. }
  307. const {
  308. data: result
  309. } = await uni.$http.get('/ucenter/mini-program-openid-uid/wxGetPhone', query)
  310. if (result.data.phone === '' || result.data.phone === null) {
  311. this.disabledPhone = false
  312. return uni.$showMsg('手机号获取失败,请手动输入')
  313. } else {
  314. this.baseFormData.phone = result.data.phone
  315. return uni.$showMsg('获取手机成功!')
  316. }
  317. },
  318. deletePhoto(item,e) {
  319. // console.log("删除",item)
  320. this.baseFormData[item] = ''
  321. },
  322. // 上传身份证正面
  323. selectPhoto(item,e) {
  324. // console.log('上传',item)
  325. switch(item) {
  326. case 'idCardFront':
  327. this.idCardFrontByte = []
  328. this.idCardFrontUrl = e.tempFilePaths[0]
  329. break
  330. case 'idCardBack':
  331. this.idCardBackByte = []
  332. this.idCardBackUrl = e.tempFilePaths[0]
  333. break
  334. case 'diplomaPhoto':
  335. this.diplomaPhotoByte = []
  336. this.diplomaPhotoUrl = e.tempFilePaths[0]
  337. break
  338. case 'teacherPhoto':
  339. this.teacherPhotoByte = []
  340. this.teacherPhotoUrl = e.tempFilePaths[0]
  341. break
  342. }
  343. },
  344. urlonok(item,ev) {
  345. // console.log('裁剪',item)
  346. const evPath = ev.path
  347. switch(item) {
  348. case 'idCardFront':
  349. this.idCardFrontByte = {
  350. url: evPath
  351. }
  352. this.idCardFrontUrl = ''
  353. this.upload(evPath, 'idCardFront')
  354. break
  355. case 'idCardBack':
  356. this.idCardBackByte = {
  357. url: evPath
  358. }
  359. this.idCardBackUrl = ''
  360. this.upload(evPath, 'idCardBack')
  361. break
  362. case 'diplomaPhoto':
  363. this.diplomaPhotoByte = {
  364. url: evPath
  365. }
  366. this.diplomaPhotoUrl = ''
  367. this.upload(evPath, 'diplomaPhoto')
  368. break
  369. case 'teacherPhoto':
  370. this.teacherPhotoByte = {
  371. url: evPath
  372. }
  373. this.teacherPhotoUrl = ''
  374. this.upload(evPath, 'teacherPhoto')
  375. break
  376. }
  377. },
  378. urloncancel(item) {
  379. // console.log('取消',item)
  380. switch(item) {
  381. case 'idCardFront':
  382. this.idCardFrontByte = null
  383. // url设置为空,隐藏控件
  384. this.idCardFrontUrl = "";
  385. break
  386. case 'idCardBack':
  387. this.idCardBackByte = null
  388. this.idCardBackUrl = "";
  389. break
  390. case 'diplomaPhoto':
  391. this.diplomaPhotoByte = null
  392. this.diplomaPhotoUrl = "";
  393. break
  394. case 'teacherPhoto':
  395. this.teacherPhotoByte = null
  396. this.teacherPhotoUrl = "";
  397. break
  398. }
  399. },
  400. upload(path, item) {
  401. wx.uploadFile({
  402. url: uni.$http.baseUrl + '/file/uploading',
  403. filePath: path,
  404. name: 'file',
  405. header: {
  406. token: uni.getStorageSync('token'),
  407. picName: item
  408. },
  409. success: res => {
  410. const result = JSON.parse(res.data)
  411. this.baseFormData[item] = result.data.url
  412. },
  413. fail: res => {
  414. if (res.errno === 1001) {
  415. uni.$showMsg('只能选择.jpg或者.png的图片')
  416. }
  417. }
  418. })
  419. },
  420. submit() {
  421. if (this.isLoading) {
  422. return uni.$showMsg('操作过快,请耐心等待…')
  423. }
  424. this.isLoading = true
  425. this.$refs.baseForm.validate().then(res => {
  426. if (this.baseFormData.phone === undefined || this.baseFormData.phone === '') return uni.$showMsg('手机号未获取!')
  427. if (this.baseFormData.idCardFront === undefined || this.baseFormData.idCardFront === '') return uni.$showMsg('身份证正面未上传!')
  428. if (this.baseFormData.idCardBack === undefined || this.baseFormData.idCardBack === '') return uni.$showMsg('身份证背面未上传!')
  429. if (this.baseFormData.diplomaPhoto === undefined || this.baseFormData.diplomaPhoto === '') return uni.$showMsg('学生/毕业证未上传!')
  430. if (this.baseFormData.teacherPhoto === undefined || this.baseFormData.teacherPhoto === '') return uni.$showMsg('头像未上传!')
  431. if (this.baseFormData.education === undefined || this.baseFormData.education === '') return uni.$showMsg('请选择学历')
  432. if (this.buttonMessage === '修改认证') {
  433. const certificationUrl = '/education/teacher-certifications/updateCertificationInfo'
  434. this.sendRequest(certificationUrl, 2)
  435. } else {
  436. const certificationUrl = '/education/teacher-certifications/saveCertificationInfo'
  437. this.sendRequest(certificationUrl, 1)
  438. }
  439. }).catch(err => {
  440. this.isLoading = false
  441. })
  442. this.isLoading = false
  443. },
  444. sendRequest(certificationUrl, count) {
  445. uni.request({
  446. url: uni.$http.baseUrl + certificationUrl,
  447. data: this.baseFormData,
  448. header: {
  449. token: uni.getStorageSync('token')
  450. },
  451. method: 'POST',
  452. success: res => {
  453. this.isLoading = false
  454. uni.$showMsg(res.data.message)
  455. this.updateAuthentication('审核中')
  456. setTimeout(() => {
  457. // uni.navigateBack({
  458. // delta: count
  459. // })
  460. uni.navigateTo({
  461. url: '/subpkg/teacher/authentication/teacher_authentication'
  462. })
  463. }, 1000)
  464. }
  465. })
  466. }
  467. }
  468. }
  469. </script>
  470. <!-- 设置页面背景 -->
  471. <style lang="scss">
  472. page{
  473. height: 100%;
  474. //background-color: #FFF2CC;
  475. }
  476. </style>
  477. <style lang="scss" scoped>
  478. .idCardFrontClass {
  479. position: absolute;
  480. left:-8000px;
  481. top:-8000px;
  482. }
  483. .idCardBackClass {
  484. position: absolute;
  485. left:-9000px;
  486. top:-9000px;
  487. }
  488. .diplomaPhotoClass {
  489. position: absolute;
  490. left:-7000px;
  491. top:-7000px;
  492. }
  493. .profilePhotoClass {
  494. position: absolute;
  495. left:-6000px;
  496. top:-6000px;
  497. }
  498. .auth-Container{
  499. width: 96%;
  500. height: 100%;
  501. padding-left: 20rpx;
  502. font-size: 30rpx;
  503. }
  504. .warning {
  505. color: red
  506. }
  507. // 提交按钮样式
  508. .submitBtnWrapper{
  509. height: 140rpx;
  510. align-items: center;
  511. }
  512. .submitBtn{
  513. width: 300rpx;
  514. border-radius: 50rpx;
  515. // margin-bottom: 40rpx;
  516. background-color: #35b882;
  517. font-size: 30rpx;
  518. }
  519. // 获取手机号按钮背景颜色
  520. .getPhone{
  521. font-size: 30rpx;
  522. border-radius: 40rpx;
  523. background-color: #35b882;
  524. //font-weight: bold;
  525. color: #FFF;
  526. //padding: 10rpx;
  527. }
  528. .phoneClass {
  529. margin-top: 6rpx;
  530. }
  531. .uni-input{
  532. //border: 1rpx solid;
  533. background-color: #FFF;
  534. height: 80rpx;
  535. border-radius: 10rpx;
  536. display: flex;
  537. align-items: center;
  538. justify-content: center;
  539. }
  540. </style>