index.vue 10 KB

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