pay-popup.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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" @click="toNotice">同意<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. // return
  73. uni.navigateTo({
  74. url: '/pages/coupon/index'
  75. })
  76. },
  77. toNotice() {
  78. uni.navigateTo({
  79. url: '/pages/about/notice'
  80. })
  81. },
  82. close() {
  83. this.checked = false
  84. this.$emit('close')
  85. },
  86. success(id) {
  87. this.checked = false
  88. this.$emit('success', id)
  89. },
  90. pay() {
  91. let _this = this
  92. let payIng = false
  93. if (!this.checked) {
  94. uni.$u.toast('请同意《盲票购买须知》!');
  95. return
  96. }
  97. if (payIng) return
  98. $http.post('/api/v1/mp/user/ticket/order/submit', {}).then(res => {
  99. payIng = true
  100. if (res.code == 0) {
  101. if (res.data.needPay == 1) {
  102. $http.post('/api/v1/mp/user/ticket/order/pay', {
  103. orderId: res.data.orderId,
  104. payType: 2
  105. }).then(ele => {
  106. if (ele.code == 0) {
  107. uni.requestPayment({
  108. timeStamp: ele.data.timeStamp,
  109. nonceStr: ele.data.nonceStr,
  110. package: ele.data.package,
  111. signType: ele.data.signType,
  112. paySign: ele.data.paySign,
  113. success() {
  114. uni.showToast({
  115. title: '支付成功',
  116. icon: 'success',
  117. duration: 2000
  118. })
  119. _this.success(res.data.orderId)
  120. },
  121. fail() {
  122. payIng = false
  123. _this.close()
  124. }
  125. })
  126. } else {
  127. payIng = false
  128. _this.close()
  129. uni.$u.toast('支付失败!');
  130. }
  131. }).catch(() => {
  132. payIng = false
  133. _this.close()
  134. uni.$u.toast('支付失败!');
  135. })
  136. } else {
  137. uni.showToast({
  138. title: '支付成功',
  139. icon: 'success',
  140. duration: 2000
  141. })
  142. _this.close()
  143. }
  144. } else {
  145. payIng = false
  146. _this.close()
  147. uni.$u.toast('支付失败!');
  148. }
  149. }).catch(() => {
  150. payIng = false
  151. uni.$u.toast('支付失败!');
  152. })
  153. },
  154. },
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. .choiceShow-wrap {
  159. min-height: 400rpx;
  160. padding: 80rpx 0 60rpx;
  161. .goods {
  162. padding: 0 20rpx;
  163. justify-content: space-between;
  164. margin-bottom: 20rpx;
  165. .image-wrap {
  166. width: 220rpx;
  167. height: 220rpx;
  168. border: 1px solid rgba(236, 236, 236, 100);
  169. border-radius: 10rpx;
  170. image {
  171. width: 174rpx;
  172. height: 174rpx;
  173. }
  174. }
  175. .info {
  176. flex: 1;
  177. display: flex;
  178. height: 220rpx;
  179. flex-direction: column;
  180. justify-content: space-between;
  181. padding-left: 26rpx;
  182. &-title {
  183. font-size: 32rpx;
  184. line-height: 44rpx;
  185. font-weight: bold;
  186. }
  187. &-coin {
  188. display: flex;
  189. align-items: center;
  190. font-size: 32rpx;
  191. line-height: 44rpx;
  192. color: rgba(235, 112, 9, 100);
  193. font-weight: bold;
  194. image {
  195. width: 42rpx;
  196. height: 42rpx;
  197. margin-right: 20rpx;
  198. }
  199. }
  200. &-stock {
  201. line-height: 44rpx;
  202. }
  203. }
  204. }
  205. .coupon {
  206. justify-content: space-between;
  207. padding: 30rpx 40rpx;
  208. border-top: 1px solid rgba(187, 187, 187, 100);
  209. border-bottom: 1px solid rgba(187, 187, 187, 100);
  210. .txt {
  211. margin: 0 24rpx;
  212. }
  213. }
  214. .agreement {
  215. justify-content: space-between;
  216. padding: 50rpx 40rpx;
  217. border-bottom: 1px solid rgba(187, 187, 187, 100);
  218. .txt text {
  219. color: #007aff;
  220. }
  221. }
  222. .btn {
  223. justify-content: space-between;
  224. padding: 20rpx 20rpx;
  225. &-left {
  226. .coin {
  227. display: flex;
  228. align-items: center;
  229. font-size: 32rpx;
  230. line-height: 44rpx;
  231. color: rgba(235, 112, 9, 100);
  232. margin-left: 20rpx;
  233. }
  234. }
  235. &-right {
  236. .confirm {
  237. width: 250rpx;
  238. height: 60rpx;
  239. line-height: 60rpx;
  240. border-radius: 8px;
  241. background-color: rgba(235, 112, 9, 100);
  242. color: rgba(255, 255, 255, 100);
  243. font-size: 28rpx;
  244. text-align: center;
  245. }
  246. }
  247. }
  248. }
  249. </style>