kporder.vue 10 KB

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