orderList.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  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="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. const index = this.list.findIndex((key)=>key.purchaseSn == item.purchaseSn)
  192. // 全部列表,改变状态
  193. if(this.swiperCurrent==0){
  194. purchaseQueryPage({pageNo:1,pageSize:1,purchaseSn: item.purchaseSn}).then(res => {
  195. const data = res.data ? res.data.list[0] : null
  196. if(data){
  197. data.billStatus = data.billStatus == 'WAIT_AUDIT'&&data.payOnlineFlag==1&&data.payInfo&&data.payInfo.payState=='WAIT'?'WAIT_PAY':data.billStatus
  198. this.list.splice(index,1,data)
  199. }
  200. })
  201. }else{
  202. if(index>-1){
  203. this.list.splice(index,1)
  204. }
  205. }
  206. },
  207. pageInit(){
  208. this.total = 0
  209. this.pageNo = 1
  210. this.getRow()
  211. },
  212. // tabs通知swiper切换
  213. tabsChange(index) {
  214. if(index != this.swiperCurrent && this.status !='loading'){
  215. this.list = []
  216. this.status = "loading"
  217. this.swiperCurrent = index;
  218. }
  219. },
  220. swiperChange(event){
  221. this.list = []
  222. this.status = "loading"
  223. this.swiperCurrent = event.detail.current
  224. },
  225. // swiper-item左右移动,通知tabs的滑块跟随移动
  226. transition(e) {
  227. let dx = e.detail.dx;
  228. this.$refs.uTabs.setDx(dx);
  229. },
  230. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  231. // swiper滑动结束,分别设置tabs和swiper的状态
  232. animationfinish(e) {
  233. let current = e.detail.current;
  234. if(current != this.current){
  235. this.$refs.uTabs.setFinishCurrent(current);
  236. this.swiperCurrent = current;
  237. this.current = current;
  238. this.pageInit()
  239. }
  240. },
  241. // scroll-view到底部加载更多
  242. onreachBottom() {
  243. if(this.list.length < this.total){
  244. this.pageNo += 1
  245. this.getRow()
  246. }else{
  247. this.status = "nomore"
  248. }
  249. },
  250. // 取消订单
  251. cancelOrder(item){
  252. let _this = this
  253. uni.showModal({
  254. title: '提示',
  255. content: !item.payOk ? '确定取消订单吗?':'取消后订单金额将于1-3个工作日到账(原路返回)?',
  256. success: function (res) {
  257. if (res.confirm) {
  258. purchaseCancel({purchaseSn:item.purchaseSn}).then(res => {
  259. if (res.status == 200) {
  260. _this.message('取消成功')
  261. _this.resetList(item,'CANCEL')
  262. } else {
  263. _this.message(res.message)
  264. }
  265. })
  266. }
  267. }
  268. });
  269. },
  270. // 立即支付
  271. payOrder(item){
  272. const _this = this
  273. this.$store.state.vuex_tempOrderData = item
  274. uni.showLoading({
  275. title: '加载中...'
  276. })
  277. purchasePay({
  278. bizSn:item.purchaseSn,
  279. bizNo:item.purchaseNo,
  280. bizType:'PURCHASE',
  281. payUserOpenId: this.$store.state.vuex_openid || uni.getStorageSync('openid')
  282. }).then(res=>{
  283. uni.hideLoading()
  284. if(res.status == 200){
  285. this.showPopu = true
  286. this.payData = res.data?res.data.payRequestRest:null
  287. }else{
  288. if(res.data.errorCode == 'VALIDATE_F_00001'){
  289. uni.showModal({
  290. showCancel:false,
  291. title: '提示',
  292. content: '下单人员与支付人员不一致,请在订单详情核实后再支付',
  293. success: function (res) {
  294. if (res.confirm) {
  295. _this.viewRow(item)
  296. }
  297. }
  298. });
  299. }
  300. }
  301. })
  302. },
  303. // 付款成功,isOk: false 取消支付或支付失败,true 支付完成
  304. payComplete(item,isOk){
  305. this.showPopu = false
  306. if(isOk){
  307. item.payOnlineFlag = 0
  308. item.billStatus = 'WAIT_AUDIT'
  309. this.viewRow(item)
  310. setTimeout(()=>{
  311. this.resetList(item,'WAIT_AUDIT')
  312. },150)
  313. }
  314. },
  315. // 再次购买
  316. buyAgain(item){
  317. },
  318. // 订单超时
  319. countDownEnd(item){
  320. item.payInfo = null
  321. this.resetList(item,'CANCEL')
  322. },
  323. // 确认收货
  324. receiveOrder(item){
  325. let _this = this
  326. uni.showModal({
  327. title: '提示',
  328. content: '确定收货吗?',
  329. success: function (res) {
  330. if (res.confirm) {
  331. purchaseReceive({purchaseSn:item.purchaseSn}).then(res => {
  332. if (res.status == 200) {
  333. _this.message('收货成功')
  334. _this.resetList(item,'FINISH')
  335. } else {
  336. _this.message(res.message)
  337. }
  338. })
  339. }
  340. }
  341. });
  342. },
  343. // 查询列表
  344. getRow (pageNo) {
  345. let _this = this
  346. if (pageNo) {
  347. this.pageNo = pageNo
  348. }
  349. let params = {
  350. pageNo: this.pageNo,
  351. pageSize: this.pageSize,
  352. }
  353. // 待付款
  354. if(this.swiperCurrent == 1 && this.hasPay){
  355. params.billStatusList = ['WAIT_AUDIT']
  356. }
  357. const tab = this.hasPay ? this.swiperCurrent : this.swiperCurrent + 1
  358. // 待收货
  359. if(tab == 2){
  360. params.billStatusList = ['WAIT_AUDIT','WAIT_OUT_WAREHOUSE','WAIT_RECEIVE']
  361. }
  362. // 已完成
  363. if(tab == 3){
  364. params.billStatusList = ['FINISH']
  365. }
  366. // 已取消
  367. if(tab == 4){
  368. params.billStatusList = ['CANCEL']
  369. }
  370. // 未审核通过
  371. if(tab == 5){
  372. params.billStatusList = ['AUDIT_REJECT']
  373. }
  374. this.status = "loading"
  375. purchaseQueryPage(params).then(res => {
  376. if (res.code == 200 || res.status == 204 || res.status == 200) {
  377. let list = res.data.list || []
  378. list.map(item => {
  379. item.billStatus = item.billStatus == 'WAIT_AUDIT'&&item.payOnlineFlag==1&&item.payInfo&&item.payInfo.payState=='WAIT'?'WAIT_PAY':item.billStatus
  380. // 计算待付款剩余倒计时
  381. if(item.billStatus== 'WAIT_PAY'){
  382. item.timestamp = (new Date(item.createDate.replace(/-/g,'/')).getTime() + 1800000 - new Date().getTime())/1000
  383. }
  384. item.payOk = item.payOnlineFlag==1&&item.payInfo&&item.payInfo.payState=='FINISH'
  385. })
  386. // 只显示待付款
  387. if(_this.hasPay&&this.swiperCurrent == 1){
  388. list = list.filter(item => item.billStatus== 'WAIT_PAY')
  389. }
  390. // 待收货里去除待付款
  391. if(_this.hasPay&&this.swiperCurrent == 2 || !_this.hasPay&&this.swiperCurrent == 1){
  392. list = list.filter(item => item.billStatus!= 'WAIT_PAY')
  393. }
  394. _this.list = _this.list.concat(list)
  395. _this.total = res.data.count || 0
  396. // 待收货或待付款显示总数
  397. if(_this.swiperCurrent == 1){
  398. // _this.tabList[_this.swiperCurrent].count = _this.total
  399. }
  400. } else {
  401. _this.list = []
  402. _this.total = 0
  403. _this.noDataText = res.message
  404. }
  405. _this.status = _this.total>=_this.list.length ? "nomore" : 'loadmore'
  406. })
  407. },
  408. // 详细页
  409. viewRow(item){
  410. this.$store.state.vuex_tempOrderData = item
  411. uni.navigateTo({
  412. url: "/pagesB/procureOrder/orderDetail?purchaseSn="+item.purchaseSn
  413. })
  414. }
  415. }
  416. }
  417. </script>
  418. <style lang="scss">
  419. page{
  420. height: 100%;
  421. }
  422. .digitShelf-pagesCons{
  423. height: 100%;
  424. display: flex;
  425. flex-direction: column;
  426. .tab-body{
  427. .check-list{
  428. height: calc(100vh - 44px);
  429. }
  430. .check-order-list{
  431. background: #ffffff;
  432. padding: 10upx 20upx;
  433. margin: 20upx;
  434. border-radius: 20upx;
  435. box-shadow: 1px 1px 3px #EEEEEE;
  436. .check-row{
  437. display: flex;
  438. font-size: 28upx;
  439. position: relative;
  440. &:first-child{
  441. color: #666E75;
  442. font-size: 24upx;
  443. padding: 20upx 0;
  444. .orderNo{
  445. font-size: 28upx;
  446. color: #222222;
  447. margin-top: -6upx;
  448. flex-grow: 1;
  449. }
  450. }
  451. &:last-child{
  452. align-items: center;
  453. justify-content: space-between;
  454. padding: 20upx 0;
  455. }
  456. .times{
  457. text-align: right;
  458. font-size: 24upx;
  459. }
  460. > view{
  461. .price{
  462. color: #666;
  463. font-size: 28upx;
  464. font-weight: bold;
  465. }
  466. .nums{
  467. font-size: 24upx;
  468. color: #666;
  469. }
  470. .waitPay{
  471. background: #f9e4e4;
  472. border-radius: 30px;
  473. display: flex;
  474. align-items: center;
  475. text{
  476. color: #fff;
  477. padding: 3px 5px;
  478. &:first-child{
  479. background: #ff0000;
  480. border-radius: 30rpx 0 20rpx 30rpx;
  481. font-size: 24rpx;
  482. }
  483. &:last-child{
  484. font-size: 20rpx;
  485. color: #ff0000;
  486. }
  487. }
  488. }
  489. }
  490. .check-row-left{
  491. display: flex;
  492. align-items: center;
  493. flex-grow:1;
  494. width: 50%;
  495. }
  496. .img-item{
  497. display: inline-block;
  498. width: 160rpx;
  499. height: 160rpx;
  500. background: #f8f8f8;
  501. border-radius: 5px;
  502. margin-right: 5px;
  503. border: 1px solid #eee;
  504. overflow: hidden;
  505. }
  506. .product-info{
  507. flex-grow: 1;
  508. width: 60%;
  509. padding:0 5px;
  510. > text{
  511. &:last-child{
  512. margin-top: 5px;
  513. display: inline-block;
  514. color: #2196F3;
  515. width: 100%;
  516. }
  517. }
  518. }
  519. .check-row-right-fixed{
  520. position: absolute;
  521. top: 0;
  522. right:0;
  523. }
  524. .check-row-right{
  525. display: flex;
  526. flex-direction: column;
  527. justify-content: center;
  528. align-items: flex-end;
  529. padding:0 5px;
  530. height: 160rpx;
  531. min-width: 100rpx;
  532. text-align: right;
  533. font-size: 10px;
  534. background: rgba(255,255,255,0.9);
  535. }
  536. .finish{
  537. background-color: #2d8cf0;
  538. }
  539. .del{
  540. color: #666;
  541. border:2rpx solid #EDEDED;
  542. background: none;
  543. }
  544. }
  545. }
  546. }
  547. }
  548. </style>