myOrder.vue 17 KB

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