index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. <template>
  2. <div>
  3. <div class="home_page">
  4. <div>
  5. <div class="pd">
  6. <Header></Header>
  7. </div>
  8. <!-- <div class="top">
  9. <img src="@/assets/images/index/cha.png" alt="" class="cha" />
  10. <van-field v-model="key" :placeholder="$t('lang4')" class="input" right-icon="search" @click="navigatorTo('transfer')" />
  11. </div> -->
  12. <div class="con">
  13. <div class="banner">
  14. <van-swipe :autoplay="3000" class="my-swipe" ref="swipeRef">
  15. <van-swipe-item class="swipe-item" v-for="(item, index) in indexinfo.banner_list" :key="index">
  16. <van-image style="width: 100%; height: 100%" radius="12" :src="item.img_url" />
  17. </van-swipe-item>
  18. </van-swipe>
  19. </div>
  20. <van-notice-bar class="notice" color="#000" background="#ffffff" :text="indexinfo.notice_list[0]?.title" @click="navigatorToPage('bulletinDetail', indexinfo.notice_list[0].id)">
  21. <div slot="left-icon" class="notice-ico">{{ $t('lang3') }}</div>
  22. <div slot="right-icon" @click="navigatorTo('bulletin')"><van-icon name="wap-nav" size="20" color="#29b286" /></div>
  23. </van-notice-bar>
  24. </div>
  25. </div>
  26. <div class="pd navbox flex jsb">
  27. <div class="navbox_item flex" v-for="(item, index) in navlist" :key="index" @click="navigatorTo(item.url)">
  28. <img :src="item.icon" alt="" />
  29. <span>{{ item.text }}</span>
  30. </div>
  31. </div>
  32. <div class="split flex">
  33. <img src="@/assets/images/index/split.png" alt="" />
  34. <span>{{ $t('lang263') }}</span>
  35. <img src="@/assets/images/index/split.png" alt="" />
  36. </div>
  37. <!-- 热门抢购 -->
  38. <div class="goods_box">
  39. <!-- <div class="title">
  40. <div class="flex">
  41. <img src="@/assets/images/index/hot.png" class="good_icon" />
  42. <span>{{ $t('lang1') }}</span>
  43. </div>
  44. <div class="" @click="navigatorTo('trade')">
  45. <span class="all">{{ $t('lang5') }}</span>
  46. <van-icon name="arrow" color="#7f7f7f" size="14px" />
  47. </div>
  48. </div> -->
  49. <div class="goods_list" v-for="(item, index) in product_list" :key="index" @click="navigatorToPage('GoodsDetail', item.id, item.product_id)">
  50. <van-image class="goods_list_img" radius="10" :src="item.products_list.thum" />
  51. <div class="right">
  52. <span class="ellipsis" v-if="$i18n.locale == 'en'">{{ item.products_list.en_name }}</span>
  53. <span class="ellipsis" v-else>{{ item.products_list.zh_name }}</span>
  54. <div class="cen">
  55. <span class="money"
  56. >{{ item.price }}<span class="ssm">{{ $t('lang174') }}</span></span
  57. >
  58. </div>
  59. <!-- <span class="time_text">{{ $t('lang6') }} {{ item.cost_price }}{{ $t('lang174') }}</span> -->
  60. <div class="yel" v-if="item.status == 1">
  61. <van-count-down class="count" :time="item.end_time * 1000 - new Date().getTime()" :format="`${$t('lang8')} DD ${$t('lang9')} HH ${$t('lang10')} mm ${$t('lang11')} ss ${$t('lang12')}`" />
  62. </div>
  63. <div class="yel" style="background-color: #f1f1f1" v-else-if="item.status == 0">
  64. <span class="count" style="color: #aaa">{{ $t('lang72') }}</span>
  65. </div>
  66. <div class="progress">
  67. <van-progress :percentage="((item.num + item.init_num) / item.stock) * 100 || 0" class="pro" color="#29b286" :show-pivot="false" />
  68. <span>{{ item.num + item.init_num }}/{{ item.stock }}{{ $t('lang7') }}</span>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. <!-- <div class="pd goods_box">
  74. <div class="title">
  75. <div class="flex">
  76. <img src="@/assets/images/index/change.png" class="good_icon" />
  77. <span>{{ $t('lang216') }}</span>
  78. </div>
  79. <div>
  80. <span class="all" @click="navigatorTo('transfer')">{{ $t('lang14') }}</span>
  81. <van-icon name="arrow" color="#7f7f7f" size="14px" />
  82. </div>
  83. </div>
  84. <div class="goods_list jsb" v-for="(item, index) in transfer_list" :key="index">
  85. <van-image class="goods_list_img" radius="10" :src="item.img_url" />
  86. <div class="right" style="flex: 1">
  87. <span class="ellipsis">{{ item.name }}</span>
  88. <span class="time_text t2">{{ $t('lang15') }}{{ item.nickname }}</span>
  89. <div class="green">{{ item.title }}</div>
  90. <div class="flex jsb">
  91. <div class="cen1">
  92. <span class="mon_t">{{ $t('lang16') }}: </span>
  93. <span class="money"
  94. >{{ Math.floor(item.price * 100) / 100 }}<span class="ssm">{{ $t('lang174') }}</span></span
  95. >
  96. </div>
  97. <div class="buy" @click="navigatorToPage('TransferDetail', item.id)">
  98. <van-button class="buy_btn" type="primary">{{ $t('lang17') }}</van-button>
  99. </div>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. <div class="pd goods_box">
  105. <div class="title">
  106. <div class="flex">
  107. <img src="@/assets/images/index/mine.png" class="good_icon" />
  108. <span>{{ $t('lang217') }}</span>
  109. </div>
  110. <div>
  111. <span class="all" @click="$toast($t('lang2'))">{{ $t('lang19') }}</span>
  112. <van-icon name="arrow" color="#7f7f7f" size="14px" />
  113. </div>
  114. </div>
  115. <div class="goods_list goods_list1 jsb">
  116. <div class="item" v-for="(item, index) in mortgage_list" :key="index">
  117. <van-image class="goods_list1_img" radius="10" :src="item.img_url" />
  118. <div class="right">
  119. <span>{{ item.title }}</span>
  120. <div class="cen">
  121. <span class="mon_t">{{ $t('lang20') }}: </span>
  122. <span class="money">10000</span>
  123. </div>
  124. </div>
  125. </div>
  126. </div>
  127. </div> -->
  128. </div>
  129. <!-- 绑定弹窗 -->
  130. <van-popup v-model="show" round style="width: 80%" :close-on-click-overlay="false">
  131. <div class="bind_box">
  132. <van-icon name="cross" class="close" size="20" @click="show = false" />
  133. <div class="title">{{ $t('lang21') }}</div>
  134. <div class="address_field">
  135. <van-field v-model="inviteCode" type="textarea" rows="1" autosize class="input1" :placeholder="$t('lang23')" />
  136. </div>
  137. <div class="bind_button" @click="bindParent">
  138. <span>{{ $t('lang22') }}</span>
  139. </div>
  140. </div>
  141. </van-popup>
  142. <BottomNavigation></BottomNavigation>
  143. </div>
  144. </template>
  145. <script>
  146. import Header from '@/components/Header.vue';
  147. import { mapState } from 'vuex';
  148. import { homeApi } from '@/api/index';
  149. import BottomNavigation from '@/components/BottomNavigation.vue';
  150. import { Notify } from 'vant';
  151. import { dateFormat } from '@/utils/formatTool.js';
  152. import { Locale } from 'vant';
  153. import enUS from 'vant/es/locale/lang/en-US';
  154. import zhCN from 'vant/lib/locale/lang/zh-CN';
  155. export default {
  156. data() {
  157. return {
  158. show: false, //弹窗状态
  159. address: '', //上级地址
  160. noticeText: '', //公告
  161. indexinfo: {
  162. system_name: '',
  163. system_logo: '',
  164. banner_list: [],
  165. notice_list: [],
  166. },
  167. inviteCode: undefined,
  168. userinfo: {
  169. power: undefined,
  170. token: undefined,
  171. team_poser: undefined,
  172. },
  173. bindShow: false,
  174. time: 30 * 60 * 60 * 1000,
  175. showLoading: true,
  176. key: '',
  177. transfer_list: [],
  178. product_list: [],
  179. mortgage_list: [],
  180. navlist: [
  181. {
  182. text: this.$t('lang258'),
  183. icon: require('@/assets/images/index/rb.png'),
  184. url: '',
  185. },
  186. {
  187. text: this.$t('lang259'),
  188. icon: require('@/assets/images/index/hc.png'),
  189. url: '',
  190. },
  191. {
  192. text: this.$t('lang264'),
  193. icon: require('@/assets/images/index/cj.png'),
  194. url: 'welfare',
  195. },
  196. {
  197. text: this.$t('lang261'),
  198. icon: require('@/assets/images/index/kf.png'),
  199. url: '',
  200. },
  201. {
  202. text: this.$t('lang262'),
  203. icon: require('@/assets/images/index/fx.png'),
  204. url: 'invite',
  205. },
  206. ],
  207. };
  208. },
  209. created() {
  210. if (localStorage.getItem('language') == 'en') {
  211. Locale.use('en-US', enUS);
  212. } else {
  213. Locale.use('zh-CN', zhCN);
  214. }
  215. this.inviteCode = this.$route.query.inviteCode;
  216. if (this.inviteCode) {
  217. localStorage.setItem('inviteCode', this.inviteCode);
  218. }
  219. // this.getUserInfo();
  220. },
  221. mounted() {
  222. this.inviteCode = this.$route.query.inviteCode;
  223. if (this.inviteCode) {
  224. localStorage.setItem('inviteCode', this.inviteCode);
  225. }
  226. if (this.account) {
  227. this.init();
  228. }
  229. // if (!localStorage.getItem('noLogin')) {
  230. // this.init();
  231. // }
  232. //注册一个事件总线 on
  233. this.$bus.$on('updateUserinfo', data => {
  234. // console.log('走了事件总线', data);
  235. if (data == 'update') {
  236. this.init();
  237. }
  238. });
  239. },
  240. methods: {
  241. init() {
  242. this.getIndexBaseInfo();
  243. this.getIndexGoodsInfo();
  244. this.getUserInfo();
  245. },
  246. // bind() {
  247. // if (this.userinfo.parent_id == 0 && this.inviteCode) {
  248. // // this.show = true;
  249. // this.bindParent();
  250. // } else if (this.userinfo.parent_id == 0 && !this.inviteCode) {
  251. // this.show = true;
  252. // }
  253. // },
  254. dateFormatFn(date) {
  255. return dateFormat(new Date(date * 1000), 'yyyy-MM-dd');
  256. },
  257. bindParent() {
  258. if (!this.inviteCode) {
  259. Notify({ type: 'danger', message: this.$t('lang23') });
  260. this.show = true;
  261. return;
  262. }
  263. let data = {
  264. address: this.account,
  265. inviteCode: this.inviteCode,
  266. // sign: res,
  267. };
  268. //绑定上级 看信息
  269. homeApi.auth(data).then(res => {
  270. // console.log('走了这里11');
  271. //我是绑定上级
  272. if (res.code == 200) {
  273. if (res.data.parent_id != 0) {
  274. Notify({ type: 'success', message: this.$t('lang152') });
  275. this.bindShow = false;
  276. this.show = false;
  277. this.init();
  278. localStorage.setItem('userinfo', JSON.stringify(res.data));
  279. localStorage.setItem('token__' + account, res.data.token);
  280. localStorage.setItem('parentId', res.data.parent_id);
  281. } else {
  282. this.show = true;
  283. Notify({ type: 'danger', message: res.msg });
  284. }
  285. } else {
  286. this.show = true;
  287. Notify({ type: 'danger', message: res.msg });
  288. }
  289. });
  290. },
  291. changeBanner(index) {
  292. this.$refs.swipeRef.swipeTo(index, { immediate: false });
  293. },
  294. getUserInfo() {
  295. homeApi.getUserInfo({ address: this.account, inviteCode: this.inviteCode }).then(res => {
  296. if (res.code == 200) {
  297. localStorage.setItem('userinfo', JSON.stringify(res.data));
  298. localStorage.setItem('parentId', res.data.parent_id);
  299. this.userinfo = res.data;
  300. if (this.userinfo.parent_id == 0) {
  301. this.show = true;
  302. }
  303. // if (this.userinfo.parent_id == 0) {
  304. // this.bindParent();
  305. // }
  306. } else {
  307. }
  308. });
  309. },
  310. navigatorTo(router) {
  311. if (this.$route.name == router) return;
  312. if (router != '') {
  313. this.$router.push({ name: router });
  314. } else {
  315. this.$toast(this.$t('lang2'));
  316. }
  317. },
  318. navigatorToPage(name, id, product_id) {
  319. this.$router.push({ name, query: { id: id, product_id: product_id } });
  320. },
  321. getIndexBaseInfo() {
  322. homeApi.getIndexBaseInfo().then(res => {
  323. if (res.code == 200) {
  324. this.showLoading = false;
  325. this.indexinfo = res.data;
  326. } else {
  327. this.showLoading = false;
  328. }
  329. });
  330. },
  331. getIndexGoodsInfo() {
  332. homeApi.getIndexGoodsInfo().then(res => {
  333. if (res.code == 200) {
  334. this.transfer_list = res.data.transfer_list;
  335. this.product_list = res.data.product_list;
  336. this.mortgage_list = res.data.mortgage_list;
  337. } else {
  338. }
  339. });
  340. },
  341. finish() {
  342. this.getIndexBaseInfo();
  343. },
  344. toLink(e) {
  345. window.location.href = e;
  346. },
  347. toAssets() {
  348. this.$router.push({ name: 'assets' });
  349. },
  350. toPage(type) {
  351. this.$router.push({ name: 'datainfo', query: { type } });
  352. },
  353. toTeam() {
  354. this.$router.push({ name: 'trade' });
  355. },
  356. },
  357. computed: {
  358. ...mapState(['account']),
  359. },
  360. watch: {
  361. account(e) {
  362. // this.init();
  363. // this.bind();
  364. },
  365. },
  366. components: {
  367. Header,
  368. BottomNavigation,
  369. },
  370. };
  371. </script>
  372. <style lang="less" scoped>
  373. .home_page {
  374. padding: 0 0 100px;
  375. min-height: 100vh;
  376. .pd {
  377. padding: 14px;
  378. background-color: #fff;
  379. }
  380. .top {
  381. display: flex;
  382. justify-content: space-between;
  383. align-items: center;
  384. .cha {
  385. width: 100px;
  386. }
  387. .input {
  388. width: calc(100% - 110px);
  389. border: 1px solid #29b286;
  390. border-radius: 20px;
  391. }
  392. ::v-deep .van-field__control {
  393. padding: 6px 12px;
  394. }
  395. ::v-deep .van-icon-search {
  396. font-size: 20px;
  397. color: #29b286;
  398. font-weight: bold;
  399. margin-right: 10px;
  400. }
  401. }
  402. .con {
  403. margin: 14px;
  404. border-radius: 12px;
  405. background-color: #fff;
  406. }
  407. .notice {
  408. font-size: 13px;
  409. margin: 0px 4px 12px;
  410. .notice-ico {
  411. color: #fff;
  412. letter-spacing: 2px;
  413. padding: 0 8px;
  414. border-radius: 20px;
  415. margin-right: 10px;
  416. background-color: #29b286;
  417. }
  418. }
  419. ::v-deep .van-notice-bar {
  420. padding: 0 !important;
  421. }
  422. .banner {
  423. margin: 8px 0 0;
  424. height: 160px;
  425. color: #fff;
  426. font-size: 22px;
  427. border-radius: 12px;
  428. .my-swipe {
  429. width: 100%;
  430. height: 100%;
  431. border-radius: 12px;
  432. }
  433. }
  434. .jsb {
  435. justify-content: space-between;
  436. }
  437. .goods_box {
  438. margin: 14px;
  439. border-radius: 14px;
  440. .good_icon {
  441. width: 16px;
  442. height: 16px;
  443. margin-right: 5px;
  444. }
  445. }
  446. .title {
  447. color: #000;
  448. font-size: 15px;
  449. font-weight: 600;
  450. // font-style: italic;
  451. padding: 0 0 20px;
  452. display: flex;
  453. justify-content: space-between;
  454. align-items: center;
  455. .all {
  456. font-size: 12px;
  457. font-weight: normal;
  458. font-style: normal;
  459. color: rgba(#999, 1);
  460. }
  461. }
  462. .navbox {
  463. margin: 14px;
  464. border-radius: 12px;
  465. &_item {
  466. color: #000;
  467. font-size: 10px;
  468. font-weight: 550;
  469. text-align: center;
  470. flex-direction: column;
  471. img {
  472. width: 36px;
  473. height: 36px;
  474. margin-bottom: 4px;
  475. }
  476. }
  477. }
  478. .split {
  479. color: #000;
  480. justify-content: center;
  481. span {
  482. font-size: 17px;
  483. font-weight: 550;
  484. letter-spacing: 2px;
  485. padding: 0 10px;
  486. }
  487. img {
  488. width: 40px;
  489. }
  490. img:last-child {
  491. transform: rotate(180deg);
  492. }
  493. }
  494. .goods_list {
  495. display: flex;
  496. // align-items: center;
  497. // justify-content: space-between;
  498. color: #000;
  499. padding: 12px;
  500. border-radius: 10px;
  501. // box-shadow: 0 4px 16px 0 rgba(53, 73, 93, 0.15);
  502. margin-bottom: 20px;
  503. // box-shadow: 4px 4px 15px 0px rgba(180, 212, 212, 0.29);
  504. background-color: #fff;
  505. // background-image: linear-gradient(90deg, rgba(217, 239, 239, 0.3) 0, rgba(217, 239, 239, 0.3) 0, rgba(225, 240, 242, 0.3) 100%, rgba(225, 240, 242, 0.3) 100%);
  506. &_img {
  507. width: 90px;
  508. height: 90px;
  509. border-radius: 10px;
  510. margin-right: 10px;
  511. }
  512. .right {
  513. width: calc(100% - 100px);
  514. display: flex;
  515. flex-direction: column;
  516. justify-content: space-between;
  517. font-size: 13px;
  518. .time_text {
  519. color: #7f7f7f;
  520. font-weight: normal;
  521. font-size: 10px;
  522. text-decoration: line-through;
  523. // padding-top: 10px;
  524. }
  525. .cen1 {
  526. color: red;
  527. // font-weight: 550;
  528. // padding: 5px 0;
  529. font-size: 12px;
  530. }
  531. .cen {
  532. color: red;
  533. // font-weight: 550;
  534. display: flex;
  535. align-items: center;
  536. // padding: 5px 0;
  537. font-size: 12px;
  538. }
  539. .money {
  540. font-size: 15px;
  541. }
  542. .ssm {
  543. font-size: 10px;
  544. font-weight: normal;
  545. }
  546. .mon_t {
  547. color: #000;
  548. font-weight: normal;
  549. }
  550. .yel {
  551. font-weight: normal;
  552. white-space: nowrap;
  553. line-height: 100%;
  554. width: fit-content;
  555. // margin-left: 8px;
  556. padding: 0px 8px;
  557. border-radius: 16px;
  558. background-color: #f9f6e5;
  559. .count {
  560. color: #f7c35d;
  561. font-size: 9px;
  562. }
  563. }
  564. .green {
  565. width: fit-content;
  566. color: #29b286;
  567. background-color: #ddf2e7;
  568. font-size: 10px;
  569. font-weight: normal;
  570. padding: 2px 6px;
  571. border-radius: 6px;
  572. }
  573. .t2 {
  574. text-decoration: none;
  575. }
  576. .progress {
  577. display: flex;
  578. align-items: center;
  579. justify-content: space-between;
  580. font-size: 10px;
  581. .pro {
  582. width: 70%;
  583. overflow: hidden;
  584. }
  585. }
  586. }
  587. .buy {
  588. display: flex;
  589. align-items: flex-end;
  590. justify-content: flex-end;
  591. &_btn {
  592. height: 26px;
  593. line-height: 26px;
  594. font-size: 10px;
  595. background-color: #29b286;
  596. border: none;
  597. padding: 0 10px;
  598. white-space: nowrap;
  599. border-radius: 30px;
  600. }
  601. }
  602. }
  603. }
  604. .goods_list1 {
  605. flex-wrap: wrap;
  606. &_img {
  607. width: 100%;
  608. height: 70px;
  609. border-radius: 10px;
  610. margin-right: 10px;
  611. }
  612. .item {
  613. width: 45%;
  614. margin-bottom: 10px;
  615. .cen {
  616. padding-top: 4px;
  617. .mon_t {
  618. font-size: 11px;
  619. color: #7f7f7f;
  620. }
  621. .money::after {
  622. content: 'CHA/年';
  623. }
  624. }
  625. }
  626. }
  627. .bind_box {
  628. font-size: 15px;
  629. text-align: center;
  630. color: #000;
  631. .close {
  632. position: absolute;
  633. right: 20px;
  634. top: 20px;
  635. }
  636. .title {
  637. padding: 20px 20px 26px;
  638. }
  639. .address_field {
  640. padding: 10px 0;
  641. margin: 0 30px 20px;
  642. }
  643. .bind_button {
  644. color: #29b286;
  645. text-align: center;
  646. border: none;
  647. padding: 16px 0;
  648. border-top: 1px solid #cccccc9d;
  649. }
  650. }
  651. .flex {
  652. display: flex;
  653. align-items: center;
  654. }
  655. .ellipsis {
  656. overflow: hidden; /* 确保超出容器的文本被裁剪 */
  657. white-space: nowrap; /* 确保文本在一行内显示 */
  658. text-overflow: ellipsis; /* 使用省略号表示文本超出 */
  659. }
  660. // ::v-deep .van-field__control {
  661. // overflow: hidden; /* 确保超出容器的文本被裁剪 */
  662. // white-space: nowrap; /* 确保文本在一行内显示 */
  663. // text-overflow: ellipsis; /* 使用省略号表示文本超出 */
  664. // }
  665. </style>