orderList.vue 13 KB

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