Browse Source

1.优化登录流程

2.uniapp评价完成后要连需3-4次返回才能到首页(体验不是很好)
master
gaoxs 5 years ago
parent
commit
d7e0875381
  1. 17
      pages/authorization/index.vue
  2. 31
      pages/order/MyOrder/index.vue
  3. 6
      pages/order/OrderSubmission/index.vue
  4. 6
      pages/shop/GoodsCon/index.vue
  5. 22
      pages/shop/GoodsEvaluate/index.vue
  6. 19
      pages/user/User/index.vue
  7. 6
      pages/user/promotion/Poster/index.vue
  8. 52
      utils/index.js

17
pages/authorization/index.vue

@ -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);

31
pages/order/MyOrder/index.vue

@ -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;

6
pages/order/OrderSubmission/index.vue

@ -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();

6
pages/shop/GoodsCon/index.vue

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

22
pages/shop/GoodsEvaluate/index.vue

@ -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({

19
pages/user/User/index.vue

@ -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();
}

6
pages/user/promotion/Poster/index.vue

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

52
utils/index.js

@ -403,7 +403,7 @@ export const handleLoginStatus = (location, complete, fail, success) => {
// }
export function routerPermissions(url) {
export function routerPermissions(url, type) {
let path = url
if (!path) {
path = getCurrentPageUrlWithArgs()
@ -416,9 +416,15 @@ export function routerPermissions(url) {
// 自动登录
login().then(res => {
// 登录成功,跳转到需要跳转的页面
push({
path,
})
if (type == 'reLaunch') {
reLaunch({
path,
})
} else {
push({
path,
})
}
}).catch(error => {
uni.showToast({
title: error,
@ -687,9 +693,7 @@ export const handleLoginFailure = () => {
// cookie.set("spread", url.spread || 0);
} else {
console.log('是拼团进来的,但是没有获取到参数')
switchTab({
path: '/pages/home/index',
});
handleNoParameters()
}
}
@ -697,15 +701,6 @@ export const handleLoginFailure = () => {
if (getCurrentPageUrl() == 'pages/activity/DargainDetails/index' && handleQrCode()) {
console.log('是扫描的砍价海报进来的')
let url = handleQrCode();
console.log(url)
// bargainId: "36"
// bargainUserUid: 1404
// bargainId: "36"
// codeType: "routine"
// pageType: "dargain"
// spread: "1404"
// uid: "1404"
if (url) {
path = parseUrl({
path: `/${getCurrentPageUrl()}`,
@ -716,10 +711,9 @@ export const handleLoginFailure = () => {
})
// cookie.set("spread", url.spread || 0);
} else {
handleNoParameters()
console.log('是扫描的砍价海报进来的,但是没有获取到参数')
switchTab({
path: '/pages/home/index',
});
}
}
@ -736,12 +730,24 @@ export const handleLoginFailure = () => {
})
cookie.set("spread", url.spread || 0);
} else {
switchTab({
path: '/pages/home/index',
});
handleNoParameters()
console.log('是扫描的商品详情进来的,但是没有获取到参数')
}
}
routerPermissions(path)
routerPermissions(path, 'reLaunch')
}
const handleNoParameters = () => {
uni.showToast({
title: '未获取到必要参数,即将跳转首页',
icon: 'success',
duration: 2000
})
setTimeout(() => {
clearTimeout()
switchTab({
path: '/pages/home/index',
});
}, 1500)
}

Loading…
Cancel
Save