orderList.vue 16 KB

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