home.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  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@2x.png" mode=""></image>
  8. {{position.name}}
  9. </view>
  10. <view
  11. @click='naviageToPage("/pages/grain_pulse/distribution/distribution?position="+JSON.stringify(position))'
  12. class='Regular flex align-item-center distribution justify-center'>
  13. <image class='cangku' src="../../static/img/liangmai/cangku.png" mode=""></image>
  14. 分布
  15. </view>
  16. </view>
  17. <u-search bg-color='#F5F6F9' :show-action="true" action-text="搜索" :animation="true"></u-search>
  18. <!-- <view class="cu-bar search">
  19. <view class="search-form round" @click="naviageToPage('/pages/grain_pulse/search')">
  20. <image class='icon-scarch' src="../../static/img/liangmai/sousuo.png" mode=""></image>
  21. <view class='Regular'> 请输入货名或标题</view>
  22. </view>
  23. </view> -->
  24. </view>
  25. <view class="content">
  26. <view @click='friendcircle' class="friendcircle">
  27. <view class='title flex align-item-center Medium'>
  28. <image class='icon-friendcircle' src="../../static/img/liangmai/icon.png" mode=""></image>
  29. 圈友说
  30. </view>
  31. <view class='friendcircle-content flex justify-between'>
  32. <image class='bg' src="../../static/img/liangmai/bg.png" mode=""></image>
  33. <view class='friendcircle-content-right'>
  34. <view v-for='item in releaseInfo'
  35. class='friendcircle-content-right-item Regular flex align-item-center'>
  36. <image class='headportrait' v-if='item.avatarUrl' :src="item.avatarUrl" mode=""></image>
  37. <image class='headportrait' v-else src="../../static/img/myimg/YongHu@3x.png" mode="">
  38. </image>
  39. {{item.title}}
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <scroll-view scroll-x="true" scroll-with-animation="true" class='list-type'>
  45. <view v-for='item in searchTypes' @click='mainBusinessTypechange(item)'
  46. :class='mainBusinessTypeKey==item.value?"Semibold active":"Regular"' class="typeitem">{{item.name}}
  47. </view>
  48. </scroll-view>
  49. <view v-if='datalist.length>0' v-for='item in datalist' @click='todetails(item)' class="listitem">
  50. <view class="flex">
  51. <image style='width:98px;height:97px;flex:1;' class='listitem-left' :src="item.attachmentAddress"
  52. mode=""></image>
  53. <view style='flex:2;' class="listitem-right">
  54. <view class="companyname Medium">{{item.compName}}</view>
  55. <view class='Regular introduce'>{{item.companyProfile}}</view>
  56. </view>
  57. </view>
  58. <view class="flex align-item-center justify-between">
  59. <view @click.stop='naviageToPage1(item,"/pages/grain_pulse/localtion/localtion")'
  60. class='companylocation flex align-item-center Regular'>
  61. <image class='location' src="../../static/img/liangmai/icon_ditu.png" mode=""></image>
  62. {{item.province}}{{item.city}}{{item.area}}{{item.detailedAddress}}
  63. </view>
  64. <view v-if='position.name!="未设置"' class='distance Regular'>{{item._metre}}</view>
  65. </view>
  66. </view>
  67. <view style='padding:10px;text-align:center;' v-if='datalist.length==0'>
  68. 当前暂无数据
  69. </view>
  70. <view v-else-if="isLoadMore">
  71. <uni-load-more :status="loadStatus"></uni-load-more>
  72. </view>
  73. </view>
  74. <view class="enter" @click="enterUrl">
  75. <image style='width:56.5px;height:28px;' src="../../static/img/liangmai/ruzhu.png" mode=""></image>
  76. <view class='enter-content'>入驻</view>
  77. </view>
  78. <u-back-top :scroll-top="scrollTop" mode="circle" icon="arrow-upward"></u-back-top>
  79. <u-modal v-model="isShowAlert" :title-style="{fontSize: '18px',fontWeight:'500'}"
  80. :content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定' title='提示'
  81. showCancelButton='false' :content="content" @confirm="alertBtn" @cancel="cancelClick"></u-modal>
  82. </view>
  83. </template>
  84. <script>
  85. import {
  86. mapState
  87. } from 'vuex';
  88. export default {
  89. components: {
  90. },
  91. data() {
  92. return {
  93. isShowAlert: false,
  94. content: '您尚未登录,是否立即登录?',
  95. position: {
  96. name: "未设置"
  97. },
  98. status: 0,
  99. mainBusinessType: '',
  100. mainBusinessTypeKey: '0',
  101. pageSize: 10,
  102. releaseInfo: [],
  103. currentPage: 1,
  104. isLoadMore: false, //是否加载中
  105. loadStatus: 'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
  106. searchTypes: [{
  107. name: '全部',
  108. value: '0'
  109. }, {
  110. name: '粮库',
  111. value: '1'
  112. }, {
  113. name: '加工厂',
  114. value: '2'
  115. },
  116. {
  117. name: '烘干塔',
  118. value: '3'
  119. }, {
  120. name: '饲料厂',
  121. value: '4'
  122. }, {
  123. name: '养殖场',
  124. value: '5'
  125. },
  126. {
  127. name: '粮贸',
  128. value: '6'
  129. }, {
  130. name: '期货',
  131. value: '7'
  132. }
  133. ],
  134. notlist: false,
  135. datalist: [],
  136. scrollTop: 0,
  137. }
  138. },
  139. computed: {
  140. ...mapState(['hasLogin', 'userInfo'])
  141. },
  142. onPageScroll(e) {
  143. this.scrollTop = e.scrollTop;
  144. },
  145. onPullDownRefresh() {
  146. this.getList()
  147. this.isLoadMore = false
  148. this.loadStatus = 'loading'
  149. this.currentPage = 1
  150. setTimeout(function() {
  151. uni.stopPullDownRefresh(); //关闭下拉刷新
  152. }, 1000);
  153. },
  154. onReachBottom() { //上拉触底函数
  155. if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
  156. this.isLoadMore = true
  157. this.currentPage += 1
  158. console.log("currentPage", this.currentPage)
  159. this.getData()
  160. }
  161. },
  162. onShow(val) {
  163. this.isLoadMore = false
  164. this.currentPage = 1
  165. uni.hideKeyboard()
  166. uni.getStorage({
  167. key: 'setLocaltion',
  168. success: (res) => {
  169. console.log("setLocaltion", res.data)
  170. this.position = res.data
  171. // uni.removeStorage({
  172. // key: 'setLocaltion'
  173. // })
  174. },
  175. })
  176. if (this.position.name == "未设置") {
  177. let that = this;
  178. uni.getLocation({
  179. type: 'gcj02',
  180. geocode: true,
  181. success: function(res) {
  182. console.log('获取位置数据:', res);
  183. console.log('当前位置的经度:' + res.longitude);
  184. console.log('当前位置的纬度:' + res.latitude);
  185. //拼接当前定位回显地址
  186. // #ifdef APP-PLUS
  187. that.position.name = res.address.poiName
  188. that.position.cityname = res.address.city
  189. that.position.location = res.longitude + "," + res.latitude
  190. uni.setStorage({
  191. key: 'setLocaltion',
  192. data: that.position
  193. })
  194. // #endif
  195. that.getList()
  196. },
  197. fail: function(req) {
  198. console.log(req)
  199. that.getList()
  200. }
  201. });
  202. } else {
  203. this.getList()
  204. }
  205. uni.removeTabBarBadge({
  206. index: 4
  207. })
  208. this.$api.doRequest('get', '/newNoticeTask/query/noticeTasks').then(res => {
  209. if (res.data.data) {
  210. let name = 'myTip';
  211. let value = res.data.data.total;
  212. that.$store.commit('$uStore', {
  213. name,
  214. value
  215. });
  216. if (value != 0 && value) {
  217. uni.setTabBarBadge({
  218. index: 4,
  219. text: value + ""
  220. })
  221. }
  222. name = 'taskTip';
  223. value = res.data.data.total;
  224. that.$store.commit('$uStore', {
  225. name,
  226. value
  227. });
  228. }
  229. })
  230. },
  231. onLoad(option) {
  232. if (option.position) {
  233. this.position = option.position
  234. }
  235. },
  236. methods: {
  237. getList() {
  238. this.$api.doRequest('get', '/settledCompanyDynamics/selectSettledCompanyDynamicsPage', {
  239. currentPage: 1,
  240. pageSize: 4,
  241. searchKeyWord: this.keyword,
  242. searchType: 2
  243. })
  244. .then(res => {
  245. if (res.data.code == 200) {
  246. this.releaseInfo = res.data.data.records
  247. }
  248. })
  249. this.getInfo()
  250. },
  251. getData() {
  252. var that = this
  253. uni.showLoading({
  254. title: "正在加载"
  255. })
  256. this.$api.doRequest('get', '/settledCompanyInfo/selectSettledCompanyInfo', {
  257. mainBusinessType: this.mainBusinessType,
  258. pageSize: this.pageSize,
  259. currentPage: this.currentPage,
  260. pcFlag: 2,
  261. searchType: 2,
  262. location: that.position.cityname
  263. }).then(res => {
  264. if (res.data.code == 200) {
  265. var data = res.data.data.records
  266. if (data.length > 0) {
  267. this.datalist = this.datalist.concat(data)
  268. if (this.position && this.position.location) {
  269. let lat2 = this.position.location.split(',')[1];
  270. let lng2 = this.position.location.split(',')[0];
  271. for (var i = 0; i < this.datalist.length; i++) {
  272. this.datalist[i]._metre = this.utils.getDistance(this.datalist[i].latitude,
  273. this.datalist[i].longitude, lat2, lng2)
  274. }
  275. }
  276. if (this.currentPage == 1 && this.datalist.length == 0) {
  277. this.notlist = true
  278. } else {
  279. this.notlist = false
  280. }
  281. console.log("this.datalist", this.datalist)
  282. that.isLoadMore = false
  283. } else {
  284. if (that.currentPage > 1) {
  285. that.currentPage -= 1
  286. }
  287. that.isLoadMore = true
  288. that.loadStatus = 'nomore'
  289. }
  290. // let _metre = this.utils.getDistance(lat1,lng1,lat2,lng2) +"千米"
  291. }
  292. uni.hideLoading()
  293. }).catch(res => {
  294. that.isLoadMore = false
  295. that.loadStatus = 'nomore'
  296. if (that.currentPage > 1) {
  297. that.currentPage = 1
  298. }
  299. uni.hideLoading()
  300. })
  301. },
  302. getInfo() {
  303. var that = this
  304. uni.showLoading({
  305. title: "正在加载"
  306. })
  307. this.$api.doRequest('get', '/settledCompanyInfo/selectSettledCompanyInfo', {
  308. mainBusinessType: this.mainBusinessType,
  309. pageSize: this.pageSize,
  310. currentPage: this.currentPage,
  311. pcFlag: 2,
  312. searchType: 2,
  313. location: that.position.cityname
  314. }).then(res => {
  315. if (res.data.code == 200) {
  316. this.datalist = res.data.data.records
  317. console.log(this.position)
  318. let lat2 = this.position.location.split(',')[1];
  319. let lng2 = this.position.location.split(',')[0];
  320. for (var i = 0; i < this.datalist.length; i++) {
  321. this.datalist[i]._metre = this.utils.getDistance(this.datalist[i].latitude, this
  322. .datalist[i].longitude, lat2, lng2)
  323. }
  324. if (this.currentPage == 1 && this.datalist.length == 0) {
  325. this.notlist = true
  326. } else {
  327. this.notlist = false
  328. }
  329. console.log(this.datalist)
  330. // let _metre = this.utils.getDistance(lat1,lng1,lat2,lng2) +"千米"
  331. }
  332. uni.hideLoading()
  333. }).catch(res => {
  334. uni.hideLoading()
  335. })
  336. },
  337. mainBusinessTypechange(item) {
  338. if (item.name != '全部') {
  339. this.mainBusinessType = item.name
  340. } else {
  341. this.mainBusinessType = ''
  342. }
  343. this.currentPage = 1
  344. this.getInfo()
  345. this.mainBusinessTypeKey = item.value
  346. },
  347. alertBtn() {
  348. uni.navigateTo({
  349. url: '/pages/public/login'
  350. })
  351. },
  352. cancelClick() {
  353. this.isShowAlert = false
  354. },
  355. enterUrl() {
  356. if (!this.hasLogin) {
  357. this.isShowAlert = true;
  358. // uni.showModal({
  359. // title: '提示',
  360. // content: '您尚未登录,是否立即登录?',
  361. // showCancel: true,
  362. // confirmText: '登录',
  363. // success: (e) => {
  364. // if (e.confirm) {
  365. // uni.navigateTo({
  366. // url: '/pages/public/login'
  367. // })
  368. // }
  369. // },
  370. // fail: () => {},
  371. // complete: () => {}
  372. // })
  373. } else {
  374. //入驻
  375. uni.navigateTo({
  376. url: '/pages/grain_pulse/enter'
  377. })
  378. }
  379. },
  380. friendcircle() {
  381. uni.navigateTo({
  382. url: '/pages/grain_pulse/dynamic'
  383. })
  384. },
  385. todetails(item) {
  386. uni.navigateTo({
  387. url: '/pages/grain_pulse/details?id=' + item.id
  388. })
  389. },
  390. naviageToPage(item) {
  391. console.log(item)
  392. uni.navigateTo({
  393. url: item
  394. })
  395. },
  396. naviageToPage1(item, url) {
  397. uni.setStorageSync('location', item)
  398. uni.navigateTo({
  399. url: url
  400. })
  401. }
  402. }
  403. }
  404. </script>
  405. <style scoped>
  406. /* 《--头部 */
  407. .header {
  408. padding: 0 25rpx 20rpx 25rpx;
  409. background: #fff;
  410. border-radius: 0 0 10px 10px;
  411. }
  412. /* 头部--》 */
  413. /* 《--定位 */
  414. .location {
  415. width: 30rpx;
  416. height: 30rpx;
  417. margin-right: 10rpx;
  418. }
  419. .locationwrap {
  420. font-size: 16px;
  421. }
  422. /* 定位 --》 */
  423. /* 《--分布 */
  424. .map {
  425. padding: 8.5px 0;
  426. }
  427. .cangku {
  428. width: 16.5px;
  429. height: 16.5px;
  430. margin-right: 5px;
  431. }
  432. .distribution {
  433. background: #F5F6FA;
  434. width: 71.5px;
  435. height: 32px;
  436. border-radius: 15px;
  437. font-size: 12px;
  438. }
  439. /* 分布--》 */
  440. /* 《--搜索 */
  441. .cu-bar .search-form {
  442. background: #F5F6F9;
  443. margin: 0;
  444. margin-bottom: 18px;
  445. padding: 10px 18px;
  446. }
  447. .icon-scarch {
  448. width: 15px;
  449. height: 15px;
  450. margin-right: 5px;
  451. }
  452. /* 搜索--》 */
  453. /* 《--内容 */
  454. .content {
  455. margin-top: 13px;
  456. }
  457. /* 内容--》 */
  458. /* 《--圈友说 */
  459. .friendcircle {
  460. background: #fff;
  461. margin: 0 9px;
  462. border-radius: 20rpx;
  463. }
  464. .friendcircle .title {
  465. font-size: 16px;
  466. padding: 11.5px 14.5px;
  467. }
  468. .icon-friendcircle {
  469. width: 17px;
  470. height: 17px;
  471. margin-right: 5.5px;
  472. }
  473. .bg {
  474. width: 220rpx;
  475. height: 248rpx;
  476. }
  477. .friendcircle-content {
  478. padding: 0 17px 18px;
  479. }
  480. .friendcircle-content-right {
  481. margin-left: 15.5px;
  482. }
  483. .friendcircle-content-right-item {
  484. background: linear-gradient(90deg, #F5F6FA 0%, #FFFFFF 100%);
  485. border-radius: 15rpx;
  486. margin-bottom: 10rpx;
  487. width: 420rpx;
  488. font-size: 12px;
  489. padding: 3px 0;
  490. }
  491. .headportrait {
  492. width: 22.5px;
  493. height: 22.5px;
  494. margin-right: 8.5px;
  495. border-radius: 10px;
  496. }
  497. /* 圈友说--》 */
  498. /* 《--类型 */
  499. .list-type {
  500. background: linear-gradient(180deg, #F5F6FA 0%, #FFFFFF 100%);
  501. width: 100vw;
  502. padding-top: 5px;
  503. height: 49px;
  504. overflow-x: scroll;
  505. white-space: nowrap;
  506. }
  507. .typeitem {
  508. margin: 20rpx 28rpx;
  509. position: relative;
  510. display: inline-block;
  511. padding-top: 8px;
  512. padding-bottom: 5px;
  513. }
  514. .typeitem.active {
  515. font-size: 16px;
  516. }
  517. .typeitem.active:after {
  518. content: '';
  519. display: block;
  520. position: absolute;
  521. height: 3px;
  522. bottom: 0;
  523. background: #22C572;
  524. width: 50%;
  525. left: 50%;
  526. transform: translateX(-50%);
  527. }
  528. /* 类型--》 */
  529. /* 《--数据 */
  530. .listitem {
  531. background: #fff;
  532. margin: 10px;
  533. padding: 15px 19px;
  534. border-radius: 20rpx;
  535. }
  536. .listitem-left {
  537. width: 400rpx;
  538. height: 200rpx;
  539. margin-right: 8px;
  540. border-radius: 5px;
  541. }
  542. .companyname {
  543. font-size: 14px;
  544. color: #333;
  545. }
  546. .introduce {
  547. font-size: 12px;
  548. color: #676E80;
  549. }
  550. .companylocation {
  551. color: #676E80;
  552. /* background: #F5F6FA; */
  553. margin-top: 8px;
  554. /* padding: 4px 10px; */
  555. border-radius: 15px;
  556. font-size: 12px;
  557. /* width: 65%; */
  558. background: #F5F6FA;
  559. padding:8rpx 14rpx ;
  560. }
  561. .distance {
  562. color: #AFB3BF;
  563. padding: 4px;
  564. margin-top: 8px;
  565. font-size: 12px;
  566. }
  567. /* 数据--》 */
  568. .enter {
  569. position: fixed;
  570. right: 0;
  571. top: 70%;
  572. width: 56.5px;
  573. height: 28px;
  574. }
  575. .enter-content {
  576. position: absolute;
  577. right: 5px;
  578. top: 50%;
  579. transform: translateY(-50%);
  580. color: #fff;
  581. }
  582. </style>