purchase.vue 11 KB

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