home.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  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: this.currentPage,
  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.currentPage=1
  304. this.getInfo()
  305. this.mainBusinessTypeKey = item.value
  306. },
  307. enterUrl() {
  308. if (!this.hasLogin) {
  309. uni.showModal({
  310. title: '登录提示',
  311. content: '您尚未登录,是否立即登录?',
  312. showCancel: true,
  313. confirmText: '登录',
  314. success: (e) => {
  315. if (e.confirm) {
  316. uni.navigateTo({
  317. url: '/pages/public/login'
  318. })
  319. }
  320. },
  321. fail: () => {},
  322. complete: () => {}
  323. })
  324. }
  325. else{
  326. //入驻
  327. uni.navigateTo({
  328. url: '/pages/grain_pulse/enter'
  329. })
  330. }
  331. },
  332. friendcircle() {
  333. uni.navigateTo({
  334. url: '/pages/grain_pulse/dynamic'
  335. })
  336. },
  337. todetails(item) {
  338. uni.navigateTo({
  339. url: '/pages/grain_pulse/details?id=' + item.id
  340. })
  341. },
  342. naviageToPage(item) {
  343. console.log(item)
  344. uni.navigateTo({
  345. url: item
  346. })
  347. },
  348. naviageToPage1(item,url) {
  349. uni.setStorageSync('location', item)
  350. uni.navigateTo({
  351. url: url
  352. })
  353. }
  354. }
  355. }
  356. </script>
  357. <style scoped>
  358. /* 《--头部 */
  359. .header {
  360. padding: 0 12.5px;
  361. background: #fff;
  362. border-radius: 0 0 10px 10px;
  363. }
  364. /* 头部--》 */
  365. /* 《--定位 */
  366. .location {
  367. width: 30rpx;
  368. height: 30rpx;
  369. margin-right: 2.5px;
  370. }
  371. .locationwrap {
  372. font-size: 16px;
  373. }
  374. /* 定位 --》 */
  375. /* 《--分布 */
  376. .map {
  377. padding: 8.5px 0;
  378. }
  379. .cangku {
  380. width: 16.5px;
  381. height: 16.5px;
  382. margin-right: 5px;
  383. }
  384. .distribution {
  385. background: #F5F6FA;
  386. width: 71.5px;
  387. height: 32px;
  388. border-radius: 15px;
  389. font-size: 12px;
  390. }
  391. /* 分布--》 */
  392. /* 《--搜索 */
  393. .cu-bar .search-form {
  394. background: #F5F6F9;
  395. margin: 0;
  396. margin-bottom: 18px;
  397. padding: 10px 18px;
  398. }
  399. .icon-scarch {
  400. width: 15px;
  401. height: 15px;
  402. margin-right: 5px;
  403. }
  404. /* 搜索--》 */
  405. /* 《--内容 */
  406. .content {
  407. margin-top: 13px;
  408. }
  409. /* 内容--》 */
  410. /* 《--圈友说 */
  411. .friendcircle {
  412. background: #fff;
  413. margin: 0 9px;
  414. border-radius: 4px;
  415. }
  416. .friendcircle .title {
  417. font-size: 16px;
  418. padding: 11.5px 14.5px;
  419. }
  420. .icon-friendcircle {
  421. width: 17px;
  422. height: 17px;
  423. margin-right: 5.5px;
  424. }
  425. .bg {
  426. width: 200rpx;
  427. height: 200rpx;
  428. }
  429. .friendcircle-content {
  430. padding: 0 17px 18px;
  431. }
  432. .friendcircle-content-right {
  433. margin-left: 15.5px;
  434. }
  435. .friendcircle-content-right-item {
  436. background: linear-gradient(90deg, #F5F6FA 0%, #FFFFFF 100%);
  437. border-radius: 15rpx;
  438. margin-bottom: 20rpx;
  439. width: 420rpx;
  440. font-size: 12px;
  441. padding: 3px 0;
  442. }
  443. .headportrait {
  444. width: 22.5px;
  445. height: 22.5px;
  446. margin-right: 8.5px;
  447. border-radius:10px;
  448. }
  449. /* 圈友说--》 */
  450. /* 《--类型 */
  451. .list-type {
  452. background: linear-gradient(180deg, #F5F6FA 0%, #FFFFFF 100%);
  453. width: 100vw;
  454. padding-top: 5px;
  455. height: 49px;
  456. overflow-x: scroll;
  457. white-space: nowrap;
  458. }
  459. .typeitem {
  460. margin: 10px;
  461. position: relative;
  462. display: inline-block;
  463. padding-top: 8px;
  464. padding-bottom: 5px;
  465. }
  466. .typeitem.active {
  467. font-size: 16px;
  468. }
  469. .typeitem.active:after {
  470. content: '';
  471. display: block;
  472. position: absolute;
  473. height: 3px;
  474. bottom: 0;
  475. background: #22C572;
  476. width: 50%;
  477. left: 50%;
  478. transform: translateX(-50%);
  479. }
  480. /* 类型--》 */
  481. /* 《--数据 */
  482. .listitem {
  483. background: #fff;
  484. margin: 10px;
  485. padding: 15px 19px;
  486. }
  487. .listitem-left {
  488. width: 400rpx;
  489. height: 200rpx;
  490. margin-right: 8px;
  491. border-radius: 5px;
  492. }
  493. .companyname {
  494. font-size: 14px;
  495. color: #333;
  496. }
  497. .introduce {
  498. font-size: 12px;
  499. color: #676E80;
  500. }
  501. .companylocation {
  502. color: #676E80;
  503. /* background: #F5F6FA; */
  504. margin-top: 8px;
  505. /* padding: 4px 10px; */
  506. border-radius: 15px;
  507. font-size: 12px;
  508. /* width: 65%; */
  509. }
  510. .distance {
  511. color: #AFB3BF;
  512. padding: 4px;
  513. margin-top: 8px;
  514. font-size: 12px;
  515. }
  516. /* 数据--》 */
  517. .enter {
  518. position: fixed;
  519. right: 0;
  520. top: 70%;
  521. width: 56.5px;
  522. height: 28px;
  523. }
  524. .enter-content {
  525. position: absolute;
  526. right: 5px;
  527. top: 50%;
  528. transform: translateY(-50%);
  529. color: #fff;
  530. }
  531. </style>