shopping.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <!-- 十元购 -->
  3. <view style="position: relative;">
  4. <view class="back" style="z-index: -1;">
  5. </view>
  6. <u-navbar bgColor="#FE2E2E" :safeAreaInsetTop="true" :placeholder='true'>
  7. <view class="u-nav-slot" slot="left">
  8. <image v-if="language =='zh-CN'" src="../../static/shopping/title.png" style="width: 390rpx;height: 48rpx;" mode=""></image>
  9. <image v-else src="../../static/shopping/title1.png" style="width: 390rpx;height: 48rpx;" mode=""></image>
  10. </view>
  11. </u-navbar>
  12. <view class="input u-flex u-row-between" style="margin-top: 16rpx;">
  13. <view class="u-flex">
  14. <image src="../../static/shopping/search.png" style="width: 32rpx;height: 32rpx;" mode=""></image>
  15. <input v-model="keyword" type="text" placeholder="请输入商品名称搜索"
  16. style="width: 500rpx;margin-left: 14rpx;" />
  17. </view>
  18. <view class="search" @click="search">搜索</view>
  19. </view>
  20. <view class="content">
  21. <view class="">
  22. <!-- <u-tabs lineColor="#f56c6c" :activeStyle="{
  23. color: 'rgba(248, 53, 39, 1)',
  24. fontWeight: 'bold',
  25. transform: 'scale(1.05)'
  26. }" :list="list1" @click="click"></u-tabs> -->
  27. <u-tabs :activeStyle="{
  28. color: 'rgba(248, 53, 39, 1)',
  29. fontWeight: 'bold',
  30. transform: 'scale(1.05)'
  31. }" :list="list1" lineColor='rgba(248, 53, 39, 1)' @change='changetab'></u-tabs>
  32. </view>
  33. <view class="u-flex u-row-between" style="margin-top: 24rpx;flex-wrap: wrap;">
  34. <view @click="todetail(item.id)" class="item" v-for="(item,idx) in list" :key="idx" style="margin-bottom: 20rpx;">
  35. <image :src="item.goods.image" style="width: 340rpx;height: 340rpx;" mode=""></image>
  36. <view class="" style="padding: 20rpx;box-sizing: border-box;">
  37. <!-- <text class="title">可心柔 V9系列婴儿保wadhbiuawd</text> -->
  38. <text class="titl" v-if="language =='zh-CN'">
  39. {{item.goods.name_cn}}
  40. </text>
  41. <view class="titl" v-if="language =='en-US'">
  42. {{item.goods.name_en}}
  43. </view>
  44. <view class="titl" v-if="language =='es-ES'">
  45. {{item.goods.name_es}}
  46. </view>
  47. <view class="titl" v-if="language =='it-IT'">
  48. {{item.goods.name_ita}}
  49. </view>
  50. <view class="u-flex" style="margin-top: 12rpx;flex-wrap: wrap;column-gap: 12rpx;">
  51. <view class="tabsa" v-for="(child,idx) in item.goods.label_arr" :key="idx">
  52. <text class="titl" v-if="language =='zh-CN'">
  53. {{child.name_cn}}
  54. </text>
  55. <view class="titl" v-if="language =='en-US'">
  56. {{child.name_en}}
  57. </view>
  58. <view class="titl" v-if="language =='es-ES'">
  59. {{child.name_es}}
  60. </view>
  61. <view class="titl" v-if="language =='it-IT'">
  62. {{child.name_ita}}
  63. </view>
  64. </view>
  65. </view>
  66. <view class="num">
  67. {{i18n.Soldout}}{{item.goods.sale_num}}{{i18n.piece}}
  68. </view>
  69. <view class="" style="margin-top: 16rpx;position: relative;">
  70. <image src="/static/shopping/btn.png"
  71. style="width: 300rpx;height: 68rpx;position: absolute;top:0;left:0;" mode=""></image>
  72. <view class="u-flex u-row-between"
  73. style="padding:10rpx 20rpx 0 26rpx;width: 85%;position: relative;z-index: 1;">
  74. <view class="" style="margin-top: 10rpx;">
  75. <text class="money">¥</text>
  76. <text class="money" style="font-size: 40rpx;">{{item.goods.price}}</text>
  77. </view>
  78. <image src="../../static/shopping/shop.png" style="width: 82rpx;height: 38rpx;" mode="">
  79. </image>
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. <!-- <view class="" style="height: 80rpx;"></view> -->
  87. <view class="" style="height: 160rpx;"></view>
  88. <kj-tabbar :value1=2></kj-tabbar>
  89. </view>
  90. </template>
  91. <script>
  92. export default {
  93. data() {
  94. return {
  95. list1: [],
  96. language: 'zh-CN', //语言
  97. list: [],
  98. keyword: '',
  99. parent_id: ''
  100. };
  101. },
  102. onShow() {
  103. if (uni.getStorageSync('language') != '') {
  104. this.language = uni.getStorageSync('language')
  105. }
  106. this.category()
  107. this.shipp()
  108. },
  109. methods: {
  110. //跳转详情
  111. todetail(id){
  112. uni.navigateTo({
  113. url:'/pageA/productdetails?id='+id
  114. })
  115. },
  116. //搜索
  117. search() {
  118. this.shipp(this.parent_id)
  119. },
  120. //10元购
  121. shipp() {
  122. uni.$u.http.post('/api/goods/ten_yuan_goods', {
  123. parent_id: this.parent_id,
  124. keyword: this.keyword
  125. }).then((res) => {
  126. this.list = res.data
  127. }).catch(() => {
  128. })
  129. },
  130. //商品分类列表
  131. category() {
  132. uni.$u.http.get('/api/goods/category', {
  133. params: {
  134. parent_id: 0,
  135. }
  136. }).then((res) => {
  137. const categoryArr = res
  138. this.list1 = [{
  139. name: '',
  140. category_id: ''
  141. }]
  142. if (this.language == 'en-US') {
  143. categoryArr.forEach(item => {
  144. item.name = item.name_en
  145. })
  146. this.list1[0].name = 'selection'
  147. }
  148. if (this.language == 'es-ES') {
  149. categoryArr.forEach(item => {
  150. item.name = item.name_es
  151. })
  152. this.list1[0].name = 'Una selección de'
  153. }
  154. if (this.language == 'it-IT') {
  155. categoryArr.forEach(item => {
  156. item.name = item.name_ita
  157. })
  158. this.list1[0].name = 'selezionate'
  159. }
  160. if (this.language == 'zh-CN') {
  161. categoryArr.forEach(item => {
  162. item.name = item.name_cn
  163. })
  164. this.list1[0].name = '精选'
  165. }
  166. this.list1 = this.list1.concat(categoryArr)
  167. console.log(this.list1);
  168. }).catch(() => {
  169. })
  170. },
  171. changetab(item) {
  172. this.parent_id = item.id
  173. console.log('item', item);
  174. this.shipp(item.id)
  175. }
  176. },
  177. computed: {
  178. i18n() {
  179. return this.$t('index')
  180. }
  181. },
  182. }
  183. </script>
  184. <style lang="scss" scoped>
  185. .content {
  186. width: 750rpx;
  187. // height: 1332rpx;
  188. background: linear-gradient(180deg, #FDFCFB 0%, #F4F4F4 100%);
  189. border-radius: 30rpx 30rpx 0rpx 0rpx;
  190. margin-top: 32rpx;
  191. padding: 32rpx;
  192. box-sizing: border-box;
  193. .item {
  194. width: 340rpx;
  195. // height: 592rpx;
  196. background: #FFFFFF;
  197. border-radius: 16rpx;
  198. .title {
  199. font-family: PingFangSC, PingFang SC;
  200. font-weight: 400;
  201. font-size: 26rpx;
  202. color: #222222;
  203. line-height: 36rpx;
  204. text-align: left;
  205. font-style: normal;
  206. display: block;
  207. width: 100%;
  208. overflow: hidden;
  209. text-overflow: ellipsis;
  210. white-space: nowrap;
  211. }
  212. .tabsa {
  213. // width: 96rpx;
  214. // height: 32rpx;
  215. margin-top: 10rpx;
  216. border-radius: 4rpx;
  217. border: 1rpx solid #ED0909;
  218. font-family: PingFangSC, PingFang SC;
  219. font-weight: 400;
  220. font-size: 20rpx;
  221. color: #ED0909;
  222. // line-height: 32rpx;
  223. text-align: center;
  224. font-style: normal;
  225. display: inline;
  226. padding: 0 4rpx;
  227. box-sizing: border-box;
  228. }
  229. .num {
  230. font-family: SFPro, SFPro;
  231. font-weight: 400;
  232. font-size: 20rpx;
  233. color: #555555;
  234. line-height: 24rpx;
  235. text-align: left;
  236. font-style: normal;
  237. margin-top: 16rpx;
  238. }
  239. .money {
  240. font-family: HarmonyOS_Sans_Medium;
  241. font-size: 20rpx;
  242. color: #F83224;
  243. line-height: 26rpx;
  244. text-align: left;
  245. font-style: normal;
  246. }
  247. }
  248. }
  249. .back {
  250. position: absolute;
  251. top: 0;
  252. left: 0;
  253. width: 750rpx;
  254. height: 800rpx;
  255. background: #FE2E2E;
  256. }
  257. .input {
  258. width: 702rpx;
  259. height: 68rpx;
  260. background: #FFFFFF;
  261. border-radius: 34rpx;
  262. margin-left: 24rpx;
  263. box-sizing: border-box;
  264. padding: 0 8rpx 0 24rpx;
  265. .search {
  266. width: 100rpx;
  267. height: 56rpx;
  268. background: #F83224;
  269. border-radius: 28rpx;
  270. font-family: PingFangSC, PingFang SC;
  271. font-weight: 400;
  272. font-size: 26rpx;
  273. color: #FFFFFF;
  274. line-height: 56rpx;
  275. text-align: center;
  276. font-style: normal;
  277. }
  278. }
  279. </style>