pay-popup.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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">¥{{ $numberFormat( payInfo.salePrice ) }}</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">{{}}</view>
  21. <u-icon name="arrow-right" size="16" color="#333"></u-icon>
  22. </view>
  23. </view>
  24. <view class="flex agreement">
  25. <view class="txt" @click="toRule">同意<text>《盲票购买协议》</text></view>
  26. <view class="checked">
  27. <u-checkbox-group>
  28. <u-checkbox :value="checked" :checked="checked" size="24" shape="circle"
  29. activeColor="#E96737" @change="changeChecked"></u-checkbox>
  30. </u-checkbox-group>
  31. </view>
  32. </view>
  33. <view class="flex btn">
  34. <view class="flex btn-left">
  35. <view class="title">应付:</view>
  36. <view class="flex coin">¥{{ $numberFormat(payInfo.payAmt) }}</view>
  37. </view>
  38. <view class="btn-right">
  39. <view class="confirm" @click="pay">立即支付</view>
  40. </view>
  41. </view>
  42. </view>
  43. </u-popup>
  44. </view>
  45. </template>
  46. <script>
  47. import $http from '@/utils/request.js'
  48. export default {
  49. name: "pay-popup",
  50. props: {
  51. payShow: {
  52. type: [Boolean],
  53. default: false
  54. },
  55. payInfo: {
  56. type: [Object],
  57. default: {}
  58. }
  59. },
  60. data() {
  61. return {
  62. checked: false,
  63. couponIds: [],
  64. autoCoupon: 1,
  65. couponTitle: '',
  66. };
  67. },
  68. methods: {
  69. changeChecked(e) {
  70. this.checked = e
  71. },
  72. toCoupon() {
  73. // return
  74. console.log(this.payInfo+"11111111111111111111")
  75. uni.navigateTo({
  76. url: '/pages/coupon/index'
  77. })
  78. },
  79. toNotice() {
  80. uni.navigateTo({
  81. url: '/pages/about/notice'
  82. })
  83. },
  84. toRule() {
  85. uni.navigateTo({
  86. url: '/pages/about/rule'
  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 {
  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.close()
  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('支付失败!');
  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. .choiceShow-wrap {
  178. min-height: 400rpx;
  179. padding: 80rpx 0 60rpx;
  180. .goods {
  181. padding: 0 20rpx;
  182. justify-content: space-between;
  183. margin-bottom: 20rpx;
  184. .image-wrap {
  185. width: 220rpx;
  186. height: 220rpx;
  187. border: 1px solid #F8F8F8;
  188. border-radius: 10rpx;
  189. image {
  190. width: 174rpx;
  191. height: 174rpx;
  192. }
  193. }
  194. .info {
  195. flex: 1;
  196. display: flex;
  197. height: 220rpx;
  198. flex-direction: column;
  199. justify-content: space-between;
  200. padding-left: 26rpx;
  201. &-title {
  202. font-size: 32rpx;
  203. line-height: 44rpx;
  204. font-weight: bold;
  205. }
  206. &-coin {
  207. display: flex;
  208. align-items: center;
  209. font-size: 32rpx;
  210. line-height: 44rpx;
  211. color: rgba(235, 112, 9, 100);
  212. font-weight: bold;
  213. image {
  214. width: 42rpx;
  215. height: 42rpx;
  216. margin-right: 20rpx;
  217. }
  218. }
  219. &-stock {
  220. line-height: 44rpx;
  221. }
  222. }
  223. }
  224. .coupon {
  225. box-sizing: border-box;
  226. height: 110rpx;
  227. line-height: 110rpx;
  228. justify-content: space-between;
  229. padding: 0 40rpx;
  230. border-top: 1px solid #F8F8F8;
  231. border-bottom: 1px solid #F8F8F8;
  232. .txt {
  233. margin: 0 24rpx;
  234. }
  235. }
  236. .agreement {
  237. box-sizing: border-box;
  238. height: 110rpx;
  239. line-height: 110rpx;
  240. justify-content: space-between;
  241. padding: 0 40rpx;
  242. border-bottom: 1px solid #F8F8F8;
  243. .txt text {
  244. color: #007aff;
  245. }
  246. }
  247. .btn {
  248. justify-content: space-between;
  249. padding: 20rpx 40rpx;
  250. &-left {
  251. .coin {
  252. display: flex;
  253. align-items: center;
  254. font-size: 32rpx;
  255. line-height: 44rpx;
  256. color: rgba(235, 112, 9, 100);
  257. margin-left: 20rpx;
  258. }
  259. }
  260. &-right {
  261. .confirm {
  262. width: 280rpx;
  263. height: 90rpx;
  264. font-size: 36rpx;
  265. line-height: 90rpx;
  266. border-radius: 10rpx;
  267. background-color: rgba(235, 112, 9, 100);
  268. color: rgba(255, 255, 255, 100);
  269. text-align: center;
  270. }
  271. }
  272. }
  273. }
  274. </style>