index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <view :data-theme="theme">
  3. <view class='payment-status'>
  4. <!--失败时: 用icon-iconfontguanbi fail替换icon-duihao2 bg-color-->
  5. <view class='iconfont icons icon-duihao2 bg_color'
  6. v-if="order_pay_info.paid === 1"></view>
  7. <view v-if="order_pay_info.paid === 2" class='iconfont icons icon-iconfontguanbi'></view>
  8. <!-- 失败时:订单支付失败 -->
  9. <view class='status' v-if="order_pay_info.payType != 'offline'">{{status==2 ? '订单取消支付' : errMsg ? '订单支付异常':payResult }}</view>
  10. <view class='status' v-else>订单创建成功</view>
  11. <view class='wrapper'>
  12. <view v-show="!fromType" class='item acea-row row-between-wrapper'>
  13. <view>订单编号</view>
  14. <view class='itemCom'>{{order_pay_info.orderNo}}</view>
  15. </view>
  16. <view v-show="!fromType" class='item acea-row row-between-wrapper'>
  17. <view>下单时间</view>
  18. <view class='itemCom'>{{order_pay_info.createTime?order_pay_info.createTime:'-'}}</view>
  19. </view>
  20. <view v-show="(order_pay_info.payType && order_pay_info.secondType !== ProductTypeEnum.Integral) || (order_pay_info.secondType === ProductTypeEnum.Integral && order_pay_info.payPrice!=0)" class='item acea-row row-between-wrapper'>
  21. <view>支付方式</view>
  22. <view class='itemCom'>{{order_pay_info.payType | payTypeFilter}}支付</view>
  23. </view>
  24. <view class='item acea-row row-between-wrapper'>
  25. <view>支付金额</view>
  26. <view class='itemCom'>{{order_pay_info.payPrice}}</view>
  27. </view>
  28. <view v-show="order_pay_info.secondType === ProductTypeEnum.Integral" class='item acea-row row-between-wrapper'>
  29. <view>消耗积分</view>
  30. <view class='itemCom'>{{order_pay_info.redeemIntegral}}</view>
  31. </view>
  32. <!--失败时加上这个 -->
  33. <view class='item acea-row row-between-wrapper'
  34. v-if="!order_pay_info.paid && order_pay_info.payType != 'offline'">
  35. <view>失败原因</view>
  36. <view class='itemCom'>{{status==2 ? '取消支付':msg}}</view>
  37. </view>
  38. </view>
  39. <!--失败时: 重新购买 -->
  40. <view @tap="goOrderDetails">
  41. <button formType="submit" class='returnBnt bg_color' hover-class='none'>{{fromType =='svip'?'查看会员':type==2?'查看拼团':'查看订单'}}</button>
  42. </view>
  43. <button @click="goIndex" class='returnBnt cart-color' formType="submit" hover-class='none'
  44. >返回首页</button>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. // +----------------------------------------------------------------------
  50. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  51. // +----------------------------------------------------------------------
  52. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  53. // +----------------------------------------------------------------------
  54. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  55. // +----------------------------------------------------------------------
  56. // | Author: CRMEB Team <admin@crmeb.com>
  57. // +----------------------------------------------------------------------
  58. import {
  59. getOrderDetail,
  60. getExpressOrderDetail,
  61. getSecondHandOrderDetail,
  62. wechatQueryPayResult,
  63. wechatExpressQueryPayResult,
  64. wechatSecondHandQueryPayResult
  65. } from '@/api/order.js';
  66. import {
  67. openOrderSubscribe
  68. } from '@/utils/SubscribeMessage.js';
  69. import {
  70. toLogin
  71. } from '@/libs/login.js';
  72. import {
  73. mapGetters
  74. } from "vuex";
  75. import {
  76. ProductTypeEnum
  77. } from "../../../enums/productEnums";
  78. let app = getApp();
  79. export default {
  80. data() {
  81. return {
  82. ProductTypeEnum:ProductTypeEnum,
  83. orderNo: '',
  84. order_pay_info: {
  85. paid: 0,
  86. _status: {}
  87. },
  88. status: 0,
  89. msg: '',
  90. errMsg: false,
  91. payResult: '订单查询中...',
  92. theme:app.globalData.theme,
  93. fromType: '', // 支付页面来源,会员支付,商品支付,积分支付
  94. apiType: '',
  95. type:'',
  96. };
  97. },
  98. computed: mapGetters(['isLogin']),
  99. watch: {
  100. isLogin: {
  101. handler: function(newV, oldV) {
  102. if (newV) {
  103. this.getOrderPayInfo();
  104. }
  105. },
  106. deep: true
  107. }
  108. },
  109. onLoad: function(options) {
  110. this.fromType = options.fromType
  111. this.orderNo = options.order_id;
  112. this.apiType = options.apiType
  113. console.log(options)
  114. if(!this.fromType || this.fromType==='integral'){
  115. this.status = options.status || 0;
  116. if (this.isLogin) {
  117. this.getOrderPayInfo();
  118. } else {
  119. toLogin();
  120. }
  121. }else{
  122. this.order_pay_info.payType= options.payType
  123. this.order_pay_info.payPrice = options.payPrice
  124. if(options.payType !== 'yue'){
  125. uni.showLoading({
  126. title: '正在加载中'
  127. });
  128. setTimeout(()=>{
  129. this.wechatQueryPay('svip');
  130. },500);
  131. }else{
  132. this.payResult = '支付成功';
  133. this.order_pay_info.paid = 1;
  134. }
  135. };
  136. },
  137. methods: {
  138. //svip支付成功之后更新会员状态
  139. setPaidMember(){
  140. this.$store.commit('updatePaidMember', true);
  141. },
  142. //微信支付查明结果
  143. wechatQueryPay(orderType) {
  144. const api = this.apiType == 'fast' ? wechatExpressQueryPayResult : this.apiType == 'secondHand' ? wechatSecondHandQueryPayResult : wechatQueryPayResult;
  145. api({
  146. orderType: orderType,
  147. orderNo:this.orderNo
  148. }).then(res => {
  149. if(res.data){
  150. this.payResult = '支付成功';
  151. this.order_pay_info.paid = 1;
  152. uni.hideLoading();
  153. this.setPaidMember();
  154. }else{
  155. this.payResult = '支付失败';
  156. this.order_pay_info.paid = 2;
  157. uni.hideLoading();
  158. }
  159. })
  160. .catch(err => {
  161. this.order_pay_info.paid = 2;
  162. this.errMsg = true;
  163. this.msg = err;
  164. uni.hideLoading();
  165. this.$util.Tips({
  166. title: err
  167. });
  168. });
  169. },
  170. onLoadFun: function() {
  171. if(this.fromType !=='svip')this.getOrderPayInfo();
  172. },
  173. /**
  174. *
  175. * 支付完成查询支付状态
  176. *
  177. */
  178. getOrderPayInfo: function() {
  179. let that = this;
  180. uni.showLoading({
  181. title: '正在加载中'
  182. });
  183. const api = that.apiType == 'fast' ? getExpressOrderDetail : that.apiType == 'secondHand' ? getSecondHandOrderDetail : getOrderDetail;
  184. api(that.orderNo).then(res => {
  185. this.type=res.data.type
  186. that.$set(that, 'order_pay_info', res.data);
  187. if (res.data.payType === 'weixin') {
  188. setTimeout(()=>{
  189. that.wechatQueryPay('order');
  190. },2000);
  191. }else {
  192. if(res.data.paid){
  193. this.payResult = '支付成功';
  194. this.order_pay_info.paid = 1;
  195. }else{
  196. this.payResult = '支付失败';
  197. this.order_pay_info.paid = 2;
  198. }
  199. uni.hideLoading();
  200. }
  201. }).catch(err => {
  202. uni.hideLoading();
  203. });
  204. },
  205. /**
  206. * 去首页关闭当前所有页面
  207. */
  208. goIndex: function(e) {
  209. uni.switchTab({
  210. url: '/pages/index/index'
  211. });
  212. },
  213. /**
  214. *
  215. * 去订单详情页面
  216. */
  217. goOrderDetails: function(e) {
  218. if (this.apiType == 'fast') {
  219. uni.navigateTo({
  220. url: '/pages/substitute_fast_mail/my_fast_mail/index'
  221. });
  222. } else {
  223. uni.navigateTo({
  224. url: this.fromType =='svip'?'/pages/activity/vip_paid/index':this.type==2?`/pages/activity/status/index?orderNo=${this.orderNo}`:'/pages/goods/order_list/index'
  225. });
  226. }
  227. }
  228. }
  229. }
  230. </script>
  231. <style lang="scss">
  232. .icon-iconfontguanbi {
  233. background-color: #999 !important;
  234. text-shadow: none !important;
  235. }
  236. .bg_color{
  237. @include main_bg_color(theme);
  238. }
  239. .cart_color{
  240. @include main_color(theme);
  241. @include coupons_border_color(theme);
  242. }
  243. .payment-status {
  244. background-color: #fff;
  245. margin: 195rpx 30rpx 0 30rpx;
  246. border-radius: 10rpx;
  247. padding: 1rpx 0 28rpx 0;
  248. }
  249. .payment-status .icons {
  250. font-size: 70rpx;
  251. width: 140rpx;
  252. height: 140rpx;
  253. border-radius: 50%;
  254. color: #fff;
  255. text-align: center;
  256. line-height: 140rpx;
  257. text-shadow: 0px 4px 0px rgba(0,0,0,.1);
  258. border: 6rpx solid #f5f5f5;
  259. margin: -76rpx auto 0 auto;
  260. background-color: #999;
  261. }
  262. .payment-status .iconfont {
  263. font-size: 70rpx;
  264. width: 140rpx;
  265. height: 140rpx;
  266. border-radius: 50%;
  267. color: #fff;
  268. text-align: center;
  269. line-height: 140rpx;
  270. text-shadow: 0px 4px 0px rgba(0,0,0,.1);
  271. border: 6rpx solid #f5f5f5;
  272. margin: -76rpx auto 0 auto;
  273. background-color: #999;
  274. }
  275. .payment-status .iconfont.fail {
  276. text-shadow: 0px 4px 0px #7a7a7a;
  277. }
  278. .payment-status .status {
  279. font-size: 32rpx;
  280. font-weight: bold;
  281. text-align: center;
  282. margin: 25rpx 0 37rpx 0;
  283. }
  284. .payment-status .wrapper {
  285. border: 1rpx solid #eee;
  286. margin: 0 30rpx 47rpx 30rpx;
  287. padding: 35rpx 0;
  288. border-left: 0;
  289. border-right: 0;
  290. }
  291. .payment-status .wrapper .item {
  292. font-size: 28rpx;
  293. color: #282828;
  294. }
  295. .payment-status .wrapper .item~.item {
  296. margin-top: 20rpx;
  297. }
  298. .payment-status .wrapper .item .itemCom {
  299. color: #666;
  300. }
  301. .payment-status .returnBnt {
  302. width: 630rpx;
  303. height: 86rpx;
  304. border-radius: 50rpx;
  305. color: #fff;
  306. font-size: 30rpx;
  307. text-align: center;
  308. line-height: 86rpx;
  309. margin: 0 auto 20rpx auto;
  310. }
  311. .cart-color {
  312. @include main_color(theme);
  313. @include coupons_border_color(theme);
  314. }
  315. </style>