index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. <template>
  2. <view :style="viewColor">
  3. <view class='my-order'>
  4. <view class='list'>
  5. <!-- 代付款 -->
  6. <view class='item' v-for="(item,index) in orderList" :key="index">
  7. <view>
  8. <view class='title acea-row row-between-wrapper'>
  9. <view class="acea-row row-middle left-wrapper" @click="goStore(item.mer_id)">
  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. <block v-if="item.presellOrder">
  15. <view v-if="item.presellOrder.activeStatus === 1" class='t-color'>等待买家付尾款</view>
  16. <view v-if="item.presellOrder.activeStatus === 0" class='t-color'>未开始</view>
  17. <view v-if="item.presellOrder.activeStatus === 2" class='t-color'>交易已关闭</view>
  18. </block>
  19. </view>
  20. <block v-for="(goods,g) in item.orderProduct">
  21. <!--预售-->
  22. <view class='item-info acea-row row-between row-top' @click='goOrderDetails(item.order_id)'>
  23. <view class='pictrue'>
  24. <image :src='(goods.cart_info.productAttr && goods.cart_info.productAttr.image) || goods.cart_info.product.image'></image>
  25. </view>
  26. <view class='text acea-row row-between'>
  27. <view class='name line1'>
  28. <text class="event_name event_bg">预售</text><text>{{goods.cart_info.product.store_name}}</text>
  29. <view class="event_ship event_color">发货时间:
  30. <block v-if="goods.cart_info.productPresell">
  31. <!--全款预售-->
  32. <text v-if="goods.cart_info.productPresell.presell_type === 1">{{ goods.cart_info.productPresell.delivery_type === 1 ? '支付成功后' : '预售结束后' }}{{ goods.cart_info.productPresell.delivery_day }}天内</text>
  33. <!--定金预售-->
  34. <text v-if="goods.cart_info.productPresell.presell_type === 2">{{ goods.cart_info.productPresell.delivery_type === 1 ? '支付尾款后' : '预售结束后' }}{{ goods.cart_info.productPresell.delivery_day }}天内</text>
  35. </block>
  36. </view>
  37. </view>
  38. <view class='money'>
  39. <view v-if="goods.cart_info.productPresellAttr">¥{{goods.cart_info.productPresellAttr.presell_price}}</view>
  40. <view>x{{goods.product_num}}</view>
  41. </view>
  42. </view>
  43. <view v-if="goods.cart_info.productPresell.presell_type === 2" class="event_price">
  44. <text class="color_gray">定金已支付 <text>¥{{ item.pay_price }},</text></text>
  45. 尾款待支付 <text class="p-color">¥{{ item.presellOrder&&item.presellOrder.pay_price }}</text>
  46. </view>
  47. </view>
  48. </block>
  49. <view v-if="item.presellOrder" class='bottom acea-row row-right row-middle'>
  50. <view v-if="item.presellOrder.activeStatus === 2" class='bnt cancelBnt' @click.stop='cancelOrder(index,item.order_id)'>取消订单</view>
  51. <view v-if="item.presellOrder.activeStatus === 1" class='bnt b-color' @click.stop='goPay(item.presellOrder.pay_price,item.order_id)'>立即付款</view>
  52. <view v-if="item.presellOrder.activeStatus === 0" class='bnt b-color btn_auto'>未开始</view>
  53. <view v-if="item.presellOrder.activeStatus === 2" class='bnt b-color'>交易已关闭</view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class='loadingicon acea-row row-center-wrapper' v-if="orderList.length>5">
  59. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  60. </view>
  61. <view v-if="orderList.length == 0">
  62. <emptyPage title="暂无订单~"></emptyPage>
  63. </view>
  64. </view>
  65. <payment :payMode='payMode' :pay_close="pay_close" @onChangeFun='onChangeFun' :order_id="pay_order_id" :totalPrice='totalPrice' :order_type='1'></payment>
  66. </view>
  67. </template>
  68. <script>
  69. // +----------------------------------------------------------------------
  70. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  71. // +----------------------------------------------------------------------
  72. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  73. // +----------------------------------------------------------------------
  74. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  75. // +----------------------------------------------------------------------
  76. // | Author: CRMEB Team <admin@crmeb.com>
  77. // +----------------------------------------------------------------------
  78. let app = getApp();
  79. import { getOrderList, orderData, orderDel } from '@/api/order.js';
  80. import { getUserInfo } from '@/api/user.js';
  81. import { openOrderSubscribe } from '@/utils/SubscribeMessage.js';
  82. import payment from '@/components/payment';
  83. import { mapGetters } from "vuex";
  84. import emptyPage from '@/components/emptyPage.vue'
  85. import { configMap } from '@/utils'
  86. import { toLogin } from '@/libs/login.js';
  87. export default {
  88. components: {
  89. payment,
  90. emptyPage,
  91. },
  92. data() {
  93. return {
  94. loading: false, //是否加载中
  95. loadend: false, //是否加载完毕
  96. loadTitle: '加载更多', //提示语
  97. orderList: [], //订单数组
  98. orderData: {}, //订单详细统计
  99. orderStatus: 0, //订单状态
  100. page: 1,
  101. limit: 20,
  102. payMode: [{
  103. name: "微信支付",
  104. icon: "icon-weixinzhifu",
  105. value: 'wechat',
  106. title: '微信快捷支付',
  107. payStatus: 1
  108. },
  109. {
  110. name: "支付宝支付",
  111. icon: "icon-zhifubao",
  112. value: 'alipay',
  113. title: '支付宝支付',
  114. payStatus: this.$store.getters.globalData.alipay_open
  115. },
  116. {
  117. name: "余额支付",
  118. icon: "icon-yuezhifu",
  119. value: 'balance',
  120. title: '可用余额:',
  121. number: 0,
  122. payStatus: this.$store.getters.globalData.yue_pay_status
  123. }
  124. ],
  125. pay_close: false,
  126. pay_order_id: '',
  127. totalPrice: '0',
  128. isTimePay: false,
  129. };
  130. },
  131. computed: {
  132. ...mapGetters(['isLogin','viewColor']),
  133. ...configMap(['hide_mer_status', 'community_status', 'alipay_open', 'yue_pay_status']),
  134. },
  135. onShow() {
  136. if (this.isLogin) {
  137. this.$set(this, 'orderList', []);
  138. this.page = 1;
  139. this.loadend = false;
  140. this.loading = false;
  141. this.getOrderList();
  142. this.getUserInfo();
  143. } else {
  144. toLogin()
  145. }
  146. },
  147. onReady: function() {
  148. },
  149. methods: {
  150. /**
  151. * 事件回调
  152. *
  153. */
  154. onChangeFun: function(e) {
  155. let opt = e;
  156. let action = opt.action || null;
  157. let value = opt.value != undefined ? opt.value : null;
  158. (action && this[action]) && this[action](value);
  159. },
  160. /**
  161. * 获取用户信息
  162. *
  163. */
  164. getUserInfo: function() {
  165. let that = this;
  166. getUserInfo().then(res => {
  167. that.payMode[2].number = res.data.now_money;
  168. });
  169. },
  170. /**
  171. * 关闭支付组件
  172. *
  173. */
  174. payClose: function() {
  175. this.pay_close = false;
  176. },
  177. /**
  178. * 生命周期函数--监听页面加载
  179. */
  180. onLoad: function(options) {
  181. if (options.status) this.orderStatus = options.status;
  182. },
  183. /**
  184. * 取消订单
  185. *
  186. */
  187. cancelOrder: function(index, order_id) {
  188. let that = this;
  189. if (!order_id) return that.$util.Tips({
  190. title: '缺少订单号无法取消订单'
  191. });
  192. orderDel(order_id).then(res => {
  193. return that.$util.Tips({
  194. title: res.message,
  195. icon: 'success'
  196. }, function() {
  197. that.orderList.splice(index, 1);
  198. that.$set(that, 'orderList', that.orderList);
  199. that.$set(that.orderData, 'unpaid_count', that.orderData.unpaid_count - 1);
  200. });
  201. }).catch(err => {
  202. return that.$util.Tips({
  203. title: err
  204. });
  205. });
  206. },
  207. /**
  208. * 打开支付组件
  209. *
  210. */
  211. goPay: function(pay_price, order_id) {
  212. this.$set(this, 'pay_close', true);
  213. this.order_id = order_id;
  214. this.pay_order_id = order_id.toString()
  215. this.$set(this, 'totalPrice', pay_price);
  216. },
  217. /**
  218. * 支付成功回调
  219. *
  220. */
  221. pay_complete: function() {
  222. this.loadend = false;
  223. this.page = 1;
  224. this.$set(this, 'orderList', []);
  225. this.pay_close = false;
  226. this.pay_order_id = '';
  227. this.getOrderList();
  228. },
  229. /**
  230. * 支付失败回调
  231. *
  232. */
  233. pay_fail: function() {
  234. this.pay_close = false;
  235. this.pay_order_id = '';
  236. },
  237. goStore(id){
  238. if(this.hide_mer_status != 1){
  239. uni.navigateTo({
  240. url:`/pages/store/home/index?id=${id}`
  241. })
  242. }
  243. },
  244. /**
  245. * 去订单详情
  246. */
  247. goOrderDetails: function(order_id) {
  248. let self = this
  249. if (!order_id) return that.$util.Tips({
  250. title: '缺少订单号无法查看订单详情'
  251. });
  252. // #ifdef MP
  253. uni.showLoading({
  254. title: '正在加载',
  255. })
  256. openOrderSubscribe().then(() => {
  257. uni.hideLoading();
  258. uni.navigateTo({
  259. url: '/pages/order_details/index?order_id=' + order_id
  260. })
  261. }).catch(() => {
  262. uni.hideLoading();
  263. })
  264. // #endif
  265. // #ifndef MP
  266. uni.navigateTo({
  267. url: '/pages/order_details/index?order_id=' + order_id
  268. })
  269. // #endif
  270. },
  271. /**
  272. * 获取订单列表
  273. */
  274. getOrderList: function() {
  275. let that = this;
  276. if (that.loadend) return;
  277. if (that.loading) return;
  278. that.loading = true;
  279. that.loadTitle = "加载更多";
  280. getOrderList({
  281. status: 10,
  282. page: that.page,
  283. limit: that.limit,
  284. }).then(res => {
  285. let list = res.data.list || [];
  286. let loadend = list.length < that.limit;
  287. that.orderList = that.$util.SplitArray(list, that.orderList);
  288. that.$set(that, 'orderList', that.orderList);
  289. that.getProductCount();
  290. that.loadend = loadend;
  291. that.loading = false;
  292. that.loadTitle = loadend ? "我也是有底线的" : '加载更多';
  293. that.page = that.page + 1;
  294. }).catch(err => {
  295. that.loading = false;
  296. that.loadTitle = "加载更多";
  297. })
  298. },
  299. /**
  300. * 获取单个订单商品数量
  301. */
  302. getProductCount: function(){
  303. if(this.orderStatus !== 0){
  304. this.orderList.forEach((item,i) => {
  305. let orderNum = 0
  306. item.orderProduct.forEach((val) => {
  307. orderNum += val.product_num
  308. })
  309. this.orderList[i]['orderNum']=orderNum;
  310. })
  311. }
  312. },
  313. },
  314. onReachBottom: function() {
  315. this.getOrderList();
  316. }
  317. }
  318. </script>
  319. <style scoped lang="scss">
  320. .my-order .header {
  321. height: 260rpx;
  322. padding: 0 30rpx;
  323. }
  324. .my-order .header .picTxt {
  325. height: 190rpx;
  326. }
  327. .my-order .header .picTxt .text {
  328. color: rgba(255, 255, 255, 0.8);
  329. font-size: 26rpx;
  330. }
  331. .my-order .header .picTxt .text .name {
  332. font-size: 34rpx;
  333. font-weight: bold;
  334. color: #fff;
  335. margin-bottom: 20rpx;
  336. }
  337. .my-order .header .picTxt .pictrue {
  338. width: 122rpx;
  339. height: 109rpx;
  340. }
  341. .my-order .header .picTxt .pictrue image {
  342. width: 100%;
  343. height: 100%;
  344. }
  345. .my-order .nav {
  346. background-color: #fff;
  347. width: 690rpx;
  348. height: 140rpx;
  349. border-radius: 6rpx;
  350. margin: -73rpx auto 0 auto;
  351. }
  352. .my-order .nav .item {
  353. text-align: center;
  354. font-size: 26rpx;
  355. color: #282828;
  356. padding: 29rpx 0;
  357. }
  358. .my-order .nav .item.on {
  359. font-weight: bold;
  360. border-bottom: 5rpx solid #e93323;
  361. }
  362. .my-order .nav .item .num {
  363. margin-top: 18rpx;
  364. }
  365. .my-order .list {
  366. width: 690rpx;
  367. margin: 14rpx auto 0 auto;
  368. }
  369. .my-order .list .item {
  370. background-color: #fff;
  371. border-radius: 16rpx;
  372. margin-bottom: 14rpx;
  373. }
  374. .t-color {
  375. color: var(--view-theme);
  376. }
  377. .p-color {
  378. color: var(--view-priceColor);
  379. }
  380. .b-color {
  381. background-color: var(--view-theme);
  382. }
  383. .my-order .list .item .title {
  384. height: 84rpx;
  385. padding: 0 30rpx;
  386. border-bottom: 1rpx solid #eee;
  387. font-size: 28rpx;
  388. color: #282828;
  389. .left-wrapper {
  390. .iconfont {
  391. margin-top: 5rpx;
  392. }
  393. .store-name {
  394. margin: 0 10rpx;
  395. }
  396. .icon-xiangyou {
  397. font-size: 20rpx;
  398. }
  399. }
  400. }
  401. .my-order .list .item .title .sign {
  402. font-size: 24rpx;
  403. padding: 0 7rpx;
  404. height: 36rpx;
  405. margin-right: 15rpx;
  406. }
  407. .my-order .list .item .item-info {
  408. padding: 0 30rpx;
  409. margin-top: 22rpx;
  410. }
  411. .my-order .list .item .item-info .pictrue {
  412. width: 120rpx;
  413. height: 120rpx;
  414. }
  415. .my-order .list .item .item-info .pictrue image {
  416. width: 100%;
  417. height: 100%;
  418. border-radius: 6rpx;
  419. }
  420. .my-order .list .item .item-info .text {
  421. width: 486rpx;
  422. font-size: 28rpx;
  423. color: #999;
  424. margin-top: 6rpx;
  425. }
  426. .my-order .list .item .item-info .text .name {
  427. width: 320rpx;
  428. color: #282828;
  429. }
  430. .event_bg{
  431. background: #FF7F00;
  432. }
  433. .event_color{
  434. color: #FF7F00;
  435. }
  436. .my-order .list .item .event_name{
  437. display: inline-block;
  438. margin-right: 9rpx;
  439. color: #fff;
  440. font-size: 20rpx;
  441. padding: 0 8rpx;
  442. line-height: 30rpx;
  443. text-align: center;
  444. border-radius: 6rpx;
  445. }
  446. .my-order .list .item .event_ship{
  447. font-size: 20rpx;
  448. margin-top: 10rpx;
  449. }
  450. .my-order .list .event_price{
  451. margin: 0 0 50rpx 120rpx;
  452. font-size: 24rpx;
  453. .color_gray{
  454. color: #999;
  455. }
  456. }
  457. .my-order .list .item .item-info .text .money {
  458. text-align: right;
  459. }
  460. .my-order .list .item .totalPrice {
  461. font-size: 26rpx;
  462. color: #282828;
  463. text-align: right;
  464. margin: 27rpx 0 0 30rpx;
  465. padding: 0 30rpx 30rpx 0;
  466. }
  467. .my-order .list .item .totalPrice .money {
  468. font-size: 28rpx;
  469. font-weight: bold;
  470. }
  471. .my-order .list .item .bottom {
  472. height: 107rpx;
  473. padding: 0 30rpx;
  474. border-top: 1px solid #f0f0f0;
  475. }
  476. .my-order .list .item .bottom .bnt {
  477. width: 176rpx;
  478. height: 60rpx;
  479. text-align: center;
  480. line-height: 60rpx;
  481. color: #fff;
  482. border-radius: 50rpx;
  483. font-size: 27rpx;
  484. &.btn_auto{
  485. width: auto;
  486. padding: 0 40rpx;
  487. }
  488. }
  489. .my-order .list .item .bottom .bnt.cancelBnt {
  490. border: 1rpx solid #ddd;
  491. color: #aaa;
  492. }
  493. .my-order .list .item .bottom .bnt~.bnt {
  494. margin-left: 17rpx;
  495. }
  496. </style>