food.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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 class="tag-type">
  22. <uni-tag :circle="true" :text="item.iname" type="warning" :inverted="inverted" style="width: 61px;text-align: center; margin-left: 20px;" v-for='item in jobs' @click="change(item)"/>
  23. </view>
  24. <scroll-view scroll-x="true" scroll-with-animation="true" class='list-type'>
  25. <view v-for='item in searchTypes' @click='changetype(item)' :class='searchType==item.value?"Semibold active":"Regular"' class="typeitem">{{item.name}}</view>
  26. </scroll-view>
  27. <view>
  28. <mescroll-uni :up="upOption" :down="downOption" ref="mescrollRef" @init="mescrollInit"
  29. @up="upCallback" @down="downCallback" height="660">
  30. <view class='findItem' v-for='item in findList'>
  31. <view style='align-items: flex-start;' class='flex'>
  32. <view class="left">
  33. <view class='cover'>
  34. <u--image radius='4' :showLoading="true" :src="item.coverImage" width="80px" height="80px"></u--image>
  35. </view>
  36. </view>
  37. <view class="right">
  38. <view class='cover'>
  39. <u--image radius='4' :showLoading="true" :src="item.indoorImage" width="80px" height="80px"></u--image>
  40. </view>
  41. </view>
  42. </view>
  43. <view class='flex'>
  44. <view v-if='item.mainBody=="商铺"' class='iconfont applet-dianpu1'></view>
  45. <u--image v-if='item.mainBody=="个人"' :showLoading="true" src="/static/image/find/geren.png" width="20px" height="20px"></u--image>
  46. <view class='name'>{{item.shopNames}}</view>
  47. </view>
  48. <view class="tag-type">
  49. <uni-tag :inverted="true" :text="item" type="warning" style="width: 61px;text-align: center; margin-left: 10px;" v-for='item in item.labels'/>
  50. </view>
  51. <view class='address flex justify-space-between'>
  52. <view class='flex'>
  53. <view class='iconfont applet-dizhi'></view>
  54. <view>{{item.province}}{{item.city}}{{item.area}}</view>
  55. </view>
  56. <view>{{item.distance}}
  57. <text style='font-weight:600;'>km</text></view>
  58. </view>
  59. </view>
  60. </mescroll-uni>
  61. <!-- <mescroll-body ref="mescrollRef" :up="upOption" :down="downOption" @init="mescrollInit" @up="upCallback" @down="downCallback"></mescroll-body> -->
  62. </view>
  63. <view class='group' @click='group'>
  64. <button class="tuan">团</button>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. var that;
  70. var QQMapWX = require('@/js_sdk/qqmap-wx-jssdk.min.js');
  71. var qqmapsdk = new QQMapWX({
  72. key: 'HQ6BZ-RMALQ-TGF5H-BXJQB-UFYN3-Q5BYM'
  73. });
  74. import MoteLinesDivide from "@/components/text-over-flow/text-over-flow.vue"
  75. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  76. export default {
  77. components: {
  78. MoteLinesDivide
  79. },
  80. mixins: [MescrollMixin],
  81. data() {
  82. return {
  83. searchVal:uni.getStorageSync("search_val")?uni.getStorageSync("search_val"):"",
  84. current:0,
  85. mescroll:null,
  86. findList:[],
  87. inverted: true,
  88. handleList:[],
  89. labels:[],
  90. searchType:'1',
  91. label:'',
  92. longitude:uni.getStorageSync("findlongitude")?uni.getStorageSync("findlongitude"):"",
  93. latitude:uni.getStorageSync("findlatitude")?uni.getStorageSync("findlatitude"):'',
  94. curPageLen:0,
  95. totalPage:0,
  96. detailedAddress:uni.getStorageSync("detailedAddress")?uni.getStorageSync("detailedAddress"):'',
  97. downOption: {
  98. auto: false,
  99. textColor: '#bbb'
  100. },
  101. searchTypes:[
  102. {name:'默认排序',value:'1'},{name:'距离最近',value:'2'},{name:'最多点赞',value:'3'},{name:'我的收藏',value:'4'}
  103. ],
  104. jobs: [
  105. {
  106. id: 1,
  107. iname: '海鲜',
  108. },
  109. {
  110. id: 2,
  111. iname: '自助'
  112. }, {
  113. id: 3,
  114. iname: '烧烤',
  115. },
  116. {
  117. id: 4,
  118. iname: '火锅',
  119. },
  120. {
  121. id: 5,
  122. iname: '家常菜'
  123. }
  124. ],
  125. upOption: {
  126. page: {
  127. size: 10 // 每页数据的数量,默认10
  128. },
  129. auto: false,
  130. noMoreSize: 1,
  131. textNoMore: '没有更多了~',
  132. textColor: '#bbb'
  133. },
  134. };
  135. },
  136. onLoad() {
  137. that = this
  138. // this.getList()
  139. console.log(this)
  140. // this.mescroll.resetUpScroll();
  141. },
  142. onShow(){
  143. if(!this.detailedAddress){
  144. this.placeSelect()
  145. }else{
  146. that.upCallback({
  147. num:1,
  148. size:10
  149. })
  150. }
  151. },
  152. methods: {
  153. search() {
  154. uni.navigateTo({
  155. url: "/pageA/food/search"
  156. })
  157. },
  158. change(item){
  159. if(this.label==item.iname){
  160. this.label=''
  161. }
  162. else{
  163. this.label=item.iname
  164. }
  165. this.inverted = !this.inverted;
  166. that.upCallback({
  167. num:1,
  168. size:10
  169. })
  170. },
  171. changetype(item){
  172. this.searchType=item.value
  173. that.upCallback({
  174. num:1,
  175. size:10
  176. })
  177. },
  178. placeSelect() {
  179. uni.chooseLocation({
  180. success: function(res) {
  181. console.log(res);
  182. that.latitude = res.latitude
  183. that.longitude = res.longitude
  184. uni.setStorageSync("findlatitude",res.latitude)
  185. uni.setStorageSync("findlongitude",res.longitude)
  186. let _address = that.$helper.formatLocation(res.address)
  187. that.detailedAddress = _address.Village
  188. uni.setStorageSync("detailedAddress",_address.Village)
  189. that.$forceUpdate()
  190. that.upCallback({
  191. num:1,
  192. size:10
  193. })
  194. }
  195. });
  196. },
  197. mescrollInit(mescroll) {
  198. this.mescroll = mescroll;
  199. },
  200. downCallback() {
  201. if (uni.getStorageSync("userInfo").phone) {
  202. this.mescroll.resetUpScroll()
  203. } else {
  204. that.mescroll.endBySize(0, 0)
  205. this.showAuthorizePhone = true
  206. }
  207. },
  208. getDistance(latitude,longitude){
  209. console.log(latitude,longitude,that.latitude,that.longitude)
  210. return new Promise((resolve, reject) => {
  211. qqmapsdk.direction({
  212. mode: 'driving', //可选值:'driving'(驾车) trucking 货车
  213. //from参数不填默认当前地址
  214. // latitude纬度 longitude 经度
  215. from: {
  216. latitude: that.latitude,
  217. longitude: that.longitude
  218. },
  219. to: {
  220. latitude: latitude,
  221. longitude:longitude
  222. },
  223. size: 4, // 车型 1: 微型车 2: 轻型车 3: 中型车 4: 重型车
  224. policy: 'LEAST_TIME', //'9', //参考实时路况,高速优先,尽量躲避拥堵
  225. height: 4,
  226. width: 2.5,
  227. length: 13,
  228. weight: 6.8,
  229. axle_weight: 34,
  230. axle_count: 6,
  231. is_trailer: 1,
  232. success: function(res1, data) {
  233. console.log(res1,data[0].distance,data)
  234. resolve(data[0])
  235. }
  236. })
  237. })
  238. },
  239. async upCallback(page) {
  240. uni.showLoading({
  241. title: '数据加载中'
  242. })
  243. await that.$request.baseRequest('admin.tourism.foodInfo', 'list', {
  244. page: page.num,
  245. limit: page.size,
  246. searchType: this.searchType,
  247. label: this.label,
  248. }, failres => {
  249. uni.showToast({
  250. icon: "none",
  251. title: failres.errmsg,
  252. duration: 3000
  253. });
  254. uni.hideLoading()
  255. }).then(res => {
  256. if (page.num == 1) that.findList = [],that.handleList = [];
  257. that.curPageLen = res.data.items.length;
  258. that.handleList = res.data.items
  259. that.totalPage = res.data.total;
  260. })
  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=(data.distance/1000).toFixed(2)
  267. that.handleList[i].labels = that.handleList[i].label.split(",")
  268. if(i==that.handleList.length-1){
  269. setTimeout(()=>{
  270. console.log(that.handleList)
  271. that.findList = that.handleList
  272. that.loading = false
  273. that.$nextTick(() => {
  274. that.mescroll.endBySize(that.curPageLen, that.totalPage)
  275. });
  276. uni.hideLoading()
  277. },100)
  278. }
  279. }
  280. }
  281. else{
  282. uni.hideLoading()
  283. }
  284. },
  285. group(){
  286. uni.navigateTo({
  287. url: '/pageA/food/groupBuying'
  288. })
  289. },
  290. }
  291. }
  292. </script>
  293. <style lang="scss" scoped>
  294. .content1 {
  295. padding: 20rpx;
  296. background-color: #fbb612;
  297. .search {
  298. // color: #9199af;
  299. // background: #f9d27d;
  300. border-radius: 50rpx;
  301. padding: 10rpx 0 10rpx 30rpx;
  302. box-sizing: border-box;
  303. margin-right: 20rpx;
  304. }
  305. .left {
  306. width: 80%;
  307. text {
  308. height: 46rpx;
  309. white-space: nowrap;
  310. overflow: scroll;
  311. position: relative;
  312. margin-left: 20rpx;
  313. color:#9199af;
  314. }
  315. }
  316. .right {
  317. // width:14%;
  318. margin-right: 20rpx
  319. }
  320. }
  321. .search-wrap{
  322. width:78%;
  323. background: #ffff;
  324. border: 1px solid #f9d27d;
  325. border-radius: 50rpx;
  326. }
  327. .address{
  328. width:22%;
  329. }
  330. .findItem{
  331. background:#fff;
  332. margin:10rpx;
  333. border-radius:20rpx;
  334. padding:20rpx;
  335. font-size:32rpx;
  336. .left{
  337. margin-right:20rpx;
  338. .cover{
  339. border-radius: 8rpx;
  340. }
  341. }
  342. .name{
  343. font-size:36rpx;
  344. color:#333;
  345. margin-left:10rpx;
  346. }
  347. .description{
  348. color:#666;
  349. margin-top:10rpx;
  350. }
  351. .address{
  352. margin-top:20rpx;
  353. width:100%;
  354. font-size:28rpx;
  355. color:#393733;
  356. }
  357. }
  358. .applet-dianpu1{
  359. font-size:44rpx;
  360. color:#eaad1a;
  361. }
  362. .applet-dizhi{
  363. font-size:38rpx;
  364. color:#393733;
  365. }
  366. .group{
  367. position: fixed;
  368. margin-left:350px;bottom:10px;
  369. }
  370. .tuan{
  371. background:#eaad1a;
  372. border-radius:50px;
  373. color:#fff;
  374. }
  375. .applet-colors-tianjia2{
  376. font-size:30px;
  377. }
  378. .text {
  379. font-size: 26rpx;
  380. font-weight: 500;
  381. color: #eaad1a;
  382. opacity: 0.5;
  383. margin-right: 56rpx;
  384. }
  385. .tag-type{
  386. background: #fff;
  387. }
  388. .list-type{
  389. background: #fff;
  390. width:100vw;
  391. padding-top:5px;
  392. height:49px;
  393. overflow-x: scroll;
  394. white-space: nowrap;
  395. }
  396. .typeitem{
  397. margin:10px;
  398. position:relative;
  399. display:inline-block;
  400. padding-bottom:10px;
  401. font-size:17px;
  402. }
  403. .typeitem.active:after{
  404. content:'';
  405. display:block;
  406. position:absolute;
  407. height:3px;
  408. bottom:0;
  409. background:#eaad1a;
  410. width:18px;
  411. left:50%;
  412. transform: translateX(-50%);
  413. }
  414. </style>