pay-popup.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <view>
  3. <u-popup :show="payShow" mode="bottom" round="17" @close="close" :closeable="true" overlayOpacity="0.5" @touchmove.prevent.stop>
  4. <view class="choiceShow-wrap">
  5. <!-- 盲票信息 -->
  6. <view class="flex goods">
  7. <view class="flex image-wrap">
  8. <image :src="payInfo.picUrl" mode="aspectFit"></image>
  9. </view>
  10. <view class="info">
  11. <view class="info-title">{{ payInfo.title }}</view>
  12. <view class="info-stock">¥{{ $numberFormat( payInfo.orderAmt ) }}</view>
  13. </view>
  14. </view>
  15. <!-- 优惠券信息 -->
  16. <view class="flex coupon" @click="toCoupon">
  17. <view class="flex coupon-left">
  18. <image src="../../static/icon/public_coupon.png" mode="scaleToFill"></image>
  19. <view class="txt">优惠券</view>
  20. </view>
  21. <view class="coupon-right flex">
  22. <view class="txt coupon-right-color" v-if="$numberFormat(payInfo.discountAmt) != 0">-¥{{ $numberFormat(payInfo.discountAmt)}}</view>
  23. <view class="txt" v-else-if="payInfo.listNum != undefined">{{payInfo.listNum}}张可用</view>
  24. <view class="txt" v-else>暂无可用优惠券</view>
  25. <image src="../../static/icon/public_right_arrow.png" mode="scaleToFill"></image>
  26. </view>
  27. </view>
  28. <view class="flex agreement">
  29. <view class="checked">
  30. <u-checkbox-group>
  31. <u-checkbox :value="checked" :checked="checked" shape="circle"
  32. activeColor="#F9822C" @change="changeChecked"></u-checkbox>
  33. </u-checkbox-group>
  34. </view>
  35. <view class="txt" @click="toRule">同意《盲票购买协议》</text></view>
  36. </view>
  37. <view class="flex btn">
  38. <view class="flex btn-left">
  39. <view class="title">应付:</view>
  40. <view class="flex price">¥{{ $numberFormat(payInfo.payAmt) }}</view>
  41. </view>
  42. <view class="btn-right">
  43. <view class="confirm" @click="pay">立即支付</view>
  44. </view>
  45. </view>
  46. </view>
  47. </u-popup>
  48. </view>
  49. </template>
  50. <script>
  51. import $http from '@/utils/request.js'
  52. export default {
  53. name: "pay-popup",
  54. props: {
  55. payShow: {
  56. type: [Boolean],
  57. default: false
  58. },
  59. payInfo: {
  60. type: [Object],
  61. default: {}
  62. }
  63. },
  64. data() {
  65. return {
  66. checked: false,
  67. };
  68. },
  69. methods: {
  70. changeChecked(e) {
  71. this.checked = e
  72. },
  73. toCoupon() {
  74. uni.navigateTo({
  75. url: `/packageGoods/coupon/index?couponId=${ this.payInfo.couponId }&boxId=${ this.payInfo.boxId }&ticketId=${ this.payInfo.ticketId }`
  76. })
  77. },
  78. toRule() {
  79. uni.navigateTo({
  80. url: '/packageOther/rule/index'
  81. })
  82. },
  83. close() {
  84. this.checked = false
  85. this.$emit('close')
  86. },
  87. success(id) {
  88. this.checked = false
  89. this.$emit('success', id)
  90. },
  91. pay() {
  92. let _this = this
  93. let payIng = false
  94. if (!this.checked) {
  95. uni.$u.toast('请同意《盲票产品规则》');
  96. return
  97. }
  98. uni.showLoading({
  99. title: '支付中'
  100. });
  101. if (payIng) return
  102. $http.post('/api/v1/mp/user/ticket/order/submit', {
  103. suid: uni.getStorageSync('shareUid'),
  104. type: uni.getStorageSync('shareType')
  105. }).then(res => {
  106. uni.hideLoading();
  107. payIng = true
  108. if (res.code == 0) {
  109. if (res.data.needPay == 1) {
  110. $http.post('/api/v1/mp/user/ticket/order/pay', {
  111. orderId: res.data.orderId,
  112. payType: 2
  113. }).then(ele => {
  114. if (ele.code == 0) {
  115. uni.requestPayment({
  116. timeStamp: ele.data.timeStamp,
  117. nonceStr: ele.data.nonceStr,
  118. package: ele.data.package,
  119. signType: ele.data.signType,
  120. paySign: ele.data.paySign,
  121. success() {
  122. uni.showToast({
  123. title: '支付成功',
  124. icon: 'success',
  125. duration: 2000
  126. })
  127. _this.success(res.data.orderId)
  128. },
  129. fail() {
  130. payIng = false
  131. _this.close()
  132. }
  133. })
  134. } else {
  135. payIng = false
  136. _this.close()
  137. uni.$u.toast('支付失败!');
  138. }
  139. }).catch(() => {
  140. payIng = false
  141. _this.close()
  142. uni.$u.toast('支付失败!');
  143. })
  144. } else {
  145. uni.showToast({
  146. title: '支付成功',
  147. icon: 'success',
  148. duration: 2000
  149. })
  150. _this.success(res.data.orderId)
  151. }
  152. } else if (res.code == 1020) {
  153. payIng = false
  154. _this.close()
  155. uni.$u.toast(res.msg);
  156. } else {
  157. payIng = false
  158. _this.close()
  159. uni.$u.toast(res.msg);
  160. }
  161. }).catch(() => {
  162. uni.hideLoading();
  163. payIng = false
  164. uni.$u.toast('支付失败!');
  165. })
  166. },
  167. },
  168. }
  169. </script>
  170. <style lang="scss" scoped>
  171. .coupon-right-color{
  172. font-size: 32rpx;
  173. line-height: 44rpx;
  174. color: rgba(235, 112, 9, 100);
  175. }
  176. </style>
  177. <style lang="scss" scoped>
  178. .choiceShow-wrap {
  179. min-height: 400rpx;
  180. padding: 34rpx;
  181. // 盲票信息
  182. .goods {
  183. justify-content: flex-start;
  184. margin-bottom: 60rpx;
  185. .image-wrap {
  186. width: 220rpx;
  187. height: 220rpx;
  188. border-radius: 10rpx;
  189. overflow: hidden;
  190. image {
  191. width: 100%;
  192. height: 100%;
  193. }
  194. }
  195. .info {
  196. flex: 1;
  197. display: flex;
  198. height: 220rpx;
  199. flex-direction: column;
  200. justify-content: space-around;
  201. padding-left: 34rpx;
  202. &-title {
  203. font-size: 36rpx;
  204. line-height: 36rpx;
  205. font-weight: bold;
  206. }
  207. &-stock {
  208. font-size: 26rpx;
  209. color: #FF4208;
  210. }
  211. }
  212. }
  213. // 优惠券
  214. .coupon {
  215. justify-content: space-between;
  216. height: 40rpx;
  217. margin-bottom: 46rpx;
  218. &-left {
  219. image {
  220. width: 48rpx;
  221. height: 40rpx;
  222. margin-right: 18rpx;
  223. }
  224. .txt {
  225. font-size: 30rpx;
  226. font-weight: bold;
  227. }
  228. }
  229. &-right {
  230. height: 40rpx;
  231. image {
  232. width: 12rpx;
  233. height: 22rpx;
  234. margin-left: 14rpx;
  235. }
  236. .txt {
  237. line-height: 26rpx;
  238. font-size: 26rpx;
  239. color: #666666;
  240. }
  241. }
  242. }
  243. // 同意协议
  244. .agreement {
  245. justify-content: flex-start;
  246. margin-bottom: 56rpx;
  247. .txt {
  248. font-size: 26rpx;
  249. color: #666666;
  250. }
  251. }
  252. // 支付按钮
  253. .btn {
  254. justify-content: space-between;
  255. &-left {
  256. .title {
  257. font-size: 13px;
  258. font-weight: 500;
  259. }
  260. .price {
  261. font-size: 30rpx;
  262. font-weight: bold;
  263. color: #FF4208;
  264. }
  265. }
  266. &-right {
  267. .confirm {
  268. width: 200rpx;
  269. height: 72rpx;
  270. line-height: 72rpx;
  271. background: #F9822C;
  272. border-radius: 36rpx;
  273. font-size: 26rpx;
  274. color: #fff;
  275. text-align: center;
  276. }
  277. }
  278. }
  279. }
  280. </style>