kporder.vue 11 KB

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