home.vue 13 KB

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