pay-popup.vue 6.7 KB

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