index.vue 10 KB

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