order.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <view class="container">
  3. <view class="header">
  4. <text class="title">确认订单</text>
  5. <text class="subtitle">请确认测评订单信息并完成支付</text>
  6. </view>
  7. <!-- 订单信息 -->
  8. <view class="section">
  9. <view class="section-title">订单详情</view>
  10. <view class="info-row">
  11. <text class="info-label">套餐名称</text>
  12. <text class="info-value">{{ packageName }}</text>
  13. </view>
  14. <view class="info-row">
  15. <text class="info-label">成长规划师</text>
  16. <text class="info-value">{{ guideName }}</text>
  17. </view>
  18. <view class="info-row">
  19. <text class="info-label">预约日期</text>
  20. <text class="info-value">{{ appointmentDate }}</text>
  21. </view>
  22. <view class="info-row">
  23. <text class="info-label">预约时间</text>
  24. <text class="info-value">{{ appointmentTime }}</text>
  25. </view>
  26. </view>
  27. <!-- 费用信息 -->
  28. <view class="section">
  29. <view class="section-title">费用信息</view>
  30. <view class="price-row">
  31. <text class="price-label">测评费用</text>
  32. <text class="price-value">¥{{ totalPrice }}</text>
  33. </view>
  34. <view class="price-row" v-if="discountAmount > 0">
  35. <text class="price-label">优惠金额</text>
  36. <text class="price-value discount">-¥{{ discountAmount }}</text>
  37. </view>
  38. <view class="price-row total">
  39. <text class="price-label">实付金额</text>
  40. <text class="price-value highlight">¥{{ actualPrice }}</text>
  41. </view>
  42. </view>
  43. <!-- 支付方式 -->
  44. <view class="section">
  45. <view class="section-title">支付方式</view>
  46. <view class="pay-methods">
  47. <view class="pay-method-item" :class="{ active: payMethod === 'wechat' }" @click="payMethod = 'wechat'">
  48. <text class="pay-icon">💳</text>
  49. <text class="pay-name">微信支付</text>
  50. <view class="pay-radio" v-if="payMethod === 'wechat'">
  51. <view class="radio-inner" />
  52. </view>
  53. </view>
  54. <view class="pay-method-item" :class="{ active: payMethod === 'alipay' }" @click="payMethod = 'alipay'">
  55. <text class="pay-icon">🔷</text>
  56. <text class="pay-name">支付宝</text>
  57. <view class="pay-radio" v-if="payMethod === 'alipay'">
  58. <view class="radio-inner" />
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <button class="btn-submit" @click="handlePay">确认支付 ¥{{ actualPrice }}</button>
  64. </view>
  65. </template>
  66. <script>
  67. import { createAssessmentAppointment, payAssessmentOrder } from '../../utils/api.js'
  68. export default {
  69. data() {
  70. return {
  71. packageName: '',
  72. guideName: '',
  73. appointmentDate: '',
  74. appointmentTime: '',
  75. totalPrice: '0',
  76. discountAmount: '0',
  77. actualPrice: '0',
  78. payMethod: 'wechat',
  79. childId: null,
  80. guideId: null,
  81. packageId: null
  82. }
  83. },
  84. onLoad(options) {
  85. this.packageName = decodeURIComponent(options.packageName || 'DAN专注力测评')
  86. this.guideName = decodeURIComponent(options.guideName || '')
  87. this.appointmentDate = options.appointmentDate || ''
  88. this.appointmentTime = options.appointmentTime || ''
  89. this.totalPrice = options.totalPrice || '0'
  90. this.discountAmount = options.discountAmount || '0'
  91. this.actualPrice = options.actualPrice || this.totalPrice
  92. this.childId = options.childId || null
  93. this.guideId = options.guideId || null
  94. this.packageId = options.packageId || null
  95. },
  96. methods: {
  97. async handlePay() {
  98. if (!this.guideId) {
  99. uni.showToast({ title: '请选择成长规划师', icon: 'none' })
  100. return
  101. }
  102. try {
  103. uni.showLoading({ title: '创建订单中...' })
  104. const res = await createAssessmentAppointment({
  105. childId: this.childId,
  106. guideId: this.guideId,
  107. packageId: this.packageId,
  108. appointmentDate: this.appointmentDate,
  109. appointmentTime: this.appointmentTime,
  110. notes: '',
  111. totalPrice: this.totalPrice,
  112. guideName: this.guideName,
  113. packageName: this.packageName,
  114. discountAmount: this.discountAmount
  115. })
  116. if (res.code !== 200) {
  117. uni.hideLoading()
  118. return
  119. }
  120. const orderNo = res.data.orderNo
  121. uni.showLoading({ title: '支付中...' })
  122. const payRes = await payAssessmentOrder(orderNo, this.payMethod)
  123. uni.hideLoading()
  124. if (payRes.code === 200) {
  125. uni.removeStorageSync('assessmentFlowData')
  126. uni.removeStorageSync('assessmentChildInfo')
  127. uni.showModal({
  128. title: '支付成功',
  129. content: '您的测评订单已支付,请按时参加测评',
  130. showCancel: false,
  131. success: () => {
  132. uni.redirectTo({ url: '/pages/assessment/results' })
  133. }
  134. })
  135. } else {
  136. uni.showToast({ title: payRes.message || '支付失败', icon: 'none' })
  137. }
  138. } catch (e) {
  139. uni.hideLoading()
  140. uni.showToast({ title: '操作失败,请重试', icon: 'none' })
  141. }
  142. }
  143. }
  144. }
  145. </script>
  146. <style scoped>
  147. .container {
  148. padding: 30rpx;
  149. background: #F8F8F8;
  150. min-height: 100vh;
  151. }
  152. .header {
  153. text-align: center;
  154. padding: 40rpx 0 30rpx;
  155. }
  156. .title {
  157. font-size: 48rpx;
  158. font-weight: bold;
  159. color: #333;
  160. display: block;
  161. margin-bottom: 16rpx;
  162. }
  163. .subtitle {
  164. font-size: 26rpx;
  165. color: #666;
  166. }
  167. .section {
  168. background: #fff;
  169. border-radius: 20rpx;
  170. padding: 30rpx;
  171. margin-bottom: 24rpx;
  172. }
  173. .section-title {
  174. font-size: 32rpx;
  175. font-weight: bold;
  176. color: #333;
  177. margin-bottom: 24rpx;
  178. padding-bottom: 16rpx;
  179. border-bottom: 1rpx solid #eee;
  180. }
  181. .info-row {
  182. display: flex;
  183. justify-content: space-between;
  184. padding: 16rpx 0;
  185. font-size: 28rpx;
  186. }
  187. .info-label { color: #666; }
  188. .info-value { color: #333; font-weight: 500; }
  189. .price-row {
  190. display: flex;
  191. justify-content: space-between;
  192. padding: 16rpx 0;
  193. font-size: 28rpx;
  194. }
  195. .price-label { color: #666; }
  196. .price-value { color: #333; font-weight: bold; }
  197. .price-value.discount { color: #F97316; }
  198. .price-row.total {
  199. margin-top: 16rpx;
  200. padding-top: 24rpx;
  201. border-top: 1rpx dashed #eee;
  202. }
  203. .price-value.highlight {
  204. font-size: 36rpx;
  205. color: #F97316;
  206. }
  207. .pay-methods {
  208. display: flex;
  209. flex-direction: column;
  210. gap: 20rpx;
  211. }
  212. .pay-method-item {
  213. display: flex;
  214. align-items: center;
  215. padding: 24rpx;
  216. background: #F8F8F8;
  217. border-radius: 12rpx;
  218. border: 2rpx solid transparent;
  219. }
  220. .pay-method-item.active {
  221. border-color: #667eea;
  222. background: #F0F4FF;
  223. }
  224. .pay-icon {
  225. font-size: 40rpx;
  226. margin-right: 20rpx;
  227. }
  228. .pay-name {
  229. font-size: 28rpx;
  230. color: #333;
  231. flex: 1;
  232. }
  233. .pay-radio {
  234. width: 40rpx;
  235. height: 40rpx;
  236. border-radius: 50%;
  237. border: 2rpx solid #667eea;
  238. display: flex;
  239. align-items: center;
  240. justify-content: center;
  241. }
  242. .radio-inner {
  243. width: 20rpx;
  244. height: 20rpx;
  245. border-radius: 50%;
  246. background: #667eea;
  247. }
  248. .btn-submit {
  249. width: 100%;
  250. height: 90rpx;
  251. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  252. color: #fff;
  253. border-radius: 45rpx;
  254. font-size: 32rpx;
  255. font-weight: bold;
  256. margin-top: 40rpx;
  257. margin-bottom: 40rpx;
  258. }
  259. </style>