pay-popup.vue 5.9 KB

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