order.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  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 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 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. <!-- v-if="!form[item.fieldKey]" -->
  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. v-else
  98. style="width: 100%; height: 100%; position: relative"
  99. >
  100. <view class="ctoples">图片</view>
  101. <image
  102. style="width: 100%; height: 100%"
  103. :src="$method.splitImgHost(form[item.fieldKey])"
  104. mode=""
  105. ></image>
  106. </view> -->
  107. </view>
  108. </view>
  109. <view class="btnMain">
  110. <view class="return" @click="backPage">上一步</view>
  111. <view class="sure" @click="sureOppoint">{{
  112. dataId === 1 ? "下一步" : dataId === 2 ? "确定预约" : "异常"
  113. }}</view>
  114. </view>
  115. </view>
  116. <!-- 弹框-->
  117. <u-popup v-model="address_show" mode="bottom" class="addModel">
  118. <view class="tipBox safeArea">
  119. <view class="line"></view>
  120. <view class="title">温馨提示</view>
  121. <u-line color="#EEEEEE" />
  122. <scroll-view class="addressList" :scroll-y="true">
  123. <view
  124. class="item"
  125. v-for="(item, index) in listData"
  126. :key="index"
  127. @click="choAddress(item, index)"
  128. >
  129. <u-checkbox
  130. class="checkbox"
  131. v-model="item.checked"
  132. shape="circle"
  133. ></u-checkbox>
  134. <view :class="['address', { active: item.checked }]">{{
  135. item.siteAddress
  136. }}</view>
  137. </view>
  138. </scroll-view>
  139. <u-line color="#EEEEEE" />
  140. <view class="btn" @click="sureAddress">确认</view>
  141. </view>
  142. </u-popup>
  143. </view>
  144. </template>
  145. <script>
  146. import { mapGetters } from "vuex";
  147. import Handwriting from "@/common/signature.js";
  148. export default {
  149. data() {
  150. return {
  151. orderGoodsId: 0,
  152. address_show: false,
  153. addressName: "请选择",
  154. addressId: null, //当前选中考试点ID
  155. listData: [], //考试地点数据
  156. activeList: [], //选中考试地点列表
  157. applyId: null, //考试计划ID
  158. goodsId: null, //商品ID
  159. applyStatus: null, //学员状态ID
  160. sysTime: 0,
  161. dataId: null, //跳转拷贝
  162. handwriting: '',
  163. lineColor: "black",
  164. slideValue: 30,
  165. openVerify: false, // 控制是否手动验证
  166. commitment_electr_signature: '',
  167. isUploading: false,
  168. siteId: '', // 考试id
  169. reportStatus: 0, // 是否线上签署疫情防控承诺书, 1是,0否
  170. baseAddress: '', // 签名转成base64
  171. };
  172. },
  173. async onLoad(option) {
  174. this.applyId = Number(option.applyId);
  175. this.goodsId = Number(option.goodsId);
  176. this.applyStatus = Number(option.applyStatus);
  177. this.dataId = Number(option.dataId);
  178. this.orderGoodsId = Number(option.orderGoodsId);
  179. this.reportStatus = option.reportStatus
  180. await this.commonSystemTime();
  181. this.getInfo();
  182. },
  183. onReady(res) {
  184. this.handwriting = new Handwriting({
  185. lineColor: this.lineColor,
  186. slideValue: this.slideValue, // 0, 25, 50, 75, 100
  187. canvasName: "handWriting",
  188. });
  189. // this.$refs.uForm.setRules(this.rules);
  190. },
  191. methods: {
  192. commonSystemTime() {
  193. return new Promise((resolve) => {
  194. this.$api.commonSystemTime().then((res) => {
  195. this.sysTime = res.data.data;
  196. resolve();
  197. });
  198. });
  199. },
  200. //获取考试地点
  201. getInfo() {
  202. // apply/subscribeApplySite
  203. this.$api
  204. .getApplysubscribeApplySite({ applyId: this.applyId })
  205. .then((res) => {
  206. if (res.data.code === 200) {
  207. res.data.data.forEach((item, index) => {
  208. item.checked = false;
  209. });
  210. this.listData = res.data.data;
  211. console.log('this.listData:', this.listData)
  212. }
  213. });
  214. },
  215. showAddress() {
  216. this.address_show = true;
  217. },
  218. choAddress(item, index) {
  219. this.siteId = item.siteId
  220. this.listData.forEach((item, idx) => {
  221. this.$set(item, "checked", false);
  222. if (idx === index) {
  223. this.$set(item, "checked", true);
  224. }
  225. });
  226. },
  227. sureAddress() {
  228. var self = this;
  229. const index = this.listData.findIndex((item) => item.checked);
  230. if (index === -1) {
  231. uni.showToast({
  232. title: "请选择考试地点",
  233. icon: "none",
  234. });
  235. return;
  236. }
  237. this.siteId = this.listData[index].siteId
  238. console.log('siteId: ', this.siteId, index)
  239. if (this.addressId === this.listData[index].id) {
  240. this.address_show = false;
  241. return;
  242. }
  243. this.addressName = this.listData[index].siteAddress;
  244. console.log('addressName', this.addressName, this.listData)
  245. this.addressId = this.listData[index].id;
  246. var arrays = [];
  247. this.listData[index].examUserApplySiteTime.forEach((item) => {
  248. item.examApplySiteTimeTwoVo.forEach((items) => {
  249. arrays.push({
  250. examTime: item.examTime,
  251. startTimeC: items.startTime,
  252. endTimeC: items.endTime,
  253. dataTime: self.$method
  254. .timestampToTime(item.examTime)
  255. .replace(/-/g, "/"),
  256. startTime: items.startTime,
  257. endTime: items.endTime,
  258. num: items.num,
  259. registration: items.registration,
  260. checked: false,
  261. status:
  262. items.status === 1
  263. ? items.status
  264. : items.registration >= items.num
  265. ? 2
  266. : items.status,
  267. });
  268. });
  269. });
  270. console.log('arrays', arrays)
  271. this.activeList = arrays.filter((item, index) => {
  272. console.log(item);
  273. // const newTime = parseInt(new Date().getTime() / 1000)
  274. // console.log(
  275. // item.dataTime.replace(/-/g, "/") + "" + item.startTime + ":00"
  276. // );
  277. const liTime = parseInt(
  278. new Date(
  279. item.dataTime.replace(/-/g, "/") + "" + item.startTime + ":00"
  280. ).getTime() / 1000
  281. );
  282. console.log(liTime, "liTime");
  283. console.log(this.sysTime, "newTime");
  284. if (liTime > this.sysTime) {
  285. return item;
  286. }
  287. });
  288. console.log('----',this.activeList);
  289. this.address_show = false;
  290. },
  291. choItem(index) {
  292. const item = this.activeList[index];
  293. if (item.status !== 0) {
  294. return;
  295. }
  296. this.activeList.forEach((item, idx) => {
  297. item.checked = false;
  298. if (idx === index) {
  299. item.checked = true;
  300. }
  301. });
  302. },
  303. async sureOppoint() {
  304. if (this.isUploading) {
  305. return;
  306. }
  307. this.isUploading = true
  308. var self = this;
  309. if (self.addressId) {
  310. var ast = self.activeList.some((item) => {
  311. return item.checked === true;
  312. });
  313. console.log('ast',this.activeList, ast)
  314. if (ast) {
  315. if (this.reportStatus == 1) {
  316. await this.subCanvas()
  317. if (!this.commitment_electr_signature) {
  318. uni.showToast({
  319. title: "请签名",
  320. icon: "none",
  321. })
  322. return
  323. } else {
  324. // await this.submitApi()
  325. if (this.commitment_electr_signature) {
  326. uni.request({
  327. url: this.commitment_electr_signature, //临时路径
  328. responseType: 'arraybuffer', //设置返回的数据格式为arraybuffer
  329. success: res => {
  330. const base64 = "data:image/png;base64," + uni.arrayBufferToBase64(res.data)
  331. console.log('sfs签名转成base64', base64)
  332. this.baseAddress = base64
  333. this.submits()
  334. },
  335. fail: err => {
  336. console.log(err)
  337. }
  338. })
  339. }
  340. }
  341. } else {
  342. this.submits()
  343. }
  344. } else {
  345. uni.showToast({
  346. title: "请选择考试时间",
  347. icon: "none",
  348. });
  349. this.isUploading = false
  350. }
  351. } else {
  352. uni.showToast({
  353. title: "请选择考试地点",
  354. icon: "none",
  355. });
  356. this.isUploading = false
  357. }
  358. },
  359. submits() {
  360. var copyData = JSON.parse(JSON.stringify(this.activeList));
  361. const index = copyData.findIndex((item) => item.checked);
  362. var data = {
  363. applyId: this.applyId,
  364. goodsId: this.goodsId,
  365. studentType: this.applyStatus,
  366. applySiteAddress: this.addressName,
  367. applySiteExamTime: copyData[index].examTime,
  368. applySiteStartTime: copyData[index].startTimeC,
  369. applySiteEndTime: copyData[index].endTimeC,
  370. orderGoodsId: this.orderGoodsId,
  371. siteId: this.siteId, // 考场id
  372. };
  373. if (this.reportStatus == 1) {
  374. data.signImageStr = this.baseAddress
  375. }
  376. console.log('-----data', data, this.dataId)
  377. // return
  378. if (this.dataId === 1) {
  379. this.$store.commit("updateApplyData", data);
  380. this.$navTo.togo("/pages2/appointment/kporder", {
  381. applyId: this.applyId,
  382. applyStatus: this.applyStatus,
  383. goodsId: this.goodsId,
  384. orderGoodsId: this.orderGoodsId,
  385. });
  386. }
  387. if (this.dataId === 2) {
  388. this.$api.addApply(data).then((res) => {
  389. if (res.data.code === 200) {
  390. uni.reLaunch({
  391. url: `/pages2/appointment/appointment_success?subscribeId=${res.data.data}`,
  392. });
  393. } else {
  394. uni.showToast({
  395. icon: "none",
  396. title: res.data.msg,
  397. });
  398. }
  399. });
  400. }
  401. this.isUploading = false
  402. },
  403. backPage() {
  404. uni.navigateBack({
  405. delta: 1,
  406. });
  407. },
  408. retDraw() {
  409. this.handwriting.retDraw()
  410. this.commitment_electr_signature = ''
  411. // this.$set(this.form, "commitment_electr_signature", "");
  412. this.openVerify = false;
  413. },
  414. uploadScaleStart(event) {
  415. this.handwriting.uploadScaleStart(event);
  416. },
  417. uploadScaleMove(event) {
  418. this.handwriting.uploadScaleMove(event);
  419. },
  420. uploadScaleEnd(event) {
  421. this.handwriting.uploadScaleEnd(event);
  422. },
  423. async subCanvas() {
  424. console.log("签名-------");
  425. return new Promise((resolve, reject) => {
  426. if (this.commitment_electr_signature) {
  427. resolve();
  428. return;
  429. }
  430. this.handwriting.saveCanvas().then((res) => {
  431. if (this.handwriting.linePrack.length) {
  432. console.log('签名-----res', res)
  433. // this.$set(this.form, "commitment_electr_signature", res);
  434. this.commitment_electr_signature = res
  435. }
  436. resolve(res)
  437. })
  438. .catch((err) => {
  439. uni.showToast({
  440. title: "签名上传失败",
  441. icon: "error",
  442. });
  443. });
  444. this.isUploading = false
  445. });
  446. },
  447. //提交表单
  448. async submitApi() {
  449. if (this.commitment_electr_signature) {
  450. // this.commitment_electr_signature = await this.$method.uploadFile(
  451. // this.commitment_electr_signature,
  452. // 0
  453. // );
  454. var res = await uni.request({
  455. url: this.commitment_electr_signature, //临时路径
  456. responseType: 'arraybuffer', //设置返回的数据格式为arraybuffer
  457. success: res => {
  458. const base64 = "data:image/png;base64," + uni.arrayBufferToBase64(res.data)
  459. console.log('sfs签名转成base64', base64)
  460. this.baseAddress = base64
  461. }
  462. })
  463. console.log('----commitment_electr_signature',res, this.commitment_electr_signature)
  464. }
  465. },
  466. },
  467. };
  468. </script>
  469. <style>
  470. page {
  471. background-color: #eaeef1;
  472. }
  473. .addModel .u-drawer-bottom {
  474. box-shadow: 0px 0px 16px 4px rgba(145, 156, 178, 0.1);
  475. border-radius: 32rpx 32rpx 0px 0px;
  476. }
  477. </style>
  478. <style scoped lang="scss">
  479. .safeAreas {
  480. padding-bottom: 30rpx;
  481. }
  482. .appointment {
  483. padding: 0 8rpx;
  484. .appointmentItem {
  485. margin: 24rpx 0 40rpx;
  486. .title {
  487. font-size: 30rpx;
  488. font-family: PingFang SC;
  489. font-weight: 500;
  490. color: #333333;
  491. line-height: 1;
  492. margin-bottom: 16rpx;
  493. padding-left: 24rpx;
  494. .star_red {
  495. color: red;
  496. }
  497. }
  498. .place {
  499. height: 80rpx;
  500. background: #ffffff;
  501. border-radius: 16rpx;
  502. display: flex;
  503. justify-content: space-between;
  504. align-items: center;
  505. padding: 0 24rpx;
  506. }
  507. .commitment {
  508. padding: 12rpx;
  509. height: 300rpx;
  510. background: #ffffff;
  511. overflow-y: auto;
  512. }
  513. .handCenter, .dis_stys, .commitment {
  514. margin: 0rpx 24rpx;
  515. }
  516. .dis_stys {
  517. display: flex;
  518. justify-content: space-between;
  519. align-items: center;
  520. margin-bottom: 16rpx;
  521. }
  522. .handCenter {
  523. .handWriting {
  524. width: 100%;
  525. height: 400rpx;
  526. background: #fff;
  527. }
  528. }
  529. }
  530. .main {
  531. background: #ffffff;
  532. border-radius: 16rpx;
  533. padding: 32rpx 16rpx;
  534. .item {
  535. display: flex;
  536. align-items: center;
  537. margin-bottom: 16rpx;
  538. font-size: 28rpx;
  539. font-family: PingFang SC;
  540. font-weight: 500;
  541. color: #333333;
  542. .statusInfo {
  543. font-size: 24rpx;
  544. font-family: PingFang SC;
  545. font-weight: 500;
  546. color: #ff3b30;
  547. padding-left: 24rpx;
  548. }
  549. .checkbox {
  550. width: 32rpx;
  551. height: 32rpx;
  552. display: flex;
  553. align-items: center;
  554. }
  555. .time {
  556. width: 430rpx;
  557. height: 80rpx;
  558. line-height: 80rpx;
  559. background: #f5f5f5;
  560. border: 2rpx solid #f5f5f5;
  561. border-radius: 16rpx;
  562. font-size: 30rpx;
  563. font-family: PingFang SC;
  564. font-weight: bold;
  565. text-align: center;
  566. color: #333333;
  567. margin: 0 18rpx 0 8rpx;
  568. &.active {
  569. background: #ebf5ff;
  570. border: 2rpx solid #007aff;
  571. }
  572. &.no {
  573. background: #ffdddb;
  574. border: 2rpx solid #ffdddb;
  575. }
  576. }
  577. }
  578. }
  579. .btnMain {
  580. display: flex;
  581. justify-content: center;
  582. text-align: center;
  583. .return {
  584. width: 200rpx;
  585. height: 80rpx;
  586. line-height: 80rpx;
  587. background: #f5f5f5;
  588. border-radius: 40rpx;
  589. font-size: 30rpx;
  590. font-family: PingFang SC;
  591. font-weight: bold;
  592. color: #007aff;
  593. }
  594. .sure {
  595. width: 438rpx;
  596. height: 80rpx;
  597. line-height: 80rpx;
  598. background: #007aff;
  599. border-radius: 40rpx;
  600. font-size: 30rpx;
  601. font-family: PingFang SC;
  602. font-weight: bold;
  603. color: #ffffff;
  604. margin-left: 24rpx;
  605. }
  606. }
  607. }
  608. .tipBox {
  609. width: 100%;
  610. font-family: PingFang SC;
  611. .line {
  612. width: 80rpx;
  613. height: 8rpx;
  614. background: #999999;
  615. border-radius: 4rpx;
  616. margin: 8rpx auto;
  617. }
  618. .title {
  619. text-align: center;
  620. font-size: 24rpx;
  621. font-family: PingFang SC;
  622. font-weight: 500;
  623. color: #999999;
  624. margin: 15rpx 0;
  625. }
  626. .main {
  627. font-size: 30rpx;
  628. font-weight: 500;
  629. color: #666666;
  630. line-height: 48rpx;
  631. margin-bottom: 40rpx;
  632. }
  633. .addressList {
  634. height: 500rpx;
  635. padding-top: 24rpx;
  636. .item {
  637. display: flex;
  638. align-items: center;
  639. padding: 0 24rpx;
  640. margin-bottom: 24rpx;
  641. .checkbox {
  642. width: 32rpx;
  643. height: 32rpx;
  644. display: flex;
  645. align-items: center;
  646. margin-right: 8rpx;
  647. }
  648. .address {
  649. width: 654rpx;
  650. height: 80rpx;
  651. line-height: 80rpx;
  652. background: #f5f5f5;
  653. border-radius: 16rpx;
  654. font-size: 30rpx;
  655. font-family: PingFang SC;
  656. font-weight: bold;
  657. color: #333333;
  658. padding: 0 24rpx;
  659. &.active {
  660. background: #ebf5ff;
  661. border: 2rpx solid #007aff;
  662. }
  663. }
  664. }
  665. }
  666. .btn {
  667. width: 200rpx;
  668. height: 64rpx;
  669. line-height: 64rpx;
  670. background: linear-gradient(0deg, #015eea, #00c0fa);
  671. border-radius: 32rpx;
  672. margin: 17rpx auto;
  673. font-size: 30rpx;
  674. font-family: PingFang SC;
  675. font-weight: 500;
  676. text-align: center;
  677. color: #ffffff;
  678. }
  679. }
  680. </style>