search-order.vue 15 KB

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