index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <script setup lang="ts">
  2. import router from '@/router'
  3. definePage({
  4. name: 'djk-confirmOrder',
  5. islogin: true,
  6. style: {
  7. navigationBarTitleText: '提交订单',
  8. },
  9. })
  10. const orderInfo = ref<Api.PmsDjkGoods>()
  11. const isPay = ref(false)
  12. const isAllow = ref(true)
  13. const phone = ref(useUserStore().userInfo.mobile)
  14. const isEdit = ref(false)
  15. const points = ref(0)
  16. const price = ref(0)
  17. const goodsId = ref()
  18. onLoad((options: any) => {
  19. goodsId.value = options.order
  20. getGoodsDetaile()
  21. })
  22. async function getCore() {
  23. const res = await Apis.djk.djkAppletOrderConfirm({ data: { goodsId: orderInfo.value?.id, channelId: useUserStore().userInfo.channelId } })
  24. points.value = res.data.points
  25. price.value = res.data.price
  26. }
  27. async function getGoodsDetaile() {
  28. const res = await Apis.djk.goodsInfo({ data: { goodsId: goodsId.value } })
  29. orderInfo.value = res.data
  30. getCore()
  31. }
  32. async function handleH5PayResult(orderNumber: string) {
  33. const isPaySuccess = await useUserStore().pollOrderPaySuccess(orderNumber)
  34. if (isPaySuccess) {
  35. isPay.value = false
  36. router.replace({ name: 'djk-homeTabbar', params: { pay: '1' } })
  37. return
  38. }
  39. useGlobalToast().show({ msg: '暂未查询到支付成功,请稍后在订单列表查看' })
  40. isPay.value = false
  41. }
  42. async function handlePay() {
  43. if (!orderInfo.value) {
  44. useGlobalToast().show({ msg: '网络异常!请联系客服' })
  45. return
  46. }
  47. isPay.value = true
  48. try {
  49. const data = await Apis.djk.addDJKOrder({ data: { shopId: orderInfo.value.shopId, channelId: useUserStore().userInfo.channelId, phone: phone.value, goodsId: orderInfo.value.id, goodsNum: 1, customerAuthorization: boolToNumber(isAllow.value) } })
  50. const payMent = await useUserStore().getPayMent(data.data)
  51. if (payMent.payType !== 'point') {
  52. try {
  53. // #ifdef MP-WEIXIN
  54. const res = await useUserStore().handleCommonPayMent(data.data)
  55. await useUserStore().getWxCommonPayment(res)
  56. await useUserStore().paySuccess('djk-homeTabbar', 'subPack-djk/commonTab/index')
  57. // #endif
  58. // #ifdef H5
  59. useUserStore().handleCommonWechatPay(data.data)
  60. await handleH5PayResult(data.data)
  61. // #endif
  62. isPay.value = false
  63. }
  64. catch {
  65. useUserStore().payError('djk-homeTabbar', 'subPack-djk/commonTab/index')
  66. }
  67. }
  68. else {
  69. await useUserStore().handleCommonPayMent(data.data)
  70. await useUserStore().paySuccess('djk-homeTabbar', 'subPack-djk/commonTab/index')
  71. }
  72. }
  73. catch (error) {
  74. console.log('error', error)
  75. isPay.value = false
  76. }
  77. }
  78. </script>
  79. <template>
  80. <view v-if="orderInfo" class="page px20rpx py20rpx">
  81. <view class="flex items-center rounded-16rpx bg-white p24rpx">
  82. <image
  83. :src="orderInfo.goodsImg?.split(',')[0]"
  84. class="h160rpx w160rpx flex-shrink-0 rounded-16rpx"
  85. />
  86. <view class="ml20rpx flex-1">
  87. <view class="text-32rpx font-semibold">
  88. {{ orderInfo.goodsName }}
  89. </view>
  90. <view class="mt16rpx text-24rpx text-gray">
  91. 有效期{{ orderInfo.effectiveTime }}天·需提前{{ orderInfo.advanceBookingTime }}天预约
  92. </view>
  93. <view class="mt16rpx flex items-center justify-between">
  94. <view class="text-36rpx text-#FF4D3A font-semibold">
  95. <text class="text-20rpx">
  96. </text> {{ orderInfo.price }}
  97. </view>
  98. <view class="text-24rpx text-gray">
  99. x1
  100. </view>
  101. </view>
  102. </view>
  103. </view>
  104. <view class="mt20rpx rounded-16rpx bg-white p24rpx">
  105. <view class="flex items-center justify-between">
  106. <view class="text-28rpx text-gray">
  107. 商品金额
  108. </view>
  109. <view class="text-28rpx font-semibold">
  110. ¥{{ orderInfo.price }}
  111. </view>
  112. </view>
  113. <view class="mt20rpx flex items-center justify-between">
  114. <view class="text-28rpx text-gray">
  115. 积分{{ points ? `(${points})` : '' }}
  116. </view>
  117. <view class="text-28rpx font-semibold" :class="[points ? '' : 'text-gray']">
  118. {{ points ? `-¥${points / 100}` : '不可用' }}
  119. </view>
  120. </view>
  121. <view class="my20rpx h2rpx w-full bg-#F0F0F0" />
  122. <view class="mt20rpx flex items-center justify-between">
  123. <view class="text-28rpx text-gray">
  124. 总计
  125. </view>
  126. <view class="text-28rpx font-semibold">
  127. ¥{{ price }}
  128. </view>
  129. </view>
  130. </view>
  131. <view class="mt20rpx rounded-16rpx bg-white p24rpx">
  132. <view class="flex items-center justify-between">
  133. <view class="text-28rpx text-gray">
  134. 允许商户通过此号码致电沟通到店时间
  135. </view>
  136. <wd-checkbox v-model="isAllow" />
  137. </view>
  138. <view class="mt16rpx flex items-center text-28rpx">
  139. <view v-if="!isEdit" class="mr10rpx">
  140. {{ phoneFormat(String(phone)) }}
  141. </view>
  142. <view v-else>
  143. <input v-model="phone" type="number" :maxlength="11" :focus="isEdit" @blur="isEdit = false">
  144. </view>
  145. <view v-if="!isEdit" class="flex items-center" @click="isEdit = true">
  146. <view class="mr5rpx">
  147. 修改
  148. </view>
  149. <wd-icon name="arrow-right" size="18px" color="#000" />
  150. </view>
  151. </view>
  152. </view>
  153. <view class="mt20rpx rounded-16rpx bg-white p24rpx">
  154. <view class="text-32rpx font-semibold">
  155. 购买须知
  156. </view>
  157. <view class="mt20rpx text-24rpx text-gray">
  158. 有效期
  159. </view>
  160. <view class="mt16rpx text-28rpx">
  161. 购买之日起{{ orderInfo.effectiveTime }}天有效
  162. </view>
  163. <view class="mt20rpx text-24rpx text-gray">
  164. 预约信息
  165. </view>
  166. <view class="mt16rpx text-28rpx">
  167. 请您提前{{ orderInfo.advanceBookingTime }}天预定
  168. </view>
  169. <view class="mt20rpx text-24rpx text-gray">
  170. 可用时间
  171. </view>
  172. <view class="mt16rpx text-28rpx">
  173. {{ orderInfo.useStartTime }} 至 {{ orderInfo.useEndTime }}
  174. </view>
  175. <view class="mt20rpx text-24rpx text-gray">
  176. 消费流程
  177. </view>
  178. <view class="mt16rpx text-28rpx">
  179. {{ orderInfo.usageProcess }}
  180. </view>
  181. <view class="mt20rpx text-24rpx text-gray">
  182. 购买人群
  183. </view>
  184. <view class="mt16rpx text-28rpx">
  185. {{ orderInfo.buyNotice }}
  186. </view>
  187. </view>
  188. <view class="h250rpx" />
  189. <view class="ios footer fixed bottom-0 left-0 box-border w-full rounded-t-16rpx bg-white px24rpx">
  190. <view class="box-border w-full flex items-center justify-between py20rpx">
  191. <view class="flex items-center text-#FF4D3A">
  192. <view class="font-semibold10 flex items-baseline text-36rpx">
  193. <text class="text-24rpx">
  194. </text> {{ price }}
  195. </view>
  196. <view class="ml20rpx text-22rpx">
  197. 共减¥ {{ points / 100 }}
  198. </view>
  199. </view>
  200. <view class="w180rpx">
  201. <wd-button size="large" :loading="isPay" loading-color="#9ED605" @click="handlePay">
  202. 立即支付
  203. </wd-button>
  204. </view>
  205. </view>
  206. </view>
  207. </view>
  208. </template>
  209. <style scoped lang="scss">
  210. .footer{
  211. box-shadow: 0rpx -6rpx 12rpx 2rpx rgba(0,0,0,0.05);
  212. }
  213. .page{
  214. :deep(){
  215. .wd-button{
  216. width: 180rpx !important;
  217. }
  218. }
  219. }
  220. </style>