kporder.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  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">
  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. }
  208. });
  209. } else {
  210. var data = JSON.parse(JSON.stringify(self.applyDs));
  211. self.$api.addApply(data).then(res => {
  212. if (res.data.code === 200) {
  213. uni.reLaunch({
  214. url: `/pages2/appointment/appointment_success?subscribeId=${res.data.data}`
  215. });
  216. }
  217. });
  218. }
  219. } else {
  220. var data = JSON.parse(JSON.stringify(self.applyDs));
  221. self.$api.addApply(data).then(res => {
  222. if (res.data.code === 200) {
  223. uni.reLaunch({
  224. url: `/pages2/appointment/appointment_success?subscribeId=${res.data.data}`
  225. });
  226. }
  227. });
  228. }
  229. },
  230. backPage() {
  231. uni.navigateBack({
  232. delta: 1
  233. });
  234. }
  235. }
  236. };
  237. </script>
  238. <style>
  239. page {
  240. background-color: #eaeef1;
  241. }
  242. .addModel .u-drawer-bottom {
  243. box-shadow: 0px 0px 16px 4px rgba(145, 156, 178, 0.1);
  244. border-radius: 32rpx 32rpx 0px 0px;
  245. }
  246. </style>
  247. <style scoped lang="scss">
  248. .appointment {
  249. padding: 0 8rpx;
  250. .appointmentItem {
  251. margin: 24rpx 0 40rpx;
  252. .title {
  253. font-size: 30rpx;
  254. font-family: PingFang SC;
  255. font-weight: 500;
  256. color: #333333;
  257. line-height: 1;
  258. margin-bottom: 16rpx;
  259. padding-left: 24rpx;
  260. }
  261. .place {
  262. height: 80rpx;
  263. background: #ffffff;
  264. border-radius: 16rpx;
  265. display: flex;
  266. justify-content: space-between;
  267. align-items: center;
  268. padding: 0 24rpx;
  269. }
  270. }
  271. .main {
  272. background: #ffffff;
  273. border-radius: 16rpx;
  274. padding: 32rpx 16rpx;
  275. .item {
  276. display: flex;
  277. align-items: center;
  278. margin-bottom: 16rpx;
  279. font-size: 28rpx;
  280. font-family: PingFang SC;
  281. font-weight: 500;
  282. color: #333333;
  283. .statusInfo {
  284. font-size: 24rpx;
  285. font-family: PingFang SC;
  286. font-weight: 500;
  287. color: #ff3b30;
  288. padding-left: 24rpx;
  289. }
  290. .checkbox {
  291. width: 32rpx;
  292. height: 32rpx;
  293. display: flex;
  294. align-items: center;
  295. }
  296. .time {
  297. width: 430rpx;
  298. height: 80rpx;
  299. line-height: 80rpx;
  300. background: #f5f5f5;
  301. border: 2rpx solid #f5f5f5;
  302. border-radius: 16rpx;
  303. font-size: 30rpx;
  304. font-family: PingFang SC;
  305. font-weight: bold;
  306. text-align: center;
  307. color: #333333;
  308. margin: 0 18rpx 0 8rpx;
  309. &.active {
  310. background: #ebf5ff;
  311. border: 2rpx solid #007aff;
  312. }
  313. &.no {
  314. background: #ffdddb;
  315. border: 2rpx solid #ffdddb;
  316. }
  317. }
  318. }
  319. }
  320. .btnMain {
  321. display: flex;
  322. justify-content: center;
  323. text-align: center;
  324. .return {
  325. width: 200rpx;
  326. height: 80rpx;
  327. line-height: 80rpx;
  328. background: #f5f5f5;
  329. border-radius: 40rpx;
  330. font-size: 30rpx;
  331. font-family: PingFang SC;
  332. font-weight: bold;
  333. color: #007aff;
  334. }
  335. .sure {
  336. width: 438rpx;
  337. height: 80rpx;
  338. line-height: 80rpx;
  339. background: #007aff;
  340. border-radius: 40rpx;
  341. font-size: 30rpx;
  342. font-family: PingFang SC;
  343. font-weight: bold;
  344. color: #ffffff;
  345. margin-left: 24rpx;
  346. }
  347. }
  348. }
  349. .tipBox {
  350. width: 100%;
  351. font-family: PingFang SC;
  352. .line {
  353. width: 80rpx;
  354. height: 8rpx;
  355. background: #999999;
  356. border-radius: 4rpx;
  357. margin: 8rpx auto;
  358. }
  359. .title {
  360. text-align: center;
  361. font-size: 24rpx;
  362. font-family: PingFang SC;
  363. font-weight: 500;
  364. color: #999999;
  365. margin: 15rpx 0;
  366. }
  367. .main {
  368. font-size: 30rpx;
  369. font-weight: 500;
  370. color: #666666;
  371. line-height: 48rpx;
  372. margin-bottom: 40rpx;
  373. }
  374. .addressList {
  375. height: 500rpx;
  376. padding-top: 24rpx;
  377. .item {
  378. display: flex;
  379. align-items: center;
  380. padding: 0 24rpx;
  381. margin-bottom: 24rpx;
  382. .checkbox {
  383. width: 32rpx;
  384. height: 32rpx;
  385. display: flex;
  386. align-items: center;
  387. margin-right: 8rpx;
  388. }
  389. .address {
  390. width: 654rpx;
  391. height: 80rpx;
  392. line-height: 80rpx;
  393. background: #f5f5f5;
  394. border-radius: 16rpx;
  395. font-size: 30rpx;
  396. font-family: PingFang SC;
  397. font-weight: bold;
  398. color: #333333;
  399. padding: 0 24rpx;
  400. &.active {
  401. background: #ebf5ff;
  402. border: 2rpx solid #007aff;
  403. }
  404. }
  405. }
  406. }
  407. .btn {
  408. width: 200rpx;
  409. height: 64rpx;
  410. line-height: 64rpx;
  411. background: linear-gradient(0deg, #015eea, #00c0fa);
  412. border-radius: 32rpx;
  413. margin: 17rpx auto;
  414. font-size: 30rpx;
  415. font-family: PingFang SC;
  416. font-weight: 500;
  417. text-align: center;
  418. color: #ffffff;
  419. }
  420. }
  421. </style>