home.vue 13 KB

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