index2.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <template>
  2. <view>
  3. <view class="welcome" :style="{ marginTop: top + 'px' }">
  4. <image src="../../static/index.png" mode="widthFix" class="bq"></image>
  5. <view class="clear"></view>
  6. </view>
  7. <view class="top">
  8. <view class="wd">
  9. <view class="qw">{{ weather.tem }}°</view>
  10. <view class="xs">
  11. <view>{{ weather.wea }} {{ weather.win }} {{ weather.win_speed }}</view>
  12. <view>风速 {{ weather.win_meter }}</view>
  13. </view>
  14. </view>
  15. <view class="sos" @click="call()">
  16. <image src="../../static/qz.png" mode="widthFix" class="qiuzhu"></image>
  17. <view class="title">求助</view>
  18. </view>
  19. <image :src="ip + aboutUs.bgImg1" mode="scaleToFill" class="banner"></image>
  20. </view>
  21. <view class="page">
  22. <!--菜单-->
  23. <view class="flex menu">
  24. <view class="f" @click="navigate('/pages/travel/detail?id=43')">
  25. <image src="../../static/icon1.png" mode="widthFix" class="icon1"></image>
  26. <view class="title">谢通门介绍</view>
  27. </view>
  28. <view class="f" @click="navigate('/pages/travel/introduction')">
  29. <image src="../../static/icon2.png" mode="widthFix" class="icon1"></image>
  30. <view class="title">旅游攻略</view>
  31. </view>
  32. <view class="f" @click="navigate('/pages/government/activity')">
  33. <image src="../../static/icon3.png" mode="widthFix" class="icon1"></image>
  34. <view class="title">热门活动</view>
  35. </view>
  36. <view class="f" @click="navigate('/pages/government/index')">
  37. <image src="../../static/icon4.png" mode="widthFix" class="icon1"></image>
  38. <view class="title">党政服务</view>
  39. </view>
  40. </view>
  41. <!--图片-->
  42. <view class="flex mt15">
  43. <view class="f" style="padding-right:8px;"><image @click="detail(2)" :src="ip + aboutUs.bgImg3" mode="widthFix" class="tp"></image></view>
  44. <view class="f"><image @click="detail(3)" :src="ip + aboutUs.bgImg4" mode="widthFix" class="tp"></image></view>
  45. </view>
  46. <view style="margin-top: 10px;"><image @click="detail(4)" :src="ip + aboutUs.bgImg2" mode="widthFix" class="tp"></image></view>
  47. <!--热门景区-->
  48. <view class="item">
  49. <view class="lable">
  50. <view class="title">热门景区</view>
  51. <image src="../../static/lo2.png" mode="widthFix"></image>
  52. <view class="look" @click="tab('/pages/travel/index')">
  53. <text>更多</text>
  54. <text class="icon">&#xe62d;</text>
  55. </view>
  56. <view class="clear"></view>
  57. </view>
  58. <view class="rows">
  59. <view class="row" v-for="(item, index) in hot_list" :key="index" @click="detail(item)">
  60. <view class="out">
  61. <view class="int">
  62. <image :src="ip + item.showPictures" mode="aspectFill"></image>
  63. <view class="title omit">{{ item.title }}</view>
  64. </view>
  65. </view>
  66. </view>
  67. <view class="clear"></view>
  68. </view>
  69. </view>
  70. <!--攻略指南-->
  71. <view class="item" style="margin-top: 15px;">
  72. <view class="lable">
  73. <view class="title">攻略指南</view>
  74. <view class="look" @click="navigate('/pages/travel/introduction')">
  75. <text>更多</text>
  76. <text class="icon">&#xe62d;</text>
  77. </view>
  78. <view class="clear"></view>
  79. </view>
  80. <view class="card" v-for="(item, index) in zn_list" :key="index" @click="detail(item)">
  81. <image :src="ip + item.showPictures" mode="aspectFill"></image>
  82. <view class="cons">
  83. <view class="title omit">{{ item.title }}</view>
  84. <view class="desc omit">{{ item.briefContent }}</view>
  85. </view>
  86. </view>
  87. </view>
  88. <u-back-top :scroll-top="scrollTop"></u-back-top>
  89. <help ref="help"></help>
  90. </view>
  91. </view>
  92. </template>
  93. <script>
  94. import help from "../../components/help.vue";
  95. export default {
  96. components: {
  97. help
  98. },
  99. data() {
  100. return {
  101. ip: this.$http.urls.ip,
  102. top: 20,
  103. scrollTop: 0,
  104. hot_list: [],
  105. zn_list: [],
  106. aboutUs: {},
  107. weather: { tem: "0", wea: "晴", win: "北风", win_speed: "0级", win_meter: "0km/h" }
  108. };
  109. },
  110. onPageScroll(e) {
  111. this.scrollTop = e.scrollTop;
  112. },
  113. onLoad(e) {
  114. this.getData();
  115. this.getWeather();
  116. uni.getSystemInfo({
  117. success: res => {
  118. this.top = parseInt(res.safeArea.top) + 5;
  119. },
  120. fail(err) {
  121. console.error(err);
  122. }
  123. });
  124. },
  125. onReady() {
  126. uni.setNavigationBarColor({
  127. frontColor: "#000000",
  128. backgroundColor: "#f8f8f8",
  129. fail(e) {
  130. console.log("aaa:" + JSON.stringify(e));
  131. }
  132. });
  133. },
  134. methods: {
  135. getWeather() {
  136. //天气接口
  137. uni.request({
  138. url: this.$http.urls.weather,
  139. success: res => {
  140. if (!res.data.errcode) {
  141. this.weather = res.data;
  142. }
  143. }
  144. });
  145. },
  146. getData() {
  147. this.$http.request({
  148. url: this.$http.urls.home,
  149. success: res => {
  150. this.hot_list = res.data.data.hot_list;
  151. this.zn_list = res.data.data.zn_list;
  152. this.aboutUs = res.data.data.aboutUs;
  153. uni.setStorageSync("aboutUs", this.aboutUs);
  154. }
  155. });
  156. },
  157. tab(url) {
  158. uni.switchTab({
  159. url: url
  160. });
  161. },
  162. //详情
  163. detail(item) {
  164. if (item.contentId) {
  165. uni.navigateTo({ url: "/pages/travel/detail?id=" + item.contentId });
  166. } else {
  167. //根据后台的选择跳转id跳转到指定文章
  168. let id;
  169. if (item == 1) {
  170. id = this.$http.getParam(this.aboutUs.briefText1, "?");
  171. }
  172. if (item == 2) {
  173. id = this.$http.getParam(this.aboutUs.briefText2, "?");
  174. }
  175. if (item == 3) {
  176. id = this.$http.getParam(this.aboutUs.briefText3, "?");
  177. }
  178. if (item == 4) {
  179. id = this.$http.getParam(this.aboutUs.briefText4, "?");
  180. }
  181. uni.navigateTo({ url: "/pages/travel/detail?id=" + id });
  182. }
  183. },
  184. navigate(url) {
  185. uni.navigateTo({ url: url });
  186. },
  187. //拨打求助电话
  188. call() {
  189. this.$refs.help.init();
  190. }
  191. },
  192. //下拉刷新
  193. onPullDownRefresh() {
  194. setTimeout(() => {
  195. uni.stopPullDownRefresh();
  196. this.getData();
  197. }, 1000);
  198. }
  199. };
  200. </script>
  201. <style lang="scss">
  202. page {
  203. background-color: #f8f8f8;
  204. }
  205. .welcome {
  206. margin-top: 38px;
  207. padding-bottom: 5px;
  208. .icon {
  209. float: left;
  210. font-size: 27px;
  211. }
  212. .dw {
  213. float: left;
  214. width: 6.5%;
  215. height: 20px;
  216. margin: 3px 10px 0px 10px;
  217. }
  218. .bq {
  219. width: 45%;
  220. height: 34px;
  221. float: left;
  222. padding-left: 10px;
  223. }
  224. }
  225. .top {
  226. overflow: hidden;
  227. position: relative;
  228. .wd {
  229. position: absolute;
  230. top: 0px;
  231. left: 0px;
  232. width: 100%;
  233. padding-top: 10px;
  234. padding-left: 10px;
  235. z-index: 111111;
  236. color: #666666;
  237. background: linear-gradient(180deg, #ffffff 0%, rgba(255, 255, 255, 0.1) 100%);
  238. .qw {
  239. font-size: 25px;
  240. float: left;
  241. font-weight: bold;
  242. }
  243. .xs {
  244. margin-left: 45px;
  245. width: 100%;
  246. font-size: 13px;
  247. line-height: 20px;
  248. }
  249. }
  250. .sos {
  251. position: absolute;
  252. right: 10px;
  253. top: 10px;
  254. background: linear-gradient(180deg, #ffffff 0%, rgba(255, 255, 255, 0.3) 100%);
  255. padding: 10px 10px 15px 10px;
  256. color: white;
  257. font-size: 15px;
  258. text-align: center;
  259. font-weight: normal;
  260. border-radius: 30px;
  261. z-index: 111112;
  262. .qiuzhu {
  263. width: 115%;
  264. height: 34px;
  265. }
  266. .title {
  267. color: #333333;
  268. }
  269. }
  270. .banner {
  271. width: 100%;
  272. height: 200px;
  273. background-color: white;
  274. }
  275. }
  276. .page {
  277. padding: 10px;
  278. overflow-x: hidden;
  279. margin-top: -50px;
  280. position: relative;
  281. .tp {
  282. height: 88px;
  283. width: 100%;
  284. background-color: white;
  285. border-radius: 10px;
  286. }
  287. .item {
  288. margin-top: 15px;
  289. .lable {
  290. margin-bottom: 13px;
  291. .title {
  292. float: left;
  293. font-size: 20px;
  294. font-weight: bold;
  295. color: #333;
  296. }
  297. image {
  298. float: left;
  299. width: 25%;
  300. margin-top: -3px;
  301. }
  302. .look {
  303. color: #999999;
  304. float: right;
  305. font-size: 15px;
  306. }
  307. }
  308. .rows {
  309. margin-left: -5px;
  310. margin-right: -5px;
  311. .row {
  312. float: left;
  313. width: 33.333%;
  314. overflow: hidden;
  315. height: 150px;
  316. .out {
  317. padding: 0px 3px 0px 3px;
  318. .int {
  319. position: relative;
  320. image {
  321. border-radius: 10px;
  322. height: 150px;
  323. width: 100%;
  324. background-color: white;
  325. }
  326. .title {
  327. position: absolute;
  328. bottom: 13px;
  329. left: 10px;
  330. width: 85%;
  331. color: white;
  332. font-size: 15px;
  333. font-weight: 400;
  334. }
  335. }
  336. }
  337. }
  338. }
  339. .card {
  340. background-color: white;
  341. overflow: hidden;
  342. border-radius: 10px;
  343. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.03);
  344. image {
  345. width: 100%;
  346. height: 150px;
  347. }
  348. .cons {
  349. padding: 12px;
  350. .title {
  351. color: #333333;
  352. font-weight: bold;
  353. font-size: 17px;
  354. }
  355. .desc {
  356. font-size: 14px;
  357. color: #999999;
  358. margin-top: 8px;
  359. }
  360. }
  361. }
  362. }
  363. }
  364. </style>