index.vue 10 KB

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