confirmOrder.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  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. {{Math.round(item.unitPrice*item.courseAmount+item.waterElectricityAmount)}}元
  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}}元
  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}}元
  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}}元
  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/youth/mine.js'
  158. import * as homePageApi from '@/apis/youth/homePage.js'
  159. import * as courseApi from '@/apis/youth/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: 'weixin'
  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. this.getMobilePay();
  216. } else if (this.payName == 'yushanfu') {
  217. } else {
  218. uni.showToast({
  219. title: '请选择支付方式',
  220. icon: "none"
  221. })
  222. }
  223. },
  224. getMobilePay() {
  225. uni.showLoading({
  226. title: "加载中",
  227. mask: true,
  228. })
  229. courseApi.mobilePay({
  230. id: this.id
  231. }).then((response) => {
  232. if (response.result) {
  233. window.location.href = response.data;
  234. }
  235. uni.hideLoading()
  236. }).catch(error => {
  237. uni.showToast({
  238. title: error
  239. })
  240. })
  241. },
  242. wxpy() {
  243. uni.showLoading({
  244. title: "加载中",
  245. mask: true,
  246. })
  247. weixinApi.pay({
  248. id: this.id,
  249. openId: this.carhelp.getOpenId()
  250. }).then((response) => {
  251. if (!response.result) {
  252. uni.showToast({
  253. title: response.message
  254. })
  255. return
  256. }
  257. var data = response.data
  258. uni.hideLoading()
  259. //("Pay+"+new Date().getTime())
  260. wxPayJs(data);
  261. }).catch(error => {
  262. uni.showToast({
  263. title: error
  264. })
  265. })
  266. },
  267. selectStudent(index) {
  268. this.selectIndex = index;
  269. this.show = true;
  270. },
  271. getCoursesPayList() {
  272. var list = this.shoppingCartList;
  273. this.coursesPayList = list;
  274. var money = 0;
  275. var money2 = 0;
  276. var money3 = 0;
  277. for (var j = 0; j < this.coursesPayList.length; j++) {
  278. money += Math.round(this.coursesPayList[j].courseAmount * this.coursesPayList[j].unitPrice + this.coursesPayList[
  279. j].waterElectricityAmount);
  280. money2 += this.coursesPayList[j].courseAmount * this.coursesPayList[j].unitPrice;
  281. money3 += this.coursesPayList[j].waterElectricityAmount;
  282. }
  283. this.payTotalMoney = money;
  284. this.entryFee = money2;
  285. this.weFee = money3;
  286. },
  287. confirm(e) {
  288. this.studentId = e[0].value;
  289. this.getStudentDetail();
  290. },
  291. getStudentList() {
  292. uni.showLoading({
  293. title: "加载中",
  294. mask: true,
  295. })
  296. mineApi.studentList().then((res) => {
  297. uni.hideLoading();
  298. var list1 = res.data.studentList;
  299. var list2 = [];
  300. for (var i = 0; i < list1.length; i++) {
  301. list2.push({
  302. value: list1[i].studentId,
  303. label: list1[i].studentName
  304. })
  305. }
  306. this.studentList = list2;
  307. }).catch(error => {
  308. uni.showToast({
  309. title: error,
  310. icon: "none"
  311. })
  312. })
  313. },
  314. getStudentDetail() {
  315. uni.showLoading({
  316. title: "加载中",
  317. mask: true,
  318. })
  319. mineApi.getStudentDtl({
  320. studentId: this.studentId
  321. }).then((response) => {
  322. uni.hideLoading();
  323. this.coursesPayList[this.selectIndex].studentId = response.data.studentId;
  324. this.coursesPayList[this.selectIndex].studentName = response.data.studentName;
  325. this.coursesPayList[this.selectIndex].age = response.data.age;
  326. this.coursesPayList[this.selectIndex].firstContactPhone = response.data.firstContactPhone;
  327. this.coursesPayList[this.selectIndex].secondContactPhone = response.data.secondContactPhone;
  328. this.coursesPayList[this.selectIndex].takerName = response.data.takerName;
  329. }).catch(error => {
  330. uni.showToast({
  331. title: error,
  332. icon: "none"
  333. })
  334. })
  335. },
  336. }
  337. }
  338. </script>
  339. <style lang="scss" scoped>
  340. // 课程信息
  341. .class-infos {
  342. padding: 24rpx 32rpx;
  343. background-color: #fff;
  344. display: flex;
  345. border-radius: 8px 8px 0 0;
  346. margin: 24rpx 24rpx 0;
  347. .picture {
  348. width: 160rpx;
  349. height: 160rpx;
  350. border-radius: 8rpx;
  351. overflow: hidden;
  352. img {
  353. width: 100%;
  354. height: 100%;
  355. }
  356. }
  357. .infos {
  358. margin-left: 16rpx;
  359. flex: 1;
  360. .title {
  361. color: rgba(51, 51, 51, 1);
  362. font-size: 36rpx;
  363. font-weight: bold;
  364. }
  365. .else {
  366. margin-top: 8rpx;
  367. text {
  368. margin-right: 8rpx;
  369. color: #8c8c8c;
  370. font-size: 12px;
  371. }
  372. }
  373. .price {
  374. display: flex;
  375. justify-content: space-between;
  376. align-items: center;
  377. margin-top: 24rpx;
  378. .price-left {
  379. color: rgba(255, 61, 0, 1);
  380. font-size: 36rpx;
  381. }
  382. .order-amount {
  383. color: rgba(51, 51, 51, 1);
  384. font-size: 32rpx;
  385. }
  386. }
  387. }
  388. }
  389. // 金额
  390. .amount {
  391. background-color: #fff;
  392. padding: 20rpx 32rpx;
  393. border-top: 1px solid rgba(244, 244, 244, 1);
  394. border-radius: 8px;
  395. margin: 24rpx;
  396. .headline {
  397. color: rgba(51, 51, 51, 1);
  398. font-size: 32rpx;
  399. margin-bottom: 32rpx;
  400. font-weight: bold;
  401. }
  402. .title {
  403. color: #333333;
  404. font-weight: bold;
  405. }
  406. .amount-payable,
  407. .discount-amount,
  408. .amount-paid {
  409. display: flex;
  410. justify-content: space-between;
  411. margin-bottom: 32rpx;
  412. .value {
  413. color: #333333;
  414. font-size: 32rpx;
  415. font-weight: bold;
  416. text-align: right;
  417. .price-info {
  418. color: rgba(119, 119, 119, 1);
  419. font-size: 24rpx;
  420. margin-top: 8rpx;
  421. font-weight: normal;
  422. }
  423. }
  424. }
  425. .amount-paid {
  426. margin-bottom: 0;
  427. .value {
  428. color: #101010
  429. }
  430. }
  431. }
  432. .student-infos {
  433. padding: 0px 30rpx;
  434. background-color: #fff;
  435. margin: 0 24rpx;
  436. border-radius: 0 0 8px 8px;
  437. .item {
  438. display: flex;
  439. justify-content: space-between;
  440. border-bottom: 1px solid rgba(244, 244, 244, 1);
  441. padding: 24rpx 0;
  442. .title {
  443. color: #333333;
  444. font-weight: bold;
  445. .asterisk {
  446. color: rgba(244, 68, 68, 1);
  447. }
  448. }
  449. .value {
  450. color: rgba(51, 51, 51, 1);
  451. font-weight: bold;
  452. display: flex;
  453. align-items: center;
  454. .icon {
  455. margin-left: 8rpx;
  456. }
  457. .add {
  458. color: #FF3D00;
  459. }
  460. .placeholder {
  461. color: #CCCCCC;
  462. }
  463. }
  464. }
  465. }
  466. /deep/uni-input {
  467. width: 300rpx;
  468. text-align: right !important;
  469. }
  470. /deep/.uni-input-placeholder {
  471. color: #cccccc !important;
  472. font-size: 28rpx;
  473. }
  474. // 支付方式
  475. .payment {
  476. background-color: #fff;
  477. padding: 40rpx 32rpx;
  478. border-radius: 8px;
  479. margin: 24rpx;
  480. .headline {
  481. color: rgba(51, 51, 51, 1);
  482. font-size: 32rpx;
  483. margin-bottom: 32rpx;
  484. font-weight: bold;
  485. }
  486. .pay-radio {
  487. display: flex;
  488. align-items: center;
  489. margin-top: 28rpx;
  490. .icon {
  491. img {
  492. width: 48rpx;
  493. height: 48rpx;
  494. vertical-align: middle;
  495. }
  496. }
  497. .text {
  498. margin-left: 8rpx;
  499. }
  500. .radio-box {
  501. margin-left: auto;
  502. }
  503. /deep/.uni-radio-input {
  504. width: 40rpx;
  505. height: 40rpx;
  506. }
  507. /deep/.uni-radio-input-checked {
  508. background-color: #0DBAC7 !important;
  509. }
  510. }
  511. }
  512. // 确认订单
  513. .confirm {
  514. background-color: #fff;
  515. display: flex;
  516. justify-content: space-between;
  517. position: fixed;
  518. bottom: 0;
  519. left: 0;
  520. right: 0;
  521. padding: 40rpx 32rpx;
  522. .money {
  523. display: flex;
  524. font-size: 18px;
  525. align-items: center;
  526. font-weight: bold;
  527. .title {
  528. color: #101010;
  529. }
  530. .value {
  531. color: #0DBAC7;
  532. margin-left: 8rpx;
  533. }
  534. }
  535. uni-button {
  536. width: 256rpx;
  537. height: 80rpx;
  538. border-radius: 50px;
  539. background-color: rgba(13, 186, 199, 1);
  540. color: rgba(255, 255, 255, 1);
  541. font-size: 16px;
  542. }
  543. }
  544. </style>