index1.vue 11 KB

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