home.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. <template>
  2. <view>
  3. <view class="header">
  4. <view class="flex justify-between map">
  5. <view class='Medium flex align-item-center locationwrap'
  6. @click='naviageToPage("/pages/grain_pulse/position/position")'>
  7. <image class='location' src="../../static/img/liangmai/icon_ditu@2x.png" mode=""></image>
  8. {{position.name}}
  9. </view>
  10. <view @click='naviageToPage("/pages/grain_pulse/distribution/distribution?position="+JSON.stringify(position))'
  11. class='Regular flex align-item-center distribution justify-center'>
  12. <image class='cangku' src="../../static/img/liangmai/cangku.png" mode=""></image>
  13. 分布
  14. </view>
  15. </view>
  16. <u-search :show-action="true" action-text="搜索" :animation="true"></u-search>
  17. <!-- <view class="cu-bar search">
  18. <view class="search-form round" @click="naviageToPage('/pages/grain_pulse/search')">
  19. <image class='icon-scarch' src="../../static/img/liangmai/sousuo.png" mode=""></image>
  20. <view class='Regular'> 请输入货名或标题</view>
  21. </view>
  22. </view> -->
  23. </view>
  24. <view class="content">
  25. <view @click='friendcircle' class="friendcircle">
  26. <view class='title flex align-item-center Medium'>
  27. <image class='icon-friendcircle' src="../../static/img/liangmai/icon.png" mode=""></image>
  28. 圈友说
  29. </view>
  30. <view class='friendcircle-content flex justify-between'>
  31. <image class='bg' src="../../static/img/liangmai/bg.png" mode=""></image>
  32. <view class='friendcircle-content-right'>
  33. <view v-for='item in releaseInfo' class='friendcircle-content-right-item Regular flex align-item-center'>
  34. <image class='headportrait' v-if='item.avatarUrl' :src="item.avatarUrl" mode=""></image>
  35. <image class='headportrait' v-else src="../../static/img/myimg/YongHu@3x.png" mode=""></image>
  36. {{item.title}}
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <scroll-view scroll-x="true" scroll-with-animation="true" class='list-type'>
  42. <view v-for='item in searchTypes' @click='mainBusinessTypechange(item)'
  43. :class='mainBusinessTypeKey==item.value?"Semibold active":"Regular"' class="typeitem">{{item.name}}
  44. </view>
  45. </scroll-view>
  46. <view v-if='datalist.length>0' v-for='item in datalist' @click='todetails(item)' class="listitem">
  47. <view class="flex">
  48. <image style='width:98px;height:97px;flex:1;' class='listitem-left' :src="item.attachmentAddress" mode=""></image>
  49. <view style='flex:2;' class="listitem-right">
  50. <view class="companyname Medium">{{item.compName}}</view>
  51. <view class='Regular introduce'>{{item.companyProfile}}</view>
  52. </view>
  53. </view>
  54. <view class="flex align-item-center justify-between">
  55. <view @click.stop='naviageToPage1(item,"/pages/grain_pulse/localtion/localtion")'
  56. class='companylocation flex align-item-center Regular'>
  57. <image class='location' src="../../static/img/liangmai/icon_ditu.png" mode=""></image>
  58. {{item.province}}{{item.city}}{{item.area}}{{item.detailedAddress}}
  59. </view>
  60. <view v-if='position.name!="未设置"' class='distance Regular'>{{item._metre}}</view>
  61. </view>
  62. </view>
  63. <view style='padding:10px;text-align:center;' v-if='datalist.length==0'>
  64. 当前暂无数据
  65. </view>
  66. <view v-else-if="isLoadMore" >
  67. <uni-load-more :status="loadStatus"></uni-load-more>
  68. </view>
  69. </view>
  70. <view class="enter" @click="enterUrl">
  71. <image style='width:56.5px;height:28px;' src="../../static/img/liangmai/ruzhu.png" mode=""></image>
  72. <view class='enter-content'>入驻</view>
  73. </view>
  74. <u-back-top :scroll-top="scrollTop" mode="circle" icon="arrow-upward"></u-back-top>
  75. </view>
  76. </template>
  77. <script>
  78. import {
  79. mapState
  80. } from 'vuex';
  81. export default {
  82. components: {
  83. },
  84. data() {
  85. return {
  86. position:{
  87. name:"未设置"
  88. } ,
  89. status: 0,
  90. mainBusinessType: '',
  91. mainBusinessTypeKey: '0',
  92. pageSize: 10,
  93. releaseInfo:[],
  94. currentPage: 1,
  95. isLoadMore: false, //是否加载中
  96. loadStatus: 'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
  97. searchTypes: [{
  98. name: '全部',
  99. value: '0'
  100. }, {
  101. name: '粮库',
  102. value: '1'
  103. }, {
  104. name: '加工厂',
  105. value: '2'
  106. },
  107. {
  108. name: '烘干塔',
  109. value: '3'
  110. }, {
  111. name: '饲料厂',
  112. value: '4'
  113. }, {
  114. name: '养殖场',
  115. value: '5'
  116. },
  117. {
  118. name: '粮贸',
  119. value: '6'
  120. }, {
  121. name: '期货',
  122. value: '7'
  123. }
  124. ],
  125. notlist:false,
  126. datalist: [],
  127. scrollTop: 0,
  128. }
  129. },
  130. computed: {
  131. ...mapState(['hasLogin', 'userInfo'])
  132. },
  133. onPageScroll(e) {
  134. this.scrollTop = e.scrollTop;
  135. },
  136. onPullDownRefresh() {
  137. this.getList()
  138. this.isLoadMore = false
  139. this.loadStatus = 'loading'
  140. this.currentPage = 1
  141. setTimeout(function () {
  142. uni.stopPullDownRefresh(); //关闭下拉刷新
  143. }, 1000);
  144. },
  145. onReachBottom() { //上拉触底函数
  146. if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
  147. this.isLoadMore = true
  148. this.currentPage += 1
  149. console.log("currentPage",this.currentPage)
  150. this.getData()
  151. }
  152. },
  153. onShow(val) {
  154. this.isLoadMore = false
  155. this.currentPage = 1
  156. uni.hideKeyboard()
  157. uni.getStorage({
  158. key: 'setLocaltion',
  159. success: (res) => {
  160. console.log("setLocaltion",res.data)
  161. this.position = res.data
  162. // uni.removeStorage({
  163. // key: 'setLocaltion'
  164. // })
  165. },
  166. })
  167. if(this.position.name == "未设置"){
  168. let that = this;
  169. uni.getLocation({
  170. type: 'gcj02',
  171. geocode: true,
  172. success: function(res) {
  173. console.log('获取位置数据:', res);
  174. console.log('当前位置的经度:' + res.longitude);
  175. console.log('当前位置的纬度:' + res.latitude);
  176. //拼接当前定位回显地址
  177. // #ifdef APP-PLUS
  178. that.position.name = res.address.poiName
  179. that.position.cityname = res.address.city
  180. that.position.location = res.longitude + "," + res.latitude
  181. uni.setStorage({
  182. key: 'setLocaltion',
  183. data: that.position
  184. })
  185. // #endif
  186. that.getList()
  187. },
  188. fail:function(req){
  189. console.log(req)
  190. that.getList()
  191. }
  192. });
  193. }
  194. else{
  195. this.getList()
  196. }
  197. uni.removeTabBarBadge({
  198. index: 4
  199. })
  200. this.$api.doRequest('get', '/notice/query/noticeNumber').then(res => {
  201. if (res.data.data) {
  202. let name = 'myTip';
  203. let value = res.data.data.task;
  204. that.$store.commit('$uStore', {
  205. name,
  206. value
  207. });
  208. if(value != 0&&value){
  209. uni.setTabBarBadge({
  210. index:4,
  211. text:value+""
  212. })
  213. }
  214. name = 'taskTip';
  215. value = res.data.data.task;
  216. that.$store.commit('$uStore', {
  217. name,
  218. value
  219. });
  220. }
  221. })
  222. },
  223. onLoad(option) {
  224. if (option.position){
  225. this.position = option.position
  226. }
  227. },
  228. methods: {
  229. getList(){
  230. this.$api.doRequest('get', '/settledCompanyDynamics/selectSettledCompanyDynamicsPage', {
  231. currentPage: 1,
  232. pageSize: 3,
  233. searchKeyWord: this.keyword,
  234. searchType:2
  235. })
  236. .then(res => {
  237. if (res.data.code == 200) {
  238. this.releaseInfo = res.data.data.records
  239. }
  240. })
  241. this.getInfo()
  242. },
  243. getData(){
  244. var that = this
  245. uni.showLoading({
  246. title:"正在加载"
  247. })
  248. this.$api.doRequest('get', '/settledCompanyInfo/selectSettledCompanyInfo', {
  249. mainBusinessType: this.mainBusinessType,
  250. pageSize: this.pageSize,
  251. currentPage: this.currentPage,
  252. pcFlag: 2,
  253. searchType: 2,
  254. location:that.position.cityname
  255. }).then(res => {
  256. if (res.data.code == 200) {
  257. var data = res.data.data.records
  258. if(data.length > 0){
  259. this.datalist = this.datalist.concat(data)
  260. if(this.position&&this.position.location){
  261. let lat2 =this.position.location.split(',')[1];
  262. let lng2 = this.position.location.split(',')[0];
  263. for(var i=0;i<this.datalist.length;i++){
  264. this.datalist[i]._metre=this.utils.getDistance(this.datalist[i].latitude,this.datalist[i].longitude,lat2,lng2)
  265. }
  266. }
  267. if(this.currentPage==1&&this.datalist.length==0){
  268. this.notlist=true
  269. }else{
  270. this.notlist=false
  271. }
  272. console.log("this.datalist",this.datalist)
  273. that.isLoadMore=false
  274. }
  275. else{
  276. if (that.currentPage > 1) {
  277. that.currentPage -= 1
  278. }
  279. that.isLoadMore = true
  280. that.loadStatus = 'nomore'
  281. }
  282. // let _metre = this.utils.getDistance(lat1,lng1,lat2,lng2) +"千米"
  283. }
  284. uni.hideLoading()
  285. }).catch(res => {
  286. that.isLoadMore=false
  287. that.loadStatus = 'nomore'
  288. if(that.currentPage>1){that.currentPage=1}
  289. uni.hideLoading()
  290. })
  291. },
  292. getInfo(){
  293. var that = this
  294. uni.showLoading({
  295. title:"正在加载"
  296. })
  297. this.$api.doRequest('get', '/settledCompanyInfo/selectSettledCompanyInfo', {
  298. mainBusinessType: this.mainBusinessType,
  299. pageSize: this.pageSize,
  300. currentPage: this.currentPage,
  301. pcFlag: 2,
  302. searchType: 2,
  303. location:that.position.cityname
  304. }).then(res => {
  305. if (res.data.code == 200) {
  306. this.datalist = res.data.data.records
  307. console.log(this.position)
  308. let lat2 =this.position.location.split(',')[1];
  309. let lng2 = this.position.location.split(',')[0];
  310. for(var i=0;i<this.datalist.length;i++){
  311. this.datalist[i]._metre=this.utils.getDistance(this.datalist[i].latitude,this.datalist[i].longitude,lat2,lng2)
  312. }
  313. if(this.currentPage==1&&this.datalist.length==0){
  314. this.notlist=true
  315. }else{
  316. this.notlist=false
  317. }
  318. console.log(this.datalist)
  319. // let _metre = this.utils.getDistance(lat1,lng1,lat2,lng2) +"千米"
  320. }
  321. uni.hideLoading()
  322. }).catch(res => {
  323. uni.hideLoading()
  324. })
  325. },
  326. mainBusinessTypechange(item) {
  327. if (item.name != '全部') {
  328. this.mainBusinessType = item.name
  329. } else {
  330. this.mainBusinessType = ''
  331. }
  332. this.currentPage=1
  333. this.getInfo()
  334. this.mainBusinessTypeKey = item.value
  335. },
  336. enterUrl() {
  337. if (!this.hasLogin) {
  338. uni.showModal({
  339. title: '登录提示',
  340. content: '您尚未登录,是否立即登录?',
  341. showCancel: true,
  342. confirmText: '登录',
  343. success: (e) => {
  344. if (e.confirm) {
  345. uni.navigateTo({
  346. url: '/pages/public/login'
  347. })
  348. }
  349. },
  350. fail: () => {},
  351. complete: () => {}
  352. })
  353. }
  354. else{
  355. //入驻
  356. uni.navigateTo({
  357. url: '/pages/grain_pulse/enter'
  358. })
  359. }
  360. },
  361. friendcircle() {
  362. uni.navigateTo({
  363. url: '/pages/grain_pulse/dynamic'
  364. })
  365. },
  366. todetails(item) {
  367. uni.navigateTo({
  368. url: '/pages/grain_pulse/details?id=' + item.id
  369. })
  370. },
  371. naviageToPage(item) {
  372. console.log(item)
  373. uni.navigateTo({
  374. url: item
  375. })
  376. },
  377. naviageToPage1(item,url) {
  378. uni.setStorageSync('location', item)
  379. uni.navigateTo({
  380. url: url
  381. })
  382. }
  383. }
  384. }
  385. </script>
  386. <style scoped>
  387. /* 《--头部 */
  388. .header {
  389. padding: 0 12.5px;
  390. background: #fff;
  391. border-radius: 0 0 10px 10px;
  392. }
  393. /* 头部--》 */
  394. /* 《--定位 */
  395. .location {
  396. width: 30rpx;
  397. height: 35rpx;
  398. margin-right:10rpx ;
  399. }
  400. .locationwrap {
  401. font-size: 16px;
  402. }
  403. /* 定位 --》 */
  404. /* 《--分布 */
  405. .map {
  406. padding: 8.5px 0;
  407. }
  408. .cangku {
  409. width: 16.5px;
  410. height: 16.5px;
  411. margin-right: 5px;
  412. }
  413. .distribution {
  414. background: #F5F6FA;
  415. width: 71.5px;
  416. height: 32px;
  417. border-radius: 15px;
  418. font-size: 12px;
  419. }
  420. /* 分布--》 */
  421. /* 《--搜索 */
  422. .cu-bar .search-form {
  423. background: #F5F6F9;
  424. margin: 0;
  425. margin-bottom: 18px;
  426. padding: 10px 18px;
  427. }
  428. .icon-scarch {
  429. width: 15px;
  430. height: 15px;
  431. margin-right: 5px;
  432. }
  433. /* 搜索--》 */
  434. /* 《--内容 */
  435. .content {
  436. margin-top: 13px;
  437. }
  438. /* 内容--》 */
  439. /* 《--圈友说 */
  440. .friendcircle {
  441. background: #fff;
  442. margin: 0 9px;
  443. border-radius: 4px;
  444. }
  445. .friendcircle .title {
  446. font-size: 16px;
  447. padding: 11.5px 14.5px;
  448. }
  449. .icon-friendcircle {
  450. width: 17px;
  451. height: 17px;
  452. margin-right: 5.5px;
  453. }
  454. .bg {
  455. width: 200rpx;
  456. height: 200rpx;
  457. }
  458. .friendcircle-content {
  459. padding: 0 17px 18px;
  460. }
  461. .friendcircle-content-right {
  462. margin-left: 15.5px;
  463. }
  464. .friendcircle-content-right-item {
  465. background: linear-gradient(90deg, #F5F6FA 0%, #FFFFFF 100%);
  466. border-radius: 15rpx;
  467. margin-bottom: 20rpx;
  468. width: 420rpx;
  469. font-size: 12px;
  470. padding: 3px 0;
  471. }
  472. .headportrait {
  473. width: 22.5px;
  474. height: 22.5px;
  475. margin-right: 8.5px;
  476. border-radius:10px;
  477. }
  478. /* 圈友说--》 */
  479. /* 《--类型 */
  480. .list-type {
  481. background: linear-gradient(180deg, #F5F6FA 0%, #FFFFFF 100%);
  482. width: 100vw;
  483. padding-top: 5px;
  484. height: 49px;
  485. overflow-x: scroll;
  486. white-space: nowrap;
  487. }
  488. .typeitem {
  489. margin: 10px;
  490. position: relative;
  491. display: inline-block;
  492. padding-top: 8px;
  493. padding-bottom: 5px;
  494. }
  495. .typeitem.active {
  496. font-size: 16px;
  497. }
  498. .typeitem.active:after {
  499. content: '';
  500. display: block;
  501. position: absolute;
  502. height: 3px;
  503. bottom: 0;
  504. background: #22C572;
  505. width: 50%;
  506. left: 50%;
  507. transform: translateX(-50%);
  508. }
  509. /* 类型--》 */
  510. /* 《--数据 */
  511. .listitem {
  512. background: #fff;
  513. margin: 10px;
  514. padding: 15px 19px;
  515. }
  516. .listitem-left {
  517. width: 400rpx;
  518. height: 200rpx;
  519. margin-right: 8px;
  520. border-radius: 5px;
  521. }
  522. .companyname {
  523. font-size: 14px;
  524. color: #333;
  525. }
  526. .introduce {
  527. font-size: 12px;
  528. color: #676E80;
  529. }
  530. .companylocation {
  531. color: #676E80;
  532. /* background: #F5F6FA; */
  533. margin-top: 8px;
  534. /* padding: 4px 10px; */
  535. border-radius: 15px;
  536. font-size: 12px;
  537. /* width: 65%; */
  538. }
  539. .distance {
  540. color: #AFB3BF;
  541. padding: 4px;
  542. margin-top: 8px;
  543. font-size: 12px;
  544. }
  545. /* 数据--》 */
  546. .enter {
  547. position: fixed;
  548. right: 0;
  549. top: 70%;
  550. width: 56.5px;
  551. height: 28px;
  552. }
  553. .enter-content {
  554. position: absolute;
  555. right: 5px;
  556. top: 50%;
  557. transform: translateY(-50%);
  558. color: #fff;
  559. }
  560. </style>