index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. <template>
  2. <view :style="viewColor">
  3. <view class='payment-status'>
  4. <!--失败时: 用icon-iconfontguanbi fail替换icon-duihao2 bg-color-->
  5. <view class='iconfont icon-duihao2 icon' v-if ="order_pay_info.paid !=0"></view>
  6. <view class='iconfont icon-iconfontguanbi icon' v-else></view>
  7. <!-- 失败时:订单支付失败 -->
  8. <!-- <view v-if="order_type== 20" class='status'>{{order_pay_info.paid == 1 ? '商品兑换成功' : order_pay_info.paid==0 && order_pay_info.pay_type != 'offline' && msg != 'success' ? '支付失败' : '未支付'}}</view> -->
  9. <!-- <view v-else class='status'>{{order_pay_info.paid == 1 ? '支付成功' : order_pay_info.paid==0 && order_pay_info.pay_type != 'offline' && msg != 'success' ? '支付失败' : '未支付'}}</view> -->
  10. <view class="status">{{payResult}}</view>
  11. <view class='wrapper'>
  12. <view v-if="order_type== 20" class='item acea-row row-between-wrapper'>
  13. <view>订单编号</view>
  14. <view class='itemCom'>{{order_pay_info.group_order_sn}}</view>
  15. </view>
  16. <view class='item acea-row row-between-wrapper'>
  17. <view>{{order_type== 20 ? '兑换时间' : '下单时间'}}</view>
  18. <view class='itemCom'>{{order_pay_info.create_time}}</view>
  19. </view>
  20. <view v-if="order_type== 20" class='item acea-row row-between-wrapper'>
  21. <view>兑换方式</view>
  22. <view class='itemCom'>积分兑换</view>
  23. </view>
  24. <view v-else class='item acea-row row-between-wrapper'>
  25. <view>支付方式</view>
  26. <view v-if="order_pay_info.pay_type==1 || order_pay_info.pay_type==2 || order_pay_info.pay_type==3" class='itemCom'>微信</view>
  27. <view v-else-if="order_pay_info.pay_type==4 || order_pay_info.pay_type==5" class='itemCom'>支付宝</view>
  28. <view v-else class='itemCom'>余额</view>
  29. </view>
  30. <view v-if="order_type== 20" class='item acea-row row-between-wrapper'>
  31. <view>支付积分</view>
  32. <view class='itemCom'>{{order_pay_info.integral}}</view>
  33. </view>
  34. <view class='item acea-row row-between-wrapper'>
  35. <view>支付金额</view>
  36. <view class='itemCom'>{{order_pay_info.pay_price}}</view>
  37. </view>
  38. <view v-if="order_pay_info.give_integral > 0 && order_pay_info.paid" class='item acea-row row-between-wrapper'>
  39. <view>赠送积分</view>
  40. <view class='itemCom t-color'>{{order_pay_info.give_integral}}</view>
  41. </view>
  42. <!--失败时加上这个 -->
  43. <view class='item acea-row row-between-wrapper' v-if="order_pay_info.paid==0 && order_pay_info.pay_type != 'offline' && msg != 'success'">
  44. <view>失败原因</view>
  45. <view class='itemCom'>{{order_pay_info.pay_type==0 ? '余额不足':msg}}</view>
  46. </view>
  47. </view>
  48. <!--失败时: 重新购买 -->
  49. <view @tap="goOrderDetails">
  50. <button formType="submit" class='returnBnt gColor' hover-class='none'>查看订单</button>
  51. </view>
  52. <button @click="goPink(order_pay_info.activity_id)" class='returnBnt s-Color' formType="submit" hover-class='none' v-if="order_pay_info.activity_type == 4 && order_pay_info.paid">邀请好友参团</button>
  53. <button v-if="!order_pay_info.paid || order_pay_info.activity_type != 4" @click="goIndex" class='returnBnt s-Color' formType="submit" hover-class='none'>返回首页</button>
  54. <view class="coupon-wrapper" v-if="couponList.length>0 && order_pay_info.paid">
  55. <view class="hd">
  56. <view class="line"></view>
  57. <view class="txt">赠送优惠券</view>
  58. <view class="line"></view>
  59. </view>
  60. <view class="coupon-box" :class="{on:isOpen}">
  61. <block v-for="(item,index) in couponList" :key="index">
  62. <view class="coupon-item flex">
  63. <view class="left-bg" :style="{ 'background-image': `url(${domain}/static/diy/couponBg${keyColor}.png)` }"><text>¥</text>{{item.coupon_price}}</view>
  64. <view class="info">
  65. <view class="title">{{item.title}}</view>
  66. <view class="des">满{{item.use_min_price}}元可用</view>
  67. <block v-if="item.coupon_type == 1">
  68. <view class="des">有效期:{{ item.use_start_time |timeYMD }}-{{ item.use_end_time |timeYMD}}</view>
  69. </block>
  70. <block v-if="item.coupon_type == 0">
  71. <view class="des">领取后{{ item.coupon_time}}天内可用</view>
  72. </block>
  73. </view>
  74. </view>
  75. </block>
  76. </view>
  77. <view class="more" v-if="couponList.length>2" @click="bindMore">
  78. {{ text }}
  79. <text v-if="!isOpen" class="iconfont icon-xiangxia"></text>
  80. <text v-else class="iconfont icon-xiangshang"></text>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. </template>
  86. <script>
  87. // +----------------------------------------------------------------------
  88. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  89. // +----------------------------------------------------------------------
  90. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  91. // +----------------------------------------------------------------------
  92. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  93. // +----------------------------------------------------------------------
  94. // | Author: CRMEB Team <admin@crmeb.com>
  95. // +----------------------------------------------------------------------
  96. import {getPayOrder} from '@/api/order.js';
  97. import {openOrderSubscribe} from '@/utils/SubscribeMessage.js';
  98. import {mapGetters} from "vuex";
  99. import { toLogin } from '@/libs/login.js';
  100. import { HTTP_REQUEST_URL } from '@/config/app';
  101. export default {
  102. components: {
  103. },
  104. filters: {
  105. timeYMD: function (value) {
  106. if(value){
  107. var newDate=/\d{4}-\d{1,2}-\d{1,2}/g.exec(value)
  108. return newDate[0]
  109. }
  110. }
  111. },
  112. data() {
  113. return {
  114. domain: HTTP_REQUEST_URL,
  115. orderId: '',
  116. order_type: '',
  117. order_pay_info: {},
  118. status: 0,
  119. msg: '',
  120. couponList:[], //优惠券列表
  121. isOpen:false ,//展开
  122. moneyBg: '/static/images/couponBg',
  123. text: '展开更多',
  124. timer: null,
  125. payResult: '正在查询支付结果...'
  126. };
  127. },
  128. computed: mapGetters(['isLogin','viewColor','keyColor']),
  129. onLoad: function(options) {
  130. if (!options.order_id) return this.$util.Tips({
  131. title: '缺少参数无法查看订单支付状态'
  132. }, {
  133. tab: 3,
  134. url: 1
  135. });
  136. this.orderId = options.order_id;
  137. this.order_type = options.order_type;
  138. this.status = options.status || 0;
  139. this.msg = options.msg || '';
  140. if (this.isLogin) {
  141. this.refreshData();
  142. } else {
  143. toLogin()
  144. }
  145. },
  146. onHide: function(){
  147. clearInterval(this.timer);
  148. this.timer = null;
  149. },
  150. methods: {
  151. refreshData(){
  152. this.timer = setInterval(()=>{
  153. this.getOrderPayInfo();
  154. },1000)
  155. },
  156. // 优惠券展开
  157. bindMore(){
  158. this.isOpen = !this.isOpen
  159. this.text = this.text == '展开更多' ? '收起' : '展开更多';
  160. },
  161. /**
  162. *
  163. * 支付完成查询支付状态
  164. *
  165. */
  166. getOrderPayInfo: function() {
  167. let that = this;
  168. getPayOrder(that.orderId).then(res => {
  169. that.$set(that, 'order_pay_info', res.data);
  170. that.couponList = res.data.give_coupon
  171. if(that.order_type == 20){
  172. that.payResult = res.data.paid == 1 ? '商品兑换成功' : '支付失败'
  173. }else{
  174. that.payResult = res.data.paid == 1 ? '支付成功' : '支付失败'
  175. }
  176. uni.setNavigationBarTitle({
  177. title: res.data.paid == 1 ? '支付成功' : '支付失败'
  178. });
  179. if(res.data.paid == 1){
  180. clearInterval(this.timer);
  181. this.timer = null;
  182. }
  183. }).catch(err => {
  184. uni.hideLoading();
  185. });
  186. },
  187. /**
  188. * 去首页关闭当前所有页面
  189. */
  190. goIndex: function(e) {
  191. uni.switchTab({
  192. url: '/pages/index/index'
  193. });
  194. },
  195. // 去参团页面;
  196. goPink: function(id) {
  197. uni.navigateTo({
  198. url: '/pages/activity/combination_status/index?id=' + id
  199. });
  200. },
  201. /**
  202. *
  203. * 去订单详情页面
  204. */
  205. goOrderDetails: function(e) {
  206. let that = this;
  207. if(that.order_type == 20){
  208. uni.navigateTo({
  209. url: '/pages/points_mall/exchange_record?delte=1'
  210. })
  211. }else{
  212. if (that.order_pay_info.paid == 0) {
  213. uni.navigateTo({
  214. url: '/pages/users/order_list/index'
  215. })
  216. } else if(that.order_pay_info&&that.order_pay_info.orderList[0]['is_virtual'] == 2){
  217. uni.navigateTo({
  218. url: '/pages/users/order_list/index?status=3'
  219. })
  220. }else {
  221. uni.navigateTo({
  222. url: '/pages/users/order_list/index?status=1'
  223. })
  224. }
  225. }
  226. }
  227. },
  228. destroyed() {
  229. clearInterval(this.timer);
  230. this.timer = null;
  231. },
  232. deactivated() {
  233. clearInterval(this.timer);
  234. this.timer = null;
  235. }
  236. }
  237. </script>
  238. <style lang="scss">
  239. .payment-status {
  240. background-color: #fff;
  241. margin: 92rpx 30rpx 30rpx;
  242. border-radius: 10rpx;
  243. padding: 1rpx 0 28rpx 0;
  244. }
  245. .payment-status .icon {
  246. font-size: 70rpx;
  247. width: 140rpx;
  248. height: 140rpx;
  249. border-radius: 50%;
  250. color: #fff;
  251. text-align: center;
  252. line-height: 140rpx;
  253. border: 6rpx solid #f5f5f5;
  254. margin: -76rpx auto 0 auto;
  255. background-color: #999;
  256. &.icon-duihao2{
  257. background-color: var(--view-theme);
  258. }
  259. }
  260. .payment-status .icon.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: 1px 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. &.gColor{
  296. background-color: var(--view-theme);
  297. }
  298. &.s-Color{
  299. color: var(--view-theme);
  300. border: 1px solid var(--view-theme);
  301. }
  302. }
  303. .t-color {
  304. color: var(--view-theme)!important;
  305. }
  306. .coupon-wrapper{
  307. .hd{
  308. display: flex;
  309. align-items: center;
  310. justify-content: center;
  311. margin: 30rpx 0;
  312. color: #999999;
  313. font-size: 24rpx;
  314. .line{
  315. width: 70rpx;
  316. height: 1px;
  317. background: #DCDCDC;
  318. }
  319. .txt{
  320. margin: 0 20rpx;
  321. }
  322. }
  323. .coupon-box{
  324. height: 356rpx;
  325. padding: 0 20rpx;
  326. overflow: hidden;
  327. &.on{
  328. height: auto;
  329. }
  330. .coupon-item{
  331. width: 100%;
  332. margin-bottom: 20rpx;
  333. box-shadow:0px 2px 10px 0px rgba(0, 0, 0, 0.06);
  334. .left-bg{
  335. display: flex;
  336. align-items: center;
  337. justify-content: center;
  338. width: 236rpx;
  339. height: 160rpx;
  340. color: #fff;
  341. font-size: 64rpx;
  342. text{
  343. margin-top: 26rpx;
  344. font-size: 36rpx;
  345. }
  346. }
  347. .info{
  348. display: flex;
  349. flex-direction: column;
  350. justify-content: space-between;
  351. margin-left: 20rpx;
  352. padding: 20rpx 0;
  353. .title{
  354. color: #282828;
  355. font-size: 30rpx;
  356. }
  357. .des{
  358. font-size: 24rpx;
  359. color: #999999;
  360. }
  361. }
  362. }
  363. }
  364. .more{
  365. display: flex;
  366. align-items: center;
  367. justify-content: center;
  368. padding-top: 24rpx;
  369. font-size: 24rpx;
  370. color: #999999;
  371. .iconfont{
  372. margin-top: 6rpx;
  373. margin-left: 10rpx;
  374. font-size: 20rpx;
  375. }
  376. }
  377. }
  378. </style>