find.vue 13 KB

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