pay-popup.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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/public/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/public/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. <auth :auth-show="authShow" @close="authShow = false" />
  49. </view>
  50. </template>
  51. <script>
  52. import $http from '@/utils/request.js'
  53. import Auth from '../../components/auth/auth.vue'
  54. export default {
  55. name: "pay-popup",
  56. components: {
  57. Auth
  58. },
  59. props: {
  60. payShow: {
  61. type: [Boolean],
  62. default: false
  63. },
  64. payInfo: {
  65. type: [Object],
  66. default: {}
  67. }
  68. },
  69. data() {
  70. return {
  71. checked: true,
  72. authShow: false,
  73. };
  74. },
  75. methods: {
  76. changeChecked(e) {
  77. this.checked = e
  78. },
  79. toCoupon() {
  80. uni.navigateTo({
  81. url: `/packageGoods/coupon/index?couponId=${ this.payInfo.couponId }&boxId=${ this.payInfo.boxId }&ticketId=${ this.payInfo.ticketId }`
  82. })
  83. },
  84. toRule() {
  85. uni.navigateTo({
  86. url: '/packageOther/rule/index'
  87. })
  88. },
  89. close() {
  90. this.$emit('close')
  91. },
  92. success(id) {
  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', {
  107. suid: uni.getStorageSync('shareUid'),
  108. type: uni.getStorageSync('shareType')
  109. }).then(res => {
  110. uni.hideLoading();
  111. payIng = true
  112. if (res.code == 0) {
  113. if (res.data.needPay == 1) {
  114. $http.post('/api/v1/mp/user/ticket/order/pay', {
  115. orderId: res.data.orderId,
  116. payType: 2
  117. }).then(ele => {
  118. if (ele.code == 0) {
  119. uni.requestPayment({
  120. timeStamp: ele.data.timeStamp,
  121. nonceStr: ele.data.nonceStr,
  122. package: ele.data.package,
  123. signType: ele.data.signType,
  124. paySign: ele.data.paySign,
  125. success() {
  126. uni.showToast({
  127. title: '支付成功',
  128. icon: 'success',
  129. duration: 2000
  130. })
  131. _this.success(res.data.orderId)
  132. },
  133. fail() {
  134. payIng = false
  135. _this.close()
  136. }
  137. })
  138. } else if (ele.code == 1005) {
  139. _this.authShow = true
  140. } else {
  141. payIng = false
  142. _this.close()
  143. uni.$u.toast('支付失败!');
  144. }
  145. }).catch(() => {
  146. payIng = false
  147. _this.close()
  148. uni.$u.toast('支付失败!');
  149. })
  150. } else {
  151. uni.showToast({
  152. title: '支付成功',
  153. icon: 'success',
  154. duration: 2000
  155. })
  156. _this.success(res.data.orderId)
  157. }
  158. } else if (res.code == 1020) {
  159. payIng = false
  160. _this.close()
  161. uni.$u.toast(res.msg);
  162. } else {
  163. payIng = false
  164. _this.close()
  165. uni.$u.toast(res.msg);
  166. }
  167. }).catch(() => {
  168. uni.hideLoading();
  169. payIng = false
  170. uni.$u.toast('支付失败!');
  171. })
  172. },
  173. },
  174. }
  175. </script>
  176. <style lang="scss" scoped>
  177. .coupon-right-color{
  178. font-size: 32rpx;
  179. line-height: 44rpx;
  180. color: rgba(235, 112, 9, 100);
  181. }
  182. </style>
  183. <style lang="scss" scoped>
  184. .choiceShow-wrap {
  185. min-height: 400rpx;
  186. padding: 34rpx;
  187. // 盲票信息
  188. .goods {
  189. justify-content: flex-start;
  190. margin-bottom: 60rpx;
  191. .image-wrap {
  192. width: 220rpx;
  193. height: 220rpx;
  194. border-radius: 10rpx;
  195. overflow: hidden;
  196. image {
  197. width: 100%;
  198. height: 100%;
  199. }
  200. }
  201. .info {
  202. flex: 1;
  203. display: flex;
  204. height: 220rpx;
  205. flex-direction: column;
  206. justify-content: space-around;
  207. padding-left: 34rpx;
  208. &-title {
  209. font-size: 36rpx;
  210. line-height: 36rpx;
  211. font-weight: bold;
  212. }
  213. &-stock {
  214. font-size: 26rpx;
  215. color: #FF4208;
  216. }
  217. }
  218. }
  219. // 优惠券
  220. .coupon {
  221. justify-content: space-between;
  222. height: 40rpx;
  223. margin-bottom: 46rpx;
  224. &-left {
  225. image {
  226. width: 48rpx;
  227. height: 40rpx;
  228. margin-right: 18rpx;
  229. }
  230. .txt {
  231. font-size: 30rpx;
  232. font-weight: bold;
  233. }
  234. }
  235. &-right {
  236. height: 40rpx;
  237. image {
  238. width: 12rpx;
  239. height: 22rpx;
  240. margin-left: 14rpx;
  241. }
  242. .txt {
  243. line-height: 26rpx;
  244. font-size: 26rpx;
  245. color: #666666;
  246. }
  247. }
  248. }
  249. // 同意协议
  250. .agreement {
  251. justify-content: flex-start;
  252. margin-bottom: 56rpx;
  253. .txt {
  254. font-size: 26rpx;
  255. color: #666666;
  256. }
  257. }
  258. // 支付按钮
  259. .btn {
  260. justify-content: space-between;
  261. &-left {
  262. .title {
  263. font-size: 13px;
  264. font-weight: 500;
  265. }
  266. .price {
  267. font-size: 30rpx;
  268. font-weight: bold;
  269. color: #FF4208;
  270. }
  271. }
  272. &-right {
  273. .confirm {
  274. width: 414rpx;
  275. height: 88rpx;
  276. line-height: 88rpx;
  277. background: #FA822C;
  278. border-radius: 44rpx;
  279. font-size: 36rpx;
  280. color: #fff;
  281. text-align: center;
  282. }
  283. }
  284. }
  285. }
  286. </style>