index.vue 18 KB

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