index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. <template>
  2. <view>
  3. <view class='my-order'>
  4. <view class='list'>
  5. <!-- 代付款 -->
  6. <view class='item' v-for="(item,index) in orderList" :key="index">
  7. <view @click='goOrderDetails(item.order_id)'>
  8. <view class='title acea-row row-between-wrapper'>
  9. <view class="acea-row row-middle left-wrapper">
  10. <text class="iconfont icon-shangjiadingdan"></text>
  11. <view class="store-name">{{item.merchant.mer_name}}</view>
  12. <text class="iconfont icon-xiangyou"></text>
  13. </view>
  14. <view v-if="item.presellOrder.activeStatus === 1" class='font-color'>等待买家付尾款</view>
  15. <view v-if="item.presellOrder.activeStatus === 0" class='font-color'>未开始</view>
  16. <view v-if="item.presellOrder.activeStatus === 2" class='font-color'>交易已关闭</view>
  17. </view>
  18. <block v-for="(goods,g) in item.orderProduct">
  19. <!--预售-->
  20. <view class='item-info acea-row row-between row-top'>
  21. <view class='pictrue'>
  22. <image :src='(goods.cart_info.productAttr && goods.cart_info.productAttr.image) || goods.cart_info.product.image'></image>
  23. </view>
  24. <view class='text acea-row row-between'>
  25. <view class='name line1'>
  26. <text class="event_name event_bg">预售</text><text>{{goods.cart_info.product.store_name}}</text>
  27. <view class="event_ship event_color">发货时间:
  28. <!--全款预售-->
  29. <text v-if="goods.cart_info.productPresell.presell_type === 1">{{ goods.cart_info.productPresell.delivery_type === 1 ? '支付成功后' : '预售结束后' }}{{ goods.cart_info.productPresell.delivery_day }}天内</text>
  30. <!--定金预售-->
  31. <text v-if="goods.cart_info.productPresell.presell_type === 2">{{ goods.cart_info.productPresell.delivery_type === 1 ? '支付尾款后' : '预售结束后' }}{{ goods.cart_info.productPresell.delivery_day }}天内</text>
  32. </view>
  33. </view>
  34. <view class='money'>
  35. <view>¥{{goods.cart_info.productPresellAttr.presell_price}}</view>
  36. <view>x{{goods.product_num}}</view>
  37. </view>
  38. </view>
  39. <view v-if="goods.cart_info.productPresell.presell_type === 2" class="event_price">
  40. <text class="color_gray">定金已支付 <text>¥{{ item.pay_price }},</text></text>
  41. 尾款待支付 <text class="font-color">¥{{ item.presellOrder.pay_price }}</text>
  42. </view>
  43. </view>
  44. </block>
  45. <view class='bottom acea-row row-right row-middle'>
  46. <view v-if="item.presellOrder.activeStatus === 2" class='bnt cancelBnt' @click.stop='cancelOrder(index,item.order_id)'>取消订单</view>
  47. <view v-if="item.presellOrder.activeStatus === 1" class='bnt bg-color' @click.stop='goPay(item.presellOrder.pay_price,item.order_id)'>立即付款</view>
  48. <view v-if="item.presellOrder.activeStatus === 0" class='bnt bg-color btn_auto'>未开始</view>
  49. <view v-if="item.presellOrder.activeStatus === 2" class='bnt bg-color'>交易已关闭</view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <view class='loadingicon acea-row row-center-wrapper' v-if="orderList.length>5">
  55. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  56. </view>
  57. <view v-if="orderList.length == 0">
  58. <emptyPage title="暂无订单~"></emptyPage>
  59. </view>
  60. </view>
  61. <!-- #ifdef MP -->
  62. <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize>
  63. <!-- #endif -->
  64. <payment :payMode='payMode' :pay_close="pay_close" @onChangeFun='onChangeFun' :order_id="pay_order_id" :totalPrice='totalPrice' :order_type='1'></payment>
  65. </view>
  66. </template>
  67. <script>
  68. let app = getApp();
  69. import {
  70. getOrderList,
  71. orderData,
  72. unOrderCancel,
  73. orderDel,
  74. orderPay,
  75. groupOrderList,
  76. orderTake
  77. } from '@/api/order.js';
  78. import {
  79. getUserInfo
  80. } from '@/api/user.js';
  81. import {
  82. openOrderSubscribe
  83. } from '@/utils/SubscribeMessage.js';
  84. import payment from '@/components/payment';
  85. import {
  86. toLogin
  87. } from '@/libs/login.js';
  88. import {
  89. getconfig,
  90. } from '@/api/public.js'
  91. import {
  92. mapGetters
  93. } from "vuex";
  94. // #ifdef MP
  95. import authorize from '@/components/Authorize';
  96. // #endif
  97. import emptyPage from '@/components/emptyPage.vue'
  98. export default {
  99. components: {
  100. payment,
  101. emptyPage,
  102. // #ifdef MP
  103. authorize
  104. // #endif
  105. },
  106. data() {
  107. return {
  108. loading: false, //是否加载中
  109. loadend: false, //是否加载完毕
  110. loadTitle: '加载更多', //提示语
  111. orderList: [], //订单数组
  112. orderData: {}, //订单详细统计
  113. orderStatus: 0, //订单状态
  114. page: 1,
  115. limit: 20,
  116. payMode: [{
  117. name: "微信支付",
  118. icon: "icon-weixinzhifu",
  119. value: 'wechat',
  120. title: '微信快捷支付',
  121. payStatus: 1
  122. },
  123. {
  124. name: "支付宝支付",
  125. icon: "icon-zhifubao",
  126. value: 'alipay',
  127. title: '支付宝支付',
  128. payStatus: app.globalData.alipay_open
  129. },
  130. {
  131. name: "余额支付",
  132. icon: "icon-yuezhifu",
  133. value: 'balance',
  134. title: '可用余额:',
  135. number: 0,
  136. payStatus: app.globalData.yue_pay_status
  137. }
  138. ],
  139. pay_close: false,
  140. pay_order_id: '',
  141. totalPrice: '0',
  142. isAuto: false, //没有授权的不会自动授权
  143. isShowAuth: false ,//是否隐藏授权
  144. isTimePay: false
  145. };
  146. },
  147. computed: mapGetters(['isLogin']),
  148. onShow() {
  149. if (this.isLogin) {
  150. this.$set(this, 'orderList', []);
  151. this.page = 1;
  152. this.loadend = false;
  153. this.loading = false;
  154. this.getOrderList();
  155. this.getUserInfo();
  156. } else {
  157. // #ifdef H5 || APP-PLUS
  158. toLogin();
  159. // #endif
  160. // #ifdef MP
  161. this.isAuto = true;
  162. this.$set(this, 'isShowAuth', true);
  163. // #endif
  164. }
  165. },
  166. methods: {
  167. onLoadFun() {
  168. this.isShowAuth = false;
  169. this.getOrderList();
  170. this.getUserInfo();
  171. },
  172. // 授权关闭
  173. authColse: function(e) {
  174. this.isShowAuth = e
  175. },
  176. /**
  177. * 事件回调
  178. *
  179. */
  180. onChangeFun: function(e) {
  181. let opt = e;
  182. let action = opt.action || null;
  183. let value = opt.value != undefined ? opt.value : null;
  184. (action && this[action]) && this[action](value);
  185. },
  186. /**
  187. * 获取用户信息
  188. *
  189. */
  190. getUserInfo: function() {
  191. let that = this;
  192. getUserInfo().then(res => {
  193. that.payMode[2].number = res.data.now_money;
  194. // that.$set(that, 'payMode', that.payMode);
  195. });
  196. },
  197. /**
  198. * 关闭支付组件
  199. *
  200. */
  201. payClose: function() {
  202. this.pay_close = false;
  203. },
  204. /**
  205. * 生命周期函数--监听页面加载
  206. */
  207. onLoad: function(options) {
  208. if (options.status) this.orderStatus = options.status;
  209. // // 获取配置
  210. // getconfig().then(res => {
  211. // this.payMode[1].yue_pay_status = res.data.yue_pay_status
  212. // this.payMode[2].alipay_open = res.data.alipay_open
  213. // try {
  214. // } catch (e) {
  215. // // error
  216. // }
  217. // // #ifdef H5
  218. // this.setOpenShare(res.data);
  219. // // #endif
  220. // }).catch(err => {})
  221. },
  222. /**
  223. * 获取订单统计数据
  224. *
  225. */
  226. /**
  227. * 取消订单
  228. *
  229. */
  230. cancelOrder: function(index, order_id) {
  231. let that = this;
  232. if (!order_id) return that.$util.Tips({
  233. title: '缺少订单号无法取消订单'
  234. });
  235. orderDel(order_id).then(res => {
  236. return that.$util.Tips({
  237. title: res.message,
  238. icon: 'success'
  239. }, function() {
  240. that.orderList.splice(index, 1);
  241. that.$set(that, 'orderList', that.orderList);
  242. that.$set(that.orderData, 'unpaid_count', that.orderData.unpaid_count - 1);
  243. });
  244. }).catch(err => {
  245. return that.$util.Tips({
  246. title: err
  247. });
  248. });
  249. },
  250. /**
  251. * 打开支付组件
  252. *
  253. */
  254. goPay: function(pay_price, order_id) {
  255. console.log(order_id)
  256. this.$set(this, 'pay_close', true);
  257. this.order_id = order_id;
  258. this.pay_order_id = order_id.toString()
  259. // this.$set(this, 'pay_order_id', );
  260. this.$set(this, 'totalPrice', pay_price);
  261. },
  262. /**
  263. * 支付成功回调
  264. *
  265. */
  266. pay_complete: function() {
  267. this.loadend = false;
  268. this.page = 1;
  269. this.$set(this, 'orderList', []);
  270. this.pay_close = false;
  271. this.pay_order_id = '';
  272. this.getOrderList();
  273. },
  274. /**
  275. * 支付失败回调
  276. *
  277. */
  278. pay_fail: function() {
  279. this.pay_close = false;
  280. this.pay_order_id = '';
  281. },
  282. /**
  283. * 去订单详情
  284. */
  285. goOrderDetails: function(order_id) {
  286. let self = this
  287. if (!order_id) return that.$util.Tips({
  288. title: '缺少订单号无法查看订单详情'
  289. });
  290. // #ifdef MP-WEIXIN
  291. uni.showLoading({
  292. title: '正在加载',
  293. })
  294. openOrderSubscribe().then(() => {
  295. uni.hideLoading();
  296. uni.navigateTo({
  297. url: '/pages/order_details/index?order_id=' + order_id
  298. })
  299. }).catch(() => {
  300. uni.hideLoading();
  301. })
  302. // #endif
  303. // #ifndef MP-WEIXIN
  304. uni.navigateTo({
  305. url: '/pages/order_details/index?order_id=' + order_id
  306. })
  307. // #endif
  308. },
  309. /**
  310. * 获取订单列表
  311. */
  312. getOrderList: function() {
  313. let that = this;
  314. if (that.loadend) return;
  315. if (that.loading) return;
  316. that.loading = true;
  317. that.loadTitle = "加载更多";
  318. getOrderList({
  319. status: 10,
  320. page: that.page,
  321. limit: that.limit,
  322. }).then(res => {
  323. let list = res.data.list || [];
  324. let loadend = list.length < that.limit;
  325. that.orderList = that.$util.SplitArray(list, that.orderList);
  326. that.$set(that, 'orderList', that.orderList);
  327. that.getProductCount();
  328. that.loadend = loadend;
  329. that.loading = false;
  330. that.loadTitle = loadend ? "我也是有底线的" : '加载更多';
  331. that.page = that.page + 1;
  332. }).catch(err => {
  333. that.loading = false;
  334. that.loadTitle = "加载更多";
  335. })
  336. },
  337. /**
  338. * 获取单个订单商品数量
  339. */
  340. getProductCount: function(){
  341. if(this.orderStatus !== 0){
  342. this.orderList.forEach((item,i) => {
  343. let orderNum = 0
  344. item.orderProduct.forEach((val) => {
  345. orderNum += val.product_num
  346. })
  347. this.orderList[i]['orderNum']=orderNum;
  348. })
  349. }
  350. },
  351. /**
  352. * 删除订单
  353. */
  354. delOrder: function(order_id, index) {
  355. let that = this;
  356. orderDel(order_id).then(res => {
  357. that.orderList.splice(index, 1);
  358. that.$set(that, 'orderList', that.orderList);
  359. that.$set(that.orderData, 'unpaid_count', that.orderData.unpaid_count - 1);
  360. return that.$util.Tips({
  361. title: '删除成功',
  362. icon: 'success'
  363. });
  364. }).catch(err => {
  365. return that.$util.Tips({
  366. title: err
  367. });
  368. })
  369. },
  370. // 确认收货
  371. confirmOrder: function(item, index) {
  372. let that = this;
  373. uni.showModal({
  374. title: '确认收货',
  375. content: '为保障权益,请收到货确认无误后,再确认收货',
  376. success: function(res) {
  377. if (res.confirm) {
  378. orderTake(item.order_id).then(res => {
  379. return that.$util.Tips({
  380. title: '操作成功',
  381. icon: 'success'
  382. }, function() {
  383. that.orderList.splice(index, 1);
  384. });
  385. }).catch(err => {
  386. return that.$util.Tips({
  387. title: err
  388. });
  389. })
  390. }
  391. }
  392. })
  393. },
  394. },
  395. onReachBottom: function() {
  396. this.getOrderList();
  397. }
  398. }
  399. </script>
  400. <style scoped lang="scss">
  401. .my-order .header {
  402. height: 260rpx;
  403. padding: 0 30rpx;
  404. }
  405. .my-order .header .picTxt {
  406. height: 190rpx;
  407. }
  408. .my-order .header .picTxt .text {
  409. color: rgba(255, 255, 255, 0.8);
  410. font-size: 26rpx;
  411. font-family: 'Guildford Pro';
  412. }
  413. .my-order .header .picTxt .text .name {
  414. font-size: 34rpx;
  415. font-weight: bold;
  416. color: #fff;
  417. margin-bottom: 20rpx;
  418. }
  419. .my-order .header .picTxt .pictrue {
  420. width: 122rpx;
  421. height: 109rpx;
  422. }
  423. .my-order .header .picTxt .pictrue image {
  424. width: 100%;
  425. height: 100%;
  426. }
  427. .my-order .nav {
  428. background-color: #fff;
  429. width: 690rpx;
  430. height: 140rpx;
  431. border-radius: 6rpx;
  432. margin: -73rpx auto 0 auto;
  433. }
  434. .my-order .nav .item {
  435. text-align: center;
  436. font-size: 26rpx;
  437. color: #282828;
  438. padding: 29rpx 0;
  439. }
  440. .my-order .nav .item.on {
  441. font-weight: bold;
  442. border-bottom: 5rpx solid #e93323;
  443. }
  444. .my-order .nav .item .num {
  445. margin-top: 18rpx;
  446. }
  447. .my-order .list {
  448. width: 690rpx;
  449. margin: 14rpx auto 0 auto;
  450. }
  451. .my-order .list .item {
  452. background-color: #fff;
  453. border-radius: 6rpx;
  454. margin-bottom: 14rpx;
  455. }
  456. .my-order .list .item .title {
  457. height: 84rpx;
  458. padding: 0 30rpx;
  459. border-bottom: 1rpx solid #eee;
  460. font-size: 28rpx;
  461. color: #282828;
  462. .left-wrapper {
  463. .iconfont {
  464. margin-top: 5rpx;
  465. }
  466. .store-name {
  467. margin: 0 10rpx;
  468. }
  469. .icon-xiangyou {
  470. font-size: 20rpx;
  471. }
  472. }
  473. }
  474. .my-order .list .item .title .sign {
  475. font-size: 24rpx;
  476. padding: 0 7rpx;
  477. height: 36rpx;
  478. margin-right: 15rpx;
  479. }
  480. .my-order .list .item .item-info {
  481. padding: 0 30rpx;
  482. margin-top: 22rpx;
  483. }
  484. .my-order .list .item .item-info .pictrue {
  485. width: 120rpx;
  486. height: 120rpx;
  487. }
  488. .my-order .list .item .item-info .pictrue image {
  489. width: 100%;
  490. height: 100%;
  491. border-radius: 6rpx;
  492. }
  493. .my-order .list .item .item-info .text {
  494. width: 486rpx;
  495. font-size: 28rpx;
  496. color: #999;
  497. margin-top: 6rpx;
  498. }
  499. .my-order .list .item .item-info .text .name {
  500. width: 320rpx;
  501. color: #282828;
  502. }
  503. .event_bg{
  504. background: #FF7F00;
  505. }
  506. .event_color{
  507. color: #FF7F00;
  508. }
  509. .my-order .list .item .event_name{
  510. display: inline-block;
  511. margin-right: 9rpx;
  512. color: #fff;
  513. font-size: 20rpx;
  514. padding: 0 8rpx;
  515. line-height: 30rpx;
  516. text-align: center;
  517. border-radius: 6rpx;
  518. }
  519. .my-order .list .item .event_ship{
  520. font-size: 20rpx;
  521. margin-top: 10rpx;
  522. }
  523. .my-order .list .event_price{
  524. margin: 0 0 50rpx 120rpx;
  525. font-size: 24rpx;
  526. .color_gray{
  527. color: #999;
  528. }
  529. }
  530. .my-order .list .item .item-info .text .money {
  531. text-align: right;
  532. }
  533. .my-order .list .item .totalPrice {
  534. font-size: 26rpx;
  535. color: #282828;
  536. text-align: right;
  537. margin: 27rpx 0 0 30rpx;
  538. padding: 0 30rpx 30rpx 0;
  539. }
  540. .my-order .list .item .totalPrice .money {
  541. font-size: 28rpx;
  542. font-weight: bold;
  543. }
  544. .my-order .list .item .bottom {
  545. height: 107rpx;
  546. padding: 0 30rpx;
  547. border-top: 1px solid #f0f0f0;
  548. }
  549. .my-order .list .item .bottom .bnt {
  550. width: 176rpx;
  551. height: 60rpx;
  552. text-align: center;
  553. line-height: 60rpx;
  554. color: #fff;
  555. border-radius: 50rpx;
  556. font-size: 27rpx;
  557. &.btn_auto{
  558. width: auto;
  559. padding: 0 40rpx;
  560. }
  561. }
  562. .my-order .list .item .bottom .bnt.cancelBnt {
  563. border: 1rpx solid #ddd;
  564. color: #aaa;
  565. }
  566. .my-order .list .item .bottom .bnt~.bnt {
  567. margin-left: 17rpx;
  568. }
  569. .noCart {
  570. margin-top: 171rpx;
  571. padding-top: 0.1rpx;
  572. }
  573. .noCart .pictrue {
  574. width: 414rpx;
  575. height: 336rpx;
  576. margin: 78rpx auto 56rpx auto;
  577. }
  578. .noCart .pictrue image {
  579. width: 100%;
  580. height: 100%;
  581. }
  582. .event_container{
  583. width: 690rpx;
  584. background-image: url(~static/images/presell_orderBg.png);
  585. background-size: cover;
  586. background-repeat: no-repeat;
  587. margin: 20rpx auto;
  588. padding: 26rpx 30rpx;
  589. border-radius: 16rpx;
  590. .info{
  591. width: 420rpx;
  592. .title{
  593. color: #282828;
  594. font-size: 26rpx;
  595. }
  596. .desc{
  597. color: #999;
  598. font-size: 24rpx;
  599. margin-top: 30rpx;
  600. }
  601. }
  602. .photo{
  603. width: 180rpx;
  604. .picture{
  605. width: 120rpx;
  606. height: 120rpx;
  607. image{
  608. width: 100%;
  609. height: 100%;
  610. border-radius: 8rpx;
  611. }
  612. }
  613. .more_btn{
  614. color: #fff;
  615. background: #F97E3B;
  616. width: 40rpx;
  617. height: 40rpx;
  618. border-radius: 40rpx;
  619. text-align: center;
  620. line-height: 40rpx;
  621. position: relative;
  622. top: 40rpx;
  623. text{
  624. font-size: 10rpx;
  625. }
  626. }
  627. }
  628. }
  629. </style>