优化小程序和app登录的逻辑,优化部分页面样式错乱的问题,优化跳转页面后部分页面无法接受url参数的问题,优化app端的兼容问题

This commit is contained in:
gaoxs
2020-03-19 16:17:26 +08:00
parent 4cc4c60a87
commit 3fa8054983
12 changed files with 503 additions and 464 deletions

View File

@ -1,77 +1,97 @@
<template>
<view class="lottie-bg">
<view id="lottie"><image src="../../static/images/live-logo.gif" rel="preload" mode="widthFix" style="width: 100%;" /></view>
</view>
<view class="lottie-bg">
<view id="lottie">
<image
src="../../static/images/live-logo.gif"
rel="preload"
mode="widthFix"
style="width: 100%;"
/>
</view>
</view>
</template>
<script>
import { mapState, mapMutations, mapActions } from 'vuex';
import { mapState, mapMutations, mapActions } from "vuex";
// 组件
// import request from "@//api/request";
import { wxappAuth, getUser } from '@/api/user';
import dayjs from 'dayjs';
import cookie from '@/utils/store/cookie';
import { parseQuery, login, handleQrCode } from '@/utils';
import { wxappAuth, getUser } from "@/api/user";
import dayjs from "dayjs";
import cookie from "@/utils/store/cookie";
import { parseQuery, login, handleQrCode } from "@/utils";
export default {
name: 'Loading',
data() {
return {};
},
mounted() {
var url = handleQrCode();
// 判断是否是分销
if (url) {
var spread = cookie.get('spread');
let urlSpread = parseInt(url.spread);
if (!Number.isNaN(urlSpread) && spread !== urlSpread) {
cookie.set('spread', urlSpread || 0);
} else if (spread === 0 || typeof spread !== 'number') {
cookie.set('spread', urlSpread || 0);
}
}
// this.toLaunch();
login({
fail: () => {
this.toLaunch();
}
});
},
methods: {
...mapActions(['changeAuthorization', 'changeUserInfo']),
toLaunch() {
console.log(this);
this.changeAuthorization(false);
this.$yrouter.switchTab({
path: '/pages/home/index',
});
}
}
name: "Loading",
data() {
return {};
},
onShow() {
var url = handleQrCode();
// 判断是否是分销
if (url) {
var spread = cookie.get("spread");
let urlSpread = parseInt(url.spread);
if (!Number.isNaN(urlSpread) && spread !== urlSpread) {
cookie.set("spread", urlSpread || 0);
} else if (spread === 0 || typeof spread !== "number") {
cookie.set("spread", urlSpread || 0);
}
}
if (this.$store.getters.token) {
this.toLaunch();
return;
}
console.log(this.$store.getters.token, 9999);
cookie.get("spread");
// this.toLaunch();
if (this.$deviceType == 'App') {
// this.toLaunch();
this.$yrouter.switchTab({
path: '/pages/home/index',
});
return
}
login({
fail: () => {
this.toLaunch();
}
});
},
methods: {
...mapActions(["changeAuthorization", "setUserInfo"]),
toLaunch() {
console.log(this);
this.changeAuthorization(false);
this.$yrouter.switchTab({
path: "/pages/home/index"
});
}
}
};
</script>
<style scoped>
.lottie-bg {
position: fixed;
left: 0;
top: 0;
background-color: #fff;
width: 100%;
height: 100%;
z-index: 999;
display: -webkit-flex;
display: flex;
-webkit-align-items: center;
align-items: center;
-webkit-justify-content: center;
justify-content: center;
position: fixed;
left: 0;
top: 0;
background-color: #fff;
width: 100%;
height: 100%;
z-index: 999;
display: -webkit-flex;
display: flex;
-webkit-align-items: center;
align-items: center;
-webkit-justify-content: center;
justify-content: center;
}
#lottie {
width: 35%;
display: block;
overflow: hidden;
transform: translate3d(0, 0, 0);
margin: auto;
width: 35%;
display: block;
overflow: hidden;
transform: translate3d(0, 0, 0);
margin: auto;
}
</style>

View File

@ -10,6 +10,7 @@
:key="combinationListIndex"
@click="link(item.id)"
>
<text>{{item.id}}</text>
<view class="pictrue">
<image :src="item.image" />
</view>

View File

@ -114,7 +114,7 @@
<view class="bnt bg-color-violet" @click="openAlone">单独购买</view>
<view class="bnt bg-color-red" @click="openTeam">立即开团</view>
</view>
<ProductWindow v-on:changeFun="changeFun" :attr="attr" :cartNum="cartNum"></ProductWindow>
<ProductWindow v-if="cartNum" v-on:changeFun="changeFun" :attr="attr" :cartNum="cartNum"></ProductWindow>
<StorePoster
v-on:setPosterImageStatus="setPosterImageStatus"
:posterImageStatus="posterImageStatus"
@ -122,18 +122,6 @@
></StorePoster>
</view>
</template>
<style scoped>
.noscroll {
height: 100%;
overflow: hidden;
}
.product-con .footer-group .bnt {
width: 43%;
}
.product-con .footer-group .bnt.bg-color-violet {
background-color: #fa8013;
}
</style>
<script>
// import { swiper, swiperSlide } from "vue-awesome-swiper";
@ -211,7 +199,7 @@ export default {
}
}
},
mounted: function() {
onShow: function() {
this.mountedStart();
},
methods: {
@ -220,6 +208,7 @@ export default {
},
mountedStart: function() {
var that = this;
console.log(that)
let id = that.$yroute.query.id;
getCombinationDetail(id).then(res => {
that.$set(that, "storeInfo", res.data.storeInfo);
@ -336,4 +325,14 @@ export default {
.product-con .wrapper {
padding-bottom: 0.26rem;
}
.noscroll {
height: 100%;
overflow: hidden;
}
.product-con .footer-group .bnt {
width: 43%;
}
.product-con .footer-group .bnt.bg-color-violet {
background-color: #fa8013;
}
</style>

View File

@ -40,7 +40,7 @@ export default {
this.changeAuthorization(false);
},
methods: {
...mapActions(["changeAuthorization", "changeUserInfo"]),
...mapActions(["changeAuthorization", "setUserInfo"]),
...mapMutations(["UPDATE_AUTHORIZATIONPAGE", "CHANGE_TABTAR"]),
back() {
this.$yrouter.switchTab({

View File

@ -252,7 +252,7 @@ export default {
}
};
},
mounted: function() {
onShow: function() {
let that = this;
uni.showLoading({
title:'加载中'

View File

@ -1,318 +1,329 @@
<template>
<view class="register absolute">
<view class="shading">
<view class="pictrue acea-row row-center-wrapper">
<image src="@/assets/images/logo.png" />
</view>
</view>
<view class="whiteBg" v-if="formItem === 1">
<view class="title acea-row row-center-wrapper">
<view
class="item"
:class="current === index ? 'on' : ''"
v-for="(item, index) in navList"
@click="navTap(index)"
:key="index"
>{{ item }}</view>
</view>
<view class="list" :hidden="current !== 0">
<form @submit.prevent="submit">
<view class="item">
<view class="acea-row row-between-wrapper">
<svg class="icon" aria-hidden="true">
<view class="register absolute">
<view class="shading">
<view class="pictrue acea-row row-center-wrapper">
<image src="@/assets/images/logo.png" />
</view>
</view>
<view class="whiteBg" v-if="formItem === 1">
<view class="title acea-row row-center-wrapper">
<view class="item" :class="current === index ? 'on' : ''" v-for="(item, index) in navList" @click="navTap(index)"
:key="index">{{ item }}</view>
</view>
<view class="list" :hidden="current !== 0">
<form @submit.prevent="submit">
<view class="item">
<view class="acea-row row-between-wrapper">
<!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-phone_" />
</svg>
<input type="text" placeholder="输入手机号码" v-model="account" required />
</view>
</view>
<view class="item">
<view class="acea-row row-between-wrapper">
<svg class="icon" aria-hidden="true">
</svg> -->
<input type="text" placeholder="输入手机号码" v-model="account" required />
</view>
</view>
<view class="item">
<view class="acea-row row-between-wrapper">
<!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-code_" />
</svg>
<input type="password" placeholder="填写登录密码" v-model="password" required />
</view>
</view>
</form>
</view>
<view class="list" :hidden="current !== 1">
<view class="item">
<view class="acea-row row-between-wrapper">
<svg class="icon" aria-hidden="true">
</svg> -->
<input type="password" placeholder="填写登录密码" v-model="password" required />
</view>
</view>
</form>
</view>
<view class="list" :hidden="current !== 1">
<view class="item">
<view class="acea-row row-between-wrapper">
<!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-phone_" />
</svg>
<input type="text" placeholder="输入手机号码" v-model="account" />
</view>
</view>
<view class="item">
<view class="align-left">
<svg class="icon" aria-hidden="true">
</svg> -->
<input type="text" placeholder="输入手机号码" v-model="account" />
</view>
</view>
<view class="item">
<view class="align-left">
<!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-code_1" />
</svg>
<input type="text" placeholder="填写验证码" class="codeIput" v-model="captcha" />
<button
class="code"
:disabled="disabled"
:class="disabled === true ? 'on' : ''"
@click="code"
>{{ text }}</button>
</view>
</view>
</view>
<view class="logon" @click="loginMobile" :hidden="current !== 1">登录</view>
<view class="logon" @click="submit" :hidden="current === 1">登录</view>
<view class="tip">
没有账号?
<text @click="formItem = 2" class="font-color-red">立即注册</text>
</view>
</view>
<view class="whiteBg" v-else>
<view class="title">注册账号</view>
<view class="list">
<view class="item">
<view>
<svg class="icon" aria-hidden="true">
</svg> -->
<input type="text" placeholder="填写验证码" class="codeIput" v-model="captcha" />
<button class="code" :disabled="disabled" :class="disabled === true ? 'on' : ''" @click="code">{{ text }}</button>
</view>
</view>
</view>
<view class="logon" @click="loginMobile" :hidden="current !== 1">登录</view>
<view class="logon" @click="submit" :hidden="current === 1">登录</view>
<view class="tip">
没有账号?
<text @click="formItem = 2" class="font-color-red">立即注册</text>
</view>
</view>
<view class="whiteBg" v-else>
<view class="title">注册账号</view>
<view class="list">
<view class="item">
<view>
<!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-phone_" />
</svg>
<input type="text" placeholder="输入手机号码" v-model="account" />
</view>
</view>
<view class="item">
<view class="align-left">
<svg class="icon" aria-hidden="true">
</svg> -->
<input type="text" placeholder="输入手机号码" v-model="account" />
</view>
</view>
<view class="item">
<view class="align-left">
<!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-code_1" />
</svg>
<input type="text" placeholder="填写验证码" class="codeIput" v-model="captcha" />
<button
class="code"
:disabled="disabled"
:class="disabled === true ? 'on' : ''"
@click="code"
>{{ text }}</button>
</view>
</view>
<view class="item">
<view>
<svg class="icon" aria-hidden="true">
</svg> -->
<input type="text" placeholder="填写验证码" class="codeIput" v-model="captcha" />
<button class="code" :disabled="disabled" :class="disabled === true ? 'on' : ''" @click="code">{{ text }}</button>
</view>
</view>
<view class="item">
<view>
<!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-code_" />
</svg>
<input type="password" placeholder="填写您的登录密码" v-model="password" />
</view>
</view>
</view>
<view class="logon" @click="register">注册</view>
<view class="tip">
已有账号?
<text @click="formItem = 1" class="font-color-red">立即登录</text>
</view>
</view>
<view class="bottom"></view>
</view>
</svg> -->
<input type="password" placeholder="填写您的登录密码" v-model="password" />
</view>
</view>
</view>
<view class="logon" @click="register">注册</view>
<view class="tip">
已有账号?
<text @click="formItem = 1" class="font-color-red">立即登录</text>
</view>
</view>
<view class="bottom"></view>
</view>
</template>
<script>
import sendVerifyCode from "@/mixins/SendVerifyCode";
import { login, loginMobile, registerVerify, register } from "@/api/user";
import attrs, { required, alpha_num, chs_phone } from "@/utils/validate";
import { validatorDefaultCatch } from "@/utils/dialog";
import dayjs from "dayjs";
import cookie from "@/utils/store/cookie";
import sendVerifyCode from "@/mixins/SendVerifyCode";
import {
login,
loginMobile,
registerVerify,
register
} from "@/api/user";
import attrs, {
required,
alpha_num,
chs_phone
} from "@/utils/validate";
import {
validatorDefaultCatch
} from "@/utils/dialog";
import dayjs from "dayjs";
import cookie from "@/utils/store/cookie";
import {handleGetUserInfo} from '@/utils'
const BACK_URL = "login_back_url";
const BACK_URL = "login_back_url";
export default {
name: "Login",
mixins: [sendVerifyCode],
data: function() {
return {
navList: ["账号登录"],
current: 0,
account: "",
password: "",
captcha: "",
formItem: 1,
type: "login"
};
},
methods: {
async loginMobile() {
var that = this;
const { account, captcha } = that;
try {
await that
.$validator({
account: [
required(required.message("手机号码")),
chs_phone(chs_phone.message())
],
captcha: [
required(required.message("验证码")),
alpha_num(alpha_num.message("验证码"))
]
})
.validate({
account,
captcha
});
} catch (e) {
return validatorDefaultCatch(e);
}
loginMobile({
phone: that.account,
captcha: that.captcha,
spread: cookie.get("spread")
})
.then(res => {
var data = res.data;
that.$store.commit("LOGIN", data.token, dayjs(data.expires_time));
const backUrl = cookie.get(BACK_URL) || "/";
cookie.remove(BACK_URL);
that.$yrouter.replace({
path: backUrl
});
})
.catch(err => {
uni.showToast({
title: err.msg || err.response.data.msg,
icon: 'none',
duration: 2000
});
});
},
async register() {
var that = this;
const { account, captcha, password } = that;
try {
await that
.$validator({
account: [
required(required.message("手机号码")),
chs_phone(chs_phone.message())
],
captcha: [
required(required.message("验证码")),
alpha_num(alpha_num.message("验证码"))
],
password: [
required(required.message("码")),
attrs.range([6, 16], attrs.range.message("密码")),
alpha_num(alpha_num.message("密码"))
]
})
.validate({
account,
captcha,
password
});
} catch (e) {
return validatorDefaultCatch(e);
}
register({
account: that.account,
captcha: that.captcha,
password: that.password,
spread: cookie.get("spread")
})
.then(res => {
uni.showToast({
title: res.msg,
icon: "success",
duration: 2000
});
that.formItem = 1;
})
.catch(err => {
uni.showToast({
title: err.msg || err.response.data.msg,
icon: "none",
duration: 2000
});
});
},
async code() {
var that = this;
const { account } = that;
try {
await that
.$validator({
account: [
required(required.message("手机号码")),
chs_phone(chs_phone.message())
]
})
.validate({
account
});
} catch (e) {
return validatorDefaultCatch(e);
}
if (that.formItem == 2) that.type = "register";
await registerVerify({
phone: that.account,
type: that.type
})
.then(res => {
uni.showToast({
title: res.msg,
icon: "success",
duration: 2000
});
that.sendCode();
})
.catch(err => {
uni.showToast({
title: err.msg || err.response.data.msg,
icon: "none",
duration: 2000
});
});
},
navTap: function(index) {
this.current = index;
},
async submit() {
console.log("spread:" + cookie.get("spread"));
const { account, password } = this;
try {
await this.$validator({
account: [
required(required.message("账号")),
attrs.range([5, 16], attrs.range.message("账号")),
alpha_num(alpha_num.message("账号"))
],
password: [
required(required.message("密码")),
attrs.range([6, 16], attrs.range.message("密码")),
alpha_num(alpha_num.message("密码"))
]
}).validate({
account,
password
});
} catch (e) {
return validatorDefaultCatch(e);
}
export default {
name: "Login",
mixins: [sendVerifyCode],
data: function() {
return {
navList: ["账号登录"],
current: 0,
account: "",
password: "",
captcha: "",
formItem: 1,
type: "login"
};
},
methods: {
async loginMobile() {
var that = this;
const {
account,
captcha
} = that;
try {
await that
.$validator({
account: [
required(required.message("手机号码")),
chs_phone(chs_phone.message())
],
captcha: [
required(required.message("验证码")),
alpha_num(alpha_num.message("验证码"))
]
})
.validate({
account,
captcha
});
} catch (e) {
return validatorDefaultCatch(e);
}
loginMobile({
phone: that.account,
captcha: that.captcha,
spread: cookie.get("spread")
})
.then(res => {
var data = res.data;
that.$store.commit("LOGIN", data.token, dayjs(data.expires_time));
handleGetUserInfo()
})
.catch(err => {
uni.showToast({
title: err.msg || err.response.data.msg,
icon: 'none',
duration: 2000
});
});
},
async register() {
var that = this;
const {
account,
captcha,
password
} = that;
try {
await that
.$validator({
account: [
required(required.message("手机号码")),
chs_phone(chs_phone.message())
],
captcha: [
required(required.message("验证码")),
alpha_num(alpha_num.message("验证码"))
],
password: [
required(required.message("密码")),
attrs.range([6, 16], attrs.range.message("密码")),
alpha_num(alpha_num.message("密码"))
]
})
.validate({
account,
captcha,
password
});
} catch (e) {
return validatorDefaultCatch(e);
}
register({
account: that.account,
captcha: that.captcha,
password: that.password,
spread: cookie.get("spread")
})
.then(res => {
uni.showToast({
title: res.msg,
icon: "success",
duration: 2000
});
that.formItem = 1;
})
.catch(err => {
uni.showToast({
title: err.msg || err.response.data.msg,
icon: "none",
duration: 2000
});
});
},
async code() {
var that = this;
const {
account
} = that;
try {
await that
.$validator({
account: [
required(required.message("手机号码")),
chs_phone(chs_phone.message())
]
})
.validate({
account
});
} catch (e) {
return validatorDefaultCatch(e);
}
if (that.formItem == 2) that.type = "register";
await registerVerify({
phone: that.account,
type: that.type
})
.then(res => {
uni.showToast({
title: res.msg,
icon: "success",
duration: 2000
});
that.sendCode();
})
.catch(err => {
uni.showToast({
title: err.msg || err.response.data.msg,
icon: "none",
duration: 2000
});
});
},
navTap: function(index) {
this.current = index;
},
async submit() {
console.log("spread:" + cookie.get("spread"));
const {
account,
password
} = this;
try {
await this.$validator({
account: [
required(required.message("账号")),
attrs.range([5, 16], attrs.range.message("账号")),
alpha_num(alpha_num.message("账号"))
],
password: [
required(required.message("密码")),
attrs.range([6, 16], attrs.range.message("密码")),
alpha_num(alpha_num.message("密码"))
]
}).validate({
account,
password
});
} catch (e) {
return validatorDefaultCatch(e);
}
login({
username: account,
password,
spread: cookie.get("spread")
})
.then(({ data }) => {
this.$store.commit("LOGIN", data.token, dayjs(data.expires_time));
const backUrl = cookie.get(BACK_URL) || "/";
cookie.remove(BACK_URL);
this.$yrouter.replace({
path: backUrl
});
})
.catch(err => {
uni.showToast({
title: err.msg || err.response.data.msg,
icon: "none",
duration: 2000
});
});
}
}
};
</script>
login({
username: account,
password,
spread: cookie.get("spread")
})
.then(({
data
}) => {
this.$store.commit("LOGIN", data.token, dayjs(data.expires_time));
handleGetUserInfo()
// let replace=this.$yroute.query.replace
// if(replace){
// }
// this.$yrouter.replace({
// path: this.$yroute.query.replace || '/pages/home/index'
// });
})
.catch(err => {
uni.showToast({
title: err.msg || err.response.data.msg,
icon: "none",
duration: 2000
});
});
}
}
};
</script>

View File

@ -10,17 +10,17 @@
<view class="list">
<view class="item">
<view>
<svg class="icon" aria-hidden="true">
<!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-phone_" />
</svg>
</svg> -->
<input type="text" placeholder="输入手机号码" />
</view>
</view>
<view class="item">
<view class="align-left">
<svg class="icon" aria-hidden="true">
<!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-code_1" />
</svg>
</svg> -->
<input type="text" placeholder="填写验证码" class="codeIput" />
<button
class="code"
@ -32,9 +32,9 @@
</view>
<view class="item">
<view>
<svg class="icon" aria-hidden="true">
<!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-code_" />
</svg>
</svg> -->
<input type="text" placeholder="填写您的登录密码" />
</view>
</view>

View File

@ -57,7 +57,7 @@
<view class="title acea-row row-between-wrapper">
<text>我的订单</text>
<text @click="goMyOrder()" class="allOrder">
全部订单
<text>全部订单</text>
<text class="iconfont icon-jiantou"></text>
</text>
</view>
@ -67,8 +67,8 @@
<image :src="$VUE_APP_RESOURCES_URL + '/images/dfk.png'" />
<text
class="order-status-num"
v-if="orderStatusNum.unpaidCount > 0"
>{{ orderStatusNum.unpaidCount }}</text>
v-if="userInfo.orderStatusNum.unpaidCount > 0"
>{{ userInfo.orderStatusNum.unpaidCount }}</text>
</view>
<view>待付款</view>
</view>
@ -142,11 +142,11 @@
</view>
<view style="text-align: center;margin-top: 1rem">By@意象</view>
<view class="footer-line-height"></view>
<SwitchWindow
<!-- <SwitchWindow
v-on:changeswitch="changeswitch"
:switchActive="switchActive"
:login_type="userInfo.login_type"
></SwitchWindow>
></SwitchWindow> -->
</view>
<Authorization v-else />
</view>
@ -310,7 +310,7 @@ export default {
},
onShow() {
console.log(this.userInfo);
if (this.userInfo.uid) {
if (this.$store.getters.token) {
this.User();
this.MenuUser();
this.isWeixin = isWeixin();