orderList.vue 15 KB

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