1.优化登录流程

2.uniapp评价完成后要连需3-4次返回才能到首页(体验不是很好)
This commit is contained in:
gaoxs
2020-06-03 10:58:31 +08:00
parent 15694002e8
commit d7e0875381
8 changed files with 94 additions and 65 deletions

View File

@ -2,7 +2,7 @@
<view class="container">
<view v-if="!token">
<!-- 小程序 -->
<view v-if="$deviceType == 'routine'">
<view v-if="$deviceType == 'routine'&&!authorize">
<view class="getUserInfo">
<text>您还未允许微信登录授权请点击下方按钮允许微信授权登录</text>
<button type="primary" open-type="getUserInfo" @getuserinfo="getUserInfo">允许微信登录授权</button>
@ -11,7 +11,7 @@
</view>
</view>
<!-- app -->
<view v-if="$deviceType == 'app'">
<view v-if="$deviceType == 'app'&&!authorize">
<view class="getUserInfo">
<text>请先登录</text>
<button type="primary" @click="this.toLogin">去登录</button>
@ -28,17 +28,26 @@ import { mapState, mapMutations, mapActions } from "vuex";
import { wxappAuth, getUser } from "@/api/user";
import dayjs from "dayjs";
import cookie from "@/utils/store/cookie";
import { login } from "@/utils";
import { login, authorize } from "@/utils";
export default {
data() {
return {};
return {
authorize: true
};
},
computed: {
...mapState(["isAuthorization", "$deviceType", "token"])
},
onShow() {
this.UPDATE_AUTHORIZATIONPAGE(true);
// 先校验用户是否授权,如果没有授权,显示授权按钮
authorize("userInfo")
.then(() => {})
.catch(error => {
// 用户未授权,显示授权按钮
this.authorize = true;
});
},
onHide() {
this.UPDATE_AUTHORIZATIONPAGE(false);

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

@ -340,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

@ -291,9 +291,14 @@ 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 => {
console.log(error);
});
},
goPages: function(index) {
let url = this.MyMenus[index].uniapp_url;
@ -335,9 +340,11 @@ 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();
}

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;
},