head.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <view>
  3. <view class="bg">
  4. <view class="search" style="margin-top: 10rpx;">
  5. <u-search bgColor='#fff' placeholder="请输入关键词"
  6. :showAction='false'
  7. @custom="Linkto('Information')" @click="Linkto('Information')"
  8. :disabled='true' v-model="searchword"></u-search>
  9. <view class="searchBtn">搜索</view>
  10. </view>
  11. <view class="margintb w700" >
  12. <u-tabs keyName='subIdName'
  13. :activeStyle="{
  14. color:'#000',
  15. fontSize: '42rpx',
  16. transform: 'scale(1.05)'
  17. }"
  18. @click="clicktabs" :list="list1"></u-tabs>
  19. </view>
  20. <view class="swiperstyle">
  21. <u-swiper
  22. style="width:702rpx"
  23. height="300rpx"
  24. :list="swiperlist"
  25. indicatorMode="line"
  26. circular
  27. indicator
  28. keyName="fileUrl"
  29. @click="LinktoDetails"
  30. ></u-swiper>
  31. </view>
  32. </view>
  33. <view v-if="showNoticeBar" class="margintop40 w750 flexjc" >
  34. <view class="noticeBar">
  35. <view class="noticeBar_1">
  36. <u--image width="40rpx" height="40rpx" src="/static/index/btn_xiaox.png" ></u--image>
  37. 最新消息
  38. </view>
  39. <view @click="openDetails" class="noticeBar_2">
  40. {{noticeDetails.title}}
  41. </view>
  42. <view>
  43. <u--image @click="showNoticeBar = false" width="40rpx" height="40rpx" src="/static/index/icomx_sahnchu1.png" ></u--image>
  44. </view>
  45. </view>
  46. <!-- <u-notice-bar :url="'/pages/myinfo/notifiesPageDetails?id=' + noticeDetails.id" :text="noticeDetails.title" mode="closable"></u-notice-bar> -->
  47. </view>
  48. <view class="menus">
  49. <view @click="clicktabs(item)" v-for="item in menuslist" :key="item.id">
  50. <view class="menus_item">
  51. <u--image width="80rpx" height="80rpx" :src="item.imgUrl" ></u--image>
  52. <view style="margin-top: 16rpx;">{{item.subIdName}}</view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. import {carouselList,moduleByOne,moduleByTwo,notifiesPage} from '@/http/api/common.js'
  60. export default {
  61. data() {
  62. return {
  63. list1:[
  64. {
  65. subIdName: '推荐',
  66. }
  67. ],
  68. swiperlist:[],
  69. searchword:'',
  70. noticebarmsg: '测试公告测试公告测试公告测试公告',
  71. menuslist:[],
  72. noticeDetails:{
  73. title:''
  74. },
  75. actionStyle:{
  76. width:'100rpx',
  77. color:'#333'
  78. },
  79. inputStyle:{
  80. width:'300rpx'
  81. },
  82. showNoticeBar:true
  83. }
  84. },
  85. async mounted() {
  86. this.getCarouselList()
  87. this.getmoduleByOne()
  88. this.getmoduleByTwo()
  89. this.getnotifiesPage()
  90. },
  91. methods: {
  92. async getnotifiesPage(){
  93. let res = await notifiesPage({
  94. pageSize:1,
  95. pageNum:1,
  96. })
  97. if (res.data.code == 200) {
  98. this.noticeDetails = res.data.data?.rows[0]
  99. }
  100. },
  101. openDetails(){
  102. uni.navigateTo({
  103. url: '/pages/myinfo/notifiesPageDetails?id=' + this.noticeDetails.id
  104. });
  105. },
  106. Linkto(key){
  107. uni.switchTab({
  108. url: '/pages/home/Information',
  109. });
  110. },
  111. LinktoDetails(e){
  112. console.log('第',e,this.swiperlist[e]);
  113. if (this.swiperlist[e] && this.swiperlist[e]?.targetType == '2') {
  114. // 2=文章;
  115. // columnId 菜单栏目id/商品大类
  116. // subId 子栏目id/商品子类
  117. // articleId 文章id/商品id
  118. if (this.swiperlist[e]?.articleId) {
  119. uni.navigateTo({
  120. url: '/pages/home/ArticleDetails?id=' + this.swiperlist[e]?.articleId
  121. });
  122. }
  123. }else if(this.swiperlist[e] && this.swiperlist[e]?.targetType == '3'){
  124. // 3=商品;
  125. if (this.swiperlist[e]?.articleId) {
  126. uni.navigateTo({
  127. url: '/pages/market/ProductDetails?id=' + this.swiperlist[e]?.articleId
  128. });
  129. }
  130. }else{
  131. //跳转方式1=栏目;
  132. uni.switchTab({
  133. url: '/pages/home/Information',
  134. });
  135. }
  136. },
  137. async getCarouselList(){
  138. //获取轮播图
  139. let res = await carouselList({
  140. modules:'1'
  141. })
  142. if (res.data.code == 200) {
  143. let data = res.data.data.rows
  144. this.swiperlist = data.map(v => {
  145. return {
  146. ...v,
  147. fileUrl:v.carouselUrlList[0].fileUrl
  148. }
  149. })
  150. }
  151. },
  152. async getmoduleByOne(){
  153. //获取模块1
  154. let res = await moduleByOne()
  155. if (res.data.code == 200) {
  156. this.list1 = [
  157. {
  158. subIdName: res.data.data.title,
  159. }
  160. ]
  161. this.list1 = [
  162. ...this.list1,
  163. ...res.data.data.subList
  164. ]
  165. }
  166. },
  167. async getmoduleByTwo(){
  168. //获取模块1
  169. let res = await moduleByTwo()
  170. this.menuslist = []
  171. if (res.data.code == 200) {
  172. this.menuslist = res.data.data.subList.map(v =>{
  173. return {
  174. ...v,
  175. imgUrl:v.coverList[0].fileUrl
  176. }
  177. })
  178. }
  179. },
  180. clicktabs(item){
  181. if (item.subIdName != '推荐') {
  182. let data = {
  183. curNowid:item.columnId,
  184. curNowsubid:item.subId,
  185. }
  186. uni.setStorageSync('curNowdata',JSON.stringify(data) );
  187. uni.switchTab({
  188. url: '/pages/home/Information',
  189. });
  190. }
  191. }
  192. }
  193. }
  194. </script>
  195. <style>
  196. .w700{
  197. width: 702rpx;
  198. }
  199. .content {
  200. display: flex;
  201. flex-direction: column;
  202. align-items: center;
  203. justify-content: center;
  204. }
  205. .bg{
  206. display: flex;
  207. flex-direction: column;
  208. align-items: center;
  209. justify-content: center;
  210. background: linear-gradient(180deg, #A3D1FC 0%, #FFFFFF 50%);
  211. opacity: 1;
  212. width: 750rpx;
  213. }
  214. .u-notice-bar{
  215. width: 702rpx !important;
  216. height: 40rpx !important;
  217. background: #FFFFFF;
  218. margin: 0 auto !important;
  219. }
  220. /* .u-search{
  221. width: 702rpx !important;
  222. height: 80rpx !important;
  223. } */
  224. .margintb{
  225. margin: 16rpx 0;
  226. }
  227. .margintop40{
  228. margin-top: 40rpx;
  229. }
  230. .menus_item{
  231. display: flex;
  232. flex-direction: column;
  233. align-items: center;
  234. font-size: 28rpx;
  235. font-weight: 400;
  236. color: #333333;
  237. line-height: 45rpx;
  238. }
  239. .menus{
  240. padding-bottom: 20rpx;
  241. display: flex;
  242. justify-content: space-around;
  243. width: 90vw;
  244. margin: 0 auto;
  245. margin-top: 40rpx;
  246. }
  247. .swiperstyle{
  248. width: 702rpx;
  249. height: 300rpx;
  250. box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.1);
  251. border-radius: 16rpx;
  252. }
  253. .noticeBar{
  254. width: 702rpx;
  255. height: 90rpx;
  256. background: linear-gradient(90deg, #FFF4E5 0%, #FFFFFF 100%);
  257. border-radius: 8rpx 8rpx 8rpx 8rpx;
  258. opacity: 1;
  259. display: flex;
  260. align-items: center;
  261. }
  262. .noticeBar_1{
  263. width: 216rpx;
  264. display: flex;
  265. font-size: 28rpx;
  266. font-weight: bold;
  267. color: #000000;
  268. justify-content: space-evenly;
  269. align-items: center;
  270. border-right: 1rpx solid #ccc;
  271. }
  272. .noticeBar_2{
  273. margin-left: 16rpx;
  274. width: 430rpx;
  275. font-size: 28rpx;
  276. font-weight: bold;
  277. color: #000000;
  278. overflow: hidden;
  279. text-overflow: ellipsis;
  280. white-space: nowrap;
  281. }
  282. </style>