shoptype.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <view class="">
  3. <zhSlidingMenu ref='zhSlidingMenu' :tabbar='list' :scrollH="scrollH">
  4. <template #default="{scroll_list}">
  5. <view class="goods">
  6. <view class="goods_item" v-for="(item, index) in scroll_list" :key="index"
  7. @click="clickGoods(item)">
  8. <image class="goods_item_img" :src="item.image" mode=""></image>
  9. <view class="goods_item_name" v-if="language =='zh-CN'">
  10. {{item.name_cn}}
  11. </view>
  12. <view class="goods_item_name" v-if="language =='en-US'">
  13. {{item.name_en}}
  14. </view>
  15. <view class="goods_item_name" v-if="language =='es-ES'">
  16. {{item.name_es}}
  17. </view>
  18. <view class="goods_item_name" v-if="language =='it-IT'">
  19. {{item.name_ita}}
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. </zhSlidingMenu>
  25. </view>
  26. </template>
  27. <script>
  28. import zhSlidingMenu from '@/components/zh-slidingMenu/zhSlidingMenu/zhSlidingMenu.vue'
  29. export default {
  30. components: {
  31. zhSlidingMenu
  32. },
  33. data() {
  34. return {
  35. scrollH: 0, //scroll高度
  36. // list: [{
  37. // name: "女装",
  38. // children: [{
  39. // name: "A字裙",
  40. // icon: "https://cdn.uviewui.com/uview/common/classify/1/1.jpg",
  41. // },
  42. // {
  43. // name: "礼服/婚纱",
  44. // icon: "https://cdn.uviewui.com/uview/common/classify/1/14.jpg",
  45. // }
  46. // ]
  47. // },
  48. // {
  49. // name: "美食",
  50. // children: [{
  51. // name: "火锅",
  52. // icon: "https://cdn.uviewui.com/uview/common/classify/2/1.jpg",
  53. // },
  54. // {
  55. // name: "精品茗茶",
  56. // icon: "https://cdn.uviewui.com/uview/common/classify/2/7.jpg",
  57. // },
  58. // {
  59. // name: "休闲食品",
  60. // icon: "https://cdn.uviewui.com/uview/common/classify/2/8.jpg",
  61. // },
  62. // ]
  63. // },
  64. // {
  65. // name: "美妆",
  66. // children: [{
  67. // name: "化妆刷",
  68. // icon: "https://cdn.uviewui.com/uview/common/classify/3/1.jpg",
  69. // },
  70. // {
  71. // name: "防晒品",
  72. // icon: "https://cdn.uviewui.com/uview/common/classify/3/14.jpg",
  73. // },
  74. // {
  75. // name: "美甲",
  76. // icon: "https://cdn.uviewui.com/uview/common/classify/3/15.jpg",
  77. // }
  78. // ]
  79. // }
  80. // ],
  81. language: '',
  82. list:[]
  83. }
  84. },
  85. onLoad() {
  86. uni.getSystemInfo({
  87. success: (res) => {
  88. this.scrollH = res.windowHeight
  89. }
  90. });
  91. },
  92. computed: {
  93. i18n() {
  94. return this.$t('index')
  95. }
  96. },
  97. onShow() {
  98. uni.setNavigationBarTitle({
  99. title: this.i18n.classification
  100. })
  101. this.category() //商品分类
  102. if (uni.getStorageSync('language') != '') {
  103. this.language = uni.getStorageSync('language')
  104. }
  105. },
  106. methods: {
  107. clickGoods(item) { //点击商品
  108. console.log(item);
  109. if (this.language == 'en-US') {
  110. uni.navigateTo({
  111. url: '/pageA/shoplist?id=' + item.id + '&title=' + item.name_en + '&parent_id=' + item
  112. .parent_id
  113. })
  114. }
  115. if (this.language == 'es-ES') {
  116. uni.navigateTo({
  117. url: '/pageA/shoplist?id=' + item.id + '&title=' + item.name_es + '&parent_id=' + item
  118. .parent_id
  119. })
  120. }
  121. if (this.language == 'it-IT') {
  122. uni.navigateTo({
  123. url: '/pageA/shoplist?id=' + item.id + '&title=' + item.name_ita + '&parent_id=' + item
  124. .parent_id
  125. })
  126. }
  127. if (this.language == 'zh-CN') {
  128. uni.navigateTo({
  129. url: '/pageA/shoplist?id=' + item.id + '&title=' + item.name_cn + '&parent_id=' + item
  130. .parent_id
  131. })
  132. }
  133. },
  134. //商品分类列表
  135. category() {
  136. uni.$u.http.get('/api/goods/category', {
  137. params: {
  138. parent_id: 0
  139. }
  140. }).then((res) => {
  141. const categoryArr = res
  142. if (this.language == 'en-US') {
  143. categoryArr.forEach(item => {
  144. item.name = item.name_en
  145. })
  146. }
  147. if (this.language == 'es-ES') {
  148. categoryArr.forEach(item => {
  149. item.name = item.name_es
  150. })
  151. }
  152. if (this.language == 'it-IT') {
  153. categoryArr.forEach(item => {
  154. item.name = item.name_ita
  155. })
  156. }
  157. if (this.language == 'zh-CN') {
  158. categoryArr.forEach(item => {
  159. item.name = item.name_cn
  160. })
  161. }
  162. this.list = categoryArr
  163. console.log(categoryArr);
  164. }).catch(() => {
  165. })
  166. },
  167. },
  168. }
  169. </script>
  170. <style lang="scss" scoped>
  171. .goods {
  172. display: flex;
  173. flex-wrap: wrap;
  174. .goods_item {
  175. width: 33.3%;
  176. display: flex;
  177. align-items: center;
  178. justify-content: center;
  179. flex-direction: column;
  180. margin-top: 20rpx;
  181. .goods_item_img {
  182. width: 120rpx;
  183. height: 120rpx;
  184. }
  185. .goods_item_name {
  186. color: #333;
  187. font-size: 28rpx;
  188. font-weight: 500rpx;
  189. display: -webkit-box;
  190. -webkit-box-orient: vertical;
  191. -webkit-line-clamp: 1;
  192. overflow: hidden;
  193. word-break: break-all;
  194. text-align: center;
  195. }
  196. }
  197. }
  198. </style>