home.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  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. },
  198. onLoad(option) {
  199. if (option.position){
  200. this.position = option.position
  201. }
  202. },
  203. methods: {
  204. getList(){
  205. this.$api.doRequest('get', '/settledCompanyDynamics/selectSettledCompanyDynamicsPage', {
  206. currentPage: 1,
  207. pageSize: 3,
  208. searchKeyWord: this.keyword,
  209. searchType:2
  210. })
  211. .then(res => {
  212. if (res.data.code == 200) {
  213. this.releaseInfo = res.data.data.records
  214. }
  215. })
  216. this.getInfo()
  217. },
  218. getData(){
  219. var that = this
  220. uni.showLoading({
  221. title:"正在加载"
  222. })
  223. this.$api.doRequest('get', '/settledCompanyInfo/selectSettledCompanyInfo', {
  224. mainBusinessType: this.mainBusinessType,
  225. pageSize: this.pageSize,
  226. currentPage: this.currentPage,
  227. pcFlag: 2,
  228. searchType: 2,
  229. location:that.position.cityname
  230. }).then(res => {
  231. if (res.data.code == 200) {
  232. var data = res.data.data.records
  233. if(data.length > 0){
  234. this.datalist = this.datalist.concat(data)
  235. if(this.position&&this.position.location){
  236. let lat2 =this.position.location.split(',')[1];
  237. let lng2 = this.position.location.split(',')[0];
  238. for(var i=0;i<this.datalist.length;i++){
  239. this.datalist[i]._metre=this.utils.getDistance(this.datalist[i].latitude,this.datalist[i].longitude,lat2,lng2)
  240. }
  241. }
  242. if(this.currentPage==1&&this.datalist.length==0){
  243. this.notlist=true
  244. }else{
  245. this.notlist=false
  246. }
  247. console.log("this.datalist",this.datalist)
  248. that.isLoadMore=false
  249. }
  250. else{
  251. if (that.currentPage > 1) {
  252. that.currentPage -= 1
  253. }
  254. that.isLoadMore = true
  255. that.loadStatus = 'nomore'
  256. }
  257. // let _metre = this.utils.getDistance(lat1,lng1,lat2,lng2) +"千米"
  258. }
  259. uni.hideLoading()
  260. }).catch(res => {
  261. that.isLoadMore=false
  262. that.loadStatus = 'nomore'
  263. if(that.currentPage>1){that.currentPage=1}
  264. uni.hideLoading()
  265. })
  266. },
  267. getInfo(){
  268. var that = this
  269. uni.showLoading({
  270. title:"正在加载"
  271. })
  272. this.$api.doRequest('get', '/settledCompanyInfo/selectSettledCompanyInfo', {
  273. mainBusinessType: this.mainBusinessType,
  274. pageSize: this.pageSize,
  275. currentPage: this.currentPage,
  276. pcFlag: 2,
  277. searchType: 2,
  278. location:that.position.cityname
  279. }).then(res => {
  280. if (res.data.code == 200) {
  281. this.datalist = res.data.data.records
  282. console.log(this.position)
  283. let lat2 =this.position.location.split(',')[1];
  284. let lng2 = this.position.location.split(',')[0];
  285. for(var i=0;i<this.datalist.length;i++){
  286. this.datalist[i]._metre=this.utils.getDistance(this.datalist[i].latitude,this.datalist[i].longitude,lat2,lng2)
  287. }
  288. if(this.currentPage==1&&this.datalist.length==0){
  289. this.notlist=true
  290. }else{
  291. this.notlist=false
  292. }
  293. console.log(this.datalist)
  294. // let _metre = this.utils.getDistance(lat1,lng1,lat2,lng2) +"千米"
  295. }
  296. uni.hideLoading()
  297. }).catch(res => {
  298. uni.hideLoading()
  299. })
  300. },
  301. mainBusinessTypechange(item) {
  302. if (item.name != '全部') {
  303. this.mainBusinessType = item.name
  304. } else {
  305. this.mainBusinessType = ''
  306. }
  307. this.currentPage=1
  308. this.getInfo()
  309. this.mainBusinessTypeKey = item.value
  310. },
  311. enterUrl() {
  312. if (!this.hasLogin) {
  313. uni.showModal({
  314. title: '登录提示',
  315. content: '您尚未登录,是否立即登录?',
  316. showCancel: true,
  317. confirmText: '登录',
  318. success: (e) => {
  319. if (e.confirm) {
  320. uni.navigateTo({
  321. url: '/pages/public/login'
  322. })
  323. }
  324. },
  325. fail: () => {},
  326. complete: () => {}
  327. })
  328. }
  329. else{
  330. //入驻
  331. uni.navigateTo({
  332. url: '/pages/grain_pulse/enter'
  333. })
  334. }
  335. },
  336. friendcircle() {
  337. uni.navigateTo({
  338. url: '/pages/grain_pulse/dynamic'
  339. })
  340. },
  341. todetails(item) {
  342. uni.navigateTo({
  343. url: '/pages/grain_pulse/details?id=' + item.id
  344. })
  345. },
  346. naviageToPage(item) {
  347. console.log(item)
  348. uni.navigateTo({
  349. url: item
  350. })
  351. },
  352. naviageToPage1(item,url) {
  353. uni.setStorageSync('location', item)
  354. uni.navigateTo({
  355. url: url
  356. })
  357. }
  358. }
  359. }
  360. </script>
  361. <style scoped>
  362. /* 《--头部 */
  363. .header {
  364. padding: 0 12.5px;
  365. background: #fff;
  366. border-radius: 0 0 10px 10px;
  367. }
  368. /* 头部--》 */
  369. /* 《--定位 */
  370. .location {
  371. width: 30rpx;
  372. height: 35rpx;
  373. margin-right:10rpx ;
  374. }
  375. .locationwrap {
  376. font-size: 16px;
  377. }
  378. /* 定位 --》 */
  379. /* 《--分布 */
  380. .map {
  381. padding: 8.5px 0;
  382. }
  383. .cangku {
  384. width: 16.5px;
  385. height: 16.5px;
  386. margin-right: 5px;
  387. }
  388. .distribution {
  389. background: #F5F6FA;
  390. width: 71.5px;
  391. height: 32px;
  392. border-radius: 15px;
  393. font-size: 12px;
  394. }
  395. /* 分布--》 */
  396. /* 《--搜索 */
  397. .cu-bar .search-form {
  398. background: #F5F6F9;
  399. margin: 0;
  400. margin-bottom: 18px;
  401. padding: 10px 18px;
  402. }
  403. .icon-scarch {
  404. width: 15px;
  405. height: 15px;
  406. margin-right: 5px;
  407. }
  408. /* 搜索--》 */
  409. /* 《--内容 */
  410. .content {
  411. margin-top: 13px;
  412. }
  413. /* 内容--》 */
  414. /* 《--圈友说 */
  415. .friendcircle {
  416. background: #fff;
  417. margin: 0 9px;
  418. border-radius: 4px;
  419. }
  420. .friendcircle .title {
  421. font-size: 16px;
  422. padding: 11.5px 14.5px;
  423. }
  424. .icon-friendcircle {
  425. width: 17px;
  426. height: 17px;
  427. margin-right: 5.5px;
  428. }
  429. .bg {
  430. width: 200rpx;
  431. height: 200rpx;
  432. }
  433. .friendcircle-content {
  434. padding: 0 17px 18px;
  435. }
  436. .friendcircle-content-right {
  437. margin-left: 15.5px;
  438. }
  439. .friendcircle-content-right-item {
  440. background: linear-gradient(90deg, #F5F6FA 0%, #FFFFFF 100%);
  441. border-radius: 15rpx;
  442. margin-bottom: 20rpx;
  443. width: 420rpx;
  444. font-size: 12px;
  445. padding: 3px 0;
  446. }
  447. .headportrait {
  448. width: 22.5px;
  449. height: 22.5px;
  450. margin-right: 8.5px;
  451. border-radius:10px;
  452. }
  453. /* 圈友说--》 */
  454. /* 《--类型 */
  455. .list-type {
  456. background: linear-gradient(180deg, #F5F6FA 0%, #FFFFFF 100%);
  457. width: 100vw;
  458. padding-top: 5px;
  459. height: 49px;
  460. overflow-x: scroll;
  461. white-space: nowrap;
  462. }
  463. .typeitem {
  464. margin: 10px;
  465. position: relative;
  466. display: inline-block;
  467. padding-top: 8px;
  468. padding-bottom: 5px;
  469. }
  470. .typeitem.active {
  471. font-size: 16px;
  472. }
  473. .typeitem.active:after {
  474. content: '';
  475. display: block;
  476. position: absolute;
  477. height: 3px;
  478. bottom: 0;
  479. background: #22C572;
  480. width: 50%;
  481. left: 50%;
  482. transform: translateX(-50%);
  483. }
  484. /* 类型--》 */
  485. /* 《--数据 */
  486. .listitem {
  487. background: #fff;
  488. margin: 10px;
  489. padding: 15px 19px;
  490. }
  491. .listitem-left {
  492. width: 400rpx;
  493. height: 200rpx;
  494. margin-right: 8px;
  495. border-radius: 5px;
  496. }
  497. .companyname {
  498. font-size: 14px;
  499. color: #333;
  500. }
  501. .introduce {
  502. font-size: 12px;
  503. color: #676E80;
  504. }
  505. .companylocation {
  506. color: #676E80;
  507. /* background: #F5F6FA; */
  508. margin-top: 8px;
  509. /* padding: 4px 10px; */
  510. border-radius: 15px;
  511. font-size: 12px;
  512. /* width: 65%; */
  513. }
  514. .distance {
  515. color: #AFB3BF;
  516. padding: 4px;
  517. margin-top: 8px;
  518. font-size: 12px;
  519. }
  520. /* 数据--》 */
  521. .enter {
  522. position: fixed;
  523. right: 0;
  524. top: 70%;
  525. width: 56.5px;
  526. height: 28px;
  527. }
  528. .enter-content {
  529. position: absolute;
  530. right: 5px;
  531. top: 50%;
  532. transform: translateY(-50%);
  533. color: #fff;
  534. }
  535. </style>