pay.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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 + '.00' || '188.00' }}
  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. // 订单进度模版id
  55. templateOrder: 'ERU1ZY9IqwNkDxWyFJvo5VSE7ua-wey3SqhZgjqLDtU'
  56. }
  57. },
  58. onLoad(options) {
  59. if (options.info) {
  60. this.info = JSON.parse(options.info)
  61. }
  62. console.log(this.info)
  63. },
  64. methods: {
  65. // 点击确认支付按钮回调
  66. async handleSub() {
  67. if (this.isChecked) {
  68. const res = await this.$myRequest({
  69. url: '/mhotel/abkpay.action',
  70. data: {
  71. open_id: uni.getStorageSync('openid'),
  72. bookingId: this.info.orderNo
  73. }
  74. })
  75. // console.log(res)
  76. if (res.code === 200) {
  77. uni.requestPayment({
  78. provider: 'wxpay',
  79. timeStamp: res.data.timeStamp,
  80. nonceStr: res.data.nonceStr,
  81. package: 'prepay_id=' + res.data.prepay_id,
  82. signType: res.data.signType,
  83. paySign: res.data.paySign,
  84. success: (res) => {
  85. if (res.errMsg == 'requestPayment:ok') {
  86. uni.navigateTo({
  87. url: '/pages/payStatus/payStatus?status=1'
  88. })
  89. } else {
  90. uni.navigateTo({
  91. url: '/pages/payStatus/payStatus?status=2'
  92. })
  93. }
  94. },
  95. fail: (err) => {
  96. if (err.errMsg === 'requestPayment:fail cancel') {
  97. uni.showToast({
  98. title: '支付已取消',
  99. icon: 'none',
  100. mask: true
  101. })
  102. }
  103. }
  104. })
  105. }
  106. } else {
  107. uni.showToast({
  108. title: '请选择支付方式',
  109. icon: 'none'
  110. })
  111. }
  112. },
  113. // 点击支付方式回调
  114. handleChange() {
  115. this.isChecked = !this.isChecked
  116. },
  117. // 倒计时变化时触发
  118. change(e) {
  119. // console.log(e)
  120. },
  121. // 倒计时结束回调
  122. finish() {
  123. uni.showModal({
  124. title: '提示',
  125. content: '订单已超过可支付时间,请重新下单',
  126. showCancel: false,
  127. success: (res) => {
  128. if (res.confirm) {
  129. uni.switchTab({
  130. url: '/pages/home/home'
  131. })
  132. }
  133. }
  134. })
  135. }
  136. }
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. .container {
  141. position: relative;
  142. box-sizing: border-box;
  143. padding: 0 20rpx 160rpx;
  144. min-height: 100vh;
  145. background-color: #f2f3f5;
  146. .countDown {
  147. display: flex;
  148. justify-content: center;
  149. align-items: center;
  150. height: 70rpx;
  151. color: #808080;
  152. font-size: 24rpx;
  153. }
  154. .price {
  155. display: flex;
  156. justify-content: center;
  157. align-items: center;
  158. height: 65rpx;
  159. font-size: 50rpx;
  160. font-weight: bold;
  161. text {
  162. font-size: 28rpx;
  163. }
  164. }
  165. .title {
  166. margin-top: 14rpx;
  167. color: #808080;
  168. font-size: 24rpx;
  169. }
  170. .info {
  171. display: flex;
  172. flex-direction: column;
  173. box-sizing: border-box;
  174. padding: 0 30rpx;
  175. margin-top: 18rpx;
  176. width: 100%;
  177. border-radius: 15rpx;
  178. background-color: #fff;
  179. .info_time {
  180. display: flex;
  181. align-items: center;
  182. margin-top: 20rpx;
  183. font-size: 32rpx;
  184. font-weight: bold;
  185. .time_line {
  186. width: 17rpx;
  187. height: 1rpx;
  188. background-color: #096562;
  189. }
  190. .time_num {
  191. box-sizing: border-box;
  192. padding: 0 15rpx;
  193. height: 46rpx;
  194. line-height: 46rpx;
  195. font-size: 24rpx;
  196. font-weight: 400;
  197. border-radius: 66rpx;
  198. border: 1rpx solid #096562;
  199. background-color: #f0f2f5;
  200. }
  201. .gap {
  202. margin: 0 10rpx;
  203. }
  204. text {
  205. font-size: 24rpx;
  206. font-weight: 400;
  207. }
  208. }
  209. .info_msg {
  210. margin-top: 15rpx;
  211. font-size: 28rpx;
  212. font-weight: bold;
  213. }
  214. .info_type {
  215. display: flex;
  216. flex-wrap: wrap;
  217. margin-top: 15rpx;
  218. .type_item {
  219. box-sizing: border-box;
  220. padding: 0 15rpx;
  221. margin-right: 20rpx;
  222. height: 41rpx;
  223. line-height: 41rpx;
  224. font-size: 24rpx;
  225. color: #fff;
  226. border-radius: 34rpx;
  227. background-color: #096562;
  228. }
  229. }
  230. .info_tag {
  231. display: flex;
  232. flex-wrap: wrap;
  233. margin: 18rpx 0 30rpx;
  234. color: #808080;
  235. font-size: 24rpx;
  236. .tag_item {
  237. margin-right: 20rpx;
  238. }
  239. }
  240. }
  241. .way {
  242. .way_item {
  243. display: flex;
  244. align-items: center;
  245. box-sizing: border-box;
  246. padding: 0 30rpx;
  247. margin-top: 18rpx;
  248. height: 100rpx;
  249. font-size: 28rpx;
  250. border-radius: 15rpx;
  251. background-color: #fff;
  252. img {
  253. width: 40rpx;
  254. height: 40rpx;
  255. }
  256. .way_text {
  257. margin-left: 18rpx;
  258. }
  259. .way_radio {
  260. margin-left: auto;
  261. transform: scale(0.9);
  262. }
  263. }
  264. }
  265. .btn {
  266. position: fixed;
  267. bottom: 40rpx;
  268. display: flex;
  269. justify-content: center;
  270. align-items: center;
  271. width: 710rpx;
  272. height: 96rpx;
  273. color: #fff;
  274. font-size: 32rpx;
  275. border-radius: 64rpx;
  276. background-color: #096562;
  277. }
  278. }
  279. </style>