index1.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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. series: [{
  58. name: 'GD',
  59. type: 'map',
  60. roam: true,
  61. // 缩放范围限制
  62. scaleLimit: {
  63. min: 1,
  64. max: 5
  65. },
  66. map: 'GD',
  67. emphasis: {
  68. label: {
  69. show: true
  70. }
  71. },
  72. data: []
  73. }],
  74. },
  75. //
  76. page: {
  77. current: 1,
  78. size: 15,
  79. total: 0,
  80. // loadmore loading nomore
  81. status: 'loadmore',
  82. loadingText: '正在加载中',
  83. loadmoreText: '上拉加载更多',
  84. nomoreText: '没有更多了'
  85. },
  86. keyword: '',
  87. areaCode: '',
  88. list: [],
  89. tabList: [{
  90. name: '名店',
  91. }, {
  92. name: '名菜'
  93. }, {
  94. name: '名点',
  95. }, {
  96. name: '专业风采'
  97. }],
  98. currentTab: 0
  99. }
  100. },
  101. onLoad(options) {},
  102. onShow() {
  103. uni.hideLoading()
  104. // this.doRefresh()
  105. },
  106. methods: {
  107. async init() {
  108. // chart 图表实例不能存在data里
  109. echarts.registerMap('GD', mapJson, {});
  110. const chart = await this.$refs.chart.init(echarts);
  111. chart.setOption(this.option)
  112. chart.on('click', this.clickMap);
  113. myChart = chart;
  114. },
  115. clickMap(e) {
  116. let currentAcode;
  117. if (e.dataIndex < 0) {
  118. currentAcode = '';
  119. } else {
  120. currentAcode = mapJson.features[e.dataIndex].properties.adcode;
  121. }
  122. if (this.currentTab != 3 && this.areaCode != currentAcode) {
  123. this.areaCode = currentAcode;
  124. this.areaSearch();
  125. }else if(this.currentTab != 3 && this.areaCode == currentAcode) {
  126. this.areaCode = '';
  127. myChart.dispatchAction({
  128. type: 'downplay',
  129. seriesIndex: e.seriesIndex
  130. })
  131. this.areaSearch();
  132. }
  133. },
  134. tabChange(e) {
  135. this.currentTab = e.index;
  136. this.doRefresh();
  137. },
  138. scrolltolower() {
  139. this.loadmore()
  140. },
  141. loadmore() {
  142. this.page.current++;
  143. this.getList();
  144. },
  145. areaSearch() {
  146. this.page.current = 1;
  147. this.page.status = 'loadmore';
  148. this.list = [];
  149. this.getList();
  150. },
  151. doRefresh() {
  152. this.page.current = 1;
  153. this.page.status = 'loadmore';
  154. this.areaCode = '';
  155. this.list = [];
  156. this.getList();
  157. },
  158. getList() {
  159. if (this.page.status == 'loading' || this.page.status == 'nomore') {
  160. // 防止重复下拉
  161. return;
  162. }
  163. this.page.status = 'loading';
  164. //
  165. let listFunc, params = {};
  166. switch (this.currentTab) {
  167. case 0:
  168. listFunc = this.$u.api.getRestaurantList;
  169. params.name = this.keyword || '';
  170. params.regionId = this.areaCode || '';
  171. break;
  172. case 1:
  173. listFunc = this.$u.api.getDishList;
  174. params.name = this.keyword || '';
  175. params.regionId = this.areaCode || '';
  176. break;
  177. case 2:
  178. listFunc = this.$u.api.getSnacksList;
  179. params.name = this.keyword || '';
  180. params.regionId = this.areaCode || '';
  181. break;
  182. case 3:
  183. listFunc = this.$u.api.getProfessionalStyleList;
  184. params.title = this.keyword || '';
  185. break;
  186. default:
  187. return;
  188. break;
  189. }
  190. //
  191. listFunc(this.page.current, this.page.size, params).then(res => {
  192. if (res.data.records && res.data.records.length > 0) {
  193. this.list.push(...res.data.records)
  194. }
  195. this.page.total = res.data.total || 0;
  196. if (this.page.size * this.page.current >= res.data.total) {
  197. this.page.status = 'nomore'
  198. } else {
  199. this.page.status = 'loadmore'
  200. }
  201. })
  202. },
  203. toDetail(id) {
  204. switch (this.currentTab) {
  205. case 0:
  206. uni.navigateTo({
  207. url: "/pages/yuecai/restaurant/detail/index?id=" + id,
  208. })
  209. break;
  210. case 1:
  211. uni.navigateTo({
  212. url: "/pages/yuecai/dish/detail/index?id=" + id,
  213. })
  214. break;
  215. case 2:
  216. uni.navigateTo({
  217. url: "/pages/yuecai/snacks/detail/index?id=" + id,
  218. })
  219. break;
  220. case 3:
  221. uni.navigateTo({
  222. url: "/pages/yuecai/professional_style/detail/index?id=" + id,
  223. })
  224. break;
  225. default:
  226. return;
  227. break;
  228. }
  229. }
  230. },
  231. }
  232. </script>
  233. <style scoped lang="scss">
  234. .search-left-btn {
  235. width: 35px;
  236. min-width: 35px;
  237. height: 35px;
  238. margin-right: 5px;
  239. box-sizing: border-box;
  240. }
  241. .icon-circle {
  242. border-radius: 50%;
  243. border: 4rpx solid #65371b;
  244. display: flex;
  245. justify-content: center;
  246. align-items: center;
  247. }
  248. .nav-btns {
  249. border-bottom: 1rpx solid #65371b;
  250. margin-bottom: 20rpx;
  251. padding-bottom: 50rpx;
  252. .nav-btn {
  253. width: 150rpx;
  254. .nav-btn-icon {
  255. margin: auto;
  256. width: 110rpx;
  257. height: 110rpx;
  258. }
  259. .nav-btn-text {
  260. width: 100%;
  261. color: #65371b;
  262. margin-top: 5rpx;
  263. font-weight: bolder;
  264. text-align: center;
  265. }
  266. }
  267. }
  268. .info-list {
  269. display: flex;
  270. flex-wrap: wrap;
  271. .info-item {
  272. padding: 20rpx;
  273. width: 33%;
  274. box-sizing: border-box;
  275. .info-pic {
  276. margin: auto;
  277. width: 175rpx;
  278. height: 175rpx;
  279. background: bisque;
  280. }
  281. .info-title {
  282. word-break: break-all;
  283. text-align: center;
  284. color: #65371b;
  285. font-size: 24rpx;
  286. font-weight: 300;
  287. line-height: 47rpx;
  288. word-spacing: 2rpx;
  289. overflow: hidden;
  290. text-overflow: -o-ellipsis-lastline;
  291. overflow: hidden;
  292. text-overflow: ellipsis;
  293. display: -webkit-box;
  294. -webkit-line-clamp: 1;
  295. line-clamp: 3;
  296. -webkit-box-orient: vertical;
  297. }
  298. }
  299. }
  300. </style>