order.vue 12 KB

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