index1.vue 10 KB

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