orderList.vue 14 KB

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