index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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'>{{totalPrice}}</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. totalPrice: 0,
  115. loading: false,
  116. lotteryLoading: false,
  117. orderLottery: false,
  118. orderId: '',
  119. order_pay_info: {
  120. paid: 1,
  121. _status: {}
  122. },
  123. isAuto: false, //没有授权的不会自动授权
  124. isShowAuth: false, //是否隐藏授权
  125. status: 0,
  126. msg: '',
  127. couponsHidden: true,
  128. couponList: [],
  129. options: {}
  130. };
  131. },
  132. computed: mapGetters(['isLogin']),
  133. watch: {
  134. isLogin: {
  135. handler: function(newV, oldV) {
  136. if (newV) {
  137. this.getOrderPayInfo();
  138. }
  139. },
  140. deep: true
  141. }
  142. },
  143. onLoad: function(options) {
  144. this.options = options
  145. if (!options.order_id) return this.$util.Tips({
  146. title: this.$t(`缺少参数无法查看订单支付状态`)
  147. }, {
  148. tab: 3,
  149. url: 1
  150. });
  151. this.orderId = options.order_id;
  152. this.totalPrice = options.totalPrice;
  153. this.status = options.status || 0;
  154. this.msg = options.msg || '';
  155. // // #ifdef H5
  156. // document.addEventListener('visibilitychange', (e) => {
  157. // let state = document.visibilityState
  158. // if (state == 'hidden') {
  159. // console.log('用户离开了');
  160. // }
  161. // if (state == 'visible') {
  162. // this.getOrderPayInfo();
  163. // }
  164. // });
  165. // // #endif
  166. },
  167. onShow() {
  168. if (this.isLogin) {
  169. this.getOrderPayInfo();
  170. } else {
  171. toLogin();
  172. }
  173. },
  174. methods: {
  175. getOrderLottery(status) {
  176. this.orderLottery = status
  177. this.lotteryLoading = true
  178. },
  179. openTap() {
  180. this.$set(this, 'couponsHidden', !this.couponsHidden);
  181. },
  182. onLoadFun: function() {
  183. this.getOrderPayInfo();
  184. },
  185. /**
  186. *
  187. * 支付完成查询支付状态
  188. *
  189. */
  190. getOrderPayInfo: function() {
  191. let that = this;
  192. uni.showLoading({
  193. title: that.$t(`正在加载中`)
  194. });
  195. getOrderDetail(that.orderId).then(res => {
  196. uni.hideLoading();
  197. that.$set(that, 'order_pay_info', res.data);
  198. uni.setNavigationBarTitle({
  199. title: res.data.paid ? that.$t(`支付成功`) : that.$t(`未支付`)
  200. });
  201. this.loading = true
  202. this.getOrderCoupon()
  203. }).catch(err => {
  204. this.loading = true
  205. uni.hideLoading();
  206. });
  207. },
  208. getOrderCoupon() {
  209. let that = this;
  210. orderCoupon(that.orderId).then(res => {
  211. that.couponList = res.data;
  212. })
  213. },
  214. /**
  215. * 去首页关闭当前所有页面
  216. */
  217. goIndex: function(e) {
  218. uni.switchTab({
  219. url: '/pages/index/index'
  220. });
  221. },
  222. // 去参团页面;
  223. goPink: function(id) {
  224. uni.navigateTo({
  225. url: '/pages/activity/goods_combination_status/index?id=' + id
  226. });
  227. },
  228. /**
  229. *
  230. * 去订单详情页面
  231. */
  232. goOrderDetails: function(e) {
  233. let that = this;
  234. uni.redirectTo({
  235. url: '/pages/goods/order_list/index?status=2'
  236. });
  237. // // #ifdef MP
  238. // uni.showLoading({
  239. // title: that.$t(`正在加载中`),
  240. // })
  241. // openOrderSubscribe().then(res => {
  242. // uni.hideLoading();
  243. // uni.redirectTo({
  244. // url: '/pages/goods/order_details/index?order_id=' + that.orderId
  245. // });
  246. // }).catch(() => {
  247. // nui.hideLoading();
  248. // });
  249. // // #endif
  250. // // #ifndef MP
  251. // uni.redirectTo({
  252. // url: '/pages/goods/order_details/index?order_id=' + that.orderId
  253. // })
  254. // // #endif
  255. }
  256. }
  257. }
  258. </script>
  259. <style lang="scss">
  260. .coupons {
  261. .title {
  262. margin: 30rpx 0 25rpx 0;
  263. .line {
  264. width: 70rpx;
  265. height: 1px;
  266. background: #DCDCDC;
  267. }
  268. .name {
  269. font-size: 24rpx;
  270. color: #999;
  271. margin: 0 10rpx;
  272. }
  273. }
  274. .list {
  275. padding: 0 20rpx;
  276. .item {
  277. margin-bottom: 20rpx;
  278. box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.06);
  279. .price {
  280. width: 236rpx;
  281. height: 160rpx;
  282. font-size: 26rpx;
  283. color: #fff;
  284. font-weight: 800;
  285. text {
  286. font-size: 54rpx;
  287. }
  288. }
  289. .text {
  290. width: 385rpx;
  291. .name {
  292. font-size: #282828;
  293. font-size: 30rpx;
  294. }
  295. .priceMin {
  296. font-size: 24rpx;
  297. color: #999;
  298. margin-top: 10rpx;
  299. }
  300. .time {
  301. font-size: 24rpx;
  302. color: #999;
  303. margin-top: 15rpx;
  304. }
  305. }
  306. }
  307. .open {
  308. font-size: 24rpx;
  309. color: #999;
  310. margin-top: 30rpx;
  311. .iconfont {
  312. font-size: 25rpx;
  313. margin: 5rpx 0 0 10rpx;
  314. }
  315. }
  316. }
  317. }
  318. .payment-status {
  319. background-color: #fff;
  320. margin: 195rpx 30rpx 0 30rpx;
  321. border-radius: 10rpx;
  322. padding: 1rpx 0 28rpx 0;
  323. }
  324. .payment-status .icons {
  325. font-size: 70rpx;
  326. width: 140rpx;
  327. height: 140rpx;
  328. border-radius: 50%;
  329. color: #fff;
  330. text-align: center;
  331. line-height: 140rpx;
  332. text-shadow: 0px 4px 0px rgba(255,255,255,0.5);
  333. border: 6rpx solid #f5f5f5;
  334. margin: -76rpx auto 0 auto;
  335. background-color: #999;
  336. }
  337. .payment-status .icons.icon-iconfontguanbi {
  338. text-shadow: 0px 4px 0px #6c6d6d;
  339. }
  340. .payment-status .iconfont.fail {
  341. text-shadow: 0px 4px 0px #7a7a7a;
  342. }
  343. .payment-status .status {
  344. font-size: 32rpx;
  345. font-weight: bold;
  346. text-align: center;
  347. margin: 25rpx 0 37rpx 0;
  348. }
  349. .payment-status .wrapper {
  350. border: 1rpx solid #eee;
  351. margin: 0 30rpx 47rpx 30rpx;
  352. padding: 35rpx 0;
  353. border-left: 0;
  354. border-right: 0;
  355. }
  356. .payment-status .wrapper .item {
  357. font-size: 28rpx;
  358. color: #282828;
  359. }
  360. .payment-status .wrapper .item~.item {
  361. margin-top: 20rpx;
  362. }
  363. .payment-status .wrapper .item .itemCom {
  364. color: #666;
  365. }
  366. .payment-status .returnBnt {
  367. width: 630rpx;
  368. height: 86rpx;
  369. border-radius: 50rpx;
  370. color: #fff;
  371. font-size: 30rpx;
  372. text-align: center;
  373. line-height: 86rpx;
  374. margin: 0 auto 20rpx auto;
  375. }
  376. </style>