find.vue 13 KB

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