Browse Source

去掉/优化代码

master
邓平艺 4 years ago
parent
commit
2d3fb0d43f
  1. 194
      App - 副本.vue
  2. 8
      App.vue
  3. 8
      pages/center/index.vue
  4. 3
      pages/goodsDetail/index.vue
  5. 2
      pages/index/index.vue
  6. 7
      pages/login/accountLogin.vue
  7. 8
      pages/login/index.vue

194
App - 副本.vue

@ -1,194 +0,0 @@
<script>
export default {
globalData: {
wxlogin: () => {}
},
onLaunch: function() {
this.getUserInfo();
},
onShow: function() {
// #ifdef MP-WEIXIN
this.getUpdateWexin(); //
// #endif
},
onHide: function() {
console.log('App Hide')
},
methods: {
wxlogin(){
uni.login({
complete: result => {
if(result.errMsg == 'login:ok'){
let code = result.code;
this.$http(this.API.API_WXLOGIN, { code }).then(res => {
console.log("获得用户信息", res);
uni.setStorageSync('userinfo', res.data);
})
}
}
})
},
//
getUserInfo(){
this.globalData.wxlogin = this.wxlogin;
let userinfo = uni.getStorageSync('userinfo');
if(userinfo && userinfo.id){
return;
}
// console.log(this.globalData)
this.wxlogin();
// uni.login({
// complete: result => {
// if(result.errMsg == 'login:ok'){
// let code = result.code;
// this.userCode(code);
// }
// }
// })
},
// code
userCode(code){
console.log("code", code);
this.$http(this.API.API_WXLOGIN, { code }).then(res => {
console.log("获得用户信息", res);
uni.setStorageSync('userinfo', res.data);
})
},
//
login(){
this.checkSession().then(code => {
this.userCode(code);
}).catch(err => {
console.log("进入。。。。。。")
uni.login({
complete: result => {
console.log(result)
if(result.errMsg == 'login:ok'){
let code = result.code;
this.userCode(code);
}
}
})
});
},
// token
checkSession(){
return new Promise((resolve, reject) => {
uni.checkSession({
complete: result => {
if(result.errMsg == 'checkSession:ok'){ // session
// let login_token = uni.getStorageSync('login_token');
let login_token = undefined;
if(login_token){
resolve(login_token);
}else{
reject(); // token
}
}else{ // session
reject();
}
}
})
});
},
//
getUpdateWexin(){
const updateManager = uni.getUpdateManager(); //
updateManager.onCheckForUpdate(function(res) {
//
if (res.hasUpdate) {
updateManager.onUpdateReady(function(res2) {
uni.showModal({
title: '更新提示',
content: '发现新版本,是否重启应用?',
confirmColor: '#FE9903',
showCancel: false,
success(res2) {
if (res2.confirm) {
// applyUpdate
updateManager.applyUpdate();
}
}
});
});
}
});
updateManager.onUpdateFailed(function(res) {
//
uni.showModal({
title: '提示',
content: '检查到有新版本,但下载失败,请检查网络设置',
confirmColor: '#FE9903',
success(res) {
if (res.confirm) {
// applyUpdate
updateManager.applyUpdate();
}
}
});
});
}
}
}
</script>
<style lang="scss">
@import "uview-ui/index.scss";
@import './colorui/main.css';
@import './colorui/icon.css';
@import "@/colorui/animation.css";
@import '@/common/styles/common.css';
/*每个页面公共css */
//
.btn-bottom {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
z-index: 1;
}
// loading
.loading-more {
align-items: center;
justify-content: center;
padding-top: 10px;
padding-bottom: 10px;
text-align: center;
font-size: 28rpx;
color: #999;
}
.loading-more-text::before {
content: '';
width: 20px;
height: 20px;
display: inline-block;
vertical-align: middle;
-webkit-animation: weuiLoading 1s steps(12, end) infinite;
animation: weuiLoading 1s steps(12, end) infinite;
background-repeat: no-repeat;
background-image: url("data:image/svg+xml;charset=utf8, %3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 100 100'%3E%3Cpath fill='none' d='M0 0h100v100H0z'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23E9E9E9' rx='5' ry='5' transform='translate(0 -30)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23989697' rx='5' ry='5' transform='rotate(30 105.98 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%239B999A' rx='5' ry='5' transform='rotate(60 75.98 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23A3A1A2' rx='5' ry='5' transform='rotate(90 65 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23ABA9AA' rx='5' ry='5' transform='rotate(120 58.66 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23B2B2B2' rx='5' ry='5' transform='rotate(150 54.02 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23BAB8B9' rx='5' ry='5' transform='rotate(180 50 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23C2C0C1' rx='5' ry='5' transform='rotate(-150 45.98 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23CBCBCB' rx='5' ry='5' transform='rotate(-120 41.34 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23D2D2D2' rx='5' ry='5' transform='rotate(-90 35 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23DADADA' rx='5' ry='5' transform='rotate(-60 24.02 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23E2E2E2' rx='5' ry='5' transform='rotate(-30 -5.98 65)'/%3E%3C/svg%3E");
background-size: 100%;
}
@-webkit-keyframes weuiLoading {
0% {
transform: rotate3d(0, 0, 1, 0deg);
}
100% {
transform: rotate3d(0, 0, 1, 360deg);
}
}
@keyframes weuiLoading {
0% {
transform: rotate3d(0, 0, 1, 0deg);
}
100% {
transform: rotate3d(0, 0, 1, 360deg);
}
}
</style>

8
App.vue

@ -12,18 +12,10 @@
this.getUpdateWexin(); //
// #endif
},
onHide: function() {
console.log('App Hide')
},
methods: {
//
getUserInfo(){
this.globalData.wxlogin = this.wxlogin;
// 退
// let quit_login_state = uni.getStorageSync('quit_login_state');
// if(quit_login_state){
// return;
// }
//
let userinfo = uni.getStorageSync('userinfo');
if(userinfo && userinfo.id){

8
pages/center/index.vue

@ -121,9 +121,6 @@
return this.$shared.isRight(val);
}
}
},
onLoad() {
},
onShow(e){
this.verifyUserInfo();
@ -131,10 +128,6 @@
},
methods: {
verifyUserInfo(){
// let quit_login_state = uni.getStorageSync('quit_login_state');
// if(quit_login_state){
// return;
// }
let userInfo = uni.getStorageSync('userinfo') || {};
if(!userInfo.id || !userInfo.nickname || !userInfo.avatar){
if(this.showLogin){
@ -148,7 +141,6 @@
},
getData(){
this.$http(this.API.API_USER_CENTER).then(res => {
console.log("res" , res);
this.info = res.data;
})
},

3
pages/goodsDetail/index.vue

@ -6,7 +6,6 @@
<swiper :current="current" :indicator-dots="true" :circular="true" class="swiper-box" indicator-active-color="#FE9903">
<swiper-item v-for="(item, index) in goods_detail.banners" :key="item.id">
<image :src="item.cover" style="width: 100%; height: 100%;" @click="lookImg(index)"></image>
<!-- <image :src="item.cover" mode="aspectFit"></image> -->
</swiper-item>
</swiper>
<!-- 商品主要信息 -->
@ -111,13 +110,11 @@
getGoodsDetail(){
let that = this;
this.$http(this.API.API_GOODS_DETAIL, {goods_id: this.goods_id}).then(res => {
console.log("res", res);
this.skeletonLoading = false;
this.goods_detail = res.data;
this.is_collect = Boolean(res.data.user.is_collect);
}).catch(err => {
this.skeletonLoading = false;
that.$msg(err.msg);
setTimeout(() => {
that.$toBack();
}, 1000);

2
pages/index/index.vue

@ -96,8 +96,6 @@
page: tab_item.page,
per_page
}).then(res => {
console.log("res", res);
let isPage = res.data.has_more_page;
tab_item.isPage = isPage;
if(!isPage){

7
pages/login/accountLogin.vue

@ -1,12 +1,15 @@
<template>
<view>
<!-- logo -->
<view class="lf-flex-column lf-row-center logo">
<image ></image>
<image src="../../static/logo.png"></image>
</view>
<!-- 输入手机号 -->
<view class="lf-row-between inpu-box">
<u-icon name="phone" size="50"></u-icon>
<input maxlength="11" v-model="phoneNum" placeholder="请输入手机号" />
</view>
<!-- 验证码登录 -->
<view class="lf-row-between verif-code" v-if="isCodeLogin">
<view class="lf-row-between code-input">
<u-icon name="lock" size="50" color="#999999"></u-icon>
@ -16,6 +19,7 @@
{{ isGetCode ? '获取验证码' : codeTimeNum +'s后重新获取' }}
</button>
</view>
<!-- 密码登录 -->
<view class="lf-row-between inpu-box lf-m-t-30" v-else>
<u-icon name="lock" size="50"></u-icon>
<input maxlength="11" v-model="password" :password="true" placeholder="请输入密码" />
@ -97,7 +101,6 @@
width: 160rpx;
height: 160rpx;
border-radius: 50%;
background-color: #EEEEEE;
}
}
.inpu-box{

8
pages/login/index.vue

@ -86,7 +86,9 @@
console.log("更新手机号", res);
this.$msg('更新成功', {icon: 'success'});
uni.setStorageSync('userinfo', res.data);
this.$toBack();
setTimeout(() => {
this.$toBack();
}, 1000);
})
}
},
@ -111,7 +113,9 @@
console.log("更新用户信息", res);
this.$msg('更新成功', {icon: 'success'});
uni.setStorageSync('userinfo', res.data);
this.$toBack();
setTimeout(() => {
this.$toBack();
}, 1000);
})
}
}

Loading…
Cancel
Save