App.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852
  1. <script>
  2. /** copyright *** slodon *** version-v2.9.1 *** date-2021-07-06 ***主版本v2.9**/
  3. import {
  4. mapMutations, mapState
  5. } from 'vuex';
  6. export default {
  7. globalData: {
  8. goLogin() {
  9. uni.showModal({
  10. title: '提示',
  11. content: '请登录',
  12. success: res => {
  13. if (res.confirm) {
  14. const page = getCurrentPages();
  15. let url = page[page.length - 1].route;
  16. const options = page[page.length - 1].options;
  17. for (let i in options) {
  18. if (url.indexOf('?') > -1) {
  19. url += `&${i}=${options[i]}`;
  20. } else {
  21. url += `?${i}=${options[i]}`;
  22. }
  23. }
  24. url = '/' + url;
  25. uni.setStorageSync('fromurl', url);
  26. uni.navigateTo({
  27. url: '/pages/public/login'
  28. });
  29. }
  30. }
  31. });
  32. },
  33. apiUrl: 'https://jbbcdev.slodon.cn/', //测试环境接口地址 测试站
  34. // imgUrl:'https://images.slodon.cn/java/bbc/mobile/',//静态资源地址——线上开发
  35. imgUrl: '/static/local/',//静态资源地址——本地开发
  36. h5AppId: 'wx9019a5f5fb0a0844',//微商城appid
  37. cateId: '', //首页分类更多跳转分类页对应分类参数
  38. chatUrl: 'wss://jbbcdevim.slodon.cn',//客服地址
  39. uploadMaxSize: 20,//上传最大限制,以M为单位
  40. curLang: 'zh',//当前语言,zh:中文,若为其他语言,需要对应/static/language下面的文件名
  41. },//全局配置
  42. computed: {
  43. ...mapState(['hasLogin', 'userInfo', 'userCenterData'])
  44. },
  45. methods: {
  46. ...mapMutations(['login', 'logout', 'setUserCenterData']),
  47. //更新access_token
  48. updateAccessToken() {
  49. //验证token是超过1天的话,需要用refresh_token去重新获取token
  50. if (this.hasLogin) {
  51. let cur_time = Date.parse(new Date());
  52. if (true) {
  53. // 需要根据refresh_token更新token
  54. this.$request({
  55. url: 'v3/frontLogin/oauth/token',
  56. data: {
  57. grant_type: 'refresh_token',
  58. refresh_token: this.userInfo.refresh_token,
  59. },
  60. method: 'POST'
  61. }).then(res => {
  62. if (res.state == 200) {
  63. //更新token
  64. this.userInfo.access_token = res.data.access_token;
  65. this.userInfo.loginTime = Date.parse(new Date());
  66. this.login(this.userInfo);
  67. } else if (res.state == 255) {
  68. //清空所有的数据 store里面和本地缓存
  69. this.logout();
  70. } else {
  71. //提示登录
  72. uni.showModal({
  73. title: '温馨提示!',
  74. content: '您需要先登录',
  75. success: function (res) {
  76. if (res.confirm) {
  77. uni.navigateTo({
  78. url: '/pages/public/login'
  79. })
  80. } else if (res.cancel) {
  81. uni.navigateBack();//返回上级页面
  82. }
  83. }
  84. });
  85. }
  86. }).catch((e) => {
  87. //异常处理
  88. })
  89. }
  90. }
  91. },
  92. //判断当前时间是否为今天 并且不是第二天
  93. isToday(data) {
  94. return (new Date().toDateString() === data.toDateString()) && (Date.parse(data) < Date.parse(new Date(new Date().setHours(23, 59, 59, 59))));
  95. },
  96. },
  97. onLaunch: function () {
  98. let userInfo = uni.getStorageSync('userInfo') || '';
  99. if (userInfo.access_token) {
  100. //更新登陆状态
  101. uni.getStorage({
  102. key: 'userInfo',
  103. success: (res) => {
  104. this.login(res.data);
  105. this.setUserCenterData(uni.getStorageSync('userCenterData'))
  106. }
  107. });
  108. }
  109. uni.getSystemInfo({
  110. success: res => {
  111. this.globalData.systemInfo = res;
  112. this.globalData.bottomSateArea = 0; //手机底部安全区域高度
  113. this.globalData.model = res.model;
  114. this.globalData.titleBarHeight = 44; //原生的标题高度
  115. let iphoneXArr = ["iPhone X", "iPhone 11", "iPhone 11 Pro Max", "iPhone XR", "iPhoneXS"]; //iphone手机底部一条黑线
  116. if (iphoneXArr.indexOf(res.model) != -1) {
  117. this.globalData.bottomSateArea = "30rpx";
  118. }
  119. // if (res.model.indexOf('iPhone XR') != -1) {
  120. // this.globalData.bottomSateArea = "30rpx";
  121. // }
  122. this.globalData.statusBarHeight = res.statusBarHeight;
  123. }
  124. }); // 联到家定位缓存
  125. },
  126. onShow: function () {
  127. this.updateAccessToken();
  128. setInterval(function () {
  129. let data = new Date();
  130. let isToday = (new Date().toDateString() === data.toDateString()) && (Date.parse(data) < Date.parse(new Date(new Date().setHours(23, 59, 59, 59)))); //判断当前时间是否为今天并且不为第二天
  131. if (!isToday) {
  132. uni.removeSavedFile({
  133. key: 'cookie'
  134. })
  135. }
  136. }, 1000);
  137. },
  138. onHide: function () {
  139. },
  140. }
  141. </script>
  142. <style lang='scss'>
  143. /*
  144. 全局体图标——阿里巴巴图标库
  145. */
  146. @import './common/css/icons.css';
  147. /*
  148. 全局公共样式
  149. */
  150. @import './common/css/base.css';
  151. /*
  152. 全局公共样式和字体图标
  153. */
  154. @font-face {
  155. font-family: yticon;
  156. font-weight: normal;
  157. font-style: normal;
  158. src: url('https://at.alicdn.com/t/font_1078604_w4kpxh0rafi.ttf') format('truetype');
  159. }
  160. /* 微信浏览器分享提示 start */
  161. .wx_brower_share_mask {
  162. width: 750rpx;
  163. height: 100vh;
  164. background-color: rgba(0, 0, 0, 0.45);
  165. position: fixed;
  166. z-index: 99999;
  167. top: 0;
  168. }
  169. /* #ifdef H5 */
  170. page {
  171. width: 750rpx;
  172. margin: 0 auto;
  173. }
  174. /* #endif */
  175. .wx_brower_share_top_wrap {
  176. width: 100%;
  177. height: 100%;
  178. display: flex;
  179. justify-content: flex-end;
  180. align-items: flex-start;
  181. margin-top: 150rpx;
  182. }
  183. .wx_brower_share_top_wrap .wx_brower_share_img {
  184. width: 450rpx;
  185. height: 150rpx;
  186. margin-right: 80rpx;
  187. }
  188. .share_h5 {
  189. width: 100% !important;
  190. height: 100% !important
  191. }
  192. uni-image>img {
  193. opacity: unset;
  194. object-fit: contain;
  195. }
  196. .share_h5_operate_img {
  197. width: 440rpx !important;
  198. height: 120rpx !important;
  199. }
  200. .share_h5_close_img {
  201. width: 50rpx !important;
  202. height: 50rpx !important;
  203. }
  204. .share_h5_img_bottom {
  205. width: 50rpx !important;
  206. height: 200rpx !important;
  207. }
  208. /* 微信浏览器分享提示 end */
  209. .yticon {
  210. font-family: "yticon" !important;
  211. font-size: 16px;
  212. font-style: normal;
  213. -webkit-font-smoothing: antialiased;
  214. -moz-osx-font-smoothing: grayscale;
  215. }
  216. /* #ifdef MP-WEIXIN */
  217. .ql-container {
  218. display: flex;
  219. align-items: center;
  220. line-height: 62rpx;
  221. }
  222. /* #endif */
  223. .ql-editor {
  224. p {
  225. display: flex;
  226. align-items: center;
  227. flex-wrap: wrap;
  228. line-height: 62rpx !important;
  229. }
  230. }
  231. .ql-editor.ql-blank::before {
  232. color: rgba(0, 0, 0, 0.6);
  233. content: attr(data-placeholder);
  234. font-style: normal !important;
  235. pointer-events: none;
  236. position: absolute;
  237. line-height: 62rpx !important;
  238. }
  239. .icon-yiguoqi1:before {
  240. content: "\e700";
  241. }
  242. .icon-iconfontshanchu1:before {
  243. content: "\e619";
  244. }
  245. .icon-iconfontweixin:before {
  246. content: "\e611";
  247. }
  248. .icon-alipay:before {
  249. content: "\e636";
  250. }
  251. .icon-shang:before {
  252. content: "\e624";
  253. }
  254. .icon-shouye:before {
  255. content: "\e626";
  256. }
  257. .icon-shanchu4:before {
  258. content: "\e622";
  259. }
  260. .icon-xiaoxi:before {
  261. content: "\e618";
  262. }
  263. .icon-jiantour-copy:before {
  264. content: "\e600";
  265. }
  266. .icon-fenxiang2:before {
  267. content: "\e61e";
  268. }
  269. .icon-pingjia:before {
  270. content: "\e67b";
  271. }
  272. .icon-daifukuan:before {
  273. content: "\e68f";
  274. }
  275. .icon-pinglun-copy:before {
  276. content: "\e612";
  277. }
  278. .icon-dianhua-copy:before {
  279. content: "\e621";
  280. }
  281. .icon-shoucang:before {
  282. content: "\e645";
  283. }
  284. .icon-xuanzhong2:before {
  285. content: "\e62f";
  286. }
  287. .icon-gouwuche_:before {
  288. content: "\e630";
  289. }
  290. .icon-icon-test:before {
  291. content: "\e60c";
  292. }
  293. .icon-icon-test1:before {
  294. content: "\e632";
  295. }
  296. .icon-bianji:before {
  297. content: "\e646";
  298. }
  299. .icon-jiazailoading-A:before {
  300. content: "\e8fc";
  301. }
  302. .icon-zuoshang:before {
  303. content: "\e613";
  304. }
  305. .icon-jia2:before {
  306. content: "\e60a";
  307. }
  308. .icon-huifu:before {
  309. content: "\e68b";
  310. }
  311. .icon-sousuo:before {
  312. content: "\e7ce";
  313. }
  314. .icon-arrow-fine-up:before {
  315. content: "\e601";
  316. }
  317. .icon-hot:before {
  318. content: "\e60e";
  319. }
  320. .icon-lishijilu:before {
  321. content: "\e6b9";
  322. }
  323. .icon-zhengxinchaxun-zhifubaoceping-:before {
  324. content: "\e616";
  325. }
  326. .icon-naozhong:before {
  327. content: "\e64a";
  328. }
  329. .icon-xiatubiao--copy:before {
  330. content: "\e608";
  331. }
  332. .icon-shoucang_xuanzhongzhuangtai:before {
  333. content: "\e6a9";
  334. }
  335. .icon-jia1:before {
  336. content: "\e61c";
  337. }
  338. .icon-bangzhu1:before {
  339. content: "\e63d";
  340. }
  341. .icon-arrow-left-bottom:before {
  342. content: "\e602";
  343. }
  344. .icon-arrow-right-bottom:before {
  345. content: "\e603";
  346. }
  347. .icon-arrow-left-top:before {
  348. content: "\e604";
  349. }
  350. .icon-icon--:before {
  351. content: "\e744";
  352. }
  353. .icon-zuojiantou-up:before {
  354. content: "\e605";
  355. }
  356. .icon-xia:before {
  357. content: "\e62d";
  358. }
  359. .icon--jianhao:before {
  360. content: "\e60b";
  361. }
  362. .icon-weixinzhifu:before {
  363. content: "\e61a";
  364. }
  365. .icon-comment:before {
  366. content: "\e64f";
  367. }
  368. .icon-weixin:before {
  369. content: "\e61f";
  370. }
  371. .icon-fenlei1:before {
  372. content: "\e620";
  373. }
  374. .icon-erjiye-yucunkuan:before {
  375. content: "\e623";
  376. }
  377. .icon-Group-:before {
  378. content: "\e688";
  379. }
  380. .icon-you:before {
  381. content: "\e606";
  382. }
  383. .icon-forward:before {
  384. content: "\e607";
  385. }
  386. .icon-tuijian:before {
  387. content: "\e610";
  388. }
  389. .icon-bangzhu:before {
  390. content: "\e679";
  391. }
  392. .icon-share:before {
  393. content: "\e656";
  394. }
  395. .icon-yiguoqi:before {
  396. content: "\e997";
  397. }
  398. .icon-shezhi1:before {
  399. content: "\e61d";
  400. }
  401. .icon-fork:before {
  402. content: "\e61b";
  403. }
  404. .icon-kafei:before {
  405. content: "\e66a";
  406. }
  407. .icon-iLinkapp-:before {
  408. content: "\e654";
  409. }
  410. .icon-saomiao:before {
  411. content: "\e60d";
  412. }
  413. .icon-shezhi:before {
  414. content: "\e60f";
  415. }
  416. .icon-shouhoutuikuan:before {
  417. content: "\e631";
  418. }
  419. .icon-gouwuche:before {
  420. content: "\e609";
  421. }
  422. .icon-dizhi:before {
  423. content: "\e614";
  424. }
  425. .icon-fenlei:before {
  426. content: "\e706";
  427. }
  428. .icon-xingxing:before {
  429. content: "\e70b";
  430. }
  431. .icon-tuandui:before {
  432. content: "\e633";
  433. }
  434. .icon-zuanshi:before {
  435. content: "\e615";
  436. }
  437. .icon-zuo:before {
  438. content: "\e63c";
  439. }
  440. .icon-shoucang2:before {
  441. content: "\e62e";
  442. }
  443. .icon-shouhuodizhi:before {
  444. content: "\e712";
  445. }
  446. .icon-yishouhuo:before {
  447. content: "\e71a";
  448. }
  449. .icon-dianzan-ash:before {
  450. content: "\e617";
  451. }
  452. view,
  453. scroll-view,
  454. swiper,
  455. swiper-item,
  456. cover-view,
  457. cover-image,
  458. icon,
  459. text,
  460. rich-text,
  461. progress,
  462. button,
  463. checkbox,
  464. form,
  465. input,
  466. label,
  467. radio,
  468. slider,
  469. switch,
  470. textarea,
  471. navigator,
  472. audio,
  473. camera,
  474. image,
  475. video {
  476. box-sizing: border-box;
  477. }
  478. /* 骨架屏替代方案 */
  479. .Skeleton {
  480. background: #f3f3f3;
  481. padding: 20upx 0;
  482. border-radius: 8upx;
  483. }
  484. /* 图片载入替代方案 */
  485. .image-wrapper {
  486. font-size: 0;
  487. background: #f3f3f3;
  488. border-radius: 4px;
  489. image {
  490. width: 100%;
  491. height: 100%;
  492. transition: .6s;
  493. opacity: 0;
  494. &.loaded {
  495. opacity: 1;
  496. }
  497. }
  498. }
  499. .clamp {
  500. overflow: hidden;
  501. text-overflow: ellipsis;
  502. white-space: nowrap;
  503. display: block;
  504. }
  505. .common-hover {
  506. background: #f5f5f5;
  507. }
  508. /*边框*/
  509. .b-b:after,
  510. .b-t:after {
  511. position: absolute;
  512. z-index: 3;
  513. left: 0;
  514. right: 0;
  515. height: 0;
  516. content: '';
  517. transform: scaleY(.5);
  518. border-bottom: 1rpx solid rgba(0, 0, 0, .1);
  519. }
  520. /*边框*/
  521. .b_b:after,
  522. .b_t:after {
  523. position: absolute;
  524. z-index: 3;
  525. left: 0;
  526. right: 0;
  527. height: 0;
  528. content: '';
  529. transform: scaleY(.5);
  530. border-bottom: 1rpx solid rgba(0, 0, 0, .1);
  531. }
  532. .b_b:after {
  533. bottom: 0;
  534. }
  535. .b_t:after {
  536. top: 0;
  537. }
  538. .b-b:after {
  539. bottom: 0;
  540. }
  541. .b-t:after {
  542. top: 0;
  543. }
  544. /* button样式改写 */
  545. uni-button,
  546. button {
  547. height: 80upx;
  548. line-height: 80upx;
  549. font-size: $font-lg + 2upx;
  550. font-weight: normal;
  551. &.no-border:before,
  552. &.no-border:after {
  553. border: 0;
  554. }
  555. }
  556. uni-button[type=default],
  557. button[type=default] {
  558. color: $font-color-dark;
  559. }
  560. /* input 样式 */
  561. .input-placeholder {
  562. color: #999999;
  563. }
  564. .placeholder {
  565. color: #949494;
  566. font-size: 26rpx;
  567. }
  568. ::-webkit-scrollbar {
  569. display: none;
  570. width: 0;
  571. height: 0;
  572. color: transparent;
  573. display: flex;
  574. justify-content: center;
  575. }
  576. uni-tabbar .uni-tabbar {
  577. -webkit-box-shadow: 0 -2px 7px 0 hsla(0, 0%, 89.8%, .5);
  578. box-shadow: 0 -2px 7px 0 hsla(0, 0%, 89.8%, .5);
  579. width: 750rpx !important;
  580. left: auto !important;
  581. right: auto !important;
  582. }
  583. uni-tabbar {
  584. right: 0;
  585. display: flex;
  586. justify-content: center;
  587. }
  588. uni-page-head .uni-page-head {
  589. width: 750rpx !important;
  590. left: auto !important;
  591. right: auto !important;
  592. }
  593. uni-page-head {
  594. display: flex !important;
  595. justify-content: center;
  596. }
  597. body {
  598. font-family: "PingFangSC-Regular", "Microsoft YaHei", "Helvetica", "Droid Sans", "Arial", "sans-serif";
  599. }
  600. * {
  601. -webkit-font-smoothing: subpixel-antialiased
  602. }
  603. /* 商品详情页 H5 图文详情强制换行处理 start */
  604. /* #ifdef H5 */
  605. .detail-desc p {
  606. word-break: break-all;
  607. }
  608. /* #endif */
  609. /* 商品详情页 H5 图文详情强制换行处理 end */
  610. .uni-page-head .uni-page-head-ft .uni-page-head-btn .uni-btn-icon {
  611. font-size: 40rpx;
  612. margin-right: 15rpx;
  613. }
  614. .uni-popup.spec_model.bottom .uni-transition.fade-out {
  615. width: 750rpx;
  616. right: 0;
  617. left: 0;
  618. margin: 0 auto;
  619. }
  620. .uni-picker-container,
  621. .uni-picker-toggle,
  622. .uni-picker-toggle {
  623. width: 750rpx !important;
  624. left: 0 !important;
  625. right: 0 !important;
  626. margin: 0 auto !important;
  627. }
  628. .uni-popup .fade-out {
  629. width: 750rpx;
  630. margin: 0 auto;
  631. }
  632. .select_address .content_view {
  633. width: 750rpx;
  634. margin: 0 auto;
  635. }
  636. /* 分页loading */
  637. .loading {
  638. display: flex;
  639. align-items: center;
  640. justify-content: center;
  641. height: 80rpx;
  642. font-size: 24rpx;
  643. color: #999;
  644. }
  645. .spinner {
  646. display: inline-block;
  647. vertical-align: middle;
  648. margin-right: 20rpx;
  649. font-size: 26rpx;
  650. width: 26rpx;
  651. height: 26rpx;
  652. text-align: left;
  653. border-radius: 50%;
  654. box-shadow: inset 0 0 0 3rpx rgba(58, 168, 237, .3);
  655. }
  656. .spinner text {
  657. position: absolute;
  658. clip: rect(0, 26rpx, 26rpx, 13rpx);
  659. width: 26rpx;
  660. height: 26rpx;
  661. animation: spinner-circle-clipper 1s ease-in-out infinite;
  662. -webkit-animation: spinner-circle-clipper 1s ease-in-out infinite;
  663. }
  664. @keyframes spinner-circle-clipper {
  665. 0% {
  666. transform: rotate(0deg);
  667. }
  668. 100% {
  669. transform: rotate(180deg);
  670. }
  671. }
  672. @-webkit-keyframes spinner-circle-clipper {
  673. 0% {
  674. -webkit-transform: rotate(0deg);
  675. }
  676. 100% {
  677. -webkit-transform: rotate(180deg);
  678. }
  679. }
  680. .spinner text:after {
  681. position: absolute;
  682. clip: rect(0, 26rpx, 26rpx, 13rpx);
  683. width: 26rpx;
  684. height: 26rpx;
  685. content: '';
  686. animation: spinner-circle 1s ease-in-out infinite;
  687. -webkit-animation: spinner-circle 1s ease-in-out infinite;
  688. border-radius: 50%;
  689. box-shadow: inset 0 0 0 3rpx #3aa8ed;
  690. }
  691. @keyframes spinner-circle {
  692. 0% {
  693. transform: rotate(-180deg);
  694. }
  695. 100% {
  696. transform: rotate(180deg);
  697. }
  698. }
  699. @-webkit-keyframes spinner-circle {
  700. 0% {
  701. -webkit-transform: rotate(-180deg);
  702. }
  703. 100% {
  704. -webkit-transform: rotate(180deg);
  705. }
  706. }
  707. </style>