home.vue 13 KB

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