123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291 |
- <script>
- /**
- * vuex管理登陆状态,具体可以参考官方登陆模板示例
- */
- import { mapMutations } from 'vuex';
- // #ifdef H5
- import { weixindata, setRouter } from './utils/wxAuthorized';
- // #endif
- // #ifdef APP-PLUS
- import { getUpApp } from './utils/upApp.js';
- // #endif
- export default {
- data() {
- return {
- /* 保存微信信息 */
- appData: {}
- };
- },
- methods: {
- ...mapMutations('user', ['setUserInfo', 'login', 'hasLogin']),
- ...mapMutations('shop', ['setShopInfo','setShopAction']),
- ...mapMutations(['setFirstUse'])
- },
- onLaunch: function(urlObj) {
- console.log('开始升级');
- const obj = this;
- // 加载缓存中的用户信息
- const userInfo = uni.getStorageSync('userInfo') || '';
- // 判断是否拥有用户信息
- if (userInfo) {
- //更新登陆状态
- uni.getStorage({
- key: 'userInfo',
- success: res => {
- obj.setUserInfo(res.data);
- obj.login();
- },fail(res) {
- console.log(res,'res.data');
- }
-
- });
- }
- // 获取当前位置附近商店数据
- const shopDetail = uni.getStorageSync('shopDetail') ||'';
- if(shopDetail){
- uni.getStorage({
- key: 'shopDetail',
- success: res => {
- obj.setShopInfo(res.data);
- }
- });
- }
- // 获取商家用户数据
- const shopDetailAction = uni.getStorageSync('shopDetailAction') ||'';
- if(shopDetailAction){
- uni.getStorage({
- key: 'shopDetailAction',
- success: res => {
- obj.setShopAction(res.data);
- }
- });
- }
- // 获取是否已经在如果引导图
- const guideMap = uni.getStorageSync('guideMap') ||false;
- // 判断是否已经加载过数据
- if(guideMap){
- this.setFirstUse(true)
- }
- // #ifdef H5
- // 保存路由对象
- setRouter(this.$router);
- //判断是否已经缓存浏览器
- let bool = uni.getStorageSync('weichatBrowser') || '';
- if (bool === '') {
- //判断是否为微信浏览
- bool = navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == 'micromessenger';
- // 保存当前是否为微信内核浏览器
- uni.setStorageSync('weichatBrowser', bool);
- }
- if (bool) {
- // 加载微信信息
- weixindata();
- }
- // #endif
- // #ifdef APP-PLUS
- // 判断是否升级
- getUpApp();
- // 获取当前运行系统
- let system = uni.getStorageSync('platform') || '';
- if (!system) {
- uni.setStorage({
- key: 'platform',
- data: uni.getSystemInfoSync().platform
- });
- }
- // #endif
- },
- onShow: function() {
- // 加载拦截
- // console.log('App Show');
- },
- onHide: function() {
- // console.log('App Hide');
- }
- };
- </script>
- <style lang="scss">
- /*全局公共样式和字体图标*/
- @import '/static/css/cmy.css';
- 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: 20rpx 0;
- border-radius: 8rpx;
- }
- /* 图片载入替代方案 */
- .image-wrapper {
- font-size: 0;
- background: #f3f3f3;
- border-radius: 4px;
- image {
- width: 100%;
- height: 100%;
- transition: 0.6s;
- opacity: 0;
- &.loaded {
- opacity: 1;
- }
- }
- }
- // 设置富文本中图片最大宽度
- uni-rich-text img {
- max-width: 100% !important;
- }
- /*边框*/
- .b-b:after,
- .b-t:after {
- position: absolute;
- z-index: 3;
- left: 0;
- right: 0;
- height: 0;
- content: '';
- transform: scaleY(0.5);
- border-bottom: 1px solid $border-color-base;
- }
- .b-b:after {
- bottom: 0;
- }
- .b-t:after {
- top: 0;
- }
- /* input 样式 */
- .input-placeholder {
- color: #999999;
- }
- .placeholder {
- color: #999999;
- }
- // 边距样式
- @for $i from 1 to 5 {
- .margin-l-#{$i * 10} {
- margin-left: $i * 10rpx !important;
- }
- .margin-r-#{$i * 10} {
- margin-right: $i * 10rpx !important;
- }
- .margin-t-#{$i * 10} {
- margin-top: $i * 10rpx !important;
- }
- .margin-b-#{$i * 10} {
- margin-bottom: $i * 10rpx !important;
- }
- .margin-#{$i * 10} {
- margin: $i * 10rpx !important;
- }
- .margin-v-#{$i * 10} {
- margin-top: $i * 10rpx !important;
- margin-bottom: $i * 10rpx !important;
- }
- .margin-c-#{$i * 10} {
- margin-left: $i * 10rpx !important;
- margin-right: $i * 10rpx !important;
- }
- .padding-l-#{$i * 10} {
- padding-left: $i * 10rpx !important;
- }
- .padding-r-#{$i * 10} {
- padding-right: $i * 10rpx !important;
- }
- .padding-t-#{$i * 10} {
- padding-top: $i * 10rpx !important;
- }
- .padding-b-#{$i * 10} {
- padding-bottom: $i * 10rpx !important;
- }
- .padding-#{$i * 10} {
- padding: $i * 10rpx !important;
- }
- .padding-v-#{$i * 10} {
- padding-top: $i * 10rpx !important;
- padding-bottom: $i * 10rpx !important;
- }
- .padding-c-#{$i * 10} {
- padding-left: $i * 10rpx !important;
- padding-right: $i * 10rpx !important;
- }
- }
- // 字体大小
- .font-size-sm {
- font-size: $font-sm;
- }
- .font-size-base {
- font-size: $font-base;
- }
- .font-size-lg {
- font-size: $font-lg;
- }
- // 字体颜色
- .font-color-yellow {
- color: $color-yellow !important;
- }
- .font-color-gray {
- color: $color-gray !important;
- }
- .font-color-red {
- color: $color-red !important;
- }
- .font-color-greed {
- color: $color-green !important;
- }
- // 边框颜色
- .border-color-yellow {
- border: 1rpx solid $color-yellow;
- }
- // 基础按钮
- .base-buttom {
- background-color: $base-color;
- font-size: 32rpx;
- padding: 30rpx;
- color: #FFFFFF;
- margin: 0 30rpx;
- border-radius: 10rpx;
- margin-top: 100rpx;
- text-align: center;
- z-index: 95;
- }
- // 修改默认背景颜色
- uni-page-wrapper {
- background-color: $page-color-base;
- }
- page {
- background-color: $page-color-base;
- // 设置默认字体
- font-family: PingFang SC, STHeitiSC-Light, Helvetica-Light, arial, sans-serif, Droid Sans Fallback;
- min-height: 100%;
- }
- </style>
|