order.vue 11 KB

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