kporder.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  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;
  154. this.address_show = false;
  155. },
  156. choItem(index,time) {
  157. if(time >= this.applyDs.applySiteExamTime){
  158. return
  159. }
  160. const item = this.activeList[index];
  161. if (item.status !== 0) {
  162. return;
  163. }
  164. this.activeList.forEach((item, idx) => {
  165. item.checked = false;
  166. if (idx === index) {
  167. item.checked = true;
  168. }
  169. });
  170. },
  171. sureOppoint() {
  172. var self = this;
  173. if (self.addressId) {
  174. var ast = self.activeList.some(item => {
  175. return item.checked === true;
  176. });
  177. if (ast) {
  178. var copyData = JSON.parse(JSON.stringify(self.activeList));
  179. const index = copyData.findIndex(item => item.checked);
  180. var data = {
  181. applySiteAddressTrain: self.addressName,
  182. applySiteExamTrainTime: copyData[index].examTime,
  183. applySiteStartTrainTime: copyData[index].startTimeC,
  184. applySiteEndTrainTime: copyData[index].endTimeC
  185. };
  186. let newObj = {};
  187. Object.assign(newObj, data, self.applyDs);
  188. self.$api.addApply(newObj).then(res => {
  189. if (res.data.code === 200) {
  190. uni.reLaunch({
  191. url: `/pages2/appointment/appointment_success?subscribeId=${res.data.data}`
  192. });
  193. }
  194. });
  195. } else {
  196. uni.showToast({
  197. title: '请选择考试时间',
  198. icon: 'none'
  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. },
  212. backPage() {
  213. uni.navigateBack({
  214. delta: 1
  215. });
  216. }
  217. }
  218. };
  219. </script>
  220. <style>
  221. page {
  222. background-color: #eaeef1;
  223. }
  224. .addModel .u-drawer-bottom {
  225. box-shadow: 0px 0px 16px 4px rgba(145, 156, 178, 0.1);
  226. border-radius: 32rpx 32rpx 0px 0px;
  227. }
  228. </style>
  229. <style scoped lang="scss">
  230. .appointment {
  231. padding: 0 8rpx;
  232. .appointmentItem {
  233. margin: 24rpx 0 40rpx;
  234. .title {
  235. font-size: 30rpx;
  236. font-family: PingFang SC;
  237. font-weight: 500;
  238. color: #333333;
  239. line-height: 1;
  240. margin-bottom: 16rpx;
  241. padding-left: 24rpx;
  242. }
  243. .place {
  244. height: 80rpx;
  245. background: #ffffff;
  246. border-radius: 16rpx;
  247. display: flex;
  248. justify-content: space-between;
  249. align-items: center;
  250. padding: 0 24rpx;
  251. }
  252. }
  253. .main {
  254. background: #ffffff;
  255. border-radius: 16rpx;
  256. padding: 32rpx 16rpx;
  257. .item {
  258. display: flex;
  259. align-items: center;
  260. margin-bottom: 16rpx;
  261. font-size: 28rpx;
  262. font-family: PingFang SC;
  263. font-weight: 500;
  264. color: #333333;
  265. .statusInfo {
  266. font-size: 24rpx;
  267. font-family: PingFang SC;
  268. font-weight: 500;
  269. color: #ff3b30;
  270. padding-left: 24rpx;
  271. }
  272. .checkbox {
  273. width: 32rpx;
  274. height: 32rpx;
  275. display: flex;
  276. align-items: center;
  277. }
  278. .time {
  279. width: 430rpx;
  280. height: 80rpx;
  281. line-height: 80rpx;
  282. background: #f5f5f5;
  283. border: 2rpx solid #f5f5f5;
  284. border-radius: 16rpx;
  285. font-size: 30rpx;
  286. font-family: PingFang SC;
  287. font-weight: bold;
  288. text-align: center;
  289. color: #333333;
  290. margin: 0 18rpx 0 8rpx;
  291. &.active {
  292. background: #ebf5ff;
  293. border: 2rpx solid #007aff;
  294. }
  295. &.no {
  296. background: #ffdddb;
  297. border: 2rpx solid #ffdddb;
  298. }
  299. }
  300. }
  301. }
  302. .btnMain {
  303. display: flex;
  304. justify-content: center;
  305. text-align: center;
  306. .return {
  307. width: 200rpx;
  308. height: 80rpx;
  309. line-height: 80rpx;
  310. background: #f5f5f5;
  311. border-radius: 40rpx;
  312. font-size: 30rpx;
  313. font-family: PingFang SC;
  314. font-weight: bold;
  315. color: #007aff;
  316. }
  317. .sure {
  318. width: 438rpx;
  319. height: 80rpx;
  320. line-height: 80rpx;
  321. background: #007aff;
  322. border-radius: 40rpx;
  323. font-size: 30rpx;
  324. font-family: PingFang SC;
  325. font-weight: bold;
  326. color: #ffffff;
  327. margin-left: 24rpx;
  328. }
  329. }
  330. }
  331. .tipBox {
  332. width: 100%;
  333. font-family: PingFang SC;
  334. .line {
  335. width: 80rpx;
  336. height: 8rpx;
  337. background: #999999;
  338. border-radius: 4rpx;
  339. margin: 8rpx auto;
  340. }
  341. .title {
  342. text-align: center;
  343. font-size: 24rpx;
  344. font-family: PingFang SC;
  345. font-weight: 500;
  346. color: #999999;
  347. margin: 15rpx 0;
  348. }
  349. .main {
  350. font-size: 30rpx;
  351. font-weight: 500;
  352. color: #666666;
  353. line-height: 48rpx;
  354. margin-bottom: 40rpx;
  355. }
  356. .addressList {
  357. height: 500rpx;
  358. padding-top: 24rpx;
  359. .item {
  360. display: flex;
  361. align-items: center;
  362. padding: 0 24rpx;
  363. margin-bottom: 24rpx;
  364. .checkbox {
  365. width: 32rpx;
  366. height: 32rpx;
  367. display: flex;
  368. align-items: center;
  369. margin-right: 8rpx;
  370. }
  371. .address {
  372. width: 654rpx;
  373. height: 80rpx;
  374. line-height: 80rpx;
  375. background: #f5f5f5;
  376. border-radius: 16rpx;
  377. font-size: 30rpx;
  378. font-family: PingFang SC;
  379. font-weight: bold;
  380. color: #333333;
  381. padding: 0 24rpx;
  382. &.active {
  383. background: #ebf5ff;
  384. border: 2rpx solid #007aff;
  385. }
  386. }
  387. }
  388. }
  389. .btn {
  390. width: 200rpx;
  391. height: 64rpx;
  392. line-height: 64rpx;
  393. background: linear-gradient(0deg, #015eea, #00c0fa);
  394. border-radius: 32rpx;
  395. margin: 17rpx auto;
  396. font-size: 30rpx;
  397. font-family: PingFang SC;
  398. font-weight: 500;
  399. text-align: center;
  400. color: #ffffff;
  401. }
  402. }
  403. </style>