orderList.vue 16 KB

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