kporder.vue 9.5 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">确定预约</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. applyDs: {}
  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.getInfo();
  75. this.getVuexData();
  76. uni.showModal({
  77. content: '线下考前培训,自由填选如您有需要,建议先进行预约具体安排,后续会有相关工作人员与您沟通',
  78. showCancel: false
  79. });
  80. },
  81. methods: {
  82. getVuexData() {
  83. this.applyDs = this.$store.getters.getApplyData;
  84. },
  85. //获取考培地点
  86. getInfo() {
  87. this.$api.getApplysubscribeApplySiteTrain({ applyId: this.applyId }).then(res => {
  88. if (res.data.code === 200) {
  89. res.data.data.forEach((item, index) => {
  90. item.checked = false;
  91. });
  92. this.listData = res.data.data;
  93. }
  94. });
  95. },
  96. showAddress() {
  97. this.address_show = true;
  98. },
  99. choAddress(index) {
  100. this.listData.forEach((item, idx) => {
  101. this.$set(item, 'checked', false);
  102. if (idx === index) {
  103. this.$set(item, 'checked', true);
  104. }
  105. });
  106. },
  107. sureAddress() {
  108. var self = this;
  109. const index = this.listData.findIndex(item => item.checked);
  110. if (index === -1) {
  111. uni.showToast({
  112. title: '请选择考前培训地点',
  113. icon: 'none'
  114. });
  115. return;
  116. }
  117. if (this.addressId === this.listData[index].id) {
  118. this.address_show = false;
  119. return;
  120. }
  121. this.addressName = this.listData[index].siteAddress;
  122. this.addressId = this.listData[index].id;
  123. var arrays = [];
  124. this.listData[index].examUserApplySiteTime.forEach(item => {
  125. item.examApplySiteTimeTwoVo.forEach(items => {
  126. arrays.push({
  127. examTime: item.examTime,
  128. startTimeC: items.startTime,
  129. endTimeC: items.endTime,
  130. dataTime: self.$method.timestampToTime(item.examTime),
  131. startTime: items.startTime.replace('-', ':'),
  132. endTime: items.endTime.replace('-', ':'),
  133. num: items.num,
  134. registration: items.registration,
  135. checked: false,
  136. status: items.status === 1 ? items.status : items.registration >= items.num ? 2 : items.status
  137. });
  138. });
  139. });
  140. this.activeList = arrays;
  141. this.address_show = false;
  142. },
  143. choItem(index) {
  144. const item = this.activeList[index];
  145. if (item.status !== 0) {
  146. return;
  147. }
  148. this.activeList.forEach((item, idx) => {
  149. item.checked = false;
  150. if (idx === index) {
  151. item.checked = true;
  152. }
  153. });
  154. },
  155. sureOppoint() {
  156. var self = this;
  157. if (self.addressId) {
  158. var ast = self.activeList.some(item => {
  159. return item.checked === true;
  160. });
  161. if (ast) {
  162. var copyData = JSON.parse(JSON.stringify(self.activeList));
  163. const index = copyData.findIndex(item => item.checked);
  164. var data = {
  165. applySiteAddressTrain: self.addressName,
  166. applySiteExamTrainTime: copyData[index].examTime,
  167. applySiteStartTrainTime: copyData[index].startTimeC,
  168. applySiteEndTrainTime: copyData[index].endTimeC
  169. };
  170. let newObj = {};
  171. Object.assign(newObj, data, self.applyDs);
  172. self.$api.addApply(newObj).then(res => {
  173. if (res.data.code === 200) {
  174. uni.reLaunch({
  175. url: `/pages2/appointment/appointment_success?subscribeId=${res.data.data}`
  176. });
  177. }
  178. });
  179. } else {
  180. uni.showToast({
  181. title: '请选择考试时间',
  182. icon: 'none'
  183. });
  184. }
  185. } else {
  186. var data = JSON.parse(JSON.stringify(self.applyDs));
  187. self.$api.addApply(data).then(res => {
  188. if (res.data.code === 200) {
  189. uni.reLaunch({
  190. url: `/pages2/appointment/appointment_success?subscribeId=${res.data.data}`
  191. });
  192. }
  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>