index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. <template>
  2. <view :style="colorStyle">
  3. <view class="w-full relative z-99 bg-gradient " :style="{'padding-top': sysHeight + 'px'}">
  4. <view class="w-full px-20 pl-20 h-80 flex-between-center" @tap="goIndex()">
  5. <text class="iconfont icon-ic_leftarrow fs-40 text--w111-fff"></text>
  6. <text class="fs-34 fw-500 text--w111-fff">订单支付</text>
  7. <text></text>
  8. </view>
  9. <view class="flex-col flex-center mt-50">
  10. <view class="flex-y-center">
  11. <text class="iconfont icon-ic-complete1 fs-52 text--w111-fff"
  12. v-if="order_pay_info.paid || order_pay_info.pay_type == 'offline'"></text>
  13. <view v-else class="iconfont icon-ic_close1 fs-52 text--w111-fff"></view>
  14. <text class="fs-40 fw-500 text--w111-fff pl-16" v-if="order_pay_info.pay_type == 'offline' && !order_pay_info.paid">订单创建成功</text>
  15. <text class="fs-40 fw-500 text--w111-fff pl-16" v-else>{{order_pay_info.paid ? '订单支付成功':'等待支付...'}}</text>
  16. </view>
  17. <view class="flex-center mt-30">
  18. <view class="w-192 h-64 rd-40rpx flex-center fs-24 text--w111-fff white-border" @tap="goIndex">返回首页</view>
  19. <view class="w-192 h-64 rd-40rpx flex-center fs-24 text--w111-fff white-border ml-48" @tap="goOrderDetails">查看订单</view>
  20. </view>
  21. </view>
  22. <view class="h-216"></view>
  23. </view>
  24. <view class="relative content bg--w111-fff w-full pt-32 pl-20 pr-20">
  25. <view class="card bg--w111-fff rd-24rpx h-468 pl-20 pr-20"
  26. v-if="order_pay_info.paid && order_pay_info.pay_type != 'offline' && loading && lotteryLoading">
  27. <gridsLottery :prizeData="prize" @get_winingIndex='getWiningIndex'
  28. @luck_draw_finish='luck_draw_finish' :lotteryNum="lottery_num" :lotteryType='1' :datatime="datatime">
  29. </gridsLottery>
  30. </view>
  31. <view class="card bg--w111-fff rd-24rpx px-32" v-if="showGift">
  32. <view class="cell flex-between-center py-32" v-for="(item,index) in couponList" :key="index + 'n'" @click="goPage(1,'/pages/users/user_coupon/index')">
  33. <view class="flex-y-center">
  34. <image :src="imgHost + '/statics/images/order/prize_coupon_icon.png'" class="w-76 h-76 rd-40rpx"></image>
  35. <view class="ml-24">
  36. <view class="fs-28 text--w111-333 lh-38rpx">下单得{{item.coupon_price}}元优惠券</view>
  37. <view class="fs-22 text--w111-999 lh-30rpx mt-8" v-if="parseInt(item.use_min_price > 0)">满{{item.use_min_price}}元可用</view>
  38. <view class="fs-22 text--w111-999 lh-30rpx mt-8" v-else>无门槛优惠券</view>
  39. </view>
  40. </view>
  41. <view class="card_btn flex-center font-color fs-22">去使用</view>
  42. </view>
  43. <view class="cell flex-between-center py-32" v-for="(item,index) in giftList" :key="index + 'o'">
  44. <view class="flex-y-center">
  45. <image :src="imgHost + '/statics/images/order/prize_gift_icon.png'" class="w-76 h-76 rd-40rpx"></image>
  46. <view class="ml-24">
  47. <view class="fs-28 text--w111-333 line2 w-400">{{item.store_name}}</view>
  48. </view>
  49. </view>
  50. <view class="card_btn flex-center font-color fs-22" @tap="goOrderDetails">去使用</view>
  51. </view>
  52. <view class="cell flex-between-center py-32" v-if="prize_integral > 0" @click="goPage(1,'/pages/users/user_integral/index')">
  53. <view class="flex-y-center">
  54. <image :src="imgHost + '/statics/images/order/prize_integral_icon.png'" class="w-76 h-76 rd-40rpx"></image>
  55. <view class="ml-24">
  56. <view class="fs-28 text--w111-333 line2 w-400">获得{{prize_integral}}积分</view>
  57. <view class="fs-22 text--w111-999 lh-30rpx mt-8">下单即可抵扣</view>
  58. </view>
  59. </view>
  60. <view class="card_btn flex-center font-color fs-22" @tap="goOrderDetails">去使用</view>
  61. </view>
  62. <view class="cell flex-between-center py-32" v-if="prize_exp > 0">
  63. <view class="flex-y-center">
  64. <image :src="imgHost + '/statics/images/order/prize_exp_icon.png'" class="w-76 h-76 rd-40rpx"></image>
  65. <view class="ml-24">
  66. <view class="fs-28 text--w111-333 line2 w-400">获得{{prize_exp}}经验</view>
  67. <view class="fs-22 text--w111-999 lh-30rpx mt-8">下单即可抵扣</view>
  68. </view>
  69. </view>
  70. <view class="card_btn flex-center font-color fs-22" @tap="goOrderDetails">去使用</view>
  71. </view>
  72. </view>
  73. <!-- <recommend :hostProduct='hostProduct'></recommend> -->
  74. </view>
  75. <lotteryAleart
  76. :aleartStatus="aleartStatus"
  77. :alData="alData"
  78. theme
  79. :aleartType="aleartType"
  80. @close="closeLottery" >
  81. </lotteryAleart>
  82. <view class="mask" v-if="aleartStatus || addressModel" @touchmove.stop.prevent="moveHandle"></view>
  83. </view>
  84. </template>
  85. <script>
  86. let sysHeight = uni.getSystemInfoSync().statusBarHeight;
  87. // import lotteryModel from './payLottery.vue'
  88. import gridsLottery from '../components/lottery/payLottery.vue';
  89. import lotteryAleart from '../components/lotteryAleart/index.vue'
  90. import recommend from '@/components/recommend';
  91. import { getOrderDetail,orderCoupon, getOrderPrizeApi } from '@/api/order.js';
  92. import { openOrderSubscribe } from '@/utils/SubscribeMessage.js';
  93. import {
  94. getLotteryData,
  95. startLottery,
  96. receiveLottery
  97. } from '@/api/lottery.js';
  98. import { getProductHot, postCartAdd} from '@/api/store.js';
  99. import { toLogin} from '@/libs/login.js';
  100. import { mapGetters } from "vuex";
  101. import colors from "@/mixins/color";
  102. import { HTTP_REQUEST_URL } from '@/config/app';
  103. export default {
  104. components: {
  105. gridsLottery,
  106. lotteryAleart,
  107. recommend
  108. },
  109. mixins: [colors],
  110. data() {
  111. return {
  112. imgHost: HTTP_REQUEST_URL,
  113. sysHeight: sysHeight,
  114. loading: false,
  115. lotteryLoading: false,
  116. orderLottery: false,
  117. orderId: '',
  118. order_pay_info: {
  119. paid: 1,
  120. _status: {}
  121. },
  122. isAuto: false, //没有授权的不会自动授权
  123. isShowAuth: false, //是否隐藏授权
  124. status: 0,
  125. msg: '',
  126. couponsHidden: true,
  127. couponList: [],
  128. giftList:[],
  129. options: {},
  130. prize: [],
  131. datatime:0,
  132. totalPrice: 0,
  133. type:'',
  134. lottery_draw_param: {
  135. startIndex: 3, //开始抽奖位置,从0开始
  136. totalCount: 3, //一共要转的圈数
  137. winingIndex: 1, //中奖的位置,从0开始
  138. speed: 100 //抽奖动画的速度 [数字越大越慢,默认100]
  139. },
  140. aleartType: 0,
  141. aleartStatus: false,
  142. addressModel:false,
  143. lottery_num:0,
  144. alData: {},
  145. hostProduct:[],
  146. hotScroll: false,
  147. hotPage: 1,
  148. hotLimit: 10,
  149. prize_integral:0,
  150. prize_exp:0,
  151. };
  152. },
  153. computed: {
  154. ...mapGetters(['isLogin', 'cartNum']),
  155. showGift(){
  156. if(!this.couponList.length && !this.giftList.length && this.prize_integral == 0 && this.prize_exp == 0){
  157. return false
  158. }else{
  159. return true
  160. }
  161. }
  162. },
  163. watch: {
  164. isLogin: {
  165. handler: function(newV, oldV) {
  166. if (newV) {
  167. //#ifndef MP
  168. this.getOrderPayInfo();
  169. //#endif
  170. }
  171. },
  172. deep: true
  173. }
  174. },
  175. onLoad: function(options) {
  176. this.options = options
  177. if (!options.order_id) return this.$util.Tips({
  178. title: '缺少参数无法查看订单支付状态'
  179. }, {
  180. tab: 3,
  181. url: 1
  182. });
  183. this.orderId = options.order_id;
  184. this.status = options.status || 0;
  185. this.msg = options.msg || '';
  186. this.type = this.options.type;
  187. this.totalPrice = this.options.totalPrice;
  188. this.getLotteryData(this.type);
  189. this.getHostProduct();
  190. },
  191. onShow() {
  192. uni.setStorageSync('form_type_cart', 1);
  193. if (this.isLogin) {
  194. this.getOrderPayInfo();
  195. } else {
  196. toLogin()
  197. }
  198. },
  199. methods: {
  200. moveHandle(){
  201. return false
  202. },
  203. // 授权关闭
  204. authColse: function(e) {
  205. this.isShowAuth = e
  206. },
  207. openTap() {
  208. this.$set(this, 'couponsHidden', !this.couponsHidden);
  209. },
  210. onLoadFun: function() {
  211. this.getOrderPayInfo();
  212. this.isShowAuth = false;
  213. },
  214. /**
  215. *
  216. * 支付完成查询支付状态
  217. *
  218. */
  219. getOrderPayInfo: function() {
  220. let that = this;
  221. uni.showLoading({
  222. title: '正在加载中'
  223. });
  224. getOrderDetail(that.orderId).then(res => {
  225. uni.hideLoading();
  226. that.$set(that, 'order_pay_info', res.data);
  227. uni.setNavigationBarTitle({
  228. title: res.data.paid ? '支付成功' : '未支付'
  229. });
  230. uni.$emit('newCartNum',res.data.cartInfo);
  231. if(parseInt(uni.getStorageSync('news')) === 0){
  232. let colNum = this.cartNum - res.data.total_num;
  233. this.$store.commit('indexData/setCartNum', colNum +'');
  234. uni.removeStorageSync('news')
  235. }
  236. this.loading = true
  237. setTimeout(function(){
  238. that.getOrderPrize()
  239. }, 1000);
  240. }).catch(err => {
  241. this.loading = true
  242. uni.hideLoading();
  243. });
  244. },
  245. getOrderPrize() {
  246. getOrderPrizeApi(this.orderId).then(res=>{
  247. this.couponList = res.data.coupons;
  248. this.giftList = res.data.gift;
  249. this.prize_integral =res.data.integral;
  250. this.prize_exp =res.data.exp;
  251. });
  252. },
  253. /**
  254. * 去首页关闭当前所有页面
  255. */
  256. goIndex: function(e) {
  257. uni.switchTab({
  258. url: '/pages/index/index'
  259. });
  260. },
  261. // 去参团页面;
  262. goPink: function(id) {
  263. uni.navigateTo({
  264. url: '/pages/activity/goods_combination_status/index?id=' + id
  265. });
  266. },
  267. /**
  268. *
  269. * 去订单详情页面
  270. */
  271. goOrderDetails: function(e) {
  272. let that = this;
  273. // #ifdef MP
  274. uni.showLoading({
  275. title: '正在加载',
  276. })
  277. openOrderSubscribe().then(res => {
  278. uni.hideLoading();
  279. uni.navigateTo({
  280. url: '/pages/goods/order_details/index?order_id=' + that.orderId
  281. });
  282. }).catch(() => {
  283. nui.hideLoading();
  284. });
  285. // #endif
  286. // #ifndef MP
  287. uni.navigateTo({
  288. url: '/pages/goods/order_details/index?order_id=' + that.orderId
  289. })
  290. // #endif
  291. },
  292. getLotteryData(type) {
  293. getLotteryData(type).then(res => {
  294. this.factor_num = res.data.lottery.factor_num
  295. this.id = res.data.lottery.id
  296. this.prize = res.data.lottery.prize
  297. this.lottery_num = res.data.lottery_num
  298. this.prize.push({
  299. a: 1
  300. })
  301. this.lotteryLoading = true;
  302. this.datatime = parseInt(res.data.cache_time);
  303. if(res.data.lottery.type == 6){
  304. uni.navigateTo({
  305. url:"/pages/goods/lottery/grids/record"
  306. })
  307. }
  308. }).catch(err => {
  309. this.lotteryLoading = false;
  310. })
  311. },
  312. getWiningIndex(callback){
  313. this.aleartType = 0
  314. startLottery({
  315. id: this.id
  316. }).then(res => {
  317. this.prize.forEach((item, index) => {
  318. if (res.data.id === item.id) {
  319. this.alData = res.data
  320. this.lottery_draw_param.winingIndex = index;
  321. callback(this.lottery_draw_param);
  322. }
  323. })
  324. }).catch(err => {
  325. this.$util.Tips({
  326. title: err
  327. });
  328. })
  329. },
  330. // 抽奖完成
  331. luck_draw_finish(param) {
  332. this.aleartType = 2
  333. this.aleartStatus = true
  334. },
  335. closeLottery(status) {
  336. this.aleartStatus = false;
  337. if (this.alData.type === 6) {
  338. postCartAdd({
  339. cartNum: 1,
  340. new: 1,
  341. is_new: 1,
  342. productId: this.alData.product_id,
  343. uniqueId: this.alData.unique,
  344. luckRecordId: this.alData.lottery_record_id,
  345. }).then(res => {
  346. uni.navigateTo({
  347. url: `/pages/goods/order_confirm/index?new=1&luckRecordId=${this.alData.lottery_record_id}&cartId=${res.data.cartId}&product_id=${this.alData.product_id}`
  348. });
  349. }).catch(err => {
  350. this.$util.Tips({
  351. title: `${err},请联系客服`
  352. });
  353. });
  354. }
  355. this.getLotteryData(this.type)
  356. },
  357. getHostProduct: function() {
  358. let that = this;
  359. if (that.hotScroll) return
  360. getProductHot(
  361. that.hotPage,
  362. that.hotLimit,
  363. ).then(res => {
  364. that.hotPage++
  365. that.hotScroll = res.data.length < that.hotLimit
  366. that.hostProduct = that.hostProduct.concat(res.data)
  367. });
  368. },
  369. goPage(type, url){
  370. if(type == 1){
  371. uni.navigateTo({
  372. url
  373. })
  374. }else if(type == 2){
  375. uni.switchTab({
  376. url
  377. })
  378. }else if(type == 3){
  379. uni.navigateBack();
  380. }
  381. }
  382. },
  383. onPageScroll(e) {
  384. uni.$emit('scroll');
  385. },
  386. }
  387. </script>
  388. <style>
  389. .fs-52{
  390. font-size:52rpx;
  391. }
  392. .white-border{
  393. border: 1rpx solid #fff;
  394. }
  395. .ml-48{
  396. margin-left: 48rpx;
  397. }
  398. .h-216{
  399. height:216rpx;
  400. }
  401. .content{
  402. background: #f5f5f5;
  403. border-radius: 40rpx 40rpx 0 0;
  404. left:0;
  405. top: -164rpx;
  406. min-height:500rpx;
  407. }
  408. .card ~ .card{
  409. margin-top: 20rpx;
  410. }
  411. .h-76{
  412. height:76rpx;
  413. }
  414. .cell ~ .cell {
  415. border-top: 1px solid #eee;
  416. }
  417. .card_btn{
  418. width: 114rpx;
  419. height: 52rpx;
  420. border-radius: 26rpx;
  421. border: 1px solid #E93323;
  422. }
  423. </style>