order.vue 9.7 KB

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