find.vue 13 KB

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