index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. <template>
  2. <view :style="colorStyle">
  3. <view class="payment-status" v-if="(!orderLottery || !order_pay_info.paid || is_gift) && loading && lotteryLoading">
  4. <!--失败时: 用icon-iconfontguanbi fail替换icon-duihao2 bg-color-->
  5. <view class="iconfont icons icon-duihao2 bg-color" v-if="order_pay_info.paid || order_pay_info.pay_type == 'offline'"></view>
  6. <view class="iconfont icons icon-iconfontguanbi" v-else></view>
  7. <!-- 失败时:订单支付失败 -->
  8. <view class="status" v-if="order_pay_info.pay_type != 'offline'">
  9. {{ order_pay_info.paid ? $t(`订单支付成功`) : $t(payType ? `订单支付中` : `订单支付失败`) }}
  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" v-if="order_pay_info.paid == 0 && order_pay_info.pay_type != 'offline'">
  31. <view>{{ $t(`失败原因`) }}</view>
  32. <view class="itemCom">{{ $t(`未支付`) }}</view>
  33. </view>
  34. </view>
  35. <view v-if="order_pay_info.paid != 0 && is_gift !== 0" @click="giftModalShow = true">
  36. <button class="returnBnt bg-color" hover-class="none">{{ $t(`送给好友`) }}</button>
  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
  54. @click="goPink(order_pay_info.pink_id)"
  55. class="returnBnt cart-color"
  56. formType="submit"
  57. hover-class="none"
  58. v-if="order_pay_info.pink_id && order_pay_info.paid != 0 && status != 2 && status != 1"
  59. >
  60. {{ $t(`邀请好友参团`) }}
  61. </button>
  62. <button @click="goIndex" class="returnBnt cart-color" formType="submit" hover-class="none" v-else>{{ $t(`返回首页`) }}</button>
  63. <view class="coupons" v-if="couponList.length">
  64. <view class="title acea-row row-center-wrapper">
  65. <view class="line"></view>
  66. <view class="name">{{ $t(`赠送优惠券`) }}</view>
  67. <view class="line"></view>
  68. </view>
  69. <view class="list">
  70. <view class="item acea-row row-between-wrapper" v-for="(item, index) in couponList" :key="index" v-if="index < 2 || !couponsHidden">
  71. <view class="moneyCon acea-row row-between-wrapper">
  72. <view class="price acea-row row-center-wrapper">
  73. <view>
  74. {{ $t(`¥`) }}
  75. <text>{{ item.coupon_price }}</text>
  76. </view>
  77. </view>
  78. </view>
  79. <view class="text">
  80. <view class="name line1">{{ item.coupon_title }}</view>
  81. <view class="priceMin">{{ $t(`满`) }}{{ item.use_min_price }}{{ $t(`元可用`) }}</view>
  82. <view class="time">{{ $t(`有效期`) }}:{{ item.add_time ? item.add_time + '-' : '' }}{{ item.end_time }}</view>
  83. </view>
  84. </view>
  85. <view class="open acea-row row-center-wrapper" @click="openTap" v-if="couponList.length > 2">
  86. {{ couponsHidden ? $t(`更多`) : $t(`关闭`) }}
  87. <text class="iconfont" :class="couponsHidden == true ? 'icon-xiangxia' : 'icon-xiangshang'"></text>
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. <lotteryModel
  93. v-show="orderLottery && order_pay_info.paid && loading && lotteryLoading && !is_gift"
  94. :options="options"
  95. @orderDetails="goOrderDetails"
  96. @lotteryShow="getOrderLottery"
  97. ></lotteryModel>
  98. <giftModal :aleartStatus="giftModalShow" :giftData="giftData" @shareH5="shareH5" @close="giftModalShow = false"></giftModal>
  99. <view class="mask" v-if="giftModalShow"></view>
  100. <canvas class="canvas" canvas-id="posterCanvas"></canvas>
  101. <view class="share-box" v-if="H5ShareBox">
  102. <image :src="imgHost + '/statics/images/share-info.png'" @click="H5ShareBox = false"></image>
  103. </view>
  104. </view>
  105. </template>
  106. <script>
  107. import { userShare } from '@/api/user.js';
  108. import lotteryModel from './payLottery.vue';
  109. import giftModal from './components/giftModal.vue';
  110. import { getOrderDetail, orderCoupon } from '@/api/order.js';
  111. import { openOrderSubscribe } from '@/utils/SubscribeMessage.js';
  112. import { toLogin } from '@/libs/login.js';
  113. import { mapGetters } from 'vuex';
  114. // #ifdef MP
  115. import authorize from '@/components/Authorize';
  116. // #endif
  117. import colors from '@/mixins/color';
  118. import { HTTP_REQUEST_URL } from '@/config/app';
  119. export default {
  120. components: {
  121. lotteryModel,
  122. giftModal,
  123. // #ifdef MP
  124. authorize
  125. // #endif
  126. },
  127. mixins: [colors],
  128. data() {
  129. return {
  130. imgHost: HTTP_REQUEST_URL,
  131. loading: false,
  132. lotteryLoading: false,
  133. orderLottery: false,
  134. orderId: '',
  135. order_pay_info: {
  136. paid: 1,
  137. _status: {}
  138. },
  139. isAuto: false, //没有授权的不会自动授权
  140. isShowAuth: false, //是否隐藏授权
  141. status: 0,
  142. msg: '',
  143. couponsHidden: true,
  144. couponList: [],
  145. options: null,
  146. payType: '',
  147. giftData: {},
  148. giftModalShow: false,
  149. H5ShareBox: false,
  150. is_gift: 0,
  151. storeInfo: {},
  152. mpGiftImg: HTTP_REQUEST_URL + '/statics/images/gift_share.jpg'
  153. };
  154. },
  155. computed: mapGetters(['isLogin']),
  156. watch: {
  157. isLogin: {
  158. handler: function (newV, oldV) {
  159. if (newV) {
  160. this.getOrderPayInfo();
  161. }
  162. },
  163. deep: true
  164. }
  165. },
  166. onLoad(options) {
  167. this.options = options;
  168. if (!options.order_id)
  169. return this.$util.Tips(
  170. {
  171. title: this.$t(`缺少参数无法查看订单支付状态`)
  172. },
  173. {
  174. tab: 3,
  175. url: 1
  176. }
  177. );
  178. this.orderId = options.order_id;
  179. this.status = options.status || 0;
  180. this.msg = options.msg || '';
  181. this.payType = options.payType || '';
  182. // // #ifdef H5
  183. // document.addEventListener('visibilitychange', (e) => {
  184. // let state = document.visibilityState
  185. // if (state == 'hidden') {
  186. // console.log('用户离开了');
  187. // }
  188. // if (state == 'visible') {
  189. // this.getOrderPayInfo();
  190. // }
  191. // });
  192. // // #endif
  193. },
  194. onShow() {
  195. if (this.isLogin) {
  196. this.getOrderPayInfo();
  197. } else {
  198. toLogin();
  199. }
  200. },
  201. /**
  202. * 用户点击右上角分享
  203. */
  204. // #ifdef MP
  205. onShareAppMessage: function () {
  206. let that = this;
  207. userShare();
  208. return {
  209. title: that.giftData.message || '',
  210. imageUrl: that.mpGiftImg || '',
  211. path: '/pages/goods/receive_gift/index?id=' + this.giftData.id + '&spid=' + this.$store.state.app.uid
  212. };
  213. },
  214. onShareTimeline() {
  215. let that = this;
  216. userShare();
  217. return {
  218. title: that.giftData.message,
  219. query: {
  220. id: that.id,
  221. spid: that.uid || 0
  222. },
  223. imageUrl: that.mpGiftImg
  224. };
  225. },
  226. // #endif
  227. methods: {
  228. // #ifdef H5
  229. setOpenShare() {
  230. let that = this;
  231. if (that.$wechat.isWeixin()) {
  232. let configAppMessage = {
  233. desc: this.giftData.message,
  234. title: this.giftData.title,
  235. link: window.location.protocol + '//' + window.location.host + '/pages/goods/receive_gift/index?id=' + this.giftData.id + '&spid=' + that.$store.state.app.uid,
  236. imgUrl: that.mpGiftImg
  237. };
  238. that.$wechat
  239. .wechatEvevt(['updateAppMessageShareData', 'updateTimelineShareData', 'onMenuShareAppMessage', 'onMenuShareTimeline'], configAppMessage)
  240. .then((res) => {})
  241. .catch((res) => {
  242. if (res.is_ready) {
  243. res.wx.updateAppMessageShareData(configAppMessage);
  244. res.wx.updateTimelineShareData(configAppMessage);
  245. res.wx.onMenuShareAppMessage(configAppMessage);
  246. res.wx.onMenuShareTimeline(configAppMessage);
  247. }
  248. });
  249. }
  250. },
  251. // #endif
  252. shareH5() {
  253. // this.giftModalShow = false;
  254. this.H5ShareBox = true;
  255. },
  256. getOrderLottery(status) {
  257. this.orderLottery = status;
  258. this.lotteryLoading = true;
  259. },
  260. openTap() {
  261. this.$set(this, 'couponsHidden', !this.couponsHidden);
  262. },
  263. onLoadFun: function () {
  264. this.getOrderPayInfo();
  265. },
  266. /**
  267. *
  268. * 支付完成查询支付状态
  269. *
  270. */
  271. getOrderPayInfo: function () {
  272. let that = this;
  273. uni.showLoading({
  274. title: that.$t(`正在加载中`)
  275. });
  276. getOrderDetail(that.orderId)
  277. .then((res) => {
  278. uni.hideLoading();
  279. that.$set(that, 'order_pay_info', res.data);
  280. uni.setNavigationBarTitle({
  281. title: res.data.paid ? that.$t(`支付成功`) : that.$t(`未支付`)
  282. });
  283. this.loading = true;
  284. if (res.data.paid && res.data.is_gift) {
  285. this.storeInfo = res.data.cartInfo[0].productInfo;
  286. this.is_gift = res.data.is_gift;
  287. }
  288. this.giftData = {
  289. image: res.data.cartInfo[0].productInfo.image,
  290. title: res.data.cartInfo[0].productInfo.store_name,
  291. message: res.data.gift_mark,
  292. id: res.data.id,
  293. avatar: res.data.avatar,
  294. nickname: res.data.nickname,
  295. code: res.data.gift_code
  296. };
  297. // #ifdef H5
  298. if (this.is_gift) this.setOpenShare();
  299. // #endif
  300. this.getOrderCoupon();
  301. })
  302. .catch((err) => {
  303. this.loading = true;
  304. uni.hideLoading();
  305. });
  306. },
  307. getOrderCoupon() {
  308. let that = this;
  309. orderCoupon(that.orderId).then((res) => {
  310. that.couponList = res.data;
  311. });
  312. },
  313. /**
  314. * 去首页关闭当前所有页面
  315. */
  316. goIndex: function (e) {
  317. uni.switchTab({
  318. url: '/pages/index/index'
  319. });
  320. },
  321. // 去参团页面;
  322. goPink: function (id) {
  323. uni.navigateTo({
  324. url: '/pages/activity/goods_combination_status/index?id=' + id
  325. });
  326. },
  327. /**
  328. *
  329. * 去订单详情页面
  330. */
  331. goOrderDetails: function (e) {
  332. let that = this;
  333. // #ifdef MP
  334. uni.showLoading({
  335. title: that.$t(`正在加载中`)
  336. });
  337. openOrderSubscribe()
  338. .then((res) => {
  339. uni.hideLoading();
  340. uni.redirectTo({
  341. url: '/pages/goods/order_details/index?order_id=' + that.orderId
  342. });
  343. })
  344. .catch(() => {
  345. nui.hideLoading();
  346. });
  347. // #endif
  348. // #ifndef MP
  349. uni.redirectTo({
  350. url: '/pages/goods/order_details/index?order_id=' + that.orderId
  351. });
  352. // #endif
  353. }
  354. }
  355. };
  356. </script>
  357. <style lang="scss">
  358. .canvas {
  359. width: 750rpx;
  360. height: 1108rpx;
  361. z-index: 9999;
  362. position: absolute;
  363. bottom: 40000rpx;
  364. right: 30000rpx;
  365. }
  366. .coupons {
  367. .title {
  368. margin: 30rpx 0 25rpx 0;
  369. font-size: 28rpx;
  370. color: #333333;
  371. }
  372. .list {
  373. padding: 0 20rpx;
  374. .item {
  375. margin-bottom: 20rpx;
  376. box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.06);
  377. .price {
  378. width: 236rpx;
  379. height: 160rpx;
  380. font-size: 26rpx;
  381. color: #fff;
  382. font-weight: 800;
  383. text {
  384. font-size: 54rpx;
  385. }
  386. }
  387. .text {
  388. width: 385rpx;
  389. .name {
  390. font-size: #282828;
  391. font-size: 30rpx;
  392. }
  393. .priceMin {
  394. font-size: 24rpx;
  395. color: #999;
  396. margin-top: 10rpx;
  397. }
  398. .time {
  399. font-size: 24rpx;
  400. color: #999;
  401. margin-top: 15rpx;
  402. }
  403. }
  404. }
  405. .open {
  406. font-size: 24rpx;
  407. color: #999;
  408. margin-top: 30rpx;
  409. .iconfont {
  410. font-size: 25rpx;
  411. margin: 5rpx 0 0 10rpx;
  412. }
  413. }
  414. }
  415. }
  416. .payment-status {
  417. background-color: #fff;
  418. margin: 195rpx 30rpx 0 30rpx;
  419. border-radius: 10rpx;
  420. padding: 1rpx 0 28rpx 0;
  421. }
  422. .payment-status .icons {
  423. font-size: 70rpx;
  424. width: 140rpx;
  425. height: 140rpx;
  426. border-radius: 50%;
  427. color: #fff;
  428. text-align: center;
  429. line-height: 140rpx;
  430. text-shadow: 0px 4px 0px rgba(255, 255, 255, 0.5);
  431. border: 6rpx solid #f5f5f5;
  432. margin: -76rpx auto 0 auto;
  433. background-color: #999;
  434. }
  435. .payment-status .icons.icon-iconfontguanbi {
  436. text-shadow: 0px 4px 0px #6c6d6d;
  437. }
  438. .payment-status .iconfont.fail {
  439. text-shadow: 0px 4px 0px #7a7a7a;
  440. }
  441. .payment-status .status {
  442. font-size: 32rpx;
  443. font-weight: bold;
  444. text-align: center;
  445. margin: 25rpx 0 37rpx 0;
  446. }
  447. .payment-status .wrapper {
  448. border: 1rpx solid #eee;
  449. margin: 0 30rpx 47rpx 30rpx;
  450. padding: 35rpx 0;
  451. border-left: 0;
  452. border-right: 0;
  453. }
  454. .payment-status .wrapper .item {
  455. font-size: 28rpx;
  456. color: #282828;
  457. }
  458. .payment-status .wrapper .item ~ .item {
  459. margin-top: 20rpx;
  460. }
  461. .payment-status .wrapper .item .itemCom {
  462. color: #666;
  463. }
  464. .payment-status .returnBnt {
  465. width: 630rpx;
  466. height: 86rpx;
  467. border-radius: 50rpx;
  468. color: #fff;
  469. font-size: 30rpx;
  470. text-align: center;
  471. line-height: 86rpx;
  472. margin: 0 auto 20rpx auto;
  473. }
  474. .share-box {
  475. z-index: 1000;
  476. position: fixed;
  477. left: 0;
  478. top: 0;
  479. width: 100%;
  480. height: 100%;
  481. image {
  482. width: 100%;
  483. height: 100%;
  484. }
  485. }
  486. </style>