order.vue 10 KB

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