index2.vue 8.2 KB

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