123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852 |
- <script>
- /** copyright *** slodon *** version-v2.9.1 *** date-2021-07-06 ***主版本v2.9**/
- import {
- mapMutations, mapState
- } from 'vuex';
- export default {
- globalData: {
- goLogin() {
- uni.showModal({
- title: '提示',
- content: '请登录',
- success: res => {
- if (res.confirm) {
- const page = getCurrentPages();
- let url = page[page.length - 1].route;
- const options = page[page.length - 1].options;
- for (let i in options) {
- if (url.indexOf('?') > -1) {
- url += `&${i}=${options[i]}`;
- } else {
- url += `?${i}=${options[i]}`;
- }
- }
- url = '/' + url;
- uni.setStorageSync('fromurl', url);
- uni.navigateTo({
- url: '/pages/public/login'
- });
- }
- }
- });
- },
- apiUrl: 'https://jbbcdev.slodon.cn/', //测试环境接口地址 测试站
- // imgUrl:'https://images.slodon.cn/java/bbc/mobile/',//静态资源地址——线上开发
- imgUrl: '/static/local/',//静态资源地址——本地开发
- h5AppId: 'wx9019a5f5fb0a0844',//微商城appid
- cateId: '', //首页分类更多跳转分类页对应分类参数
-
- chatUrl: 'wss://jbbcdevim.slodon.cn',//客服地址
- uploadMaxSize: 20,//上传最大限制,以M为单位
- curLang: 'zh',//当前语言,zh:中文,若为其他语言,需要对应/static/language下面的文件名
- },//全局配置
- computed: {
- ...mapState(['hasLogin', 'userInfo', 'userCenterData'])
- },
- methods: {
- ...mapMutations(['login', 'logout', 'setUserCenterData']),
- //更新access_token
- updateAccessToken() {
- //验证token是超过1天的话,需要用refresh_token去重新获取token
- if (this.hasLogin) {
- let cur_time = Date.parse(new Date());
- if (true) {
- // 需要根据refresh_token更新token
- this.$request({
- url: 'v3/frontLogin/oauth/token',
- data: {
- grant_type: 'refresh_token',
- refresh_token: this.userInfo.refresh_token,
- },
- method: 'POST'
- }).then(res => {
- if (res.state == 200) {
- //更新token
- this.userInfo.access_token = res.data.access_token;
- this.userInfo.loginTime = Date.parse(new Date());
- this.login(this.userInfo);
- } else if (res.state == 255) {
- //清空所有的数据 store里面和本地缓存
- this.logout();
- } else {
- //提示登录
- uni.showModal({
- title: '温馨提示!',
- content: '您需要先登录',
- success: function (res) {
- if (res.confirm) {
- uni.navigateTo({
- url: '/pages/public/login'
- })
- } else if (res.cancel) {
- uni.navigateBack();//返回上级页面
- }
- }
- });
- }
- }).catch((e) => {
- //异常处理
- })
- }
- }
- },
- //判断当前时间是否为今天 并且不是第二天
- isToday(data) {
- return (new Date().toDateString() === data.toDateString()) && (Date.parse(data) < Date.parse(new Date(new Date().setHours(23, 59, 59, 59))));
- },
- },
- onLaunch: function () {
- let userInfo = uni.getStorageSync('userInfo') || '';
- if (userInfo.access_token) {
- //更新登陆状态
- uni.getStorage({
- key: 'userInfo',
- success: (res) => {
- this.login(res.data);
- this.setUserCenterData(uni.getStorageSync('userCenterData'))
- }
- });
- }
- uni.getSystemInfo({
- success: res => {
- this.globalData.systemInfo = res;
- this.globalData.bottomSateArea = 0; //手机底部安全区域高度
- this.globalData.model = res.model;
- this.globalData.titleBarHeight = 44; //原生的标题高度
- let iphoneXArr = ["iPhone X", "iPhone 11", "iPhone 11 Pro Max", "iPhone XR", "iPhoneXS"]; //iphone手机底部一条黑线
- if (iphoneXArr.indexOf(res.model) != -1) {
- this.globalData.bottomSateArea = "30rpx";
- }
- // if (res.model.indexOf('iPhone XR') != -1) {
- // this.globalData.bottomSateArea = "30rpx";
- // }
- this.globalData.statusBarHeight = res.statusBarHeight;
- }
- }); // 联到家定位缓存
- },
- onShow: function () {
- this.updateAccessToken();
- setInterval(function () {
- let data = new Date();
- let isToday = (new Date().toDateString() === data.toDateString()) && (Date.parse(data) < Date.parse(new Date(new Date().setHours(23, 59, 59, 59)))); //判断当前时间是否为今天并且不为第二天
- if (!isToday) {
- uni.removeSavedFile({
- key: 'cookie'
- })
- }
- }, 1000);
- },
- onHide: function () {
- },
- }
- </script>
- <style lang='scss'>
- /*
- 全局体图标——阿里巴巴图标库
- */
- @import './common/css/icons.css';
- /*
- 全局公共样式
- */
- @import './common/css/base.css';
- /*
- 全局公共样式和字体图标
- */
- @font-face {
- font-family: yticon;
- font-weight: normal;
- font-style: normal;
- src: url('https://at.alicdn.com/t/font_1078604_w4kpxh0rafi.ttf') format('truetype');
- }
- /* 微信浏览器分享提示 start */
- .wx_brower_share_mask {
- width: 750rpx;
- height: 100vh;
- background-color: rgba(0, 0, 0, 0.45);
- position: fixed;
- z-index: 99999;
- top: 0;
- }
- /* #ifdef H5 */
- page {
- width: 750rpx;
- margin: 0 auto;
- }
- /* #endif */
- .wx_brower_share_top_wrap {
- width: 100%;
- height: 100%;
- display: flex;
- justify-content: flex-end;
- align-items: flex-start;
- margin-top: 150rpx;
- }
- .wx_brower_share_top_wrap .wx_brower_share_img {
- width: 450rpx;
- height: 150rpx;
- margin-right: 80rpx;
- }
- .share_h5 {
- width: 100% !important;
- height: 100% !important
- }
- uni-image>img {
- opacity: unset;
- object-fit: contain;
- }
- .share_h5_operate_img {
- width: 440rpx !important;
- height: 120rpx !important;
- }
- .share_h5_close_img {
- width: 50rpx !important;
- height: 50rpx !important;
- }
- .share_h5_img_bottom {
- width: 50rpx !important;
- height: 200rpx !important;
- }
- /* 微信浏览器分享提示 end */
- .yticon {
- font-family: "yticon" !important;
- font-size: 16px;
- font-style: normal;
- -webkit-font-smoothing: antialiased;
- -moz-osx-font-smoothing: grayscale;
- }
- /* #ifdef MP-WEIXIN */
- .ql-container {
- display: flex;
- align-items: center;
- line-height: 62rpx;
- }
- /* #endif */
- .ql-editor {
- p {
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- line-height: 62rpx !important;
- }
- }
- .ql-editor.ql-blank::before {
- color: rgba(0, 0, 0, 0.6);
- content: attr(data-placeholder);
- font-style: normal !important;
- pointer-events: none;
- position: absolute;
- line-height: 62rpx !important;
- }
- .icon-yiguoqi1:before {
- content: "\e700";
- }
- .icon-iconfontshanchu1:before {
- content: "\e619";
- }
- .icon-iconfontweixin:before {
- content: "\e611";
- }
- .icon-alipay:before {
- content: "\e636";
- }
- .icon-shang:before {
- content: "\e624";
- }
- .icon-shouye:before {
- content: "\e626";
- }
- .icon-shanchu4:before {
- content: "\e622";
- }
- .icon-xiaoxi:before {
- content: "\e618";
- }
- .icon-jiantour-copy:before {
- content: "\e600";
- }
- .icon-fenxiang2:before {
- content: "\e61e";
- }
- .icon-pingjia:before {
- content: "\e67b";
- }
- .icon-daifukuan:before {
- content: "\e68f";
- }
- .icon-pinglun-copy:before {
- content: "\e612";
- }
- .icon-dianhua-copy:before {
- content: "\e621";
- }
- .icon-shoucang:before {
- content: "\e645";
- }
- .icon-xuanzhong2:before {
- content: "\e62f";
- }
- .icon-gouwuche_:before {
- content: "\e630";
- }
- .icon-icon-test:before {
- content: "\e60c";
- }
- .icon-icon-test1:before {
- content: "\e632";
- }
- .icon-bianji:before {
- content: "\e646";
- }
- .icon-jiazailoading-A:before {
- content: "\e8fc";
- }
- .icon-zuoshang:before {
- content: "\e613";
- }
- .icon-jia2:before {
- content: "\e60a";
- }
- .icon-huifu:before {
- content: "\e68b";
- }
- .icon-sousuo:before {
- content: "\e7ce";
- }
- .icon-arrow-fine-up:before {
- content: "\e601";
- }
- .icon-hot:before {
- content: "\e60e";
- }
- .icon-lishijilu:before {
- content: "\e6b9";
- }
- .icon-zhengxinchaxun-zhifubaoceping-:before {
- content: "\e616";
- }
- .icon-naozhong:before {
- content: "\e64a";
- }
- .icon-xiatubiao--copy:before {
- content: "\e608";
- }
- .icon-shoucang_xuanzhongzhuangtai:before {
- content: "\e6a9";
- }
- .icon-jia1:before {
- content: "\e61c";
- }
- .icon-bangzhu1:before {
- content: "\e63d";
- }
- .icon-arrow-left-bottom:before {
- content: "\e602";
- }
- .icon-arrow-right-bottom:before {
- content: "\e603";
- }
- .icon-arrow-left-top:before {
- content: "\e604";
- }
- .icon-icon--:before {
- content: "\e744";
- }
- .icon-zuojiantou-up:before {
- content: "\e605";
- }
- .icon-xia:before {
- content: "\e62d";
- }
- .icon--jianhao:before {
- content: "\e60b";
- }
- .icon-weixinzhifu:before {
- content: "\e61a";
- }
- .icon-comment:before {
- content: "\e64f";
- }
- .icon-weixin:before {
- content: "\e61f";
- }
- .icon-fenlei1:before {
- content: "\e620";
- }
- .icon-erjiye-yucunkuan:before {
- content: "\e623";
- }
- .icon-Group-:before {
- content: "\e688";
- }
- .icon-you:before {
- content: "\e606";
- }
- .icon-forward:before {
- content: "\e607";
- }
- .icon-tuijian:before {
- content: "\e610";
- }
- .icon-bangzhu:before {
- content: "\e679";
- }
- .icon-share:before {
- content: "\e656";
- }
- .icon-yiguoqi:before {
- content: "\e997";
- }
- .icon-shezhi1:before {
- content: "\e61d";
- }
- .icon-fork:before {
- content: "\e61b";
- }
- .icon-kafei:before {
- content: "\e66a";
- }
- .icon-iLinkapp-:before {
- content: "\e654";
- }
- .icon-saomiao:before {
- content: "\e60d";
- }
- .icon-shezhi:before {
- content: "\e60f";
- }
- .icon-shouhoutuikuan:before {
- content: "\e631";
- }
- .icon-gouwuche:before {
- content: "\e609";
- }
- .icon-dizhi:before {
- content: "\e614";
- }
- .icon-fenlei:before {
- content: "\e706";
- }
- .icon-xingxing:before {
- content: "\e70b";
- }
- .icon-tuandui:before {
- content: "\e633";
- }
- .icon-zuanshi:before {
- content: "\e615";
- }
- .icon-zuo:before {
- content: "\e63c";
- }
- .icon-shoucang2:before {
- content: "\e62e";
- }
- .icon-shouhuodizhi:before {
- content: "\e712";
- }
- .icon-yishouhuo:before {
- content: "\e71a";
- }
- .icon-dianzan-ash:before {
- content: "\e617";
- }
- view,
- scroll-view,
- swiper,
- swiper-item,
- cover-view,
- cover-image,
- icon,
- text,
- rich-text,
- progress,
- button,
- checkbox,
- form,
- input,
- label,
- radio,
- slider,
- switch,
- textarea,
- navigator,
- audio,
- camera,
- image,
- video {
- box-sizing: border-box;
- }
- /* 骨架屏替代方案 */
- .Skeleton {
- background: #f3f3f3;
- padding: 20upx 0;
- border-radius: 8upx;
- }
- /* 图片载入替代方案 */
- .image-wrapper {
- font-size: 0;
- background: #f3f3f3;
- border-radius: 4px;
- image {
- width: 100%;
- height: 100%;
- transition: .6s;
- opacity: 0;
- &.loaded {
- opacity: 1;
- }
- }
- }
- .clamp {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- display: block;
- }
- .common-hover {
- background: #f5f5f5;
- }
- /*边框*/
- .b-b:after,
- .b-t:after {
- position: absolute;
- z-index: 3;
- left: 0;
- right: 0;
- height: 0;
- content: '';
- transform: scaleY(.5);
- border-bottom: 1rpx solid rgba(0, 0, 0, .1);
- }
- /*边框*/
- .b_b:after,
- .b_t:after {
- position: absolute;
- z-index: 3;
- left: 0;
- right: 0;
- height: 0;
- content: '';
- transform: scaleY(.5);
- border-bottom: 1rpx solid rgba(0, 0, 0, .1);
- }
- .b_b:after {
- bottom: 0;
- }
- .b_t:after {
- top: 0;
- }
- .b-b:after {
- bottom: 0;
- }
- .b-t:after {
- top: 0;
- }
- /* button样式改写 */
- uni-button,
- button {
- height: 80upx;
- line-height: 80upx;
- font-size: $font-lg + 2upx;
- font-weight: normal;
- &.no-border:before,
- &.no-border:after {
- border: 0;
- }
- }
- uni-button[type=default],
- button[type=default] {
- color: $font-color-dark;
- }
- /* input 样式 */
- .input-placeholder {
- color: #999999;
- }
- .placeholder {
- color: #949494;
- font-size: 26rpx;
- }
- ::-webkit-scrollbar {
- display: none;
- width: 0;
- height: 0;
- color: transparent;
- display: flex;
- justify-content: center;
- }
- uni-tabbar .uni-tabbar {
- -webkit-box-shadow: 0 -2px 7px 0 hsla(0, 0%, 89.8%, .5);
- box-shadow: 0 -2px 7px 0 hsla(0, 0%, 89.8%, .5);
- width: 750rpx !important;
- left: auto !important;
- right: auto !important;
- }
- uni-tabbar {
- right: 0;
- display: flex;
- justify-content: center;
- }
- uni-page-head .uni-page-head {
- width: 750rpx !important;
- left: auto !important;
- right: auto !important;
- }
- uni-page-head {
- display: flex !important;
- justify-content: center;
- }
- body {
- font-family: "PingFangSC-Regular", "Microsoft YaHei", "Helvetica", "Droid Sans", "Arial", "sans-serif";
- }
- * {
- -webkit-font-smoothing: subpixel-antialiased
- }
- /* 商品详情页 H5 图文详情强制换行处理 start */
- /* #ifdef H5 */
- .detail-desc p {
- word-break: break-all;
- }
- /* #endif */
- /* 商品详情页 H5 图文详情强制换行处理 end */
- .uni-page-head .uni-page-head-ft .uni-page-head-btn .uni-btn-icon {
- font-size: 40rpx;
- margin-right: 15rpx;
- }
- .uni-popup.spec_model.bottom .uni-transition.fade-out {
- width: 750rpx;
- right: 0;
- left: 0;
- margin: 0 auto;
- }
- .uni-picker-container,
- .uni-picker-toggle,
- .uni-picker-toggle {
- width: 750rpx !important;
- left: 0 !important;
- right: 0 !important;
- margin: 0 auto !important;
- }
- .uni-popup .fade-out {
- width: 750rpx;
- margin: 0 auto;
- }
- .select_address .content_view {
- width: 750rpx;
- margin: 0 auto;
- }
- /* 分页loading */
- .loading {
- display: flex;
- align-items: center;
- justify-content: center;
- height: 80rpx;
- font-size: 24rpx;
- color: #999;
- }
- .spinner {
- display: inline-block;
- vertical-align: middle;
- margin-right: 20rpx;
- font-size: 26rpx;
- width: 26rpx;
- height: 26rpx;
- text-align: left;
- border-radius: 50%;
- box-shadow: inset 0 0 0 3rpx rgba(58, 168, 237, .3);
- }
- .spinner text {
- position: absolute;
- clip: rect(0, 26rpx, 26rpx, 13rpx);
- width: 26rpx;
- height: 26rpx;
- animation: spinner-circle-clipper 1s ease-in-out infinite;
- -webkit-animation: spinner-circle-clipper 1s ease-in-out infinite;
- }
- @keyframes spinner-circle-clipper {
- 0% {
- transform: rotate(0deg);
- }
- 100% {
- transform: rotate(180deg);
- }
- }
- @-webkit-keyframes spinner-circle-clipper {
- 0% {
- -webkit-transform: rotate(0deg);
- }
- 100% {
- -webkit-transform: rotate(180deg);
- }
- }
- .spinner text:after {
- position: absolute;
- clip: rect(0, 26rpx, 26rpx, 13rpx);
- width: 26rpx;
- height: 26rpx;
- content: '';
- animation: spinner-circle 1s ease-in-out infinite;
- -webkit-animation: spinner-circle 1s ease-in-out infinite;
- border-radius: 50%;
- box-shadow: inset 0 0 0 3rpx #3aa8ed;
- }
- @keyframes spinner-circle {
- 0% {
- transform: rotate(-180deg);
- }
- 100% {
- transform: rotate(180deg);
- }
- }
- @-webkit-keyframes spinner-circle {
- 0% {
- -webkit-transform: rotate(-180deg);
- }
- 100% {
- -webkit-transform: rotate(180deg);
- }
- }
- </style>
|