home.vue 12 KB

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