orderList.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <template>
  2. <view class="digitShelf-pagesCons">
  3. <view class="tab-body">
  4. <view>
  5. <u-tabs-swiper ref="uTabs" :list="tabList" :offset="[5,40]" bar-width='100' active-color="#1283d4" name="dispName" :current="current" @change="tabsChange" :is-scroll="false"
  6. swiperWidth="750"></u-tabs-swiper>
  7. </view>
  8. <swiper class="check-list" :current="swiperCurrent" @transition="transition" @change="swiperChange" @animationfinish="animationfinish">
  9. <swiper-item class="swiper-item" style="height: 100%;width: 100%;overflow: hidden;" v-for="(tabs, indexs) in tabList" :key="indexs">
  10. <scroll-view scroll-y style="height: 100%;width: 100%;overflow: auto;" @scrolltolower="onreachBottom" v-if="swiperCurrent == indexs">
  11. <view
  12. class="check-order-list"
  13. v-for="(item,index) in list"
  14. :key="item.id"
  15. @click="viewRow(item)"
  16. >
  17. <view class="check-row align_center justify_between">
  18. <view class="orderNo">{{item.purchaseNo}}</view>
  19. <view class="times">
  20. <span v-if="item.billStatus == 'WAIT_AUDIT'&&item.payOnlineFlag==0">待审核</span>
  21. <view v-if="item.billStatus == 'WAIT_PAY'" class="waitPay">
  22. <text>待付款</text>
  23. <u-count-down :timestamp="item.timestamp" :show-days="false" :show-hours="false"></u-count-down>
  24. </view>
  25. <span v-if="item.billStatus == 'AUDIT_REJECT'">审核不通过</span>
  26. <span v-if="item.billStatus == 'WAIT_OUT_WAREHOUSE' || item.billStatus == 'WAIT_RECEIVE'">待收货</span>
  27. <span v-if="item.billStatus == 'FINISH'">已完结</span>
  28. <span v-if="item.billStatus == 'CANCEL'">已取消</span>
  29. </view>
  30. </view>
  31. <view class="check-row">
  32. <view v-if="item.totalCategory>1" class="check-row-left">
  33. <scroll-view style="width: 100%;white-space: nowrap;" scroll-x="true">
  34. <view class="img-item" v-for="item in item.productList" :key="item.id">
  35. <image :src="item.images||'/static/def_imgs.png'" style="width: 100%;height: 100%;"></image>
  36. </view>
  37. </scroll-view>
  38. </view>
  39. <view v-else class="check-row-left">
  40. <view class="img-item">
  41. <image :src="item.productList&&item.productList[0].images||'/static/def_imgs.png'" style="width: 100%;height: 100%;"></image>
  42. </view>
  43. <view class="product-info">
  44. <text class="ellipsis-two">{{item.productList&&item.productList[0].productName ||'--'}}</text>
  45. <text class="ellipsis-one">{{item.productList&&item.productList[0].origCode||'--'}}</text>
  46. </view>
  47. </view>
  48. <view :class="item.totalCategory>1?'check-row-right check-row-right-fixed':'check-row-right'">
  49. <view>¥<text class="price">{{priceStr(item.totalAmount)[0]}}</text>.{{priceStr(item.totalAmount)[1]}}</view>
  50. <view><text class="nums">共{{item.totalQty}}件</text></view>
  51. </view>
  52. </view>
  53. <view class="check-row">
  54. <view class="times">
  55. {{item.createDate}}
  56. </view>
  57. <view style="text-align: right;color: #999;">
  58. <u-button style="margin-left: 10px;" v-if="item.billStatus == 'WAIT_AUDIT'" size="mini" shape="round" type="default" plain @click="cancelOrder(item)">取消订单</u-button>
  59. <u-button style="margin-left: 10px;" v-if="item.billStatus == 'WAIT_PAY'" size="mini" shape="round" type="error" plain @click="payOrder(item)">立即支付</u-button>
  60. <!-- <u-button style="margin-left: 10px;" v-if="item.billStatus == 'CANCEL'" size="mini" shape="round" type="error" plain @click="buyAgain(item)">再次购买</u-button> -->
  61. <u-button style="margin-left: 10px;" v-if="item.billStatus == 'WAIT_RECEIVE'" size="mini" shape="round" type="error" plain @click="receiveOrder(item)">确认收货</u-button>
  62. </view>
  63. </view>
  64. </view>
  65. <view style="padding: 20upx;">
  66. <u-empty :src="`/static/nodata.png`" icon-size="180" :text="noDataText" img-width="120" v-if="list.length==0 && status!='loading'" mode="list"></u-empty>
  67. <u-loadmore v-if="(total>=list.length&&list.length)||status=='loading'" :status="status" />
  68. </view>
  69. </scroll-view>
  70. </swiper-item>
  71. </swiper>
  72. </view>
  73. <!-- 付款弹框 -->
  74. <payModal :showPopu="showPopu" :payInfo="payInfo" @close="showPopu=false" @payComplete="payComplete"></payModal>
  75. </view>
  76. </template>
  77. <script>
  78. import { purchaseQueryPage,purchaseCancel,purchaseReceive } from '@/api/purchase.js'
  79. import payModal from '../components/payModal.vue'
  80. export default {
  81. components:{
  82. payModal
  83. },
  84. data() {
  85. return {
  86. status: 'loading',
  87. noDataText: '暂无数据',
  88. showPopu: false,
  89. tabList: [
  90. {
  91. dispName: '全部',
  92. typeId: 1,
  93. count: 0
  94. },
  95. {
  96. dispName: '待付款',
  97. typeId: 2,
  98. count: 0
  99. },
  100. {
  101. dispName: '待收货',
  102. typeId: 3,
  103. count: 0
  104. },
  105. {
  106. dispName: '已完结',
  107. typeId: 4,
  108. count: 0
  109. },
  110. {
  111. dispName: '已取消',
  112. typeId: 5,
  113. count: 0
  114. },
  115. {
  116. dispName: '审核不通过',
  117. typeId: 6,
  118. count: 0
  119. },
  120. ],
  121. current: 1,
  122. swiperCurrent: 1,
  123. // 查询条件
  124. pageNo: 1,
  125. pageSize: 10,
  126. list: [],
  127. total: 0,
  128. }
  129. },
  130. computed: {
  131. // 付款信息
  132. payInfo(){
  133. return this.$store.state.vuex_tempOrderData
  134. }
  135. },
  136. onLoad() {
  137. let _this = this
  138. _this.pageInit()
  139. uni.$on('refreshPurcaOrder',function(data, state){
  140. _this.resetList(data,state)
  141. })
  142. },
  143. methods:{
  144. message(title){
  145. uni.showToast({
  146. icon:'none',
  147. title: title
  148. })
  149. },
  150. priceStr: function(value) {
  151. const str = Number(value).toFixed(2).split('.')
  152. return str;
  153. },
  154. // 刷新列表
  155. resetList(item,state){
  156. // 全部列表,改变状态
  157. if(this.swiperCurrent==0){
  158. item.billStatus = state
  159. this.list.splice()
  160. }else{
  161. // 其它列表,删除当前操作的订单
  162. const index = this.list.findIndex((key)=>key.purchaseSn == item.purchaseSn)
  163. if(index>-1){
  164. this.list.splice(index,1)
  165. }
  166. }
  167. },
  168. pageInit(){
  169. this.total = 0
  170. this.pageNo = 1
  171. this.getRow()
  172. },
  173. // tabs通知swiper切换
  174. tabsChange(index) {
  175. if(index != this.swiperCurrent && this.status !='loading'){
  176. this.list = []
  177. this.status = "loading"
  178. this.swiperCurrent = index;
  179. }
  180. },
  181. swiperChange(event){
  182. this.list = []
  183. this.status = "loading"
  184. this.swiperCurrent = event.detail.current
  185. },
  186. // swiper-item左右移动,通知tabs的滑块跟随移动
  187. transition(e) {
  188. let dx = e.detail.dx;
  189. this.$refs.uTabs.setDx(dx);
  190. },
  191. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  192. // swiper滑动结束,分别设置tabs和swiper的状态
  193. animationfinish(e) {
  194. let current = e.detail.current;
  195. if(current != this.current){
  196. this.$refs.uTabs.setFinishCurrent(current);
  197. this.swiperCurrent = current;
  198. this.current = current;
  199. this.pageInit()
  200. }
  201. },
  202. // scroll-view到底部加载更多
  203. onreachBottom() {
  204. if(this.list.length < this.total){
  205. this.pageNo += 1
  206. this.getRow()
  207. }else{
  208. this.status = "nomore"
  209. }
  210. },
  211. // 取消订单
  212. cancelOrder(item){
  213. let _this = this
  214. uni.showModal({
  215. title: '提示',
  216. content: '确定取消订单吗?',
  217. success: function (res) {
  218. if (res.confirm) {
  219. purchaseCancel({purchaseSn:item.purchaseSn}).then(res => {
  220. if (res.status == 200) {
  221. _this.message('取消成功')
  222. _this.resetList(item,'CANCEl')
  223. } else {
  224. _this.message(res.message)
  225. }
  226. })
  227. }
  228. }
  229. });
  230. },
  231. // 立即支付
  232. payOrder(item){
  233. this.$store.state.vuex_tempOrderData = item
  234. this.showPopu = true
  235. },
  236. // 付款成功,isOk: false 取消支付或支付失败,true 支付完成
  237. payComplete(item,isOk){
  238. this.showPopu = false
  239. if(isOk){
  240. item.payOnlineFlag = 0
  241. this.viewRow(item)
  242. setTimeout(()=>{
  243. this.resetList(item,'WAIT_AUDIT')
  244. },150)
  245. }
  246. },
  247. // 再次购买
  248. buyAgain(item){
  249. },
  250. // 确认收货
  251. receiveOrder(item){
  252. let _this = this
  253. uni.showModal({
  254. title: '提示',
  255. content: '确定收货吗?',
  256. success: function (res) {
  257. if (res.confirm) {
  258. purchaseReceive({purchaseSn:item.purchaseSn}).then(res => {
  259. if (res.status == 200) {
  260. _this.message('收货成功')
  261. _this.resetList(item,'FINISH')
  262. } else {
  263. _this.message(res.message)
  264. }
  265. })
  266. }
  267. }
  268. });
  269. },
  270. // 查询列表
  271. getRow (pageNo) {
  272. let _this = this
  273. if (pageNo) {
  274. this.pageNo = pageNo
  275. }
  276. let params = {
  277. pageNo: this.pageNo,
  278. pageSize: this.pageSize,
  279. }
  280. // 状态条件
  281. // 待付款
  282. if(this.swiperCurrent == 1){
  283. params.billStatusList = ['WAIT_AUDIT']
  284. }
  285. // 待收货
  286. if(this.swiperCurrent == 2){
  287. params.billStatusList = ['WAIT_AUDIT','WAIT_OUT_WAREHOUSE','WAIT_RECEIVE']
  288. }
  289. // 已完成
  290. if(this.swiperCurrent == 3){
  291. params.billStatusList = ['FINISH']
  292. }
  293. // 已取消
  294. if(this.swiperCurrent == 4){
  295. params.billStatusList = ['CANCEL']
  296. }
  297. // 未审核通过
  298. if(this.swiperCurrent == 5){
  299. params.billStatusList = ['AUDIT_REJECT']
  300. }
  301. this.status = "loading"
  302. purchaseQueryPage(params).then(res => {
  303. if (res.code == 200 || res.status == 204 || res.status == 200) {
  304. let list = res.data.list || []
  305. list.map(item => {
  306. let now = new Date(item.purchaseDate)
  307. now.setMilliseconds(now.getMilliseconds() + 30 * 60 * 1000)
  308. item.timestamp = now.getTime()
  309. item.billStatus = item.billStatus == 'WAIT_AUDIT'&&item.payOnlineFlag==1&&item.payInfo&&item.payInfo.payState=='WAIT'?'WAIT_PAY':item.billStatus
  310. })
  311. // 待收款
  312. if(_this.swiperCurrent==1){
  313. list = list.filter(item => {
  314. return item.billStatus == 'WAIT_PAY'
  315. })
  316. }
  317. if(_this.pageNo>1){
  318. _this.list = _this.list.concat(list)
  319. }else{
  320. _this.list = list
  321. }
  322. _this.total = res.data.count || 0
  323. // 待收货
  324. if(_this.swiperCurrent == 2){
  325. _this.tabList[2].count = _this.total
  326. }
  327. } else {
  328. _this.list = []
  329. _this.total = 0
  330. _this.noDataText = res.message
  331. }
  332. _this.status = _this.total>=_this.list.length ? "nomore" : 'loadmore'
  333. })
  334. },
  335. // 详细页
  336. viewRow(item){
  337. this.$store.state.vuex_tempOrderData = item
  338. uni.navigateTo({
  339. url: "/pagesB/procureOrder/orderDetail?purchaseSn="+item.purchaseSn+"&state="+item.billStatus
  340. })
  341. }
  342. }
  343. }
  344. </script>
  345. <style lang="scss">
  346. page{
  347. height: 100%;
  348. }
  349. .digitShelf-pagesCons{
  350. height: 100%;
  351. display: flex;
  352. flex-direction: column;
  353. .tab-body{
  354. .check-list{
  355. height: calc(100vh - 44px);
  356. }
  357. .check-order-list{
  358. background: #ffffff;
  359. padding: 10upx 20upx;
  360. margin: 20upx;
  361. border-radius: 20upx;
  362. box-shadow: 1px 1px 3px #EEEEEE;
  363. .check-row{
  364. display: flex;
  365. font-size: 28upx;
  366. position: relative;
  367. &:first-child{
  368. color: #666E75;
  369. font-size: 24upx;
  370. padding: 20upx 0;
  371. .orderNo{
  372. font-size: 28upx;
  373. color: #222222;
  374. margin-top: -6upx;
  375. flex-grow: 1;
  376. }
  377. }
  378. &:last-child{
  379. align-items: center;
  380. justify-content: space-between;
  381. padding: 20upx 0;
  382. }
  383. .times{
  384. text-align: right;
  385. font-size: 24upx;
  386. }
  387. > view{
  388. .price{
  389. color: #666;
  390. font-size: 28upx;
  391. font-weight: bold;
  392. }
  393. .nums{
  394. font-size: 24upx;
  395. color: #666;
  396. }
  397. .waitPay{
  398. background: #f9e4e4;
  399. border-radius: 30px;
  400. display: flex;
  401. align-items: center;
  402. text{
  403. color: #fff;
  404. padding: 3px 5px;
  405. &:first-child{
  406. background: #ff0000;
  407. border-radius: 30rpx 0 20rpx 30rpx;
  408. font-size: 24rpx;
  409. }
  410. &:last-child{
  411. font-size: 20rpx;
  412. color: #ff0000;
  413. }
  414. }
  415. }
  416. }
  417. .check-row-left{
  418. display: flex;
  419. align-items: center;
  420. flex-grow:1;
  421. width: 50%;
  422. }
  423. .img-item{
  424. display: inline-block;
  425. width: 160rpx;
  426. height: 160rpx;
  427. background: #f8f8f8;
  428. border-radius: 5px;
  429. margin-right: 5px;
  430. }
  431. .product-info{
  432. flex-grow: 1;
  433. width: 60%;
  434. padding:0 5px;
  435. > text{
  436. &:last-child{
  437. margin-top: 5px;
  438. display: inline-block;
  439. color: #2196F3;
  440. width: 100%;
  441. }
  442. }
  443. }
  444. .check-row-right-fixed{
  445. position: absolute;
  446. top: 0;
  447. right:0;
  448. }
  449. .check-row-right{
  450. display: flex;
  451. flex-direction: column;
  452. justify-content: center;
  453. align-items: flex-end;
  454. padding:0 5px;
  455. height: 160rpx;
  456. min-width: 100rpx;
  457. text-align: right;
  458. font-size: 10px;
  459. background: rgba(255,255,255,0.9);
  460. }
  461. .finish{
  462. background-color: #2d8cf0;
  463. }
  464. .del{
  465. color: #666;
  466. border:2rpx solid #EDEDED;
  467. background: none;
  468. }
  469. }
  470. }
  471. }
  472. }
  473. </style>