myOrder.vue 17 KB

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