1、购买选择规格属性点不了
2、购物车列表点击管理 点击收藏功能去掉 3、下单点击积分抵扣没反应 4、待收货 列表查看物流点击没反应,详情查看物流可以点 5、添加地址选择地区无效 6、个人中心我的余额点进去点击账单记录一直正在加载中,点击下全部就出来了,应该你没带默认参数 8、订单点击评价没反应 9、小程序订单核销没上 你那边先根据路径判断隐藏下 10、我的推广,里面样式有问题,点击海报里面空白 11、分类点击 会分类Tab页分类一级比一级低 12、拼团详情客服功能隐藏去掉,其他地方有客服功能的都去掉
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -4494,7 +4494,7 @@ flex: 0 2.4*100rpx;
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.bargain .bargainGang .title .pictrue img,
|
||||
.bargain .bargainGang .title .pictrue image,
|
||||
.bargain .goodsDetails .title .pictrue image{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
@ -16,11 +16,7 @@
|
||||
v-if="cart.productInfo.attrInfo"
|
||||
>{{ cart.productInfo.attrInfo.suk }}</view>
|
||||
<view class="money font-color-red">¥{{ cart.truePrice }}</view>
|
||||
<view
|
||||
class="evaluate"
|
||||
v-if="evaluate == 3"
|
||||
@click="routerGo(cart)"
|
||||
>评价</view>
|
||||
<view class="evaluate" v-if="evaluate == 3" @click="routerGo(cart)">评价</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -41,9 +37,12 @@ export default {
|
||||
},
|
||||
mounted: function() {},
|
||||
methods: {
|
||||
routerGo(item) {
|
||||
this.$yrouter.push({ path: '/pages/shop/GoodsEvaluate/index',query:{id:cart.unique} });
|
||||
},
|
||||
routerGo(cart) {
|
||||
this.$yrouter.push({
|
||||
path: "/pages/shop/GoodsEvaluate/index",
|
||||
query: { id: cart.unique }
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -65,13 +65,8 @@ export default {
|
||||
data: function() {
|
||||
return {};
|
||||
},
|
||||
watch: {
|
||||
attr:function(ne){
|
||||
console.log(ne)
|
||||
}
|
||||
},
|
||||
mounted: function() {
|
||||
console.log(this.attr)
|
||||
console.log(this.attr);
|
||||
},
|
||||
methods: {
|
||||
closeAttr: function() {
|
||||
@ -84,16 +79,23 @@ export default {
|
||||
this.$emit("changeFun", { action: "ChangeCartNum", value: 1 });
|
||||
},
|
||||
tapAttr: function(indexw, indexn) {
|
||||
// 修改商品规格不生效的原因:
|
||||
// H5端下面写法,attr更新,但是除H5外其他端不支持,
|
||||
// 尽量避免下面的骚写法,不要在子组件内更新props
|
||||
// this.attr.productAttr[res.indexw].index = res.indexn;
|
||||
let that = this;
|
||||
console.log(that.attr.productAttr);
|
||||
console.log(that.attr.productAttr[indexw], indexw, indexn);
|
||||
that.attr.productAttr[indexw].index = indexn;
|
||||
let value = that
|
||||
.getCheckedValue()
|
||||
.sort()
|
||||
.join(",");
|
||||
console.log(value);
|
||||
that.$emit("changeFun", { action: "ChangeAttr", value: value });
|
||||
that.$emit("changeFun", {
|
||||
action: "ChangeAttr",
|
||||
value: {
|
||||
value,
|
||||
indexw,
|
||||
indexn
|
||||
}
|
||||
});
|
||||
},
|
||||
//获取被选中属性;
|
||||
getCheckedValue: function() {
|
||||
|
@ -84,9 +84,9 @@
|
||||
<image src="@/static/images/left.png" />
|
||||
</view>
|
||||
<view class="titleCon">砍价帮</view>
|
||||
<view class="pictrue on">
|
||||
<!-- <view class="pictrue on">
|
||||
<image src="@/static/images/left.png" />
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
<view class="list">
|
||||
<view
|
||||
@ -507,6 +507,9 @@ export default {
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.bargain{
|
||||
background: #00c17b;
|
||||
}
|
||||
.bargainBnts {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
@ -78,4 +78,7 @@ export default {
|
||||
</script>
|
||||
|
||||
<style >
|
||||
page{
|
||||
background: #00c17b;
|
||||
}
|
||||
</style>
|
||||
|
@ -107,10 +107,10 @@
|
||||
</view>
|
||||
<view style="height:100rpx;"></view>
|
||||
<view class="footer-group acea-row row-between-wrapper">
|
||||
<view class="customerSer acea-row row-center-wrapper row-column">
|
||||
<!-- <view class="customerSer acea-row row-center-wrapper row-column">
|
||||
<view class="iconfont icon-kefu"></view>
|
||||
<view>客服</view>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="bnt bg-color-violet" @click="openAlone">单独购买</view>
|
||||
<view class="bnt bg-color-red" @click="openTeam">立即开团</view>
|
||||
</view>
|
||||
|
@ -39,13 +39,13 @@
|
||||
</view>
|
||||
<view style="height:100rpx;"></view>
|
||||
<view class="footerRush acea-row row-between-wrapper">
|
||||
<view
|
||||
<!-- <view
|
||||
class="customerSer acea-row row-center-wrapper row-column"
|
||||
@click="routerGo()"
|
||||
>
|
||||
<view class="iconfont icon-kefu"></view>
|
||||
<view>客服</view>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="bnt bg-color-red" @click="tapBuy">立即购买</view>
|
||||
</view>
|
||||
<ProductWindow v-on:changeFun="changeFun" :attr="attr" :cartNum="cartNum"></ProductWindow>
|
||||
|
@ -107,31 +107,18 @@
|
||||
</view>
|
||||
<view class="totalPrice">
|
||||
共{{ order.cartInfo.length || 0 }}件商品,总金额
|
||||
<text
|
||||
class="money font-color-red"
|
||||
>¥{{ order.payPrice }}</text>
|
||||
<text class="money font-color-red">¥{{ order.payPrice }}</text>
|
||||
</view>
|
||||
<view class="bottom acea-row row-right row-middle">
|
||||
<template v-if="order._status._type == 0">
|
||||
<view class="bnt cancelBnt" @click="cancelOrder(order)">取消订单</view>
|
||||
<view
|
||||
class="bnt bg-color-red"
|
||||
@click="goOrderDetails(order)"
|
||||
>立即付款</view>
|
||||
<view class="bnt bg-color-red" @click="goOrderDetails(order)">立即付款</view>
|
||||
</template>
|
||||
<template v-if="order._status._type == 1 || order._status._type == 9">
|
||||
<view
|
||||
class="bnt bg-color-red"
|
||||
@click="goOrderDetails(order)"
|
||||
>查看详情</view>
|
||||
<view class="bnt bg-color-red" @click="goOrderDetails(order)">查看详情</view>
|
||||
</template>
|
||||
<template v-if="order._status._type == 2">
|
||||
<view
|
||||
class="bnt default"
|
||||
@click="
|
||||
$yrouter.push({ path: '/pages/order/Logistics/index',query:{id:order.orderId}})
|
||||
"
|
||||
>查看物流</view>
|
||||
<view class="bnt default" @click="goLogistics(order)">查看物流</view>
|
||||
<view class="bnt bg-color-red" @click="takeOrder(order)">确认收货</view>
|
||||
</template>
|
||||
<template v-if="order._status._type == 3">
|
||||
@ -144,16 +131,10 @@
|
||||
<!-->-->
|
||||
<!--查看物流-->
|
||||
<!--</view>-->
|
||||
<view
|
||||
class="bnt bg-color-red"
|
||||
@click="goOrderDetails(order)"
|
||||
>去评价</view>
|
||||
<view class="bnt bg-color-red" @click="goOrderDetails(order)">去评价</view>
|
||||
</template>
|
||||
<template v-if="order._status._type === 4">
|
||||
<view
|
||||
class="bnt bg-color-red"
|
||||
@click="goOrderDetails(order)"
|
||||
>查看订单</view>
|
||||
<view class="bnt bg-color-red" @click="goOrderDetails(order)">查看订单</view>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
@ -231,6 +212,12 @@ export default {
|
||||
type() {}
|
||||
},
|
||||
methods: {
|
||||
goLogistics(order) {
|
||||
this.$yrouter.push({
|
||||
path: "/pages/order/Logistics/index",
|
||||
query: { id: order.orderId }
|
||||
});
|
||||
},
|
||||
goOrderDetails(order) {
|
||||
this.$yrouter.push({
|
||||
path: "/pages/order/OrderDetails/index",
|
||||
@ -334,19 +321,19 @@ export default {
|
||||
|
||||
<style scoped lang="less">
|
||||
.noCart {
|
||||
margin-top: 0.17*100rpx;
|
||||
padding-top: 0.1*100rpx;
|
||||
margin-top: 0.17 * 100rpx;
|
||||
padding-top: 0.1 * 100rpx;
|
||||
}
|
||||
|
||||
.noCart .pictrue {
|
||||
width: 4*100rpx;
|
||||
height: 3*100rpx;
|
||||
width: 4 * 100rpx;
|
||||
height: 3 * 100rpx;
|
||||
overflow: hidden;
|
||||
margin: 0.7*100rpx auto 0.5*100rpx auto;
|
||||
margin: 0.7 * 100rpx auto 0.5 * 100rpx auto;
|
||||
}
|
||||
|
||||
.noCart .pictrue image{
|
||||
width: 4*100rpx;
|
||||
height: 3*100rpx;
|
||||
.noCart .pictrue image {
|
||||
width: 4 * 100rpx;
|
||||
height: 3 * 100rpx;
|
||||
}
|
||||
</style>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -58,7 +58,7 @@
|
||||
当前积分
|
||||
<text class="num font-color-red">{{ userInfo.integral || 0 }}</text>
|
||||
</text>
|
||||
<checkbox value :checked="useIntegral ? true : false"></checkbox>
|
||||
<checkbox value="true" :checked="useIntegral ? true : false"></checkbox>
|
||||
</label>
|
||||
</checkbox-group>
|
||||
</view>
|
||||
@ -345,6 +345,7 @@
|
||||
},
|
||||
changeUseIntegral: function(e) {
|
||||
// this.computedPrice();
|
||||
console.log(e)
|
||||
this.useIntegral = e.mp.detail.value[0];
|
||||
},
|
||||
computedPrice() {
|
||||
|
@ -20,8 +20,8 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="conter">
|
||||
<view class="listw" v-for="(item, eq) in category" :key="eq">
|
||||
<view v-if="eq === navActive">
|
||||
<view v-for="(item, eq) in category" :key="eq">
|
||||
<view class="listw" v-if="eq === navActive">
|
||||
<view class="title acea-row row-center-wrapper" ref="title">
|
||||
<view class="line"></view>
|
||||
<view class="name">{{ item.cateName }}</view>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -130,7 +130,7 @@
|
||||
<view class="placeOrder bg-color-red" @click="placeOrder">立即下单</view>
|
||||
</view>
|
||||
<view class="button acea-row row-middle" v-else>
|
||||
<view class="bnt cart-color" @click="collectAll">收藏</view>
|
||||
<!-- <view class="bnt cart-color" @click="collectAll">收藏</view> -->
|
||||
<view class="bnt" @click="delgoods">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
|
@ -96,7 +96,7 @@
|
||||
</view>
|
||||
<view class="serviceList acea-row row-middle">
|
||||
<template v-for="(item, MyMenusIndex) in MyMenus">
|
||||
<view class="item" :key="MyMenusIndex" @click="goPages(MyMenusIndex)" v-if="item.url">
|
||||
<view class="item" :key="MyMenusIndex" @click="goPages(MyMenusIndex)" v-if="item.url&&item.id!='230'">
|
||||
<view class="pictrue">
|
||||
<image :src="item.pic" />
|
||||
</view>
|
||||
|
@ -11,8 +11,8 @@
|
||||
</view>
|
||||
<view class="item acea-row row-between-wrapper">
|
||||
<view class="name">所在地区</view>
|
||||
<view class="picker acea-row row-between-wrapper select-value form-control">
|
||||
<view class="address">
|
||||
<view class="picker acea-row row-between-wrapper select-value form-control" >
|
||||
<view class="address" @tap="openAddres2">
|
||||
<!-- <picker
|
||||
@columnchange="addRessColumnchange"
|
||||
@change="changeAddress"
|
||||
@ -23,7 +23,7 @@
|
||||
<text class="uni-input" v-if="model2">{{model2}}</text>
|
||||
<text class="uni-input" v-else>请选择地区</text>
|
||||
</picker>-->
|
||||
<text class="uni-input" @tap="openAddres2" >{{model2||'请选择'}}</text>
|
||||
<text class="uni-input" >{{model2||'请选择'}}</text>
|
||||
<simple-address
|
||||
ref="simpleAddress"
|
||||
:pickerValueDefault="cityPickerValueDefault"
|
||||
@ -116,7 +116,7 @@ if(this.address.province){
|
||||
"label"
|
||||
);
|
||||
console.log(index);
|
||||
this.cityPickerValueDefault = index.index;
|
||||
this.cityPickerValueDefault = index.index;
|
||||
}
|
||||
this.$refs.simpleAddress.open();
|
||||
},
|
||||
@ -226,3 +226,12 @@ if(this.address.province){
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.address{
|
||||
text{
|
||||
width: 100%;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@ -1,153 +1,160 @@
|
||||
<template>
|
||||
<view class="distribution-posters">
|
||||
<view class="slider-banner banner">
|
||||
<swiper indicatorDots="true">
|
||||
<block v-for="(item, infoIndex) in info" :key="infoIndex">
|
||||
<swiper-item>
|
||||
<image class="slide-image" :src="item.wap_poster" mode="widthFix" show-menu-by-longpress />
|
||||
</swiper-item>
|
||||
</block>
|
||||
</swiper>
|
||||
</view>
|
||||
<view class="keep bg-color-red" @click="saveImg">保存海报</view>
|
||||
</view>
|
||||
<view class="distribution-posters">
|
||||
<view class="slider-banner banner">
|
||||
<swiper indicatorDots="true">
|
||||
<block v-for="(item, infoIndex) in info" :key="infoIndex">
|
||||
<swiper-item>
|
||||
<image
|
||||
class="slide-image"
|
||||
:src="item.wap_poster"
|
||||
mode="widthFix"
|
||||
show-menu-by-longpress
|
||||
/>
|
||||
</swiper-item>
|
||||
</block>
|
||||
</swiper>
|
||||
</view>
|
||||
<view class="keep bg-color-red" @click="saveImg">保存海报</view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
// import { swiper, swiperSlide } from "vue-awesome-swiper";
|
||||
import {
|
||||
getSpreadImg
|
||||
} from "@/api/user";
|
||||
// import { swiper, swiperSlide } from "vue-awesome-swiper";
|
||||
import { getSpreadImg } from "@/api/user";
|
||||
|
||||
export default {
|
||||
name: "Poster",
|
||||
components: {
|
||||
// swiper,
|
||||
// swiperSlide
|
||||
},
|
||||
props: {},
|
||||
data: function() {
|
||||
return {
|
||||
swiperPosters: {
|
||||
speed: 1000,
|
||||
effect: "coverflow",
|
||||
slidesPerView: "auto",
|
||||
centeredSlides: true,
|
||||
coverflowEffect: {
|
||||
rotate: 0, // 旋转的角度
|
||||
stretch: -20, // 拉伸 图片间左右的间距和密集度
|
||||
depth: 100, // 深度 切换图片间上下的间距和密集度
|
||||
modifier: 3, // 修正值 该值越大前面的效果越明显
|
||||
slideShadows: false // 页面阴影效果
|
||||
},
|
||||
observer: true,
|
||||
observeParents: true
|
||||
},
|
||||
info: [],
|
||||
activeIndex: 0
|
||||
};
|
||||
},
|
||||
mounted: function() {
|
||||
this.getIndex();
|
||||
let that = this;
|
||||
// this.swiper.on("slideChange", function() {
|
||||
// that.activeIndex = that.swiper.activeIndex;
|
||||
// });
|
||||
},
|
||||
computed: {
|
||||
swiper() {
|
||||
// return this.$refs.mySwiper.swiper;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getIndex: function() {
|
||||
let that = this;
|
||||
let form = {}
|
||||
if (this.$deviceType == 'app') {
|
||||
form.form = 'app'
|
||||
}
|
||||
getSpreadImg(form).then(
|
||||
res => {
|
||||
that.info = res.data;
|
||||
},
|
||||
err => {
|
||||
uni.showToast({
|
||||
title: err.msg || err.response.data.msg,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
downloadIamge: function(imgsrc, name) {
|
||||
var that = this;
|
||||
this.isDown = true;
|
||||
var downloadUrl = imgsrc;
|
||||
export default {
|
||||
name: "Poster",
|
||||
components: {
|
||||
// swiper,
|
||||
// swiperSlide
|
||||
},
|
||||
props: {},
|
||||
data: function() {
|
||||
return {
|
||||
swiperPosters: {
|
||||
speed: 1000,
|
||||
effect: "coverflow",
|
||||
slidesPerView: "auto",
|
||||
centeredSlides: true,
|
||||
coverflowEffect: {
|
||||
rotate: 0, // 旋转的角度
|
||||
stretch: -20, // 拉伸 图片间左右的间距和密集度
|
||||
depth: 100, // 深度 切换图片间上下的间距和密集度
|
||||
modifier: 3, // 修正值 该值越大前面的效果越明显
|
||||
slideShadows: false // 页面阴影效果
|
||||
},
|
||||
observer: true,
|
||||
observeParents: true
|
||||
},
|
||||
info: [],
|
||||
activeIndex: 0
|
||||
};
|
||||
},
|
||||
mounted: function() {
|
||||
this.getIndex();
|
||||
let that = this;
|
||||
// this.swiper.on("slideChange", function() {
|
||||
// that.activeIndex = that.swiper.activeIndex;
|
||||
// });
|
||||
},
|
||||
computed: {
|
||||
swiper() {
|
||||
// return this.$refs.mySwiper.swiper;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getIndex: function() {
|
||||
let that = this;
|
||||
let form = {};
|
||||
if (this.$deviceType == "app") {
|
||||
form.form = "app";
|
||||
}
|
||||
getSpreadImg(form).then(
|
||||
res => {
|
||||
that.info = res.data;
|
||||
},
|
||||
err => {
|
||||
uni.showToast({
|
||||
title: err.msg || err.response.data.msg,
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
downloadIamge: function(imgsrc, name) {
|
||||
var that = this;
|
||||
this.isDown = true;
|
||||
var downloadUrl = imgsrc;
|
||||
|
||||
if (!wx.saveImageToPhotosAlbum) {
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。"
|
||||
});
|
||||
that.openDialogVisible = true;
|
||||
if (!wx.saveImageToPhotosAlbum) {
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content:
|
||||
"当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。"
|
||||
});
|
||||
that.openDialogVisible = true;
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 可以通过 wx.getSetting 先查询一下用户是否授权了 "scope.writePhotosAlbum" 这个 scope
|
||||
wx.getSetting({
|
||||
success(res) {
|
||||
if (!res.authSetting["scope.writePhotosAlbum"]) {
|
||||
that.openDialogVisible = true;
|
||||
// 可以通过 wx.getSetting 先查询一下用户是否授权了 "scope.writePhotosAlbum" 这个 scope
|
||||
wx.getSetting({
|
||||
success(res) {
|
||||
if (!res.authSetting["scope.writePhotosAlbum"]) {
|
||||
that.openDialogVisible = true;
|
||||
|
||||
// 接口调用询问
|
||||
wx.authorize({
|
||||
scope: "scope.writePhotosAlbum",
|
||||
success() {
|
||||
that.downloadImage(downloadUrl);
|
||||
},
|
||||
fail() {
|
||||
// 用户拒绝了授权
|
||||
// 打开设置页面
|
||||
wx.openSetting({
|
||||
success: function(data) {},
|
||||
fail: function(data) {}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
that.downloadImage(downloadUrl);
|
||||
}
|
||||
},
|
||||
fail(res) {
|
||||
that.openDialogVisible = true;
|
||||
}
|
||||
});
|
||||
},
|
||||
saveImg: function() {
|
||||
this.downloadIamge(
|
||||
this.info[this.activeIndex].wap_poster,
|
||||
"poster" + this.activeIndex
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
// 接口调用询问
|
||||
wx.authorize({
|
||||
scope: "scope.writePhotosAlbum",
|
||||
success() {
|
||||
that.downloadImage(downloadUrl);
|
||||
},
|
||||
fail() {
|
||||
// 用户拒绝了授权
|
||||
// 打开设置页面
|
||||
wx.openSetting({
|
||||
success: function(data) {},
|
||||
fail: function(data) {}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
that.downloadImage(downloadUrl);
|
||||
}
|
||||
},
|
||||
fail(res) {
|
||||
that.openDialogVisible = true;
|
||||
}
|
||||
});
|
||||
},
|
||||
saveImg: function() {
|
||||
this.downloadIamge(
|
||||
this.info[this.activeIndex].wap_poster,
|
||||
"poster" + this.activeIndex
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.distribution-posters {
|
||||
height: 100%;
|
||||
}
|
||||
<style lang="less">
|
||||
page {
|
||||
height: 100%;
|
||||
}
|
||||
.distribution-posters {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.banenr {
|
||||
height: 100%;
|
||||
}
|
||||
.banenr {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.banner swiper {
|
||||
height: 100%;
|
||||
}
|
||||
.banner swiper {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.banner .slide-image {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
</style>
|
||||
.banner .slide-image {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
</style>
|
||||
|
@ -4,7 +4,7 @@ import Vuex from "vuex";
|
||||
Vue.use(Vuex);
|
||||
const debug = process.env.NODE_ENV !== "production";
|
||||
|
||||
import store from "@/utils/store/cookie";
|
||||
import cookie from "@/utils/store/cookie";
|
||||
import {
|
||||
getUserInfo
|
||||
} from "@/api/user";
|
||||
@ -18,8 +18,9 @@ const vuexStore = new Vuex.Store({
|
||||
isAuthorizationPage: false,
|
||||
// 是否授权
|
||||
isAuthorization: false,
|
||||
token: store.get(LOGIN_KEY) || null,
|
||||
userInfo: store.get('userInfo'),
|
||||
// 不建议从这里取 token,但是删除掉会影响其他的页面
|
||||
token: cookie.get(LOGIN_KEY) || null,
|
||||
userInfo: cookie.get('userInfo'),
|
||||
$deviceType: null,
|
||||
},
|
||||
mutations: {
|
||||
@ -46,12 +47,12 @@ const vuexStore = new Vuex.Store({
|
||||
},
|
||||
LOGIN(state, token, expires_time) {
|
||||
state.token = token;
|
||||
store.set(LOGIN_KEY, token, expires_time);
|
||||
cookie.set(LOGIN_KEY, token, expires_time);
|
||||
},
|
||||
LOGOUT(state) {
|
||||
state.token = null;
|
||||
state.userInfo = null
|
||||
store.clearAll()
|
||||
cookie.clearAll()
|
||||
},
|
||||
BACKGROUND_COLOR(state, color) {
|
||||
state.color = color;
|
||||
@ -99,9 +100,9 @@ const vuexStore = new Vuex.Store({
|
||||
}, user) {
|
||||
commit("UPDATE_USERINFO", user);
|
||||
if (user) {
|
||||
store.set('userInfo', user)
|
||||
cookie.set('userInfo', user)
|
||||
} else {
|
||||
store.set('userInfo', null)
|
||||
cookie.set('userInfo', null)
|
||||
}
|
||||
},
|
||||
changeAuthorizationPage({
|
||||
@ -127,4 +128,4 @@ const vuexStore = new Vuex.Store({
|
||||
strict: debug
|
||||
});
|
||||
|
||||
export default vuexStore
|
||||
export default vuexStore
|
||||
|
@ -218,7 +218,7 @@ export const login = (option) => {
|
||||
console.log('登录成功4')
|
||||
store.commit("LOGIN", data.token, dayjs(data.expires_time));
|
||||
console.log('登录成功5')
|
||||
|
||||
console.log(store)
|
||||
handleGetUserInfo()
|
||||
|
||||
}).catch(error => {
|
||||
@ -259,6 +259,7 @@ export const login = (option) => {
|
||||
}
|
||||
|
||||
export const handleGetUserInfo = () => {
|
||||
console.log('登录后请求用户信息')
|
||||
getUser().then(res => {
|
||||
console.log(res.data, '登录后的样式')
|
||||
store.dispatch('setUserInfo', res.data)
|
||||
@ -341,9 +342,25 @@ export function parseRoute($mp) {
|
||||
}
|
||||
}
|
||||
|
||||
export function auth() {
|
||||
/**
|
||||
* 如何判断权限?
|
||||
* 用户如果登录了系统,会留下两个东西,一个是token,一个是userInfo
|
||||
* token存在会过期的问题,如果长时间没有打开小程序,会导致登录失效,出现打开一个页面瞬间跳转到授权页面的问题
|
||||
* 解决办法,保存token的时候加上过期时间,每次请求都取一下缓存里的token
|
||||
* userInfo只是用来限时用户信息,作用并不是很大
|
||||
* ps:只需要判断 token 是否存在即可
|
||||
*/
|
||||
console.log(cookie.get('login_status'), 'token')
|
||||
if (cookie.get('login_status')) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
export const handleLoginStatus = (location, complete, fail, success) => {
|
||||
console.log(location, '开始健全')
|
||||
console.log(location, '开始检验权限')
|
||||
// 不登录可访问的页面
|
||||
let page = [{
|
||||
path: '/pages/Loading/index',
|
||||
@ -374,8 +391,7 @@ export const handleLoginStatus = (location, complete, fail, success) => {
|
||||
path = location.path
|
||||
}
|
||||
|
||||
console.log(store.getters.userInfo, '用户信息')
|
||||
if (!store.getters.token) {
|
||||
if (!auth()) {
|
||||
page.map((item) => {
|
||||
console.log(item.path == path)
|
||||
if (item.path == path) {
|
||||
|
@ -2,6 +2,7 @@ import Fly from "flyio/dist/npm/wx";
|
||||
import $store from "../store";
|
||||
import toLogin from "@/libs/login";
|
||||
import { VUE_APP_API_URL } from "@/config";
|
||||
import cookie from "@/utils/store/cookie";
|
||||
|
||||
|
||||
const fly = new Fly()
|
||||
@ -28,28 +29,38 @@ fly.interceptors.response.use(
|
||||
const defaultOpt = { login: true };
|
||||
|
||||
function baseRequest(options) {
|
||||
const token = $store.state.token;
|
||||
const headers = options.headers || {};
|
||||
if (options.login) {
|
||||
headers["Authorization"] = "Bearer " + token;
|
||||
|
||||
// 从缓存中获取 token 防止 token 失效后还会继续请求的情况
|
||||
const token = cookie.get('login_status');
|
||||
|
||||
// 合并传参过来的 headers
|
||||
// 如果接口需要登录,携带 token 去请求
|
||||
options.headers = {
|
||||
...options.headers,
|
||||
Authorization: options.login ? "Bearer " + token : null
|
||||
}
|
||||
|
||||
options.headers = headers;
|
||||
if (options.login && !token) {
|
||||
// 如果需要登录才可访问的接口没有拿到 token 视为登录失效
|
||||
if (options.login === true && !token) {
|
||||
// 跳转到登录或授权页面
|
||||
toLogin();
|
||||
// 提示错误信息
|
||||
return Promise.reject({ msg: "未登录", toLogin: true });
|
||||
}
|
||||
|
||||
// 结构请求需要的参数
|
||||
const { url, params, data, login, ...option } = options
|
||||
|
||||
// 发起请求
|
||||
return fly.request(url, params || data, {
|
||||
...option
|
||||
}).then(res => {
|
||||
console.log(res)
|
||||
// console.log(url,params,data, ...option)
|
||||
}).then(res => {
|
||||
console.log(res)
|
||||
// console.log(url,params,data, ...option)
|
||||
const data = res.data || {};
|
||||
if (res.status !== 200)
|
||||
if (res.status !== 200) {
|
||||
return Promise.reject({ msg: "请求失败", res, data });
|
||||
|
||||
}
|
||||
if ([410000, 410001, 410002].indexOf(data.status) !== -1) {
|
||||
toLogin();
|
||||
return Promise.reject({ msg: res.data.msg, res, data, toLogin: true });
|
||||
|
Reference in New Issue
Block a user