index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. <template>
  2. <view :style="colorStyle">
  3. <view class='payment-status'>
  4. <!--失败时: 用icon-iconfontguanbi fail替换icon-duihao2 bg-color-->
  5. <view class='iconfont icons icon-duihao2 bg-color'
  6. v-if="order_pay_info.payFlag == 2 || 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.payFlag == 2 ?
  10. $t(`订单支付成功`) : $t(`订单支付失败`)
  11. }}
  12. </view>
  13. <view class='status' v-else>{{ $t(`订单创建成功`) }}</view>
  14. <view class='wrapper'>
  15. <view class='item acea-row row-between-wrapper'>
  16. <view>{{ $t(`订单号`) }}</view>
  17. <view class='itemCom'>{{ orderId }}</view>
  18. </view>
  19. <view class='item acea-row row-between-wrapper'>
  20. <view>{{ $t(`下单时间`) }}</view>
  21. <view class='itemCom'>{{ order_pay_info.createTime }}</view>
  22. </view>
  23. <view class='item acea-row row-between-wrapper'>
  24. <view>{{ $t(`支付方式`) }}</view>
  25. <view class='itemCom'>{{ $t(`微信支付`) }}</view>
  26. </view>
  27. <view class='item acea-row row-between-wrapper'>
  28. <view>{{ $t(`支付金额`) }}</view>
  29. <view class='itemCom'>{{ order_pay_info.payFee }}</view>
  30. </view>
  31. <view class='item acea-row row-between-wrapper'>
  32. <view>{{ $t(`支付时间`) }}</view>
  33. <view class='itemCom'>{{ order_pay_info.payTime }}</view>
  34. </view>
  35. <!--失败时加上这个 -->
  36. <view class='item acea-row row-between-wrapper'
  37. v-if="order_pay_info.paid == 0 && order_pay_info.pay_type != 'offline'">
  38. <view>{{ $t(`失败原因`) }}</view>
  39. <view class='itemCom'>{{ status == 2 ? $t(`取消支付`) : msg }}</view>
  40. </view>
  41. </view>
  42. <!--失败时: 重新购买 -->
  43. <view @tap="goOrderDetails" v-if="status == 0">
  44. <button formType="submit" class='returnBnt bg-color' hover-class='none'>{{ $t(`查看订单`) }}</button>
  45. </view>
  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">{{ $t(`有效期`) }}:{{ item.add_time ? item.add_time + "-" : "" }}{{
  77. item.end_time
  78. }}
  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 :options="options"
  90. @orderDetails="goOrderDetails" @lotteryShow="getOrderLottery"></lotteryModel> -->
  91. </view>
  92. </template>
  93. <script>
  94. // import lotteryModel from './payLottery.vue'
  95. import {
  96. getOrderDetailById,
  97. } from '@/api/home.js';
  98. import {
  99. getOrderDetail,
  100. orderCoupon
  101. } from '@/api/order.js';
  102. import {
  103. openOrderSubscribe
  104. } from '@/utils/SubscribeMessage.js';
  105. import {
  106. toLogin
  107. } from '@/libs/login.js';
  108. import {
  109. mapGetters
  110. } from "vuex";
  111. // #ifdef MP
  112. import authorize from '@/components/Authorize';
  113. // #endif
  114. import colors from "@/mixins/color";
  115. export default {
  116. components: {
  117. // lotteryModel,
  118. // #ifdef MP
  119. authorize
  120. // #endif
  121. },
  122. mixins: [colors],
  123. data() {
  124. return {
  125. totalPrice: 0,
  126. loading: false,
  127. lotteryLoading: false,
  128. orderLottery: false,
  129. orderId: '',
  130. order_pay_info: {
  131. paid: 1,
  132. _status: {}
  133. },
  134. isAuto: false, //没有授权的不会自动授权
  135. isShowAuth: false, //是否隐藏授权
  136. status: 0,
  137. msg: '',
  138. couponsHidden: true,
  139. couponList: [],
  140. options: {}
  141. };
  142. },
  143. computed: mapGetters(['isLogin']),
  144. watch: {
  145. isLogin: {
  146. handler: function (newV, oldV) {
  147. if (newV) {
  148. this.getOrderPayInfo();
  149. }
  150. },
  151. deep: true
  152. }
  153. },
  154. onLoad: function (options) {
  155. this.options = options
  156. if (!options.order_id) return this.$util.Tips({
  157. title: this.$t(`缺少参数无法查看订单支付状态`)
  158. }, {
  159. tab: 3,
  160. url: 1
  161. });
  162. this.orderId = options.order_id;
  163. this.totalPrice = options.totalPrice;
  164. this.status = options.status || 0;
  165. this.msg = options.msg || '';
  166. // // #ifdef H5
  167. // document.addEventListener('visibilitychange', (e) => {
  168. // let state = document.visibilityState
  169. // if (state == 'hidden') {
  170. // console.log('用户离开了');
  171. // }
  172. // if (state == 'visible') {
  173. // this.getOrderPayInfo();
  174. // }
  175. // });
  176. // // #endif
  177. },
  178. onShow() {
  179. if (this.isLogin) {
  180. this.getOrderPayInfo();
  181. } else {
  182. toLogin();
  183. }
  184. },
  185. methods: {
  186. getOrderLottery(status) {
  187. this.orderLottery = status
  188. this.lotteryLoading = true
  189. },
  190. openTap() {
  191. this.$set(this, 'couponsHidden', !this.couponsHidden);
  192. },
  193. onLoadFun: function () {
  194. this.getOrderPayInfo();
  195. },
  196. /**
  197. *
  198. * 支付完成查询支付状态
  199. *
  200. */
  201. getOrderPayInfo: function () {
  202. let that = this;
  203. uni.showLoading({
  204. title: that.$t(`正在加载中`)
  205. });
  206. getOrderDetailById({
  207. orderId: that.orderId
  208. }).then(res => {
  209. uni.hideLoading();
  210. that.$set(that, 'order_pay_info', res.data);
  211. uni.setNavigationBarTitle({
  212. title: res.data.payFlag == 2 ? 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. uni.redirectTo({
  248. url: '/pages/goods/order_details/index?order_id='+ that.orderId
  249. });
  250. // // #ifdef MP
  251. // uni.showLoading({
  252. // title: that.$t(`正在加载中`),
  253. // })
  254. // openOrderSubscribe().then(res => {
  255. // uni.hideLoading();
  256. // uni.redirectTo({
  257. // url: '/pages/goods/order_details/index?order_id=' + that.orderId
  258. // });
  259. // }).catch(() => {
  260. // nui.hideLoading();
  261. // });
  262. // // #endif
  263. // // #ifndef MP
  264. // uni.redirectTo({
  265. // url: '/pages/goods/order_details/index?order_id=' + that.orderId
  266. // })
  267. // // #endif
  268. }
  269. }
  270. }
  271. </script>
  272. <style lang="scss">
  273. .coupons {
  274. .title {
  275. margin: 30rpx 0 25rpx 0;
  276. .line {
  277. width: 70rpx;
  278. height: 1px;
  279. background: #DCDCDC;
  280. }
  281. .name {
  282. font-size: 24rpx;
  283. color: #999;
  284. margin: 0 10rpx;
  285. }
  286. }
  287. .list {
  288. padding: 0 20rpx;
  289. .item {
  290. margin-bottom: 20rpx;
  291. box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.06);
  292. .price {
  293. width: 236rpx;
  294. height: 160rpx;
  295. font-size: 26rpx;
  296. color: #fff;
  297. font-weight: 800;
  298. text {
  299. font-size: 54rpx;
  300. }
  301. }
  302. .text {
  303. width: 385rpx;
  304. .name {
  305. font-size: #282828;
  306. font-size: 30rpx;
  307. }
  308. .priceMin {
  309. font-size: 24rpx;
  310. color: #999;
  311. margin-top: 10rpx;
  312. }
  313. .time {
  314. font-size: 24rpx;
  315. color: #999;
  316. margin-top: 15rpx;
  317. }
  318. }
  319. }
  320. .open {
  321. font-size: 24rpx;
  322. color: #999;
  323. margin-top: 30rpx;
  324. .iconfont {
  325. font-size: 25rpx;
  326. margin: 5rpx 0 0 10rpx;
  327. }
  328. }
  329. }
  330. }
  331. .payment-status {
  332. background-color: #fff;
  333. margin: 195rpx 30rpx 0 30rpx;
  334. border-radius: 10rpx;
  335. padding: 1rpx 0 28rpx 0;
  336. }
  337. .payment-status .icons {
  338. font-size: 70rpx;
  339. width: 140rpx;
  340. height: 140rpx;
  341. border-radius: 50%;
  342. color: #fff;
  343. text-align: center;
  344. line-height: 140rpx;
  345. text-shadow: 0px 4px 0px rgba(255, 255, 255, 0.5);
  346. border: 6rpx solid #f5f5f5;
  347. margin: -76rpx auto 0 auto;
  348. background-color: #999;
  349. }
  350. .payment-status .icons.icon-iconfontguanbi {
  351. text-shadow: 0px 4px 0px #6c6d6d;
  352. }
  353. .payment-status .iconfont.fail {
  354. text-shadow: 0px 4px 0px #7a7a7a;
  355. }
  356. .payment-status .status {
  357. font-size: 32rpx;
  358. font-weight: bold;
  359. text-align: center;
  360. margin: 25rpx 0 37rpx 0;
  361. }
  362. .payment-status .wrapper {
  363. border: 1rpx solid #eee;
  364. margin: 0 30rpx 47rpx 30rpx;
  365. padding: 35rpx 0;
  366. border-left: 0;
  367. border-right: 0;
  368. }
  369. .payment-status .wrapper .item {
  370. font-size: 28rpx;
  371. color: #282828;
  372. }
  373. .payment-status .wrapper .item~.item {
  374. margin-top: 20rpx;
  375. }
  376. .payment-status .wrapper .item .itemCom {
  377. color: #666;
  378. }
  379. .payment-status .returnBnt {
  380. width: 630rpx;
  381. height: 86rpx;
  382. border-radius: 50rpx;
  383. color: #fff;
  384. font-size: 30rpx;
  385. text-align: center;
  386. line-height: 86rpx;
  387. margin: 0 auto 20rpx auto;
  388. }
  389. </style>