purchase.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. <template>
  2. <view class="content">
  3. <u-navbar title=" " @leftClick="leftClick" :placeholder="true" :autoBack="true">
  4. <view slot="center" class="hflex nav">
  5. <view class="nav_item" :class="nav_index == 1 ? 'nav_active' : ''" @click="changeNav(nav_index)">采购订单</view>
  6. <view class="nav_item" :class="nav_index == 2 ? 'nav_active' : ''" @click="changeNav(nav_index)">接单需求</view>
  7. </view>
  8. </u-navbar>
  9. <view class="" v-if="nav_index == 1">
  10. <view class="tabs">
  11. <u-tabs :list="tabs" :scrollable="false" :activeStyle="{color: '#506DFF'}" lineColor="#506DFF" @click="changeTabs"></u-tabs>
  12. </view>
  13. <view class="box1">
  14. <view class="box1_top hflex acenter">
  15. <view class="top_item" :class="sort_index == 1 ? 'top_active' : ''" @click="changeSort('1')">按照距离</view>
  16. <view class="top_item" :class="sort_index == 2 ? 'top_active' : ''" @click="changeSort('2')">价格高低</view>
  17. </view>
  18. <scroll-view :scroll-y="true" style="height: calc(100vh - 440rpx);" @scrolltolower="scrolltolower">
  19. <block v-for="(item,index) in pageList" :key="index">
  20. <view class="order_box" @click="toDetail(item.id)">
  21. <view class="order_top hflex acenter">
  22. <image src="https://ship.shipcc.cn/common/order_type1.png" v-if="item.tab == 1" class="order_img"></image>
  23. <image src="https://ship.shipcc.cn/common/order_type2.png" v-if="item.tab == 2" class="order_img"></image>
  24. <image src="https://ship.shipcc.cn/common/order_type3.png" v-if="item.tab == 3" class="order_img"></image>
  25. <image src="https://ship.shipcc.cn/common/order_type4.png" v-if="item.tab == 4" class="order_img"></image>
  26. <view class="order_title">{{item.merchant.company}}</view>
  27. </view>
  28. <view class="" v-if="item.items.length < 3">
  29. <block v-for="(item2,inx) in item.items" :key="inx">
  30. <view class="order_item">
  31. <view class="item_name text_hide">{{item2.name}}</view>
  32. <view class="hflex acenter " v-if="item.tab !== 4">
  33. <view class="text_style1 padR-20">规格:{{item2.spec}}</view>
  34. <view class="text_style1">数量:{{item2.number}}</view>
  35. </view>
  36. <view class="hflex acenter " v-else>
  37. <view class="text_style1 padR-20">数量/吨位:{{item2.weight}}</view>
  38. </view>
  39. </view>
  40. </block>
  41. </view>
  42. <view v-else>
  43. <block v-for="(item2,inx) in item.items.slice(0,2)" :key="inx">
  44. <view class="order_item">
  45. <view class="item_name text_hide">{{item2.name}}</view>
  46. <view class="hflex acenter " v-if="item.tab !== 4">
  47. <view class="text_style1 padR-20" >规格:{{item2.spec}}</view>
  48. <view class="text_style1">数量:{{item2.number}}</view>
  49. </view>
  50. <view class="hflex acenter " v-else>
  51. <view class="text_style1 padR-20" >数量/吨位:{{item2.weight}}</view>
  52. </view>
  53. </view>
  54. </block>
  55. </view>
  56. <view class="hflex acenter jbetween order_bottom">
  57. <view class="text_style1">发布于{{item.create_time.slice(0,16)}}</view>
  58. <view class="more">查看更多 》</view>
  59. </view>
  60. </view>
  61. </block>
  62. </scroll-view>
  63. </view>
  64. </view>
  65. <view class="box2" v-if="nav_index == 2">
  66. <view class="search">
  67. <u-input v-model="serach_value" type="text" border="none" placeholder="大家都在搜" shape="circle"
  68. prefixIcon="search" prefixIconStyle="font-size: 22px;color: #909399">
  69. </u-input>
  70. </view>
  71. <scroll-view :scroll-y="true" style="height: calc(100vh - 350rpx);" @scrolltolower="scrolltolower">
  72. <block v-for="(item,index) in pageList2" :key="index">
  73. <view class="box hflex acenter" @click="toDetail2(item.id)">
  74. <image :src="item.user.headimg" mode="aspectFill" class="item_avatar"></image>
  75. <view class="vflex img-right" style="margin-left: 20rpx;">
  76. <view class="item_name text_hide">{{item.username}}</view>
  77. <view class="hflex acenter cell">
  78. <u-icon name="phone-fill" color="#b8b8b8" size="14"></u-icon>
  79. <view class="text_style1" style="padding-left: 16rpx;">{{item.user.phone}}</view>
  80. </view>
  81. <view class="hflex astart cell">
  82. <u-icon name="map-fill" color="#b8b8b8" size="14"></u-icon>
  83. <text>{{item.addr}}</text>
  84. <!-- <view class="text_style1" style="padding-left: 16rpx;">{{item.addr}}</view> -->
  85. </view>
  86. </view>
  87. </view>
  88. </block>
  89. </scroll-view>
  90. <view class="add">
  91. <image src="https://ship.shipcc.cn/common/add.png" class="add_img" @click="release"></image>
  92. </view>
  93. </view>
  94. </view>
  95. </template>
  96. <script>
  97. import $api from '@/static/js/api.js'
  98. var that = ''
  99. export default {
  100. data() {
  101. return {
  102. nav_index: 1,
  103. tabs: [
  104. {
  105. index: 0,
  106. name: '采购订单',
  107. },
  108. {
  109. index: 1,
  110. name: '生产订单',
  111. },
  112. {
  113. index: 2,
  114. name: '外协订单',
  115. },
  116. {
  117. index: 3,
  118. name: '海运订单',
  119. }
  120. ],
  121. sort_index: 0,
  122. pageList: [
  123. ],
  124. pageList2: [
  125. ],
  126. serach_value: '',
  127. page: 1,
  128. limit: 10,
  129. tab_active: 0,
  130. total: 10,
  131. }
  132. },
  133. onLoad() {
  134. that = this
  135. },
  136. onShow() {
  137. /* var token = uni.getStorageSync('token')
  138. if(!token) {
  139. $api.info('请先登录')
  140. setTimeout(() =>{
  141. $api.jump('/pages/login/password_login')
  142. }, 1000)
  143. } */
  144. that.getList()
  145. // that.getList2()
  146. },
  147. onReachBottom() {
  148. console.log('滑到底部');
  149. if (Number(that.page) * Number(that.limit) >= Number(that.total)) {
  150. $api.info("没有更多了")
  151. } else {
  152. that.page++
  153. if(that.nav_index == 1) {
  154. that.getList()
  155. }else {
  156. that.getList2()
  157. }
  158. }
  159. },
  160. methods: {
  161. scrolltolower() {
  162. console.log('滑到底部');
  163. if (Number(that.page) * Number(that.limit) >= Number(that.total)) {
  164. $api.info("没有更多了")
  165. } else {
  166. that.page++
  167. if(that.nav_index == 1) {
  168. that.getList()
  169. }else {
  170. that.getList2()
  171. }
  172. }
  173. },
  174. // 返回
  175. leftClick() {
  176. console.log('返回');
  177. $api.jump(-1)
  178. },
  179. getList() {
  180. $api.req({
  181. url: '/data/api.auth.Purchase/list',
  182. data: {
  183. page: that.page,
  184. limit: that.limit,
  185. tab: Number(that.tab_active) + 1,
  186. sort: that.sort_index == 0 ? '' : that.sort_index,
  187. sort_dir: 'asc',
  188. longitude: uni.getStorageSync('userLocation').split(',')[0] ? uni.getStorageSync('userLocation').split(',')[0] : null,
  189. latitude:uni.getStorageSync('userLocation').split(',')[1] ? uni.getStorageSync('userLocation').split(',')[1] : null
  190. }
  191. }, function(res) {
  192. console.log('经纬度================',uni.getStorageSync('userLocation').split(',')[0],uni.getStorageSync('userLocation').split(',')[1]);
  193. if(res.code == 1) {
  194. if(that.page == 1) {
  195. that.pageList = res.data.data
  196. } else {
  197. that.pageList = that.pageList.concat(res.data.data)
  198. }
  199. that.total = res.data.total
  200. }
  201. })
  202. },
  203. getList2() {
  204. $api.req({
  205. url: '/data/api.auth.Purchase/needs',
  206. data: {
  207. page: that.page,
  208. limit: that.limit,
  209. keyword: that.serach_value
  210. }
  211. }, function(res) {
  212. if(res.code == 1) {
  213. if(that.page == 1) {
  214. that.pageList2 = res.data.data
  215. } else {
  216. that.pageList2 = that.pageList2.concat(res.data.data)
  217. }
  218. that.total = res.data.total
  219. }
  220. })
  221. },
  222. // 切换导航栏
  223. changeNav(index) {
  224. that.page = 1
  225. if (index == 1) {
  226. that.nav_index = 2
  227. that.getList2()
  228. } else {
  229. that.nav_index = 1
  230. that.getList()
  231. }
  232. },
  233. // 切换tabs
  234. changeTabs(e) {
  235. var token = uni.getStorageSync('token')
  236. if(!token) {
  237. $api.info('请先登录')
  238. setTimeout(() =>{
  239. $api.jump('/pages/login/password_login')
  240. }, 1000)
  241. } else {
  242. console.log(e);
  243. that.tab_active = e.index
  244. that.sort_index = 0
  245. that.page = 1
  246. that.pageList = []
  247. that.getList()
  248. }
  249. },
  250. // 切换排序
  251. changeSort(index) {
  252. if(that.sort_index == index) {
  253. that.sort_index = 0
  254. } else {
  255. that.sort_index = index
  256. }
  257. that.page = 1
  258. that.pageList = []
  259. that.getList()
  260. },
  261. // 查看订单详情
  262. toDetail(id) {
  263. var token = uni.getStorageSync('token')
  264. if(!token) {
  265. $api.info('请先登录')
  266. setTimeout(() =>{
  267. $api.jump('/pages/login/password_login')
  268. }, 1000)
  269. } else {
  270. $api.jump('/page_index/pages/purchase/orderDetail?id=' + id + '&tab=' + that.tab_active)
  271. }
  272. },
  273. // 发布
  274. release() {
  275. var token = uni.getStorageSync('token')
  276. if(!token) {
  277. $api.info('请先登录')
  278. setTimeout(() =>{
  279. $api.jump('/pages/login/password_login')
  280. }, 1000)
  281. } else {
  282. $api.jump('/page_index/pages/purchase/release')
  283. }
  284. },
  285. // 查看接单详情
  286. toDetail2(id) {
  287. var token = uni.getStorageSync('token')
  288. if(!token) {
  289. $api.info('请先登录')
  290. setTimeout(() =>{
  291. $api.jump('/pages/login/password_login')
  292. }, 1000)
  293. } else {
  294. $api.jump('/page_index/pages/purchase/receivingDetail?id=' + id)
  295. }
  296. },
  297. },
  298. }
  299. </script>
  300. <style lang="scss" scoped>
  301. .content::v-deep {
  302. background: #F4F4F4;
  303. overflow: hidden;
  304. max-height: 100vh;
  305. .nav {
  306. width: 350rpx;
  307. height: 60rpx;
  308. background: #F4F4F4;
  309. border-radius: 30rpx;
  310. font-size: 28rpx;
  311. font-weight: 400;
  312. color: #020202;
  313. .nav_item {
  314. width: 50%;
  315. height: 60rpx;
  316. background: #F4F4F4;
  317. border-radius: 15px;
  318. text-align: center;
  319. line-height: 60rpx;
  320. }
  321. .nav_active {
  322. background: #506DFF;
  323. color: #FFFFFF;
  324. }
  325. }
  326. .tabs {
  327. width: 100%;
  328. background-color: #fff;
  329. height: 80rpx;
  330. }
  331. .box1 {
  332. width: 100%;
  333. margin-top: 20rpx;
  334. background: linear-gradient(180deg, #FFFFFF 0%, #F4F4F4 100%);
  335. border-radius: 40rpx 40rpx 0px 0px;
  336. box-sizing: border-box;
  337. padding: 28rpx 30rpx 72rpx;
  338. .box1_top {
  339. width: 100%;
  340. margin-bottom: 8rpx;
  341. .top_item {
  342. width: 152rpx;
  343. height: 52rpx;
  344. background: #EDEDED;
  345. border-radius: 26rpx;
  346. margin-right: 28rpx;
  347. font-size: 26rpx;
  348. font-weight: 400;
  349. color: #666666;
  350. text-align: center;
  351. line-height: 52rpx;
  352. }
  353. .top_active {
  354. color: #516EFE;
  355. background: #EDF2FE;
  356. border-radius: 26rpx;
  357. border: 1px solid #506DFF;
  358. }
  359. }
  360. .order_box {
  361. width: 100%;
  362. margin: 20rpx 0 ;
  363. background: #FFFFFF;
  364. border-radius: 10px;
  365. box-sizing: border-box;
  366. padding: 28rpx 20rpx;
  367. .order_top {
  368. width: 100%;
  369. /* .order_type {
  370. width: 108rpx;
  371. height: 36rpx;
  372. text-align: center;
  373. line-height: 36rpx;
  374. font-size: 20rpx;
  375. color: #fff;
  376. margin-right: 5rpx;
  377. border-radius: 4rpx;
  378. }
  379. .type1 {
  380. background-color: #506dff;
  381. } */
  382. .order_img {
  383. width: 108rpx;
  384. height: 36rpx;
  385. margin-right: 5rpx;
  386. }
  387. .order_title {
  388. font-size: 32rpx;
  389. font-weight: 500;
  390. color: #222222;
  391. }
  392. }
  393. .order_item {
  394. width: 100%;
  395. padding: 20rpx 0;
  396. border-bottom: 1rpx solid #F4F4F4;
  397. }
  398. .item_name {
  399. max-width: 500rpx;
  400. font-size: 28rpx;
  401. font-weight: 400;
  402. color: #222222;
  403. padding: 20rpx 0;
  404. }
  405. .order_bottom {
  406. width: 100%;
  407. padding: 20rpx 0 0;
  408. .more {
  409. // width: 140rpx;
  410. // height: 48rpx;
  411. box-sizing: border-box;
  412. padding: 10rpx 20rpx;
  413. border-radius: 24rpx;
  414. border: 1px solid #979797;
  415. font-size: 20rpx;
  416. font-weight: 400;
  417. color: #888888;
  418. }
  419. }
  420. }
  421. }
  422. .padR-20 {
  423. padding-right: 20rpx;
  424. }
  425. .text_style1 {
  426. font-size: 24rpx;
  427. font-weight: 400;
  428. color: #888888;
  429. word-wrap: break-word;
  430. }
  431. .box2 {
  432. width: 100%;
  433. box-sizing: border-box;
  434. padding: 0 30rpx;
  435. .search {
  436. width: 100%;
  437. margin: 20rpx 0 4rpx;
  438. .u-input {
  439. background-color: #fff !important;
  440. padding: 20rpx 30rpx !important;
  441. }
  442. }
  443. .box {
  444. background: #FFFFFF;
  445. box-sizing: border-box;
  446. padding: 24rpx 20rpx;
  447. border-radius: 20rpx;
  448. margin: 20rpx 0;
  449. .item_avatar {
  450. width: 84rpx;
  451. height: 84rpx;
  452. border-radius: 50%;
  453. }
  454. .img-right {
  455. width: calc(100% - 100rpx);
  456. box-sizing: border-box;
  457. }
  458. .cell {
  459. margin-top: 20rpx;
  460. text {
  461. font-size: 24rpx;
  462. font-weight: 400;
  463. color: #888888;
  464. padding-left: 16rpx;
  465. box-sizing: border-box;
  466. }
  467. }
  468. .item_name {
  469. max-width: 500rpx;
  470. font-size: 30rpx;
  471. font-weight: 500;
  472. color: #222222;
  473. }
  474. }
  475. .add {
  476. position: fixed;
  477. right: 30rpx;
  478. bottom: 186rpx;
  479. z-index: 99;
  480. .add_img {
  481. width: 96rpx;
  482. height: 96rpx;
  483. }
  484. }
  485. }
  486. }
  487. </style>