orderList.vue 16 KB

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