index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. <template>
  2. <view :style="colorStyle">
  3. <view class='payment-status' v-if="(!orderLottery || !order_pay_info.paid) && loading && lotteryLoading">
  4. <!--失败时: 用icon-iconfontguanbi fail替换icon-duihao2 bg-color-->
  5. <view class='iconfont icons icon-duihao2 bg-color'
  6. v-if="order_pay_info.paid || order_pay_info.pay_type == 'offline'"></view>
  7. <view class='iconfont icons icon-iconfontguanbi' v-else></view>
  8. <!-- 失败时:订单支付失败 -->
  9. <view class='status' v-if="order_pay_info.pay_type != 'offline'">
  10. {{order_pay_info.paid ? $t(`订单支付成功`):$t(payType ? `订单支付中`:`订单支付失败`)}}
  11. </view>
  12. <view class='status' v-else>{{$t(`订单创建成功`)}}</view>
  13. <view class='wrapper'>
  14. <view class='item acea-row row-between-wrapper'>
  15. <view>{{$t(`订单号`)}}</view>
  16. <view class='itemCom'>{{orderId}}</view>
  17. </view>
  18. <view class='item acea-row row-between-wrapper'>
  19. <view>{{$t(`下单时间`)}}</view>
  20. <view class='itemCom'>{{order_pay_info._add_time}}</view>
  21. </view>
  22. <view class='item acea-row row-between-wrapper'>
  23. <view>{{$t(`支付方式`)}}</view>
  24. <view class='itemCom'>{{$t(order_pay_info._status._payType) || $t(`暂未支付`)}}</view>
  25. </view>
  26. <view class='item acea-row row-between-wrapper'>
  27. <view>{{$t(`支付金额`)}}</view>
  28. <view class='itemCom'>{{order_pay_info.pay_price}}</view>
  29. </view>
  30. <!--失败时加上这个 -->
  31. <view class='item acea-row row-between-wrapper'
  32. v-if="order_pay_info.paid==0 && order_pay_info.pay_type != 'offline'">
  33. <view>{{$t(`失败原因`)}}</view>
  34. <view class='itemCom'>{{status==2 ? $t(`取消支付`):msg}}</view>
  35. </view>
  36. </view>
  37. <!--失败时: 重新购买 -->
  38. <view @tap="goOrderDetails" v-if="status==0">
  39. <button formType="submit" class='returnBnt bg-color' hover-class='none'>{{$t(`查看订单`)}}</button>
  40. </view>
  41. <view @tap="getOrderPayInfo" v-if="payType == 'ALLINPAY_PAY'">
  42. <button class='returnBnt bg-color' hover-class='none'>{{$t(`刷新支付状态`)}}</button>
  43. </view>
  44. <view @tap="goOrderDetails" v-if="order_pay_info.paid==0 && status==1">
  45. <button class='returnBnt bg-color' hover-class='none'>{{$t(`重新购买`)}}</button>
  46. </view>
  47. <view @tap="goOrderDetails" v-if="order_pay_info.paid==0 && status==2">
  48. <button class='returnBnt bg-color' hover-class='none'>{{$t(`重新支付`)}}</button>
  49. </view>
  50. <button @click="goPink(order_pay_info.pink_id)" class='returnBnt cart-color' formType="submit"
  51. hover-class='none'
  52. v-if="order_pay_info.pink_id && order_pay_info.paid!=0 && status!=2 && status!=1">{{$t(`邀请好友参团`)}}</button>
  53. <button @click="goIndex" class='returnBnt cart-color' formType="submit" hover-class='none'
  54. v-else>{{$t(`返回首页`)}}</button>
  55. <view class="coupons" v-if='couponList.length'>
  56. <view class="title acea-row row-center-wrapper">
  57. <view class="line"></view>
  58. <view class="name">{{$t(`赠送优惠券`)}}</view>
  59. <view class="line"></view>
  60. </view>
  61. <view class="list">
  62. <view class="item acea-row row-between-wrapper" v-for="(item,index) in couponList" :key='index'
  63. v-if="index<2 || !couponsHidden">
  64. <view class="moneyCon acea-row row-between-wrapper">
  65. <view class="price acea-row row-center-wrapper">
  66. <view>
  67. {{$t(`¥`)}}<text>{{item.coupon_price}}</text>
  68. </view>
  69. </view>
  70. </view>
  71. <view class="text">
  72. <view class="name line1">{{item.coupon_title}}</view>
  73. <view class="priceMin">{{$t(`满`)}}{{item.use_min_price}}{{$t(`元可用`)}}</view>
  74. <view class="time">
  75. {{$t(`有效期`)}}:{{ item.add_time ? item.add_time + "-" : ""}}{{ item.end_time }}
  76. </view>
  77. </view>
  78. </view>
  79. <view class="open acea-row row-center-wrapper" @click="openTap" v-if="couponList.length>2">
  80. {{couponsHidden?$t(`更多`):$t(`关闭`)}}<text class="iconfont"
  81. :class='couponsHidden==true?"icon-xiangxia":"icon-xiangshang"'></text>
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. <lotteryModel v-show="orderLottery && order_pay_info.paid && loading && lotteryLoading" :options="options"
  87. @orderDetails="goOrderDetails" @lotteryShow="getOrderLottery"></lotteryModel>
  88. </view>
  89. </template>
  90. <script>
  91. import lotteryModel from './payLottery.vue'
  92. import {
  93. getOrderDetail,
  94. orderCoupon
  95. } from '@/api/order.js';
  96. import {
  97. openOrderSubscribe
  98. } from '@/utils/SubscribeMessage.js';
  99. import {
  100. toLogin
  101. } from '@/libs/login.js';
  102. import {
  103. mapGetters
  104. } from "vuex";
  105. // #ifdef MP
  106. import authorize from '@/components/Authorize';
  107. // #endif
  108. import colors from "@/mixins/color";
  109. export default {
  110. components: {
  111. lotteryModel,
  112. // #ifdef MP
  113. authorize
  114. // #endif
  115. },
  116. mixins: [colors],
  117. data() {
  118. return {
  119. loading: false,
  120. lotteryLoading: false,
  121. orderLottery: false,
  122. orderId: '',
  123. order_pay_info: {
  124. paid: 1,
  125. _status: {}
  126. },
  127. isAuto: false, //没有授权的不会自动授权
  128. isShowAuth: false, //是否隐藏授权
  129. status: 0,
  130. msg: '',
  131. couponsHidden: true,
  132. couponList: [],
  133. options: {},
  134. payType: ''
  135. };
  136. },
  137. computed: mapGetters(['isLogin']),
  138. watch: {
  139. isLogin: {
  140. handler: function(newV, oldV) {
  141. if (newV) {
  142. this.getOrderPayInfo();
  143. }
  144. },
  145. deep: true
  146. }
  147. },
  148. onLoad: function(options) {
  149. this.options = options
  150. if (!options.order_id) return this.$util.Tips({
  151. title: this.$t(`缺少参数无法查看订单支付状态`)
  152. }, {
  153. tab: 3,
  154. url: 1
  155. });
  156. this.orderId = options.order_id;
  157. this.status = options.status || 0;
  158. this.msg = options.msg || '';
  159. this.payType = options.payType || '';
  160. // // #ifdef H5
  161. // document.addEventListener('visibilitychange', (e) => {
  162. // let state = document.visibilityState
  163. // if (state == 'hidden') {
  164. // console.log('用户离开了');
  165. // }
  166. // if (state == 'visible') {
  167. // this.getOrderPayInfo();
  168. // }
  169. // });
  170. // // #endif
  171. },
  172. onShow() {
  173. if (this.isLogin) {
  174. this.getOrderPayInfo();
  175. } else {
  176. toLogin();
  177. }
  178. },
  179. methods: {
  180. getOrderLottery(status) {
  181. this.orderLottery = status
  182. this.lotteryLoading = true
  183. },
  184. openTap() {
  185. this.$set(this, 'couponsHidden', !this.couponsHidden);
  186. },
  187. onLoadFun: function() {
  188. this.getOrderPayInfo();
  189. },
  190. /**
  191. *
  192. * 支付完成查询支付状态
  193. *
  194. */
  195. getOrderPayInfo: function() {
  196. let that = this;
  197. uni.showLoading({
  198. title: that.$t(`正在加载中`)
  199. });
  200. getOrderDetail(that.orderId).then(res => {
  201. uni.hideLoading();
  202. that.$set(that, 'order_pay_info', res.data);
  203. uni.setNavigationBarTitle({
  204. title: res.data.paid ? that.$t(`支付成功`) : that.$t(`未支付`)
  205. });
  206. this.loading = true
  207. this.getOrderCoupon()
  208. }).catch(err => {
  209. this.loading = true
  210. uni.hideLoading();
  211. });
  212. },
  213. getOrderCoupon() {
  214. let that = this;
  215. orderCoupon(that.orderId).then(res => {
  216. that.couponList = res.data;
  217. })
  218. },
  219. /**
  220. * 去首页关闭当前所有页面
  221. */
  222. goIndex: function(e) {
  223. uni.switchTab({
  224. url: '/pages/index/index'
  225. });
  226. },
  227. // 去参团页面;
  228. goPink: function(id) {
  229. uni.navigateTo({
  230. url: '/pages/activity/goods_combination_status/index?id=' + id
  231. });
  232. },
  233. /**
  234. *
  235. * 去订单详情页面
  236. */
  237. goOrderDetails: function(e) {
  238. let that = this;
  239. // #ifdef MP
  240. uni.showLoading({
  241. title: that.$t(`正在加载中`),
  242. })
  243. openOrderSubscribe().then(res => {
  244. uni.hideLoading();
  245. uni.redirectTo({
  246. url: '/pages/goods/order_details/index?order_id=' + that.orderId
  247. });
  248. }).catch(() => {
  249. nui.hideLoading();
  250. });
  251. // #endif
  252. // #ifndef MP
  253. uni.redirectTo({
  254. url: '/pages/goods/order_details/index?order_id=' + that.orderId
  255. })
  256. // #endif
  257. }
  258. }
  259. }
  260. </script>
  261. <style lang="scss">
  262. .coupons {
  263. .title {
  264. margin: 30rpx 0 25rpx 0;
  265. .line {
  266. width: 70rpx;
  267. height: 1px;
  268. background: #DCDCDC;
  269. }
  270. .name {
  271. font-size: 24rpx;
  272. color: #999;
  273. margin: 0 10rpx;
  274. }
  275. }
  276. .list {
  277. padding: 0 20rpx;
  278. .item {
  279. margin-bottom: 20rpx;
  280. box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.06);
  281. .price {
  282. width: 236rpx;
  283. height: 160rpx;
  284. font-size: 26rpx;
  285. color: #fff;
  286. font-weight: 800;
  287. text {
  288. font-size: 54rpx;
  289. }
  290. }
  291. .text {
  292. width: 385rpx;
  293. .name {
  294. font-size: #282828;
  295. font-size: 30rpx;
  296. }
  297. .priceMin {
  298. font-size: 24rpx;
  299. color: #999;
  300. margin-top: 10rpx;
  301. }
  302. .time {
  303. font-size: 24rpx;
  304. color: #999;
  305. margin-top: 15rpx;
  306. }
  307. }
  308. }
  309. .open {
  310. font-size: 24rpx;
  311. color: #999;
  312. margin-top: 30rpx;
  313. .iconfont {
  314. font-size: 25rpx;
  315. margin: 5rpx 0 0 10rpx;
  316. }
  317. }
  318. }
  319. }
  320. .payment-status {
  321. background-color: #fff;
  322. margin: 195rpx 30rpx 0 30rpx;
  323. border-radius: 10rpx;
  324. padding: 1rpx 0 28rpx 0;
  325. }
  326. .payment-status .icons {
  327. font-size: 70rpx;
  328. width: 140rpx;
  329. height: 140rpx;
  330. border-radius: 50%;
  331. color: #fff;
  332. text-align: center;
  333. line-height: 140rpx;
  334. text-shadow: 0px 4px 0px rgba(255, 255, 255, 0.5);
  335. border: 6rpx solid #f5f5f5;
  336. margin: -76rpx auto 0 auto;
  337. background-color: #999;
  338. }
  339. .payment-status .icons.icon-iconfontguanbi {
  340. text-shadow: 0px 4px 0px #6c6d6d;
  341. }
  342. .payment-status .iconfont.fail {
  343. text-shadow: 0px 4px 0px #7a7a7a;
  344. }
  345. .payment-status .status {
  346. font-size: 32rpx;
  347. font-weight: bold;
  348. text-align: center;
  349. margin: 25rpx 0 37rpx 0;
  350. }
  351. .payment-status .wrapper {
  352. border: 1rpx solid #eee;
  353. margin: 0 30rpx 47rpx 30rpx;
  354. padding: 35rpx 0;
  355. border-left: 0;
  356. border-right: 0;
  357. }
  358. .payment-status .wrapper .item {
  359. font-size: 28rpx;
  360. color: #282828;
  361. }
  362. .payment-status .wrapper .item~.item {
  363. margin-top: 20rpx;
  364. }
  365. .payment-status .wrapper .item .itemCom {
  366. color: #666;
  367. }
  368. .payment-status .returnBnt {
  369. width: 630rpx;
  370. height: 86rpx;
  371. border-radius: 50rpx;
  372. color: #fff;
  373. font-size: 30rpx;
  374. text-align: center;
  375. line-height: 86rpx;
  376. margin: 0 auto 20rpx auto;
  377. }
  378. </style>