kporder.vue 11 KB

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