paySuccess.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <template>
  2. <view :style="colorStyle">
  3. <view class='payment-status' v-if="order_pay_info.paid && loading">
  4. <!--失败时: 用icon-iconfontguanbi fail替换icon-duihao2 bg-color-->
  5. <view class='iconfont icons icon-duihao2 bg-color'
  6. v-if="order_pay_info.paid || order_pay_info.pay_type == 'offline'"></view>
  7. <view class='iconfont icons icon-iconfontguanbi' v-else></view>
  8. <!-- 失败时:订单支付失败 -->
  9. <view class='status' v-if="order_pay_info.pay_type != 'offline'">
  10. {{order_pay_info.paid ? $t(`订单支付成功`):$t(payType ? `订单支付中`:`订单支付失败`)}}
  11. </view>
  12. <view class='status' v-else>{{$t(`订单创建成功`)}}</view>
  13. <view class='wrapper'>
  14. <view class='item acea-row row-between-wrapper'>
  15. <view>{{$t(`订单号`)}}</view>
  16. <view class='itemCom'>{{orderId}}</view>
  17. </view>
  18. <view class='item acea-row row-between-wrapper'>
  19. <view>{{$t(`下单时间`)}}</view>
  20. <view class='itemCom'>{{order_pay_info.add_time}}</view>
  21. </view>
  22. <view class='item acea-row row-between-wrapper'>
  23. <view>{{$t(`支付方式`)}}</view>
  24. <view class='itemCom'>{{$t(order_pay_info._payType) || $t(`暂未支付`)}}</view>
  25. </view>
  26. <view class='item acea-row row-between-wrapper'>
  27. <view>{{$t(`支付金额`)}}</view>
  28. <view class='itemCom'>{{order_pay_info.pay_price}}</view>
  29. </view>
  30. <!--失败时加上这个 -->
  31. <view class='item acea-row row-between-wrapper'
  32. v-if="order_pay_info.paid==0 && order_pay_info.pay_type != 'offline'">
  33. <view>{{$t(`失败原因`)}}</view>
  34. <view class='itemCom'>{{status==2 ? $t(`取消支付`):msg}}</view>
  35. </view>
  36. </view>
  37. <!--失败时: 重新购买 -->
  38. <view @tap="goOrderDetails" v-if="status==0">
  39. <button formType="submit" class='returnBnt bg-color' hover-class='none'>{{$t(`查看订单`)}}</button>
  40. </view>
  41. <view @tap="getOrderPayInfo" v-if="payType == 'ALLINPAY_PAY'">
  42. <button class='returnBnt bg-color' hover-class='none'>{{$t(`刷新支付状态`)}}</button>
  43. </view>
  44. <view @tap="goOrderDetails" v-if="order_pay_info.paid==0 && status==1">
  45. <button class='returnBnt bg-color' hover-class='none'>{{$t(`重新购买`)}}</button>
  46. </view>
  47. <view @tap="goOrderDetails" v-if="order_pay_info.paid==0 && status==2">
  48. <button class='returnBnt bg-color' hover-class='none'>{{$t(`重新支付`)}}</button>
  49. </view>
  50. <button @click="goIndex" class='returnBnt cart-color' formType="submit" hover-class='none'
  51. v-else>{{$t(`返回首页`)}}</button>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. import {
  57. getOrderStatus,
  58. } from '@/api/rent.js';
  59. import {
  60. openOrderSubscribe
  61. } from '@/utils/SubscribeMessage.js';
  62. import {
  63. toLogin
  64. } from '@/libs/login.js';
  65. import {
  66. mapGetters
  67. } from "vuex";
  68. // #ifdef MP
  69. import authorize from '@/components/Authorize';
  70. // #endif
  71. import colors from "@/mixins/color";
  72. export default {
  73. components: {
  74. // #ifdef MP
  75. authorize
  76. // #endif
  77. },
  78. mixins: [colors],
  79. data() {
  80. return {
  81. loading: false,
  82. orderId: '',
  83. order_pay_info: {
  84. paid: 1,
  85. _status: {}
  86. },
  87. status: 0,
  88. msg: '',
  89. payType: ''
  90. };
  91. },
  92. computed: mapGetters(['isLogin']),
  93. watch: {
  94. isLogin: {
  95. handler: function(newV, oldV) {
  96. if (newV) {
  97. this.getOrderPayInfo();
  98. }
  99. },
  100. deep: true
  101. }
  102. },
  103. onLoad: function(options) {
  104. if (!options.order_id) return this.$util.Tips({
  105. title: this.$t(`缺少参数无法查看订单支付状态`)
  106. }, {
  107. tab: 3,
  108. url: 1
  109. });
  110. this.orderId = options.order_id;
  111. this.status = options.status || 0;
  112. this.msg = options.msg || '';
  113. this.payType = options.payType || '';
  114. // // #ifdef H5
  115. // document.addEventListener('visibilitychange', (e) => {
  116. // let state = document.visibilityState
  117. // if (state == 'hidden') {
  118. // console.log('用户离开了');
  119. // }
  120. // if (state == 'visible') {
  121. // this.getOrderPayInfo();
  122. // }
  123. // });
  124. // // #endif
  125. },
  126. onShow() {
  127. if (this.isLogin) {
  128. this.getOrderPayInfo();
  129. } else {
  130. toLogin();
  131. }
  132. },
  133. methods: {
  134. onLoadFun: function() {
  135. this.getOrderPayInfo();
  136. },
  137. /**
  138. *
  139. * 支付完成查询支付状态
  140. *
  141. */
  142. getOrderPayInfo: function() {
  143. let that = this;
  144. uni.showLoading({
  145. title: that.$t(`正在加载中`)
  146. });
  147. getOrderStatus(that.orderId).then(res => {
  148. uni.hideLoading();
  149. that.$set(that, 'order_pay_info', res.data);
  150. uni.setNavigationBarTitle({
  151. title: res.data.paid ? that.$t(`支付成功`) : that.$t(`未支付`)
  152. });
  153. this.loading = true
  154. }).catch(err => {
  155. this.loading = true
  156. uni.hideLoading();
  157. });
  158. },
  159. /**
  160. * 去首页关闭当前所有页面
  161. */
  162. goIndex: function(e) {
  163. uni.switchTab({
  164. url: '/pages/index/index'
  165. });
  166. },
  167. /**
  168. *
  169. * 去订单详情页面
  170. */
  171. goOrderDetails: function(e) {
  172. let that = this;
  173. // #ifdef MP
  174. uni.showLoading({
  175. title: that.$t(`正在加载中`),
  176. })
  177. openOrderSubscribe().then(res => {
  178. uni.hideLoading();
  179. uni.redirectTo({
  180. url: '/pages/rent/order/orderDetail?id=' + that.order_pay_info.rent.order_id
  181. });
  182. }).catch(() => {
  183. nui.hideLoading();
  184. });
  185. // #endif
  186. // #ifndef MP
  187. uni.redirectTo({
  188. url: '/pages/rent/order/orderDetail?id=' + that.order_pay_info.rent.order_id
  189. })
  190. // #endif
  191. }
  192. }
  193. }
  194. </script>
  195. <style lang="scss">
  196. .coupons {
  197. .title {
  198. margin: 30rpx 0 25rpx 0;
  199. .line {
  200. width: 70rpx;
  201. height: 1px;
  202. background: #DCDCDC;
  203. }
  204. .name {
  205. font-size: 24rpx;
  206. color: #999;
  207. margin: 0 10rpx;
  208. }
  209. }
  210. .list {
  211. padding: 0 20rpx;
  212. .item {
  213. margin-bottom: 20rpx;
  214. box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.06);
  215. .price {
  216. width: 236rpx;
  217. height: 160rpx;
  218. font-size: 26rpx;
  219. color: #fff;
  220. font-weight: 800;
  221. text {
  222. font-size: 54rpx;
  223. }
  224. }
  225. .text {
  226. width: 385rpx;
  227. .name {
  228. font-size: #282828;
  229. font-size: 30rpx;
  230. }
  231. .priceMin {
  232. font-size: 24rpx;
  233. color: #999;
  234. margin-top: 10rpx;
  235. }
  236. .time {
  237. font-size: 24rpx;
  238. color: #999;
  239. margin-top: 15rpx;
  240. }
  241. }
  242. }
  243. .open {
  244. font-size: 24rpx;
  245. color: #999;
  246. margin-top: 30rpx;
  247. .iconfont {
  248. font-size: 25rpx;
  249. margin: 5rpx 0 0 10rpx;
  250. }
  251. }
  252. }
  253. }
  254. .payment-status {
  255. background-color: #fff;
  256. margin: 195rpx 30rpx 0 30rpx;
  257. border-radius: 10rpx;
  258. padding: 1rpx 0 28rpx 0;
  259. }
  260. .payment-status .icons {
  261. font-size: 70rpx;
  262. width: 140rpx;
  263. height: 140rpx;
  264. border-radius: 50%;
  265. color: #fff;
  266. text-align: center;
  267. line-height: 140rpx;
  268. text-shadow: 0px 4px 0px rgba(255, 255, 255, 0.5);
  269. border: 6rpx solid #f5f5f5;
  270. margin: -76rpx auto 0 auto;
  271. background-color: #999;
  272. }
  273. .payment-status .icons.icon-iconfontguanbi {
  274. text-shadow: 0px 4px 0px #6c6d6d;
  275. }
  276. .payment-status .iconfont.fail {
  277. text-shadow: 0px 4px 0px #7a7a7a;
  278. }
  279. .payment-status .status {
  280. font-size: 32rpx;
  281. font-weight: bold;
  282. text-align: center;
  283. margin: 25rpx 0 37rpx 0;
  284. }
  285. .payment-status .wrapper {
  286. border: 1rpx solid #eee;
  287. margin: 0 30rpx 47rpx 30rpx;
  288. padding: 35rpx 0;
  289. border-left: 0;
  290. border-right: 0;
  291. }
  292. .payment-status .wrapper .item {
  293. font-size: 28rpx;
  294. color: #282828;
  295. }
  296. .payment-status .wrapper .item~.item {
  297. margin-top: 20rpx;
  298. }
  299. .payment-status .wrapper .item .itemCom {
  300. color: #666;
  301. }
  302. .payment-status .returnBnt {
  303. width: 630rpx;
  304. height: 86rpx;
  305. border-radius: 50rpx;
  306. color: #fff;
  307. font-size: 30rpx;
  308. text-align: center;
  309. line-height: 86rpx;
  310. margin: 0 auto 20rpx auto;
  311. }
  312. </style>