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

31
pages/order/MyOrder/index.vue

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

6
pages/order/OrderSubmission/index.vue

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

6
pages/shop/GoodsCon/index.vue

@ -340,12 +340,12 @@ export default {
// //
productCon: function() { productCon: function() {
let that = this; let that = this;
let form = {}; let from = {};
if (this.$deviceType == "app") { if (this.$deviceType == "app") {
form.form = "app"; from.from = "app";
} }
uni.showLoading({ title: "加载中", mask: true }); uni.showLoading({ title: "加载中", mask: true });
getProductDetail(that.id, form) getProductDetail(that.id, from)
.then(res => { .then(res => {
that.$set(that, "storeInfo", res.data.storeInfo); that.$set(that, "storeInfo", res.data.storeInfo);
// attr attr // attr attr

22
pages/shop/GoodsEvaluate/index.vue

@ -196,12 +196,22 @@
icon: "success", icon: "success",
duration: 2000 duration: 2000
}); });
this.$yrouter.push({
path: "/pages/order/OrderDetails/index", // ?
query: { this.$yrouter.back()
id: this.orderCon.orderId
} // ?
}); // this.$yrouter.push({
// path: "/pages/order/OrderDetails/index",
// query: {
// id: this.orderCon.orderId
// }
// });
// ?
// this.$yrouter.reLaunch({
// path: "/pages/home/index",
// });
}) })
.catch(err => { .catch(err => {
uni.showToast({ uni.showToast({

19
pages/user/User/index.vue

@ -291,9 +291,14 @@ export default {
}, },
MenuUser: function() { MenuUser: function() {
let that = this; let that = this;
getMenuUser().then(res => { getMenuUser()
that.MyMenus = res.data.routine_my_menus; .then(res => {
}); uni.hideLoading();
that.MyMenus = res.data.routine_my_menus;
})
.catch(error => {
console.log(error);
});
}, },
goPages: function(index) { goPages: function(index) {
let url = this.MyMenus[index].uniapp_url; let url = this.MyMenus[index].uniapp_url;
@ -335,9 +340,11 @@ export default {
}, },
onShow() { onShow() {
if (this.$store.getters.token) { if (this.$store.getters.token) {
// //
this.$store.dispatch('getUser', true) uni.showLoading({
title: "绑定中"
});
this.$store.dispatch("getUser", true);
this.MenuUser(); this.MenuUser();
this.isWeixin = isWeixin(); this.isWeixin = isWeixin();
} }

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

@ -64,11 +64,11 @@ export default {
methods: { methods: {
getIndex: function() { getIndex: function() {
let that = this; let that = this;
let form = {}; let from = {};
if (this.$deviceType == "app") { if (this.$deviceType == "app") {
form.form = "app"; from.from = "app";
} }
getSpreadImg(form).then( getSpreadImg(from).then(
res => { res => {
that.info = res.data; 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 let path = url
if (!path) { if (!path) {
path = getCurrentPageUrlWithArgs() path = getCurrentPageUrlWithArgs()
@ -416,9 +416,15 @@ export function routerPermissions(url) {
// 自动登录 // 自动登录
login().then(res => { login().then(res => {
// 登录成功,跳转到需要跳转的页面 // 登录成功,跳转到需要跳转的页面
push({ if (type == 'reLaunch') {
path, reLaunch({
}) path,
})
} else {
push({
path,
})
}
}).catch(error => { }).catch(error => {
uni.showToast({ uni.showToast({
title: error, title: error,
@ -687,9 +693,7 @@ export const handleLoginFailure = () => {
// cookie.set("spread", url.spread || 0); // cookie.set("spread", url.spread || 0);
} else { } else {
console.log('是拼团进来的,但是没有获取到参数') console.log('是拼团进来的,但是没有获取到参数')
switchTab({ handleNoParameters()
path: '/pages/home/index',
});
} }
} }
@ -697,15 +701,6 @@ export const handleLoginFailure = () => {
if (getCurrentPageUrl() == 'pages/activity/DargainDetails/index' && handleQrCode()) { if (getCurrentPageUrl() == 'pages/activity/DargainDetails/index' && handleQrCode()) {
console.log('是扫描的砍价海报进来的') console.log('是扫描的砍价海报进来的')
let url = handleQrCode(); let url = handleQrCode();
console.log(url)
// bargainId: "36"
// bargainUserUid: 1404
// bargainId: "36"
// codeType: "routine"
// pageType: "dargain"
// spread: "1404"
// uid: "1404"
if (url) { if (url) {
path = parseUrl({ path = parseUrl({
path: `/${getCurrentPageUrl()}`, path: `/${getCurrentPageUrl()}`,
@ -716,10 +711,9 @@ export const handleLoginFailure = () => {
}) })
// cookie.set("spread", url.spread || 0); // cookie.set("spread", url.spread || 0);
} else { } else {
handleNoParameters()
console.log('是扫描的砍价海报进来的,但是没有获取到参数') console.log('是扫描的砍价海报进来的,但是没有获取到参数')
switchTab({
path: '/pages/home/index',
});
} }
} }
@ -736,12 +730,24 @@ export const handleLoginFailure = () => {
}) })
cookie.set("spread", url.spread || 0); cookie.set("spread", url.spread || 0);
} else { } else {
switchTab({ handleNoParameters()
path: '/pages/home/index',
});
console.log('是扫描的商品详情进来的,但是没有获取到参数') 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