index.vue 9.8 KB

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