find.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <template>
  2. <view>
  3. <view class="flex content1">
  4. <view @click='placeSelect' class='address flex'>
  5. <view class='detailedAddress'>{{detailedAddress1}}</view>
  6. <view class='iconfont applet-xiala'></view>
  7. </view>
  8. <view class=" search-wrap">
  9. <view class="search flex justify-space-between align-item-center flex-between" @click="search">
  10. <view class="left flex align-item-center">
  11. <image class="dSLComVueTopLeftImg" style="width: 30rpx;height: 30rpx;flex: none;" src="@/static/image/card/search.png"></image>
  12. <view class="search-val"> {{searchVal?searchVal:'搜索店铺或服务 '}}</view>
  13. </view>
  14. <view class="right">
  15. <image style='width:32rpx;height:32rpx;' v-if="searchVal" @click.stop="delSearchVal"
  16. src="@/static/image/card/searchdel.png" mode="widthFix"></image>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. <view>
  22. <mescroll-uni :up="upOption" :down="downOption" ref="mescrollRef" @init="mescrollInit"
  23. @up="upCallback" @down="downCallback" height="1400">
  24. <view style='margin-top:108rpx;'>
  25. <u-swiper :list="fileList"
  26. autoplay
  27. :height='height'
  28. imgMode='aspectFill'
  29. radius='0'
  30. interval='5000'
  31. :circular="true"
  32. @change="e => current = e.current" @click="click">
  33. <view slot="indicator" class="indicator">
  34. <view
  35. class="indicator__dot"
  36. v-for="(item, index) in fileList"
  37. :key="index"
  38. :class="[index === current && 'indicator__dot--active']">
  39. </view>
  40. </view>
  41. </u-swiper>
  42. </view>
  43. <view class='findItem' v-for='item in findList'>
  44. <view style='align-items: flex-start;' class='flex'>
  45. <view class="left">
  46. <view class='cover'>
  47. <u--image radius='4' :showLoading="true" :src="item.coverImage" width="86px" height="86px" @click="click"></u--image>
  48. </view>
  49. </view>
  50. <view class="right">
  51. <view class='flex'>
  52. <view v-if='item.mainBody=="商铺"' class='iconfont applet-dianpu1'></view>
  53. <u--image v-if='item.mainBody=="个人"' :showLoading="true" src="/static/image/find/geren.png" width="20px" height="20px"></u--image>
  54. <view class='name'>{{item.shopNames}}</view>
  55. </view>
  56. <view class='description'>
  57. <mote-lines-divide :dt="item.serviceDescription" :line="3" expandText="展开" foldHint="收起" />
  58. </view>
  59. </view>
  60. </view>
  61. <view class='address flex justify-space-between'>
  62. <view class='flex'>
  63. <view class='iconfont applet-dizhi'></view>
  64. <view>{{item.detailedAddress}}</view>
  65. </view>
  66. <view>{{item.distance1>1000?item.distance:item.distance1}}
  67. <text style='font-weight:600;'>{{item.distance1>1000?'km':'m'}}</text></view>
  68. </view>
  69. </view>
  70. </mescroll-uni>
  71. <!-- <mescroll-body ref="mescrollRef" :up="upOption" :down="downOption" @init="mescrollInit" @up="upCallback" @down="downCallback"></mescroll-body> -->
  72. </view>
  73. <login-pop-up ref='loginpopup' :content='"手机登录后才能发布内容哦~"'></login-pop-up>
  74. <view class='add' @click='add'>
  75. <u--image :showLoading="true" src="/static/image/find/add.png" width="60px" height="60px"></u--image>
  76. </view>
  77. </view>
  78. </template>
  79. <script>
  80. var that;
  81. var GDMapWX = require('@/js_sdk/js-amap/amap-wx.130.js');
  82. import {
  83. authorizedLocation
  84. } from '@/util/util.js'
  85. import MoteLinesDivide from "@/components/text-over-flow/text-over-flow.vue"
  86. import loginPopUp from "@/components/loginPopUp/index.vue"
  87. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  88. export default {
  89. components: {
  90. MoteLinesDivide,
  91. loginPopUp
  92. },
  93. mixins: [MescrollMixin],
  94. data() {
  95. return {
  96. searchVal:uni.getStorageSync("search_val")?uni.getStorageSync("search_val"):"",
  97. current:0,
  98. mescroll:null,
  99. fileList:[],
  100. findList:[],
  101. handleList:[],
  102. height:'',
  103. width:'',
  104. longitude:"122.084565",
  105. latitude:'40.220547',
  106. curPageLen:0,
  107. totalPage:0,
  108. detailedAddress:'正在定位...',
  109. detailedAddress1:'',
  110. downOption: {
  111. auto: false,
  112. textColor: '#bbb'
  113. },
  114. upOption: {
  115. page: {
  116. size: 10 // 每页数据的数量,默认10
  117. },
  118. auto: false,
  119. noMoreSize: 1,
  120. textNoMore: '没有更多了~',
  121. textColor: '#bbb'
  122. },
  123. };
  124. },
  125. onLoad() {
  126. that = this
  127. this.getList()
  128. // this.mescroll.resetUpScroll();
  129. },
  130. onShow(){
  131. if(uni.getStorageSync("search_val")){
  132. this.searchVal = uni.getStorageSync("search_val")
  133. this.mescroll.resetUpScroll()
  134. }
  135. this.height = uni.getSystemInfoSync().windowWidth/2.35;
  136. this.width = uni.getSystemInfoSync().windowWidth;
  137. if(this.detailedAddress=='正在定位...'){
  138. this.isdingwei()
  139. }
  140. },
  141. onShareAppMessage(res) {
  142. debugger
  143. let path = `/pages/find/find?id=${this.searchVal}`
  144. if (res.from === 'button') {
  145. return {
  146. title: "本地生活一键搜索",
  147. path: path,
  148. };
  149. }
  150. if (res.from === 'menu') {
  151. return {
  152. title: "本地生活一键搜索",
  153. path: path,
  154. };
  155. }
  156. },
  157. methods: {
  158. delSearchVal(){
  159. this.searchVal = ''
  160. uni.removeStorageSync("search_val")
  161. that.mescroll.resetUpScroll()
  162. },
  163. search() {
  164. // if (this.userInfo.phone) {
  165. uni.navigateTo({
  166. url: "/pageA/find/search"
  167. })
  168. // } else {
  169. // this.showAuthorizePhone = true
  170. // }
  171. },
  172. placeSelect() {
  173. uni.chooseLocation({
  174. success: function(res) {
  175. console.log(res);
  176. that.latitude = res.latitude
  177. that.longitude = res.longitude
  178. uni.setStorageSync("findlatitude",res.latitude)
  179. uni.setStorageSync("findlongitude",res.longitude)
  180. let _address = that.$helper.formatLocation(res.address)
  181. that.detailedAddress = res.name?res.name:_address.Village
  182. that.detailedAddress1 = that.detailedAddress.length>4 ? that.detailedAddress.slice(0,4)+'...' : that.detailedAddress
  183. console.log(that.detailedAddress,that.detailedAddress1)
  184. uni.setStorageSync("detailedAddress",that.detailedAddress)
  185. that.$forceUpdate()
  186. that.upCallback({
  187. num:1,
  188. size:10
  189. })
  190. }
  191. });
  192. },
  193. isdingwei() {
  194. authorizedLocation().then(res => {
  195. let _obj = {}
  196. if (res == '取消授权') {
  197. //获取上一次,无上一次山海广场
  198. let _place = uni.getStorageSync("LocationPlace")
  199. if (_place && _place.latitude) {
  200. _obj = {
  201. latitude: _place.latitude,
  202. longitude: _place.longitude
  203. }
  204. } else {
  205. _obj = {
  206. latitude: 40.22086204872,
  207. longitude: 122.08338497727
  208. }
  209. }
  210. } else {
  211. _obj = {
  212. latitude: res.latitude,
  213. longitude: res.longitude
  214. }
  215. }
  216. this.longitude = _obj.longitude
  217. this.latitude = _obj.latitude
  218. var amapPluginInstance = new GDMapWX.AMapWX({
  219. key: '6bafe91754a563ff2b7c02542c1ef4e8'
  220. });
  221. amapPluginInstance.getRegeo({
  222. success: function(res){
  223. console.log(res)
  224. that.detailedAddress = res[0].desc
  225. that.detailedAddress1 = that.detailedAddress.length>4 ? that.detailedAddress.slice(0,4)+'...' : that.detailedAddress
  226. console.log(that.detailedAddress,that.detailedAddress1)
  227. that.mescroll.resetUpScroll()
  228. //成功回调
  229. },
  230. fail: function(info){
  231. //失败回调
  232. console.log(info)
  233. }
  234. })
  235. })
  236. },
  237. mescrollInit(mescroll) {
  238. // this.$refs.loginpopup.mescroll = mescroll;
  239. },
  240. downCallback() {
  241. // if (uni.getStorageSync("userInfo").phone) {
  242. this.mescroll.resetUpScroll()
  243. // } else {
  244. // that.mescroll.endBySize(0, 0)
  245. // this.showAuthorizePhone = true
  246. // }
  247. },
  248. getDistance(latitude,longitude){
  249. console.log(latitude,longitude,that.latitude,that.longitude)
  250. return new Promise((resolve, reject) => {
  251. qqmapsdk.direction({
  252. mode: 'driving', //可选值:'driving'(驾车) trucking 货车
  253. //from参数不填默认当前地址
  254. // latitude纬度 longitude 经度
  255. from: {
  256. latitude: that.latitude,
  257. longitude: that.longitude
  258. },
  259. to: {
  260. latitude: latitude,
  261. longitude:longitude
  262. },
  263. size: 4, // 车型 1: 微型车 2: 轻型车 3: 中型车 4: 重型车
  264. policy: 'LEAST_TIME', //'9', //参考实时路况,高速优先,尽量躲避拥堵
  265. height: 4,
  266. width: 2.5,
  267. length: 13,
  268. weight: 6.8,
  269. axle_weight: 34,
  270. axle_count: 6,
  271. is_trailer: 1,
  272. success: function(res1, data) {
  273. console.log(res1,data[0].distance,data)
  274. resolve(data[0])
  275. }
  276. })
  277. })
  278. },
  279. async upCallback(page) {
  280. // if (uni.getStorageSync("userInfo").id) {
  281. uni.showLoading({
  282. title: '数据加载中'
  283. })
  284. var finddata=await that.getfindList(page)
  285. if (page.num == 1) that.findList = [],that.handleList = [];
  286. that.curPageLen = finddata.data.items.length;
  287. that.handleList = finddata.data.items
  288. that.totalPage = finddata.data.total;
  289. if(that.handleList.length > 0){
  290. for(var i=0;i<that.handleList.length;i++){
  291. that.handleList[i].latitude=that.handleList[i].location.split(',')[0]
  292. that.handleList[i].longitude=that.handleList[i].location.split(',')[1]
  293. that.handleList[i].distance1 = JSON.parse(JSON.stringify(that.handleList[i].distance))
  294. that.handleList[i].distance=(that.handleList[i].distance/1000).toFixed(1)
  295. console.log(that.handleList)
  296. that.findList = that.handleList
  297. that.loading = false
  298. }
  299. }
  300. uni.hideLoading()
  301. that.$nextTick(() => {
  302. that.mescroll.endBySize(that.curPageLen, that.totalPage)
  303. });
  304. // }
  305. },
  306. add(){
  307. if(!uni.getStorageSync("userInfo").phone){
  308. this.$refs.loginpopup.open()
  309. }else{
  310. uni.navigateTo({
  311. url: '/pageA/find/createLifeService'
  312. })
  313. }
  314. },
  315. getList(){
  316. this.$request.baseRequest('admin.tourism.carouselManagement', 'list', {
  317. page: 1,
  318. limit: 9999,
  319. classify:'发现'
  320. }, failres => {
  321. uni.showToast({
  322. icon: "none",
  323. title: failres.errmsg,
  324. duration: 3000
  325. });
  326. }).then(res => {
  327. this.fileList=res.data.items
  328. })
  329. },
  330. getfindList(page){
  331. return new Promise((resolve, reject) => {
  332. that.$request.baseRequest('admin.tourism.productManagement', 'list', {
  333. page: page.num,
  334. limit: page.size,
  335. userLongitude:that.longitude,
  336. userLatitude:that.latitude,
  337. searchKeyWord: this.searchVal,
  338. // classify: this.typeName
  339. }, failres => {
  340. uni.showToast({
  341. icon: "none",
  342. title: failres.errmsg,
  343. duration: 3000
  344. });
  345. uni.hideLoading()
  346. }).then(res => {
  347. resolve(res)
  348. })
  349. })
  350. },
  351. }
  352. }
  353. </script>
  354. <style lang="scss" scoped>
  355. .content1 {
  356. position: fixed;
  357. top:0;
  358. left:0;
  359. padding: 20rpx;
  360. background-color: #fff;
  361. z-index:99;
  362. width:100vw;
  363. .search {
  364. // color: #9199af;
  365. // background: #f9d27d;
  366. border-radius: 50rpx;
  367. padding: 10rpx 0 10rpx 30rpx;
  368. box-sizing: border-box;
  369. margin-right: 20rpx;
  370. }
  371. .left {
  372. width: 80%;
  373. view {
  374. height: 40rpx;
  375. line-height: 40rpx;
  376. white-space: nowrap;
  377. overflow: scroll;
  378. position: relative;
  379. margin-left: 20rpx;
  380. color:#9199af;
  381. }
  382. }
  383. .right {
  384. // width:14%;
  385. margin-right: 20rpx
  386. }
  387. }
  388. .search-wrap{
  389. width:76%;
  390. background: #f9f9f9;
  391. // border: 1px solid #f9d27d;
  392. border-radius: 50rpx;
  393. }
  394. .address{
  395. width:24%;
  396. margin-right:20rpx;
  397. }
  398. .findItem{
  399. background:#fff;
  400. margin:10rpx;
  401. border-radius:20rpx;
  402. padding:20rpx;
  403. font-size:32rpx;
  404. .left{
  405. margin-right:20rpx;
  406. .cover{
  407. border-radius: 8rpx;
  408. }
  409. }
  410. .name{
  411. font-size:36rpx;
  412. color:#333;
  413. margin-left:10rpx;
  414. overflow-x: scroll;
  415. }
  416. .description{
  417. color:#666;
  418. margin-top:10rpx;
  419. }
  420. .address{
  421. margin-top:20rpx;
  422. width:100%;
  423. font-size:28rpx;
  424. color:#999;
  425. }
  426. }
  427. .applet-dianpu1{
  428. font-size:44rpx;
  429. color:#eaad1a;
  430. }
  431. .applet-dizhi{
  432. font-size:38rpx;
  433. color:#393733;
  434. }
  435. .add{
  436. // background:#fff;
  437. border-radius:50%;
  438. position: fixed;
  439. right:0;bottom:10px;
  440. }
  441. .applet-colors-tianjia2{
  442. font-size:100px;
  443. }
  444. </style>