home.vue 13 KB

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