find.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  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. methods: {
  142. delSearchVal(){
  143. this.searchVal = ''
  144. uni.removeStorageSync("search_val")
  145. that.mescroll.resetUpScroll()
  146. },
  147. search() {
  148. // if (this.userInfo.phone) {
  149. uni.navigateTo({
  150. url: "/pageA/find/search"
  151. })
  152. // } else {
  153. // this.showAuthorizePhone = true
  154. // }
  155. },
  156. placeSelect() {
  157. uni.chooseLocation({
  158. success: function(res) {
  159. console.log(res);
  160. that.latitude = res.latitude
  161. that.longitude = res.longitude
  162. uni.setStorageSync("findlatitude",res.latitude)
  163. uni.setStorageSync("findlongitude",res.longitude)
  164. let _address = that.$helper.formatLocation(res.address)
  165. that.detailedAddress = res.name?res.name:_address.Village
  166. that.detailedAddress1 = that.detailedAddress.length>4 ? that.detailedAddress.slice(0,4)+'...' : that.detailedAddress
  167. console.log(that.detailedAddress,that.detailedAddress1)
  168. uni.setStorageSync("detailedAddress",that.detailedAddress)
  169. that.$forceUpdate()
  170. that.upCallback({
  171. num:1,
  172. size:10
  173. })
  174. }
  175. });
  176. },
  177. isdingwei() {
  178. authorizedLocation().then(res => {
  179. let _obj = {}
  180. if (res == '取消授权') {
  181. //获取上一次,无上一次山海广场
  182. let _place = uni.getStorageSync("LocationPlace")
  183. if (_place && _place.latitude) {
  184. _obj = {
  185. latitude: _place.latitude,
  186. longitude: _place.longitude
  187. }
  188. } else {
  189. _obj = {
  190. latitude: 40.22086204872,
  191. longitude: 122.08338497727
  192. }
  193. }
  194. } else {
  195. _obj = {
  196. latitude: res.latitude,
  197. longitude: res.longitude
  198. }
  199. }
  200. this.longitude = _obj.longitude
  201. this.latitude = _obj.latitude
  202. var amapPluginInstance = new GDMapWX.AMapWX({
  203. key: '6bafe91754a563ff2b7c02542c1ef4e8'
  204. });
  205. amapPluginInstance.getRegeo({
  206. success: function(res){
  207. console.log(res)
  208. that.detailedAddress = res[0].desc
  209. that.detailedAddress1 = that.detailedAddress.length>4 ? that.detailedAddress.slice(0,4)+'...' : that.detailedAddress
  210. console.log(that.detailedAddress,that.detailedAddress1)
  211. that.mescroll.resetUpScroll()
  212. //成功回调
  213. },
  214. fail: function(info){
  215. //失败回调
  216. console.log(info)
  217. }
  218. })
  219. })
  220. },
  221. mescrollInit(mescroll) {
  222. // this.$refs.loginpopup.mescroll = mescroll;
  223. },
  224. downCallback() {
  225. // if (uni.getStorageSync("userInfo").phone) {
  226. this.mescroll.resetUpScroll()
  227. // } else {
  228. // that.mescroll.endBySize(0, 0)
  229. // this.showAuthorizePhone = true
  230. // }
  231. },
  232. getDistance(latitude,longitude){
  233. console.log(latitude,longitude,that.latitude,that.longitude)
  234. return new Promise((resolve, reject) => {
  235. qqmapsdk.direction({
  236. mode: 'driving', //可选值:'driving'(驾车) trucking 货车
  237. //from参数不填默认当前地址
  238. // latitude纬度 longitude 经度
  239. from: {
  240. latitude: that.latitude,
  241. longitude: that.longitude
  242. },
  243. to: {
  244. latitude: latitude,
  245. longitude:longitude
  246. },
  247. size: 4, // 车型 1: 微型车 2: 轻型车 3: 中型车 4: 重型车
  248. policy: 'LEAST_TIME', //'9', //参考实时路况,高速优先,尽量躲避拥堵
  249. height: 4,
  250. width: 2.5,
  251. length: 13,
  252. weight: 6.8,
  253. axle_weight: 34,
  254. axle_count: 6,
  255. is_trailer: 1,
  256. success: function(res1, data) {
  257. console.log(res1,data[0].distance,data)
  258. resolve(data[0])
  259. }
  260. })
  261. })
  262. },
  263. async upCallback(page) {
  264. // if (uni.getStorageSync("userInfo").id) {
  265. uni.showLoading({
  266. title: '数据加载中'
  267. })
  268. var finddata=await that.getfindList(page)
  269. if (page.num == 1) that.findList = [],that.handleList = [];
  270. that.curPageLen = finddata.data.items.length;
  271. that.handleList = finddata.data.items
  272. that.totalPage = finddata.data.total;
  273. if(that.handleList.length > 0){
  274. for(var i=0;i<that.handleList.length;i++){
  275. that.handleList[i].latitude=that.handleList[i].location.split(',')[0]
  276. that.handleList[i].longitude=that.handleList[i].location.split(',')[1]
  277. that.handleList[i].distance1 = JSON.parse(JSON.stringify(that.handleList[i].distance))
  278. that.handleList[i].distance=(that.handleList[i].distance/1000).toFixed(1)
  279. console.log(that.handleList)
  280. that.findList = that.handleList
  281. that.loading = false
  282. }
  283. }
  284. uni.hideLoading()
  285. that.$nextTick(() => {
  286. that.mescroll.endBySize(that.curPageLen, that.totalPage)
  287. });
  288. // }
  289. },
  290. add(){
  291. if(!uni.getStorageSync("userInfo").phone){
  292. this.$refs.loginpopup.open()
  293. }else{
  294. uni.navigateTo({
  295. url: '/pageA/find/createLifeService'
  296. })
  297. }
  298. },
  299. getList(){
  300. this.$request.baseRequest('admin.tourism.carouselManagement', 'list', {
  301. page: 1,
  302. limit: 9999,
  303. classify:'发现'
  304. }, failres => {
  305. uni.showToast({
  306. icon: "none",
  307. title: failres.errmsg,
  308. duration: 3000
  309. });
  310. }).then(res => {
  311. this.fileList=res.data.items
  312. })
  313. },
  314. getfindList(page){
  315. return new Promise((resolve, reject) => {
  316. that.$request.baseRequest('admin.tourism.productManagement', 'list', {
  317. page: page.num,
  318. limit: page.size,
  319. userLongitude:that.longitude,
  320. userLatitude:that.latitude,
  321. searchKeyWord: this.searchVal,
  322. // classify: this.typeName
  323. }, failres => {
  324. uni.showToast({
  325. icon: "none",
  326. title: failres.errmsg,
  327. duration: 3000
  328. });
  329. uni.hideLoading()
  330. }).then(res => {
  331. resolve(res)
  332. })
  333. })
  334. },
  335. }
  336. }
  337. </script>
  338. <style lang="scss" scoped>
  339. .content1 {
  340. position: fixed;
  341. top:0;
  342. left:0;
  343. padding: 20rpx;
  344. background-color: #fff;
  345. z-index:99;
  346. width:100vw;
  347. .search {
  348. // color: #9199af;
  349. // background: #f9d27d;
  350. border-radius: 50rpx;
  351. padding: 10rpx 0 10rpx 30rpx;
  352. box-sizing: border-box;
  353. margin-right: 20rpx;
  354. }
  355. .left {
  356. width: 80%;
  357. view {
  358. height: 40rpx;
  359. line-height: 40rpx;
  360. white-space: nowrap;
  361. overflow: scroll;
  362. position: relative;
  363. margin-left: 20rpx;
  364. color:#9199af;
  365. }
  366. }
  367. .right {
  368. // width:14%;
  369. margin-right: 20rpx
  370. }
  371. }
  372. .search-wrap{
  373. width:76%;
  374. background: #f9f9f9;
  375. // border: 1px solid #f9d27d;
  376. border-radius: 50rpx;
  377. }
  378. .address{
  379. width:24%;
  380. margin-right:20rpx;
  381. }
  382. .findItem{
  383. background:#fff;
  384. margin:10rpx;
  385. border-radius:20rpx;
  386. padding:20rpx;
  387. font-size:32rpx;
  388. .left{
  389. margin-right:20rpx;
  390. .cover{
  391. border-radius: 8rpx;
  392. }
  393. }
  394. .name{
  395. font-size:36rpx;
  396. color:#333;
  397. margin-left:10rpx;
  398. overflow-x: scroll;
  399. }
  400. .description{
  401. color:#666;
  402. margin-top:10rpx;
  403. }
  404. .address{
  405. margin-top:20rpx;
  406. width:100%;
  407. font-size:28rpx;
  408. color:#999;
  409. }
  410. }
  411. .applet-dianpu1{
  412. font-size:44rpx;
  413. color:#eaad1a;
  414. }
  415. .applet-dizhi{
  416. font-size:38rpx;
  417. color:#393733;
  418. }
  419. .add{
  420. // background:#fff;
  421. border-radius:50%;
  422. position: fixed;
  423. right:0;bottom:10px;
  424. }
  425. .applet-colors-tianjia2{
  426. font-size:100px;
  427. }
  428. </style>