orderList.vue 15 KB

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