index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <view class="">
  3. <view class="card">
  4. <view class="classHead">
  5. <view class="classBorder">
  6. </view>
  7. <view class="classTitle">
  8. 套餐详情
  9. </view>
  10. </view>
  11. <view class="body">
  12. <image :src="'https://biaodianfuhao.oss-cn-beijing.aliyuncs.com/'+setMeal.packages.imgUrl" alt="">
  13. <view class="content">
  14. <view class="title">
  15. {{setMeal.packages.name}}
  16. </view>
  17. <view class="explain">
  18. <a href="##">购买的套餐仅限选择的车辆使用</a>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <Card titles="使用车辆" :data="setMeal.userCar"></Card>
  24. <view class="bottomBtn">
  25. <view class="leftView">
  26. <view class="unit">
  27. 需支付:
  28. </view>
  29. <view class="chooseNum">
  30. <view style="font-size: 26rpx;">
  31. </view>
  32. <view style="font-size: 56rpx;">
  33. {{setMeal.price}}
  34. </view>
  35. </view>
  36. </view>
  37. <view class="rightView" @click="createOrder(setMeal.packages.id,setMeal.userCar.id,setMeal.price)">
  38. 确定
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import {
  45. packageBuy
  46. } from "@/api/maintain.js"
  47. import {
  48. buyPackage
  49. } from "@/api/myApi.js"
  50. import Card from '@/components/Card'
  51. export default {
  52. components: {
  53. Card
  54. },
  55. data() {
  56. return {
  57. setMeal: {
  58. packages: {},
  59. userCar: {},
  60. price: null
  61. },
  62. url: "",
  63. name: "",
  64. cardMsg: [],
  65. provider: '',
  66. payType: 1
  67. };
  68. },
  69. onLoad(options) {
  70. this.packageBuys(JSON.parse(options.item).id)
  71. },
  72. methods: {
  73. createOrder(packageId, carId, price) {
  74. let data = {
  75. packageId: packageId,
  76. carId: carId,
  77. payPrice: price,
  78. payType: this.payType
  79. }
  80. console.log(data);
  81. buyPackage(data).then(res => {
  82. console.log(res);
  83. if (this.payType === 1) {
  84. this.provider = 'wxpay'
  85. }
  86. console.log(res.data.wechatOrder);
  87. uni.requestPayment({
  88. provider: this.provider,
  89. orderInfo: res.data.wechatOrder,
  90. success: (res) => {
  91. console.log('下单支付===============>', res);
  92. uni.showToast({
  93. icon: 'none',
  94. title: '下单成功'
  95. })
  96. uni.redirectTo({
  97. url: '/pages/preCarWash/washOrder/index'
  98. })
  99. },
  100. fail: (res) => {
  101. console.log(res, '支付失败fail');
  102. uni.showToast({
  103. icon: 'none',
  104. title: '支付失败:' + res.errMsg + ',code:' + res.code +
  105. ',errCode:' + res.errCode
  106. })
  107. }
  108. })
  109. })
  110. },
  111. packageBuys(id) {
  112. packageBuy({
  113. packageId: id
  114. }).then(res => {
  115. console.log('获取参数=================>', res);
  116. this.setMeal = res.data;
  117. })
  118. },
  119. }
  120. }
  121. </script>
  122. <style lang="less">
  123. page {
  124. background: #EDEDED;
  125. }
  126. .bottomBtn {
  127. width: 690rpx;
  128. height: 110rpx;
  129. background: #FFFFFF;
  130. border: 1px solid #EEEEEE;
  131. box-shadow: 0px 8rpx 17rpx 0px rgba(168, 165, 165, 0.26);
  132. border-radius: 55rpx;
  133. margin-left: 30rpx;
  134. position: absolute;
  135. bottom: 67rpx;
  136. z-index: 9998;
  137. .leftView {
  138. float: left;
  139. height: 100%;
  140. display: flex;
  141. align-items: center;
  142. .unit {
  143. font-size: 26rpx;
  144. font-family: PingFang SC;
  145. font-weight: 500;
  146. color: #666666;
  147. line-height: 31rpx;
  148. padding-left: 52rpx;
  149. }
  150. .chooseNum {
  151. font-size: 30rpx;
  152. font-family: PingFang SC;
  153. font-weight: 500;
  154. color: #FF3C00;
  155. line-height: 31rpx;
  156. display: flex;
  157. align-items: baseline;
  158. }
  159. }
  160. .rightView {
  161. float: right;
  162. width: 210rpx;
  163. height: 108rpx;
  164. background: linear-gradient(0deg, #005AFF 0%, #0078FF 100%);
  165. border-radius: 0 55rpx 55rpx 0;
  166. font-size: 34rpx;
  167. font-family: PingFang SC;
  168. font-weight: 500;
  169. color: #FEFEFE;
  170. line-height: 108rpx;
  171. text-align: center;
  172. }
  173. }
  174. .card {
  175. width: 94%;
  176. height: 239rpx;
  177. margin-left: 3%;
  178. background: #FFFFFF;
  179. border-radius: 10rpx;
  180. margin-top: 28rpx;
  181. .classHead {
  182. display: flex;
  183. padding-top: 28rpx;
  184. width: 100%;
  185. height: 28rpx;
  186. .classBorder {
  187. width: 5rpx;
  188. height: 28rpx;
  189. background: linear-gradient(0deg, #005AFF 0%, #0078FF 100%);
  190. border-radius: 3rpx;
  191. }
  192. .classTitle {
  193. height: 25rpx;
  194. font-size: 26rpx;
  195. font-family: PingFang SC;
  196. font-weight: 500;
  197. color: #666666;
  198. padding-left: 28rpx;
  199. line-height: 28rpx;
  200. }
  201. }
  202. .body {
  203. display: flex;
  204. align-items: center;
  205. padding: 36rpx 0 0 26rpx;
  206. image {
  207. width: 120rpx;
  208. height: 120rpx;
  209. }
  210. .content {
  211. padding-left: 30rpx;
  212. .title {
  213. font-size: 32rpx;
  214. font-family: PingFang SC;
  215. font-weight: bold;
  216. color: #333333;
  217. line-height: 31rpx;
  218. }
  219. .explain {
  220. margin-top: 23rpx;
  221. a {
  222. font-size: 24rpx;
  223. font-family: PingFang SC;
  224. font-weight: 500;
  225. color: #005BFF;
  226. line-height: 31rpx;
  227. text-decoration: none;
  228. }
  229. }
  230. }
  231. }
  232. }
  233. </style>