index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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. wechatQueryPayResult,
  62. wechatExpressQueryPayResult
  63. } from '@/api/order.js';
  64. import {
  65. openOrderSubscribe
  66. } from '@/utils/SubscribeMessage.js';
  67. import {
  68. toLogin
  69. } from '@/libs/login.js';
  70. import {
  71. mapGetters
  72. } from "vuex";
  73. import {
  74. ProductTypeEnum
  75. } from "../../../enums/productEnums";
  76. let app = getApp();
  77. export default {
  78. data() {
  79. return {
  80. ProductTypeEnum:ProductTypeEnum,
  81. orderNo: '',
  82. order_pay_info: {
  83. paid: 0,
  84. _status: {}
  85. },
  86. status: 0,
  87. msg: '',
  88. errMsg: false,
  89. payResult: '订单查询中...',
  90. theme:app.globalData.theme,
  91. fromType: '', // 支付页面来源,会员支付,商品支付,积分支付
  92. apiType: '',
  93. type:'',
  94. };
  95. },
  96. computed: mapGetters(['isLogin']),
  97. watch: {
  98. isLogin: {
  99. handler: function(newV, oldV) {
  100. if (newV) {
  101. this.getOrderPayInfo();
  102. }
  103. },
  104. deep: true
  105. }
  106. },
  107. onLoad: function(options) {
  108. this.fromType = options.fromType
  109. this.orderNo = options.order_id;
  110. this.apiType = options.apiType
  111. console.log(options)
  112. if(!this.fromType || this.fromType==='integral'){
  113. this.status = options.status || 0;
  114. if (this.isLogin) {
  115. this.getOrderPayInfo();
  116. } else {
  117. toLogin();
  118. }
  119. }else{
  120. this.order_pay_info.payType= options.payType
  121. this.order_pay_info.payPrice = options.payPrice
  122. if(options.payType !== 'yue'){
  123. uni.showLoading({
  124. title: '正在加载中'
  125. });
  126. setTimeout(()=>{
  127. this.wechatQueryPay('svip');
  128. },500);
  129. }else{
  130. this.payResult = '支付成功';
  131. this.order_pay_info.paid = 1;
  132. }
  133. };
  134. },
  135. methods: {
  136. //svip支付成功之后更新会员状态
  137. setPaidMember(){
  138. this.$store.commit('updatePaidMember', true);
  139. },
  140. //微信支付查明结果
  141. wechatQueryPay(orderType) {
  142. const api = this.apiType == 'fast' ? wechatExpressQueryPayResult : wechatQueryPayResult;
  143. api({
  144. orderType: orderType,
  145. orderNo:this.orderNo
  146. }).then(res => {
  147. if(res.data){
  148. this.payResult = '支付成功';
  149. this.order_pay_info.paid = 1;
  150. uni.hideLoading();
  151. this.setPaidMember();
  152. }else{
  153. this.payResult = '支付失败';
  154. this.order_pay_info.paid = 2;
  155. uni.hideLoading();
  156. }
  157. })
  158. .catch(err => {
  159. this.order_pay_info.paid = 2;
  160. this.errMsg = true;
  161. this.msg = err;
  162. uni.hideLoading();
  163. this.$util.Tips({
  164. title: err
  165. });
  166. });
  167. },
  168. onLoadFun: function() {
  169. if(this.fromType !=='svip')this.getOrderPayInfo();
  170. },
  171. /**
  172. *
  173. * 支付完成查询支付状态
  174. *
  175. */
  176. getOrderPayInfo: function() {
  177. let that = this;
  178. uni.showLoading({
  179. title: '正在加载中'
  180. });
  181. const api = that.apiType == 'fast' ? getExpressOrderDetail(that.orderNo) : getOrderDetail(that.orderNo);
  182. api.then(res => {
  183. this.type=res.data.type
  184. that.$set(that, 'order_pay_info', res.data);
  185. if (res.data.payType === 'weixin') {
  186. setTimeout(()=>{
  187. that.wechatQueryPay('order');
  188. },2000);
  189. }else {
  190. if(res.data.paid){
  191. this.payResult = '支付成功';
  192. this.order_pay_info.paid = 1;
  193. }else{
  194. this.payResult = '支付失败';
  195. this.order_pay_info.paid = 2;
  196. }
  197. uni.hideLoading();
  198. }
  199. }).catch(err => {
  200. uni.hideLoading();
  201. });
  202. },
  203. /**
  204. * 去首页关闭当前所有页面
  205. */
  206. goIndex: function(e) {
  207. uni.switchTab({
  208. url: '/pages/index/index'
  209. });
  210. },
  211. /**
  212. *
  213. * 去订单详情页面
  214. */
  215. goOrderDetails: function(e) {
  216. if (this.apiType == 'fast') {
  217. uni.navigateTo({
  218. url: '/pages/substitute_fast_mail/my_fast_mail/index'
  219. });
  220. } else {
  221. uni.navigateTo({
  222. url: this.fromType =='svip'?'/pages/activity/vip_paid/index':this.type==2?`/pages/activity/status/index?orderNo=${this.orderNo}`:'/pages/goods/order_list/index'
  223. });
  224. }
  225. }
  226. }
  227. }
  228. </script>
  229. <style lang="scss">
  230. .icon-iconfontguanbi {
  231. background-color: #999 !important;
  232. text-shadow: none !important;
  233. }
  234. .bg_color{
  235. @include main_bg_color(theme);
  236. }
  237. .cart_color{
  238. @include main_color(theme);
  239. @include coupons_border_color(theme);
  240. }
  241. .payment-status {
  242. background-color: #fff;
  243. margin: 195rpx 30rpx 0 30rpx;
  244. border-radius: 10rpx;
  245. padding: 1rpx 0 28rpx 0;
  246. }
  247. .payment-status .icons {
  248. font-size: 70rpx;
  249. width: 140rpx;
  250. height: 140rpx;
  251. border-radius: 50%;
  252. color: #fff;
  253. text-align: center;
  254. line-height: 140rpx;
  255. text-shadow: 0px 4px 0px rgba(0,0,0,.1);
  256. border: 6rpx solid #f5f5f5;
  257. margin: -76rpx auto 0 auto;
  258. background-color: #999;
  259. }
  260. .payment-status .iconfont {
  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(0,0,0,.1);
  269. border: 6rpx solid #f5f5f5;
  270. margin: -76rpx auto 0 auto;
  271. background-color: #999;
  272. }
  273. .payment-status .iconfont.fail {
  274. text-shadow: 0px 4px 0px #7a7a7a;
  275. }
  276. .payment-status .status {
  277. font-size: 32rpx;
  278. font-weight: bold;
  279. text-align: center;
  280. margin: 25rpx 0 37rpx 0;
  281. }
  282. .payment-status .wrapper {
  283. border: 1rpx solid #eee;
  284. margin: 0 30rpx 47rpx 30rpx;
  285. padding: 35rpx 0;
  286. border-left: 0;
  287. border-right: 0;
  288. }
  289. .payment-status .wrapper .item {
  290. font-size: 28rpx;
  291. color: #282828;
  292. }
  293. .payment-status .wrapper .item~.item {
  294. margin-top: 20rpx;
  295. }
  296. .payment-status .wrapper .item .itemCom {
  297. color: #666;
  298. }
  299. .payment-status .returnBnt {
  300. width: 630rpx;
  301. height: 86rpx;
  302. border-radius: 50rpx;
  303. color: #fff;
  304. font-size: 30rpx;
  305. text-align: center;
  306. line-height: 86rpx;
  307. margin: 0 auto 20rpx auto;
  308. }
  309. .cart-color {
  310. @include main_color(theme);
  311. @include coupons_border_color(theme);
  312. }
  313. </style>