index.vue 8.3 KB

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