index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  1. <template>
  2. <view class="index_content">
  3. <view class="top">
  4. <view class="current_local" @click="changePosi">
  5. <image src="../../static/image/localw.png" mode=""></image>
  6. <text>{{local?local:'获取位置失败'}} ></text>
  7. </view>
  8. <view class="search">
  9. <view class="search_wrap">
  10. <image src="../../static/image/search.png" mode=""></image>
  11. <input type="text" @confirm="searchActive" v-model="searchValue" value="" placeholder="请输入关键字"
  12. placeholder-style="color:#B8B5B5;" />
  13. <text @click="searchActive" class="btn_search">查询</text>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="content">
  18. <view class="list_wrap">
  19. <view class="empty" v-if="list.length<1">
  20. <image src="../../static/image/empty2.png" mode="widthFix"></image>
  21. <view class="empty-text">
  22. 暂无内容!
  23. </view>
  24. </view>
  25. <view class="item" v-for="(item,index) in list" @click="detail(item)">
  26. <image class="left" :src="item.cover ? item.cover :'../../static/image/image.jpg'"
  27. mode="aspectFill"></image>
  28. <view class="detail">
  29. <view class="name"> <text class="title">{{item.name}}</text><text class="distance">
  30. {{item.distance<1000?item.distance:(item.distance/1000).toFixed(1)}}{{item.distance<1000?'m':'km'}}
  31. </text>
  32. </view>
  33. <view class="time">
  34. <image src="../../static/image/clock.png" mode="widthFix"></image>
  35. <text>{{item.time}}</text>
  36. </view>
  37. <view class="local">
  38. <image src="../../static/image/local_item.png" mode=""></image>
  39. <text>{{item.address}}</text>
  40. <view class="go_wrap" @click.stop="go(item)">
  41. <image class="go" src="../../static/image/nav.png" mode=""></image>
  42. <view class="teps">
  43. 去这里
  44. </view>
  45. </view>
  46. </view>
  47. <view class="other">
  48. <view class="other_item" @click.stop="good(item.id)">
  49. <image src="../../static/image/good_item.png" mode=""></image> {{item.good_nums}}
  50. </view>
  51. <view class="other_item" @click.stop="bad(item)">
  52. <image src="../../static/image/bad_item.png" mode=""></image> {{item.bad_nums}}
  53. </view>
  54. <view class="other_item">
  55. <image src="../../static/image/eye.png" mode=""></image> {{item.view_nums}}
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="share">
  63. <button hover-class='none' class="shareBtn" type="default" data-name="shareBtn" open-type="share" />
  64. </view>
  65. <view class="tips" @click="show = true">
  66. <image src="../../static/image/tip.png" mode=""></image>
  67. <view class="tips_text">
  68. 说明
  69. </view>
  70. </view>
  71. <u-popup v-model="show" mode="center" border-radius="20" width="580rpx">
  72. <view class="pop_wrap">
  73. <view class="title">
  74. 说明
  75. </view>
  76. <view class="pop_content">
  77. <view class="" style="text-align: justify;">
  78. “去那”小程序只提供信息展示,数据均来自政府公开数据和用户主动上传。如果发现信息有误,请及时进入详情页修改信息或者联系我们。<text
  79. style="color:#10C08C ;">信息的准确性和时效性需要大家共同维护,转发分享,发表意见,帮助他人,快乐自己。</text>
  80. </view>
  81. <view class="" style="color: #FF9C1A;">
  82. 温馨提示:前往核酸检测点,配合工作人员,佩戴口罩,注意个人防护。。
  83. </view>
  84. <view class="">
  85. 如有其他问题请联系 xmbin@hopaheal.com
  86. </view>
  87. <view class="">
  88. “去那”小程序服务理念:为用户提供即时、准确的地点标签
  89. </view>
  90. </view>
  91. </view>
  92. </u-popup>
  93. </view>
  94. </template>
  95. <script>
  96. var app = getApp()
  97. export default {
  98. data() {
  99. return {
  100. list: [],
  101. page: 1,
  102. last: false,
  103. searchValue: '', //搜索
  104. lat: '',
  105. lng: '',
  106. name: '',
  107. address: '',
  108. curSysPosition: {},
  109. local: '',
  110. show: false
  111. }
  112. },
  113. async onLoad() {
  114. this.page = 1
  115. this.list = []
  116. this.last = false
  117. this.getInit()
  118. },
  119. async onPullDownRefresh() {
  120. this.page = 1
  121. this.list = []
  122. this.last = false
  123. await this.getList()
  124. await uni.stopPullDownRefresh()
  125. },
  126. onReachBottom() {
  127. if (!this.last) {
  128. this.page++
  129. }
  130. this.getList()
  131. },
  132. methods: {
  133. //初始化数据
  134. getInit() {
  135. let that = this
  136. let time = Math.round(new Date().getTime() / 1000).toString();
  137. let exp = this.vuex_exp
  138. uni.getLocation({
  139. type: 'wgs84',
  140. // geocode: true, //设置该参数为true可直接获取经纬度及城市信息
  141. success: function(res) {
  142. console.log(res, '====')
  143. that.lat = res.latitude
  144. that.lng = res.longitude
  145. if (!that.vuex_token || (Number(time) == exp)) {
  146. uni.login({
  147. provider: 'weixin',
  148. success: (res) => {
  149. console.log(res, 'ppp')
  150. if (res.code) {
  151. let data = {
  152. appid: 'wxbf3a12d4b07dfcbf',
  153. code: res.code
  154. }
  155. that.$u.post('/base/auth/weapp/login', data).then(
  156. res => {
  157. that.$u.vuex('vuex_token', res.data.token);
  158. that.$u.vuex('vuex_session_key', res.data
  159. .session_key);
  160. that.$u.vuex('vuex_is_auth', res.data
  161. .is_auth);
  162. that.$u.vuex('vuex_user', res.data.user);
  163. that.$u.vuex('vuex_exp', res.data.exp)
  164. that.getList()
  165. that.getLocal()
  166. })
  167. }
  168. }
  169. })
  170. } else {
  171. that.getLocal()
  172. that.getList()
  173. }
  174. },
  175. fail: function() {
  176. uni.showToast({
  177. title: '获取地址失败,将导致部分功能不可用',
  178. icon: 'none'
  179. });
  180. }
  181. });
  182. },
  183. //选择位置
  184. changePosi() {
  185. let that = this
  186. uni.getSetting({
  187. success: (res) => {
  188. console.log(res)
  189. if (!res.authSetting['scope.userLocation']) {
  190. uni.showModal({
  191. title:'提示',
  192. content:'您需要先授权位置信息才可进该项操作!',
  193. confirmText:'去授权',
  194. success: (res) => {
  195. if(res.confirm){
  196. uni.openSetting({
  197. success() {
  198. that.getInit()
  199. }
  200. })
  201. }
  202. }
  203. })
  204. }else{
  205. uni.chooseLocation({
  206. latitude: that.lat,
  207. longitude: that.lng,
  208. success: (res) => {
  209. console.log(res, 'popopopp--------')
  210. that.lat = res.latitude
  211. that.lng = res.longitude
  212. that.getLocal()
  213. // that.local=res.address
  214. that.list = []
  215. that.page = 1
  216. that.last = false
  217. that.getList()
  218. },
  219. fail: (res) => {
  220. }
  221. })
  222. }
  223. }
  224. })
  225. },
  226. //列表
  227. getList() {
  228. // console.log('=========list')
  229. let params = {
  230. lat: this.lat,
  231. lng: this.lng,
  232. page: this.page,
  233. per_page: 15,
  234. keyword: this.searchValue
  235. }
  236. if (!this.searchValue) {
  237. delete params.keyword
  238. }
  239. this.$u.get('/qunali',
  240. params
  241. ).then(res => {
  242. console.log(res, 'ppp')
  243. let data = res.data.list
  244. console.log(res, 'course1')
  245. if (this.page > 1 && data.length == 0) {
  246. uni.showToast({
  247. title: '暂无更多',
  248. icon: 'none'
  249. })
  250. this.last = true
  251. } else {
  252. this.list = this.list.concat(data)
  253. this.list = this.list.map(item => {
  254. item.time = item.time.replace(new RegExp('\n', 'g'), ' ') //去除字符串中的回车
  255. return item
  256. })
  257. }
  258. })
  259. },
  260. detail(item) {
  261. console.log('详情')
  262. uni.navigateTo({
  263. url: 'detail?slug=' + item.slug + '&id=' + item.id + '&distance=' + item.distance
  264. })
  265. },
  266. getLocal() {
  267. this.$u.get('/qunali/geocoder', {
  268. lat: this.lat,
  269. lng: this.lng
  270. }).then(res => {
  271. console.log(res, '-----------')
  272. let address = res.data.address ? res.data.address : ''
  273. this.local = res.data.area + res.data.street + address
  274. })
  275. },
  276. //点击搜索
  277. searchActive() {
  278. this.list = []
  279. this.page = 1
  280. this.last = false
  281. // console.log(this.searchValue, '用户点击了搜索')
  282. this.getList()
  283. },
  284. //清空搜索框
  285. clearActive() {
  286. this.list = []
  287. this.page = 1
  288. this.last = false
  289. this.getList()
  290. // console.log(this.searchValue, '用户点击了搜索---')
  291. },
  292. // 信息有用
  293. good(id) {
  294. this.$u.get('/qunali/good', {
  295. id: id,
  296. }).then(res => {
  297. uni.showToast({
  298. title: '点赞成功',
  299. duration: 2000
  300. })
  301. setTimeout(item => {
  302. this.list = []
  303. this.page = 1
  304. this.last = false
  305. this.getList()
  306. }, 1000)
  307. })
  308. },
  309. // 信息无用
  310. bad(item) {
  311. this.$u.get('/qunali/bad', {
  312. id: item.id
  313. }).then(res => {
  314. uni.showModal({
  315. title: '提示',
  316. content: '诚邀您对这条信息进行修改',
  317. cancelText: '拒绝',
  318. confirmText: '去修改',
  319. success: (res) => {
  320. if (res.confirm) {
  321. uni.reLaunch({
  322. url: '../help/index?slug=' + item.slug
  323. })
  324. } else {
  325. this.list = []
  326. this.page = 1
  327. this.last = false
  328. this.getList()
  329. }
  330. }
  331. })
  332. })
  333. },
  334. //导航
  335. go(item) {
  336. let address = item.area_name + item.street_name + item.address
  337. console.log(item, 'gogogogo')
  338. let longitude = item.lng
  339. let latitude = item.lat
  340. // let name = this.name //
  341. // let address = this.address //地址
  342. wx.openLocation({
  343. latitude,
  344. longitude,
  345. name: address,
  346. // address,
  347. scale: 18 //缩放比例
  348. })
  349. },
  350. onShareAppMessage(res) {
  351. return {
  352. title: '去那',
  353. path: '/pages/index/index'
  354. }
  355. }
  356. }
  357. }
  358. </script>
  359. <style lang="scss">
  360. page {
  361. background-color: #F8F8F8;
  362. position: relative;
  363. }
  364. .index_content {
  365. padding-bottom: 60px;
  366. .top {
  367. position: fixed;
  368. width: 100%;
  369. z-index: 2;
  370. .current_local {
  371. background-color: #10C08C;
  372. padding: 90px 10px 24px;
  373. font-size: 16px;
  374. font-weight: bold;
  375. color: #ffffff;
  376. display: flex;
  377. line-height: 24px;
  378. image {
  379. flex-shrink: 0;
  380. width: 24px;
  381. height: 24px;
  382. display: inline-block;
  383. margin-right: 3px;
  384. }
  385. }
  386. .search {
  387. margin-top: -12px;
  388. background-color: #ffffff;
  389. padding: 12px;
  390. border-top-right-radius: 12px;
  391. border-top-left-radius: 12px;
  392. z-index: 2;
  393. .search_wrap {
  394. background-color: #F8F5F5;
  395. border-radius: 20px;
  396. display: flex;
  397. align-items: center;
  398. padding: 6px 8px;
  399. height: 40px;
  400. image {
  401. flex-shrink: 0;
  402. width: 16px;
  403. height: 16px;
  404. margin: 0 10px;
  405. }
  406. input {
  407. width: 100%;
  408. }
  409. .btn_search {
  410. flex-shrink: 0;
  411. display: inline-block;
  412. background-color: #10c08c;
  413. color: #ffffff;
  414. height: 32px;
  415. line-height: 32px;
  416. padding: 0 19px;
  417. font-size: 14px;
  418. border-radius: 16px;
  419. }
  420. }
  421. }
  422. }
  423. .content {
  424. padding-top: 190px;
  425. .list_wrap {
  426. padding: 12px 12px 20px;
  427. .empty {
  428. padding-top: 60px;
  429. text-align: center;
  430. image {
  431. margin: 0 auto;
  432. width: 50%;
  433. }
  434. .empty-text {
  435. text-align: center;
  436. margin-top: 8px;
  437. color: #B5B5B5;
  438. }
  439. }
  440. .item {
  441. display: flex;
  442. // align-items: center;
  443. border-radius: 5px;
  444. position: relative;
  445. box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.16);
  446. background-color: #ffffff;
  447. margin-bottom: 17px;
  448. .left {
  449. width: 81px;
  450. height: 104px;
  451. border-top-left-radius: 5px;
  452. border-bottom-left-radius: 5px;
  453. // margin-right: 11px;
  454. flex-shrink: 0;
  455. }
  456. .detail {
  457. width: calc(100% - 81px);
  458. height: 100%;
  459. padding: 7px 11px;
  460. // z-index: 2;
  461. .name {
  462. display: flex;
  463. align-items: center;
  464. justify-content: space-between;
  465. font-size: 16px;
  466. font-weight: 400;
  467. color: #000000;
  468. z-index: 2;
  469. padding-bottom: 7px;
  470. image {
  471. width: 14px;
  472. height: 14px;
  473. margin-left: 8px;
  474. }
  475. .title {
  476. overflow: hidden;
  477. text-overflow: ellipsis;
  478. white-space: nowrap;
  479. max-width: calc(100% - 40px);
  480. }
  481. .distance {
  482. color: #9F9F9F;
  483. font-size: 10px;
  484. }
  485. }
  486. .time {
  487. width: 100%;
  488. // height: 16px;
  489. display: flex;
  490. align-items: flex-start;
  491. image {
  492. width: 12px;
  493. height: 12px;
  494. margin-right: 6px;
  495. margin-top: 2px;
  496. }
  497. text {
  498. width: calc(100% - 20px);
  499. height: 16px;
  500. display: inline-block;
  501. color: #FF9100;
  502. font-size: 12px;
  503. overflow: hidden;
  504. text-overflow: ellipsis;
  505. white-space: nowrap;
  506. }
  507. }
  508. .local {
  509. padding-top: 5px;
  510. font-size: 12px;
  511. font-weight: 400;
  512. color: #9F9F9F;
  513. display: flex;
  514. align-items: center;
  515. position: relative;
  516. image {
  517. width: 14px;
  518. height: 13px;
  519. margin: 0;
  520. }
  521. text {
  522. width: calc(100% - 50px);
  523. display: inline-block;
  524. margin-left: 5px;
  525. overflow: hidden;
  526. text-overflow: ellipsis;
  527. white-space: nowrap;
  528. }
  529. .go_wrap {
  530. text-align: center;
  531. position: absolute;
  532. right: 5px;
  533. top: 5px;
  534. .go {
  535. width: 20px;
  536. height: 20px;
  537. // margin-left: 5px;
  538. }
  539. .teps {
  540. font-size: 10px;
  541. font-weight: 400;
  542. color: #10C08C;
  543. }
  544. }
  545. }
  546. .other {
  547. font-size: 10px;
  548. font-weight: 400;
  549. color: #707070;
  550. padding-top: 9px;
  551. margin: 0 -8px;
  552. display: flex;
  553. .other_item {
  554. padding: 0 10px;
  555. display: flex;
  556. align-items: center;
  557. image {
  558. width: 12px;
  559. height: 12px;
  560. margin: 0 3px 0 0;
  561. }
  562. }
  563. }
  564. }
  565. }
  566. }
  567. }
  568. .share {
  569. position: fixed;
  570. z-index: 2;
  571. right: 7px;
  572. bottom: 80px;
  573. button {
  574. width: 60px;
  575. height: 60px;
  576. border-radius: 50%;
  577. background-image: url(../../static/image/share.png);
  578. background-position: center;
  579. background-size: 100%;
  580. box-shadow: 0px 0px 6px rgba(16, 192, 140, 0.6);
  581. padding: 0 !important;
  582. margin: 0 !important;
  583. border: none !important;
  584. box-sizing: border-box;
  585. }
  586. }
  587. .tips {
  588. position: fixed;
  589. z-index: 2;
  590. right: 17px;
  591. bottom: 24px;
  592. width: 39px;
  593. height: 39px;
  594. background: #FFFFFF;
  595. box-shadow: 0px 0px 6px rgba(0, 0, 0, 0.16);
  596. border-radius: 5px;
  597. display: flex;
  598. flex-direction: column;
  599. justify-content: center;
  600. align-items: center;
  601. image {
  602. width: 17px;
  603. height: 17px;
  604. }
  605. .tips_text {
  606. font-size: 9px;
  607. font-weight: bold;
  608. color: #858482;
  609. padding-top: 2px;
  610. }
  611. }
  612. .pop_wrap {
  613. .title {
  614. background-color: #10c08c;
  615. color: #fff;
  616. font-size: 18px;
  617. text-align: center;
  618. height: 40px;
  619. line-height: 40px;
  620. }
  621. .pop_content {
  622. padding: 15px 12px;
  623. view {
  624. margin-bottom: 10px;
  625. }
  626. }
  627. }
  628. }
  629. </style>