home.vue 13 KB

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