find.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <template>
  2. <view>
  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. <uni-icons type="search" size="24" color="#9199af"></uni-icons>
  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>
  22. <u-swiper :list="fileList"
  23. autoplay
  24. imgMode='aspectFill'
  25. height='200'
  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="660">
  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. <view class="iconfont applet-colors-tianjia2"></view>
  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. longitude:uni.getStorageSync("findlongitude")?uni.getStorageSync("findlongitude"):"",
  99. latitude:uni.getStorageSync("findlatitude")?uni.getStorageSync("findlatitude"):'',
  100. curPageLen:0,
  101. totalPage:0,
  102. detailedAddress:uni.getStorageSync("detailedAddress")?uni.getStorageSync("detailedAddress"):'',
  103. downOption: {
  104. auto: false,
  105. textColor: '#bbb'
  106. },
  107. upOption: {
  108. page: {
  109. size: 10 // 每页数据的数量,默认10
  110. },
  111. auto: false,
  112. noMoreSize: 1,
  113. textNoMore: '没有更多了~',
  114. textColor: '#bbb'
  115. },
  116. };
  117. },
  118. onLoad() {
  119. that = this
  120. this.getList()
  121. console.log(this)
  122. // this.mescroll.resetUpScroll();
  123. },
  124. onShow(){
  125. if(!this.detailedAddress){
  126. this.placeSelect()
  127. }else{
  128. that.upCallback({
  129. num:1,
  130. size:10
  131. })
  132. }
  133. },
  134. methods: {
  135. search() {
  136. // if (this.userInfo.phone) {
  137. uni.navigateTo({
  138. url: "/pageA/find/search"
  139. })
  140. // } else {
  141. // this.showAuthorizePhone = true
  142. // }
  143. },
  144. placeSelect() {
  145. uni.chooseLocation({
  146. success: function(res) {
  147. console.log(res);
  148. that.latitude = res.latitude
  149. that.longitude = res.longitude
  150. uni.setStorageSync("findlatitude",res.latitude)
  151. uni.setStorageSync("findlongitude",res.longitude)
  152. let _address = that.$helper.formatLocation(res.address)
  153. that.detailedAddress = _address.Village
  154. uni.setStorageSync("detailedAddress",_address.Village)
  155. that.$forceUpdate()
  156. that.upCallback({
  157. num:1,
  158. size:10
  159. })
  160. }
  161. });
  162. },
  163. mescrollInit(mescroll) {
  164. this.mescroll = mescroll;
  165. },
  166. downCallback() {
  167. if (uni.getStorageSync("userInfo").phone) {
  168. this.mescroll.resetUpScroll()
  169. } else {
  170. that.mescroll.endBySize(0, 0)
  171. this.showAuthorizePhone = true
  172. }
  173. },
  174. getDistance(latitude,longitude){
  175. console.log(latitude,longitude,that.latitude,that.longitude)
  176. return new Promise((resolve, reject) => {
  177. qqmapsdk.direction({
  178. mode: 'driving', //可选值:'driving'(驾车) trucking 货车
  179. //from参数不填默认当前地址
  180. // latitude纬度 longitude 经度
  181. from: {
  182. latitude: that.latitude,
  183. longitude: that.longitude
  184. },
  185. to: {
  186. latitude: latitude,
  187. longitude:longitude
  188. },
  189. size: 4, // 车型 1: 微型车 2: 轻型车 3: 中型车 4: 重型车
  190. policy: 'LEAST_TIME', //'9', //参考实时路况,高速优先,尽量躲避拥堵
  191. height: 4,
  192. width: 2.5,
  193. length: 13,
  194. weight: 6.8,
  195. axle_weight: 34,
  196. axle_count: 6,
  197. is_trailer: 1,
  198. success: function(res1, data) {
  199. console.log(res1,data[0].distance,data)
  200. resolve(data[0])
  201. }
  202. })
  203. })
  204. },
  205. async upCallback(page) {
  206. // if (uni.getStorageSync("userInfo").id) {
  207. uni.showLoading({
  208. title: '数据加载中'
  209. })
  210. await that.$request.baseRequest('admin.tourism.productManagement', 'list', {
  211. page: page.num,
  212. limit: page.size,
  213. // searchContent: this.searchVal,
  214. // classify: this.typeName
  215. }, failres => {
  216. uni.showToast({
  217. icon: "none",
  218. title: failres.errmsg,
  219. duration: 3000
  220. });
  221. uni.hideLoading()
  222. }).then(res => {
  223. if (page.num == 1) that.findList = [],that.handleList = [];
  224. that.curPageLen = res.data.items.length;
  225. that.handleList = res.data.items
  226. that.totalPage = res.data.total;
  227. })
  228. for(var i=0;i<that.handleList.length;i++){
  229. that.handleList[i].latitude=that.handleList[i].location.split(',')[0]
  230. that.handleList[i].longitude=that.handleList[i].location.split(',')[1]
  231. var data=await that.getDistance(that.handleList[i].latitude,that.handleList[i].longitude)
  232. that.handleList[i].distance=(data.distance/1000).toFixed(2)
  233. console.log(data)
  234. if(i==that.handleList.length-1){
  235. setTimeout(()=>{
  236. console.log(that.handleList)
  237. that.findList = that.handleList
  238. that.loading = false
  239. that.$nextTick(() => {
  240. that.mescroll.endBySize(that.curPageLen, that.totalPage)
  241. });
  242. uni.hideLoading()
  243. },100)
  244. }
  245. }
  246. // }
  247. },
  248. add(){
  249. console.log(111111111)
  250. uni.navigateTo({
  251. url: '/pageA/find/createLifeService'
  252. })
  253. },
  254. getList(){
  255. this.$request.baseRequest('admin.tourism.carouselManagement', 'list', {
  256. page: 1,
  257. limit: 9999,
  258. classify:'发现'
  259. }, failres => {
  260. uni.showToast({
  261. icon: "none",
  262. title: failres.errmsg,
  263. duration: 3000
  264. });
  265. }).then(res => {
  266. this.fileList=res.data.items
  267. })
  268. }
  269. }
  270. }
  271. </script>
  272. <style lang="scss" scoped>
  273. .content1 {
  274. padding: 20rpx;
  275. background-color: #fbb612;
  276. .search {
  277. // color: #9199af;
  278. // background: #f9d27d;
  279. border-radius: 50rpx;
  280. padding: 10rpx 0 10rpx 30rpx;
  281. box-sizing: border-box;
  282. margin-right: 20rpx;
  283. }
  284. .left {
  285. width: 80%;
  286. text {
  287. height: 46rpx;
  288. white-space: nowrap;
  289. overflow: scroll;
  290. position: relative;
  291. margin-left: 20rpx;
  292. color:#9199af;
  293. }
  294. }
  295. .right {
  296. // width:14%;
  297. margin-right: 20rpx
  298. }
  299. }
  300. .search-wrap{
  301. width:78%;
  302. background: #ffff;
  303. border: 1px solid #f9d27d;
  304. border-radius: 50rpx;
  305. }
  306. .address{
  307. width:22%;
  308. }
  309. .findItem{
  310. background:#fff;
  311. margin:10rpx;
  312. border-radius:20rpx;
  313. padding:20rpx;
  314. font-size:32rpx;
  315. .left{
  316. margin-right:20rpx;
  317. .cover{
  318. border-radius: 8rpx;
  319. }
  320. }
  321. .name{
  322. font-size:36rpx;
  323. color:#333;
  324. margin-left:10rpx;
  325. }
  326. .description{
  327. color:#666;
  328. margin-top:10rpx;
  329. }
  330. .address{
  331. margin-top:20rpx;
  332. width:100%;
  333. font-size:28rpx;
  334. color:#393733;
  335. }
  336. }
  337. .applet-dianpu1{
  338. font-size:44rpx;
  339. color:#eaad1a;
  340. }
  341. .applet-dizhi{
  342. font-size:38rpx;
  343. color:#393733;
  344. }
  345. .add{
  346. background:#fff;
  347. position: fixed;
  348. right:0;bottom:10px;
  349. }
  350. .applet-colors-tianjia2{
  351. font-size:30px;
  352. }
  353. </style>