鸿宇研学生前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

314 lines
8.6 KiB

  1. <template>
  2. <view class="page__view">
  3. <navbar leftClick @leftClick="$utils.navigateBack" >
  4. <view class="flex">
  5. <view>待支付</view>
  6. <view>
  7. <view>剩余</view>
  8. <!-- todo -->
  9. <view>10:00</view>
  10. </view>
  11. <view>后关闭</view>
  12. </view>
  13. </navbar>
  14. <view class="main">
  15. <productCard :data="detail"></productCard>
  16. <orderInfoView :data="detail"></orderInfoView>
  17. <view class="notice">
  18. <view class="notice-header">下单须知</view>
  19. <view class="notice-content">
  20. <!-- todo: check key -->
  21. <uv-parse :content="configList['order_instructions']"></uv-parse>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="bottom">
  26. <view class="agreement">
  27. <uv-checkbox-group
  28. v-model="checkboxValue"
  29. shape="circle"
  30. >
  31. <uv-checkbox
  32. size="40rpx"
  33. icon-size="40rpx"
  34. activeColor="#00A9FF"
  35. :name="1"
  36. ></uv-checkbox>
  37. </uv-checkbox-group>
  38. <view class="desc">
  39. 我已阅读并同意
  40. <!-- todo: 替换配置项key -->
  41. <text class="highlight" @click="$refs.modal.open('config_agreement', '退订政策')">退订政策</text>
  42. <!-- todo: 替换配置项key -->
  43. <text class="highlight" @click="$refs.modal.open('config_privacy', '合同范本')">合同范本</text>
  44. <!-- todo: 替换配置项key -->
  45. <text class="highlight" @click="$refs.modal.open('config_privacy', '预订须知')">预订须知</text>
  46. <!-- todo: 替换配置项key -->
  47. <text class="highlight" @click="$refs.modal.open('config_privacy', '安全提示')">安全提示</text>
  48. </view>
  49. </view>
  50. <view class="flex bar">
  51. <button plain class="flex flex-column btn btn-simple" open-type="contact">
  52. <image class="icon" src="@/pages_order/static/product/icon-service.png" mode="widthFix"></image>
  53. <view>联系客服</view>
  54. </button>
  55. <view class="col flex price">
  56. <view class="price-label">
  57. 合计
  58. </view>
  59. <view class="price-unit">¥</view>
  60. <view class="price-value">
  61. {{ totalPrice }}
  62. </view>
  63. </view>
  64. <button class="col btn btn-primary" @click="onPay">立即支付</button>
  65. </view>
  66. </view>
  67. <agreementModal ref="modal" @confirm="onConfirmAgreement"></agreementModal>
  68. </view>
  69. </template>
  70. <script>
  71. import { mapState } from 'vuex'
  72. import productCard from '@/pages_order/order/components/productCard.vue'
  73. import orderInfoView from '@/pages_order/order/components/orderInfoView.vue'
  74. import agreementModal from '@/pages_order/components/agreementModal.vue'
  75. export default {
  76. components: {
  77. productCard,
  78. orderInfoView,
  79. agreementModal,
  80. },
  81. data() {
  82. return {
  83. id: null,
  84. detail: {},
  85. }
  86. },
  87. computed: {
  88. ...mapState(['configList', 'userInfo', 'orderInfo']),
  89. productPackage() {
  90. const { time, product } = this.detail
  91. const { timeOptions } = product || {}
  92. return timeOptions?.find?.(item => item.id === time) || {}
  93. },
  94. totalPrice() {
  95. const { adults, teenager, child, coupon, couponInfo } = this.detail
  96. const { adultsPrice, teenagerPrice, childPrice } = this.productPackage
  97. let total = 0
  98. adults && (total += adults * (adultsPrice || 0))
  99. teenager && (total += teenager * (teenagerPrice || 0))
  100. child && (total += child * (childPrice || 0))
  101. coupon && (total -= (couponInfo?.price || 0))
  102. return total
  103. },
  104. },
  105. onLoad({ id }) {
  106. this.id = id
  107. // console.log('orderInfo', this.orderInfo)
  108. // this.detail = this.orderInfo
  109. // todo: check fetch by id?
  110. this.fetchOrderDetail()
  111. },
  112. onPullDownRefresh() {
  113. this.fetchOrderDetail()
  114. },
  115. methods: {
  116. async fetchOrderDetail() {
  117. try {
  118. this.detail = {
  119. product: {
  120. id: '001',
  121. image: new Array(6).fill('/static/image/temp-20.png').join(','),
  122. name: '新疆天山行7/9日丨醉美伊犁&吐鲁番双套餐',
  123. desc: '每天车程4小时内,含一程高铁丨喀拉峻草原、夏塔古道、昭苏天马、赛里木湖、昭苏油菜花、伊犁薰衣草丨吐鲁番坎儿井&火焰山',
  124. tags: ['坝上草原', '自然探索', '户外探索', '亲子游玩'],
  125. priceDiscount: 688.99,
  126. priceOrigin: 1200,
  127. registered: 4168,
  128. timeOptions: [
  129. {
  130. id: '0011',
  131. startDate: '08/25',
  132. endDate: '09/01',
  133. priceDiscount: 1200.99,
  134. priceOrigin: 2300,
  135. adultsPrice: 2400,
  136. teenagerPrice: 1800,
  137. childPrice: 1200.99,
  138. },
  139. {
  140. id: '0012',
  141. startDate: '09/02',
  142. endDate: '09/11',
  143. priceDiscount: 1200.99,
  144. priceOrigin: 2300,
  145. adultsPrice: 2400,
  146. teenagerPrice: 1800,
  147. childPrice: 1200.99,
  148. },
  149. {
  150. id: '0013',
  151. startDate: '09/12',
  152. endDate: '09/19',
  153. priceDiscount: 1200.99,
  154. priceOrigin: 2300,
  155. adultsPrice: 2400,
  156. teenagerPrice: 1800,
  157. childPrice: 1200.99,
  158. },
  159. ],
  160. },
  161. time: "0012",
  162. adults: 2,
  163. teenager: 1,
  164. child: 1,
  165. members: [
  166. {
  167. id: "001",
  168. cerNo: "430223********9999",
  169. isDefault: false,
  170. isSelected: true,
  171. name: "李梓发",
  172. type: 0,
  173. },
  174. {
  175. id: "002",
  176. cerNo: "430223********9999",
  177. isDefault: false,
  178. isSelected: true,
  179. name: "吴彦谦",
  180. type: 0,
  181. },
  182. {
  183. id: "003",
  184. cerNo: "430223********9999",
  185. isDefault: false,
  186. isSelected: true,
  187. name: "冯云",
  188. type: 1,
  189. },
  190. {
  191. id: "004",
  192. cerNo: "430223********9999",
  193. isDefault: false,
  194. isSelected: true,
  195. name: "冯思钗",
  196. type: 2,
  197. },
  198. ],
  199. coupon: "001",
  200. discount: 88,
  201. invoice: null,
  202. name: "测试",
  203. phone: "13345678910",
  204. orderNo: 'BH872381728321983929',
  205. createTime: '2025-04-28 08:14',
  206. status: 0,
  207. }
  208. console.log('orderInfo', this.detail)
  209. // todo: check fetch by id?
  210. // this.detail = await this.$fetch('queryOrderById', { id: this.id })
  211. } catch (err) {
  212. }
  213. uni.stopPullDownRefresh()
  214. },
  215. async onPay() {
  216. try {
  217. const result = await this.$fetch('payOrder', { orderId: this.id })
  218. await uni.requestPaymentWxPay({ result })
  219. uni.showToast({
  220. title: '支付成功',
  221. icon: 'none'
  222. })
  223. setTimeout(() => {
  224. // todo: check → jump to order list page ?
  225. uni.reLaunch({
  226. url: `/pages_order/order/orderList/index`
  227. });
  228. }, 700)
  229. } catch (err) {
  230. }
  231. },
  232. },
  233. }
  234. </script>
  235. <style scoped lang="scss">
  236. @import '../styles/style.scss';
  237. .bottom {
  238. .bar {
  239. .price {
  240. justify-content: flex-start;
  241. column-gap: 8rpx;
  242. &-label {
  243. font-size: 24rpx;
  244. color: #626262;
  245. }
  246. &-unit,
  247. &-value {
  248. font-weight: 500;
  249. color: #FF4800;
  250. }
  251. &-unit {
  252. font-size: 24rpx;
  253. }
  254. &-value {
  255. font-size: 40rpx;
  256. }
  257. }
  258. .btn-simple {
  259. flex: none;
  260. width: auto;
  261. font-family: PingFang SC;
  262. font-weight: 400;
  263. font-size: 22rpx;
  264. line-height: 1.1;
  265. color: #999999;
  266. border: none;
  267. border-radius: unset;
  268. .icon {
  269. width: 52rpx;
  270. height: auto;
  271. margin-bottom: 4rpx;
  272. }
  273. }
  274. }
  275. }
  276. </style>