pay.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <view class="container">
  3. <view class="countDown">
  4. 交易剩余时间
  5. <uv-count-down :time="countDownTime" format="mm:ss" @change="change" @finish="finish"></uv-count-down>
  6. </view>
  7. <view class="price">
  8. <text>¥</text>
  9. {{ info.price }}
  10. </view>
  11. <view class="title">住房信息</view>
  12. <view class="info">
  13. <view class="info_time">
  14. {{ info.detaliInfo.startTimeMonth || 8 }}月{{ info.detaliInfo.startTimeDay || 2 }}日
  15. <text class="gap">星期{{ info.detaliInfo.startTimeWeek || '三' }}</text>
  16. <view class="time_line"></view>
  17. <view class="time_num">{{ info.detaliInfo.nightNum || 1 }}晚</view>
  18. <view class="time_line"></view>
  19. <view class="gap">{{ info.detaliInfo.endTimeMonth || 8 }}月{{ info.detaliInfo.endTimeDay || 3 }}日</view>
  20. <text>星期{{ info.detaliInfo.endTimeWeek || '四' }}</text>
  21. </view>
  22. <view class="info_msg">{{ info.detaliInfo.item.hName }}</view>
  23. <view class="info_type">
  24. <view class="type_item">包吃住型</view>
  25. <view class="type_item">包吃住型</view>
  26. <view class="type_item">包吃住型</view>
  27. </view>
  28. <view class="info_tag">
  29. <view class="tag_item">{{ info.detaliInfo.item.hAreas }}㎡</view>
  30. <view class="tag_item">双人床</view>
  31. <view class="tag_item">窗户位于走廊/窗户较小</view>
  32. </view>
  33. </view>
  34. <view class="title">支付方式</view>
  35. <view class="way">
  36. <view class="way_item" @click="handleChange">
  37. <img src="../../static/index/wxPay.png" />
  38. <view class="way_text">微信支付</view>
  39. <radio class="way_radio" :checked="isChecked" />
  40. </view>
  41. </view>
  42. <!-- 提交订单区域 -->
  43. <view class="btn" @click="handleSub">确认支付</view>
  44. </view>
  45. </template>
  46. <script>
  47. export default {
  48. data() {
  49. return {
  50. isChecked: true,
  51. info: {},
  52. // 倒计时时间(毫秒)
  53. countDownTime: 1000 * 60 * 15
  54. }
  55. },
  56. onLoad(options) {
  57. if (options.info) {
  58. this.info = JSON.parse(options.info)
  59. }
  60. console.log(this.info)
  61. },
  62. methods: {
  63. // 点击确认支付按钮回调
  64. async handleSub() {
  65. if (this.isChecked) {
  66. const res = await this.$myRequest({
  67. url: '/mhotel/abkpay.action',
  68. data: {
  69. open_id: uni.getStorageSync('openid'),
  70. bookingId: this.info.orderNo
  71. }
  72. })
  73. // console.log(res)
  74. if (res.code === 200) {
  75. uni.requestPayment({
  76. provider: 'wxpay',
  77. timeStamp: res.data.timeStamp,
  78. nonceStr: res.data.nonceStr,
  79. package: 'prepay_id=' + res.data.prepay_id,
  80. signType: res.data.signType,
  81. paySign: res.data.paySign,
  82. success: (res) => {
  83. if (res.errMsg == 'requestPayment:ok') {
  84. uni.navigateTo({
  85. url: '/pages/payStatus/payStatus?status=1'
  86. })
  87. } else {
  88. uni.navigateTo({
  89. url: '/pages/payStatus/payStatus?status=2'
  90. })
  91. }
  92. },
  93. fail: (err) => {
  94. if (err.errMsg === 'requestPayment:fail cancel') {
  95. uni.showToast({
  96. title: '支付已取消',
  97. icon: 'none',
  98. mask: true
  99. })
  100. }
  101. }
  102. })
  103. }
  104. } else {
  105. uni.showToast({
  106. title: '请选择支付方式',
  107. icon: 'none'
  108. })
  109. }
  110. },
  111. // 点击支付方式回调
  112. handleChange() {
  113. this.isChecked = !this.isChecked
  114. },
  115. // 倒计时变化时触发
  116. change(e) {
  117. // console.log(e)
  118. },
  119. // 倒计时结束回调
  120. finish() {
  121. uni.showModal({
  122. title: '提示',
  123. content: '订单已超过可支付时间,请重新下单',
  124. showCancel: false,
  125. success: (res) => {
  126. if (res.confirm) {
  127. uni.switchTab({
  128. url: '/pages/home/home'
  129. })
  130. }
  131. }
  132. })
  133. }
  134. }
  135. }
  136. </script>
  137. <style lang="scss" scoped>
  138. .container {
  139. position: relative;
  140. box-sizing: border-box;
  141. padding: 0 20rpx 160rpx;
  142. min-height: 100vh;
  143. background-color: #f2f3f5;
  144. .countDown {
  145. display: flex;
  146. justify-content: center;
  147. align-items: center;
  148. height: 70rpx;
  149. color: #808080;
  150. font-size: 24rpx;
  151. }
  152. .price {
  153. display: flex;
  154. justify-content: center;
  155. align-items: center;
  156. height: 65rpx;
  157. font-size: 50rpx;
  158. font-weight: bold;
  159. text {
  160. font-size: 28rpx;
  161. }
  162. }
  163. .title {
  164. margin-top: 14rpx;
  165. color: #808080;
  166. font-size: 24rpx;
  167. }
  168. .info {
  169. display: flex;
  170. flex-direction: column;
  171. box-sizing: border-box;
  172. padding: 0 30rpx;
  173. margin-top: 18rpx;
  174. width: 100%;
  175. border-radius: 15rpx;
  176. background-color: #fff;
  177. .info_time {
  178. display: flex;
  179. align-items: center;
  180. margin-top: 20rpx;
  181. font-size: 32rpx;
  182. font-weight: bold;
  183. .time_line {
  184. width: 17rpx;
  185. height: 1rpx;
  186. background-color: #096562;
  187. }
  188. .time_num {
  189. box-sizing: border-box;
  190. padding: 0 15rpx;
  191. height: 46rpx;
  192. line-height: 46rpx;
  193. font-size: 24rpx;
  194. font-weight: 400;
  195. border-radius: 66rpx;
  196. border: 1rpx solid #096562;
  197. background-color: #f0f2f5;
  198. }
  199. .gap {
  200. margin: 0 10rpx;
  201. }
  202. text {
  203. font-size: 24rpx;
  204. font-weight: 400;
  205. }
  206. }
  207. .info_msg {
  208. margin-top: 15rpx;
  209. font-size: 28rpx;
  210. font-weight: bold;
  211. }
  212. .info_type {
  213. display: flex;
  214. flex-wrap: wrap;
  215. margin-top: 15rpx;
  216. .type_item {
  217. box-sizing: border-box;
  218. padding: 0 15rpx;
  219. margin-right: 20rpx;
  220. height: 41rpx;
  221. line-height: 41rpx;
  222. font-size: 24rpx;
  223. color: #fff;
  224. border-radius: 34rpx;
  225. background-color: #096562;
  226. }
  227. }
  228. .info_tag {
  229. display: flex;
  230. flex-wrap: wrap;
  231. margin: 18rpx 0 30rpx;
  232. color: #808080;
  233. font-size: 24rpx;
  234. .tag_item {
  235. margin-right: 20rpx;
  236. }
  237. }
  238. }
  239. .way {
  240. .way_item {
  241. display: flex;
  242. align-items: center;
  243. box-sizing: border-box;
  244. padding: 0 30rpx;
  245. margin-top: 18rpx;
  246. height: 100rpx;
  247. font-size: 28rpx;
  248. border-radius: 15rpx;
  249. background-color: #fff;
  250. img {
  251. width: 40rpx;
  252. height: 40rpx;
  253. }
  254. .way_text {
  255. margin-left: 18rpx;
  256. }
  257. .way_radio {
  258. margin-left: auto;
  259. transform: scale(0.9);
  260. }
  261. }
  262. }
  263. .btn {
  264. position: fixed;
  265. bottom: 40rpx;
  266. display: flex;
  267. justify-content: center;
  268. align-items: center;
  269. width: 710rpx;
  270. height: 96rpx;
  271. color: #fff;
  272. font-size: 32rpx;
  273. border-radius: 64rpx;
  274. background-color: #096562;
  275. }
  276. }
  277. </style>