order.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. <template>
  2. <view class="safeAreas">
  3. <nav-bar title="预约考试"></nav-bar>
  4. <view class="appointment">
  5. <view class="appointmentItem">
  6. <view class="title">考试地点:</view>
  7. <view class="place" @click="showAddress">
  8. <view class="name">{{ addressName }}</view>
  9. <view
  10. ><u-icon name="arrow-right" color="#999999" size="28"></u-icon
  11. ></view>
  12. </view>
  13. </view>
  14. <view class="appointmentItem" v-if="activeList.length">
  15. <view class="title">考试时间:</view>
  16. <view class="main">
  17. <view
  18. v-for="(item, index) in activeList"
  19. class="item"
  20. :key="index"
  21. @click="choItem(index)"
  22. >
  23. <view class="checkbox"
  24. ><u-checkbox
  25. v-if="item.status === 0"
  26. v-model="item.checked"
  27. shape="circle"
  28. ></u-checkbox
  29. ></view>
  30. <view class="box">
  31. <view
  32. :class="[
  33. 'time',
  34. { active: item.checked },
  35. { no: item.status !== 0 },
  36. ]"
  37. >{{
  38. item.dataTime + " " + item.startTime + " ~ " + item.endTime
  39. }}</view
  40. >
  41. <view class="statusInfo" v-if="item.status !== 0">
  42. <template v-if="item.status === 2"> 预约名额已满 </template>
  43. <template v-if="item.status === 1">
  44. 此时段您已经有其他考试预约
  45. </template>
  46. </view>
  47. </view>
  48. <view class="num"
  49. >已报:{{ item.registration }}/{{ item.num }}</view
  50. >
  51. </view>
  52. </view>
  53. </view>
  54. <view v-else class="appointmentItem">
  55. <view class="title">
  56. <text v-if="addressName && addressName != '请选择'">
  57. 该考试地点暂无考试时间,建议重新选择考试地点
  58. </text>
  59. <!-- <text v-else>
  60. 当前考培地点无考前培训时间点
  61. </text> -->
  62. </view>
  63. </view>
  64. <!-- 考试疫情承诺书 -->
  65. <view v-if="reportStatus == 1" class="appointmentItem">
  66. <view class="title"><text class="star_red">*</text>考试疫情防控承诺书</view>
  67. <view class="commitment">
  68. 本人参加“住房和城乡建设领域施工现场专业人员岗位”考试,愿意遵守疫情防控各项管理的相关要求,秉承对自己、对他人负责的原则,承担疫情防控社会责任,郑重作出以下承诺:<br/>
  69. 一、充分理解并遵守考试期间考点各项防疫安全的要求。<br/>
  70. 二、在考试前14天内,没有到过国内疫情中风险、高风险地区,未出境,不存在自境外回国情形。<br/>
  71. 三、在考试前14天内,每日自觉监测体温,体温均未出现高于37.3度的情形,无发热和呼吸道门诊就诊史。<br/>
  72. 四、在考试前14天内,未和新冠肺炎病例或疑似病例密切接触或间接接触,没有发烧、干咳、乏力、咳痰、气短、肌肉痛或关节痛、咽喉痛、头痛、寒颤、恶心或呕吐、鼻塞、腹泻、咳血、结膜充血等疑似新冠肺炎症状。<br/>
  73. 五、如出现与前述第二、三、四项任何一项不符的情形之一的,本人将及时在考前向相关管理机构报告,自觉配合采取隔离或其他防疫措施,并根据情况,自愿放弃参加考试。<br/>
  74. 六、考试当日自行做好防护工作,佩戴防护口罩。提前抵达考点,配合查验健康码、测量体温等。<br/>
  75. 七、考试期间,将严格遵守应考人员考场守则及疫情防控相关管理要求,完成考试后立即离场,不扎堆,不聚集。<br/>
  76. 八、本人承诺遵守《应考人员安全承诺书》中所有承诺内容,若因有瞒报、谎报造成新冠肺炎疫情传播的,一经查实,由本人承担相应的法律和经济责任。
  77. </view>
  78. </view>
  79. <view v-if="reportStatus == 1" class="appointmentItem ">
  80. <view class="title"><text class="star_red">*</text>签名板</view>
  81. <view class="dis_stys">
  82. <text style="color: #999999">请在下方签名区进行签名</text>
  83. <text @click="retDraw" mode="">清空</text>
  84. </view>
  85. <view class="handCenter">
  86. <view v-show="!address_show" class="can_vas">
  87. <canvas
  88. class="handWriting"
  89. disable-scroll="true"
  90. :catchtouchmove="true"
  91. @touchstart="uploadScaleStart"
  92. @touchmove="uploadScaleMove"
  93. @touchend="uploadScaleEnd"
  94. canvas-id="handWriting"
  95. ></canvas>
  96. </view>
  97. <view v-show="address_show" class="no_true"></view>
  98. <!-- <view
  99. v-else
  100. style="width: 100%; height: 100%; position: relative"
  101. >
  102. <view class="ctoples">图片</view>
  103. <image
  104. style="width: 100%; height: 100%"
  105. :src="$method.splitImgHost(form[item.fieldKey])"
  106. mode=""
  107. ></image>
  108. </view> -->
  109. </view>
  110. </view>
  111. <view class="btnMain">
  112. <view class="return" @click="backPage">上一步</view>
  113. <view class="sure" @click="sureOppoint">{{
  114. dataId === 1 ? "下一步" : dataId === 2 ? "确定预约" : "异常"
  115. }}</view>
  116. </view>
  117. </view>
  118. <!-- 弹框-->
  119. <u-popup v-model="address_show" mode="bottom" class="addModel">
  120. <view class="tipBox safeArea">
  121. <view class="line"></view>
  122. <view class="title">温馨提示</view>
  123. <u-line color="#EEEEEE" />
  124. <scroll-view class="addressList" :scroll-y="true">
  125. <view
  126. class="item"
  127. v-for="(item, index) in listData"
  128. :key="index"
  129. @click="choAddress(item, index)"
  130. >
  131. <u-checkbox
  132. class="checkbox"
  133. v-model="item.checked"
  134. shape="circle"
  135. ></u-checkbox>
  136. <view :class="['address', { active: item.checked }]">{{
  137. item.siteAddress
  138. }}</view>
  139. </view>
  140. </scroll-view>
  141. <u-line color="#EEEEEE" />
  142. <view class="btn" @click="sureAddress">确认</view>
  143. </view>
  144. </u-popup>
  145. </view>
  146. </template>
  147. <script>
  148. import { mapGetters } from "vuex";
  149. import Handwriting from "@/common/signature.js";
  150. export default {
  151. data() {
  152. return {
  153. orderGoodsId: 0,
  154. address_show: false,
  155. addressName: "请选择",
  156. addressId: null, //当前选中考试点ID
  157. listData: [], //考试地点数据
  158. activeList: [], //选中考试地点列表
  159. applyId: null, //考试计划ID
  160. goodsId: null, //商品ID
  161. applyStatus: null, //学员状态ID
  162. sysTime: 0,
  163. dataId: null, //跳转拷贝
  164. handwriting: '',
  165. lineColor: "black",
  166. slideValue: 30,
  167. openVerify: false, // 控制是否手动验证
  168. commitment_electr_signature: '',
  169. isUploading: false,
  170. siteId: '', // 考场id
  171. reportStatus: 0, // 是否线上签署疫情防控承诺书, 1是,0否
  172. baseAddress: '', // 签名转成base64
  173. };
  174. },
  175. async onLoad(option) {
  176. this.applyId = Number(option.applyId);
  177. this.goodsId = Number(option.goodsId);
  178. this.applyStatus = Number(option.applyStatus);
  179. this.dataId = Number(option.dataId);
  180. this.orderGoodsId = Number(option.orderGoodsId);
  181. this.reportStatus = option.reportStatus
  182. await this.commonSystemTime();
  183. this.getInfo();
  184. },
  185. onReady(res) {
  186. this.handwriting = new Handwriting({
  187. lineColor: this.lineColor,
  188. slideValue: this.slideValue, // 0, 25, 50, 75, 100
  189. canvasName: "handWriting",
  190. });
  191. // this.$refs.uForm.setRules(this.rules);
  192. },
  193. methods: {
  194. commonSystemTime() {
  195. return new Promise((resolve) => {
  196. this.$api.commonSystemTime().then((res) => {
  197. this.sysTime = res.data.data;
  198. resolve();
  199. });
  200. });
  201. },
  202. //获取考试地点
  203. getInfo() {
  204. // apply/subscribeApplySite
  205. this.$api
  206. .getApplysubscribeApplySite({ applyId: this.applyId })
  207. .then((res) => {
  208. if (res.data.code === 200) {
  209. res.data.data.forEach((item, index) => {
  210. item.checked = false;
  211. });
  212. this.listData = res.data.data;
  213. console.log('this.listData:', this.listData)
  214. }
  215. });
  216. },
  217. showAddress() {
  218. this.address_show = true;
  219. },
  220. choAddress(item, index) {
  221. this.siteId = item.siteId
  222. this.listData.forEach((item, idx) => {
  223. this.$set(item, "checked", false);
  224. if (idx === index) {
  225. this.$set(item, "checked", true);
  226. }
  227. });
  228. },
  229. sureAddress() {
  230. var self = this;
  231. const index = this.listData.findIndex((item) => item.checked);
  232. if (index === -1) {
  233. uni.showToast({
  234. title: "请选择考试地点",
  235. icon: "none",
  236. });
  237. return;
  238. }
  239. this.siteId = this.listData[index].siteId
  240. console.log('siteId: ', this.siteId, index)
  241. if (this.addressId === this.listData[index].id) {
  242. this.address_show = false;
  243. return;
  244. }
  245. this.addressName = this.listData[index].siteAddress;
  246. console.log('addressName', this.addressName, this.listData)
  247. this.addressId = this.listData[index].id;
  248. var arrays = [];
  249. this.listData[index].examUserApplySiteTime.forEach((item) => {
  250. item.examApplySiteTimeTwoVo.forEach((items) => {
  251. arrays.push({
  252. examTime: item.examTime,
  253. startTimeC: items.startTime,
  254. endTimeC: items.endTime,
  255. dataTime: self.$method
  256. .timestampToTime(item.examTime)
  257. .replace(/-/g, "/"),
  258. startTime: items.startTime,
  259. endTime: items.endTime,
  260. num: items.num,
  261. registration: items.registration,
  262. checked: false,
  263. status:
  264. items.status === 1
  265. ? items.status
  266. : items.registration >= items.num
  267. ? 2
  268. : items.status,
  269. });
  270. });
  271. });
  272. console.log('arrays', arrays)
  273. this.activeList = arrays.filter((item, index) => {
  274. console.log(item);
  275. // const newTime = parseInt(new Date().getTime() / 1000)
  276. // console.log(
  277. // item.dataTime.replace(/-/g, "/") + "" + item.startTime + ":00"
  278. // );
  279. const liTime = parseInt(
  280. new Date(
  281. item.dataTime.replace(/-/g, "/") + "" + item.startTime + ":00"
  282. ).getTime() / 1000
  283. );
  284. console.log(liTime, "liTime");
  285. console.log(this.sysTime, "newTime");
  286. if (liTime > this.sysTime) {
  287. return item;
  288. }
  289. });
  290. console.log('----',this.activeList);
  291. this.address_show = false;
  292. },
  293. choItem(index) {
  294. const item = this.activeList[index];
  295. if (item.status !== 0) {
  296. return;
  297. }
  298. this.activeList.forEach((item, idx) => {
  299. item.checked = false;
  300. if (idx === index) {
  301. item.checked = true;
  302. }
  303. });
  304. },
  305. async sureOppoint() {
  306. if (this.isUploading) {
  307. return;
  308. }
  309. this.isUploading = true
  310. var self = this;
  311. if (self.addressId) {
  312. var ast = self.activeList.some((item) => {
  313. return item.checked === true;
  314. });
  315. console.log('ast',this.activeList, ast)
  316. if (ast) {
  317. if (this.reportStatus == 1) {
  318. await this.subCanvas()
  319. if (!this.commitment_electr_signature) {
  320. uni.showToast({
  321. title: "请签名",
  322. icon: "none",
  323. })
  324. this.isUploading = false
  325. return
  326. } else {
  327. // await this.submitApi()
  328. uni.request({
  329. url: this.commitment_electr_signature, //临时路径
  330. responseType: 'arraybuffer', //设置返回的数据格式为arraybuffer
  331. success: res => {
  332. const base64 = "data:image/png;base64," + uni.arrayBufferToBase64(res.data)
  333. console.log('sfs签名转成base64', base64)
  334. this.baseAddress = base64
  335. this.submits()
  336. },
  337. fail: err => {
  338. console.log(err)
  339. this.isUploading = false
  340. }
  341. })
  342. }
  343. } else {
  344. this.submits()
  345. }
  346. } else {
  347. uni.showToast({
  348. title: "请选择考试时间",
  349. icon: "none",
  350. });
  351. this.isUploading = false
  352. }
  353. } else {
  354. uni.showToast({
  355. title: "请选择考试地点",
  356. icon: "none",
  357. });
  358. this.isUploading = false
  359. }
  360. },
  361. submits() {
  362. uni.showLoading({
  363. title: '拼命加载中...',
  364. mask:true,
  365. })
  366. var copyData = JSON.parse(JSON.stringify(this.activeList));
  367. const index = copyData.findIndex((item) => item.checked);
  368. var data = {
  369. applyId: this.applyId,
  370. goodsId: this.goodsId,
  371. studentType: this.applyStatus,
  372. applySiteAddress: this.addressName,
  373. applySiteExamTime: copyData[index].examTime,
  374. applySiteStartTime: copyData[index].startTimeC,
  375. applySiteEndTime: copyData[index].endTimeC,
  376. orderGoodsId: this.orderGoodsId,
  377. siteId: this.siteId, // 考场id
  378. };
  379. if (this.reportStatus == 1) {
  380. data.signImageStr = this.baseAddress
  381. }
  382. console.log('-----data', data, this.dataId)
  383. // return
  384. if (this.dataId === 1) {
  385. this.$store.commit("updateApplyData", data);
  386. this.$navTo.togo("/pages2/appointment/kporder", {
  387. applyId: this.applyId,
  388. applyStatus: this.applyStatus,
  389. goodsId: this.goodsId,
  390. orderGoodsId: this.orderGoodsId,
  391. });
  392. uni.hideLoading()
  393. }
  394. if (this.dataId === 2) {
  395. this.$api.addApply(data).then((res) => {
  396. if (res.data.code === 200) {
  397. uni.reLaunch({
  398. url: `/pages2/appointment/appointment_success?subscribeId=${res.data.data}`,
  399. });
  400. } else {
  401. uni.showToast({
  402. icon: "none",
  403. title: res.data.msg || '预约失败,请重新预约',
  404. });
  405. }
  406. uni.hideLoading()
  407. });
  408. }
  409. this.isUploading = false
  410. },
  411. backPage() {
  412. uni.navigateBack({
  413. delta: 1,
  414. });
  415. },
  416. retDraw() {
  417. this.handwriting.retDraw()
  418. this.commitment_electr_signature = ''
  419. // this.$set(this.form, "commitment_electr_signature", "");
  420. this.openVerify = false;
  421. },
  422. uploadScaleStart(event) {
  423. this.handwriting.uploadScaleStart(event);
  424. },
  425. uploadScaleMove(event) {
  426. this.handwriting.uploadScaleMove(event);
  427. },
  428. uploadScaleEnd(event) {
  429. this.handwriting.uploadScaleEnd(event);
  430. },
  431. async subCanvas() {
  432. console.log("签名-------");
  433. return new Promise((resolve, reject) => {
  434. if (this.commitment_electr_signature) {
  435. resolve();
  436. return;
  437. }
  438. this.handwriting.saveCanvas().then((res) => {
  439. if (this.handwriting.linePrack.length) {
  440. console.log('签名-----res', res)
  441. this.commitment_electr_signature = res
  442. }
  443. resolve(res)
  444. })
  445. .catch((err) => {
  446. uni.showToast({
  447. title: "签名上传失败",
  448. icon: "error",
  449. });
  450. this.isUploading = false
  451. });
  452. });
  453. },
  454. //提交表单
  455. // async submitApi() {
  456. // if (this.commitment_electr_signature) {
  457. // // this.commitment_electr_signature = await this.$method.uploadFile(
  458. // // this.commitment_electr_signature,
  459. // // 0
  460. // // );
  461. // var res = await uni.request({
  462. // url: this.commitment_electr_signature, //临时路径
  463. // responseType: 'arraybuffer', //设置返回的数据格式为arraybuffer
  464. // success: res => {
  465. // const base64 = "data:image/png;base64," + uni.arrayBufferToBase64(res.data)
  466. // console.log('sfs签名转成base64', base64)
  467. // this.baseAddress = base64
  468. // }
  469. // })
  470. // console.log('----commitment_electr_signature',res, this.commitment_electr_signature)
  471. // }
  472. // },
  473. },
  474. };
  475. </script>
  476. <style>
  477. page {
  478. background-color: #eaeef1;
  479. }
  480. .addModel .u-drawer-bottom {
  481. box-shadow: 0px 0px 16px 4px rgba(145, 156, 178, 0.1);
  482. border-radius: 32rpx 32rpx 0px 0px;
  483. }
  484. </style>
  485. <style scoped lang="scss">
  486. .safeAreas {
  487. padding-bottom: 30rpx;
  488. }
  489. .appointment {
  490. padding: 0 8rpx;
  491. .appointmentItem {
  492. margin: 24rpx 0 40rpx;
  493. .title {
  494. font-size: 30rpx;
  495. font-family: PingFang SC;
  496. font-weight: 500;
  497. color: #333333;
  498. line-height: 1;
  499. margin-bottom: 16rpx;
  500. padding-left: 24rpx;
  501. .star_red {
  502. color: red;
  503. }
  504. }
  505. .place {
  506. height: 80rpx;
  507. background: #ffffff;
  508. border-radius: 16rpx;
  509. display: flex;
  510. justify-content: space-between;
  511. align-items: center;
  512. padding: 0 24rpx;
  513. }
  514. .commitment {
  515. padding: 12rpx;
  516. height: 300rpx;
  517. background: #ffffff;
  518. overflow-y: auto;
  519. }
  520. .handCenter, .dis_stys, .commitment {
  521. margin: 0rpx 24rpx;
  522. }
  523. .dis_stys {
  524. display: flex;
  525. justify-content: space-between;
  526. align-items: center;
  527. margin-bottom: 16rpx;
  528. }
  529. .handCenter {
  530. .handWriting, .no_true {
  531. width: 100%;
  532. height: 400rpx;
  533. background: #fff;
  534. }
  535. }
  536. }
  537. .main {
  538. background: #ffffff;
  539. border-radius: 16rpx;
  540. padding: 32rpx 16rpx;
  541. .item {
  542. display: flex;
  543. align-items: center;
  544. margin-bottom: 16rpx;
  545. font-size: 28rpx;
  546. font-family: PingFang SC;
  547. font-weight: 500;
  548. color: #333333;
  549. .statusInfo {
  550. font-size: 24rpx;
  551. font-family: PingFang SC;
  552. font-weight: 500;
  553. color: #ff3b30;
  554. padding-left: 24rpx;
  555. }
  556. .checkbox {
  557. width: 32rpx;
  558. height: 32rpx;
  559. display: flex;
  560. align-items: center;
  561. }
  562. .time {
  563. width: 430rpx;
  564. height: 80rpx;
  565. line-height: 80rpx;
  566. background: #f5f5f5;
  567. border: 2rpx solid #f5f5f5;
  568. border-radius: 16rpx;
  569. font-size: 30rpx;
  570. font-family: PingFang SC;
  571. font-weight: bold;
  572. text-align: center;
  573. color: #333333;
  574. margin: 0 18rpx 0 8rpx;
  575. &.active {
  576. background: #ebf5ff;
  577. border: 2rpx solid #007aff;
  578. }
  579. &.no {
  580. background: #ffdddb;
  581. border: 2rpx solid #ffdddb;
  582. }
  583. }
  584. }
  585. }
  586. .btnMain {
  587. display: flex;
  588. justify-content: center;
  589. text-align: center;
  590. .return {
  591. width: 200rpx;
  592. height: 80rpx;
  593. line-height: 80rpx;
  594. background: #f5f5f5;
  595. border-radius: 40rpx;
  596. font-size: 30rpx;
  597. font-family: PingFang SC;
  598. font-weight: bold;
  599. color: #007aff;
  600. }
  601. .sure {
  602. width: 438rpx;
  603. height: 80rpx;
  604. line-height: 80rpx;
  605. background: #007aff;
  606. border-radius: 40rpx;
  607. font-size: 30rpx;
  608. font-family: PingFang SC;
  609. font-weight: bold;
  610. color: #ffffff;
  611. margin-left: 24rpx;
  612. }
  613. }
  614. }
  615. .tipBox {
  616. width: 100%;
  617. font-family: PingFang SC;
  618. .line {
  619. width: 80rpx;
  620. height: 8rpx;
  621. background: #999999;
  622. border-radius: 4rpx;
  623. margin: 8rpx auto;
  624. }
  625. .title {
  626. text-align: center;
  627. font-size: 24rpx;
  628. font-family: PingFang SC;
  629. font-weight: 500;
  630. color: #999999;
  631. margin: 15rpx 0;
  632. }
  633. .main {
  634. font-size: 30rpx;
  635. font-weight: 500;
  636. color: #666666;
  637. line-height: 48rpx;
  638. margin-bottom: 40rpx;
  639. }
  640. .addressList {
  641. height: 500rpx;
  642. padding-top: 24rpx;
  643. .item {
  644. display: flex;
  645. align-items: center;
  646. padding: 0 24rpx;
  647. margin-bottom: 24rpx;
  648. .checkbox {
  649. width: 32rpx;
  650. height: 32rpx;
  651. display: flex;
  652. align-items: center;
  653. margin-right: 8rpx;
  654. }
  655. .address {
  656. width: 654rpx;
  657. height: 80rpx;
  658. line-height: 80rpx;
  659. background: #f5f5f5;
  660. border-radius: 16rpx;
  661. font-size: 30rpx;
  662. font-family: PingFang SC;
  663. font-weight: bold;
  664. color: #333333;
  665. padding: 0 24rpx;
  666. &.active {
  667. background: #ebf5ff;
  668. border: 2rpx solid #007aff;
  669. }
  670. }
  671. }
  672. }
  673. .btn {
  674. width: 200rpx;
  675. height: 64rpx;
  676. line-height: 64rpx;
  677. background: linear-gradient(0deg, #015eea, #00c0fa);
  678. border-radius: 32rpx;
  679. margin: 17rpx auto;
  680. font-size: 30rpx;
  681. font-family: PingFang SC;
  682. font-weight: 500;
  683. text-align: center;
  684. color: #ffffff;
  685. }
  686. }
  687. </style>