index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. <template>
  2. <!-- 商城 -->
  3. <view class="">
  4. <!-- <view class="index-navbar"> -->
  5. <view style="position: relative;">
  6. <!-- 自定义导航栏 -->
  7. <image src="../../static/images/index/back.png"
  8. style="width: 750rpx;height: 1200rpx;position: absolute;top: 0;z-index: -1;" mode=""></image>
  9. <u-navbar bgColor='rgba(255, 215,215, 1)' :placeholder='true' :fixed='true'>
  10. <view class="u-nav-slot" slot="left" style="display: flex;">
  11. <image @click="tochat" src="../../static/images/index/xiaoxi.png" mode=""
  12. style="width: 40rpx;height: 40rpx;">
  13. </image>
  14. <image @click="counter" src="../../static/images/index/compile.png" mode=""
  15. style="width: 40rpx;height: 40rpx;margin-left: 22rpx;"></image>
  16. <image src="../../static/images/index/dianhua.png" mode=""
  17. style="width: 40rpx;height: 40rpx;margin-left: 22rpx;"></image>
  18. </view>
  19. <view class="u-nav-slot" slot="center" style="width: 226rpx;">
  20. <u-subsection bgColor='rgba(248, 50, 36, 0.1)' activeColor='#F83224' inactiveColor='#222'
  21. :list="list" :current="current" @change="sectionChange"></u-subsection>
  22. </view>
  23. </u-navbar>
  24. <view class="" style="margin-top: 30rpx;padding:0 24rpx;">
  25. <!-- 搜索 -->
  26. <view class="search">
  27. <view class="u-flex">
  28. <u-icon name="search" size='32'></u-icon>
  29. <input type="text" v-model="keyword" :placeholder="i18n.Searchcon" />
  30. </view>
  31. <view class="right" @click="search">
  32. {{i18n.search}}
  33. </view>
  34. </view>
  35. <!-- tabs -->
  36. <view class=""
  37. style="display: flex;margin-top: 20rpx;align-items: center;justify-content: space-between;">
  38. <u-tabs :list="list1" @change='changetab'></u-tabs>
  39. <view class="border">
  40. </view>
  41. <view class="u-flex" style="margin-left: 24rpx;width: 100rpx;" @click="shoptype">
  42. <image src="../../static/images/index/fenlei.png" style="width: 24rpx;height: 24rpx;;" mode="">
  43. </image>
  44. <text class="fenlei">{{i18n.sort}}</text>
  45. </view>
  46. </view>
  47. <!-- 轮播图 -->
  48. <view class="" style="margin-top: 20rpx;">
  49. <u-swiper radius='10' :indicator='true' :list="banner"></u-swiper>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="shopback">
  54. <view class="u-flex u-row-between">
  55. <!-- 百亿补贴 -->
  56. <view class="bigbox" @click="subsidy(1)">
  57. <view class="u-flex">
  58. <image src="../../static/images/index/butie.png" style="width: 104rpx;height: 26rpx;" mode="">
  59. </image>
  60. <view class="biaoqian" style="background: #F35D22;">{{i18n.expensive}}</view>
  61. </view>
  62. <view class="u-flex" style="flex-wrap: wrap;justify-content: space-between;">
  63. <view v-for="(item,idx) in subsidylist" class="ssbox " style="margin-top: 16rpx;">
  64. <view class="" style="position: relative">
  65. <image :src="item.image" style="width: 144rpx;height: 144rpx;" mode=""></image>
  66. <view class="u-flex u-row-center"
  67. style="position: absolute;bottom: 10rpx;width: 144rpx;">
  68. <view class="u-flex">
  69. <view class="tag u-flex" style="background: rgba(243, 93, 34, 1);">
  70. <image src="../../static/images/index/down.png"
  71. style="width: 28rpx;height: 28rpx;position: relative;z-index: 3;"
  72. mode="">
  73. </image>
  74. <text>{{(item.price*1000 - item.discount_price*1000)/1000 + i18n.RMB}}</text>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. <view class="money" style="text-align: center;">
  80. ¥{{item.discount_price}}
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. <!-- 拼包好物 -->
  86. <view class="">
  87. <view class="smallbox" @click="subsidy(2)">
  88. <view class="u-flex">
  89. <image src="../../static/images/index/pinbao.png" style="width: 164rpx;height: 26rpx;"
  90. mode=""></image>
  91. <view class="biaoqian" style="background: rgba(255, 148, 21, 1);">{{i18n.expensive}}
  92. </view>
  93. </view>
  94. <view class="u-flex" style="flex-wrap: wrap;justify-content: space-between;">
  95. <view v-for="(item,idx) in packlist" class="ssbox " style="margin-top: 16rpx;">
  96. <view class="" style="position: relative">
  97. <image :src="item.image" style=";width: 144rpx;height: 144rpx;" mode=""></image>
  98. <view class="u-flex u-row-center"
  99. style="position: absolute;bottom: 10rpx;width: 144rpx;">
  100. <view class="u-flex">
  101. <!-- <image src="../../static/images/index/label.png"
  102. style="width: 28rpx;height: 28rpx;position: relative;z-index: 3;"
  103. mode="">
  104. </image> -->
  105. <view v-if="item.is_discount==0" class="tag u-flex"
  106. style="background-color: rgba(251, 73, 70, 1);">
  107. <image src="../../static/images/index/down.png"
  108. style="width: 28rpx;height: 28rpx;position: relative;z-index: 3;"
  109. mode="">
  110. </image>
  111. <text>{{(item.price*1000 - item.discount_price*1000)/1000 + i18n.RMB}}</text>
  112. </view>
  113. </view>
  114. </view>
  115. </view>
  116. </view>
  117. </view>
  118. </view>
  119. <view class="smallbox" @click="subsidy(3)">
  120. <view class="u-flex">
  121. <image src="../../static/images/index/postage.png" style="width: 116rpx;height: 26rpx;"
  122. mode=""></image>
  123. <view class="biaoqian" style="background:rgba(248, 50, 36, 1)">{{i18n.Something}}</view>
  124. </view>
  125. <view class="u-flex" style="flex-wrap: wrap;justify-content: space-between;">
  126. <view v-for="(item,idx) in shippList" class="ssbox " style="margin-top: 8rpx;">
  127. <view class="" style="position: relative">
  128. <image :src="item.image" style="width: 124rpx;height: 124rpx;" mode=""></image>
  129. <view class="shopname" v-if="language =='zh-CN'">
  130. {{item.name_cn}}
  131. </view>
  132. <view class="shopname" v-if="language =='en-US'">
  133. {{item.name_en}}
  134. </view>
  135. <view class="shopname" v-if="language =='es-ES'">
  136. {{item.name_es}}
  137. </view>
  138. <view class="shopname" v-if="language =='it-IT'">
  139. {{item.name_ita}}
  140. </view>
  141. </view>
  142. </view>
  143. </view>
  144. </view>
  145. </view>
  146. </view>
  147. <view class="u-flex u-row-between" style="flex-wrap: wrap;">
  148. <view class="bigbox" v-for="(item,index) in recomlist" style="position: relative;"
  149. @click="todetail(item.id)">
  150. <image v-if="item.is_discount==0" src="../../static/images/index/discount.png"
  151. style="width: 60rpx;height: 36rpx;position: absolute;left: 12rpx;top: 12rpx;z-index: 10;"
  152. mode="">
  153. </image>
  154. <image :src="item.image"
  155. style="width: 340rpx;height: 340rpx;;margin-left: -20rpx;margin-top: -18rpx;" mode=""></image>
  156. <view class="title" v-if="language =='zh-CN'">
  157. {{item.name_cn}}
  158. </view>
  159. <view class="title" v-if="language =='en-US'">
  160. {{item.name_en}}
  161. </view>
  162. <view class="title" v-if="language =='es-ES'">
  163. {{item.name_es}}
  164. </view>
  165. <view class="title" v-if="language =='it-IT'">
  166. {{item.name_ita}}
  167. </view>
  168. <view class="">
  169. <text class="money">
  170. ¥{{item.is_discount==0?item.discount_price:item.price}}
  171. </text>
  172. <text class="weight">
  173. ¥{{item.weight}}/kg
  174. </text>
  175. </view>
  176. <view class="u-flex" style="flex-wrap: wrap;margin-top: 18rpx;column-gap: 12px;overflow: hidden;">
  177. <!-- <view v-for="(child,idx) in item.label_arr" :key="idx" class="taber"
  178. style="border: 1rpx solid #E5BC78;color: #E5BC78;">
  179. <text>{{child.name_cn}}</text>
  180. </view> -->
  181. <view v-for="(child,idx) in item.label_arr" :key="idx" class="taber"
  182. style="border: 1rpx solid rgba(237, 9, 9, 1);color: rgba(237, 9, 9, 1);">
  183. <text v-if="language =='zh-CN'">
  184. {{child.name_cn}}
  185. </text>
  186. <text v-if="language =='en-US'">
  187. {{child.name_en}}
  188. </text>
  189. <text v-if="language =='es-ES'">
  190. {{child.name_es}}
  191. </text>
  192. <text v-if="language =='it-IT'">
  193. {{child.name_ita}}
  194. </text>
  195. </view>
  196. <!-- <view class="taber" style="border: 1rpx solid #E5BC78;color: #E5BC78;">以旧换新</view> -->
  197. </view>
  198. </view>
  199. </view>
  200. </view>
  201. <u-popup :show="show" mode='center' :round='16' bgColor='transparent'>
  202. <view style="position: relative;" @click="advert">
  203. <image :src="configimage" style="width: 570rpx;height: 764rpx;border-radius: 16rpx;" mode=""></image>
  204. <view class="" style="text-align: center;" @click.stop='show=false'>
  205. <image src="../../static/images/index/close.png" mode="" style="width: 70rpx;height: 70rpx;">
  206. </image>
  207. </view>
  208. </view>
  209. </u-popup>
  210. <view class="" style="height: 160rpx;" v-if="recomlist.length >3"></view>
  211. <kj-tabbar :value1=1></kj-tabbar>
  212. </view>
  213. </template>
  214. <script>
  215. import {
  216. recom
  217. } from "../../network/shopApi.js";
  218. export default {
  219. data() {
  220. return {
  221. recomlist: [], //推荐列表
  222. //顶部分段器
  223. list: [],
  224. current: 1,
  225. //tabs
  226. list1: [{
  227. name: '推荐',
  228. }],
  229. //轮播图
  230. banner: [
  231. 'https://cdn.uviewui.com/uview/swiper/swiper1.png',
  232. 'https://cdn.uviewui.com/uview/swiper/swiper2.png',
  233. 'https://cdn.uviewui.com/uview/swiper/swiper3.png',
  234. ],
  235. show: true,
  236. timer: '',
  237. language: 'zh-CN',
  238. subsidylist: [], //百万补贴
  239. packlist: [], //拼包好物
  240. shippList: [], //海外包邮
  241. keyword: '',
  242. page: 1,
  243. index: 0,
  244. parent_id: '',
  245. last_page: '',
  246. configimage: '',
  247. url:''
  248. }
  249. },
  250. computed: {
  251. i18n() {
  252. return this.$t('index')
  253. }
  254. },
  255. onReachBottom() {
  256. if (this.page == this.last_page) {
  257. this.$u.toast('已无更多数据')
  258. } else {
  259. if (this.current != 0) {
  260. this.page++
  261. this.goods(this.parent_id)
  262. }
  263. }
  264. },
  265. onLoad(options) {
  266. this.list = [this.i18n.border, this.i18n.shop]
  267. // this.seater()
  268. if (options.current) {
  269. this.current = options.current
  270. }
  271. //商品推荐
  272. this.recommend()
  273. },
  274. onShow() {
  275. this.config()
  276. // tabs列表
  277. this.category()
  278. //百万补贴
  279. this.subsid()
  280. //拼包好物
  281. this.pack()
  282. //海外包邮
  283. this.shipp()
  284. if (uni.getStorageSync('language') != '') {
  285. this.language = uni.getStorageSync('language')
  286. }
  287. },
  288. methods: {
  289. advert(){
  290. console.log(this.url);
  291. uni.navigateTo({
  292. url:this.url
  293. })
  294. },
  295. //广告弹窗
  296. config() {
  297. uni.$u.http.get('api/config', {
  298. params: {
  299. module: 'advertising'
  300. }
  301. }).then((res) => {
  302. console.log(res);
  303. this.configimage = res.image
  304. this.url = res.url
  305. }).catch(() => {
  306. })
  307. },
  308. //海外包邮接口
  309. shipp() {
  310. uni.$u.http.post('api/goods/shipping').then((res) => {
  311. this.shippList = res.splice(0, 2)
  312. }).catch(() => {
  313. })
  314. },
  315. //拼包好物接口
  316. pack() {
  317. uni.$u.http.post('/api/goods/pack').then((res) => {
  318. this.packlist = res.splice(0, 2)
  319. }).catch(() => {
  320. })
  321. },
  322. //百万补贴接口
  323. subsid() {
  324. uni.$u.http.post('/api/goods/subsidy').then((res) => {
  325. this.subsidylist = res.splice(0, 4)
  326. }).catch(() => {
  327. })
  328. },
  329. //标签切换
  330. changetab(e) {
  331. this.index = e.index
  332. this.parent_id = e.id
  333. if (this.index == 0) {
  334. this.recommend()
  335. } else {
  336. this.recomlist = []
  337. this.goods(this.parent_id)
  338. }
  339. },
  340. search() {
  341. if (this.index == 0) {
  342. this.recommend()
  343. } else {
  344. this.recomlist = []
  345. this.goods(this.parent_id)
  346. }
  347. },
  348. //商品推荐
  349. recommend() {
  350. uni.$u.http.post('/api/goods/recommend', {
  351. keyword: this.keyword
  352. }).then((res) => {
  353. this.recomlist = res
  354. }).catch(() => {
  355. })
  356. },
  357. //商品分类列表
  358. category() {
  359. uni.$u.http.get('/api/goods/category', {
  360. params: {
  361. parent_id: 0
  362. }
  363. }).then((res) => {
  364. const categoryArr = res
  365. this.list1 = [{
  366. name: ''
  367. }]
  368. if (this.language == 'en-US') {
  369. categoryArr.forEach(item => {
  370. item.name = item.name_en
  371. })
  372. this.list1[0].name = 'recommend'
  373. }
  374. if (this.language == 'es-ES') {
  375. categoryArr.forEach(item => {
  376. item.name = item.name_es
  377. })
  378. this.list1[0].name = 'recomendación'
  379. }
  380. if (this.language == 'it-IT') {
  381. categoryArr.forEach(item => {
  382. item.name = item.name_ita
  383. })
  384. this.list1[0].name = 'raccomandata'
  385. }
  386. if (this.language == 'zh-CN') {
  387. categoryArr.forEach(item => {
  388. item.name = item.name_cn
  389. })
  390. this.list1[0].name = '推荐'
  391. }
  392. this.list1 = this.list1.concat(categoryArr)
  393. }).catch(() => {
  394. })
  395. },
  396. //商品列表
  397. goods(id) {
  398. uni.$u.http.get('/api/goods', {
  399. params: {
  400. parent_id: id,
  401. limit: 10,
  402. page: this.page,
  403. keyword: this.keyword
  404. }
  405. }).then((res) => {
  406. this.recomlist = this.recomlist.concat(res.data)
  407. this.last_page = res.last_page
  408. }).catch(() => {
  409. })
  410. },
  411. //百万补贴跳转
  412. subsidy(item) {
  413. uni.navigateTo({
  414. url: '/pageA/subsidy?show=' + item
  415. })
  416. },
  417. //物流计算器
  418. counter() {
  419. uni.navigateTo({
  420. url: '/pageA/counter'
  421. })
  422. },
  423. //消息
  424. tochat() {
  425. uni.navigateTo({
  426. url: '/pageA/chat/news'
  427. })
  428. },
  429. //商品分类
  430. shoptype() {
  431. uni.navigateTo({
  432. url: '/pageA/shoptype'
  433. })
  434. },
  435. //分段器切换
  436. sectionChange(index) {
  437. this.current = index;
  438. console.log(index);
  439. if (this.current == 0) {
  440. uni.switchTab({
  441. url: '/pages/express/express?current=0'
  442. })
  443. this.current = 1
  444. }
  445. },
  446. //详情
  447. todetail(id) {
  448. uni.navigateTo({
  449. url: '/pageA/productdetails?id=' + id
  450. })
  451. }
  452. }
  453. }
  454. </script>
  455. <style lang="scss" scoped>
  456. page {
  457. background-color: rgba(0, 0, 0, 0)
  458. }
  459. .index-navbar {
  460. position: sticky;
  461. top: 0;
  462. left: 0;
  463. width: 750rpx;
  464. z-index: 100;
  465. }
  466. ::v-deep .u-tabs {
  467. width: 560rpx;
  468. }
  469. .taber {
  470. border-radius: 4rpx;
  471. padding: 4rpx 8rpx;
  472. margin-bottom: 10rpx;
  473. font-family: PingFangSC, PingFang SC;
  474. font-weight: 400;
  475. font-size: 20rpx;
  476. color: #D48700;
  477. line-height: 28rpx;
  478. text-align: left;
  479. font-style: normal;
  480. }
  481. .title {
  482. font-family: SFPro, SFPro;
  483. font-weight: 400;
  484. font-size: 26rpx;
  485. color: #222222;
  486. // line-height: 30rpx;
  487. // text-align: left;
  488. // font-style: normal;
  489. width: 300rpx;
  490. // height: 70rpx;
  491. overflow: hidden;
  492. text-overflow: ellipsis ;
  493. -webkit-line-clamp: 2;
  494. display: -webkit-box;
  495. -webkit-box-orient:vertical;
  496. }
  497. .weight {
  498. font-family: SFPro, SFPro;
  499. font-weight: 400;
  500. font-size: 20rpx;
  501. color: #888888;
  502. line-height: 24rpx;
  503. text-align: left;
  504. font-style: normal;
  505. margin-left: 12rpx;
  506. }
  507. .shopname {
  508. font-family: PingFangSC, PingFang SC;
  509. font-weight: 400;
  510. font-size: 20rpx;
  511. color: #666666;
  512. line-height: 28rpx;
  513. text-align: left;
  514. font-style: normal;
  515. }
  516. .money {
  517. font-family: HarmonyOS_Sans_Medium;
  518. font-size: 28rpx;
  519. color: #F83224;
  520. line-height: 38rpx;
  521. text-align: right;
  522. font-style: normal;
  523. }
  524. .biaoqian {
  525. height: 28rpx;
  526. border-radius: 6rpx;
  527. padding: 6rpx;
  528. margin-left: 8rpx;
  529. font-family: PingFangSC, PingFang SC;
  530. font-weight: 400;
  531. font-size: 20rpx;
  532. color: #FFFFFF;
  533. line-height: 28rpx;
  534. text-align: center;
  535. }
  536. .tag {
  537. // height: 28rpx;
  538. border-radius: 14rpx 14rpx 14rpx 0rpx;
  539. border: 1rpx solid #FFFFFF;
  540. padding: 6rpx;
  541. text-align: center;
  542. font-family: PingFangSC, PingFang SC;
  543. font-weight: 400;
  544. font-size: 20rpx;
  545. color: #FFFFFF;
  546. line-height: 28rpx;
  547. text-align: center;
  548. font-style: normal;
  549. box-sizing: border-box;
  550. // margin-left: -15rpx;
  551. }
  552. .bigbox {
  553. width: 340rpx;
  554. // height: 468rpx;
  555. background: #FFFFFF;
  556. border-radius: 12rpx;
  557. border: 2rpx solid #FFFFFF;
  558. margin-bottom: 22rpx;
  559. padding: 18rpx 20rpx;
  560. box-sizing: border-box;
  561. }
  562. .smallbox {
  563. width: 340rpx;
  564. height: 226rpx;
  565. background: #FFFFFF;
  566. border-radius: 12rpx;
  567. border: 2rpx solid #FFFFFF;
  568. margin-bottom: 22rpx;
  569. padding: 18rpx 20rpx;
  570. box-sizing: border-box;
  571. }
  572. .shopback {
  573. width: 750rpx;
  574. min-height: 1216rpx;
  575. background: #F4F4F4;
  576. border-radius: 28rpx 28rpx 0rpx 0rpx;
  577. padding: 26rpx 24rpx;
  578. box-sizing: border-box;
  579. }
  580. .fenlei {
  581. font-family: PingFangSC, PingFang SC;
  582. font-weight: 400;
  583. font-size: 28rpx;
  584. color: #222222;
  585. line-height: 40rpx;
  586. text-align: right;
  587. font-style: normal;
  588. margin-left: 8rpx;
  589. }
  590. .search {
  591. width: 702rpx;
  592. height: 68rpx;
  593. background: #FFFFFF;
  594. border-radius: 34rpx;
  595. padding: 6rpx 6rpx 6rpx 36rpx;
  596. display: flex;
  597. align-items: center;
  598. justify-content: space-between;
  599. box-sizing: border-box;
  600. .right {
  601. width: 100rpx;
  602. height: 56rpx;
  603. background: #ED0909;
  604. border-radius: 28rpx;
  605. font-family: PingFangSC, PingFang SC;
  606. font-weight: 400;
  607. font-size: 26rpx;
  608. color: #FFFFFF;
  609. line-height: 56rpx;
  610. text-align: center;
  611. }
  612. }
  613. .border {
  614. width: 2rpx;
  615. height: 24rpx;
  616. border: 2rpx solid #979797;
  617. opacity: 0.2;
  618. background-color: #979797;
  619. }
  620. // ::v-deep .u-navbar__content.data-v-1194bf80 {
  621. // background-color: rgba(0, 0, 0, 0) !important;
  622. // }
  623. // ::v-deep .u-status-bar.data-v-13f16680 {
  624. // background-color: rgba(0, 0, 0, 0) !important;
  625. // }
  626. ::v-deep .u-subsection--button.data-v-b14d3440 {
  627. /* padding: 6rpx 34rpx !important; */
  628. border-radius: 64rpx !important;
  629. }
  630. ::v-deep .u-subsection--button__bar.data-v-b14d3440 {
  631. border-radius: 32rpx !important;
  632. }
  633. </style>