find.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. <template>
  2. <view style='padding-bottom:150rpx;'>
  3. <view class="flex content1">
  4. <view @click='placeSelect' class='address flex'>
  5. <view class='detailedAddress'>{{detailedAddress}}</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">
  11. <image class="dSLComVueTopLeftImg" style="width: 30rpx;height: 30rpx;flex: none;" src="@/static/image/card/search.png"></image>
  12. <text class="search-val"> {{searchVal?searchVal:'搜索店铺或服务 '}}</text>
  13. </view>
  14. <view class="right">
  15. <!-- <image style='width:32rpx;height:32rpx;' v-if="searchVal" @click.native.stop="delSearchVal"
  16. src="../../static/imgs/card/searchdel.png" mode="widthFix"></image> -->
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. <view style='margin-top:106rpx;'>
  22. <u-swiper :list="fileList"
  23. autoplay
  24. :height='height'
  25. imgMode='aspectFill'
  26. radius='0'
  27. :circular="true"
  28. @change="e => current = e.current" @click="click">
  29. <view slot="indicator" class="indicator">
  30. <view
  31. class="indicator__dot"
  32. v-for="(item, index) in fileList"
  33. :key="index"
  34. :class="[index === current && 'indicator__dot--active']">
  35. </view>
  36. </view>
  37. </u-swiper>
  38. </view>
  39. <view>
  40. <mescroll-uni :up="upOption" :down="downOption" ref="mescrollRef" @init="mescrollInit"
  41. @up="upCallback" @down="downCallback" height="730">
  42. <view class='findItem' v-for='item in findList'>
  43. <view style='align-items: flex-start;' class='flex'>
  44. <view class="left">
  45. <view class='cover'>
  46. <u--image radius='4' :showLoading="true" :src="item.coverImage" width="80px" height="80px" @click="click"></u--image>
  47. </view>
  48. </view>
  49. <view class="right">
  50. <view class='flex'>
  51. <view v-if='item.mainBody=="商铺"' class='iconfont applet-dianpu1'></view>
  52. <u--image v-if='item.mainBody=="个人"' :showLoading="true" src="/static/image/find/geren.png" width="20px" height="20px"></u--image>
  53. <view class='name'>{{item.shopNames}}</view>
  54. </view>
  55. <view class='description'>
  56. <mote-lines-divide :dt="item.serviceDescription" :line="4" expandText="展开" foldHint="收起" />
  57. </view>
  58. </view>
  59. </view>
  60. <view class='address flex justify-space-between'>
  61. <view class='flex'>
  62. <view class='iconfont applet-dizhi'></view>
  63. <view>{{item.province}}{{item.city}}{{item.area}}</view>
  64. </view>
  65. <view>{{item.distance}}
  66. <text style='font-weight:600;'>km</text></view>
  67. </view>
  68. </view>
  69. </mescroll-uni>
  70. <!-- <mescroll-body ref="mescrollRef" :up="upOption" :down="downOption" @init="mescrollInit" @up="upCallback" @down="downCallback"></mescroll-body> -->
  71. </view>
  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 QQMapWX = require('@/js_sdk/qqmap-wx-jssdk.min.js');
  80. var qqmapsdk = new QQMapWX({
  81. key: 'HQ6BZ-RMALQ-TGF5H-BXJQB-UFYN3-Q5BYM'
  82. });
  83. import MoteLinesDivide from "@/components/text-over-flow/text-over-flow.vue"
  84. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  85. export default {
  86. components: {
  87. MoteLinesDivide
  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:uni.getStorageSync("findlongitude")?uni.getStorageSync("findlongitude"):"122.084565",
  101. latitude:uni.getStorageSync("findlatitude")?uni.getStorageSync("findlatitude"):'40.220547',
  102. curPageLen:0,
  103. totalPage:0,
  104. detailedAddress:uni.getStorageSync("detailedAddress")?uni.getStorageSync("detailedAddress"):'山海广场',
  105. downOption: {
  106. auto: false,
  107. textColor: '#bbb'
  108. },
  109. upOption: {
  110. page: {
  111. size: 10 // 每页数据的数量,默认10
  112. },
  113. auto: false,
  114. noMoreSize: 1,
  115. textNoMore: '没有更多了~',
  116. textColor: '#bbb'
  117. },
  118. };
  119. },
  120. onLoad() {
  121. that = this
  122. this.getList()
  123. // this.mescroll.resetUpScroll();
  124. },
  125. onShow(){
  126. this.height = uni.getSystemInfoSync().windowWidth/2;
  127. this.width = uni.getSystemInfoSync().windowWidth;
  128. console.log(this.height,this.width,11111111)
  129. if(!this.detailedAddress){
  130. // this.placeSelect()
  131. }else{
  132. that.upCallback({
  133. num:1,
  134. size:10
  135. })
  136. }
  137. },
  138. methods: {
  139. search() {
  140. // if (this.userInfo.phone) {
  141. uni.navigateTo({
  142. url: "/pageA/find/search"
  143. })
  144. // } else {
  145. // this.showAuthorizePhone = true
  146. // }
  147. },
  148. placeSelect() {
  149. uni.chooseLocation({
  150. success: function(res) {
  151. console.log(res);
  152. that.latitude = res.latitude
  153. that.longitude = res.longitude
  154. uni.setStorageSync("findlatitude",res.latitude)
  155. uni.setStorageSync("findlongitude",res.longitude)
  156. let _address = that.$helper.formatLocation(res.address)
  157. that.detailedAddress = _address.Village
  158. console.log(that.detailedAddress)
  159. uni.setStorageSync("detailedAddress",_address.Village)
  160. that.$forceUpdate()
  161. that.upCallback({
  162. num:1,
  163. size:10
  164. })
  165. }
  166. });
  167. },
  168. isdingwei() {
  169. authorizedLocation().then(res => {
  170. let _obj = {}
  171. if (res == '取消授权') {
  172. //获取上一次,无上一次山海广场
  173. let _place = uni.getStorageSync("LocationPlace")
  174. if (_place && _place.latitude) {
  175. _obj = {
  176. latitude: _place.latitude,
  177. longitude: _place.longitude
  178. }
  179. } else {
  180. _obj = {
  181. latitude: 40.22086204872,
  182. longitude: 122.08338497727
  183. }
  184. }
  185. } else {
  186. _obj = {
  187. latitude: res.latitude,
  188. longitude: res.longitude
  189. }
  190. }
  191. this.longitude = _obj.longitude
  192. this.latitude = _obj.latitude
  193. qqmapsdk.reverseGeocoder({
  194. location: _obj,
  195. success: function(res) {
  196. console.log(res)
  197. that.detailedAddress = res.result.formatted_addresses.recommend
  198. that.mescroll.resetUpScroll()
  199. },
  200. fail: function(error) {
  201. console.error(error);
  202. },
  203. complete: function(res) {
  204. // console.log(res);
  205. }
  206. })
  207. })
  208. },
  209. mescrollInit(mescroll) {
  210. this.mescroll = mescroll;
  211. },
  212. downCallback() {
  213. if (uni.getStorageSync("userInfo").phone) {
  214. this.mescroll.resetUpScroll()
  215. } else {
  216. that.mescroll.endBySize(0, 0)
  217. this.showAuthorizePhone = true
  218. }
  219. },
  220. getDistance(latitude,longitude){
  221. console.log(latitude,longitude,that.latitude,that.longitude)
  222. return new Promise((resolve, reject) => {
  223. qqmapsdk.direction({
  224. mode: 'driving', //可选值:'driving'(驾车) trucking 货车
  225. //from参数不填默认当前地址
  226. // latitude纬度 longitude 经度
  227. from: {
  228. latitude: that.latitude,
  229. longitude: that.longitude
  230. },
  231. to: {
  232. latitude: latitude,
  233. longitude:longitude
  234. },
  235. size: 4, // 车型 1: 微型车 2: 轻型车 3: 中型车 4: 重型车
  236. policy: 'LEAST_TIME', //'9', //参考实时路况,高速优先,尽量躲避拥堵
  237. height: 4,
  238. width: 2.5,
  239. length: 13,
  240. weight: 6.8,
  241. axle_weight: 34,
  242. axle_count: 6,
  243. is_trailer: 1,
  244. success: function(res1, data) {
  245. console.log(res1,data[0].distance,data)
  246. resolve(data[0])
  247. }
  248. })
  249. })
  250. },
  251. async upCallback(page) {
  252. // if (uni.getStorageSync("userInfo").id) {
  253. uni.showLoading({
  254. title: '数据加载中'
  255. })
  256. var finddata=await that.getfindList(page)
  257. if (page.num == 1) that.findList = [],that.handleList = [];
  258. that.curPageLen = finddata.data.items.length;
  259. that.handleList = finddata.data.items
  260. that.totalPage = finddata.data.total;
  261. if(that.handleList.length > 0){
  262. for(var i=0;i<that.handleList.length;i++){
  263. that.handleList[i].latitude=that.handleList[i].location.split(',')[0]
  264. that.handleList[i].longitude=that.handleList[i].location.split(',')[1]
  265. // var data=await that.getDistance(that.handleList[i].latitude,that.handleList[i].longitude)
  266. that.handleList[i].distance=(that.handleList[i].distance/1000).toFixed(2)
  267. console.log(that.handleList)
  268. that.findList = that.handleList
  269. that.loading = false
  270. }
  271. }
  272. uni.hideLoading()
  273. that.$nextTick(() => {
  274. that.mescroll.endBySize(that.curPageLen, that.totalPage)
  275. });
  276. // }
  277. },
  278. add(){
  279. uni.navigateTo({
  280. url: '/pageA/find/createLifeService'
  281. })
  282. },
  283. getList(){
  284. this.$request.baseRequest('admin.tourism.carouselManagement', 'list', {
  285. page: 1,
  286. limit: 9999,
  287. classify:'发现'
  288. }, failres => {
  289. uni.showToast({
  290. icon: "none",
  291. title: failres.errmsg,
  292. duration: 3000
  293. });
  294. }).then(res => {
  295. this.fileList=res.data.items
  296. })
  297. },
  298. getfindList(page){
  299. return new Promise((resolve, reject) => {
  300. that.$request.baseRequest('admin.tourism.productManagement', 'list', {
  301. page: page.num,
  302. limit: page.size,
  303. latitude: that.latitude,
  304. longitude: that.longitude
  305. // searchContent: this.searchVal,
  306. // classify: this.typeName
  307. }, failres => {
  308. uni.showToast({
  309. icon: "none",
  310. title: failres.errmsg,
  311. duration: 3000
  312. });
  313. uni.hideLoading()
  314. }).then(res => {
  315. resolve(res)
  316. })
  317. })
  318. },
  319. }
  320. }
  321. </script>
  322. <style lang="scss" scoped>
  323. .content1 {
  324. position: fixed;
  325. top:0;
  326. left:0;
  327. padding: 20rpx;
  328. background-color: #fff;
  329. z-index:99;
  330. width:95vw;
  331. .search {
  332. // color: #9199af;
  333. // background: #f9d27d;
  334. border-radius: 50rpx;
  335. padding: 10rpx 0 10rpx 30rpx;
  336. box-sizing: border-box;
  337. margin-right: 20rpx;
  338. }
  339. .left {
  340. width: 80%;
  341. text {
  342. height: 46rpx;
  343. white-space: nowrap;
  344. overflow: scroll;
  345. position: relative;
  346. margin-left: 20rpx;
  347. color:#9199af;
  348. }
  349. }
  350. .right {
  351. // width:14%;
  352. margin-right: 20rpx
  353. }
  354. }
  355. .search-wrap{
  356. width:78%;
  357. background: #f9f9f9;
  358. // border: 1px solid #f9d27d;
  359. border-radius: 50rpx;
  360. }
  361. .address{
  362. width:22%;
  363. }
  364. .findItem{
  365. background:#fff;
  366. margin:10rpx;
  367. border-radius:20rpx;
  368. padding:20rpx;
  369. font-size:32rpx;
  370. .left{
  371. margin-right:20rpx;
  372. .cover{
  373. border-radius: 8rpx;
  374. }
  375. }
  376. .name{
  377. font-size:36rpx;
  378. color:#333;
  379. margin-left:10rpx;
  380. }
  381. .description{
  382. color:#666;
  383. margin-top:10rpx;
  384. }
  385. .address{
  386. margin-top:20rpx;
  387. width:100%;
  388. font-size:28rpx;
  389. color:#999;
  390. }
  391. }
  392. .applet-dianpu1{
  393. font-size:44rpx;
  394. color:#eaad1a;
  395. }
  396. .applet-dizhi{
  397. font-size:38rpx;
  398. color:#393733;
  399. }
  400. .add{
  401. // background:#fff;
  402. border-radius:50%;
  403. position: fixed;
  404. right:0;bottom:10px;
  405. }
  406. .applet-colors-tianjia2{
  407. font-size:100px;
  408. }
  409. </style>