鸿宇研学生前端代码
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.

263 lines
6.3 KiB

  1. <template>
  2. <view class="page__view">
  3. <navbar leftClick @leftClick="$utils.navigateBack" >
  4. <view class="flex">
  5. <view>待支付</view>
  6. <template v-if="time">
  7. <uv-count-down
  8. :time="time"
  9. format="mm:ss"
  10. autoStart
  11. millisecond
  12. @change="onChange">
  13. <view class="flex countdown">
  14. <text>剩余</text>
  15. <text>{{ `${timeData.minutes}:${timeData.seconds}` }}</text>
  16. </view>
  17. </uv-count-down>
  18. <view>后关闭</view>
  19. </template>
  20. </view>
  21. </navbar>
  22. <view class="main">
  23. <productCard :data="productCardData"></productCard>
  24. <orderInfoView :data="detail"></orderInfoView>
  25. <view class="notice">
  26. <view class="notice-header">下单须知</view>
  27. <view class="notice-content">
  28. <uv-parse :content="configList['order_instructions']"></uv-parse>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="bottom">
  33. <view class="agreement">
  34. <uv-checkbox-group
  35. v-model="checkboxValue"
  36. shape="circle"
  37. >
  38. <uv-checkbox
  39. size="40rpx"
  40. icon-size="40rpx"
  41. activeColor="#00A9FF"
  42. :name="1"
  43. ></uv-checkbox>
  44. </uv-checkbox-group>
  45. <view class="desc">
  46. 我已阅读并同意
  47. <text class="highlight" @click="$refs.modal.open('unsubscribe_policy', '退订政策')">退订政策</text>
  48. <text class="highlight" @click="$refs.modal.open('model_contract', '合同范本')">合同范本</text>
  49. <text class="highlight" @click="$refs.modal.open('booking_instructions', '预订须知')">预订须知</text>
  50. <text class="highlight" @click="$refs.modal.open('safety_reminder', '安全提示')">安全提示</text>
  51. </view>
  52. </view>
  53. <view class="flex bar">
  54. <button plain class="flex flex-column btn btn-simple" open-type="contact">
  55. <image class="icon" src="@/pages_order/static/product/icon-service.png" mode="widthFix"></image>
  56. <view>联系客服</view>
  57. </button>
  58. <view class="col flex price">
  59. <view class="price-label">
  60. 合计
  61. </view>
  62. <view class="price-unit">¥</view>
  63. <view class="price-value">
  64. {{ detail.payAmount }}
  65. </view>
  66. </view>
  67. <button class="col btn btn-primary" @click="onPay">立即支付</button>
  68. </view>
  69. </view>
  70. <agreementModal ref="modal" @confirm="onConfirmAgreement"></agreementModal>
  71. </view>
  72. </template>
  73. <script>
  74. import { mapState } from 'vuex'
  75. import productCard from '@/pages_order/order/components/productCard.vue'
  76. import orderInfoView from '@/pages_order/order/components/orderInfoView.vue'
  77. import agreementModal from '@/pages_order/components/agreementModal.vue'
  78. export default {
  79. components: {
  80. productCard,
  81. orderInfoView,
  82. agreementModal,
  83. },
  84. data() {
  85. return {
  86. id: null,
  87. detail: {},
  88. time: null,
  89. timeData: {},
  90. checkboxValue: [],
  91. }
  92. },
  93. computed: {
  94. ...mapState(['configList', 'userInfo', 'orderInfo']),
  95. productCardData() {
  96. const {
  97. activityId,
  98. activityTitle,
  99. activityBrief,
  100. activityTag,
  101. startDate,
  102. endDate,
  103. } = this.detail
  104. return {
  105. time: 'time',
  106. product: {
  107. id: activityId,
  108. title: activityTitle,
  109. brief: activityBrief,
  110. tagDetails: activityTag,
  111. dateList: [
  112. {
  113. id: 'time',
  114. startDate,
  115. endDate,
  116. }
  117. ]
  118. }
  119. }
  120. },
  121. },
  122. async onLoad({ id }) {
  123. this.id = id
  124. await this.fetchOrderDetail()
  125. // todo
  126. // this.updateCountdown()
  127. },
  128. async onPullDownRefresh() {
  129. await this.fetchOrderDetail()
  130. uni.stopPullDownRefresh()
  131. },
  132. methods: {
  133. async fetchOrderDetail() {
  134. try {
  135. this.detail = await this.$fetch('queryOrderById', { orderId: this.id })
  136. console.log('orderInfo', this.detail)
  137. } catch (err) {
  138. }
  139. uni.stopPullDownRefresh()
  140. },
  141. onConfirmAgreement(confirm) {
  142. if (confirm) {
  143. this.checkboxValue = [1]
  144. } else {
  145. this.checkboxValue = []
  146. }
  147. },
  148. async onPay() {
  149. if(!this.checkboxValue.length){
  150. return uni.showToast({
  151. title: '请先同意《退订政策》《合同范本》《预订须知》《安全提示》',
  152. icon:'none'
  153. })
  154. }
  155. try {
  156. const result = await this.$fetch('payOrder', { orderId: this.id })
  157. await uni.requestPaymentWxPay({ result })
  158. uni.showToast({
  159. title: '支付成功',
  160. icon: 'none'
  161. })
  162. setTimeout(() => {
  163. // todo: check → jump to order list page ?
  164. uni.reLaunch({
  165. url: `/pages_order/order/orderList/index`
  166. });
  167. }, 700)
  168. } catch (err) {
  169. }
  170. },
  171. updateCountdown() {
  172. let current = dayjs()
  173. let startTime = dayjs(this.detail.createTime)
  174. if (startTime.isSameOrBefore(current)) {
  175. this.time = null
  176. return
  177. }
  178. this.time = startTime.diff(current, 'second')
  179. },
  180. onChange(e) {
  181. this.timeData = e
  182. },
  183. },
  184. }
  185. </script>
  186. <style scoped lang="scss">
  187. @import '../styles/style.scss';
  188. .bottom {
  189. .bar {
  190. .price {
  191. justify-content: flex-start;
  192. column-gap: 8rpx;
  193. &-label {
  194. font-size: 24rpx;
  195. color: #626262;
  196. }
  197. &-unit,
  198. &-value {
  199. font-weight: 500;
  200. color: #FF4800;
  201. }
  202. &-unit {
  203. font-size: 24rpx;
  204. }
  205. &-value {
  206. font-size: 40rpx;
  207. }
  208. }
  209. .btn-simple {
  210. flex: none;
  211. width: auto;
  212. font-family: PingFang SC;
  213. font-weight: 400;
  214. font-size: 22rpx;
  215. line-height: 1.1;
  216. color: #999999;
  217. border: none;
  218. border-radius: unset;
  219. .icon {
  220. width: 52rpx;
  221. height: auto;
  222. margin-bottom: 4rpx;
  223. }
  224. }
  225. }
  226. }
  227. </style>