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

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