order.vue 10 KB

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