index.vue 12 KB

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