index.vue 11 KB

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