Merge branch 'wlogin'

This commit is contained in:
gaoxs
2020-06-04 14:15:21 +08:00
13 changed files with 497 additions and 370 deletions

View File

@ -43,22 +43,23 @@ export default {
}
cookie.get("spread");
// this.toLaunch();
if (this.$deviceType == 'app') {
// this.toLaunch();
this.$yrouter.switchTab({
path: '/pages/home/index',
});
return
if (this.$deviceType == "app") {
// this.toLaunch();
this.$yrouter.switchTab({
path: "/pages/home/index"
});
return;
}
login({
fail: () => {
this.toLaunch();
}
login().finally(() => {
this.$yrouter.switchTab({
path: "/pages/home/index"
});
});
},
methods: {
...mapActions(["changeAuthorization", "setUserInfo"]),
toLaunch() {
console.log("loading home");
this.changeAuthorization(false);
this.$yrouter.switchTab({
path: "/pages/home/index"

View File

@ -1,211 +1,255 @@
<template>
<view class="container">
<view v-if="!token">
<!-- 小程序 -->
<view v-if="$deviceType == 'routine'">
<view class="getUserInfo">
<text>您还未允许微信登录授权请点击下方按钮允许微信授权登录</text>
<button type="primary" open-type="getUserInfo" @getuserinfo="getUserInfo">允许微信登录授权</button>
<view style="height:20rpx"></view>
<button @click="back">取消微信登录授权</button>
</view>
</view>
<!-- app -->
<view v-if="$deviceType == 'app'">
<view class="getUserInfo">
<text>请先登录</text>
<button type="primary" @click="this.toLogin">去登录</button>
</view>
</view>
</view>
</view>
<view class="container">
<view v-if="!token">
<!-- 小程序 -->
<view v-if="$deviceType == 'routine'&&authorize">
<view class="getUserInfo">
<text>您还未允许微信登录授权请点击下方按钮允许微信授权登录</text>
<button type="primary" open-type="getUserInfo" @getuserinfo="getUserInfo">允许微信登录授权</button>
<view style="height:20rpx"></view>
<button @click="back">取消微信登录授权</button>
</view>
</view>
<!-- app -->
<view v-if="$deviceType == 'app'&&authorize">
<view class="getUserInfo">
<text>请先登录</text>
<button type="primary" @click="this.toLogin">去登录</button>
</view>
</view>
<view v-if="!authorize">
<view class="getUserInfo">
<text>登录中</text>
</view>
</view>
</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 { login } from '@/utils';
import { wxappAuth, getUser } from "@/api/user";
import dayjs from "dayjs";
import cookie from "@/utils/store/cookie";
import { login, authorize } from "@/utils";
export default {
data() {
return {
};
},
computed: {
...mapState(['isAuthorization','$deviceType','token'])
},
onShow() {
this.UPDATE_AUTHORIZATIONPAGE(true);
},
onHide() {
this.UPDATE_AUTHORIZATIONPAGE(false);
this.changeAuthorization(false);
},
onUnload() {
this.UPDATE_AUTHORIZATIONPAGE(false);
this.changeAuthorization(false);
},
methods: {
...mapActions(['changeAuthorization', 'setUserInfo']),
...mapMutations(['UPDATE_AUTHORIZATIONPAGE', 'CHANGE_TABTAR']),
back() {
this.$yrouter.switchTab({
path: '/pages/home/index',
query: {}
});
},
getUserInfo(data) {
if (data.detail.errMsg == 'getUserInfo:fail auth deny') {
uni.showToast({
title: '取消授权',
icon: 'none',
duration: 2000
});
return;
}
uni.showLoading({
title: '登录中'
});
login({
success: () => {}
});
},
toLogin() {
this.$yrouter.push({
path: '/pages/user/Login/index',
query: {}
});
}
},
onUnload() {},
mounted() {
}
data() {
return {
authorize: false
};
},
computed: {
...mapState(["isAuthorization", "$deviceType", "token"])
},
onShow() {
this.UPDATE_AUTHORIZATIONPAGE(true);
// // 先校验用户是否授权,如果没有授权,显示授权按钮
console.log("先校验用户是否授权,如果没有授权,显示授权按钮");
authorize("userInfo")
.then(res => {
console.log(res);
})
.catch(error => {
console.log(error);
// 用户未授权,显示授权按钮
this.authorize = true;
});
},
onHide() {
console.log("离开授权页面,11111");
this.UPDATE_AUTHORIZATIONPAGE(false);
this.changeAuthorization(false);
},
onUnload() {
console.log("离开授权页面,11111");
this.UPDATE_AUTHORIZATIONPAGE(false);
this.changeAuthorization(false);
},
methods: {
...mapActions(["changeAuthorization", "setUserInfo"]),
...mapMutations(["UPDATE_AUTHORIZATIONPAGE", "CHANGE_TABTAR"]),
back() {
this.$yrouter.switchTab({
path: "/pages/home/index",
query: {}
});
},
getUserInfo(data) {
if (data.detail.errMsg == "getUserInfo:fail auth deny") {
uni.showToast({
title: "取消授权",
icon: "none",
duration: 2000
});
return;
}
uni.showLoading({
title: "登录中"
});
login()
.then(res => {
this.$yrouter.replace({ path: cookie.get("redirect") });
})
.catch(error => {
console.log(error);
uni.showToast({
title: error,
icon: "none",
duration: 2000
});
});
},
toLogin() {
this.$yrouter.push({
path: "/pages/user/Login/index",
query: {}
});
}
},
onUnload() {
console.log("离开授权页面,11111");
this.UPDATE_AUTHORIZATIONPAGE(false);
this.changeAuthorization(false);
},
mounted() {
this.UPDATE_AUTHORIZATIONPAGE(true);
// // 先校验用户是否授权,如果没有授权,显示授权按钮
console.log("先校验用户是否授权,如果没有授权,显示授权按钮");
authorize("userInfo")
.then(res => {
console.log(res);
})
.catch(error => {
console.log(error);
// 用户未授权,显示授权按钮
this.authorize = true;
});
}
};
</script>
<style lang="less">
.sp-cell {
height: 20rpx;
height: 20rpx;
}
.getUserInfo {
display: flex;
align-items: center;
flex-direction: column;
padding: 30px;
display: flex;
align-items: center;
flex-direction: column;
padding: 30px;
text {
font-size: 30rpx;
text-align: center;
margin-bottom: 20px;
}
text {
font-size: 30rpx;
text-align: center;
margin-bottom: 20px;
}
}
.container {
flex: 1;
display: flex;
flex-direction: column;
justify-content: flex-start;
position: relative;
flex: 1;
display: flex;
flex-direction: column;
justify-content: flex-start;
position: relative;
}
.tab-bar {
font-size: 0;
display: flex;
align-items: center;
background: rgba(255, 255, 255, 0.9);
position: fixed;
bottom: 0;
left: 0;
right: 0;
z-index: 99;
border-top: 1px solid rgba(248, 248, 248, 1);
font-size: 0;
display: flex;
align-items: center;
background: rgba(255, 255, 255, 0.9);
position: fixed;
bottom: 0;
left: 0;
right: 0;
z-index: 99;
border-top: 1px solid rgba(248, 248, 248, 1);
.tab-bar-item {
flex: 1;
height: 49px;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
.tab-bar-item {
flex: 1;
height: 49px;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
&.active {
text {
color: #ee7559;
}
&.active {
text {
color: #ee7559;
}
.tab-bar-pic {
display: none;
background: #f9f9f9;
.tab-bar-pic {
display: none;
background: #f9f9f9;
&.active {
display: block;
}
}
}
&.active {
display: block;
}
}
}
.tab-bar-pic {
display: block;
background: #f9f9f9;
.tab-bar-pic {
display: block;
background: #f9f9f9;
&.active {
display: none;
}
}
}
&.active {
display: none;
}
}
}
.tab-bar-pic {
width: 25px;
height: 25px;
background: #f9f9f9;
.tab-bar-pic {
width: 25px;
height: 25px;
background: #f9f9f9;
image {
width: 25px;
height: 25px;
}
}
image {
width: 25px;
height: 25px;
}
}
.tab-bar-pic-active {
}
.tab-bar-pic-active {
}
text {
font-size: 10px;
color: rgb(160, 160, 160);
line-height: 10px;
margin-top: 5px;
}
text {
font-size: 10px;
color: rgb(160, 160, 160);
line-height: 10px;
margin-top: 5px;
}
}
.tab-bar-bg {
padding-top: 46px;
width: 100%;
padding-top: 46px;
width: 100%;
}
.view-item {
display: none;
width: 100%;
display: none;
width: 100%;
}
.view-item-active {
display: block;
display: block;
}
.getUserInfo {
display: flex;
align-items: center;
flex-direction: column;
padding: 30px;
display: flex;
align-items: center;
flex-direction: column;
padding: 30px;
p {
margin-bottom: 20px;
}
p {
margin-bottom: 20px;
}
}
._van-dialog {
z-index: 99999999999;
z-index: 99999999999;
}
</style>

View File

@ -199,17 +199,19 @@ export default {
DataFormat
},
computed: mapGetters(["userInfo"]),
watch: {
$yroute(n) {
if (n.name === NAME) {
const type = parseInt(this.$yroute.query.type) || 0;
if (this.type !== type) {
this.changeType(type);
}
this.getOrderData();
}
},
type() {}
onShow: function() {
console.log(this)
this.type = parseInt(this.$yroute.query.type) || 0;
this.changeType(this.type);
this.getOrderData();
this.getOrderList();
},
onHide: function() {
this.orderList = [];
this.page = 1;
this.limit = 20;
this.loaded = false;
this.loading = false;
},
methods: {
goLogistics(order) {
@ -308,11 +310,7 @@ export default {
},
toPay() {}
},
mounted() {
this.type = parseInt(this.$yroute.query.type) || 0;
this.getOrderData();
this.getOrderList();
},
mounted() {},
onReachBottom() {
!this.loading && this.getOrderList();
}
@ -320,7 +318,6 @@ export default {
</script>
<style scoped lang="less">
.noCart {
margin-top: 0.17 * 100rpx;
padding-top: 0.1 * 100rpx;

View File

@ -482,9 +482,9 @@
uni.showLoading({
title: "生成订单中"
});
let form = {}
let from = {}
if (this.$deviceType == 'app') {
form.form = 'app'
from.from = 'app'
}
createOrder(this.orderGroupInfo.orderKey, {
realName: this.contacts,
@ -500,7 +500,7 @@
from: this.from,
mark: this.mark || "",
shippingType: parseInt(shipping_type) + 1,
...form
...from
})
.then(res => {
uni.hideLoading();

View File

@ -266,6 +266,7 @@ export default {
console.log(url);
if (url && url.productId) {
this.id = url.productId;
} else {
this.id = this._route.query.id;
}
@ -339,12 +340,12 @@ export default {
//产品详情接口;
productCon: function() {
let that = this;
let form = {};
let from = {};
if (this.$deviceType == "app") {
form.form = "app";
from.from = "app";
}
uni.showLoading({ title: "加载中", mask: true });
getProductDetail(that.id, form)
getProductDetail(that.id, from)
.then(res => {
that.$set(that, "storeInfo", res.data.storeInfo);
// 给 attr 赋值,将请求回来的规格赋值给 attr

View File

@ -196,12 +196,22 @@
icon: "success",
duration: 2000
});
this.$yrouter.push({
path: "/pages/order/OrderDetails/index",
query: {
id: this.orderCon.orderId
}
});
// ? 回跳到上一页
this.$yrouter.back()
// ? 默认跳转到详情页
// this.$yrouter.push({
// path: "/pages/order/OrderDetails/index",
// query: {
// id: this.orderCon.orderId
// }
// });
// ? 可选重定向到详情页,这时左上角会有一个返回首页的图标
// this.$yrouter.reLaunch({
// path: "/pages/home/index",
// });
})
.catch(err => {
uni.showToast({

View File

@ -164,11 +164,11 @@
</view>
</template>
<script>
import { mapState, mapGetters, mapMutations, mapActions } from "vuex";
import { getUser, getMenuUser, bindingPhone } from "@/api/user";
import { isWeixin, VUE_APP_RESOURCES_URL } from "@/utils";
import SwitchWindow from "@/components/SwitchWindow";
import Authorization from "@/pages/authorization/index";
import { mapGetters } from "vuex";
const NAME = "User";
@ -188,6 +188,7 @@ export default {
},
computed: mapGetters(["userInfo"]),
methods: {
...mapMutations(["UPDATE_AUTHORIZATIONPAGE", "CHANGE_TABTAR"]),
goReturnList() {
this.$yrouter.push("/pages/order/ReturnList/index");
},
@ -291,9 +292,15 @@ export default {
},
MenuUser: function() {
let that = this;
getMenuUser().then(res => {
that.MyMenus = res.data.routine_my_menus;
});
getMenuUser()
.then(res => {
uni.hideLoading();
that.MyMenus = res.data.routine_my_menus;
})
.catch(error => {
uni.hideLoading();
console.log(error);
});
},
goPages: function(index) {
let url = this.MyMenus[index].uniapp_url;
@ -335,12 +342,18 @@ export default {
},
onShow() {
if (this.$store.getters.token) {
//
this.$store.dispatch('getUser', true)
//
uni.showLoading({
title: "加载中"
});
this.$store.dispatch("getUser", true);
this.MenuUser();
this.isWeixin = isWeixin();
}
},
onHide() {
console.log('离开用户中心')
this.UPDATE_AUTHORIZATIONPAGE(false);
}
};
</script>

View File

@ -64,11 +64,11 @@ export default {
methods: {
getIndex: function() {
let that = this;
let form = {};
let from = {};
if (this.$deviceType == "app") {
form.form = "app";
from.from = "app";
}
getSpreadImg(form).then(
getSpreadImg(from).then(
res => {
that.info = res.data;
},