listitemB.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <view style="background-color: white;">
  3. <!-- <view class="titleview">{{$t('index.toplanmuT')}}</view> -->
  4. <view class="contentInRowS titleview">
  5. <text>美食分类</text>
  6. <text style="color:#40AE36;"> </text>
  7. </view>
  8. <scroll-view scroll-view scroll-x="true" >
  9. <view class="">
  10. <view class="item_list">
  11. <view v-for="(item, index) in fenleiLst">
  12. <view class="item_content" @click="fenleixuanz(item.id)">
  13. <netImage width="130" height="130" :mysrc="item.image" mymode="scaleToFill"></netImage>
  14. <!-- <image :src="item.image=='/static/logo.png'?item.image:baseUrl+item.image" mode="widthFix" @error="imageError(index)"></image> -->
  15. <view class="title">
  16. <text v-if="lgstate=='zh-Hant'">{{item.nameTw}}</text>
  17. <text v-if="lgstate=='zh-Hans'">{{item.name}}</text>
  18. <text v-if="lgstate=='yuenan'">{{item.nameVi}}</text>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </scroll-view>
  25. </view>
  26. </template>
  27. <script>
  28. import api from "@/pages/api/api.js";
  29. //import mendianfenleiData from '@/common/mendianfenlei.js';
  30. export default {
  31. data() {
  32. return {
  33. toptitle:"",
  34. baseUrl:this.$baseImagurl,
  35. fenleiLst:[],
  36. lgstate:''
  37. };
  38. },
  39. created() {
  40. this.getmendianfenlei();
  41. this.getMeishifenlei();
  42. },
  43. methods:{
  44. fenleixuanz(e){
  45. this.$emit('Efenleixuanze',e);
  46. },
  47. imageError(index){
  48. this.fenleiLst[index]['image'] = '/static/logo.png';//默认图片
  49. },
  50. getMeishifenlei(){
  51. this.lgstate = uni.getStorageSync('language');
  52. var that = this;
  53. api('listByTag',{
  54. tag:'food'
  55. },res=>{
  56. console.log('listByTag',res)
  57. if(res.data.code==200){
  58. that.fenleiLst=res.data.data;
  59. //console.log('1---------------',that.fenleiLst)
  60. }
  61. },failc=>{
  62. uni.showToast({
  63. title: that.$t('api.wangluoshibai'),
  64. icon: 'none',
  65. duration: 2500
  66. })
  67. })
  68. },
  69. getmendianfenlei(){
  70. this.lgstate = uni.getStorageSync('language');
  71. var that = this;
  72. api('getmendianfenlei',{
  73. pageSize:40
  74. },res=>{
  75. //console.log(res)
  76. if(res.data.code==200){
  77. that.fenleiLst=res.data.rows;
  78. //console.log('1---------------',that.fenleiLst)
  79. }
  80. },failc=>{
  81. uni.showToast({
  82. title: that.$t('api.wangluoshibai'),
  83. icon: 'none',
  84. duration: 2500
  85. })
  86. })
  87. },
  88. }
  89. }
  90. </script>
  91. <style lang="scss">
  92. @font-face {
  93. font-family: zrht;
  94. src: url('/uni_modules/font/zrht.otf');
  95. }
  96. .item_list{
  97. padding-left: 40rpx;
  98. display: flex;
  99. flex-direction: row;
  100. justify-content: flex-start;
  101. }
  102. .item_content{
  103. width: 150rpx;
  104. height: 220rpx;
  105. margin: 16rpx 0;
  106. padding: 14rpx;
  107. box-sizing: border-box;
  108. image{
  109. width: 130rpx;
  110. height:130rpx;
  111. background-color:whitesmoke;
  112. display: block;
  113. }
  114. .title{
  115. width: 100%;
  116. text-align: center;
  117. font-size: 24rpx;
  118. line-height: 30rpx;
  119. padding-top: 4rpx;
  120. }
  121. }
  122. .titleview{
  123. margin-left: 5%;
  124. width: 90%;
  125. padding-top: 22rpx;
  126. font-size: 30rpx;
  127. line-height: 46rpx;
  128. }
  129. </style>