pay-popup.vue 6.5 KB

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