order.vue 10 KB

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