index1.vue 11 KB

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