order.vue 11 KB

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