优化登录的逻辑,
This commit is contained in:
+2
-15
@@ -1,10 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<view>
|
<view>
|
||||||
<view v-if="isIpx" class="iphonex-footer-bg"></view>
|
<view class="footer-bg"></view>
|
||||||
<view v-else class="footer-bg"></view>
|
|
||||||
<view id="footer" :class="[isIpx ? 'iphonex-footer' : '', 'acea-row row-middle'] ">
|
<view id="footer" :class="[isIpx ? 'iphonex-footer' : '', 'acea-row row-middle'] ">
|
||||||
<view
|
<view
|
||||||
@click="changeTabtar(footerIndex)"
|
|
||||||
class="item"
|
class="item"
|
||||||
:class="{ on: footerIndex == tabtarIndex }"
|
:class="{ on: footerIndex == tabtarIndex }"
|
||||||
v-for="(item, footerIndex) in footerList"
|
v-for="(item, footerIndex) in footerList"
|
||||||
@@ -59,20 +57,9 @@ export default {
|
|||||||
...mapState(["tabtarIndex"])
|
...mapState(["tabtarIndex"])
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(["changeTabtar"])
|
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
let that = this;
|
|
||||||
this.changeTabtar(this.$yroute.query.type);
|
|
||||||
wx.getSystemInfo({
|
|
||||||
success: function(res) {
|
|
||||||
console.log(res);
|
|
||||||
var name = "iPhone X";
|
|
||||||
if (res.model.indexOf(name) > -1) {
|
|
||||||
that.isIpx = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
+20
-7
@@ -1,14 +1,26 @@
|
|||||||
// import router from "../router";
|
// import router from "../router";
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
import cookie from "@/utils/store/cookie";
|
import cookie from "@/utils/store/cookie";
|
||||||
import { isWeixin, login, getCurrentPageUrl, getCurrentPageUrlWithArgs, parseQuery, replace, handleQrCode } from "@/utils";
|
import {
|
||||||
|
isWeixin,
|
||||||
|
login,
|
||||||
|
replaceLogin,
|
||||||
|
getCurrentPageUrl,
|
||||||
|
getCurrentPageUrlWithArgs,
|
||||||
|
parseQuery,
|
||||||
|
replace,
|
||||||
|
handleQrCode
|
||||||
|
} from "@/utils";
|
||||||
|
|
||||||
export default function toLogin(push, backUrl) {
|
export default function toLogin(push, backUrl) {
|
||||||
store.commit("LOGOUT");
|
store.commit("LOGOUT");
|
||||||
|
// 如果没有授权,走登录的接口重新授权
|
||||||
|
// 授权获取失败会跳转到授权的接口
|
||||||
if (store.getters.isAuthorization) {
|
if (store.getters.isAuthorization) {
|
||||||
login()
|
login()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// 判断当前是不是已经在登录页面或者授权页,防止二次跳转
|
||||||
if (store.getters.isAuthorizationPage || getCurrentPageUrl() == '/pages/user/Login/index') {
|
if (store.getters.isAuthorizationPage || getCurrentPageUrl() == '/pages/user/Login/index') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -17,16 +29,17 @@ export default function toLogin(push, backUrl) {
|
|||||||
if (getCurrentPageUrl() == 'pages/activity/DargainDetails/index' && handleQrCode()) {
|
if (getCurrentPageUrl() == 'pages/activity/DargainDetails/index' && handleQrCode()) {
|
||||||
let url = handleQrCode();
|
let url = handleQrCode();
|
||||||
if (url) {
|
if (url) {
|
||||||
console.log(222222222)
|
replaceLogin({
|
||||||
replace({ path: '/pages/user/Login/index', query: { redirect: `/${getCurrentPageUrl()}`, id: url.bargainId, partake: url.uid } })
|
redirect: `/${getCurrentPageUrl()}`,
|
||||||
|
id: url.bargainId,
|
||||||
|
partake: url.uid
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
replace({ path: '/pages/user/Login/index', query: { redirect: `/${getCurrentPageUrl()}`, ...parseQuery() } })
|
replaceLogin()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(222222222)
|
replaceLogin()
|
||||||
replace({ path: '/pages/user/Login/index', query: { redirect: `/${getCurrentPageUrl()}`, ...parseQuery() } })
|
|
||||||
}
|
}
|
||||||
store.commit("UPDATE_AUTHORIZATION", false);
|
store.commit("UPDATE_AUTHORIZATION", false);
|
||||||
store.commit("UPDATE_AUTHORIZATIONPAGE", true);
|
store.commit("UPDATE_AUTHORIZATIONPAGE", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
export const weappPay = (option) => {
|
export const weappPay = (option) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// 吊起微信支付
|
// 吊起微信支付
|
||||||
wx.requestPayment({
|
uni.requestPayment({
|
||||||
...option,
|
...option,
|
||||||
timeStamp: option.timeStamp + '',
|
timeStamp: option.timeStamp + '',
|
||||||
success: (success) => {
|
success: (success) => {
|
||||||
|
|||||||
@@ -323,7 +323,7 @@ export default {
|
|||||||
.catch(err => {
|
.catch(err => {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: err.msg || err.response.data.msg,
|
title: err.msg || err.response.data.msg,
|
||||||
icon: 'none',
|
icon: "none",
|
||||||
duration: 2000
|
duration: 2000
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,33 +2,24 @@
|
|||||||
<view class="container">
|
<view class="container">
|
||||||
<view v-if="!isAuthorization">
|
<view v-if="!isAuthorization">
|
||||||
<view class="getUserInfo">
|
<view class="getUserInfo">
|
||||||
<view>您还未允许微信登录授权,请点击下方按钮允许微信授权登录。</text>
|
<text>您还未允许微信登录授权,请点击下方按钮允许微信授权登录。</text>
|
||||||
<vant-button type="primary" open-type="getUserInfo" @getuserinfo="getUserInfo">允许微信登录授权</vant-button>
|
<view style="height:20rpx"></view>
|
||||||
<view class="sp-cell"></view>
|
<button type="primary" open-type="getUserInfo" @getuserinfo="getUserInfo">允许微信登录授权</button>
|
||||||
<vant-button type="default" @click="back">取消微信登录授权</vant-button>
|
<view style="height:20rpx"></view>
|
||||||
</view>
|
<button @click="back">取消微信登录授权</button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {
|
import { mapState, mapMutations, mapActions } from "vuex";
|
||||||
mapState,
|
|
||||||
mapMutations,
|
|
||||||
mapActions
|
|
||||||
} from "vuex";
|
|
||||||
// 组件
|
// 组件
|
||||||
// import request from "@//api/request";
|
// import request from "@//api/request";
|
||||||
import {
|
import { wxappAuth, getUser } from "@/api/user";
|
||||||
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 {
|
import { login } from "@/utils";
|
||||||
login
|
|
||||||
} from "@/utils";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@@ -38,41 +29,40 @@
|
|||||||
...mapState(["isAuthorization"])
|
...mapState(["isAuthorization"])
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
this.UPDATE_AUTHORIZATIONPAGE(false);
|
this.UPDATE_AUTHORIZATIONPAGE(true);
|
||||||
},
|
},
|
||||||
onHide() {
|
onHide() {
|
||||||
|
this.UPDATE_AUTHORIZATIONPAGE(false);
|
||||||
this.changeAuthorization(false);
|
this.changeAuthorization(false);
|
||||||
},
|
},
|
||||||
onUnload() {
|
onUnload() {
|
||||||
|
this.UPDATE_AUTHORIZATIONPAGE(false);
|
||||||
this.changeAuthorization(false);
|
this.changeAuthorization(false);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(["changeAuthorization", "changeUserInfo"]),
|
...mapActions(["changeAuthorization", "changeUserInfo"]),
|
||||||
...mapMutations(["UPDATE_AUTHORIZATIONPAGE", "CHANGE_TABTAR"]),
|
...mapMutations(["UPDATE_AUTHORIZATIONPAGE", "CHANGE_TABTAR"]),
|
||||||
back() {
|
back() {
|
||||||
// if (this.$yroute.query.redirect) {
|
this.$yrouter.switchTab({
|
||||||
// this.$yrouter.replace({
|
|
||||||
// path: this.$yroute.query.redirect
|
|
||||||
// });
|
|
||||||
// } else {
|
|
||||||
// this.$yrouter.replace({
|
|
||||||
// path: "/pages/launch/index",
|
|
||||||
// query: { type: 0 }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
this.CHANGE_TABTAR(0);
|
|
||||||
this.$yrouter.replace({
|
|
||||||
path: "/pages/home/index",
|
path: "/pages/home/index",
|
||||||
query: {
|
query: {}
|
||||||
type: 0
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getUserInfo(data) {
|
getUserInfo(data) {
|
||||||
|
if (data.detail.errMsg == "getUserInfo:fail auth deny") {
|
||||||
|
uni.showToast({
|
||||||
|
title: "取消授权",
|
||||||
|
icon: "none",
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: "登录中"
|
title: "登录中"
|
||||||
});
|
});
|
||||||
login();
|
login({
|
||||||
|
success: () => {}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onUnload() {},
|
onUnload() {},
|
||||||
@@ -160,7 +150,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab-bar-pic-active {}
|
.tab-bar-pic-active {
|
||||||
|
}
|
||||||
|
|
||||||
text {
|
text {
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
|
|||||||
@@ -254,6 +254,9 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted: function() {
|
mounted: function() {
|
||||||
let that = this;
|
let that = this;
|
||||||
|
uni.showLoading({
|
||||||
|
title:'加载中'
|
||||||
|
})
|
||||||
getHomeData().then(res => {
|
getHomeData().then(res => {
|
||||||
that.logoUrl = res.data.logoUrl;
|
that.logoUrl = res.data.logoUrl;
|
||||||
that.$set(that, "banner", res.data.banner);
|
that.$set(that, "banner", res.data.banner);
|
||||||
@@ -269,6 +272,7 @@ export default {
|
|||||||
that.$set(that, "lovely", res.data.lovely);
|
that.$set(that, "lovely", res.data.lovely);
|
||||||
that.$set(that, "benefit", res.data.benefit);
|
that.$set(that, "benefit", res.data.benefit);
|
||||||
that.$set(that, "couponList", res.data.couponList);
|
that.$set(that, "couponList", res.data.couponList);
|
||||||
|
uni.hideLoading()
|
||||||
that.setOpenShare();
|
that.setOpenShare();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -43,22 +43,18 @@ export default {
|
|||||||
...mapState(["tabtarIndex"])
|
...mapState(["tabtarIndex"])
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(["changeTabtar"])
|
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
let type = this.$yroute.query.type;
|
let type = this.$yroute.query.type;
|
||||||
console.log(2222)
|
console.log(2222)
|
||||||
if (type) {
|
if (type) {
|
||||||
this.changeTabtar(type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (!this.tabtarIndex) {
|
// if (!this.tabtarIndex) {
|
||||||
// this.changeTabtar(0);
|
|
||||||
// }
|
// }
|
||||||
},
|
},
|
||||||
onHide() {
|
onHide() {
|
||||||
console.log("清除状态");
|
console.log("清除状态");
|
||||||
// this.changeTabtar(0);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -496,6 +496,7 @@
|
|||||||
methods: {
|
methods: {
|
||||||
copyClipboard,
|
copyClipboard,
|
||||||
showChang: function() {
|
showChang: function() {
|
||||||
|
// 这里判断是不是微信小程序
|
||||||
if (isWeixin()) {
|
if (isWeixin()) {
|
||||||
let config = {
|
let config = {
|
||||||
latitude: this.system_store.latitude,
|
latitude: this.system_store.latitude,
|
||||||
@@ -503,14 +504,6 @@
|
|||||||
name: this.system_store.name,
|
name: this.system_store.name,
|
||||||
address: this.system_store._detailed_address
|
address: this.system_store._detailed_address
|
||||||
};
|
};
|
||||||
// wechatEvevt("openLocation", config)
|
|
||||||
// .then(res => {
|
|
||||||
// })
|
|
||||||
// .catch(res => {
|
|
||||||
// if (res.is_ready) {
|
|
||||||
// res.wx.openLocation(config);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
} else {
|
} else {
|
||||||
if (!this.mapKey)
|
if (!this.mapKey)
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
|
|||||||
@@ -152,43 +152,7 @@
|
|||||||
},
|
},
|
||||||
openQRCode: function() {
|
openQRCode: function() {
|
||||||
let that = this;
|
let that = this;
|
||||||
// wechatEvevt("scanQRCode", {
|
// 这里需要调用扫码功能
|
||||||
// needResult: 1,
|
|
||||||
// scanType: ["qrCode", "barCode"]
|
|
||||||
// })
|
|
||||||
// .then(res => {
|
|
||||||
// if (res.resultStr) {
|
|
||||||
// that.verify_code = res.resultStr;
|
|
||||||
// that.storeCancellation();
|
|
||||||
// } else {
|
|
||||||
// uni.showToast({
|
|
||||||
// title: '没有扫描到什么!',
|
|
||||||
// icon: "none",
|
|
||||||
// duration: 2000
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// .catch(res => {
|
|
||||||
// if (res.is_ready) {
|
|
||||||
// res.wx.scanQRCode({
|
|
||||||
// needResult: 1,
|
|
||||||
// scanType: ["qrCode", "barCode"],
|
|
||||||
// success: function(res) {
|
|
||||||
// that.verify_code = res.resultStr;
|
|
||||||
// that.storeCancellation();
|
|
||||||
// },
|
|
||||||
// fail: function(res) {
|
|
||||||
// if (res.errMsg == "scanQRCode:permission denied") {
|
|
||||||
// uni.showToast({
|
|
||||||
// title: '没有权限',
|
|
||||||
// icon: "none",
|
|
||||||
// duration: 2000
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -288,14 +288,6 @@ export default {
|
|||||||
name: this.system_store.name,
|
name: this.system_store.name,
|
||||||
address: this.system_store._detailed_address
|
address: this.system_store._detailed_address
|
||||||
};
|
};
|
||||||
// wechatEvevt("openLocation", config)
|
|
||||||
// .then(res => {
|
|
||||||
// })
|
|
||||||
// .catch(res => {
|
|
||||||
// if (res.is_ready) {
|
|
||||||
// res.wx.openLocation(config);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
} else {
|
} else {
|
||||||
if (!this.mapKey) {
|
if (!this.mapKey) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="shoppingCart">
|
<view class="shoppingCart">
|
||||||
|
<view class v-if="userInfo.uid">
|
||||||
<view class="labelNav acea-row row-around row-middle">
|
<view class="labelNav acea-row row-around row-middle">
|
||||||
<view class="item">
|
<view class="item">
|
||||||
<text class="iconfont icon-xuanzhong"></text>100%正品保证
|
<text class="iconfont icon-xuanzhong"></text>100%正品保证
|
||||||
@@ -16,11 +17,19 @@
|
|||||||
购物数量
|
购物数量
|
||||||
<text class="num font-color-red">{{ count }}</text>
|
<text class="num font-color-red">{{ count }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="cartList.valid.length > 0" class="administrate acea-row row-center-wrapper" @click="manage">{{ footerswitch ? "取消" : "管理" }}</view>
|
<view
|
||||||
|
v-if="cartList.valid.length > 0"
|
||||||
|
class="administrate acea-row row-center-wrapper"
|
||||||
|
@click="manage"
|
||||||
|
>{{ footerswitch ? "取消" : "管理" }}</view>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="validList.length > 0 || cartList.invalid.length > 0">
|
<view v-if="validList.length > 0 || cartList.invalid.length > 0">
|
||||||
<view class="list">
|
<view class="list">
|
||||||
<view class="item acea-row row-between-wrapper" v-for="(item, cartListValidIndex) in validList" :key="cartListValidIndex">
|
<view
|
||||||
|
class="item acea-row row-between-wrapper"
|
||||||
|
v-for="(item, cartListValidIndex) in validList"
|
||||||
|
:key="cartListValidIndex"
|
||||||
|
>
|
||||||
<view class="select-btn">
|
<view class="select-btn">
|
||||||
<view class="checkbox-wrapper">
|
<view class="checkbox-wrapper">
|
||||||
<checkbox-group @change="switchSelect(cartListValidIndex)">
|
<checkbox-group @change="switchSelect(cartListValidIndex)">
|
||||||
@@ -37,16 +46,31 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="text">
|
<view class="text">
|
||||||
<view class="line1">{{ item.productInfo.storeName }}</view>
|
<view class="line1">{{ item.productInfo.storeName }}</view>
|
||||||
<view class="infor line1" v-if="item.productInfo.attrInfo">属性:{{ item.productInfo.attrInfo.suk }}</view>
|
<view
|
||||||
|
class="infor line1"
|
||||||
|
v-if="item.productInfo.attrInfo"
|
||||||
|
>属性:{{ item.productInfo.attrInfo.suk }}</view>
|
||||||
<view class="money">¥{{ item.truePrice }}</view>
|
<view class="money">¥{{ item.truePrice }}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="carnum acea-row row-center-wrapper">
|
<view class="carnum acea-row row-center-wrapper">
|
||||||
<view class="reduce" :class="validList[cartListValidIndex].cartNum <= 1 ? 'on' : ''" @click.prevent="reduce(cartListValidIndex)">-</view>
|
<view
|
||||||
|
class="reduce"
|
||||||
|
:class="validList[cartListValidIndex].cartNum <= 1 ? 'on' : ''"
|
||||||
|
@click.prevent="reduce(cartListValidIndex)"
|
||||||
|
>-</view>
|
||||||
<view class="num">{{ item.cartNum }}</view>
|
<view class="num">{{ item.cartNum }}</view>
|
||||||
<view class="plus" v-if="validList[cartListValidIndex].attrInfo" :class="validList[cartListValidIndex].cartNum >=validList[cartListValidIndex].attrInfo.stock? 'on': ''"
|
<view
|
||||||
@click.prevent="plus(cartListValidIndex)">+</view>
|
class="plus"
|
||||||
<view class="plus" v-else :class="validList[cartListValidIndex].cartNum >= validList[cartListValidIndex].stock? 'on': ''"
|
v-if="validList[cartListValidIndex].attrInfo"
|
||||||
@click.prevent="plus(cartListValidIndex)">+</view>
|
:class="validList[cartListValidIndex].cartNum >=validList[cartListValidIndex].attrInfo.stock? 'on': ''"
|
||||||
|
@click.prevent="plus(cartListValidIndex)"
|
||||||
|
>+</view>
|
||||||
|
<view
|
||||||
|
class="plus"
|
||||||
|
v-else
|
||||||
|
:class="validList[cartListValidIndex].cartNum >= validList[cartListValidIndex].stock? 'on': ''"
|
||||||
|
@click.prevent="plus(cartListValidIndex)"
|
||||||
|
>+</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -54,15 +78,25 @@
|
|||||||
<view class="invalidGoods" v-if="cartList.invalid.length > 0">
|
<view class="invalidGoods" v-if="cartList.invalid.length > 0">
|
||||||
<view class="goodsNav acea-row row-between-wrapper">
|
<view class="goodsNav acea-row row-between-wrapper">
|
||||||
<view @click="goodsOpen">
|
<view @click="goodsOpen">
|
||||||
<text class="iconfont" :class="goodsHidden === true ? 'icon-xiangyou' : 'icon-xiangxia'"></text>失效商品
|
<text
|
||||||
|
class="iconfont"
|
||||||
|
:class="goodsHidden === true ? 'icon-xiangyou' : 'icon-xiangxia'"
|
||||||
|
></text>失效商品
|
||||||
</view>
|
</view>
|
||||||
<view class="del" @click="delInvalidGoods">
|
<view class="del" @click="delInvalidGoods">
|
||||||
<text class="iconfont icon-shanchu1"></text>清空
|
<text class="iconfont icon-shanchu1"></text>清空
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="goodsList" :hidden="goodsHidden">
|
<view class="goodsList" :hidden="goodsHidden">
|
||||||
<view v-for="(item, cartListinvalidIndex) in cartList.invalid" :key="cartListinvalidIndex">
|
<view
|
||||||
<view @click="goGoodsCon(item)" class="item acea-row row-between-wrapper" v-if="item.productInfo">
|
v-for="(item, cartListinvalidIndex) in cartList.invalid"
|
||||||
|
:key="cartListinvalidIndex"
|
||||||
|
>
|
||||||
|
<view
|
||||||
|
@click="goGoodsCon(item)"
|
||||||
|
class="item acea-row row-between-wrapper"
|
||||||
|
v-if="item.productInfo"
|
||||||
|
>
|
||||||
<view class="invalid acea-row row-center-wrapper">失效</view>
|
<view class="invalid acea-row row-center-wrapper">失效</view>
|
||||||
<view class="pictrue">
|
<view class="pictrue">
|
||||||
<image :src="item.productInfo.attrInfo.image" v-if="item.productInfo.attrInfo" />
|
<image :src="item.productInfo.attrInfo.image" v-if="item.productInfo.attrInfo" />
|
||||||
@@ -70,7 +104,10 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="text acea-row row-column-between">
|
<view class="text acea-row row-column-between">
|
||||||
<view class="line1">{{ item.productInfo.storeName }}</view>
|
<view class="line1">{{ item.productInfo.storeName }}</view>
|
||||||
<view class="infor line1" v-if="item.productInfo.attrInfo">属性:{{ item.productInfo.attrInfo.suk }}</view>
|
<view
|
||||||
|
class="infor line1"
|
||||||
|
v-if="item.productInfo.attrInfo"
|
||||||
|
>属性:{{ item.productInfo.attrInfo.suk }}</view>
|
||||||
<view class="acea-row row-between-wrapper">
|
<view class="acea-row row-between-wrapper">
|
||||||
<view class="end">该商品已下架</view>
|
<view class="end">该商品已下架</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -123,22 +160,22 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<Authorization v-else />
|
||||||
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import Recommend from "@/components/Recommend";
|
import Recommend from "@/components/Recommend";
|
||||||
|
import Authorization from "@/pages/authorization/index";
|
||||||
|
import { mapGetters } from "vuex";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getCartList,
|
getCartList,
|
||||||
postCartDel,
|
postCartDel,
|
||||||
changeCartNum,
|
changeCartNum,
|
||||||
getCartCount
|
getCartCount
|
||||||
} from "@/api/store";
|
} from "@/api/store";
|
||||||
import {
|
import { postCollectAll } from "@/api/user";
|
||||||
postCollectAll
|
import { mul, add } from "@/utils/bc";
|
||||||
} from "@/api/user";
|
|
||||||
import {
|
|
||||||
mul,
|
|
||||||
add
|
|
||||||
} from "@/utils/bc";
|
|
||||||
import cookie from "@/utils/store/cookie";
|
import cookie from "@/utils/store/cookie";
|
||||||
import debounce from "lodash.debounce";
|
import debounce from "lodash.debounce";
|
||||||
|
|
||||||
@@ -147,12 +184,12 @@
|
|||||||
export default {
|
export default {
|
||||||
name: "ShoppingCart",
|
name: "ShoppingCart",
|
||||||
components: {
|
components: {
|
||||||
Recommend
|
Recommend,
|
||||||
|
Authorization
|
||||||
},
|
},
|
||||||
props: {},
|
props: {},
|
||||||
data: function() {
|
data: function() {
|
||||||
return {
|
return {
|
||||||
isIpx: false,
|
|
||||||
cartList: {
|
cartList: {
|
||||||
invalid: [],
|
invalid: [],
|
||||||
valid: []
|
valid: []
|
||||||
@@ -168,36 +205,44 @@
|
|||||||
loaded: false
|
loaded: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: mapGetters(["userInfo"]),
|
||||||
|
|
||||||
|
// watch: {
|
||||||
|
// $yroute(n) {
|
||||||
|
// if (n.name === "ShoppingCart") {
|
||||||
|
// this.carnum();
|
||||||
|
// this.countMoney();
|
||||||
|
// this.getCartList();
|
||||||
|
// this.gainCount();
|
||||||
|
// this.goodsHidden = true;
|
||||||
|
// this.footerswitch = false;
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// cartList(list) {
|
||||||
|
// this.validList = list.valid;
|
||||||
|
// }
|
||||||
|
// },
|
||||||
watch: {
|
watch: {
|
||||||
$yroute(n) {
|
userInfo(user) {
|
||||||
if (n.name === "ShoppingCart") {
|
console.log(user);
|
||||||
|
if (user.uid) {
|
||||||
this.carnum();
|
this.carnum();
|
||||||
this.countMoney();
|
this.countMoney();
|
||||||
this.getCartList();
|
this.getCartList();
|
||||||
this.gainCount();
|
this.gainCount();
|
||||||
this.goodsHidden = true;
|
|
||||||
this.footerswitch = false;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
cartList(list) {
|
cartList(list) {
|
||||||
this.validList = list.valid;
|
this.validList = list.valid;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted: function() {
|
onShow: function() {
|
||||||
let that = this;
|
if (this.userInfo.uid) {
|
||||||
that.carnum();
|
this.carnum();
|
||||||
that.countMoney();
|
this.countMoney();
|
||||||
that.getCartList();
|
this.getCartList();
|
||||||
that.gainCount();
|
this.gainCount();
|
||||||
wx.getSystemInfo({
|
|
||||||
success: function(res) {
|
|
||||||
console.log(res);
|
|
||||||
var name = "iPhone X";
|
|
||||||
if (res.model.indexOf(name) > -1) {
|
|
||||||
that.isIpx = true;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
goGoodsCon(item) {
|
goGoodsCon(item) {
|
||||||
|
|||||||
@@ -121,11 +121,6 @@ export default {
|
|||||||
userIndex: 0
|
userIndex: 0
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
|
||||||
$yroute(n) {
|
|
||||||
if (n.name === "PersonalData") this.$store.dispatch("USERINFO", true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: mapGetters(["userInfo"]),
|
computed: mapGetters(["userInfo"]),
|
||||||
mounted: function() {
|
mounted: function() {
|
||||||
this.avatar = this.userInfo.avatar;
|
this.avatar = this.userInfo.avatar;
|
||||||
|
|||||||
@@ -63,14 +63,14 @@ export default {
|
|||||||
icon: "none",
|
icon: "none",
|
||||||
duration: 2000
|
duration: 2000
|
||||||
});
|
});
|
||||||
return
|
return;
|
||||||
} else if (price < 0.01) {
|
} else if (price < 0.01) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "转入金额不能低于0.01",
|
title: "转入金额不能低于0.01",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
duration: 2000
|
duration: 2000
|
||||||
});
|
});
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
|
|||||||
+39
-28
@@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="user">
|
<view class="user">
|
||||||
|
<view v-if="userInfo.uid">
|
||||||
<view class="header bg-color-red acea-row row-between-wrapper">
|
<view class="header bg-color-red acea-row row-between-wrapper">
|
||||||
<view class="picTxt acea-row row-between-wrapper">
|
<view class="picTxt acea-row row-between-wrapper">
|
||||||
<view class="pictrue">
|
<view class="pictrue">
|
||||||
@@ -76,8 +77,8 @@
|
|||||||
<image :src="$VUE_APP_RESOURCES_URL+'/images/dfh.png'" />
|
<image :src="$VUE_APP_RESOURCES_URL+'/images/dfh.png'" />
|
||||||
<text
|
<text
|
||||||
class="order-status-num"
|
class="order-status-num"
|
||||||
v-if="orderStatusNum.unshippedCount > 0"
|
v-if="userInfo.orderStatusNum.unshippedCount > 0"
|
||||||
>{{ orderStatusNum.unshippedCount }}</text>
|
>{{ userInfo.orderStatusNum.unshippedCount }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view>待发货</view>
|
<view>待发货</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -86,8 +87,8 @@
|
|||||||
<image :src="$VUE_APP_RESOURCES_URL+'/images/dsh.png'" />
|
<image :src="$VUE_APP_RESOURCES_URL+'/images/dsh.png'" />
|
||||||
<text
|
<text
|
||||||
class="order-status-num"
|
class="order-status-num"
|
||||||
v-if="orderStatusNum.receivedCount > 0"
|
v-if="userInfo.orderStatusNum.receivedCount > 0"
|
||||||
>{{ orderStatusNum.receivedCount }}</text>
|
>{{ userInfo.orderStatusNum.receivedCount }}</text>
|
||||||
</view>
|
</view>
|
||||||
<text>待收货</text>
|
<text>待收货</text>
|
||||||
</view>
|
</view>
|
||||||
@@ -96,8 +97,8 @@
|
|||||||
<image :src="$VUE_APP_RESOURCES_URL+'/images/dpj.png'" />
|
<image :src="$VUE_APP_RESOURCES_URL+'/images/dpj.png'" />
|
||||||
<text
|
<text
|
||||||
class="order-status-num"
|
class="order-status-num"
|
||||||
v-if="orderStatusNum.evaluatedCount > 0"
|
v-if="userInfo.orderStatusNum.evaluatedCount > 0"
|
||||||
>{{ orderStatusNum.evaluatedCount }}</text>
|
>{{ userInfo.orderStatusNum.evaluatedCount }}</text>
|
||||||
</view>
|
</view>
|
||||||
<text>待评价</text>
|
<text>待评价</text>
|
||||||
</view>
|
</view>
|
||||||
@@ -106,8 +107,8 @@
|
|||||||
<image :src="$VUE_APP_RESOURCES_URL+'/images/sh.png'" />
|
<image :src="$VUE_APP_RESOURCES_URL+'/images/sh.png'" />
|
||||||
<text
|
<text
|
||||||
class="order-status-num"
|
class="order-status-num"
|
||||||
v-if="orderStatusNum.refundCount > 0"
|
v-if="userInfo.orderStatusNum.refundCount > 0"
|
||||||
>{{ orderStatusNum.refundCount }}</text>
|
>{{ userInfo.orderStatusNum.refundCount }}</text>
|
||||||
</view>
|
</view>
|
||||||
<text>售后/退款</text>
|
<text>售后/退款</text>
|
||||||
</view>
|
</view>
|
||||||
@@ -147,11 +148,14 @@
|
|||||||
:login_type="userInfo.login_type"
|
:login_type="userInfo.login_type"
|
||||||
></SwitchWindow>
|
></SwitchWindow>
|
||||||
</view>
|
</view>
|
||||||
|
<Authorization v-else />
|
||||||
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { getUser, getMenuUser, bindingPhone } from "@/api/user";
|
import { getUser, getMenuUser, bindingPhone } from "@/api/user";
|
||||||
import { isWeixin, VUE_APP_RESOURCES_URL } from "@/utils";
|
import { isWeixin, VUE_APP_RESOURCES_URL } from "@/utils";
|
||||||
import SwitchWindow from "@/components/SwitchWindow";
|
import SwitchWindow from "@/components/SwitchWindow";
|
||||||
|
import Authorization from "@/pages/authorization/index";
|
||||||
import { mapGetters } from "vuex";
|
import { mapGetters } from "vuex";
|
||||||
|
|
||||||
const NAME = "User";
|
const NAME = "User";
|
||||||
@@ -159,30 +163,18 @@ const NAME = "User";
|
|||||||
export default {
|
export default {
|
||||||
name: NAME,
|
name: NAME,
|
||||||
components: {
|
components: {
|
||||||
SwitchWindow
|
SwitchWindow,
|
||||||
|
Authorization
|
||||||
},
|
},
|
||||||
props: {},
|
props: {},
|
||||||
data: function() {
|
data: function() {
|
||||||
return {
|
return {
|
||||||
userInfo: {},
|
|
||||||
MyMenus: [],
|
MyMenus: [],
|
||||||
orderStatusNum: {},
|
|
||||||
switchActive: false,
|
switchActive: false,
|
||||||
isWeixin: false
|
isWeixin: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: mapGetters(["wxCode"]),
|
computed: mapGetters(["userInfo"]),
|
||||||
watch: {
|
|
||||||
$yroute(n) {
|
|
||||||
if (n.name === NAME) this.User();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted: function() {
|
|
||||||
console.log("这个是个人中心");
|
|
||||||
this.User();
|
|
||||||
this.MenuUser();
|
|
||||||
this.isWeixin = isWeixin();
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
goReturnList() {
|
goReturnList() {
|
||||||
this.$yrouter.push("/pages/order/ReturnList/index");
|
this.$yrouter.push("/pages/order/ReturnList/index");
|
||||||
@@ -214,11 +206,19 @@ export default {
|
|||||||
},
|
},
|
||||||
getPhoneNumber: function(e) {
|
getPhoneNumber: function(e) {
|
||||||
console.log(e.mp.detail);
|
console.log(e.mp.detail);
|
||||||
|
// 判断一下这里是不是小程序 如果是小程序,走获取微信手机号进行绑定
|
||||||
if (e.mp.detail.errMsg == "getPhoneNumber:ok") {
|
if (e.mp.detail.errMsg == "getPhoneNumber:ok") {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: "绑定中"
|
title: "绑定中"
|
||||||
});
|
});
|
||||||
wx.login({
|
// 获取当前环境的服务商
|
||||||
|
uni.getProvider({
|
||||||
|
service: "oauth",
|
||||||
|
success: function(res) {
|
||||||
|
console.log(res.provider);
|
||||||
|
// 此处可以排除h5
|
||||||
|
if (res.provider) {
|
||||||
|
uni.login({
|
||||||
success: loginRes => {
|
success: loginRes => {
|
||||||
bindingPhone({
|
bindingPhone({
|
||||||
code: loginRes.code,
|
code: loginRes.code,
|
||||||
@@ -243,6 +243,9 @@ export default {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "已拒绝授权",
|
title: "已拒绝授权",
|
||||||
@@ -256,10 +259,10 @@ export default {
|
|||||||
},
|
},
|
||||||
User: function() {
|
User: function() {
|
||||||
let that = this;
|
let that = this;
|
||||||
getUser().then(res => {
|
// getUser().then(res => {
|
||||||
that.userInfo = res.data;
|
// that.user = res.data;
|
||||||
that.orderStatusNum = res.data.orderStatusNum;
|
// that.orderStatusNum = res.data.orderStatusNum;
|
||||||
});
|
// });
|
||||||
},
|
},
|
||||||
MenuUser: function() {
|
MenuUser: function() {
|
||||||
let that = this;
|
let that = this;
|
||||||
@@ -300,11 +303,19 @@ export default {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
userInfo() {
|
||||||
|
this.MenuUser();
|
||||||
|
}
|
||||||
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
|
console.log(this.userInfo);
|
||||||
|
if (this.userInfo.uid) {
|
||||||
this.User();
|
this.User();
|
||||||
this.MenuUser();
|
this.MenuUser();
|
||||||
this.isWeixin = isWeixin();
|
this.isWeixin = isWeixin();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -73,23 +73,6 @@ export default {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
downloadIamge: function(imgsrc, name) {
|
downloadIamge: function(imgsrc, name) {
|
||||||
// let image = new Image();
|
|
||||||
// image.setAttribute("crossOrigin", "anonymous");
|
|
||||||
// image.onload = function() {
|
|
||||||
// // let canvas = document.createElement("canvas");
|
|
||||||
// // canvas.width = image.width;
|
|
||||||
// // canvas.height = image.height;
|
|
||||||
// // let context = canvas.getContext("2d");
|
|
||||||
// // context.drawImage(image, 0, 0, image.width, image.height);
|
|
||||||
// // let url = canvas.toDataURL("image/png"); //得到图片的base64编码数据
|
|
||||||
// // let a = document.createElement("a"); // 生成一个a元素
|
|
||||||
// // let event = new MouseEvent("click"); // 创建一个单击事件
|
|
||||||
// // a.download = name || "photo"; // 设置图片名称
|
|
||||||
// // a.href = url; // 将生成的URL设置为a.href属性
|
|
||||||
// // a.dispatchEvent(event); // 触发a的单击事件
|
|
||||||
// };
|
|
||||||
// image.src = imgsrc;
|
|
||||||
|
|
||||||
var that = this;
|
var that = this;
|
||||||
this.isDown = true;
|
this.isDown = true;
|
||||||
var downloadUrl = imgsrc;
|
var downloadUrl = imgsrc;
|
||||||
|
|||||||
+10
-23
@@ -12,15 +12,11 @@ const LOGIN_KEY = "login_status";
|
|||||||
|
|
||||||
const vuexStore = new Vuex.Store({
|
const vuexStore = new Vuex.Store({
|
||||||
state: {
|
state: {
|
||||||
wxCode: null,
|
// 是否已经在授权页面
|
||||||
isAuthorizationPage: false,
|
isAuthorizationPage: false,
|
||||||
|
// 是否授权
|
||||||
isAuthorization: false,
|
isAuthorization: false,
|
||||||
footer: true,
|
|
||||||
home: true,
|
|
||||||
tabtarIndex: 0,
|
|
||||||
homeActive: false,
|
|
||||||
token: store.get(LOGIN_KEY) || null,
|
token: store.get(LOGIN_KEY) || null,
|
||||||
backgroundColor: "#fff",
|
|
||||||
userInfo: null
|
userInfo: null
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
@@ -50,8 +46,9 @@ const vuexStore = new Vuex.Store({
|
|||||||
store.set(LOGIN_KEY, token, expires_time);
|
store.set(LOGIN_KEY, token, expires_time);
|
||||||
},
|
},
|
||||||
LOGOUT(state) {
|
LOGOUT(state) {
|
||||||
state.token = undefined;
|
state.token = null;
|
||||||
store.remove(LOGIN_KEY);
|
state.userInfo = null
|
||||||
|
store.clearAll()
|
||||||
},
|
},
|
||||||
BACKGROUND_COLOR(state, color) {
|
BACKGROUND_COLOR(state, color) {
|
||||||
state.color = color;
|
state.color = color;
|
||||||
@@ -66,10 +63,6 @@ const vuexStore = new Vuex.Store({
|
|||||||
UPDATE_AUTHORIZATION(state, isAuthorization) {
|
UPDATE_AUTHORIZATION(state, isAuthorization) {
|
||||||
state.isAuthorization = isAuthorization;
|
state.isAuthorization = isAuthorization;
|
||||||
},
|
},
|
||||||
UPDATE_WXCODE(state, wxCode) {
|
|
||||||
console.log(wxCode, 'wxCode')
|
|
||||||
state.wxCode = wxCode;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
USERINFO({ state, commit }, force) {
|
USERINFO({ state, commit }, force) {
|
||||||
@@ -85,31 +78,25 @@ const vuexStore = new Vuex.Store({
|
|||||||
dialog.error("获取信息失败!");
|
dialog.error("获取信息失败!");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
changeLogin({ state, commit }, data, date) {
|
||||||
|
commit("LOGIN", data, date);
|
||||||
|
},
|
||||||
changeUserInfo({ state, commit }, user) {
|
changeUserInfo({ state, commit }, user) {
|
||||||
commit("UPDATE_USERINFO", user.user);
|
commit("UPDATE_USERINFO", user.user);
|
||||||
},
|
},
|
||||||
changeTabtar({ state, commit }, index) {
|
changeAuthorizationPage({ state, commit }, index) {
|
||||||
commit("CHANGE_TABTAR", index);
|
commit("UPDATE_AUTHORIZATIONPAGE", index);
|
||||||
},
|
},
|
||||||
changeAuthorization({ state, commit }, index) {
|
changeAuthorization({ state, commit }, index) {
|
||||||
commit("UPDATE_AUTHORIZATION", index);
|
commit("UPDATE_AUTHORIZATION", index);
|
||||||
},
|
},
|
||||||
changeWxCode({ state, commit }, index) {
|
|
||||||
commit("UPDATE_WXCODE", index);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
wxCode: state => state.wxCode,
|
|
||||||
isAuthorizationPage: state => state.isAuthorizationPage,
|
isAuthorizationPage: state => state.isAuthorizationPage,
|
||||||
isAuthorization: state => state.isAuthorization,
|
isAuthorization: state => state.isAuthorization,
|
||||||
footer: state => state.footer,
|
|
||||||
homeActive: state => state.homeActive,
|
|
||||||
home: state => state.home,
|
|
||||||
token: state => state.token,
|
token: state => state.token,
|
||||||
isLogin: state => !!state.token,
|
isLogin: state => !!state.token,
|
||||||
backgroundColor: state => state.backgroundColor,
|
|
||||||
userInfo: state => state.userInfo || {},
|
userInfo: state => state.userInfo || {},
|
||||||
tabtarIndex: state => state.tabtarIndex
|
|
||||||
},
|
},
|
||||||
strict: debug
|
strict: debug
|
||||||
});
|
});
|
||||||
|
|||||||
+208
-97
@@ -97,7 +97,7 @@ export function getCurrentPageUrlWithArgs() {
|
|||||||
|
|
||||||
// 复制到剪切板
|
// 复制到剪切板
|
||||||
export const copyClipboard = (data) => {
|
export const copyClipboard = (data) => {
|
||||||
wx.setClipboardData({
|
uni.setClipboardData({
|
||||||
data: data,
|
data: data,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@@ -110,52 +110,95 @@ export const copyClipboard = (data) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const toAuthorization = (msg) => {
|
export const replaceLogin = (msg) => {
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: msg,
|
title: msg,
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
duration: 2000
|
duration: 2000
|
||||||
});
|
});
|
||||||
console.log(222222222)
|
console.log(Vue.prototype.$deviceType)
|
||||||
|
// 这里代表已经失去登录状态以及401强制推出登录了
|
||||||
|
store.commit('LOGOUT')
|
||||||
|
|
||||||
|
if (Vue.prototype.$deviceType == 'Weixin') {
|
||||||
|
// 如果是微信小程序,跳转到授权页
|
||||||
replace({
|
replace({
|
||||||
path: '/pages/user/Login/index',
|
path: '/pages/authorization/index',
|
||||||
query: {
|
query: {
|
||||||
redirect: `/${getCurrentPageUrl()}`,
|
redirect: `/${getCurrentPageUrl()}`,
|
||||||
...parseQuery()
|
...parseQuery()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
// 如果不是小程序跳转到登录页
|
||||||
|
replace({
|
||||||
|
path: '/pages/user/Login/index',
|
||||||
|
query: query || {
|
||||||
|
redirect: `/${getCurrentPageUrl()}`,
|
||||||
|
...parseQuery()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getProvider = () => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
// 获取当前环境的服务商
|
||||||
|
uni.getProvider({
|
||||||
|
service: 'oauth',
|
||||||
|
success: function (res) {
|
||||||
|
console.log(`当前环境的服务商为 | ${res.provider}`)
|
||||||
|
// 此处可以排除h5
|
||||||
|
if (res.provider) {
|
||||||
|
resolve(res.provider[0])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail() {
|
||||||
|
reject('获取环境服务商失败')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}).catch(error => {
|
||||||
|
console.log(error)
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export const authorize = (authorizeStr) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
uni.authorize({
|
||||||
|
scope: `scope.${authorizeStr}`,
|
||||||
|
success() {
|
||||||
|
resolve('获取授权成功')
|
||||||
|
},
|
||||||
|
fail() {
|
||||||
|
reject('获取授权失败')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}).catch(error => {
|
||||||
|
console.log(error)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const login = (option) => {
|
export const login = (option) => {
|
||||||
console.log('调用登录')
|
console.log('调用登录')
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// 获取当前环境的服务商
|
getProvider().then(provider => {
|
||||||
uni.getProvider({
|
|
||||||
service: 'oauth',
|
|
||||||
success: function(res) {
|
|
||||||
console.log(res.provider)
|
|
||||||
// 此处可以排除h5
|
|
||||||
if (res.provider) {
|
|
||||||
// 调用登录接口
|
// 调用登录接口
|
||||||
uni.login({
|
uni.login({
|
||||||
provider: res.provider[0],
|
provider: provider,
|
||||||
success: function (loginRes) {
|
success: function (loginRes) {
|
||||||
// 微信登录
|
// 微信登录
|
||||||
console.log('获取code')
|
console.log(`获取code | ${loginRes.code}`)
|
||||||
let code = loginRes.code;
|
let code = loginRes.code;
|
||||||
store.commit("UPDATE_WXCODE", loginRes.code);
|
|
||||||
|
|
||||||
console.log(JSON.stringify(loginRes));
|
|
||||||
// 检查授权, 检查用户信息授权
|
// 检查授权, 检查用户信息授权
|
||||||
uni.authorize({
|
authorize('userInfo').then(() => {
|
||||||
scope: 'scope.userInfo',
|
|
||||||
success() {
|
|
||||||
uni.getUserInfo({
|
uni.getUserInfo({
|
||||||
provider: res.provider[0],
|
provider: provider,
|
||||||
success: function (user) {
|
success: function (user) {
|
||||||
console.log(user)
|
console.log(user)
|
||||||
console.log('用户昵称为:' + user.userInfo.nickName);
|
console.log(`用户昵称为 | ${user.userInfo.nickName}`);
|
||||||
|
console.log(`当前的环境 | ${Vue.prototype.$deviceType}`)
|
||||||
if (Vue.prototype.$deviceType == 'Weixin') {
|
if (Vue.prototype.$deviceType == 'Weixin') {
|
||||||
wxappAuth({
|
wxappAuth({
|
||||||
encryptedData: user.encryptedData,
|
encryptedData: user.encryptedData,
|
||||||
@@ -165,84 +208,111 @@ export const login = (option) => {
|
|||||||
}).then(({
|
}).then(({
|
||||||
data
|
data
|
||||||
}) => {
|
}) => {
|
||||||
resolve(res.data)
|
console.log('登录成功')
|
||||||
|
console.log(data)
|
||||||
|
console.log('登录成功1')
|
||||||
|
|
||||||
|
resolve(data)
|
||||||
|
console.log('登录成功3')
|
||||||
|
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
|
console.log('登录成功4')
|
||||||
store.commit("LOGIN", data.token, dayjs(data.expires_time));
|
store.commit("LOGIN", data.token, dayjs(data.expires_time));
|
||||||
|
console.log('登录成功5')
|
||||||
|
|
||||||
getUser().then(res => {
|
getUser().then(res => {
|
||||||
store.dispatch('changeUserInfo', {
|
store.dispatch('changeUserInfo', {
|
||||||
user: res.data
|
user: res.data
|
||||||
})
|
})
|
||||||
});
|
console.log('登录成功6')
|
||||||
|
console.log(option)
|
||||||
|
// option && option.success ? option.success() : null
|
||||||
var pages = getCurrentPages() //获取加载的页面
|
var pages = getCurrentPages() //获取加载的页面
|
||||||
|
console.log('登录成功7')
|
||||||
|
|
||||||
var currentPage = pages[pages.length - 1] //获取当前页面的对象
|
var currentPage = pages[pages.length - 1] //获取当前页面的对象
|
||||||
let url = "/pages/home/index"
|
let url = "/pages/home/index"
|
||||||
let query = {}
|
let query = {}
|
||||||
|
console.log('登录成功8')
|
||||||
|
console.log(currentPage)
|
||||||
|
|
||||||
if (currentPage) {
|
if (currentPage) {
|
||||||
if (currentPage.route != 'pages/Loading/index' && currentPage.route !=
|
// 获取到最后一个页面
|
||||||
'pages/user/Login/index') {
|
if (
|
||||||
|
currentPage.route != 'pages/Loading/index'
|
||||||
|
&&
|
||||||
|
currentPage.route != 'pages/user/Login/index'
|
||||||
|
) {
|
||||||
url = currentPage.route
|
url = currentPage.route
|
||||||
}
|
}
|
||||||
if (currentPage.route == 'pages/user/Login/index') {
|
if (currentPage.route == 'pages/authorization/index') {
|
||||||
const {
|
const {
|
||||||
redirect,
|
redirect,
|
||||||
...querys
|
...querys
|
||||||
} = currentPage.options
|
} = currentPage.options
|
||||||
url = redirect
|
url = redirect
|
||||||
query = { ...querys
|
query = {
|
||||||
|
...querys
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switchTab({
|
console.log('登录成功9')
|
||||||
|
console.log({
|
||||||
path: url,
|
path: url,
|
||||||
query
|
query
|
||||||
|
})
|
||||||
|
switchTab({
|
||||||
|
path: `${url}`,
|
||||||
|
query
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
}).catch(error => {
|
||||||
|
reject()
|
||||||
|
console.log('微信登录失败')
|
||||||
|
console.log(error)
|
||||||
|
handleFail(option, '微信登录失败')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail() {
|
||||||
|
// 获取用户信息失败
|
||||||
|
reject()
|
||||||
|
handleFail(option, '获取用户信息失败')
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
reject()
|
reject()
|
||||||
option && option.fail ? option.fail() : toAuthorization('获取用户信息失败,请重试')
|
console.log(error)
|
||||||
});
|
handleFail(option, '拒绝授权')
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
fail() {
|
|
||||||
// 获取用户信息失败
|
|
||||||
reject()
|
|
||||||
option && option.fail ? option.fail() : toAuthorization('获取用户信息失败,请重试')
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
fail() {
|
|
||||||
// 获取用户信息失败
|
|
||||||
reject()
|
|
||||||
option && option.fail ? option.fail() : toAuthorization('获取用户信息失败,请重试')
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
fail() {
|
fail() {
|
||||||
// 调用登录接口失败
|
// 调用登录接口失败
|
||||||
reject()
|
reject()
|
||||||
option && option.fail ? option.fail() : toAuthorization('获取用户信息失败,请重试')
|
handleFail(option, '登录失败')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}).catch(error => {
|
||||||
},
|
|
||||||
fail() {
|
|
||||||
reject()
|
reject()
|
||||||
option && option.fail ? option.fail() : toAuthorization('获取用户信息失败,请重试')
|
console.log(error)
|
||||||
}
|
handleFail(option, '获取环境服务商失败')
|
||||||
});
|
})
|
||||||
|
}).catch(error => {
|
||||||
|
console.log(error)
|
||||||
|
handleFail(option, '登录失败')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const handleFail = (option, msg) => {
|
||||||
|
// 此处是处理登录失效的问题的
|
||||||
|
console.log(store)
|
||||||
|
option && option.fail ? option.fail() : replaceLogin('登录失败,请重新登录')
|
||||||
|
}
|
||||||
|
|
||||||
export function parseUrl(location) {
|
export function parseUrl(location) {
|
||||||
if (typeof location === 'string') return location
|
if (typeof location === 'string') return location
|
||||||
|
|
||||||
const {
|
const {
|
||||||
path,
|
path,
|
||||||
query
|
query
|
||||||
@@ -272,53 +342,95 @@ export function parseRoute($mp) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function push(location, complete, fail, success) {
|
|
||||||
|
export const handleLoginStatus = (location, complete, fail, success) => {
|
||||||
|
console.log(location, '开始健全')
|
||||||
|
// 不登录可访问的页面
|
||||||
|
let page = [{
|
||||||
|
path: '/pages/Loading/index',
|
||||||
|
name: 'loading页面'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/pages/home/index',
|
||||||
|
name: '首页'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/pages/user/Login/index',
|
||||||
|
name: '登录页面'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/pages/authorization/index',
|
||||||
|
name: '授权页面'
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
// 是否可以访问
|
||||||
|
let isAuth = false
|
||||||
|
|
||||||
|
// 从 location 中获取当前url,location typeof string || object
|
||||||
let path = ''
|
let path = ''
|
||||||
if (typeof location === 'string') {
|
if (typeof location === 'string') {
|
||||||
path = location
|
path = location
|
||||||
} else {
|
} else {
|
||||||
path = location.path
|
path = location.path
|
||||||
}
|
}
|
||||||
console.log(path)
|
|
||||||
if (path != '/pages/launch/index' || path != '/pages/loading/index' || path != '/pages/home/index' || path !=
|
console.log(store.getters.userInfo, '用户信息')
|
||||||
'/pages/loading/index') {
|
|
||||||
if (!store.getters.userInfo.uid) {
|
if (!store.getters.userInfo.uid) {
|
||||||
replace({
|
page.map((item) => {
|
||||||
path: '/pages/user/Login/index',
|
console.log(item.path == path)
|
||||||
query: {
|
if (item.path == path) {
|
||||||
redirect: `/${getCurrentPageUrl()}`,
|
isAuth = true
|
||||||
...parseQuery()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return
|
} else {
|
||||||
|
isAuth = true
|
||||||
}
|
}
|
||||||
}
|
|
||||||
const url = parseUrl(location)
|
return new Promise((resolve, reject) => {
|
||||||
const params = {
|
if (isAuth) {
|
||||||
url,
|
console.log('有权限')
|
||||||
|
// 登录了有权限
|
||||||
|
console.log({
|
||||||
|
url: parseUrl(location),
|
||||||
complete,
|
complete,
|
||||||
fail,
|
fail,
|
||||||
success
|
success
|
||||||
|
})
|
||||||
|
resolve({
|
||||||
|
url: parseUrl(location),
|
||||||
|
complete,
|
||||||
|
fail,
|
||||||
|
success
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
console.log('无权限')
|
||||||
|
// 未登录没有权限
|
||||||
|
replaceLogin()
|
||||||
|
reject()
|
||||||
|
}
|
||||||
|
}).catch(error => {
|
||||||
|
console.log(error)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (location.isTab) {
|
export function push(location, complete, fail, success) {
|
||||||
uni.switchTab(params)
|
handleLoginStatus(location, complete, fail, success).then(params => {
|
||||||
return
|
console.log(params)
|
||||||
}
|
|
||||||
if (location.reLaunch) {
|
|
||||||
uni.reLaunch(params)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
uni.navigateTo(params)
|
uni.navigateTo(params)
|
||||||
|
}).catch(error => {
|
||||||
|
// 没有权限
|
||||||
|
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function replace(location, complete, fail, success) {
|
export function replace(location, complete, fail, success) {
|
||||||
const url = parseUrl(location)
|
handleLoginStatus(location, complete, fail, success).then(params => {
|
||||||
uni.redirectTo({
|
console.log(params)
|
||||||
url,
|
uni.redirectTo(params)
|
||||||
complete,
|
}).catch(error => {
|
||||||
fail,
|
// 没有权限
|
||||||
success
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,12 +449,12 @@ export function back() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function switchTab(location, complete, fail, success) {
|
export function switchTab(location, complete, fail, success) {
|
||||||
const url = parseUrl(location)
|
console.log(location)
|
||||||
uni.switchTab({
|
handleLoginStatus(location, complete, fail, success).then(params => {
|
||||||
url,
|
console.log(params)
|
||||||
complete,
|
uni.switchTab(params)
|
||||||
fail,
|
}).catch(error => {
|
||||||
success
|
// 没有权限
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -383,11 +495,10 @@ export function handleQrCode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getImageInfo = (images) => {
|
const getImageInfo = (images) => {
|
||||||
console.log(images)
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let imageAry = {}
|
let imageAry = {}
|
||||||
images.map((item, index) => {
|
images.map((item, index) => {
|
||||||
wx.getImageInfo({
|
uni.getImageInfo({
|
||||||
src: item,
|
src: item,
|
||||||
fail: function (res) {
|
fail: function (res) {
|
||||||
imageAry[index] = null
|
imageAry[index] = null
|
||||||
@@ -425,7 +536,7 @@ export const PosterCanvas = (store, successCallBack) => {
|
|||||||
});
|
});
|
||||||
getImageInfo([store.image, store.code]).then(res => {
|
getImageInfo([store.image, store.code]).then(res => {
|
||||||
let contentHh = 48 * 1.3
|
let contentHh = 48 * 1.3
|
||||||
const ctx = wx.createCanvasContext('myCanvas');
|
const ctx = uni.createCanvasContext('myCanvas');
|
||||||
ctx.clearRect(0, 0, 0, 0);
|
ctx.clearRect(0, 0, 0, 0);
|
||||||
const WIDTH = 747
|
const WIDTH = 747
|
||||||
const HEIGHT = 1326;
|
const HEIGHT = 1326;
|
||||||
@@ -456,7 +567,7 @@ export const PosterCanvas = (store, successCallBack) => {
|
|||||||
// ctx.drawImage(store.code, 199, 1064, 200, 200);
|
// ctx.drawImage(store.code, 199, 1064, 200, 200);
|
||||||
ctx.save();
|
ctx.save();
|
||||||
ctx.draw(true, function (oi) {
|
ctx.draw(true, function (oi) {
|
||||||
wx.canvasToTempFilePath({
|
uni.canvasToTempFilePath({
|
||||||
canvasId: 'myCanvas',
|
canvasId: 'myCanvas',
|
||||||
fileType: 'png',
|
fileType: 'png',
|
||||||
destWidth: WIDTH,
|
destWidth: WIDTH,
|
||||||
@@ -473,7 +584,7 @@ export const PosterCanvas = (store, successCallBack) => {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
// wx.getImageInfo({
|
// uni.getImageInfo({
|
||||||
// src: store.image,
|
// src: store.image,
|
||||||
// fail: function (res) {
|
// fail: function (res) {
|
||||||
// uni.showToast({
|
// uni.showToast({
|
||||||
|
|||||||
+6
-39
@@ -7,69 +7,36 @@ function get(key) {
|
|||||||
if (!key || !_has(key)) {
|
if (!key || !_has(key)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return wx.getStorageSync(key)
|
return uni.getStorageSync(key)
|
||||||
// let regexpStr =
|
|
||||||
// "(?:^|.*;\\s*)" +
|
|
||||||
// escape(key).replace(/[-.+*]/g, "\\$&") +
|
|
||||||
// "\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";
|
|
||||||
// return JSON.parse(unescape(doc.cookie.replace(new RegExp(regexpStr), "$1")));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function all() {
|
function all() {
|
||||||
return wx.getStorageInfoSync()
|
return uni.getStorageInfoSync()
|
||||||
// let cookies = doc.cookie.split(/; ?/g),
|
|
||||||
// data = {};
|
|
||||||
// for (let i = cookies.length - 1; i >= 0; i--) {
|
|
||||||
// if (!trim(cookies[i])) {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// let kvp = cookies[i].split("=");
|
|
||||||
// let key = unescape(kvp[0]);
|
|
||||||
// data[key] = unescape(kvp[1]);
|
|
||||||
// }
|
|
||||||
// return data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function set(key, data, time) {
|
function set(key, data, time) {
|
||||||
if (!key) {
|
if (!key) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// let expires = "Tue, 19 Jan 2038 03:14:07 GMT";
|
uni.setStorageSync(key, data)
|
||||||
// if (time) {
|
|
||||||
// let date;
|
|
||||||
// if (isType(time, "Date")) {
|
|
||||||
// date = time;
|
|
||||||
// } else {
|
|
||||||
// date = new Date();
|
|
||||||
// date.setTime(date.getTime() + time * 60000);
|
|
||||||
// }
|
|
||||||
// expires = date.toGMTString();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// data = JSON.stringify(data);
|
|
||||||
// doc.cookie =
|
|
||||||
// escape(key) + "=" + escape(data) + "; expires=" + expires + "; path=/";
|
|
||||||
|
|
||||||
wx.setStorageSync(key, data)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove(key) {
|
function remove(key) {
|
||||||
if (!key || !_has(key)) {
|
if (!key || !_has(key)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wx.removeStorageSync(key)
|
uni.removeStorageSync(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearAll() {
|
function clearAll() {
|
||||||
wx.clearStorage()
|
uni.clearStorage()
|
||||||
}
|
}
|
||||||
|
|
||||||
function _has(key) {
|
function _has(key) {
|
||||||
if (!key) {
|
if (!key) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let value = wx.getStorageSync(key)
|
let value = uni.getStorageSync(key)
|
||||||
if (value) {
|
if (value) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user