1、购买选择规格属性点不了

2、购物车列表点击管理 点击收藏功能去掉
3、下单点击积分抵扣没反应
4、待收货 列表查看物流点击没反应,详情查看物流可以点
5、添加地址选择地区无效
6、个人中心我的余额点进去点击账单记录一直正在加载中,点击下全部就出来了,应该你没带默认参数
8、订单点击评价没反应
9、小程序订单核销没上 你那边先根据路径判断隐藏下
10、我的推广,里面样式有问题,点击海报里面空白
11、分类点击 会分类Tab页分类一级比一级低
12、拼团详情客服功能隐藏去掉,其他地方有客服功能的都去掉
This commit is contained in:
Gao xiaosong
2020-04-11 01:44:10 +08:00
parent 1eba07de8a
commit 728deeaa35
21 changed files with 1684 additions and 1605 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

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

View File

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

View File

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

View File

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

View File

@ -78,4 +78,7 @@ export default {
</script>
<style >
page{
background: #00c17b;
}
</style>

View File

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

View File

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

View File

@ -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 @@
<!--&gt;-->
<!--查看物流-->
<!--</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",

View File

@ -20,51 +20,75 @@
<view :class="{ on: status.type === 4 }">已完成</view>
</view>
<view class="progress acea-row row-between-wrapper">
<view class="iconfont" :class="[
<view
class="iconfont"
:class="[
status.type === 0 || status.type === 9
? 'icon-webicon318'
: 'icon-yuandianxiao',
status.type >= 0 ? 'font-color-red' : ''
]"></view>
]"
></view>
<view class="line" :class="{ 'bg-color-red': status.type > 0 && status.type != 9 }"></view>
<view class="iconfont" :class="[
<view
class="iconfont"
:class="[
status.type === 1 ? 'icon-webicon318' : 'icon-yuandianxiao',
status.type >= 1 && status.type != 6 && status.type != 9
? 'font-color-red'
: ''
]"></view>
<view class="line" :class="{
]"
></view>
<view
class="line"
:class="{
'bg-color-red':
status.type > 1 && status.type != 6 && status.type != 9
}"
v-if="orderInfo.shipping_type === 1"></view>
<view class="iconfont" :class="[
v-if="orderInfo.shipping_type === 1"
></view>
<view
class="iconfont"
:class="[
status.type === 2 ? 'icon-webicon318' : 'icon-yuandianxiao',
status.type >= 2 && status.type != 6 && status.type != 9
? 'font-color-red'
: ''
]"
v-if="orderInfo.shippingType === 1"></view>
<view class="line" :class="{
v-if="orderInfo.shippingType === 1"
></view>
<view
class="line"
:class="{
'bg-color-red':
status.type > 2 && status.type != 6 && status.type != 9
}"></view>
<view class="iconfont" :class="[
}"
></view>
<view
class="iconfont"
:class="[
status.type === 3 ? 'icon-webicon318' : 'icon-yuandianxiao',
status.type >= 3 && status.type != 6 && status.type != 9
? 'font-color-red'
: ''
]"></view>
<view class="line" :class="{
]"
></view>
<view
class="line"
:class="{
'bg-color-red':
status.type > 3 && status.type != 6 && status.type != 9
}"></view>
<view class="iconfont" :class="[
}"
></view>
<view
class="iconfont"
:class="[
status.type == 4 ? 'icon-webicon318' : 'icon-yuandianxiao',
status.type >= 4 && status.type != 6 && status.type != 9
? 'font-color-red'
: ''
]"></view>
]"
></view>
</view>
</view>
<!--<view-->
@ -246,21 +270,30 @@
<view class="bnt cancel" @click="goGoodsReturn(orderInfo)">申请退款</view>
</template>
<template v-if="status.type == 2">
<view class="bnt default" @click="
<view
class="bnt default"
@click="
$yrouter.push({ path: '/pages/order/Logistics/index' ,query:{id:orderInfo.orderId }})
">查看物流</view>
"
>查看物流</view>
<view class="bnt bg-color-red" @click="takeOrder">确认收货</view>
</template>
<template v-if="status.type == 3 && orderInfo.deliveryType == 'express'">
<view class="bnt default" @click="
<view
class="bnt default"
@click="
$yrouter.push({ path: '/pages/order/Logistics/index' ,query:{id:orderInfo.orderId }})
">查看物流</view>
"
>查看物流</view>
</template>
<template v-if="status.type == 4">
<view class="bnt cancel" @click="delOrder">删除订单</view>
<view class="bnt default" @click="
<view
class="bnt default"
@click="
$yrouter.push({ path: '/pages/order/Logistics/index' ,query:{id:orderInfo.orderId }})
">查看物流</view>
"
>查看物流</view>
</template>
<template v-if="status.type == 6">
<view class="bnt bg-color-red" @click="goGroupRule(orderInfo)">查看拼团</view>
@ -268,7 +301,13 @@
</view>
<Payment v-model="pay" :types="payType" @checked="toPay" :balance="userInfo.nowMoney"></Payment>
<view class="geoPage" v-if="mapShow">
<iframe width="100%" height="100%" frameborder="0" scrolling="no" :src="'https://apis.map.qq.com/uri/v1/geocoder?coord=' + system_store.latitude + ',' +system_store.longitude +'&referer=' +mapKey"></iframe>
<iframe
width="100%"
height="100%"
frameborder="0"
scrolling="no"
:src="'https://apis.map.qq.com/uri/v1/geocoder?coord=' + system_store.latitude + ',' +system_store.longitude +'&referer=' +mapKey"
></iframe>
</view>
</view>
</template>
@ -429,18 +468,11 @@
</style>
<script>
import OrderGoods from "@/components/OrderGoods";
import {
orderDetail
} from "@/api/order";
import { orderDetail } from "@/api/order";
import Payment from "@/components/Payment";
import DataFormat from "@/components/DataFormat";
import {
isWeixin,
copyClipboard
} from "@/utils";
import {
mapGetters
} from "vuex";
import { isWeixin, copyClipboard } from "@/utils";
import { mapGetters } from "vuex";
import {
cancelOrderHandle,
takeOrderHandle,
@ -508,10 +540,10 @@
if (!this.mapKey)
uni.showToast({
title: "暂无法使用查看地图请配置您的腾讯地图key",
icon: 'none',
icon: "none",
duration: 2000
});
return
return;
this.mapShow = true;
}
},
@ -519,7 +551,8 @@
const history = this.app.history,
last = history[history.length - 1] || {};
if (last.name === "MyOrder") return this.$yrouter.back();
else return this.$yrouter.replace({
else
return this.$yrouter.replace({
path: "/order/list/"
});
},
@ -559,9 +592,9 @@
delivery_type = orderInfo.deliveryType,
seckill_id = orderInfo.seckillId ? parseInt(orderInfo.seckillId) : 0,
bargain_id = orderInfo.bargainId ? parseInt(orderInfo.bargainId) : 0,
combination_id = orderInfo.combinationId ?
parseInt(orderInfo.combinationId) :
0;
combination_id = orderInfo.combinationId
? parseInt(orderInfo.combinationId)
: 0;
status = {
type: type,
class_status: 0
@ -592,10 +625,10 @@
if (!id) {
uni.showToast({
title: "订单不存在",
icon: 'none',
icon: "none",
duration: 2000
});
return
return;
}
orderDetail(id)
.then(res => {

View File

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

View File

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

View File

@ -6,8 +6,15 @@
<view class="money font-color-red">
<text></text>
<text class="num">{{ storeInfo.price }}</text>
<text class="vip-money" v-if="storeInfo.vipPrice && storeInfo.vipPrice > 0">¥{{ storeInfo.vipPrice }}</text>
<image src="@/static/images/vip.png" class="image" v-if="storeInfo.vipPrice && storeInfo.vipPrice > 0" />
<text
class="vip-money"
v-if="storeInfo.vipPrice && storeInfo.vipPrice > 0"
>¥{{ storeInfo.vipPrice }}</text>
<image
src="@/static/images/vip.png"
class="image"
v-if="storeInfo.vipPrice && storeInfo.vipPrice > 0"
/>
</view>
<view class="iconfont icon-fenxiang" @click="listenerActionSheet"></view>
</view>
@ -20,7 +27,11 @@
<view class="coupon acea-row row-between-wrapper" @click="couponTap" v-if="couponList.length">
<text class="hide line1 acea-row">
<text>优惠券:</text>
<text class="activity" v-for="(item, couponListEq) in couponList" :key="couponListEq">满{{ item.use_min_price }}减{{ item.coupon_price }}</text>
<text
class="activity"
v-for="(item, couponListEq) in couponList"
:key="couponListEq"
>满{{ item.use_min_price }}减{{ item.coupon_price }}</text>
</text>
<view class="iconfont icon-jiantou"></view>
</view>
@ -99,7 +110,11 @@
<view class="iconfont" :class="storeInfo.userCollect ? 'icon-shoucang1' : 'icon-shoucang'"></view>
<text>收藏</text>
</view>
<view @click="goShoppingCart()" class="item animated" :class="animated === true ? 'bounceIn' : ''">
<view
@click="goShoppingCart()"
class="item animated"
:class="animated === true ? 'bounceIn' : ''"
>
<view class="iconfont icon-gouwuche1">
<text class="num bg-color-red" v-if="CartCount > 0">{{CartCount}}</text>
</view>
@ -116,7 +131,11 @@
</view>
<CouponPop v-on:changeFun="changeFun" :coupon="coupon"></CouponPop>
<ProductWindow v-on:changeFun="changeFun" :attr="attr" :cartNum="cart_num"></ProductWindow>
<StorePoster v-on:setPosterImageStatus="setPosterImageStatus" :posterImageStatus="posterImageStatus" :posterData="posterData"></StorePoster>
<StorePoster
v-on:setPosterImageStatus="setPosterImageStatus"
:posterImageStatus="posterImageStatus"
:posterData="posterData"
></StorePoster>
<ShareInfo v-on:setShareInfoStatus="setShareInfoStatus" :shareInfoStatus="shareInfoStatus"></ShareInfo>
<view class="generate-posters acea-row row-middle" :class="posters ? 'on' : ''">
<view class="item" v-if="weixinStatus === true" @click="setShareInfoStatus">
@ -130,7 +149,13 @@
</view>
<view class="mask" @touchmove.prevent @click="listenerActionClose" v-show="posters"></view>
<view class="geoPage" v-if="mapShow">
<iframe width="100%" height="100%" frameborder="0" scrolling="no" :src="'https://apis.map.qq.com/uri/v1/geocoder?coord=' +system_store.latitude +',' +system_store.longitude +'&referer=' +mapKey"></iframe>
<iframe
width="100%"
height="100%"
frameborder="0"
scrolling="no"
:src="'https://apis.map.qq.com/uri/v1/geocoder?coord=' +system_store.latitude +',' +system_store.longitude +'&referer=' +mapKey"
></iframe>
</view>
</view>
</template>
@ -156,18 +181,10 @@
getCollectDel,
getUserInfo
} from "@/api/user";
import {
isWeixin,
PosterCanvas,
handleQrCode
} from "@/utils";
import { isWeixin, PosterCanvas, handleQrCode } from "@/utils";
// import { wechatEvevt } from "@/libs/wechat";
import {
imageBase64
} from "@/api/public";
import {
mapGetters
} from "vuex";
import { imageBase64 } from "@/api/public";
import { mapGetters } from "vuex";
export default {
name: "GoodsCon",
@ -237,7 +254,7 @@
},
computed: mapGetters(["isLogin"]),
mounted: function() {
console.log(this)
console.log(this);
let url = handleQrCode();
console.log(url);
if (url && url.productId) {
@ -305,11 +322,11 @@
//产品详情接口;
productCon: function() {
let that = this;
let form = {}
if (this.$deviceType == 'app') {
form.form = 'app'
let form = {};
if (this.$deviceType == "app") {
form.form = "app";
}
console.log(form, 2222)
console.log(form, 2222);
getProductDetail(that.id, form)
.then(res => {
that.$set(that, "storeInfo", res.data.storeInfo);
@ -485,27 +502,15 @@
},
//选择属性;
ChangeAttr: function(res) {
let productSelectValue = this.productValue[res];
if (productSelectValue) {
let productSelect = {
...this.attr.productSelect,
image: productSelectValue.image,
price: productSelectValue.price,
stock: productSelectValue.stock,
unique: productSelectValue.unique,
cart_num: 1
};
let attr = {
...this.attr,
productSelect
};
this.attr = attr;
// this.$set(this.attr.productSelect, "image", productSelect.image);
// this.$set(this.attr.productSelect, "price", productSelect.price);
// this.$set(this.attr.productSelect, "stock", productSelect.stock);
// this.$set(this.attr.productSelect, "unique", productSelect.unique);
// this.$set(this.attr.productSelect, "cart_num", 1);
this.$set(this, "attrValue", res);
let productSelect = this.productValue[res.value];
if (productSelect) {
this.attr.productAttr[res.indexw].index = res.indexn;
this.$set(this.attr.productSelect, "image", productSelect.image);
this.$set(this.attr.productSelect, "price", productSelect.price);
this.$set(this.attr.productSelect, "stock", productSelect.stock);
this.$set(this.attr.productSelect, "unique", productSelect.unique);
this.$set(this.attr.productSelect, "cart_num", 1);
this.$set(this, "attrValue", res.value);
this.$set(this, "attrTxt", "已选择");
} else {
this.$set(this.attr.productSelect, "image", this.storeInfo.image);
@ -569,8 +574,10 @@
productId: that.id,
cartNum: that.attr.productSelect.cart_num,
new: news,
uniqueId: that.attr.productSelect !== undefined ?
that.attr.productSelect.unique : ""
uniqueId:
that.attr.productSelect !== undefined
? that.attr.productSelect.unique
: ""
};
postCartAdd(q)
.then(function(res) {

View File

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

View File

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

View File

@ -12,7 +12,7 @@
<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="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"
@ -226,3 +226,12 @@ if(this.address.province){
}
};
</script>
<style lang="less">
.address{
text{
width: 100%;
display: block;
}
}
</style>

View File

@ -4,7 +4,12 @@
<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 />
<image
class="slide-image"
:src="item.wap_poster"
mode="widthFix"
show-menu-by-longpress
/>
</swiper-item>
</block>
</swiper>
@ -14,9 +19,7 @@
</template>
<script>
// import { swiper, swiperSlide } from "vue-awesome-swiper";
import {
getSpreadImg
} from "@/api/user";
import { getSpreadImg } from "@/api/user";
export default {
name: "Poster",
@ -61,9 +64,9 @@
methods: {
getIndex: function() {
let that = this;
let form = {}
if (this.$deviceType == 'app') {
form.form = 'app'
let form = {};
if (this.$deviceType == "app") {
form.form = "app";
}
getSpreadImg(form).then(
res => {
@ -72,7 +75,7 @@
err => {
uni.showToast({
title: err.msg || err.response.data.msg,
icon: 'none',
icon: "none",
duration: 2000
});
}
@ -86,7 +89,8 @@
if (!wx.saveImageToPhotosAlbum) {
uni.showModal({
title: "提示",
content: "当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。"
content:
"当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。"
});
that.openDialogVisible = true;
@ -133,7 +137,10 @@
};
</script>
<style scoped lang="less">
<style lang="less">
page {
height: 100%;
}
.distribution-posters {
height: 100%;
}

View File

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

View File

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

View File

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