pay-popup.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <view>
  3. <u-popup :show="payShow" mode="bottom" @close="close" :closeable="true">
  4. <view class="choiceShow-wrap">
  5. <view class="flex goods">
  6. <view class="flex image-wrap">
  7. <image :src="payInfo.picUrl" mode="aspectFill"></image>
  8. </view>
  9. <view class="info">
  10. <view class="info-title">{{ payInfo.title }}</view>
  11. <view class="info-stock">¥{{ $numberFormat( payInfo.salePrice ) }}</view>
  12. </view>
  13. </view>
  14. <view class="flex coupon" @click="toCoupon">
  15. <view class="flex coupon-left">
  16. <u-icon name="coupon" size="26" color="#333"></u-icon>
  17. <view class="txt">代金券</view>
  18. </view>
  19. <view class="flex coupon-right">
  20. <view class="txt">暂无可用代金券</view>
  21. <u-icon name="arrow-right" size="16" color="#333"></u-icon>
  22. </view>
  23. </view>
  24. <view class="flex agreement">
  25. <view class="txt">同意<text>《盲票购买须知》</text></view>
  26. <view class="checked">
  27. <u-checkbox-group>
  28. <u-checkbox :value="checked" :checked="checked" shape="circle" activeColor="#E96737"
  29. @change="changeChecked"></u-checkbox>
  30. </u-checkbox-group>
  31. </view>
  32. </view>
  33. <view class="flex btn">
  34. <view class="flex btn-left">
  35. <view class="title">应付:</view>
  36. <view class="flex coin">¥{{ $numberFormat(payInfo.payAmt) }}</view>
  37. </view>
  38. <view class="btn-right">
  39. <view class="confirm" @click="pay">立即支付</view>
  40. </view>
  41. </view>
  42. </view>
  43. </u-popup>
  44. </view>
  45. </template>
  46. <script>
  47. import $http from '@/utils/request.js'
  48. export default {
  49. name: "pay-popup",
  50. props: {
  51. payShow: {
  52. type: [Boolean],
  53. default: false
  54. },
  55. payInfo: {
  56. type: [Object],
  57. default: {}
  58. }
  59. },
  60. data() {
  61. return {
  62. checked: false,
  63. couponIds: [],
  64. autoCoupon: 1,
  65. };
  66. },
  67. methods: {
  68. changeChecked(e) {
  69. this.checked = e
  70. },
  71. toCoupon() {
  72. uni.navigateTo({
  73. url: '/pages/coupon/index'
  74. })
  75. },
  76. close() {
  77. this.checked = false
  78. this.$emit('close')
  79. },
  80. success(id){
  81. this.checked = false
  82. this.$emit('success', id)
  83. },
  84. pay() {
  85. let _this = this
  86. let payIng = false
  87. if (!this.checked) {
  88. uni.$u.toast('请同意《盲票购买须知》!');
  89. return
  90. }
  91. if (payIng) return
  92. $http.post('/api/v1/mp/user/ticket/order/submit', {}).then(res => {
  93. payIng = true
  94. if (res.code == 0) {
  95. if (res.data.needPay == 1) {
  96. $http.post('/api/v1/mp/user/ticket/order/pay', {
  97. orderId: res.data.orderId,
  98. payType: 2
  99. }).then(ele => {
  100. if (ele.code == 0) {
  101. uni.requestPayment({
  102. timeStamp: ele.data.timeStamp,
  103. nonceStr: ele.data.nonceStr,
  104. package: ele.data.package,
  105. signType: ele.data.signType,
  106. paySign: ele.data.paySign,
  107. success() {
  108. uni.showToast({
  109. title: '支付成功',
  110. icon: 'success',
  111. duration: 2000
  112. })
  113. _this.success(res.data.orderId)
  114. },
  115. fail() {
  116. payIng = false
  117. _this.close()
  118. }
  119. })
  120. } else {
  121. payIng = false
  122. _this.close()
  123. uni.$u.toast('支付失败!');
  124. }
  125. }).catch(() => {
  126. payIng = false
  127. _this.close()
  128. uni.$u.toast('支付失败!');
  129. })
  130. } else {
  131. uni.showToast({
  132. title: '支付成功',
  133. icon: 'success',
  134. duration: 2000
  135. })
  136. _this.close()
  137. }
  138. }else{
  139. payIng = false
  140. _this.close()
  141. uni.$u.toast('支付失败!');
  142. }
  143. }).catch(() => {
  144. payIng = false
  145. uni.$u.toast('支付失败!');
  146. })
  147. },
  148. },
  149. }
  150. </script>
  151. <style lang="scss" scoped>
  152. .choiceShow-wrap {
  153. min-height: 400rpx;
  154. padding: 80rpx 0 60rpx;
  155. .goods {
  156. padding: 0 20rpx;
  157. justify-content: space-between;
  158. margin-bottom: 20rpx;
  159. .image-wrap {
  160. width: 220rpx;
  161. height: 220rpx;
  162. border: 1px solid rgba(236, 236, 236, 100);
  163. border-radius: 10rpx;
  164. image {
  165. width: 174rpx;
  166. height: 174rpx;
  167. }
  168. }
  169. .info {
  170. flex: 1;
  171. display: flex;
  172. height: 220rpx;
  173. flex-direction: column;
  174. justify-content: space-between;
  175. padding-left: 26rpx;
  176. &-title {
  177. font-size: 32rpx;
  178. line-height: 44rpx;
  179. font-weight: bold;
  180. }
  181. &-coin {
  182. display: flex;
  183. align-items: center;
  184. font-size: 32rpx;
  185. line-height: 44rpx;
  186. color: rgba(235, 112, 9, 100);
  187. font-weight: bold;
  188. image {
  189. width: 42rpx;
  190. height: 42rpx;
  191. margin-right: 20rpx;
  192. }
  193. }
  194. &-stock {
  195. line-height: 44rpx;
  196. }
  197. }
  198. }
  199. .coupon {
  200. justify-content: space-between;
  201. padding: 30rpx 40rpx;
  202. border-top: 1px solid rgba(187, 187, 187, 100);
  203. border-bottom: 1px solid rgba(187, 187, 187, 100);
  204. .txt {
  205. margin: 0 24rpx;
  206. }
  207. }
  208. .agreement {
  209. justify-content: space-between;
  210. padding: 50rpx 40rpx;
  211. border-bottom: 1px solid rgba(187, 187, 187, 100);
  212. .txt text {
  213. color: #007aff;
  214. }
  215. }
  216. .btn {
  217. justify-content: space-between;
  218. padding: 20rpx 20rpx;
  219. &-left {
  220. .coin {
  221. display: flex;
  222. align-items: center;
  223. font-size: 32rpx;
  224. line-height: 44rpx;
  225. color: rgba(235, 112, 9, 100);
  226. margin-left: 20rpx;
  227. }
  228. }
  229. &-right {
  230. .confirm {
  231. width: 250rpx;
  232. height: 60rpx;
  233. line-height: 60rpx;
  234. border-radius: 8px;
  235. background-color: rgba(235, 112, 9, 100);
  236. color: rgba(255, 255, 255, 100);
  237. font-size: 28rpx;
  238. text-align: center;
  239. }
  240. }
  241. }
  242. }
  243. </style>