pay-popup.vue 6.5 KB

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