confirmOrder.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. <template>
  2. <view>
  3. <u-navbar title="确认订单"></u-navbar>
  4. <!-- 课程信息 -->
  5. <view v-for="(item,index) in coursesPayList" :key="index">
  6. <view class="class-infos">
  7. <view class="picture">
  8. <img v-if="item.posterUrl!=null" :src="item.posterUrl" alt="">
  9. <img v-else src="../../../assets/img/picture1.png" alt="">
  10. </view>
  11. <view class="infos">
  12. <view class="title">
  13. {{item.className}}
  14. </view>
  15. <view class="else">
  16. <text>{{item.packageName}}班</text>
  17. <text>{{item.courseAmount}}节课</text>
  18. <!-- <text>x1</text> -->
  19. </view>
  20. <view class="price">
  21. <view class="price-left">
  22. {{(item.unitPrice*item.courseAmount).toFixed(2)}}元
  23. </view>
  24. <view class="order-amount">
  25. <!-- x1 -->
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <!-- 学员信息 -->
  31. <view class="student-infos">
  32. <view class="item">
  33. <view class="title">
  34. <text>学生信息</text>
  35. </view>
  36. <view class="value" @click="selectStudent(index)">
  37. <text>{{item.studentName}}</text>
  38. <text style="color: #999999;margin-left: 8rpx;">{{item.age}}岁</text>
  39. <text class="icon"><u-icon name="arrow-right" color="#c8c8c8"></u-icon></text>
  40. </view>
  41. </view>
  42. <view class="item">
  43. <view class="title">
  44. <text>联系人手机号</text>
  45. </view>
  46. <view class="value">
  47. <text>{{item.firstContactPhone}}</text>
  48. </view>
  49. </view>
  50. <view class="item">
  51. <view class="title">
  52. <text>第二联系人手机号</text>
  53. </view>
  54. <view class="value">
  55. <text>
  56. <input type="text" placeholder="请填写手机号" v-model="item.secondContactPhone">
  57. </text>
  58. <text class="icon"><u-icon name="arrow-right" color="#c8c8c8"></u-icon></text>
  59. </view>
  60. </view>
  61. <view class="item">
  62. <view class="title">
  63. <text>接送家长姓名</text>
  64. </view>
  65. <view class="value">
  66. <text>
  67. <input type="text" placeholder="请填写家长姓名" v-model="item.takerName">
  68. </text>
  69. <text class="icon"><u-icon name="arrow-right" color="#c8c8c8"></u-icon></text>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. <u-select v-model="show" mode="single-column" :list="studentList" @confirm="confirm"></u-select>
  75. <!-- 价格明细 -->
  76. <view class="amount" style="margin-top: 12px;">
  77. <view class="headline">
  78. 价格明细
  79. </view>
  80. <view class="amount-payable">
  81. <view class="title">
  82. 课程总价
  83. </view>
  84. <view class="value">
  85. <view class="price">
  86. {{payTotalMoney.toFixed(2)}}元
  87. </view>
  88. <!-- <view class="price-info">
  89. 报名费{{entryFee.toFixed(2)}} 水电费{{weFee.toFixed(2)}}
  90. </view> -->
  91. </view>
  92. </view>
  93. <view class="discount-amount">
  94. <view class="title">
  95. 优惠金额
  96. </view>
  97. <view class="value">
  98. 0.00元
  99. </view>
  100. </view>
  101. <view class="amount-paid">
  102. <view class="title">
  103. 合计
  104. </view>
  105. <view class="value">
  106. {{payTotalMoney.toFixed(2)}}元
  107. </view>
  108. </view>
  109. </view>
  110. <!-- 支付方式 -->
  111. <view class="payment">
  112. <view class="headline">
  113. 支付方式
  114. </view>
  115. <view class="pay-radio">
  116. <view class="icon">
  117. <img src="../../../assets/img/riFill-wechat-pay-fill@1x.png" alt="">
  118. </view>
  119. <view class="text">
  120. 微信支付
  121. </view>
  122. <view class="radio-box">
  123. <label class="radio" @click="radioClick('weixin')">
  124. <radio value="" :checked="payName == 'weixin'" /><text></text>
  125. </label>
  126. </view>
  127. </view>
  128. <!-- <view class="pay-radio">
  129. <view class="icon">
  130. <img src="../../../assets/img/yunPay.png" alt="">
  131. </view>
  132. <view class="text">
  133. 云闪付
  134. </view>
  135. <view class="radio-box">
  136. <label class="radio" @click="radioClick('yushanfu')">
  137. <radio value="" :checked="payName == 'yushanfu'" /><text></text>
  138. </label>
  139. </view>
  140. </view> -->
  141. </view>
  142. <!-- 确认订单 -->
  143. <view class="confirm">
  144. <view class="money">
  145. <view class="title">合计: </view>
  146. <view class="value">
  147. {{payTotalMoney.toFixed(2)}}元
  148. </view>
  149. </view>
  150. <view class="pay">
  151. <button @click="topayResult">去支付</button>
  152. </view>
  153. </view>
  154. </view>
  155. </template>
  156. <script>
  157. import * as mineApi from '@/apis/parents/mine.js'
  158. import * as homePageApi from '@/apis/parents/homePage.js'
  159. import * as courseApi from '@/apis/parents/course.js'
  160. import * as weixinApi from '@/apis/weixin.js'
  161. import {
  162. wxPayJs
  163. } from '@/apis/utils/wxpay'
  164. export default {
  165. data() {
  166. return {
  167. studentId: '',
  168. stuDetail: {},
  169. show: false,
  170. studentList: [],
  171. classList: [],
  172. packageList: [],
  173. selectNum: '',
  174. packageId: '',
  175. packageName: '',
  176. classId: '',
  177. className: '',
  178. courseId: '',
  179. courseBase: {},
  180. coursePackageList: [],
  181. tclassList: [],
  182. packageDetail: {},
  183. classDetail: {},
  184. shoppingCartList: [],
  185. coursesPayList: [],
  186. payTotalMoney: 0,
  187. selectIndex: 0,
  188. entryFee: 0,
  189. weFee: 0,
  190. submitForm: {},
  191. id: '',
  192. payName: ''
  193. }
  194. },
  195. onLoad(op) {
  196. if (op.id) {
  197. this.id = op.id;
  198. }
  199. },
  200. onReady() {
  201. if (this.carhelp.getShoppingCartList()) {
  202. this.shoppingCartList = this.carhelp.getShoppingCartList();
  203. this.getCoursesPayList();
  204. }
  205. this.getStudentList();
  206. },
  207. methods: {
  208. radioClick(value) {
  209. this.payName = value;
  210. },
  211. topayResult() {
  212. this.submitForm.amount = 0.01;
  213. if(this.payName == 'weixin') {
  214. this.wxpy();
  215. } else if (this.payName == 'yushanfu') {
  216. } else {
  217. uni.showToast({
  218. title: '请选择支付方式',
  219. icon: "none"
  220. })
  221. }
  222. },
  223. wxpy() {
  224. uni.showLoading({
  225. title: "加载中",
  226. mask: true,
  227. })
  228. weixinApi.pay({
  229. id: this.id,
  230. openId: this.carhelp.getOpenId()
  231. }).then((response) => {
  232. if (!response.result) {
  233. uni.showToast({
  234. title: response.message
  235. })
  236. return
  237. }
  238. var data = response.data
  239. uni.hideLoading()
  240. //("Pay+"+new Date().getTime())
  241. wxPayJs(data);
  242. }).catch(error => {
  243. uni.showToast({
  244. title: error
  245. })
  246. })
  247. },
  248. selectStudent(index) {
  249. this.selectIndex = index;
  250. this.show = true;
  251. },
  252. getCoursesPayList() {
  253. var list = this.shoppingCartList;
  254. this.coursesPayList = list;
  255. var money = 0;
  256. var money2 = 0;
  257. var money3 = 0;
  258. for (var j = 0; j < this.coursesPayList.length; j++) {
  259. money += this.coursesPayList[j].courseAmount * this.coursesPayList[j].unitPrice + this.coursesPayList[
  260. j].waterElectricityAmount;
  261. money2 += this.coursesPayList[j].courseAmount * this.coursesPayList[j].unitPrice;
  262. money3 += this.coursesPayList[j].waterElectricityAmount;
  263. }
  264. this.payTotalMoney = money;
  265. this.entryFee = money2;
  266. this.weFee = money3;
  267. },
  268. confirm(e) {
  269. this.studentId = e[0].value;
  270. this.getStudentDetail();
  271. },
  272. getStudentList() {
  273. uni.showLoading({
  274. title: "加载中",
  275. mask: true,
  276. })
  277. mineApi.studentList().then((res) => {
  278. uni.hideLoading();
  279. var list1 = res.data.studentList;
  280. var list2 = [];
  281. for (var i = 0; i < list1.length; i++) {
  282. list2.push({
  283. value: list1[i].studentId,
  284. label: list1[i].studentName
  285. })
  286. }
  287. this.studentList = list2;
  288. }).catch(error => {
  289. uni.showToast({
  290. title: error,
  291. icon: "none"
  292. })
  293. })
  294. },
  295. getStudentDetail() {
  296. uni.showLoading({
  297. title: "加载中",
  298. mask: true,
  299. })
  300. mineApi.getStudentDtl({
  301. studentId: this.studentId
  302. }).then((response) => {
  303. uni.hideLoading();
  304. this.coursesPayList[this.selectIndex].studentId = response.data.studentId;
  305. this.coursesPayList[this.selectIndex].studentName = response.data.studentName;
  306. this.coursesPayList[this.selectIndex].age = response.data.age;
  307. this.coursesPayList[this.selectIndex].firstContactPhone = response.data.firstContactPhone;
  308. this.coursesPayList[this.selectIndex].secondContactPhone = response.data.secondContactPhone;
  309. this.coursesPayList[this.selectIndex].takerName = response.data.takerName;
  310. }).catch(error => {
  311. uni.showToast({
  312. title: error,
  313. icon: "none"
  314. })
  315. })
  316. },
  317. }
  318. }
  319. </script>
  320. <style lang="scss" scoped>
  321. // 课程信息
  322. .class-infos {
  323. padding: 24rpx 32rpx;
  324. background-color: #fff;
  325. display: flex;
  326. border-radius: 8px;
  327. margin: 24rpx;
  328. .picture {
  329. width: 160rpx;
  330. height: 160rpx;
  331. border-radius: 8rpx;
  332. overflow: hidden;
  333. img {
  334. width: 100%;
  335. height: 100%;
  336. }
  337. }
  338. .infos {
  339. margin-left: 16rpx;
  340. flex: 1;
  341. .title {
  342. color: rgba(51, 51, 51, 1);
  343. font-size: 36rpx;
  344. font-weight: bold;
  345. }
  346. .else {
  347. margin-top: 8rpx;
  348. text {
  349. margin-right: 8rpx;
  350. color: #8c8c8c;
  351. font-size: 12px;
  352. }
  353. }
  354. .price {
  355. display: flex;
  356. justify-content: space-between;
  357. align-items: center;
  358. margin-top: 24rpx;
  359. .price-left {
  360. color: rgba(255, 61, 0, 1);
  361. font-size: 36rpx;
  362. }
  363. .order-amount {
  364. color: rgba(51, 51, 51, 1);
  365. font-size: 32rpx;
  366. }
  367. }
  368. }
  369. }
  370. // 金额
  371. .amount {
  372. background-color: #fff;
  373. padding: 20rpx 32rpx;
  374. border-top: 1px solid rgba(244, 244, 244, 1);
  375. border-radius: 8px;
  376. margin: 24rpx;
  377. .headline {
  378. color: rgba(51, 51, 51, 1);
  379. font-size: 32rpx;
  380. margin-bottom: 32rpx;
  381. font-weight: bold;
  382. }
  383. .title {
  384. color: #333333;
  385. font-weight: bold;
  386. }
  387. .amount-payable,
  388. .discount-amount,
  389. .amount-paid {
  390. display: flex;
  391. justify-content: space-between;
  392. margin-bottom: 32rpx;
  393. .value {
  394. color: #333333;
  395. font-size: 32rpx;
  396. font-weight: bold;
  397. text-align: right;
  398. .price-info {
  399. color: rgba(119, 119, 119, 1);
  400. font-size: 24rpx;
  401. margin-top: 8rpx;
  402. font-weight: normal;
  403. }
  404. }
  405. }
  406. .amount-paid {
  407. margin-bottom: 0;
  408. .value {
  409. color: #101010
  410. }
  411. }
  412. }
  413. .student-infos {
  414. padding: 0px 30rpx;
  415. background-color: #fff;
  416. .item {
  417. display: flex;
  418. justify-content: space-between;
  419. border-bottom: 1px solid rgba(244, 244, 244, 1);
  420. padding: 24rpx 0;
  421. .title {
  422. color: #333333;
  423. font-weight: bold;
  424. .asterisk {
  425. color: rgba(244, 68, 68, 1);
  426. }
  427. }
  428. .value {
  429. color: rgba(51, 51, 51, 1);
  430. font-weight: bold;
  431. display: flex;
  432. align-items: center;
  433. .icon {
  434. margin-left: 8rpx;
  435. }
  436. .add {
  437. color: #FF3D00;
  438. }
  439. .placeholder {
  440. color: #CCCCCC;
  441. }
  442. }
  443. }
  444. }
  445. /deep/uni-input {
  446. width: 300rpx;
  447. text-align: right !important;
  448. }
  449. /deep/.uni-input-placeholder {
  450. color: #cccccc !important;
  451. font-size: 28rpx;
  452. }
  453. // 支付方式
  454. .payment {
  455. background-color: #fff;
  456. padding: 40rpx 32rpx;
  457. border-radius: 8px;
  458. margin: 24rpx;
  459. .headline {
  460. color: rgba(51, 51, 51, 1);
  461. font-size: 32rpx;
  462. margin-bottom: 32rpx;
  463. font-weight: bold;
  464. }
  465. .pay-radio {
  466. display: flex;
  467. align-items: center;
  468. margin-top: 28rpx;
  469. .icon {
  470. img {
  471. width: 48rpx;
  472. height: 48rpx;
  473. vertical-align: middle;
  474. }
  475. }
  476. .text {
  477. margin-left: 8rpx;
  478. }
  479. .radio-box {
  480. margin-left: auto;
  481. }
  482. /deep/.uni-radio-input {
  483. width: 40rpx;
  484. height: 40rpx;
  485. }
  486. /deep/.uni-radio-input-checked {
  487. background-color: #0DBAC7 !important;
  488. }
  489. }
  490. }
  491. // 确认订单
  492. .confirm {
  493. background-color: #fff;
  494. display: flex;
  495. justify-content: space-between;
  496. position: fixed;
  497. bottom: 0;
  498. left: 0;
  499. right: 0;
  500. padding: 40rpx 32rpx;
  501. .money {
  502. display: flex;
  503. font-size: 18px;
  504. align-items: center;
  505. font-weight: bold;
  506. .title {
  507. color: #101010;
  508. }
  509. .value {
  510. color: #0DBAC7;
  511. margin-left: 8rpx;
  512. }
  513. }
  514. uni-button {
  515. width: 256rpx;
  516. height: 80rpx;
  517. border-radius: 50px;
  518. background-color: rgba(13, 186, 199, 1);
  519. color: rgba(255, 255, 255, 1);
  520. font-size: 16px;
  521. }
  522. }
  523. </style>