orderList.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  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. item.payInfo = null
  316. this.resetList(item,'CANCEL')
  317. },
  318. // 确认收货
  319. receiveOrder(item){
  320. let _this = this
  321. uni.showModal({
  322. title: '提示',
  323. content: '确定收货吗?',
  324. success: function (res) {
  325. if (res.confirm) {
  326. purchaseReceive({purchaseSn:item.purchaseSn}).then(res => {
  327. if (res.status == 200) {
  328. _this.message('收货成功')
  329. _this.resetList(item,'FINISH')
  330. } else {
  331. _this.message(res.message)
  332. }
  333. })
  334. }
  335. }
  336. });
  337. },
  338. // 查询列表
  339. getRow (pageNo) {
  340. let _this = this
  341. if (pageNo) {
  342. this.pageNo = pageNo
  343. }
  344. let params = {
  345. pageNo: this.pageNo,
  346. pageSize: this.pageSize,
  347. }
  348. // 待付款
  349. if(this.swiperCurrent == 1 && this.hasPay){
  350. params.billStatusList = ['WAIT_AUDIT']
  351. }
  352. const tab = this.hasPay ? this.swiperCurrent : this.swiperCurrent + 1
  353. // 待收货
  354. if(tab == 2){
  355. params.billStatusList = ['WAIT_AUDIT','WAIT_OUT_WAREHOUSE','WAIT_RECEIVE']
  356. }
  357. // 已完成
  358. if(tab == 3){
  359. params.billStatusList = ['FINISH']
  360. }
  361. // 已取消
  362. if(tab == 4){
  363. params.billStatusList = ['CANCEL']
  364. }
  365. // 未审核通过
  366. if(tab == 5){
  367. params.billStatusList = ['AUDIT_REJECT']
  368. }
  369. this.status = "loading"
  370. purchaseQueryPage(params).then(res => {
  371. if (res.code == 200 || res.status == 204 || res.status == 200) {
  372. let list = res.data.list || []
  373. list.map(item => {
  374. item.billStatus = item.billStatus == 'WAIT_AUDIT'&&item.payOnlineFlag==1&&item.payInfo&&item.payInfo.payState=='WAIT'?'WAIT_PAY':item.billStatus
  375. // 计算待付款剩余倒计时
  376. if(item.billStatus== 'WAIT_PAY'){
  377. item.timestamp = (new Date(item.createDate.replace(/-/g,'/')).getTime() + 1800000 - new Date().getTime())/1000
  378. }
  379. item.payOk = item.payOnlineFlag==1&&item.payInfo&&item.payInfo.payState=='FINISH'
  380. })
  381. // 只显示待付款
  382. if(_this.hasPay&&this.swiperCurrent == 1){
  383. list = list.filter(item => item.billStatus== 'WAIT_PAY')
  384. }
  385. // 待收货里去除待付款
  386. if(_this.hasPay&&this.swiperCurrent == 2 || !_this.hasPay&&this.swiperCurrent == 1){
  387. list = list.filter(item => item.billStatus!= 'WAIT_PAY')
  388. }
  389. _this.list = _this.list.concat(list)
  390. _this.total = res.data.count || 0
  391. // 待收货或待付款显示总数
  392. if(_this.swiperCurrent == 1){
  393. // _this.tabList[_this.swiperCurrent].count = _this.total
  394. }
  395. } else {
  396. _this.list = []
  397. _this.total = 0
  398. _this.noDataText = res.message
  399. }
  400. _this.status = _this.total>=_this.list.length ? "nomore" : 'loadmore'
  401. })
  402. },
  403. // 详细页
  404. viewRow(item){
  405. this.$store.state.vuex_tempOrderData = item
  406. uni.navigateTo({
  407. url: "/pagesB/procureOrder/orderDetail?purchaseSn="+item.purchaseSn
  408. })
  409. }
  410. }
  411. }
  412. </script>
  413. <style lang="scss">
  414. page{
  415. height: 100%;
  416. }
  417. .digitShelf-pagesCons{
  418. height: 100%;
  419. display: flex;
  420. flex-direction: column;
  421. .tab-body{
  422. .check-list{
  423. height: calc(100vh - 44px);
  424. }
  425. .check-order-list{
  426. background: #ffffff;
  427. padding: 10upx 20upx;
  428. margin: 20upx;
  429. border-radius: 20upx;
  430. box-shadow: 1px 1px 3px #EEEEEE;
  431. .check-row{
  432. display: flex;
  433. font-size: 28upx;
  434. position: relative;
  435. &:first-child{
  436. color: #666E75;
  437. font-size: 24upx;
  438. padding: 20upx 0;
  439. .orderNo{
  440. font-size: 28upx;
  441. color: #222222;
  442. margin-top: -6upx;
  443. flex-grow: 1;
  444. }
  445. }
  446. &:last-child{
  447. align-items: center;
  448. justify-content: space-between;
  449. padding: 20upx 0;
  450. }
  451. .times{
  452. text-align: right;
  453. font-size: 24upx;
  454. }
  455. > view{
  456. .price{
  457. color: #666;
  458. font-size: 28upx;
  459. font-weight: bold;
  460. }
  461. .nums{
  462. font-size: 24upx;
  463. color: #666;
  464. }
  465. .waitPay{
  466. background: #f9e4e4;
  467. border-radius: 30px;
  468. display: flex;
  469. align-items: center;
  470. text{
  471. color: #fff;
  472. padding: 3px 5px;
  473. &:first-child{
  474. background: #ff0000;
  475. border-radius: 30rpx 0 20rpx 30rpx;
  476. font-size: 24rpx;
  477. }
  478. &:last-child{
  479. font-size: 20rpx;
  480. color: #ff0000;
  481. }
  482. }
  483. }
  484. }
  485. .check-row-left{
  486. display: flex;
  487. align-items: center;
  488. flex-grow:1;
  489. width: 50%;
  490. }
  491. .img-item{
  492. display: inline-block;
  493. width: 160rpx;
  494. height: 160rpx;
  495. background: #f8f8f8;
  496. border-radius: 5px;
  497. margin-right: 5px;
  498. }
  499. .product-info{
  500. flex-grow: 1;
  501. width: 60%;
  502. padding:0 5px;
  503. > text{
  504. &:last-child{
  505. margin-top: 5px;
  506. display: inline-block;
  507. color: #2196F3;
  508. width: 100%;
  509. }
  510. }
  511. }
  512. .check-row-right-fixed{
  513. position: absolute;
  514. top: 0;
  515. right:0;
  516. }
  517. .check-row-right{
  518. display: flex;
  519. flex-direction: column;
  520. justify-content: center;
  521. align-items: flex-end;
  522. padding:0 5px;
  523. height: 160rpx;
  524. min-width: 100rpx;
  525. text-align: right;
  526. font-size: 10px;
  527. background: rgba(255,255,255,0.9);
  528. }
  529. .finish{
  530. background-color: #2d8cf0;
  531. }
  532. .del{
  533. color: #666;
  534. border:2rpx solid #EDEDED;
  535. background: none;
  536. }
  537. }
  538. }
  539. }
  540. }
  541. </style>