myOrder.vue 17 KB

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