index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <div class="My">
  3. <!-- 输入框 -->
  4. <div class="inputBox" @keydown.enter="searchFu()">
  5. <div class="searInco">
  6. <van-icon name="search" />
  7. </div>
  8. <div class="searBtn" @click="searchFu()">搜索</div>
  9. <van-field
  10. maxlength="10"
  11. v-model="txt"
  12. placeholder="输入您感兴趣的内容"
  13. />
  14. </div>
  15. <!-- 精彩必体验 -->
  16. <div class="titleTit">精彩必体验</div>
  17. <div class="bsBox">
  18. <div v-for="item in bsData" :key="item.id">{{ item.name }}</div>
  19. </div>
  20. <!-- 主体内容 -->
  21. <div class="mainBoxNull" v-if="dataShow.length === 0">暂无内容</div>
  22. <div class="mainBox" v-else>
  23. <div
  24. class="row"
  25. @click="$router.push('/layout/interact/info')"
  26. v-for="item in dataShow"
  27. :key="item.id"
  28. >
  29. <img :src="require(`@/assets/img/interact/row${item.id}.png`)" alt="" />
  30. <div class="name">{{ item.name }}</div>
  31. <div class="author">
  32. <div class="author_ll">
  33. <img src="../../assets/img/interact/user.png" alt="" />
  34. <span>{{ item.author }}</span>
  35. </div>
  36. <div class="author_rr">{{ item.time }}</div>
  37. </div>
  38. </div>
  39. </div>
  40. <!-- +号 -->
  41. <div class="issue">
  42. <img
  43. src="../../assets/img/interact/issue.png"
  44. alt=""
  45. @click="addInteract"
  46. />
  47. </div>
  48. </div>
  49. </template>
  50. <script>
  51. export default {
  52. components: {},
  53. data() {
  54. return {
  55. txt: "",
  56. bsData: [
  57. { id: 1, name: "梦幻游乐王国" },
  58. { id: 2, name: "古建筑" },
  59. { id: 3, name: "美食" },
  60. { id: 4, name: "周边风景游玩" },
  61. { id: 5, name: "美景" },
  62. ],
  63. spotData: [
  64. {
  65. id: 1,
  66. name: "方特梦幻王国万圣夜",
  67. author: "王大锤",
  68. time: "2022-11-16",
  69. },
  70. { id: 2, name: "芜湖老海关", author: "孔连顺", time: "2022-11-16" },
  71. { id: 3, name: "中江塔", author: "子墨", time: "2022-11-16" },
  72. { id: 4, name: "鸠兹古镇", author: "张本钰", time: "2022-11-16" },
  73. ],
  74. dataShow: [],
  75. };
  76. },
  77. computed: {},
  78. watch: {},
  79. methods: {
  80. // 点击+号
  81. addInteract() {
  82. this.$router.push("/layout/interact/issue");
  83. // let code = this.getQueryString("code");
  84. // if (code) this.$router.push("/layout/interact/issue");
  85. // else {
  86. // //此处的ID是在文档的开发-基本配置里面
  87. // let appid = "wx779dbafb46bab697";
  88. // let url = "http://192.168.20.48:8080/#/layout/interact";
  89. // window.location.href =
  90. // "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" +
  91. // appid +
  92. // "&redirect_uri=" +
  93. // url +
  94. // "&response_type=code&scope=snsapi_userinfo&state=bc17befd6d5060f16de95e38f6eaf69c&connect_redirect=1#wechat_redirect";
  95. // }
  96. },
  97. searchFu() {
  98. this.getList();
  99. },
  100. // 获取列表的方法
  101. getList() {
  102. if (this.txt.trim() === "") this.dataShow = this.spotData;
  103. else
  104. this.dataShow = this.spotData.filter((v) => v.name.includes(this.txt));
  105. },
  106. // 获取地址栏参数的方法
  107. getQueryString(name) {
  108. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  109. var r = window.location.search.substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配
  110. var context = "";
  111. if (r != null) context = r[2];
  112. reg = null;
  113. r = null;
  114. return context == null || context == "" || context == "undefined"
  115. ? ""
  116. : context;
  117. },
  118. },
  119. created() {
  120. document.querySelector("#app").style.maxWidth = "500px";
  121. this.getList();
  122. let code = this.getQueryString("code");
  123. console.log("---------", code);
  124. },
  125. mounted() {},
  126. beforeCreate() {}, //生命周期 - 创建之前
  127. beforeMount() {}, //生命周期 - 挂载之前
  128. beforeUpdate() {}, //生命周期 - 更新之前
  129. updated() {}, //生命周期 - 更新之后
  130. beforeDestroy() {}, //生命周期 - 销毁之前
  131. destroyed() {}, //生命周期 - 销毁完成
  132. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  133. };
  134. </script>
  135. <style lang='less' scoped>
  136. .My {
  137. width: 100%;
  138. height: calc(100% - 80px);
  139. overflow-y: auto;
  140. padding: 20px 15px;
  141. position: relative;
  142. .issue {
  143. margin: 20px 0;
  144. text-align: center;
  145. & > img {
  146. width: 40px;
  147. }
  148. }
  149. .inputBox {
  150. margin: 0px auto;
  151. width: 100%;
  152. height: 30px;
  153. position: relative;
  154. .searBtn {
  155. position: absolute;
  156. right: 0;
  157. top: 0;
  158. width: 40px;
  159. height: 30px;
  160. border-radius: 3px;
  161. z-index: 2;
  162. background-color: #fe6e69;
  163. font-size: 14px;
  164. color: #fff;
  165. line-height: 30px;
  166. text-align: center;
  167. }
  168. .searInco {
  169. color: #a0a0a0;
  170. display: flex;
  171. justify-content: center;
  172. align-items: center;
  173. font-size: 16px;
  174. position: absolute;
  175. top: 0;
  176. left: 10px;
  177. z-index: 3;
  178. width: 20px;
  179. height: 30px;
  180. }
  181. /deep/.van-cell {
  182. width: 100%;
  183. height: 30px;
  184. line-height: 30px;
  185. padding: 0px 0 0px 36px;
  186. background-color: #f4f4f4;
  187. border-radius: 5px;
  188. }
  189. }
  190. .titleTit {
  191. font-size: 16px;
  192. font-weight: 700;
  193. margin: 15px 0;
  194. color: #000000;
  195. }
  196. .bsBox {
  197. display: flex;
  198. flex-wrap: wrap;
  199. & > div {
  200. text-align: center;
  201. min-width: 60px;
  202. padding: 0 5px;
  203. height: 30px;
  204. line-height: 30px;
  205. border-radius: 2px;
  206. background-color: #f4f4f4;
  207. margin: 0 15px 15px 0;
  208. font-size: 12px;
  209. color: #333333;
  210. }
  211. }
  212. .mainBoxNull {
  213. width: 100%;
  214. height: 300px;
  215. display: flex;
  216. justify-content: center;
  217. align-items: center;
  218. font-size: 16px;
  219. }
  220. .mainBox {
  221. display: flex;
  222. flex-wrap: wrap;
  223. .row {
  224. margin-right: 4%;
  225. margin-bottom: 4%;
  226. overflow: hidden;
  227. width: 48%;
  228. height: 260px;
  229. background-color: #f7f8fa;
  230. border-radius: 4px;
  231. color: #333333;
  232. &:nth-of-type(2n) {
  233. margin-right: 0;
  234. }
  235. & > img {
  236. width: 100%;
  237. height: 180px;
  238. object-fit: cover;
  239. }
  240. .name {
  241. padding: 10px 10px 5px;
  242. font-size: 14px;
  243. font-weight: 700;
  244. }
  245. .author {
  246. margin-top: 12px;
  247. padding: 0 10px;
  248. display: flex;
  249. align-items: center;
  250. justify-content: space-between;
  251. font-size: 12px;
  252. .author_ll {
  253. vertical-align: middle;
  254. & > img {
  255. margin-right: 5px;
  256. width: 12px;
  257. height: 12px;
  258. border-radius: 50%;
  259. }
  260. }
  261. }
  262. }
  263. }
  264. }
  265. </style>