index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <view>
  3. <view class='payment-status'>
  4. <!--失败时: 用icon-iconfontguanbi fail替换icon-duihao2 bg-color-->
  5. <view class='iconfont icon-duihao2 bg-color' v-if="order_pay_info.paid || order_pay_info.pay_type == 'offline'">
  6. <image src="../../static/images/duihao.png"></image>
  7. </view>
  8. <view class='iconfont icon-iconfontguanbi bg-color' v-else>
  9. <image src="../../static/images/guanbi.png"></image>
  10. </view>
  11. <!-- 失败时:订单支付失败 -->
  12. <view class='status' v-if="order_pay_info.pay_type != 'offline'">{{order_pay_info.paid ? '订单支付成功':'订单支付失败'}}</view>
  13. <view class='status' v-else>订单创建成功</view>
  14. <view class='wrapper'>
  15. <view class='item acea-row row-between-wrapper'>
  16. <view>订单编号</view>
  17. <view class='itemCom'>{{orderId}}</view>
  18. </view>
  19. <view class='item acea-row row-between-wrapper'>
  20. <view>下单时间</view>
  21. <view class='itemCom'>{{order_pay_info._pay_time}}</view>
  22. </view>
  23. <view class='item acea-row row-between-wrapper'>
  24. <view>支付方式</view>
  25. <view class='itemCom'>{{order_pay_info._status._payType}}</view>
  26. </view>
  27. <view class='item acea-row row-between-wrapper'>
  28. <view>支付金额</view>
  29. <view class='itemCom'>{{order_pay_info.pay_price}}</view>
  30. </view>
  31. <!--失败时加上这个 -->
  32. <view class='item acea-row row-between-wrapper' v-if="order_pay_info.paid==0 && order_pay_info.pay_type != 'offline'">
  33. <view>失败原因</view>
  34. <view class='itemCom'>{{status==2 ? '取消支付':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'>查看订单</button>
  40. </view>
  41. <view @tap="goOrderDetails" v-if="order_pay_info.paid==0 && status==1">
  42. <button class='returnBnt bg-color' hover-class='none'>重新购买</button>
  43. </view>
  44. <view @tap="goOrderDetails" v-if="order_pay_info.paid==0 && status==2">
  45. <button class='returnBnt bg-color' hover-class='none'>重新支付</button>
  46. </view>
  47. <button @click="goPink(order_pay_info.pink_id)" class='returnBnt cart-color' formType="submit" hover-class='none' v-if="order_pay_info.pink_id && order_pay_info.paid!=0 && status!=2 && status!=1">邀请好友参团</button>
  48. <button @click="goIndex" class='returnBnt cart-color' formType="submit" hover-class='none' v-else>返回首页</button>
  49. </view>
  50. <!-- #ifdef MP -->
  51. <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize>
  52. <!-- #endif -->
  53. </view>
  54. </template>
  55. <script>
  56. import {
  57. orderDetail
  58. } from '@/api/order.js';
  59. import {
  60. openOrderSubscribe
  61. } from '@/utils/SubscribeMessage.js';
  62. import {
  63. toLogin
  64. } from '@/libs/login.js';
  65. import {
  66. mapState
  67. } from "vuex";
  68. // #ifdef MP
  69. import authorize from '@/components/Authorize';
  70. // #endif
  71. export default {
  72. components: {
  73. // #ifdef MP
  74. authorize
  75. // #endif
  76. },
  77. data() {
  78. return {
  79. orderId: '',
  80. order_pay_info: {
  81. paid: 1,
  82. _status: {}
  83. },
  84. isAuto: false, //没有授权的不会自动授权
  85. isShowAuth: false ,//是否隐藏授权
  86. status:0,
  87. msg:''
  88. };
  89. },
  90. computed: {
  91. ...mapState(['hasLogin'])
  92. },
  93. onLoad: function(options) {
  94. if (!options.order_id){
  95. uni.showToast({
  96. title:"缺少参数无法查看订单支付状态"
  97. })
  98. };
  99. this.orderId = options.order_id;
  100. this.status = options.status || 0;
  101. this.msg = options.msg || '';
  102. if (this.hasLogin) {
  103. this.getOrderPayInfo();
  104. } else {
  105. // #ifdef H5 || APP-PLUS
  106. toLogin();
  107. // #endif
  108. // #ifdef MP
  109. this.isAuto = true;
  110. this.$set(this, 'isShowAuth', true);
  111. // #endif
  112. }
  113. },
  114. methods: {
  115. onLoadFun: function() {
  116. this.getOrderPayInfo();
  117. },
  118. /**
  119. *
  120. * 支付完成查询支付状态
  121. *
  122. */
  123. getOrderPayInfo: function() {
  124. let that = this;
  125. uni.showLoading({
  126. title: '正在加载中'
  127. });
  128. orderDetail({},that.orderId).then(res => {
  129. uni.hideLoading();
  130. that.$set(that, 'order_pay_info', res.data);
  131. uni.setNavigationBarTitle({
  132. title: res.data.paid ? '支付成功' : '支付失败'
  133. });
  134. }).catch(err => {
  135. uni.hideLoading();
  136. });
  137. },
  138. /**
  139. * 去首页关闭当前所有页面
  140. */
  141. goIndex: function(e) {
  142. uni.switchTab({
  143. url: '/pages/index/index'
  144. });
  145. },
  146. // 去参团页面;
  147. goPink:function(id){
  148. uni.navigateTo({
  149. url: '/pages/activity/goods_combination_status/index?id='+id
  150. });
  151. },
  152. /**
  153. *
  154. * 去订单详情页面
  155. */
  156. goOrderDetails: function(e) {
  157. let that = this;
  158. // #ifdef MP
  159. uni.showLoading({
  160. title: '正在加载',
  161. })
  162. openOrderSubscribe().then(res => {
  163. uni.hideLoading();
  164. uni.navigateTo({
  165. url: '/pages/order_details/index?order_id=' + that.orderId
  166. });
  167. }).catch(() => {
  168. nui.hideLoading();
  169. });
  170. // #endif
  171. // #ifndef MP
  172. uni.navigateTo({
  173. url: '/pages/order_details/index?order_id=' + that.orderId
  174. })
  175. // #endif
  176. }
  177. }
  178. }
  179. </script>
  180. <style lang="scss">
  181. .payment-status {
  182. background-color: #fff;
  183. margin: 195rpx 30rpx 0 30rpx;
  184. border-radius: 10rpx;
  185. padding: 1rpx 0 28rpx 0;
  186. }
  187. .payment-status .iconfont {
  188. font-size: 70rpx;
  189. width: 140rpx;
  190. height: 140rpx;
  191. border-radius: 50%;
  192. color: #fff;
  193. text-align: center;
  194. // line-height: 140rpx;
  195. text-shadow: 0px 4px 0px #df1e14;
  196. border: 6rpx solid #f5f5f5;
  197. margin: -76rpx auto 0 auto;
  198. background-color: #999;
  199. image{
  200. margin-top: 35rpx;
  201. width: 70rpx;
  202. height: 70rpx;
  203. }
  204. }
  205. .payment-status .iconfont.fail {
  206. text-shadow: 0px 4px 0px #7a7a7a;
  207. }
  208. .payment-status .status {
  209. font-size: 32rpx;
  210. font-weight: bold;
  211. text-align: center;
  212. margin: 25rpx 0 37rpx 0;
  213. }
  214. .payment-status .wrapper {
  215. border: 1rpx solid #eee;
  216. margin: 0 30rpx 47rpx 30rpx;
  217. padding: 35rpx 0;
  218. border-left: 0;
  219. border-right: 0;
  220. }
  221. .payment-status .wrapper .item {
  222. font-size: 28rpx;
  223. color: #282828;
  224. }
  225. .payment-status .wrapper .item~.item {
  226. margin-top: 20rpx;
  227. }
  228. .payment-status .wrapper .item .itemCom {
  229. color: #666;
  230. }
  231. .payment-status .returnBnt {
  232. width: 630rpx;
  233. height: 86rpx;
  234. border-radius: 50rpx;
  235. color: #fff;
  236. font-size: 30rpx;
  237. text-align: center;
  238. line-height: 86rpx;
  239. margin: 0 auto 20rpx auto;
  240. }
  241. </style>