myOrder.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. <template>
  2. <view class="container" :style="{paddingTop:navbarHeight+'px'}">
  3. <!-- 自定义返回 -->
  4. <header-back :systeminfo='systeminfo' :navbar-data='nvabarData' :headerBtnPosi ="headerBtnPosi" :isDelete="isDelete"></header-back>
  5. <view class="container-order">
  6. <!--选项卡逻辑自己实现即可,此处未做处理-->
  7. <tui-tabs :tabs="tabs"
  8. :isFixed="scrollTop>=0"
  9. :currentTab="currentTab"
  10. selectedColor="#E15616"
  11. sliderBgColor="#E15616"
  12. @change="change"
  13. :marginTop="navbarHeight">
  14. </tui-tabs>
  15. <view :class="{'tui-order-list':scrollTop >= 0}" class="clearfix">
  16. <!-- 空白页 -->
  17. <empty v-if="isEmpty" :typeIndex="currentTab" :navbarHeight="navbarHeight"></empty>
  18. <!-- 列表 -->
  19. <view v-else class="tui-order-content">
  20. <view class="tui-order-item" v-for="(order,orderIndex) in orderData" :key="orderIndex" >
  21. <view class="order-title">
  22. <view class="order-title-t">
  23. <view class="order-title-num">订单号:{{order.orderNo}}</view>
  24. <view class="order-title-tip">{{orderStateExp(order.status)}}</view>
  25. </view>
  26. <view class="order-title-b">下单时间:{{order.orderTime}}</view>
  27. </view>
  28. <block v-for="(item,index) in order.shopOrderList" :key="index">
  29. <view class="goods-title">
  30. <view class="title-logo"><image :src="item.shopLogo" mode=""></image></view>
  31. <view class="title-text">{{item.shopName}}</view>
  32. </view>
  33. <view class="goods-item" v-for="(pros,prosIndex) in item.cmOrderProducts" :key="prosIndex" @click.stop="detail(order.orderID)">
  34. <view class="goods-pros-t">
  35. <view class="pros-img"><image :src="pros.productImage" alt="" /></view>
  36. <view class="pros-product">
  37. <view class="producttitle">{{pros.name}}</view>
  38. <view class="productspec">规格:{{pros.productUnit}}</view>
  39. <view class="productprice">
  40. <view class="price">
  41. <text>¥{{pros.price}}</text>
  42. </view>
  43. <view class="count">
  44. <text class="small">x</text>{{pros.num}}
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </block>
  51. <view class="order-footer">
  52. <view class="order-footer-top" v-if="order.discountFee!=0">经理折扣:¥{{orderPriceToFixed(order.discountFee)}}</view>
  53. <view class="order-footer-bot">
  54. <view class="count">共{{order.productCount}}件商品</view>
  55. <view class="money">合计:¥{{orderPriceToFixed(order.payableAmount)}}</view>
  56. </view>
  57. </view>
  58. <!-- 底部button -->
  59. <order-button ref="orderButton"
  60. :status="order.status"
  61. :orderID="order.orderID"
  62. @buttonConfirm="handButtonConfirm">
  63. </order-button>
  64. </view>
  65. <!--加载loadding-->
  66. <tui-loadmore :visible="loadding" :index="3" type="black"></tui-loadmore>
  67. <tui-nomore :visible="!pullUpOn" bgcolor="#F7F7F7" :text='nomoreText'></tui-nomore>
  68. <!--加载loadding-->
  69. </view>
  70. </view>
  71. </view>
  72. <!-- 分享弹窗 -->
  73. <share-alert v-if="isShareModal"
  74. :orderID="btnoRderID"
  75. @shareConfirm ='onShareAppMessage'>
  76. </share-alert>
  77. <!-- 删除订单弹窗 -->
  78. <model-alert v-if="isShowDelModal"
  79. :alertText='alertText'
  80. @btnConfirm ='handOrderDetele'>
  81. </model-alert>
  82. <!-- 取消订单弹窗 -->
  83. <cancel-alert v-if="isCenceModal"
  84. :cenceAlertText='cenceAlertText'
  85. @cenceConfirm ='handCenceConfirm'>
  86. </cancel-alert>
  87. <!-- 透明模态层 -->
  88. <modal-layer v-if='isModalLayer'></modal-layer>
  89. </view>
  90. </template>
  91. <script>
  92. import headerBack from '@/components/module/headerNavbar/header-back' //自定义导航
  93. import tuiTabs from "@/components/tui-components/tui-tabs/tui-tabs"
  94. import tuiListCell from "@/components/tui-components/list-cell/list-cell"
  95. import tuiLoadmore from "@/components/tui-components/loadmore/loadmore"
  96. import tuiNomore from "@/components/tui-components/nomore/nomore"
  97. import orderButton from '@/components/module/orderDetails/orderListButton' //按钮
  98. import modalLayer from "@/components/modal-layer"
  99. import empty from "@/components/empty";
  100. import shareAlert from '@/components/module/modelAlert/shareAlert' //分享弹窗
  101. import modelAlert from '@/components/module/modelAlert/modelAlert' //删除弹窗
  102. import cancelAlert from '@/components/module/modelAlert/cancelAlert' //取消弹窗
  103. export default {
  104. components: {
  105. empty,
  106. tuiTabs,
  107. tuiListCell,
  108. tuiLoadmore,
  109. tuiNomore,
  110. orderButton,
  111. modalLayer,
  112. modelAlert,
  113. shareAlert,
  114. cancelAlert,
  115. headerBack
  116. },
  117. data() {
  118. return {
  119. userID:0,
  120. orderData: [],
  121. btnoRderID: 0, //点击按钮传入的的订单ID
  122. currentTab: 0,
  123. pageNum: 1, //页数
  124. pageSize: 10, //条数
  125. scrollTop: 0,
  126. deteleType:'',
  127. skeletonShow: true,
  128. isEmpty: false,
  129. isDelete:false,
  130. isShareModal: false,//控制分享弹窗
  131. isCenceModal: false,//控制取消订单弹窗
  132. isShowDelModal: false,//控制删除订单弹窗
  133. isModalLayer: false,
  134. loadding: false,
  135. pullUpOn: true,
  136. hasNextPage: false,
  137. pullFlag: true,
  138. navbarHeight:'',
  139. alertText: '确认删除订单吗?',
  140. cenceAlertText: '确认取消该订单吗?',
  141. nomoreText: '上拉显示更多',
  142. tabs: [
  143. {name: "全部"},
  144. {name: "待付款"},
  145. {name: "待发货"},
  146. {name: "已发货"},
  147. {name: "退货/款"},
  148. ],
  149. headerBtnPosi: this.setHeaderBtnPosi(), //获取设备顶部胶囊高度
  150. systeminfo: this.setSysteminfo(), //获取设备信息
  151. nvabarData: { //顶部自定义导航
  152. showCapsule: 1, // 是否显示左上角图标 1表示显示 0表示不显示
  153. title: '我的订单', // 导航栏 中间的标题
  154. }
  155. }
  156. },
  157. onLoad(option) {
  158. console.log(option)
  159. if(option.type ==='detele'){this.isDelete = true}
  160. this.currentTab = option.state
  161. this.getHeaderTopHeight()//设置自定义导航高度
  162. },
  163. methods: {
  164. getOrderDatainit(index){
  165. /**
  166. * @订单初始化加载 仅加载第一页码
  167. * @param:orderState(订单状态:0全部,1待付款,2待发货,3已发货,4退货款)
  168. * @param:userID(用户ID)
  169. * @param:index(页码数)
  170. * @param:pageSize(每页条数)
  171. * @param:organizeID(全局变量组织ID)
  172. */
  173. // setTimeout(()=>{this.skeletonShow = false},1500)
  174. this.$api.getStorage().then((resolve) =>{
  175. this.userID = resolve.userID
  176. let param = {orderState:index,userID:this.userID,index:1,pageSize:this.pageSize,organizeID:this.userOrganizeID}
  177. this.$api.lodingGet('/order/myOrder',param,
  178. response => {
  179. if(response.code === '1'){
  180. let resData = response.data.results
  181. this.hasNextPage = response.data.hasNextPage;
  182. if(resData && resData.length > 0){
  183. this.isEmpty = false;
  184. this.orderData = [...resData];
  185. }else{
  186. this.isEmpty = true
  187. }
  188. if(this.hasNextPage){
  189. this.pullUpOn = false
  190. this.nomoreText = '上拉显示更多'
  191. }else{
  192. if(this.orderData.length < 2){
  193. this.pullUpOn = true
  194. }else{
  195. this.pullUpOn = false
  196. this.nomoreText = '已至底部'
  197. }
  198. }
  199. }else{
  200. this.$util.msg(response.msg,2000);
  201. }
  202. }
  203. )
  204. })
  205. },
  206. getOnReachBottomData(index){//上拉加载
  207. this.pageNum+=1
  208. let param = {orderState:index,userID:this.userID,index:this.pageNum,pageSize:this.pageSize,organizeID:this.userOrganizeID}
  209. this.$api.get('/order/myOrder',param,
  210. response => {
  211. if(response.code === '1'){
  212. let resData = response.data.results
  213. this.hasNextPage = response.data.hasNextPage;
  214. this.orderData = this.orderData.concat(resData)
  215. this.pullFlag = false;// 防上拉暴滑
  216. setTimeout(()=>{this.pullFlag = true;},500)
  217. if(this.hasNextPage){
  218. this.pullUpOn = false
  219. this.nomoreText = '上拉显示更多'
  220. }else{
  221. this.loadding = false
  222. this.pullUpOn = false
  223. this.nomoreText = '已至底部'
  224. }
  225. }else{
  226. this.$util.msg(response.msg,2000);
  227. }
  228. }
  229. )
  230. },
  231. change(e) {//切换tab传递当前tab[index]执行初始化方法
  232. this.currentTab = e.index
  233. this.pageNum = 1
  234. this.orderData = []
  235. this.pullUpOn = true //切换时隐藏
  236. this.loadding = false //切换时隐藏
  237. this.getOrderDatainit(this.currentTab)
  238. },
  239. detail(id) {//订单详情跳转
  240. this.isModalLayer = true;
  241. this.$api.navigateTo(`/pages/user/order/order-details?state=${this.currentTab}&orderID=${id}`)
  242. },
  243. handButtonConfirm(data) {//获取点击
  244. console.log('点击按钮的类型是',data);
  245. this.handShowAlert(data)
  246. this.btnoRderID = data.orderId
  247. },
  248. handShowAlert(data) {//执行
  249. switch(data.type){
  250. case 'delete':
  251. this.isShowDelModal = true;
  252. break
  253. case 'cancel':
  254. this.isCenceModal = true;
  255. break
  256. case 'query':
  257. this.isModalLayer = true;
  258. this.$api.navigateTo('/pages/user/order/order-logistics?orderID='+data.orderId)
  259. break
  260. case 'confirm':
  261. this.handOrderConfirm(data.orderId);
  262. break
  263. }
  264. },
  265. handOrderConfirm (id){//确认收货
  266. this.$api.get('/order/affirm',{orderID:id},
  267. response => {
  268. if(response.code === '1'){
  269. this.$util.msg(response.msg,2000,true,'success');
  270. this.isShowDelModal = false
  271. setTimeout(() => {
  272. this.getOrderDatainit(this.currentTab)
  273. },2000)
  274. }else{
  275. this.$util.msg(response.msg,2000);
  276. }
  277. }
  278. )
  279. },
  280. handOrderDetele (){//删除订单
  281. this.$api.get('/order/delete',{orderID:this.btnoRderID},
  282. response => {
  283. if(response.code === '1'){
  284. this.$util.msg(response.msg,2000,true,'success');
  285. this.isShowDelModal = false
  286. setTimeout(() => {
  287. this.orderData = [];
  288. this.getOrderDatainit(this.currentTab)
  289. },2000)
  290. }else{
  291. this.$util.msg(response.msg,2000);
  292. }
  293. }
  294. )
  295. },
  296. handCenceConfirm (){//取消订单
  297. this.$api.get('/order/cancel',{orderID:this.btnoRderID},
  298. response => {
  299. if(response.code === '1'){
  300. this.$util.msg(response.msg,2000,true,'success');
  301. this.isCenceModal = false
  302. setTimeout(() => {
  303. this.orderData = [];
  304. this.getOrderDatainit(this.currentTab)
  305. },2000)
  306. }else{
  307. this.$util.msg(response.msg,2000);
  308. }
  309. }
  310. )
  311. },
  312. onShareAppMessage (res){//分享转发
  313. this.isShareModal = false
  314. if (res.from === 'button') {// 来自页面内转发按钮
  315. // console.log(res.target)
  316. }
  317. return {
  318. title: '您有新的分享订单,快来查看吧~',
  319. path: `/pages/user/order/orderShareLogin?orderID=${this.btnoRderID}&userID=${this.userID}`,
  320. imageUrl:'https://admin-b.caimei365.com/userfiles/1/images/photo/2020/02/%E5%88%86%E4%BA%AB%E7%95%8C%E9%9D%A2a%CC%8A%403x.png'
  321. }
  322. },
  323. //订单状态文字和颜色
  324. orderStateExp (state){
  325. let stateText = '',
  326. stateTextObject={
  327. 4:'交易完成',
  328. 5:'订单完成',
  329. 6:'已关闭',
  330. 7:'交易全退',
  331. 77:'交易全退',
  332. 11:'待付款待发货',
  333. 12:'待付款部分发货',
  334. 13:'待付款已发货',
  335. 21:'部分付款待发货',
  336. 22:'部分付款部分发货',
  337. 23:'部分付款已发货',
  338. 31:'已付款待发货',
  339. 32:'已付款部分发货',
  340. 33:'已付款已发货',
  341. 111:'待付款待发货',
  342. }
  343. Object.keys(stateTextObject).forEach(key => {
  344. if(key == state){
  345. stateText = stateTextObject[key]
  346. }
  347. })
  348. return stateText;
  349. },
  350. orderPriceToFixed (n){
  351. let price ='';
  352. price = n.toFixed(2);
  353. return price
  354. },
  355. getHeaderTopHeight (){ // 状态栏高度
  356. let statusBarHeight = this.systeminfo.statusBarHeight
  357. let headerPosi = this.headerBtnPosi
  358. let btnPosi = { // 胶囊实际位置,坐标信息不是左上角原点
  359. height: headerPosi.height,
  360. width: headerPosi.width,
  361. // 胶囊top - 状态栏高度
  362. top: headerPosi.top - statusBarHeight,
  363. // 胶囊bottom - 胶囊height - 状态栏height (现胶囊bottom 为距离导航栏底部的长度)
  364. bottom: headerPosi.bottom - headerPosi.height - statusBarHeight,
  365. // 屏幕宽度 - 胶囊right
  366. right: this.systeminfo.screenWidth - headerPosi.right
  367. }
  368. this.navbarHeight= headerPosi.bottom + btnPosi.bottom// 原胶囊bottom + 现胶囊bottom
  369. },
  370. setHeaderBtnPosi (){
  371. // 获得胶囊按钮位置信息
  372. let headerBtnPosi = uni.getMenuButtonBoundingClientRect();
  373. return headerBtnPosi
  374. },
  375. setSysteminfo (){
  376. let systeminfo;
  377. uni.getSystemInfo({ // 获取设备信息
  378. success: (res) => {
  379. systeminfo = res
  380. },
  381. })
  382. return systeminfo
  383. }
  384. },
  385. // onPullDownRefresh() {
  386. // if(!this.isEmpty){
  387. // setTimeout(() => {
  388. // this.pageNum = 1,
  389. // this.getOrderDatainit(this.currentTab)
  390. // uni.stopPullDownRefresh()
  391. // }, 200);
  392. // }
  393. // },
  394. onReachBottom() {//上滑加载更多
  395. if(this.hasNextPage){
  396. this.loadding = true
  397. this.pullUpOn = true
  398. this.getOnReachBottomData(this.currentTab);
  399. }
  400. },
  401. onPageScroll(e) {
  402. this.scrollTop = e.scrollTop;
  403. },
  404. onShow() {
  405. this.isModalLayer = false;
  406. this.getOrderDatainit(this.currentTab)
  407. }
  408. }
  409. </script>
  410. <style lang="scss">
  411. page{
  412. background: #F7F7F7;
  413. }
  414. .container {
  415. padding-bottom: env(safe-area-inset-bottom);
  416. height: auto;
  417. position: relative;
  418. }
  419. .tui-order-content{
  420. width: 100%;
  421. height: auto;
  422. }
  423. .tui-order-list {
  424. margin-top: 80rpx;
  425. width: 100%;
  426. position: relative;
  427. }
  428. .tui-order-item {
  429. display: flex;
  430. flex-direction: column;
  431. width: 702rpx;
  432. padding:20rpx 24rpx 0 24rpx;
  433. background: #fff;
  434. border-bottom: 20rpx solid #F7F7F7;
  435. }
  436. .order-title{
  437. width: 100%;
  438. height: auto;
  439. .order-title-t{
  440. width: 100%;
  441. height: 40rpx;
  442. float: left;
  443. font-size: $font-size-base;
  444. line-height: 40rpx;
  445. font-weight: bold;
  446. .order-title-num{
  447. float: left;
  448. text-align: left;
  449. color: #E15616;
  450. }
  451. .order-title-tip{
  452. float: right;
  453. text-align: right;
  454. color: #FF2A2A;
  455. }
  456. }
  457. .order-title-b{
  458. width: 100%;
  459. height: 40rpx;
  460. float: left;
  461. margin-top: 8rpx;
  462. font-size: $font-size-base;
  463. line-height: 40rpx;
  464. color: #999999;
  465. text-align: left;
  466. }
  467. }
  468. .goods-title{
  469. width: 100%;
  470. height: 48rpx;
  471. float: left;
  472. margin-top: 24rpx;
  473. .title-logo{
  474. width: 48rpx;
  475. height: 48rpx;
  476. float: left;
  477. image{
  478. width: 48rpx;
  479. height: 48rpx;
  480. }
  481. }
  482. .title-text{
  483. float: left;
  484. margin-left: 16rpx;
  485. font-size: $font-size-base;
  486. color: $text-color;
  487. text-align: left;
  488. line-height: 48rpx;
  489. font-weight: bold;
  490. }
  491. }
  492. .goods-item{
  493. width: 100%;
  494. height: auto;
  495. }
  496. .goods-pros-t{
  497. display: flex;
  498. align-items: center;
  499. width: 100%;
  500. height: 217rpx;
  501. padding:24rpx 0;
  502. .pros-img{
  503. width: 210rpx;
  504. height: 100%;
  505. border-radius: 10rpx;
  506. margin:0 26rpx 0 0;
  507. border:1px solid #f3f3f3;
  508. image{
  509. width: 100%;
  510. height: 100%;
  511. border-radius: 10rpx;
  512. }
  513. }
  514. }
  515. .pros-product{
  516. width: 468rpx;
  517. height: 100%;
  518. line-height: 36rpx;
  519. font-size: $font-size-sb;
  520. position: relative;
  521. .producttitle{
  522. width: 100%;
  523. display: inline-block;
  524. height: auto;
  525. text-overflow:ellipsis;
  526. display: -webkit-box;
  527. word-break: break-all;
  528. -webkit-box-orient: vertical;
  529. -webkit-line-clamp: 2;
  530. overflow: hidden;
  531. margin-bottom: 8rpx;
  532. }
  533. .productspec{
  534. height: 36rpx;
  535. color: #999999;
  536. }
  537. .productprice{
  538. height: 48rpx;
  539. position: absolute;
  540. width: 100%;
  541. bottom: 0;
  542. .price{
  543. line-height: 48rpx;
  544. font-size: $font-size-base;
  545. width: 48%;
  546. color: #FF2A2A;
  547. float: left;
  548. font-weight: bold;
  549. }
  550. .count{
  551. height: 100%;
  552. float: right;
  553. position: relative;
  554. .small{
  555. color: #666666;
  556. }
  557. }
  558. }
  559. }
  560. .order-footer{
  561. width: 100%;
  562. height: 78rpx;
  563. float: left;
  564. .order-footer-top{
  565. width: 100%;
  566. height: 34rpx;
  567. line-height: 34rpx;
  568. font-size: $font-size-sm;
  569. color: #999999;
  570. text-align: right;
  571. }
  572. .order-footer-bot{
  573. width: 100%;
  574. float: left;
  575. height: 48rpx;
  576. line-height: 48rpx;
  577. font-size: $font-size-base;
  578. font-weight: bold;
  579. color: $text-color;
  580. .count{
  581. width: 50%;
  582. float: left;
  583. text-align: left;
  584. }
  585. .money{
  586. width: 50%;
  587. float: right;
  588. text-align: right;
  589. }
  590. }
  591. }
  592. </style>