kporder.vue 10 KB

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