index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <view>
  3. <view class='payment-status'>
  4. <!-- 支付状态 -->
  5. <view class='iconfont icons icon-duihao2 bg-color' v-if="order_pay_info.payStatus" />
  6. <view class='iconfont icons icon-iconfontguanbi' v-else />
  7. <view class='status'>{{order_pay_info.payStatus ? '订单支付成功':'订单支付失败'}}</view>
  8. <!-- 基本信息 -->
  9. <view class='wrapper'>
  10. <view class='item acea-row row-between-wrapper'>
  11. <view>订单编号</view>
  12. <view class='itemCom'>{{order_pay_info.no}}</view>
  13. </view>
  14. <view class='item acea-row row-between-wrapper'>
  15. <view>下单时间</view>
  16. <view class='itemCom'>{{ order_pay_info.createTime ? formatDate(order_pay_info.createTime) : '-' }}</view>
  17. </view>
  18. <view class='item acea-row row-between-wrapper' v-if="order_pay_info.payStatus">
  19. <view>支付方式</view>
  20. <view class='itemCom'>{{ order_pay_info.payChannelName }}</view>
  21. </view>
  22. <view class='item acea-row row-between-wrapper'>
  23. <view>支付金额</view>
  24. <view class='itemCom'>{{ fen2yuan(order_pay_info.payPrice) }}</view>
  25. </view>
  26. <!-- 失败时加上这个 -->
  27. <view class='item acea-row row-between-wrapper' v-if="!order_pay_info.payStatus">
  28. <view>失败原因</view>
  29. <view class='itemCom' v-if="payResult === 'success'">获取支付结果失败,请稍后刷新</view> <!-- 一般情况下,是支付中心回调更新订单为已支付,存在延迟 -->
  30. <view class='itemCom' v-else-if="payResult === 'close'">支付已关闭</view>
  31. <view class='itemCom' v-else-if="payResult === 'cancel'">取消支付</view>
  32. <view class='itemCom' v-else>未知原因</view>
  33. </view>
  34. </view>
  35. <!-- 操作区 -->
  36. <view @tap="goOrderDetails">
  37. <button formType="submit" class='returnBnt bg-color' hover-class='none'>
  38. 查看订单
  39. </button>
  40. </view>
  41. <!-- TODO 芋艿:拼团 -->
  42. <button @click="goPink(order_pay_info.pinkId)" class='returnBnt cart-color' formType="submit" hover-class='none'
  43. v-if="order_pay_info.pinkId && order_pay_info.payStatus">
  44. 邀请好友参团
  45. </button>
  46. <button @click="goIndex" class='returnBnt cart-color' formType="submit" hover-class='none' v-else>
  47. 返回首页
  48. </button>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import * as OrderApi from '@/api/trade/order.js';
  54. import { openOrderSubscribe } from '@/utils/SubscribeMessage.js';
  55. import { toLogin } from '@/libs/login.js';
  56. import { mapGetters } from "vuex";
  57. import dayjs from '@/plugin/dayjs/dayjs.min.js';
  58. import * as Util from '@/utils/util.js';
  59. export default {
  60. data() {
  61. return {
  62. orderId: '',
  63. order_pay_info: {
  64. payStatus: true,
  65. },
  66. status: 0,
  67. payResult: ''
  68. };
  69. },
  70. computed: mapGetters(['isLogin']),
  71. watch:{
  72. isLogin:{
  73. handler:function(newV, oldV) {
  74. if (newV) {
  75. this.getOrderPayInfo();
  76. }
  77. },
  78. deep:true
  79. }
  80. },
  81. onLoad: function(options) {
  82. if (!this.isLogin) {
  83. toLogin();
  84. return
  85. }
  86. if (!options.order_id) {
  87. return this.$util.Tips({
  88. title: '缺少参数无法查看订单支付状态'
  89. }, {
  90. tab: 3,
  91. url: 1
  92. });
  93. }
  94. this.orderId = options.order_id;
  95. this.payResult = options.payResult;
  96. this.getOrderPayInfo();
  97. },
  98. methods: {
  99. /**
  100. * 支付完成查询支付状态
  101. */
  102. getOrderPayInfo: function() {
  103. uni.showLoading({
  104. title: '正在加载中'
  105. });
  106. OrderApi.getOrderDetail(this.orderId).then(res => {
  107. uni.hideLoading();
  108. this.$set(this, 'order_pay_info', res.data);
  109. uni.setNavigationBarTitle({
  110. title: res.data.payStatus ? '支付成功' : '支付失败'
  111. });
  112. }).catch(err => {
  113. uni.hideLoading();
  114. });
  115. },
  116. /**
  117. * 去订单详情页面
  118. */
  119. goOrderDetails: function() {
  120. // #ifdef MP
  121. uni.showLoading({
  122. title: '正在加载',
  123. })
  124. openOrderSubscribe().then(res => {
  125. uni.hideLoading();
  126. uni.navigateTo({
  127. url: '/pages/order_details/index?order_id=' + this.orderId
  128. });
  129. }).catch(() => {
  130. nui.hideLoading();
  131. });
  132. // #endif
  133. // #ifndef MP
  134. uni.navigateTo({
  135. url: '/pages/order_details/index?order_id=' + this.orderId
  136. })
  137. // #endif
  138. },
  139. /**
  140. * 去首页关闭当前所有页面
  141. */
  142. goIndex: function(e) {
  143. uni.switchTab({
  144. url: '/pages/index/index'
  145. });
  146. },
  147. /**
  148. * 去参团页面
  149. */
  150. goPink: function(id) {
  151. uni.navigateTo({
  152. url: '/pages/activity/goods_combination_status/index?id=' + id
  153. });
  154. },
  155. fen2yuan(price) {
  156. return Util.fen2yuan(price)
  157. },
  158. formatDate: function(date) {
  159. return dayjs(date).format("YYYY-MM-DD HH:mm:ss");
  160. }
  161. }
  162. }
  163. </script>
  164. <style>
  165. .icon-iconfontguanbi{
  166. background-color: #999 !important;
  167. text-shadow: none !important;
  168. }
  169. .payment-status {
  170. background-color: #fff;
  171. margin: 195rpx 30rpx 0 30rpx;
  172. border-radius: 10rpx;
  173. padding: 1rpx 0 28rpx 0;
  174. }
  175. .payment-status .icons {
  176. font-size: 70rpx;
  177. width: 140rpx;
  178. height: 140rpx;
  179. border-radius: 50%;
  180. color: #fff;
  181. text-align: center;
  182. line-height: 140rpx;
  183. text-shadow: 0px 4px 0px #df1e14;
  184. border: 6rpx solid #f5f5f5;
  185. margin: -76rpx auto 0 auto;
  186. background-color: #999;
  187. }
  188. .payment-status .iconfont {
  189. font-size: 70rpx;
  190. width: 140rpx;
  191. height: 140rpx;
  192. border-radius: 50%;
  193. color: #fff;
  194. text-align: center;
  195. line-height: 140rpx;
  196. text-shadow: 0px 4px 0px #df1e14;
  197. border: 6rpx solid #f5f5f5;
  198. margin: -76rpx auto 0 auto;
  199. background-color: #999;
  200. }
  201. .payment-status .iconfont.fail {
  202. text-shadow: 0px 4px 0px #7a7a7a;
  203. }
  204. .payment-status .status {
  205. font-size: 32rpx;
  206. font-weight: bold;
  207. text-align: center;
  208. margin: 25rpx 0 37rpx 0;
  209. }
  210. .payment-status .wrapper {
  211. border: 1rpx solid #eee;
  212. margin: 0 30rpx 47rpx 30rpx;
  213. padding: 35rpx 0;
  214. border-left: 0;
  215. border-right: 0;
  216. }
  217. .payment-status .wrapper .item {
  218. font-size: 28rpx;
  219. color: #282828;
  220. }
  221. .payment-status .wrapper .item~.item {
  222. margin-top: 20rpx;
  223. }
  224. .payment-status .wrapper .item .itemCom {
  225. color: #666;
  226. }
  227. .payment-status .returnBnt {
  228. width: 630rpx;
  229. height: 86rpx;
  230. border-radius: 50rpx;
  231. color: #fff;
  232. font-size: 30rpx;
  233. text-align: center;
  234. line-height: 86rpx;
  235. margin: 0 auto 20rpx auto;
  236. }
  237. </style>