index.vue 10 KB

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