appitem.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <view>
  3. <u-swiper v-if="swiperlist.length>0" class="swiperstyle"
  4. :list="swiperlist"
  5. indicatorMode="line"
  6. circular
  7. indicator
  8. keyName="fileUrl"
  9. @click="LinktoDetails"
  10. ></u-swiper>
  11. <view class="btnList">
  12. <view @click="changeType(index)"
  13. :class="item.plain ?'btnview': 'checkbtnview'"
  14. v-for="(item,index) in btnList" :key="index">
  15. {{ item.name }}
  16. </view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import {carouselList} from '@/http/api/common.js'
  22. export default {
  23. props: {
  24. listdata: {
  25. type: Object,
  26. default: '',
  27. },
  28. openType:{
  29. type: String,
  30. default: '1',
  31. },
  32. curNowdata:{
  33. type:Object
  34. },
  35. current:{
  36. type:Number,
  37. default:0
  38. },
  39. },
  40. watch:{
  41. listdata: {
  42. immediate: true,
  43. handler(val) {
  44. console.log('vassss',val);
  45. this.btnList = val.columnMenuSubList
  46. if (val?.id) {
  47. this.getCarouselList(val.id)
  48. }
  49. },
  50. },
  51. current: {
  52. immediate: true,
  53. handler(val) {
  54. //获取轮播图
  55. // this.getCarouselList()
  56. },
  57. },
  58. },
  59. data() {
  60. return {
  61. swiperlist:[],
  62. btnList:[]
  63. }
  64. },
  65. components: {
  66. // appitem,
  67. },
  68. onLoad(e) {
  69. },
  70. methods: {
  71. async getCarouselList(id){
  72. //获取轮播图
  73. let res = await carouselList({
  74. modules:'2',
  75. modulesColumnId:id
  76. })
  77. if (res.data.code == 200) {
  78. let data = res.data.data.rows
  79. this.swiperlist = data.map(v => {
  80. return {
  81. ...v,
  82. fileUrl:v.carouselUrlList[0].fileUrl
  83. }
  84. })
  85. }
  86. },
  87. changeType(index) {
  88. if (this.btnList[index].name == '互动天地') {
  89. uni.navigateTo({
  90. url: '/pages/home/exchange'
  91. });
  92. return
  93. }
  94. this.btnList.forEach(item => {
  95. item.plain = true
  96. });
  97. this.btnList[index].plain = false
  98. let curNowdata = uni.getStorageSync('curNowdata')
  99. if (curNowdata&&curNowdata!='') {
  100. curNowdata = JSON.parse(curNowdata)
  101. curNowdata['curNowsubid'] = this.btnList[index].id
  102. uni.setStorageSync('curNowdata',JSON.stringify(curNowdata) );
  103. }
  104. if (this.openType == 'commodity') {
  105. //从商场页过来的 选类型 不做跳转
  106. }else{
  107. uni.switchTab({
  108. url: '/pages/home/Information',
  109. });
  110. }
  111. },
  112. LinktoDetails(e){
  113. console.log('第',e,this.swiperlist[e]);
  114. if (this.swiperlist[e] && this.swiperlist[e]?.targetType == '2') {
  115. // 2=文章;
  116. // columnId 菜单栏目id/商品大类
  117. // subId 子栏目id/商品子类
  118. // articleId 文章id/商品id
  119. if (this.swiperlist[e]?.articleId) {
  120. uni.navigateTo({
  121. url: '/pages/home/ArticleDetails?id=' + this.swiperlist[e]?.articleId
  122. });
  123. }
  124. }else if(this.swiperlist[e] && this.swiperlist[e]?.targetType == '3'){
  125. // 3=商品;
  126. if (this.swiperlist[e]?.articleId) {
  127. uni.navigateTo({
  128. url: '/pages/market/ProductDetails?id=' + this.swiperlist[e]?.articleId
  129. });
  130. }
  131. }else{
  132. //跳转方式1=栏目;
  133. uni.switchTab({
  134. url: '/pages/home/Information',
  135. });
  136. }
  137. },
  138. }
  139. }
  140. </script>
  141. <style lang="scss">
  142. .btnList{
  143. display: flex;
  144. flex-direction: row;
  145. flex-wrap: wrap;
  146. justify-content: flex-start;
  147. }
  148. .swiperstyle{
  149. width: 436rpx;
  150. height: 187rpx;
  151. }
  152. .checkbtnview{
  153. width: 206rpx;
  154. height: 80rpx;
  155. background: #46A6FF;
  156. border-radius: 40rpx 40rpx 40rpx 40rpx;
  157. opacity: 1;
  158. font-size: 28rpx;
  159. font-weight: 400;
  160. color: #FFFFFF;
  161. line-height: 80rpx;
  162. text-align: center;
  163. margin: 20rpx;
  164. }
  165. .btnview{
  166. width: 206rpx;
  167. height: 80rpx;
  168. background: #F1F1F1;
  169. border-radius: 40rpx 40rpx 40rpx 40rpx;
  170. opacity: 1;
  171. font-size: 28rpx;
  172. font-weight: 400;
  173. color: #666;
  174. line-height: 80rpx;
  175. text-align: center;
  176. margin: 20rpx;
  177. }
  178. </style>