index1.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. <template>
  2. <view class="width-100 height-100 view-page">
  3. <view class="p-10 dis-flex flex-y-center flex-x-between">
  4. <view class="search-left-btn">
  5. <u-image width="35px" height="35px" mode="aspectFit" src="@/static/images/home/logo.png"></u-image>
  6. </view>
  7. <view class="width-100">
  8. <u-search :clearabled="true" height="35px" placeholder="请输入搜索关键字" v-model="keyword" shape="round"
  9. search="doSearch" @custom="doSearch" :showAction="false" bg-color="#e9f0f8"
  10. placeholder-color="#65371b"></u-search>
  11. </view>
  12. </view>
  13. <view v-show="currentTab != 3">
  14. <view style="width: 100%;height: 150px;">
  15. <l-echart class="width-100 height-100" ref="chart" @finished="init"></l-echart>
  16. </view>
  17. <view class="area-title">
  18. <u-icon name="map-fill" color="#65371b"></u-icon>
  19. <view class="area-title-text">{{currentAreaName || '广东省'}}</view>
  20. </view>
  21. </view>
  22. <u-tabs ref="tabs" :list="tabList" :scrollable="false" :current="currentTab" @change="tabChange" lineColor="#65371b"
  23. :activeStyle="{color:'#65371b'}" inactiveStyle="{color:'#65371b'}"></u-tabs>
  24. <u-list @scrolltolower="scrolltolower" :height="currentTab != 3?'calc(100% - 283px)':'calc(100% - 59px)'"
  25. lowerThreshold="10">
  26. <view class="info-list">
  27. <view class="info-item" v-for="(item, index) in list" :key="index" @click="toDetail(item.id)">
  28. <view class="info-pic">
  29. <u-image width="175rpx" height="175rpx" mode="aspectFill" :src="item.cover"></u-image>
  30. </view>
  31. <view class="info-title">
  32. {{item.name || item.title}}
  33. </view>
  34. </view>
  35. </view>
  36. <u-loadmore :status="page.status" :loading-text="page.loadingText" :loadmore-text="page.loadmoreText"
  37. :nomore-text="page.nomoreText" />
  38. </u-list>
  39. </view>
  40. </template>
  41. <script>
  42. import * as echarts from '@/static/echarts.min'
  43. import * as mapJson from '@/mockdata/mapdata.json'; /*echart.min.js为在线定制*/
  44. let myChart;
  45. export default {
  46. data() {
  47. return {
  48. option: {
  49. title: {
  50. show: false,
  51. text: '',
  52. subtext: '',
  53. sublink: '',
  54. left: 'right'
  55. },
  56. tooltip: {
  57. show: false,
  58. trigger: 'item',
  59. formatter: '{b}'
  60. },
  61. toolbox: {
  62. show: false,
  63. },
  64. visualMap: {
  65. show: false,
  66. min: 1,
  67. max: 3,
  68. text: ['High', 'Low'],
  69. realtime: false,
  70. calculable: true,
  71. inRange: {
  72. //color: ['#91abd7', '#e57e80', '#ad9a92'],
  73. //color: ['#515E73', '#A7787A', '#64554E']
  74. color: ['#91abd7', '#A7787A', '#64554E']
  75. }
  76. },
  77. series: [{
  78. name: 'GD',
  79. type: 'map',
  80. roam: true,
  81. //
  82. // 缩放范围限制
  83. scaleLimit: {
  84. min: 1.5,
  85. max: 5
  86. },
  87. map: 'GD',
  88. data: [{
  89. name: '汕尾市',
  90. value: 3,
  91. }, {
  92. name: '云浮市',
  93. value: 1
  94. }, {
  95. name: '河源市',
  96. value: 2
  97. }, {
  98. name: '梅州市',
  99. value: 2
  100. }, {
  101. name: '韶关市',
  102. value: 2
  103. }, {
  104. name: '阳江市',
  105. value: 1
  106. }, {
  107. name: '肇庆市',
  108. value: 1
  109. }, {
  110. name: '清远市',
  111. value: 1
  112. }, {
  113. name: '茂名市',
  114. value: 1
  115. }, {
  116. name: '潮州市',
  117. value: 3
  118. }, {
  119. name: '揭阳市',
  120. value: 3
  121. }, {
  122. name: '湛江市',
  123. value: 1
  124. }, {
  125. name: '江门市',
  126. value: 1
  127. }, {
  128. name: '珠海市',
  129. value: 1
  130. }, {
  131. name: '汕头市',
  132. value: 3
  133. }, {
  134. name: '惠州市',
  135. value: 2
  136. }, {
  137. name: '中山市',
  138. value: 1
  139. }, {
  140. name: '佛山市',
  141. value: 1
  142. }, {
  143. name: '东莞市',
  144. value: 1
  145. }, {
  146. name: '广州市',
  147. value: 1
  148. }, {
  149. name: '深圳市',
  150. value: 1
  151. }],
  152. emphasis: {
  153. label: {
  154. show: true
  155. }
  156. },
  157. }],
  158. },
  159. //
  160. page: {
  161. current: 1,
  162. size: 15,
  163. total: 0,
  164. // loadmore loading nomore
  165. status: 'loadmore',
  166. loadingText: '正在加载中',
  167. loadmoreText: '上拉加载更多',
  168. nomoreText: '没有更多了'
  169. },
  170. keyword: '',
  171. areaCode: '',
  172. currentAreaName: '',
  173. list: [],
  174. tabList: [{
  175. name: '名店',
  176. }, {
  177. name: '名菜'
  178. }, {
  179. name: '名点',
  180. }, {
  181. name: '专业风采'
  182. }],
  183. currentTab: 0
  184. }
  185. },
  186. onLoad(options) {
  187. uni.hideLoading()
  188. this.doRefresh()
  189. },
  190. onShow() {},
  191. methods: {
  192. async init() {
  193. // chart 图表实例不能存在data里
  194. echarts.registerMap('GD', mapJson, {});
  195. const chart = await this.$refs.chart.init(echarts);
  196. chart.setOption(this.option)
  197. chart.on('click', this.clickMap);
  198. myChart = chart;
  199. },
  200. clickMap(e) {
  201. let currentAcode = '',
  202. currentAreaName = '';
  203. if (e.data && e.data.name) {
  204. /** 通过名称匹配 */
  205. for (let i = 0; i < mapJson.features.length; i++) {
  206. let p = mapJson.features[i].properties;
  207. if (p.name == e.data.name) {
  208. currentAcode = p.adcode.toString().substring(0, 4);
  209. currentAreaName = p.name;
  210. break;
  211. }
  212. }
  213. }
  214. if (this.currentTab != 3 && this.areaCode != currentAcode) {
  215. this.areaCode = currentAcode;
  216. this.currentAreaName = currentAreaName;
  217. this.areaSearch();
  218. } else if (this.currentTab != 3 && this.areaCode == currentAcode) {
  219. this.areaCode = '';
  220. this.currentAreaName = ''
  221. myChart.dispatchAction({
  222. type: 'downplay',
  223. seriesIndex: e.seriesIndex
  224. })
  225. this.areaSearch();
  226. }
  227. },
  228. tabChange(e) {
  229. this.currentTab = e.index;
  230. this.areaSearch();
  231. },
  232. scrolltolower() {
  233. this.loadmore()
  234. },
  235. loadmore() {
  236. this.page.current++;
  237. this.getList();
  238. },
  239. areaSearch() {
  240. this.page.current = 1;
  241. this.page.status = 'loadmore';
  242. this.list = [];
  243. this.getList();
  244. },
  245. doRefresh() {
  246. this.page.current = 1;
  247. this.page.status = 'loadmore';
  248. this.areaCode = '';
  249. this.list = [];
  250. this.getList();
  251. },
  252. getList() {
  253. if (this.page.status == 'loading' || this.page.status == 'nomore') {
  254. // 防止重复下拉
  255. return;
  256. }
  257. this.page.status = 'loading';
  258. //
  259. let listFunc, params = {};
  260. switch (this.currentTab) {
  261. case 0:
  262. listFunc = this.$u.api.getRestaurantList;
  263. params.name = this.keyword || '';
  264. params.regionId = this.areaCode || '';
  265. break;
  266. case 1:
  267. listFunc = this.$u.api.getDishList;
  268. params.name = this.keyword || '';
  269. params.regionId = this.areaCode || '';
  270. break;
  271. case 2:
  272. listFunc = this.$u.api.getSnacksList;
  273. params.name = this.keyword || '';
  274. params.regionId = this.areaCode || '';
  275. break;
  276. case 3:
  277. listFunc = this.$u.api.getProfessionalStyleList;
  278. params.title = this.keyword || '';
  279. break;
  280. default:
  281. return;
  282. break;
  283. }
  284. //
  285. listFunc(this.page.current, this.page.size, params).then(res => {
  286. if (res.data.records && res.data.records.length > 0) {
  287. this.list.push(...res.data.records)
  288. }
  289. this.page.total = res.data.total || 0;
  290. if (this.page.size * this.page.current >= res.data.total) {
  291. this.page.status = 'nomore'
  292. } else {
  293. this.page.status = 'loadmore'
  294. }
  295. })
  296. },
  297. toDetail(id) {
  298. switch (this.currentTab) {
  299. case 0:
  300. uni.navigateTo({
  301. url: "/pages/yuecai/restaurant/detail/index?id=" + id,
  302. })
  303. break;
  304. case 1:
  305. uni.navigateTo({
  306. url: "/pages/yuecai/dish/detail/index?id=" + id,
  307. })
  308. break;
  309. case 2:
  310. uni.navigateTo({
  311. url: "/pages/yuecai/snacks/detail/index?id=" + id,
  312. })
  313. break;
  314. case 3:
  315. uni.navigateTo({
  316. url: "/pages/yuecai/professional_style/detail/index?id=" + id,
  317. })
  318. break;
  319. default:
  320. return;
  321. break;
  322. }
  323. }
  324. },
  325. }
  326. </script>
  327. <style scoped lang="scss">
  328. .search-left-btn {
  329. width: 35px;
  330. min-width: 35px;
  331. height: 35px;
  332. margin-right: 5px;
  333. box-sizing: border-box;
  334. }
  335. .icon-circle {
  336. border-radius: 50%;
  337. border: 4rpx solid #65371b;
  338. display: flex;
  339. justify-content: center;
  340. align-items: center;
  341. }
  342. .area-title {
  343. width: calc(100% - 40px);
  344. margin: auto;
  345. display: flex;
  346. align-items: center;
  347. padding: 10px 0px;
  348. border-bottom: 2rpx solid #65371b;
  349. .area-title-text {
  350. margin-left: 10px;
  351. color: #65371b;
  352. }
  353. }
  354. .nav-btns {
  355. border-bottom: 1rpx solid #65371b;
  356. margin-bottom: 20rpx;
  357. padding-bottom: 50rpx;
  358. .nav-btn {
  359. width: 150rpx;
  360. .nav-btn-icon {
  361. margin: auto;
  362. width: 110rpx;
  363. height: 110rpx;
  364. }
  365. .nav-btn-text {
  366. width: 100%;
  367. color: #65371b;
  368. margin-top: 5rpx;
  369. font-weight: bolder;
  370. text-align: center;
  371. }
  372. }
  373. }
  374. .info-list {
  375. display: flex;
  376. flex-wrap: wrap;
  377. .info-item {
  378. padding: 20rpx;
  379. width: 33%;
  380. box-sizing: border-box;
  381. .info-pic {
  382. margin: auto;
  383. width: 175rpx;
  384. height: 175rpx;
  385. background: bisque;
  386. }
  387. .info-title {
  388. word-break: break-all;
  389. text-align: center;
  390. color: #65371b;
  391. font-size: 24rpx;
  392. font-weight: 300;
  393. line-height: 47rpx;
  394. word-spacing: 2rpx;
  395. overflow: hidden;
  396. text-overflow: -o-ellipsis-lastline;
  397. overflow: hidden;
  398. text-overflow: ellipsis;
  399. display: -webkit-box;
  400. -webkit-line-clamp: 1;
  401. line-clamp: 3;
  402. -webkit-box-orient: vertical;
  403. }
  404. }
  405. }
  406. </style>