order.vue 9.7 KB

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