index.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. import {
  2. createRouter,
  3. createWebHistory,
  4. createWebHashHistory
  5. } from 'vue-router';
  6. import store from '../store';
  7. import {
  8. Page
  9. } from './Page';
  10. import {
  11. Dialog
  12. } from 'vant';
  13. import http from '../plugins/http';
  14. jsapiSign();
  15. function jsapiSign() {
  16. return;
  17. // eslint-disable-next-line no-unreachable
  18. setTimeout(() => {
  19. if (/micromessenger/i.test(navigator.userAgent)) {
  20. if (/localhost|(192\.168)/i.test(location.host)) {
  21. return;
  22. }
  23. let isIOS = /iphone|ipad/i.test(navigator.userAgent);
  24. http.http
  25. .get('/wx/jsapiSign', {
  26. url: isIOS ? store.state.firstUrl : location.origin + location.href
  27. })
  28. .then(res => {
  29. wx.config({
  30. debug: false,
  31. appId: res.appId,
  32. timestamp: res.timestamp,
  33. nonceStr: res.nonceStr,
  34. signature: res.signature,
  35. jsApiList: [
  36. 'chooseWXPay',
  37. 'updateAppMessageShareData',
  38. 'updateTimelineShareData',
  39. 'hideAllNonBaseMenuItem',
  40. 'scanQRCode'
  41. ],
  42. openTagList: ['wx-open-launch-weapp']
  43. });
  44. wx.error(function (res) {
  45. console.log(res);
  46. });
  47. wx.ready(function () {
  48. wx.updateAppMessageShareData({
  49. title: '拉索宇宙',
  50. desc: '全球首个基于区块链的游戏资产集换中心',
  51. link: location.origin + '/9th',
  52. imgUrl: 'https://9space-2021.oss-cn-shenzhen.aliyuncs.com/nft/2021-11-05-15-58-30YwqLzMjy.jpg'
  53. });
  54. wx.updateTimelineShareData({
  55. title: '拉索宇宙-全球首个基于区块链的游戏资产集换中心',
  56. link: location.origin + '/9th',
  57. imgUrl: 'https://9space-2021.oss-cn-shenzhen.aliyuncs.com/nft/2021-11-05-15-58-30YwqLzMjy.jpg'
  58. });
  59. });
  60. })
  61. .catch(e => {});
  62. }
  63. }, 200);
  64. }
  65. jsapiSign();
  66. const routes = [{
  67. path: '/',
  68. redirect: 'home'
  69. },
  70. {
  71. path: '/',
  72. name: 'index',
  73. component: () => import('../views/Index.vue'),
  74. children: [{
  75. path: '/home',
  76. name: 'home',
  77. component: () => import('../views/Home.vue'),
  78. meta: {
  79. pageType: Page.Every,
  80. menuPage: true,
  81. title: '拉索宇宙'
  82. }
  83. },
  84. {
  85. path: '/discover',
  86. name: 'discover',
  87. component: () => import('../views/Discover.vue'),
  88. meta: {
  89. pageType: Page.Every,
  90. menuPage: true,
  91. title: '拉索宇宙'
  92. }
  93. },
  94. {
  95. path: '/creator',
  96. name: 'creator',
  97. component: () => import('../views/Creator.vue'),
  98. meta: {
  99. pageType: Page.Every,
  100. menuPage: true,
  101. title: '拉索宇宙'
  102. }
  103. },
  104. {
  105. path: '/store',
  106. name: 'store',
  107. component: () => import('../views/Store.vue'),
  108. meta: {
  109. title: '拉索宇宙',
  110. needBack: true
  111. }
  112. },
  113. {
  114. path: '/mineMessages',
  115. name: 'mineMessages',
  116. component: () => import('../views/user/Messages.vue'),
  117. meta: {
  118. title: '消息中心'
  119. }
  120. },
  121. {
  122. path: '/mine',
  123. name: 'mine',
  124. component: () => import('../views/Mine.vue'),
  125. meta: {
  126. pageType: Page.Every,
  127. menuPage: true,
  128. title: '拉索宇宙'
  129. }
  130. }
  131. ]
  132. },
  133. {
  134. path: '/hall',
  135. name: 'hall',
  136. component: () => import('../views/hall/Detail.vue'),
  137. meta: {
  138. pageType: Page.Every,
  139. menuPage: true,
  140. isHall: true,
  141. title: '拉索宇宙'
  142. }
  143. },
  144. {
  145. path: '/hallEdit',
  146. name: 'hallEdit',
  147. component: () => import('../views/hall/Edit.vue'),
  148. meta: {
  149. pageType: Page.Every,
  150. title: '拉索宇宙',
  151. isHall: true,
  152. tabColor: '#191d27'
  153. }
  154. },
  155. {
  156. path: '/productAdd',
  157. name: 'productAdd',
  158. component: () => import('../views/hall/ProductAdd.vue'),
  159. meta: {
  160. pageType: Page.Every,
  161. title: '拉索宇宙',
  162. isHall: true,
  163. tabColor: '#191d27'
  164. }
  165. },
  166. {
  167. path: '/login',
  168. name: 'userLogin',
  169. component: () => import('../views/account/Login.vue'),
  170. meta: {
  171. pageType: Page.Login,
  172. title: ' ',
  173. tabColor: '#191d27'
  174. }
  175. },
  176. {
  177. path: '/agreement',
  178. name: 'agreement',
  179. component: () => import('../views/account/Agreement.vue'),
  180. meta: {
  181. pageType: Page.Login,
  182. title: '协议'
  183. }
  184. },
  185. {
  186. path: '/register',
  187. name: 'userRegister',
  188. component: () => import('../views/account/Register.vue'),
  189. meta: {
  190. pageType: Page.Login,
  191. title: '注册',
  192. tabColor: '#191d27'
  193. }
  194. },
  195. {
  196. path: '/forget',
  197. name: 'userForget',
  198. component: () => import('../views/account/Forget.vue'),
  199. meta: {
  200. pageType: Page.Login,
  201. // menuPage: true,
  202. title: '忘记密码'
  203. }
  204. },
  205. {
  206. path: '/changePhone',
  207. name: 'changePhone',
  208. component: () => import('../views/account/ChangePhone.vue'),
  209. meta: {
  210. title: '修改密码'
  211. }
  212. },
  213. {
  214. path: '/verified',
  215. name: 'userVerified',
  216. component: () => import('../views/account/Verified.vue'),
  217. meta: {
  218. title: ' '
  219. }
  220. },
  221. {
  222. path: '/verifiedSuc',
  223. name: 'verifiedSuc',
  224. component: () => import('../views/account/VerifiedSuc.vue')
  225. },
  226. {
  227. path: '/verifiedSucs',
  228. name: 'verifiedSucs',
  229. component: () => import('../views/account/VerifiedSucs.vue')
  230. },
  231. {
  232. path: '/Authentication',
  233. name: 'Authentication',
  234. component: () => import('../views/account/Authentication.vue')
  235. },
  236. {
  237. path: '/setting',
  238. name: 'userSetting',
  239. component: () => import('../views/account/Setting.vue')
  240. },
  241. {
  242. path: '/changeText',
  243. name: 'userChangeText',
  244. component: () => import('../views/account/ChangeText.vue')
  245. },
  246. {
  247. path: '/waiting',
  248. name: 'userWaiting',
  249. component: () => import('../views/account/Waiting.vue'),
  250. meta: {
  251. title: ' '
  252. }
  253. },
  254. {
  255. path: '/security',
  256. name: 'security',
  257. component: () => import('../views/account/Security.vue')
  258. },
  259. {
  260. path: '/about',
  261. name: 'about',
  262. component: () => import('../views/account/About.vue'),
  263. meta: {
  264. pageType: Page.Every,
  265. title: ' '
  266. }
  267. },
  268. {
  269. path: '/introduction',
  270. name: 'introduction',
  271. component: () => import('../views/account/Introduction.vue'),
  272. meta: {
  273. pageType: Page.Every,
  274. title: '拉索宇宙'
  275. }
  276. },
  277. {
  278. path: '/question',
  279. name: 'question',
  280. component: () => import('../views/account/Question.vue'),
  281. meta: {
  282. pageType: Page.Every,
  283. title: '拉索宇宙'
  284. }
  285. },
  286. {
  287. path: '/connect',
  288. name: 'connect',
  289. component: () => import('../views/account/Connect.vue'),
  290. meta: {
  291. pageType: Page.Every,
  292. title: ' '
  293. }
  294. },
  295. {
  296. path: '/tradingPassword',
  297. name: 'tradingPassword',
  298. component: () => import('../views/account/TradingPassword.vue')
  299. },
  300. {
  301. path: '/productDetail',
  302. name: 'productDetail',
  303. component: () => import('../views/product/Detail.vue'),
  304. meta: {
  305. pageType: Page.Every,
  306. tabColor: '#191d27'
  307. }
  308. },
  309. {
  310. path: '/collectionGift',
  311. name: 'collectionGift',
  312. component: () => import('../views/product/collectionGift.vue'),
  313. meta: {
  314. pageType: Page.Every,
  315. title: '拉索宇宙'
  316. }
  317. },
  318. {
  319. path: '/giftConfirmation',
  320. name: 'giftConfirmation',
  321. component: () => import('../views/product/giftConfirmation.vue')
  322. // meta: {
  323. // pageType: Page.Every,
  324. // title: '拉索宇宙'
  325. // }
  326. },
  327. // {
  328. // path: '/consignment',
  329. // name: 'consignment',
  330. // component: () => import('../views/product/consignment.vue'),
  331. // meta: {
  332. // pageType: Page.Every,
  333. // title: '拉索宇宙'
  334. // }
  335. // },
  336. {
  337. path: '/productOrderDetails',
  338. name: 'productOrderDetails',
  339. component: () => import('../views/product/orderDetails.vue'),
  340. meta: {
  341. pageType: Page.Every,
  342. menuPage: true,
  343. title: '拉索宇宙',
  344. tabColor: '#191d27'
  345. }
  346. },
  347. {
  348. path: '/productDetail2',
  349. name: 'productDetail2',
  350. component: () => import('../views/product/DetailMode.vue'),
  351. meta: {
  352. pageType: Page.Every,
  353. title: '拉索宇宙'
  354. }
  355. },
  356. {
  357. path: '/productList',
  358. name: 'productList',
  359. component: () => import('../views/product/List.vue'),
  360. meta: {
  361. pageType: Page.Every,
  362. title: '拉索宇宙'
  363. }
  364. },
  365. {
  366. path: '/productSearch',
  367. name: 'productSearch',
  368. component: () => import('../views/product/Search.vue'),
  369. meta: {
  370. pageType: Page.Every,
  371. title: '拉索宇宙'
  372. }
  373. },
  374. {
  375. path: '/creatorDetail',
  376. name: 'creatorDetail',
  377. component: () => import('../views/creator/Detail.vue'),
  378. meta: {
  379. pageType: Page.Every,
  380. title: '拉索宇宙'
  381. }
  382. },
  383. {
  384. path: '/creatorList',
  385. name: 'creatorList',
  386. component: () => import('../views/creator/List.vue'),
  387. meta: {
  388. pageType: Page.Every,
  389. title: '铸造者'
  390. }
  391. },
  392. {
  393. path: '/creatorSearch',
  394. name: 'creatorSearch',
  395. component: () => import('../views/creator/Search.vue'),
  396. meta: {
  397. pageType: Page.Every,
  398. title: '拉索宇宙'
  399. }
  400. },
  401. {
  402. path: '/assetDetail',
  403. name: 'assetDetail',
  404. component: () => import('../views/asset/Detail.vue'),
  405. meta: {
  406. pageType: Page.Every,
  407. title: '拉索宇宙',
  408. tabColor: '#191d27'
  409. }
  410. },
  411. {
  412. path: '/Consignment',
  413. name: 'Consignment',
  414. component: () => import('../views/asset/Consignment.vue'),
  415. meta: {
  416. pageType: Page.Every,
  417. title: '挂售上架'
  418. }
  419. },
  420. {
  421. path: '/ConsignmentSuccess',
  422. name: 'ConsignmentSuccess',
  423. component: () => import('../views/asset/ConsignmentSuccess.vue'),
  424. meta: {
  425. pageType: Page.Every
  426. }
  427. },
  428. {
  429. path: '/consignmentAgreement',
  430. name: 'consignmentAgreement',
  431. component: () => import('../views/asset/Agreement.vue'),
  432. meta: {
  433. pageType: Page.Every,
  434. title: '拉索宇宙'
  435. }
  436. },
  437. {
  438. path: '/assetSearch',
  439. name: 'assetSearch',
  440. component: () => import('../views/asset/Search.vue'),
  441. meta: {
  442. title: '拉索宇宙'
  443. }
  444. },
  445. {
  446. path: '/giveSearch',
  447. name: 'giveSearch',
  448. component: () => import('../views/asset/GiveSearch.vue'),
  449. meta: {
  450. title: '拉索宇宙'
  451. }
  452. },
  453. {
  454. path: '/submit',
  455. name: 'submit',
  456. component: () => import('../views/Submit.vue'),
  457. meta: {
  458. title: '我的订单'
  459. }
  460. },
  461. {
  462. path: '/couponList',
  463. name: 'couponList',
  464. component: () => import('../views/order/CouponList.vue'),
  465. meta: {
  466. title: '拉索宇宙'
  467. }
  468. },
  469. {
  470. path: '/givesubmit',
  471. name: 'givesubmit',
  472. component: () => import('../views/Givesubmit.vue'),
  473. meta: {
  474. title: 'GAS费用'
  475. }
  476. },
  477. {
  478. path: '/creatorDetail',
  479. name: 'creatorDetail',
  480. component: () => import('../views/creator/Detail.vue'),
  481. meta: {
  482. pageType: Page.Every,
  483. title: '拉索宇宙'
  484. }
  485. },
  486. {
  487. path: '/orders',
  488. name: 'orders',
  489. component: () => import('../views/order/Orders.vue'),
  490. meta: {
  491. title: '我的订单'
  492. }
  493. },
  494. {
  495. path: '/orderDetail',
  496. name: 'orderDetail',
  497. component: () => import('../views/order/Detail.vue'),
  498. meta: {
  499. title: '订单详情'
  500. }
  501. },
  502. {
  503. path: '/activityOrders',
  504. name: 'activityOrders',
  505. component: () => import('../views/order/ActivityOrders.vue'),
  506. meta: {
  507. title: '拉索宇宙'
  508. }
  509. },
  510. {
  511. path: '/activityOrderDetail',
  512. name: 'activityOrderDetail',
  513. component: () => import('../views/order/ActivityDetail.vue'),
  514. meta: {
  515. title: '拉索宇宙'
  516. }
  517. },
  518. {
  519. path: '/activityList',
  520. name: 'activityList',
  521. component: () => import('../views/activity/List1.vue'),
  522. meta: {
  523. pageType: Page.Every,
  524. title: '拉索宇宙',
  525. tabColor: '#191d27'
  526. }
  527. },
  528. {
  529. path: '/activityDetail',
  530. name: 'activityDetail',
  531. component: () => import('../views/activity/Detail1.vue'),
  532. meta: {
  533. pageType: Page.Every,
  534. title: '拉索宇宙',
  535. tabColor: '#191d27'
  536. }
  537. },
  538. {
  539. path: '/activitySubmit',
  540. name: 'activitySubmit',
  541. component: () => import('../views/activity/Submit.vue'),
  542. meta: {
  543. title: '拉索宇宙'
  544. }
  545. },
  546. {
  547. path: '/chooseProduct',
  548. name: 'chooseProduct',
  549. component: () => import('../views/activity/ChooseProduct.vue'),
  550. meta: {
  551. title: '拉索宇宙',
  552. needBack: true
  553. }
  554. },
  555. {
  556. path: '/mineFollows',
  557. name: 'mineFollows',
  558. component: () => import('../views/user/Follows.vue'),
  559. meta: {
  560. title: '拉索宇宙'
  561. }
  562. },
  563. {
  564. path: '/mineLove',
  565. name: 'mineLove',
  566. component: () => import('../views/user/myLove.vue'),
  567. meta: {
  568. title: '拉索宇宙'
  569. }
  570. },
  571. {
  572. path: '/authenticationStatus',
  573. name: 'authenticationStatus',
  574. component: () => import('../views/user/authenticationStatus.vue'),
  575. meta: {
  576. title: '拉索宇宙'
  577. }
  578. },
  579. {
  580. path: '/mineBanks',
  581. name: 'mineBanks',
  582. component: () => import('../views/user/Banks.vue'),
  583. meta: {
  584. title: '我的银行卡'
  585. }
  586. },
  587. {
  588. path: '/mineBanksAdd',
  589. name: 'mineBanksAdd',
  590. component: () => import('../views/user/BanksAdd.vue'),
  591. meta: {}
  592. },
  593. {
  594. path: '/mineAddress',
  595. name: 'mineAddress',
  596. component: () => import('../views/user/Address.vue'),
  597. meta: {
  598. title: '拉索宇宙'
  599. }
  600. },
  601. {
  602. path: '/mineMyOrder',
  603. name: 'mineMyOrder',
  604. component: () => import('../views/user/myOrder.vue'),
  605. meta: {
  606. title: '拉索宇宙'
  607. }
  608. },
  609. {
  610. path: '/mineWallet',
  611. name: 'mineWallet',
  612. component: () => import('../views/user/Wallet.vue'),
  613. meta: {
  614. title: '拉索宇宙'
  615. }
  616. },
  617. {
  618. path: '/mineBankCard',
  619. name: 'mineBankCard',
  620. component: () => import('../views/user/bankCard.vue'),
  621. meta: {
  622. title: '拉索宇宙'
  623. }
  624. },
  625. {
  626. path: '/mineExchange',
  627. name: 'mineExchange',
  628. component: () => import('../views/user/Exchange.vue'),
  629. meta: {
  630. title: '藏品记录'
  631. }
  632. },
  633. {
  634. path: '/mineAccountSecurity',
  635. name: 'mineAccountSecurity',
  636. component: () => import('../views/user/accountSecurity.vue'),
  637. meta: {
  638. title: '拉索宇宙'
  639. }
  640. },
  641. {
  642. path: '/realName',
  643. name: 'realName',
  644. component: () => import('../views/user/realName.vue'),
  645. meta: {
  646. title: '拉索宇宙'
  647. }
  648. }
  649. ];
  650. const router = createRouter({
  651. history: process.env.VUE_APP_CORDOVA === 'true' ?
  652. createWebHashHistory() : createWebHistory(process.env.VUE_APP_PUBLIC_PATH),
  653. routes,
  654. scrollBehavior(to, from, savedPosition) {
  655. return {
  656. x: 0,
  657. y: 0
  658. };
  659. }
  660. });
  661. router.beforeEach((to, from, next) => {
  662. if (/^\/http/.test(to.path)) {
  663. let url = to.path.replace('/', '');
  664. let params = [];
  665. if (to.query) {
  666. for (let key in to.query) {
  667. // eslint-disable-next-line no-prototype-builtins
  668. if (to.query.hasOwnProperty(key)) {
  669. params.push(`${key}=${to.query[key]}`);
  670. }
  671. }
  672. }
  673. if (params.length > 0) {
  674. url += `?${params.join('&')}`;
  675. }
  676. window.open(url);
  677. return;
  678. }
  679. if (to.query.invitor) {
  680. sessionStorage.setItem('invitor', to.query.invitor);
  681. }
  682. if (to.meta.pageType != Page.Every && to.path !== '/collectionDetail' && to.path !== '/castingDetail') {
  683. if (!store.state.userInfo && to.meta.pageType !== Page.Login) {
  684. store
  685. .dispatch('getUserInfo')
  686. .then(() => {
  687. next(backNext(to));
  688. })
  689. .catch(() => {
  690. Dialog.confirm({
  691. title: '提示',
  692. message: '用户未登录,是否立即登录'
  693. })
  694. .then(() => {
  695. let url = '/login';
  696. if (to.meta.needBack) {
  697. console.log(to)
  698. store.commit('setLoginBackUrl', to.fullPath);
  699. }
  700. next('/login');
  701. })
  702. .catch(() => {
  703. next(false);
  704. });
  705. });
  706. } else {
  707. next(backNext(to));
  708. }
  709. } else {
  710. next(backNext(to));
  711. !!store.state.userInfo || store.dispatch('getUserInfo');
  712. }
  713. });
  714. router.afterEach((to, from) => {
  715. jsapiSign();
  716. });
  717. function backNext(to) {
  718. if (to.path === '/collectionDetail') {
  719. to.path = '/productDetail';
  720. return to;
  721. } else if (to.path === '/castingDetail') {
  722. to.path = '/creatorDetail';
  723. return to;
  724. } else {
  725. return;
  726. }
  727. }
  728. export default router;