order.vue 9.6 KB

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