find.vue 12 KB

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