orderList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <template>
  2. <view class="digitShelf-pagesCons">
  3. <view class="tab-body">
  4. <view>
  5. <u-tabs-swiper ref="uTabs" :list="tabList" :offset="[5,40]" bar-width='100' active-color="#1283d4" name="dispName" :current="current" @change="tabsChange" :is-scroll="false"
  6. swiperWidth="750"></u-tabs-swiper>
  7. </view>
  8. <swiper class="check-list" :current="swiperCurrent" @transition="transition" @change="swiperChange" @animationfinish="animationfinish">
  9. <swiper-item class="swiper-item" style="height: 100%;width: 100%;overflow: hidden;" v-for="(tabs, indexs) in tabList" :key="indexs">
  10. <scroll-view scroll-y style="height: 100%;width: 100%;overflow: auto;" @scrolltolower="onreachBottom" v-if="swiperCurrent == indexs">
  11. <view
  12. class="check-order-list"
  13. v-for="(item,index) in list"
  14. :key="item.id"
  15. @click="viewRow(item)"
  16. >
  17. <view class="check-row align_center justify_between">
  18. <view class="orderNo">{{item.purchaseNo}}</view>
  19. <view class="times">
  20. <span v-if="item.billStatus == 'WAIT_AUDIT'&&item.payOnlineFlag==0">待审核</span>
  21. <view v-if="item.billStatus == 'WAIT_PAY'" class="waitPay">
  22. <text>待付款</text>
  23. <view style="padding:0 5px;">
  24. <u-count-down separator="zh" :separator-size="24" bg-color="none" :timestamp="item.timestamp" :show-days="false" :show-hours="false"></u-count-down>
  25. </view>
  26. </view>
  27. <span v-if="item.billStatus == 'AUDIT_REJECT'">审核不通过</span>
  28. <span v-if="item.billStatus == 'WAIT_OUT_WAREHOUSE' || item.billStatus == 'WAIT_RECEIVE'">待收货</span>
  29. <span v-if="item.billStatus == 'FINISH'">已完结</span>
  30. <span v-if="item.billStatus == 'CANCEL'">已取消</span>
  31. </view>
  32. </view>
  33. <view class="check-row">
  34. <view v-if="item.totalCategory>1" class="check-row-left">
  35. <scroll-view style="width: 100%;white-space: nowrap;" scroll-x="true">
  36. <view class="img-item" v-for="item in item.productList" :key="item.id">
  37. <image :src="item.images||'/static/def_imgs.png'" style="width: 100%;height: 100%;"></image>
  38. </view>
  39. </scroll-view>
  40. </view>
  41. <view v-else class="check-row-left">
  42. <view class="img-item">
  43. <image :src="item.productList&&item.productList[0].images||'/static/def_imgs.png'" style="width: 100%;height: 100%;"></image>
  44. </view>
  45. <view class="product-info">
  46. <text class="ellipsis-two">{{item.productList&&item.productList[0].productName ||'--'}}</text>
  47. <text class="ellipsis-one">{{item.productList&&item.productList[0].code||''}}</text>
  48. <text class="ellipsis-one">{{item.productList&&item.productList[0].origCode||''}}</text>
  49. </view>
  50. </view>
  51. <view :class="item.totalCategory>1?'check-row-right check-row-right-fixed':'check-row-right'">
  52. <view>¥<text class="price">{{priceStr(item.totalAmount)[0]}}</text>.{{priceStr(item.totalAmount)[1]}}</view>
  53. <view><text class="nums">共{{item.totalQty}}件</text></view>
  54. </view>
  55. </view>
  56. <view class="check-row">
  57. <view class="times">
  58. {{item.createDate}}
  59. </view>
  60. <view style="text-align: right;color: #999;">
  61. <u-button style="margin-left: 10px;" v-if="item.billStatus == 'WAIT_AUDIT'" size="mini" shape="round" type="default" plain @click="cancelOrder(item)">取消订单</u-button>
  62. <u-button style="margin-left: 10px;" v-if="item.billStatus == 'WAIT_PAY'" size="mini" shape="round" type="error" plain @click="payOrder(item)">立即支付</u-button>
  63. <!-- <u-button style="margin-left: 10px;" v-if="item.billStatus == 'CANCEL'" size="mini" shape="round" type="error" plain @click="buyAgain(item)">再次购买</u-button> -->
  64. <u-button style="margin-left: 10px;" v-if="item.billStatus == 'WAIT_RECEIVE'" size="mini" shape="round" type="error" plain @click="receiveOrder(item)">确认收货</u-button>
  65. </view>
  66. </view>
  67. </view>
  68. <view style="padding: 20upx;">
  69. <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>
  70. <u-loadmore v-if="(total>=list.length&&list.length)||status=='loading'" :status="status" />
  71. </view>
  72. </scroll-view>
  73. </swiper-item>
  74. </swiper>
  75. </view>
  76. <!-- 付款弹框 -->
  77. <payModal :showPopu="showPopu" :payInfo="payInfo" :payData="payData" @close="showPopu=false" @payComplete="payComplete"></payModal>
  78. </view>
  79. </template>
  80. <script>
  81. import { purchaseQueryPage,purchaseCancel,purchaseReceive,purchasePay } from '@/api/purchase.js'
  82. import payModal from '../components/payModal.vue'
  83. export default {
  84. components:{
  85. payModal
  86. },
  87. data() {
  88. return {
  89. status: 'loading',
  90. noDataText: '暂无数据',
  91. showPopu: false,
  92. tabList: [
  93. {
  94. dispName: '全部',
  95. typeId: 1,
  96. count: 0
  97. },
  98. {
  99. dispName: '待付款',
  100. typeId: 2,
  101. count: 0
  102. },
  103. {
  104. dispName: '待收货',
  105. typeId: 3,
  106. count: 0
  107. },
  108. {
  109. dispName: '已完结',
  110. typeId: 4,
  111. count: 0
  112. },
  113. {
  114. dispName: '已取消',
  115. typeId: 5,
  116. count: 0
  117. },
  118. {
  119. dispName: '审核不通过',
  120. typeId: 6,
  121. count: 0
  122. },
  123. ],
  124. current: 1,
  125. swiperCurrent: 1,
  126. // 查询条件
  127. pageNo: 1,
  128. pageSize: 10,
  129. list: [],
  130. total: 0,
  131. payData: null
  132. }
  133. },
  134. computed: {
  135. // 付款信息
  136. payInfo(){
  137. return this.$store.state.vuex_tempOrderData
  138. }
  139. },
  140. onLoad() {
  141. let _this = this
  142. _this.pageInit()
  143. uni.$on('refreshPurcaOrder',function(data, state){
  144. _this.resetList(data,state)
  145. })
  146. },
  147. methods:{
  148. message(title){
  149. uni.showToast({
  150. icon:'none',
  151. title: title
  152. })
  153. },
  154. priceStr: function(value) {
  155. const str = Number(value).toFixed(2).split('.')
  156. return str;
  157. },
  158. // 刷新列表
  159. resetList(item,state){
  160. // 全部列表,改变状态
  161. if(this.swiperCurrent==0){
  162. item.billStatus = state
  163. this.list.splice()
  164. }else{
  165. // 其它列表,删除当前操作的订单
  166. const index = this.list.findIndex((key)=>key.purchaseSn == item.purchaseSn)
  167. if(index>-1){
  168. this.list.splice(index,1)
  169. }
  170. }
  171. },
  172. pageInit(){
  173. this.total = 0
  174. this.pageNo = 1
  175. this.getRow()
  176. },
  177. // tabs通知swiper切换
  178. tabsChange(index) {
  179. if(index != this.swiperCurrent && this.status !='loading'){
  180. this.list = []
  181. this.status = "loading"
  182. this.swiperCurrent = index;
  183. }
  184. },
  185. swiperChange(event){
  186. this.list = []
  187. this.status = "loading"
  188. this.swiperCurrent = event.detail.current
  189. },
  190. // swiper-item左右移动,通知tabs的滑块跟随移动
  191. transition(e) {
  192. let dx = e.detail.dx;
  193. this.$refs.uTabs.setDx(dx);
  194. },
  195. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  196. // swiper滑动结束,分别设置tabs和swiper的状态
  197. animationfinish(e) {
  198. let current = e.detail.current;
  199. if(current != this.current){
  200. this.$refs.uTabs.setFinishCurrent(current);
  201. this.swiperCurrent = current;
  202. this.current = current;
  203. this.pageInit()
  204. }
  205. },
  206. // scroll-view到底部加载更多
  207. onreachBottom() {
  208. if(this.list.length < this.total){
  209. this.pageNo += 1
  210. this.getRow()
  211. }else{
  212. this.status = "nomore"
  213. }
  214. },
  215. // 取消订单
  216. cancelOrder(item){
  217. let _this = this
  218. uni.showModal({
  219. title: '提示',
  220. content: '确定取消订单吗?',
  221. success: function (res) {
  222. if (res.confirm) {
  223. purchaseCancel({purchaseSn:item.purchaseSn}).then(res => {
  224. if (res.status == 200) {
  225. _this.message('取消成功')
  226. _this.resetList(item,'CANCEl')
  227. } else {
  228. _this.message(res.message)
  229. }
  230. })
  231. }
  232. }
  233. });
  234. },
  235. // 立即支付
  236. payOrder(item){
  237. this.$store.state.vuex_tempOrderData = item
  238. purchasePay({
  239. bizSn:item.purchaseSn,
  240. bizNo:item.purchaseNo,
  241. bizType:'PURCHASE',
  242. payUserOpenId: this.$store.state.vuex_openid || uni.getStorageSync('openid')
  243. }).then(res=>{
  244. this.showPopu = true
  245. this.payData = res.data?res.data.payRequestRest:null
  246. })
  247. },
  248. // 付款成功,isOk: false 取消支付或支付失败,true 支付完成
  249. payComplete(item,isOk){
  250. this.showPopu = false
  251. if(isOk){
  252. item.payOnlineFlag = 0
  253. item.billStatus = 'WAIT_AUDIT'
  254. this.viewRow(item)
  255. setTimeout(()=>{
  256. this.resetList(item,'WAIT_AUDIT')
  257. },150)
  258. }
  259. },
  260. // 再次购买
  261. buyAgain(item){
  262. },
  263. // 确认收货
  264. receiveOrder(item){
  265. let _this = this
  266. uni.showModal({
  267. title: '提示',
  268. content: '确定收货吗?',
  269. success: function (res) {
  270. if (res.confirm) {
  271. purchaseReceive({purchaseSn:item.purchaseSn}).then(res => {
  272. if (res.status == 200) {
  273. _this.message('收货成功')
  274. _this.resetList(item,'FINISH')
  275. } else {
  276. _this.message(res.message)
  277. }
  278. })
  279. }
  280. }
  281. });
  282. },
  283. // 查询列表
  284. getRow (pageNo) {
  285. let _this = this
  286. if (pageNo) {
  287. this.pageNo = pageNo
  288. }
  289. let params = {
  290. pageNo: this.pageNo,
  291. pageSize: this.pageSize,
  292. }
  293. // 状态条件
  294. // 待付款
  295. if(this.swiperCurrent == 1){
  296. params.billStatusList = ['WAIT_AUDIT']
  297. }
  298. // 待收货
  299. if(this.swiperCurrent == 2){
  300. params.billStatusList = ['WAIT_AUDIT','WAIT_OUT_WAREHOUSE','WAIT_RECEIVE']
  301. }
  302. // 已完成
  303. if(this.swiperCurrent == 3){
  304. params.billStatusList = ['FINISH']
  305. }
  306. // 已取消
  307. if(this.swiperCurrent == 4){
  308. params.billStatusList = ['CANCEL']
  309. }
  310. // 未审核通过
  311. if(this.swiperCurrent == 5){
  312. params.billStatusList = ['AUDIT_REJECT']
  313. }
  314. this.status = "loading"
  315. purchaseQueryPage(params).then(res => {
  316. if (res.code == 200 || res.status == 204 || res.status == 200) {
  317. let list = res.data.list || []
  318. list.map(item => {
  319. let now = new Date(item.purchaseDate)
  320. now.setMilliseconds(now.getMilliseconds() + 30 * 60 * 1000)
  321. item.timestamp = now.getTime()
  322. item.billStatus = item.billStatus == 'WAIT_AUDIT'&&item.payOnlineFlag==1&&item.payInfo&&item.payInfo.payState=='WAIT'?'WAIT_PAY':item.billStatus
  323. })
  324. // 待收款
  325. if(_this.swiperCurrent==1){
  326. list = list.filter(item => {
  327. return item.billStatus == 'WAIT_PAY'
  328. })
  329. }
  330. if(_this.pageNo>1){
  331. _this.list = _this.list.concat(list)
  332. }else{
  333. _this.list = list
  334. }
  335. _this.total = res.data.count || 0
  336. // 待收货
  337. if(_this.swiperCurrent == 2){
  338. _this.tabList[2].count = _this.total
  339. }
  340. } else {
  341. _this.list = []
  342. _this.total = 0
  343. _this.noDataText = res.message
  344. }
  345. _this.status = _this.total>=_this.list.length ? "nomore" : 'loadmore'
  346. })
  347. },
  348. // 详细页
  349. viewRow(item){
  350. this.$store.state.vuex_tempOrderData = item
  351. uni.navigateTo({
  352. url: "/pagesB/procureOrder/orderDetail?purchaseSn="+item.purchaseSn+"&state="+item.billStatus
  353. })
  354. }
  355. }
  356. }
  357. </script>
  358. <style lang="scss">
  359. page{
  360. height: 100%;
  361. }
  362. .digitShelf-pagesCons{
  363. height: 100%;
  364. display: flex;
  365. flex-direction: column;
  366. .tab-body{
  367. .check-list{
  368. height: calc(100vh - 44px);
  369. }
  370. .check-order-list{
  371. background: #ffffff;
  372. padding: 10upx 20upx;
  373. margin: 20upx;
  374. border-radius: 20upx;
  375. box-shadow: 1px 1px 3px #EEEEEE;
  376. .check-row{
  377. display: flex;
  378. font-size: 28upx;
  379. position: relative;
  380. &:first-child{
  381. color: #666E75;
  382. font-size: 24upx;
  383. padding: 20upx 0;
  384. .orderNo{
  385. font-size: 28upx;
  386. color: #222222;
  387. margin-top: -6upx;
  388. flex-grow: 1;
  389. }
  390. }
  391. &:last-child{
  392. align-items: center;
  393. justify-content: space-between;
  394. padding: 20upx 0;
  395. }
  396. .times{
  397. text-align: right;
  398. font-size: 24upx;
  399. }
  400. > view{
  401. .price{
  402. color: #666;
  403. font-size: 28upx;
  404. font-weight: bold;
  405. }
  406. .nums{
  407. font-size: 24upx;
  408. color: #666;
  409. }
  410. .waitPay{
  411. background: #f9e4e4;
  412. border-radius: 30px;
  413. display: flex;
  414. align-items: center;
  415. text{
  416. color: #fff;
  417. padding: 3px 5px;
  418. &:first-child{
  419. background: #ff0000;
  420. border-radius: 30rpx 0 20rpx 30rpx;
  421. font-size: 24rpx;
  422. }
  423. &:last-child{
  424. font-size: 20rpx;
  425. color: #ff0000;
  426. }
  427. }
  428. }
  429. }
  430. .check-row-left{
  431. display: flex;
  432. align-items: center;
  433. flex-grow:1;
  434. width: 50%;
  435. }
  436. .img-item{
  437. display: inline-block;
  438. width: 160rpx;
  439. height: 160rpx;
  440. background: #f8f8f8;
  441. border-radius: 5px;
  442. margin-right: 5px;
  443. }
  444. .product-info{
  445. flex-grow: 1;
  446. width: 60%;
  447. padding:0 5px;
  448. > text{
  449. &:last-child{
  450. margin-top: 5px;
  451. display: inline-block;
  452. color: #2196F3;
  453. width: 100%;
  454. }
  455. }
  456. }
  457. .check-row-right-fixed{
  458. position: absolute;
  459. top: 0;
  460. right:0;
  461. }
  462. .check-row-right{
  463. display: flex;
  464. flex-direction: column;
  465. justify-content: center;
  466. align-items: flex-end;
  467. padding:0 5px;
  468. height: 160rpx;
  469. min-width: 100rpx;
  470. text-align: right;
  471. font-size: 10px;
  472. background: rgba(255,255,255,0.9);
  473. }
  474. .finish{
  475. background-color: #2d8cf0;
  476. }
  477. .del{
  478. color: #666;
  479. border:2rpx solid #EDEDED;
  480. background: none;
  481. }
  482. }
  483. }
  484. }
  485. }
  486. </style>