orderList.vue 13 KB

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