index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  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-dengdaizhifu' 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 ? (order_pay_info.type == 8 ? '抽奖提交成功' : '订单支付成功'):'等待支付...'}}
  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. >返回首页</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. <!-- #ifdef MP -->
  89. <!-- <authorize v-if="isShowAuth" @authColse="authColse" @onLoadFun="onLoadFun"></authorize> -->
  90. <!-- #endif -->
  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. import colors from "@/mixins/color";
  109. export default {
  110. components: {
  111. lotteryModel
  112. },
  113. mixins: [colors],
  114. data() {
  115. return {
  116. loading: false,
  117. lotteryLoading: false,
  118. orderLottery: false,
  119. orderId: '',
  120. order_pay_info: {
  121. paid: 1,
  122. _status: {}
  123. },
  124. isAuto: false, //没有授权的不会自动授权
  125. isShowAuth: false, //是否隐藏授权
  126. status: 0,
  127. msg: '',
  128. couponsHidden: true,
  129. couponList: [],
  130. options: {}
  131. };
  132. },
  133. computed: mapGetters(['isLogin', 'cartNum']),
  134. watch: {
  135. isLogin: {
  136. handler: function(newV, oldV) {
  137. if (newV) {
  138. this.getOrderPayInfo();
  139. }
  140. },
  141. deep: true
  142. }
  143. },
  144. onLoad: function(options) {
  145. this.options = options
  146. if (!options.order_id) return this.$util.Tips({
  147. title: '缺少参数无法查看订单支付状态'
  148. }, {
  149. tab: 3,
  150. url: 1
  151. });
  152. this.orderId = options.order_id;
  153. this.status = options.status || 0;
  154. this.msg = options.msg || '';
  155. },
  156. onShow() {
  157. uni.setStorageSync('form_type_cart', 1);
  158. if (this.isLogin) {
  159. this.getOrderPayInfo();
  160. } else {
  161. toLogin();
  162. }
  163. },
  164. methods: {
  165. // 授权关闭
  166. authColse: function(e) {
  167. this.isShowAuth = e
  168. },
  169. getOrderLottery(status) {
  170. this.orderLottery = status
  171. this.lotteryLoading = true
  172. },
  173. openTap() {
  174. this.$set(this, 'couponsHidden', !this.couponsHidden);
  175. },
  176. onLoadFun: function() {
  177. this.getOrderPayInfo();
  178. this.isShowAuth = false;
  179. },
  180. /**
  181. *
  182. * 支付完成查询支付状态
  183. *
  184. */
  185. getOrderPayInfo: function() {
  186. let that = this;
  187. uni.showLoading({
  188. title: '正在加载中'
  189. });
  190. getOrderDetail(that.orderId).then(res => {
  191. uni.hideLoading();
  192. that.$set(that, 'order_pay_info', res.data);
  193. uni.setNavigationBarTitle({
  194. title: res.data.paid ? '支付成功' : '未支付'
  195. });
  196. uni.$emit('newCartNum',res.data.cartInfo);
  197. if(parseInt(uni.getStorageSync('news')) === 0){
  198. let colNum = this.cartNum - res.data.total_num;
  199. this.$store.commit('indexData/setCartNum', colNum +'');
  200. uni.removeStorageSync('news')
  201. }
  202. this.loading = true
  203. setTimeout(function(){
  204. that.getOrderCoupon()
  205. }, 1000);
  206. }).catch(err => {
  207. this.loading = true
  208. uni.hideLoading();
  209. });
  210. },
  211. getOrderCoupon() {
  212. let that = this;
  213. orderCoupon(that.orderId).then(res => {
  214. that.couponList = res.data;
  215. })
  216. },
  217. /**
  218. * 去首页关闭当前所有页面
  219. */
  220. goIndex: function(e) {
  221. uni.switchTab({
  222. url: '/pages/index/index'
  223. });
  224. },
  225. // 去参团页面;
  226. goPink: function(id) {
  227. uni.navigateTo({
  228. url: '/pages/activity/goods_combination_status/index?id=' + id
  229. });
  230. },
  231. /**
  232. *
  233. * 去订单详情页面
  234. */
  235. goOrderDetails: function(e) {
  236. let that = this;
  237. // #ifdef MP
  238. uni.showLoading({
  239. title: '正在加载',
  240. })
  241. openOrderSubscribe().then(res => {
  242. uni.hideLoading();
  243. uni.navigateTo({
  244. url: '/pages/goods/order_details/index?order_id=' + that.orderId
  245. });
  246. }).catch(() => {
  247. nui.hideLoading();
  248. });
  249. // #endif
  250. // #ifndef MP
  251. uni.navigateTo({
  252. url: '/pages/goods/order_details/index?order_id=' + that.orderId
  253. })
  254. // #endif
  255. }
  256. }
  257. }
  258. </script>
  259. <style lang="scss">
  260. .coupons {
  261. .title {
  262. margin: 30rpx 0 25rpx 0;
  263. .line {
  264. width: 70rpx;
  265. height: 1px;
  266. background: #DCDCDC;
  267. }
  268. .name {
  269. font-size: 24rpx;
  270. color: #999;
  271. margin: 0 10rpx;
  272. }
  273. }
  274. .list {
  275. padding: 0 20rpx;
  276. .item {
  277. margin-bottom: 20rpx;
  278. box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.06);
  279. .price {
  280. width: 236rpx;
  281. height: 160rpx;
  282. font-size: 26rpx;
  283. color: #fff;
  284. font-weight: 800;
  285. text {
  286. font-size: 54rpx;
  287. }
  288. .fontSize{
  289. font-size: 40rpx;
  290. }
  291. }
  292. .text {
  293. width: 385rpx;
  294. .name {
  295. font-size: #282828;
  296. font-size: 30rpx;
  297. }
  298. .priceMin {
  299. font-size: 24rpx;
  300. color: #999;
  301. margin-top: 10rpx;
  302. }
  303. .time {
  304. font-size: 24rpx;
  305. color: #999;
  306. margin-top: 15rpx;
  307. }
  308. }
  309. }
  310. .open {
  311. font-size: 24rpx;
  312. color: #999;
  313. margin-top: 30rpx;
  314. .iconfont {
  315. font-size: 25rpx;
  316. margin: 5rpx 0 0 10rpx;
  317. }
  318. }
  319. }
  320. }
  321. .payment-status {
  322. background-color: #fff;
  323. margin: 195rpx 30rpx 0 30rpx;
  324. border-radius: 10rpx;
  325. padding: 1rpx 0 28rpx 0;
  326. }
  327. .payment-status .icons {
  328. font-size: 70rpx;
  329. width: 140rpx;
  330. height: 140rpx;
  331. border-radius: 50%;
  332. color: #fff;
  333. text-align: center;
  334. line-height: 140rpx;
  335. text-shadow: 0px 4px 0px rgba(255,255,255,0.5);
  336. border: 6rpx solid #f5f5f5;
  337. margin: -76rpx auto 0 auto;
  338. background-color: #999;
  339. &.icon-dengdaizhifu{
  340. background-color: var(--view-theme);
  341. }
  342. }
  343. .payment-status .icons.icon-iconfontguanbi {
  344. text-shadow: 0px 4px 0px #6c6d6d;
  345. }
  346. .payment-status .iconfont.fail {
  347. text-shadow: 0px 4px 0px #7a7a7a;
  348. }
  349. .payment-status .status {
  350. font-size: 32rpx;
  351. font-weight: bold;
  352. text-align: center;
  353. margin: 25rpx 0 37rpx 0;
  354. }
  355. .payment-status .wrapper {
  356. border: 1rpx solid #eee;
  357. margin: 0 30rpx 47rpx 30rpx;
  358. padding: 35rpx 0;
  359. border-left: 0;
  360. border-right: 0;
  361. }
  362. .payment-status .wrapper .item {
  363. font-size: 28rpx;
  364. color: #282828;
  365. }
  366. .payment-status .wrapper .item~.item {
  367. margin-top: 20rpx;
  368. }
  369. .payment-status .wrapper .item .itemCom {
  370. color: #666;
  371. }
  372. .payment-status .returnBnt {
  373. width: 630rpx;
  374. height: 86rpx;
  375. border-radius: 50rpx;
  376. color: #fff;
  377. font-size: 30rpx;
  378. text-align: center;
  379. line-height: 86rpx;
  380. margin: 0 auto 20rpx auto;
  381. }
  382. </style>