order.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. <template>
  2. <view class="safeArea">
  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. <view class="btnMain">
  65. <view class="return" @click="backPage">上一步</view>
  66. <view class="sure" @click="sureOppoint">{{
  67. dataId === 1 ? "下一步" : dataId === 2 ? "确定预约" : "异常"
  68. }}</view>
  69. </view>
  70. </view>
  71. <!-- 弹框-->
  72. <u-popup v-model="address_show" mode="bottom" class="addModel">
  73. <view class="tipBox safeArea">
  74. <view class="line"></view>
  75. <view class="title">温馨提示</view>
  76. <u-line color="#EEEEEE" />
  77. <scroll-view class="addressList" :scroll-y="true">
  78. <view
  79. class="item"
  80. v-for="(item, index) in listData"
  81. :key="index"
  82. @click="choAddress(index)"
  83. >
  84. <u-checkbox
  85. class="checkbox"
  86. v-model="item.checked"
  87. shape="circle"
  88. ></u-checkbox>
  89. <view :class="['address', { active: item.checked }]">{{
  90. item.siteAddress
  91. }}</view>
  92. </view>
  93. </scroll-view>
  94. <u-line color="#EEEEEE" />
  95. <view class="btn" @click="sureAddress">确认</view>
  96. </view>
  97. </u-popup>
  98. </view>
  99. </template>
  100. <script>
  101. import { mapGetters } from "vuex";
  102. export default {
  103. data() {
  104. return {
  105. orderGoodsId: 0,
  106. address_show: false,
  107. addressName: "请选择",
  108. addressId: null, //当前选中考试点ID
  109. listData: [], //考试地点数据
  110. activeList: [], //选中考试地点列表
  111. applyId: null, //考试计划ID
  112. goodsId: null, //商品ID
  113. applyStatus: null, //学员状态ID
  114. sysTime: 0,
  115. dataId: null, //跳转拷贝
  116. };
  117. },
  118. async onLoad(option) {
  119. this.applyId = Number(option.applyId);
  120. this.goodsId = Number(option.goodsId);
  121. this.applyStatus = Number(option.applyStatus);
  122. this.dataId = Number(option.dataId);
  123. this.orderGoodsId = Number(option.orderGoodsId);
  124. await this.commonSystemTime();
  125. this.getInfo();
  126. },
  127. methods: {
  128. commonSystemTime() {
  129. return new Promise((resolve) => {
  130. this.$api.commonSystemTime().then((res) => {
  131. this.sysTime = res.data.data;
  132. resolve();
  133. });
  134. });
  135. },
  136. //获取考试地点
  137. getInfo() {
  138. this.$api
  139. .getApplysubscribeApplySite({ applyId: this.applyId })
  140. .then((res) => {
  141. if (res.data.code === 200) {
  142. res.data.data.forEach((item, index) => {
  143. item.checked = false;
  144. });
  145. this.listData = res.data.data;
  146. }
  147. });
  148. },
  149. showAddress() {
  150. this.address_show = true;
  151. },
  152. choAddress(index) {
  153. this.listData.forEach((item, idx) => {
  154. this.$set(item, "checked", false);
  155. if (idx === index) {
  156. this.$set(item, "checked", true);
  157. }
  158. });
  159. },
  160. sureAddress() {
  161. var self = this;
  162. const index = this.listData.findIndex((item) => item.checked);
  163. if (index === -1) {
  164. uni.showToast({
  165. title: "请选择考试地点",
  166. icon: "none",
  167. });
  168. return;
  169. }
  170. if (this.addressId === this.listData[index].id) {
  171. this.address_show = false;
  172. return;
  173. }
  174. this.addressName = this.listData[index].siteAddress;
  175. this.addressId = this.listData[index].id;
  176. var arrays = [];
  177. this.listData[index].examUserApplySiteTime.forEach((item) => {
  178. item.examApplySiteTimeTwoVo.forEach((items) => {
  179. arrays.push({
  180. examTime: item.examTime,
  181. startTimeC: items.startTime,
  182. endTimeC: items.endTime,
  183. dataTime: self.$method
  184. .timestampToTime(item.examTime)
  185. .replace(/-/g, "/"),
  186. startTime: items.startTime,
  187. endTime: items.endTime,
  188. num: items.num,
  189. registration: items.registration,
  190. checked: false,
  191. status:
  192. items.status === 1
  193. ? items.status
  194. : items.registration >= items.num
  195. ? 2
  196. : items.status,
  197. });
  198. });
  199. });
  200. this.activeList = arrays.filter((item, index) => {
  201. console.log(item);
  202. // const newTime = parseInt(new Date().getTime() / 1000)
  203. console.log(
  204. item.dataTime.replace(/-/g, "/") + "" + item.startTime + ":00"
  205. );
  206. const liTime = parseInt(
  207. new Date(
  208. item.dataTime.replace(/-/g, "/") + "" + item.startTime + ":00"
  209. ).getTime() / 1000
  210. );
  211. console.log(liTime, "liTime");
  212. console.log(this.sysTime, "newTime");
  213. if (liTime > this.sysTime) {
  214. return item;
  215. }
  216. });
  217. console.log(this.activeList);
  218. this.address_show = false;
  219. },
  220. choItem(index) {
  221. const item = this.activeList[index];
  222. if (item.status !== 0) {
  223. return;
  224. }
  225. this.activeList.forEach((item, idx) => {
  226. item.checked = false;
  227. if (idx === index) {
  228. item.checked = true;
  229. }
  230. });
  231. },
  232. sureOppoint() {
  233. var self = this;
  234. if (self.addressId) {
  235. var ast = self.activeList.some((item) => {
  236. return item.checked === true;
  237. });
  238. if (ast) {
  239. var copyData = JSON.parse(JSON.stringify(self.activeList));
  240. const index = copyData.findIndex((item) => item.checked);
  241. var data = {
  242. applyId: self.applyId,
  243. goodsId: self.goodsId,
  244. studentType: self.applyStatus,
  245. applySiteAddress: self.addressName,
  246. applySiteExamTime: copyData[index].examTime,
  247. applySiteStartTime: copyData[index].startTimeC,
  248. applySiteEndTime: copyData[index].endTimeC,
  249. orderGoodsId: self.orderGoodsId,
  250. };
  251. if (self.dataId === 1) {
  252. self.$store.commit("updateApplyData", data);
  253. self.$navTo.togo("/pages2/appointment/kporder", {
  254. applyId: self.applyId,
  255. applyStatus: self.applyStatus,
  256. goodsId: self.goodsId,
  257. orderGoodsId: self.orderGoodsId,
  258. });
  259. }
  260. if (self.dataId === 2) {
  261. self.$api.addApply(data).then((res) => {
  262. if (res.data.code === 200) {
  263. uni.reLaunch({
  264. url: `/pages2/appointment/appointment_success?subscribeId=${res.data.data}`,
  265. });
  266. } else {
  267. uni.showToast({
  268. icon: "none",
  269. title: res.data.msg,
  270. });
  271. }
  272. });
  273. }
  274. } else {
  275. uni.showToast({
  276. title: "请选择考试时间",
  277. icon: "none",
  278. });
  279. }
  280. } else {
  281. uni.showToast({
  282. title: "请选择考试地点",
  283. icon: "none",
  284. });
  285. }
  286. },
  287. backPage() {
  288. uni.navigateBack({
  289. delta: 1,
  290. });
  291. },
  292. },
  293. };
  294. </script>
  295. <style>
  296. page {
  297. background-color: #eaeef1;
  298. }
  299. .addModel .u-drawer-bottom {
  300. box-shadow: 0px 0px 16px 4px rgba(145, 156, 178, 0.1);
  301. border-radius: 32rpx 32rpx 0px 0px;
  302. }
  303. </style>
  304. <style scoped lang="scss">
  305. .appointment {
  306. padding: 0 8rpx;
  307. .appointmentItem {
  308. margin: 24rpx 0 40rpx;
  309. .title {
  310. font-size: 30rpx;
  311. font-family: PingFang SC;
  312. font-weight: 500;
  313. color: #333333;
  314. line-height: 1;
  315. margin-bottom: 16rpx;
  316. padding-left: 24rpx;
  317. }
  318. .place {
  319. height: 80rpx;
  320. background: #ffffff;
  321. border-radius: 16rpx;
  322. display: flex;
  323. justify-content: space-between;
  324. align-items: center;
  325. padding: 0 24rpx;
  326. }
  327. }
  328. .main {
  329. background: #ffffff;
  330. border-radius: 16rpx;
  331. padding: 32rpx 16rpx;
  332. .item {
  333. display: flex;
  334. align-items: center;
  335. margin-bottom: 16rpx;
  336. font-size: 28rpx;
  337. font-family: PingFang SC;
  338. font-weight: 500;
  339. color: #333333;
  340. .statusInfo {
  341. font-size: 24rpx;
  342. font-family: PingFang SC;
  343. font-weight: 500;
  344. color: #ff3b30;
  345. padding-left: 24rpx;
  346. }
  347. .checkbox {
  348. width: 32rpx;
  349. height: 32rpx;
  350. display: flex;
  351. align-items: center;
  352. }
  353. .time {
  354. width: 430rpx;
  355. height: 80rpx;
  356. line-height: 80rpx;
  357. background: #f5f5f5;
  358. border: 2rpx solid #f5f5f5;
  359. border-radius: 16rpx;
  360. font-size: 30rpx;
  361. font-family: PingFang SC;
  362. font-weight: bold;
  363. text-align: center;
  364. color: #333333;
  365. margin: 0 18rpx 0 8rpx;
  366. &.active {
  367. background: #ebf5ff;
  368. border: 2rpx solid #007aff;
  369. }
  370. &.no {
  371. background: #ffdddb;
  372. border: 2rpx solid #ffdddb;
  373. }
  374. }
  375. }
  376. }
  377. .btnMain {
  378. display: flex;
  379. justify-content: center;
  380. text-align: center;
  381. .return {
  382. width: 200rpx;
  383. height: 80rpx;
  384. line-height: 80rpx;
  385. background: #f5f5f5;
  386. border-radius: 40rpx;
  387. font-size: 30rpx;
  388. font-family: PingFang SC;
  389. font-weight: bold;
  390. color: #007aff;
  391. }
  392. .sure {
  393. width: 438rpx;
  394. height: 80rpx;
  395. line-height: 80rpx;
  396. background: #007aff;
  397. border-radius: 40rpx;
  398. font-size: 30rpx;
  399. font-family: PingFang SC;
  400. font-weight: bold;
  401. color: #ffffff;
  402. margin-left: 24rpx;
  403. }
  404. }
  405. }
  406. .tipBox {
  407. width: 100%;
  408. font-family: PingFang SC;
  409. .line {
  410. width: 80rpx;
  411. height: 8rpx;
  412. background: #999999;
  413. border-radius: 4rpx;
  414. margin: 8rpx auto;
  415. }
  416. .title {
  417. text-align: center;
  418. font-size: 24rpx;
  419. font-family: PingFang SC;
  420. font-weight: 500;
  421. color: #999999;
  422. margin: 15rpx 0;
  423. }
  424. .main {
  425. font-size: 30rpx;
  426. font-weight: 500;
  427. color: #666666;
  428. line-height: 48rpx;
  429. margin-bottom: 40rpx;
  430. }
  431. .addressList {
  432. height: 500rpx;
  433. padding-top: 24rpx;
  434. .item {
  435. display: flex;
  436. align-items: center;
  437. padding: 0 24rpx;
  438. margin-bottom: 24rpx;
  439. .checkbox {
  440. width: 32rpx;
  441. height: 32rpx;
  442. display: flex;
  443. align-items: center;
  444. margin-right: 8rpx;
  445. }
  446. .address {
  447. width: 654rpx;
  448. height: 80rpx;
  449. line-height: 80rpx;
  450. background: #f5f5f5;
  451. border-radius: 16rpx;
  452. font-size: 30rpx;
  453. font-family: PingFang SC;
  454. font-weight: bold;
  455. color: #333333;
  456. padding: 0 24rpx;
  457. &.active {
  458. background: #ebf5ff;
  459. border: 2rpx solid #007aff;
  460. }
  461. }
  462. }
  463. }
  464. .btn {
  465. width: 200rpx;
  466. height: 64rpx;
  467. line-height: 64rpx;
  468. background: linear-gradient(0deg, #015eea, #00c0fa);
  469. border-radius: 32rpx;
  470. margin: 17rpx auto;
  471. font-size: 30rpx;
  472. font-family: PingFang SC;
  473. font-weight: 500;
  474. text-align: center;
  475. color: #ffffff;
  476. }
  477. }
  478. </style>