confirmOrder.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  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">
  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.phone}}</text>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <!-- 价格明细 -->
  53. <view class="amount" style="margin-top: 12px;">
  54. <view class="headline">
  55. 价格明细
  56. </view>
  57. <view class="amount-payable">
  58. <view class="title">
  59. 课程总价
  60. </view>
  61. <view class="value">
  62. <view class="price">
  63. {{payTotalMoney}}元
  64. </view>
  65. <!-- <view class="price-info">
  66. 报名费{{entryFee.toFixed(2)}} 水电费{{weFee.toFixed(2)}}
  67. </view> -->
  68. </view>
  69. </view>
  70. <!-- <view class="discount-amount">
  71. <view class="title">
  72. 优惠金额
  73. </view>
  74. <view class="value">
  75. 0.00元
  76. </view>
  77. </view> -->
  78. <view class="amount-paid">
  79. <view class="title">
  80. 合计
  81. </view>
  82. <view class="value">
  83. {{payTotalMoney}}元
  84. </view>
  85. </view>
  86. </view>
  87. <!-- 支付方式 -->
  88. <view class="payment">
  89. <view class="headline">
  90. 支付方式
  91. </view>
  92. <view class="pay-radio">
  93. <view class="icon">
  94. <img src="../../../assets/img/riFill-wechat-pay-fill@1x.png" alt="">
  95. </view>
  96. <view class="text">
  97. 微信支付
  98. </view>
  99. <view class="radio-box">
  100. <label class="radio" @click="radioClick('weixin')">
  101. <radio value="" :checked="payName == 'weixin'" /><text></text>
  102. </label>
  103. </view>
  104. </view>
  105. <!-- <view class="pay-radio">
  106. <view class="icon">
  107. <img src="../../../assets/img/yunPay.png" alt="">
  108. </view>
  109. <view class="text">
  110. 云闪付
  111. </view>
  112. <view class="radio-box">
  113. <label class="radio" @click="radioClick('yushanfu')">
  114. <radio value="" :checked="payName == 'yushanfu'" /><text></text>
  115. </label>
  116. </view>
  117. </view> -->
  118. </view>
  119. <!-- 确认订单 -->
  120. <view class="confirm">
  121. <view class="money">
  122. <view class="title">合计: </view>
  123. <view class="value">
  124. {{payTotalMoney}}元
  125. </view>
  126. </view>
  127. <view class="pay">
  128. <button @click="topayResult">去支付</button>
  129. </view>
  130. </view>
  131. </view>
  132. </template>
  133. <script>
  134. import * as mineApi from '@/apis/youth/mine.js'
  135. import * as homePageApi from '@/apis/youth/homePage.js'
  136. import * as courseApi from '@/apis/youth/course.js'
  137. import * as weixinApi from '@/apis/weixin.js'
  138. import {
  139. wxPayJs
  140. } from '@/apis/utils/wxpay'
  141. export default {
  142. data() {
  143. return {
  144. shoppingCartList: [],
  145. coursesPayList: [],
  146. payTotalMoney: 0,
  147. selectIndex: 0,
  148. entryFee: 0,
  149. weFee: 0,
  150. submitForm: {},
  151. id: '',
  152. payName: 'weixin'
  153. }
  154. },
  155. onLoad(op) {
  156. if (op.id) {
  157. this.id = op.id;
  158. }
  159. },
  160. onReady() {
  161. if (this.carhelp.getShoppingCartList()) {
  162. this.shoppingCartList = this.carhelp.getShoppingCartList();
  163. this.getCoursesPayList();
  164. }
  165. },
  166. methods: {
  167. radioClick(value) {
  168. this.payName = value;
  169. },
  170. topayResult() {
  171. this.submitForm.amount = 0.01;
  172. if(this.payName == 'weixin') {
  173. // this.wxpy();
  174. this.getMobilePay();
  175. } else if (this.payName == 'yushanfu') {
  176. } else {
  177. uni.showToast({
  178. title: '请选择支付方式',
  179. icon: "none"
  180. })
  181. }
  182. },
  183. getMobilePay() {
  184. uni.showLoading({
  185. title: "加载中",
  186. mask: true,
  187. })
  188. courseApi.mobilePay({
  189. id: this.id
  190. }).then((response) => {
  191. if (response.result) {
  192. window.location.href = response.data;
  193. }
  194. uni.hideLoading()
  195. }).catch(error => {
  196. uni.showToast({
  197. title: error
  198. })
  199. })
  200. },
  201. wxpy() {
  202. uni.showLoading({
  203. title: "加载中",
  204. mask: true,
  205. })
  206. weixinApi.pay({
  207. id: this.id,
  208. openId: this.carhelp.getOpenId()
  209. }).then((response) => {
  210. if (!response.result) {
  211. uni.showToast({
  212. title: response.message
  213. })
  214. return
  215. }
  216. var data = response.data
  217. uni.hideLoading()
  218. //("Pay+"+new Date().getTime())
  219. wxPayJs(data);
  220. }).catch(error => {
  221. uni.showToast({
  222. title: error
  223. })
  224. })
  225. },
  226. getCoursesPayList() {
  227. var list = this.shoppingCartList;
  228. this.coursesPayList = list;
  229. var money = 0;
  230. var money2 = 0;
  231. var money3 = 0;
  232. for (var j = 0; j < this.coursesPayList.length; j++) {
  233. money += Math.round(this.coursesPayList[j].courseAmount * this.coursesPayList[j].unitPrice + this.coursesPayList[
  234. j].waterElectricityAmount);
  235. money2 += this.coursesPayList[j].courseAmount * this.coursesPayList[j].unitPrice;
  236. money3 += this.coursesPayList[j].waterElectricityAmount;
  237. }
  238. this.payTotalMoney = money;
  239. this.entryFee = money2;
  240. this.weFee = money3;
  241. },
  242. }
  243. }
  244. </script>
  245. <style lang="scss" scoped>
  246. // 课程信息
  247. .class-infos {
  248. padding: 24rpx 32rpx;
  249. background-color: #fff;
  250. display: flex;
  251. border-radius: 8px 8px 0 0;
  252. margin: 24rpx 24rpx 0;
  253. .picture {
  254. width: 160rpx;
  255. height: 160rpx;
  256. border-radius: 8rpx;
  257. overflow: hidden;
  258. img {
  259. width: 100%;
  260. height: 100%;
  261. }
  262. }
  263. .infos {
  264. margin-left: 16rpx;
  265. flex: 1;
  266. .title {
  267. color: rgba(51, 51, 51, 1);
  268. font-size: 36rpx;
  269. font-weight: bold;
  270. }
  271. .else {
  272. margin-top: 8rpx;
  273. text {
  274. margin-right: 8rpx;
  275. color: #8c8c8c;
  276. font-size: 12px;
  277. }
  278. }
  279. .price {
  280. display: flex;
  281. justify-content: space-between;
  282. align-items: center;
  283. margin-top: 24rpx;
  284. .price-left {
  285. color: rgba(255, 61, 0, 1);
  286. font-size: 36rpx;
  287. }
  288. .order-amount {
  289. color: rgba(51, 51, 51, 1);
  290. font-size: 32rpx;
  291. }
  292. }
  293. }
  294. }
  295. // 金额
  296. .amount {
  297. background-color: #fff;
  298. padding: 20rpx 32rpx;
  299. border-top: 1px solid rgba(244, 244, 244, 1);
  300. border-radius: 8px;
  301. margin: 24rpx;
  302. .headline {
  303. color: rgba(51, 51, 51, 1);
  304. font-size: 32rpx;
  305. margin-bottom: 32rpx;
  306. font-weight: bold;
  307. }
  308. .title {
  309. color: #333333;
  310. font-weight: bold;
  311. }
  312. .amount-payable,
  313. .discount-amount,
  314. .amount-paid {
  315. display: flex;
  316. justify-content: space-between;
  317. margin-bottom: 32rpx;
  318. .value {
  319. color: #333333;
  320. font-size: 32rpx;
  321. font-weight: bold;
  322. text-align: right;
  323. .price-info {
  324. color: rgba(119, 119, 119, 1);
  325. font-size: 24rpx;
  326. margin-top: 8rpx;
  327. font-weight: normal;
  328. }
  329. }
  330. }
  331. .amount-paid {
  332. margin-bottom: 0;
  333. .value {
  334. color: #101010
  335. }
  336. }
  337. }
  338. .student-infos {
  339. padding: 0px 30rpx;
  340. background-color: #fff;
  341. margin: 0 24rpx;
  342. border-radius: 0 0 8px 8px;
  343. .item {
  344. display: flex;
  345. justify-content: space-between;
  346. border-bottom: 1px solid rgba(244, 244, 244, 1);
  347. padding: 24rpx 0;
  348. .title {
  349. color: #333333;
  350. font-weight: bold;
  351. .asterisk {
  352. color: rgba(244, 68, 68, 1);
  353. }
  354. }
  355. .value {
  356. color: rgba(51, 51, 51, 1);
  357. font-weight: bold;
  358. display: flex;
  359. align-items: center;
  360. .icon {
  361. margin-left: 8rpx;
  362. }
  363. .add {
  364. color: #FF3D00;
  365. }
  366. .placeholder {
  367. color: #CCCCCC;
  368. }
  369. }
  370. }
  371. }
  372. ::v-deepuni-input {
  373. width: 300rpx;
  374. text-align: right !important;
  375. }
  376. ::v-deep.uni-input-placeholder {
  377. color: #cccccc !important;
  378. font-size: 28rpx;
  379. }
  380. // 支付方式
  381. .payment {
  382. background-color: #fff;
  383. padding: 40rpx 32rpx;
  384. border-radius: 8px;
  385. margin: 24rpx;
  386. .headline {
  387. color: rgba(51, 51, 51, 1);
  388. font-size: 32rpx;
  389. margin-bottom: 32rpx;
  390. font-weight: bold;
  391. }
  392. .pay-radio {
  393. display: flex;
  394. align-items: center;
  395. margin-top: 28rpx;
  396. .icon {
  397. img {
  398. width: 48rpx;
  399. height: 48rpx;
  400. vertical-align: middle;
  401. }
  402. }
  403. .text {
  404. margin-left: 8rpx;
  405. }
  406. .radio-box {
  407. margin-left: auto;
  408. }
  409. ::v-deep.uni-radio-input {
  410. width: 40rpx;
  411. height: 40rpx;
  412. }
  413. ::v-deep.uni-radio-input-checked {
  414. background-color: #0DBAC7 !important;
  415. }
  416. }
  417. }
  418. // 确认订单
  419. .confirm {
  420. background-color: #fff;
  421. display: flex;
  422. justify-content: space-between;
  423. position: fixed;
  424. bottom: 0;
  425. left: 0;
  426. right: 0;
  427. padding: 40rpx 32rpx;
  428. .money {
  429. display: flex;
  430. font-size: 18px;
  431. align-items: center;
  432. font-weight: bold;
  433. .title {
  434. color: #101010;
  435. }
  436. .value {
  437. color: #0DBAC7;
  438. margin-left: 8rpx;
  439. }
  440. }
  441. uni-button {
  442. width: 256rpx;
  443. height: 80rpx;
  444. border-radius: 50px;
  445. background-color: rgba(13, 186, 199, 1);
  446. color: rgba(255, 255, 255, 1);
  447. font-size: 16px;
  448. }
  449. }
  450. </style>