order.vue 9.4 KB

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