find.vue 13 KB

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