orders.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. <template>
  2. <view class="content">
  3. <view class="nav-wrap flex">
  4. <view class="item" v-for="(nav,inden) in navList" :class="{'action': navCurrent == inden}"
  5. @click="changeNav(inden)">
  6. {{nav.tit}}
  7. </view>
  8. </view>
  9. <view class="flex nav-list">
  10. <view class="item" v-for="(item,index) in navList[navCurrent].list" :class="{'action': current == index}"
  11. @click="changeNavT(index)">
  12. {{item.tit}}
  13. </view>
  14. </view>
  15. <swiper disable-touch :style="{'height': maxHeight}" class="scroll-wrap" :current="current">
  16. <swiper-item v-for="navItem in navList[navCurrent].list">
  17. <scroll-view scroll-y="true" :style="{'height': maxHeight}" @scrolltolower="getList">
  18. <view class="order-wrap " v-for="orderItem in navItem.list">
  19. <view class="flex m-info">
  20. <image src="../../static/icon/gs-av.png" mode="" class="card-img"></image>
  21. <text style=" display: inline-block;line-height: 55rpx;" v-if="orderItem.to_user && (orderItem.to_user.phone || orderItem.to_user.nickname)">{{orderItem.to_user.phone || orderItem.to_user.nickname}}</text>
  22. </view>
  23. <view class="price">
  24. ¥{{orderItem.total_price}}
  25. </view>
  26. <view class="num">
  27. 数量:{{orderItem.amount}}
  28. </view>
  29. <view class="num">
  30. 单价:¥{{(orderItem.price*1).toFixed(2)}}
  31. </view>
  32. <view class="num">
  33. {{ getTime(orderItem.add_time)}}
  34. </view>
  35. <view class="status" :style="{color: showColor(orderItem.status)}">
  36. {{orderItem.status == 0 ? '挂售中': (orderItem.status == 1? '待支付': (orderItem.status == 2? '待审核': orderItem.status == 3 ? '已完成': (orderItem.status == 4? '已取消': '未通过')))}}
  37. </view>
  38. <view class="flex btn-list">
  39. <view class="order-btn" v-if="orderItem.status == 0 && navCurrent == 1" @click="qxOrder(orderItem)">
  40. 取消交易
  41. </view>
  42. <view class="order-btn" v-if="orderItem.status == 1 && navCurrent == 1" @click="upPz(orderItem)">
  43. 上传凭证
  44. </view>
  45. <view class="order-btn" v-if="orderItem.status == 2 && navCurrent == 1" @click="upPz(orderItem)">
  46. 修改凭证
  47. </view>
  48. <view class="order-btn" v-if="orderItem.status == 2 || orderItem.status == 3" @click="lookimg(orderItem)">
  49. 查看凭证
  50. </view>
  51. <view class="order-btn" v-if="orderItem.status == 2 && navCurrent == 0" @click="auth(orderItem,-1)">
  52. 拒绝
  53. </view>
  54. <view class="order-btn" v-if="orderItem.status == 2 && navCurrent == 0" @click="auth(orderItem,1)">
  55. 通过
  56. </view>
  57. <view class="order-btn order-btn-hui" v-if="orderItem.status == 4">
  58. 已取消
  59. </view>
  60. <view class="order-btn order-btn-hui" v-if="orderItem.status == -1" @click="lookimg(orderItem)">
  61. 查看凭证
  62. </view>
  63. <view class="order-btn order-btn-hui" v-if="orderItem.status == -1">
  64. 未通过
  65. </view>
  66. </view>
  67. </view>
  68. <empty v-if="navItem.loaded && navItem.list == 0"></empty>
  69. <uni-load-more :status="navItem.loadingType" v-else></uni-load-more>
  70. </scroll-view>
  71. </swiper-item>
  72. </swiper>
  73. <uni-popup ref="popup" type="center">
  74. <view class="pz-wrap">
  75. <view class="tit">
  76. 上传凭证
  77. </view>
  78. <image v-if="!pz" src="../../static/img/add.png" mode="" @click="upimg"></image>
  79. <image v-else :src="pz" mode="" @click="upimg"></image>
  80. <view class="btn" @click="goUp">
  81. 上传
  82. </view>
  83. </view>
  84. </uni-popup>
  85. </view>
  86. </template>
  87. <script>
  88. import {
  89. mapState,
  90. mapMutations
  91. } from 'vuex';
  92. import empty from '@/components/empty.vue'
  93. import {
  94. getGsList,
  95. qxGs,
  96. upEvaluation,
  97. auth,
  98. cancelBuy
  99. } from '@/api/zero.js'
  100. import { upload } from '@/api/order.js';
  101. export default {
  102. components: {
  103. empty
  104. },
  105. data() {
  106. return {
  107. pzing: false,
  108. orderId: '',
  109. pz: '',
  110. maxHeight: '',
  111. navCurrent: 0, // 0-》买单 1-》卖单
  112. current: 0, //二层次序
  113. navList: [{
  114. tit: '我的抢单',
  115. list: [
  116. {
  117. tit: '全部',
  118. status: -2,
  119. list: [],
  120. loadingType: 'more',
  121. page: 1,
  122. limit: 10,
  123. loaded: false
  124. },
  125. // {
  126. // tit: '抢单中',
  127. // status: 0,
  128. // list: [],
  129. // loadingType: 'more',
  130. // page: 1,
  131. // limit: 10,
  132. // loaded: false
  133. // },
  134. {
  135. tit: '待支付',
  136. status: 1,
  137. list: [],
  138. loadingType: 'more',
  139. page: 1,
  140. limit: 10,
  141. loaded: false
  142. },
  143. {
  144. tit: '待审核',
  145. status: 2,
  146. list: [],
  147. loadingType: 'more',
  148. page: 1,
  149. limit: 10,
  150. loaded: false
  151. },
  152. {
  153. tit: '已完成',
  154. status: 3,
  155. list: [],
  156. loadingType: 'more',
  157. page: 1,
  158. limit: 10,
  159. loaded: false
  160. }
  161. ]
  162. },
  163. {
  164. tit: '我的买入',
  165. list: [{
  166. tit: '全部',
  167. status: -2,
  168. list: [],
  169. loadingType: 'more',
  170. page: 1,
  171. limit: 10,
  172. loaded: false
  173. },
  174. {
  175. tit: '抢单中',
  176. status: 0,
  177. list: [],
  178. loadingType: 'more',
  179. page: 1,
  180. limit: 10,
  181. loaded: false
  182. },
  183. {
  184. tit: '待支付',
  185. status: 1,
  186. list: [],
  187. loadingType: 'more',
  188. page: 1,
  189. limit: 10,
  190. loaded: false
  191. },
  192. {
  193. tit: '待审核',
  194. status: 2,
  195. list: [],
  196. loadingType: 'more',
  197. page: 1,
  198. limit: 10,
  199. loaded: false
  200. }
  201. ]
  202. }
  203. ]
  204. }
  205. },
  206. computed: {
  207. ...mapState('user',['userInfo'])
  208. },
  209. onLoad() {
  210. },
  211. onShow() {
  212. this.getList('reload')
  213. },
  214. onReachBottom() {
  215. },
  216. onReady() {
  217. var that = this;
  218. uni.getSystemInfo({
  219. success: resu => {
  220. const query = uni.createSelectorQuery();
  221. query.select('.scroll-wrap').boundingClientRect();
  222. query.exec(function(res) {
  223. that.maxHeight = resu.windowHeight - res[0].top + 'px';
  224. });
  225. },
  226. fail: res => {}
  227. });
  228. },
  229. methods: {
  230. showColor(status) {
  231. if(status == -1 || status == 4) {
  232. return '#aaa'
  233. }else {
  234. return '#FF5570'
  235. }
  236. },
  237. auth(item,type) {
  238. let that =this
  239. uni.showModal({
  240. title: '提示',
  241. content: type == 1?'是否确认收款完成?': '是否确认当前提交的凭证没有通过审核',
  242. complete(e) {
  243. if(e.confirm) {
  244. auth({
  245. id: item.id,
  246. auth: type
  247. }).then(res => {
  248. uni.showToast({
  249. title:'审核成功',
  250. duration:2000
  251. });
  252. that.getList('reload')
  253. })
  254. }
  255. }
  256. })
  257. },
  258. // 取消交易
  259. qxOrder(item) {
  260. let that = this
  261. uni.showModal({
  262. title: '提示',
  263. content: '是否确认取消挂售?',
  264. complete(e) {
  265. if(e.confirm) {
  266. cancelBuy({
  267. id: item.id
  268. }).then(res => {
  269. uni.showToast({
  270. title:'取消成功',
  271. duration:2000
  272. });
  273. that.getList('reload')
  274. })
  275. }
  276. }
  277. })
  278. },
  279. upPz(item) {
  280. // if(item.up_files) {
  281. // this.pz = item.up_files
  282. // }
  283. // this.orderId = item.id
  284. // this.$refs.popup.open()
  285. uni.navigateTo({
  286. url: '/pages/zero/pay?id=' + item.id
  287. })
  288. },
  289. //上传凭证
  290. goUp() {
  291. if(this.pzing) {
  292. return
  293. }
  294. if(!this.pz) {
  295. return this.$api.msg('请上传凭证')
  296. }
  297. this.pzing = true
  298. upEvaluation({
  299. id: this.orderId,
  300. up_files: this.pz
  301. }).then(res => {
  302. uni.showToast({
  303. title:'上传成功',
  304. duration:2000
  305. });
  306. this.$refs.popup.close()
  307. this.orderId = ''
  308. this.getList('reload')
  309. this.pzing = false
  310. }).catch(err => {
  311. this.pzing = false
  312. })
  313. },
  314. upimg() {
  315. upload({
  316. file: ''
  317. })
  318. .then(e => {
  319. console.log(e,'e')
  320. this.pz = e[0].url
  321. console.log(this.pz)
  322. })
  323. .catch(e => {});
  324. },
  325. lookimg(item) {
  326. let arr = item.up_files.split(',')
  327. uni.previewImage({
  328. current: 0,
  329. loop: false,
  330. urls: arr,
  331. indicator: 'default'
  332. });
  333. },
  334. getTime(time) {
  335. const num =13 - (time+'').length;
  336. let l = 1;//倍数
  337. for (let i = 0; i < num; i++) {
  338. l+='0';
  339. }
  340. // 重新解析为数字
  341. l = parseInt(l)
  342. const date = new Date(parseInt(time) * l);
  343. const year = date.getFullYear();
  344. const mon = date.getMonth() + 1;
  345. const day = date.getDate();
  346. const hours = date.getHours();
  347. const minu = date.getMinutes();
  348. const sec = date.getSeconds();
  349. return year + '-' + mon + '-' + day + ' ' + hours + ':' + minu + ':' + sec;
  350. },
  351. // 切换nav
  352. changeNav(index) {
  353. if (index === this.navCurrent) {
  354. return
  355. }
  356. console.log('切换');
  357. this.navCurrent = index
  358. this.getList('tab')
  359. },
  360. changeNavT(index) {
  361. if (index === this.current) {
  362. return
  363. }
  364. console.log('切换');
  365. this.current = index
  366. this.getList('reload')
  367. },
  368. getList(type) {
  369. let that = this
  370. let item = that.navList[that.navCurrent].list[that.current]
  371. if(type == 'reload') {
  372. item.page = 1
  373. item.list = []
  374. item.loadingType = 'more'
  375. item.loaded = false
  376. }
  377. if (item.loadingType == 'loading' || item.loadingType == 'noMore') {
  378. return
  379. }
  380. if (type == 'tab' && item.loaded) {
  381. return
  382. }
  383. item.loadingType = 'loading'
  384. let qdata = {
  385. page: item.page,
  386. limit: item.limit,
  387. status: item.status,
  388. type: 1,
  389. order: 'id desc',
  390. out: 0,
  391. }
  392. if(that.navCurrent == 1) {
  393. qdata.to_uid = that.userInfo.uid
  394. }else {
  395. qdata.uid = that.userInfo.uid
  396. }
  397. getGsList(qdata).then(res => {
  398. let arr = res.data.result.list
  399. item.list = item.list.concat(arr)
  400. if (item.limit == arr.length) {
  401. item.loadingType = 'more'
  402. item.page++
  403. } else {
  404. item.loadingType = 'noMore'
  405. }
  406. item.loaded = true
  407. })
  408. }
  409. }
  410. }
  411. </script>
  412. <style lang="scss" scoped>
  413. .nav-wrap {
  414. padding: 28rpx 30rpx 20rpx;
  415. background-color: #fff;
  416. .item {
  417. width: 336rpx;
  418. height: 81rpx;
  419. border-radius: 10rpx;
  420. border: 1px solid #EC5A54;
  421. color: #EC5A54;
  422. line-height: 80rpx;
  423. text-align: center;
  424. }
  425. .action {
  426. background-color: #EC5A54;
  427. color: #fff;
  428. }
  429. }
  430. .nav-list {
  431. justify-content: space-around;
  432. background-color: #fff;
  433. font-weight: 500;
  434. color: #333333;
  435. .item {
  436. padding: 28rpx 20rpx 16rpx;
  437. }
  438. .action {
  439. color: #EC5A54;
  440. border-bottom: 2px solid red;
  441. }
  442. }
  443. .scroll-wrap {
  444. padding-top: 20rpx;
  445. }
  446. .order-wrap {
  447. width: 686rpx;
  448. // height: 297rpx;
  449. background: #FFFFFF;
  450. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50, 50, 52, 0.06);
  451. border-radius: 20rpx;
  452. margin: 0 auto 20rpx;
  453. padding: 33rpx 40rpx;
  454. position: relative;
  455. .m-info {
  456. justify-content: flex-start;
  457. image {
  458. width: 55rpx;
  459. height: 55rpx;
  460. margin-right: 13rpx;
  461. }
  462. text {
  463. font-size: 28rpx;
  464. font-weight: bold;
  465. color: #333333;
  466. }
  467. }
  468. .price {
  469. font-size: 40rpx;
  470. font-family: PingFang SC;
  471. font-weight: bold;
  472. color: #FF4C4C;
  473. padding: 40rpx 0 30rpx;
  474. }
  475. .num {
  476. font-size: 26rpx;
  477. font-weight: 500;
  478. color: #888785;
  479. }
  480. .status {
  481. position: absolute;
  482. right: 10rpx;
  483. top: 10rpx;
  484. font-size: 26rpx;
  485. }
  486. .btn-list {
  487. border-top: 1px solid #eee;
  488. margin-top: 20rpx;
  489. padding-top: 20rpx;
  490. justify-content: flex-end;
  491. }
  492. .order-btn {
  493. width: 148rpx;
  494. height: 62rpx;
  495. border: 2px solid #FF5570;
  496. border-radius: 30rpx;
  497. line-height: 62rpx;
  498. text-align: center;
  499. font-size: 28rpx;
  500. font-weight: bold;
  501. color: #FF4C4C;
  502. margin-left: 20rpx;
  503. }
  504. .order-btn-hui {
  505. color: #aaa;
  506. border: 2px solid #aaa;
  507. }
  508. }
  509. .pz-wrap {
  510. width: 550rpx;
  511. // height: 500rpx;
  512. background-color: #fff;
  513. border-radius: 20rpx;
  514. text-align: center;
  515. font-size: 32rpx;
  516. padding:40rpx;
  517. image {
  518. width: 250rpx;
  519. height: 250rpx;
  520. }
  521. .tit {
  522. font-weight: bold;
  523. padding: 20rpx 0;
  524. }
  525. .btn {
  526. background-color: $base-color;
  527. padding:0 20rpx;
  528. height: 65rpx;
  529. border-radius: 25rpx;
  530. width:250rpx;
  531. color: #fff;
  532. line-height: 60rpx;
  533. margin:20rpx auto 0;
  534. }
  535. }
  536. </style>