Browse Source

合并冲突

master
gaoxs 5 years ago
parent
commit
387e4e04c3
  1. 5
      README.md
  2. 3
      libs/login.js
  3. 4
      libs/wechat.js
  4. 7
      manifest.json
  5. 216
      pages/order/Logistics/index.vue
  6. 2
      pages/order/OrderDetails/index.vue
  7. 4
      pages/order/OrderSubmission/index.vue
  8. 164
      pages/shop/ShoppingCart/index.vue
  9. 9
      pages/user/UserVip/index.vue
  10. 2
      pages/user/signIn/Sign/index.vue
  11. 26
      utils/index.js
  12. 5
      utils/request.js

5
README.md

@ -1,6 +1,6 @@
# 使用说明
## 安装步骤
## 小程序安装步骤
- 先从私服上clone下来项目
- 下载uni的开发者工具 https://www.dcloud.io/hbuilderx.html
- 登录微信开发者工具打开 菜单 > 设置 > 安全设置 勾选服务端口为开启
@ -16,8 +16,7 @@
- 如需修改样式问题,请编辑.less的文件,请勿编辑.css的文件
## 声明
- 此阶段的uni项目app端只是可以运行界面,还无法进行正常的登录以及分享和支付操作
- 小程序端暂时90%的功能及界面正常,相关代码后面兼容app时会做一些调整
- app测试版已上,请通过 `https://www.pgyer.com/yRYf` 安装测试。
- 运行app项目ios需要安装xcode,安卓需要装安卓的sdk以及安卓模拟器,建议安卓安装genymotion https://www.genymotion.com/ 登录时可选择私人使用,勾选后无需付费

3
libs/login.js

@ -13,13 +13,16 @@ import {
} from "@/utils";
export default function toLogin(push, backUrl) {
// console.log('需要重新登录')
store.commit("LOGOUT");
// 如果没有授权,走登录的接口重新授权
// 授权获取失败会跳转到授权的接口
// console.log(store.getters.isAuthorization, '是否有登陆权限')
if (store.getters.isAuthorization) {
login()
return
}
// console.log(store.getters.isAuthorizationPage, '判断是不是登录页面或者授权页面')
// 判断当前是不是已经在登录页面或者授权页,防止二次跳转
if (store.getters.isAuthorizationPage || getCurrentPageUrl() == '/pages/user/Login/index') {
return

4
libs/wechat.js

@ -39,7 +39,9 @@ export const weappPay = (option) => {
},
fail: (error) => {
console.log(error)
uni.showToast({ title: JSON.stringify(error), icon: 'none', duration: 5000 });
if (error.errMsg == 'requestPayment:fail cancel') {
uni.showToast({ title: '已取消支付', icon: 'none', duration: 5000 });
}
reject(error)
}
})

7
manifest.json

@ -75,6 +75,13 @@
}
},
"ad" : {}
},
"splashscreen" : {
"ios" : {
"iphone" : {
"portrait-896h@3x" : "/Users/piao/Downloads/意(1)/1242+2688.png"
}
}
}
}
},

216
pages/order/Logistics/index.vue

@ -27,7 +27,10 @@
</view>
</view>
</view>
<view class="copy acea-row row-center-wrapper copy-data" @click="copyClipboard(orderInfo.deliveryId)">复制单号</view>
<view
class="copy acea-row row-center-wrapper copy-data"
@click="copyClipboard(orderInfo.deliveryId)"
>复制单号</view>
</view>
<view class="item" v-for="(express, expressListIndex) in expressList" :key="expressListIndex">
<view class="circular" :class="expressListIndex === 0 ? 'on' : ''"></view>
@ -42,7 +45,10 @@
<view class="div-bg bg-white" style="font-size:12px; background:#fff;">
<!--物流跟踪-->
<view style="margin-bottom:5px;">
<view class="bg-white" style="width: 92%; margin-left: 4%;margin: auto;padding-left: 15px;padding-right: 15px;padding-top: 10px">
<view
class="bg-white"
style="width: 92%; margin-left: 4%;margin: auto;padding-left: 15px;padding-right: 15px;padding-top: 10px"
>
<view style="font-size: 26rpx;color: #111111; margin: 5px 0">
物流跟踪
<!--物流跟踪-->
@ -51,14 +57,20 @@
<view class="track-rcol">
<view class="track-list">
<view>
<view v-for="(item,logisticsListindex) in logisticsList" :key="logisticsListindex">
<view
class="track-list-item"
v-for="(item,logisticsListindex) in logisticsList"
:key="logisticsListindex"
>
<view class="active" v-if="logisticsListindex===0">
<view></view>
<i class="node-icon"></i>
<text class="txt">{{item.acceptStation}}</text>
<text class="time">{{item.acceptTime}}</text>
</view>
<view v-if="logisticsListindex > 0 && logisticsListindex !== logisticsList.length-1">
<view
v-if="logisticsListindex > 0 && logisticsListindex !== logisticsList.length-1"
>
<i class="node-icon"></i>
<text class="txt">{{item.acceptStation}}</text>
<text class="time">{{item.acceptTime}}</text>
@ -85,18 +97,13 @@
</view>
</template>
<script>
import Recommend from "@/components/Recommend";
import {
express,
orderDetail
} from "@/api/order";
import {
copyClipboard
} from "@/utils";
import Recommend from "@/components/Recommend";
import { express, orderDetail } from "@/api/order";
import { copyClipboard } from "@/utils";
const NAME = "Logistics";
const NAME = "Logistics";
export default {
export default {
name: NAME,
components: {
Recommend
@ -108,10 +115,12 @@
orderInfo: {},
expressList: [],
loaded: false,
logisticsList: [{
logisticsList: [
{
message: "暂无数据",
messageDate: ""
}]
}
]
};
},
watch: {
@ -140,8 +149,9 @@
})
.catch(err => {
uni.showToast({
title: err.msg || err.response.data.msg|| err.response.data.message,
icon: 'none',
title:
err.msg || err.response.data.msg || err.response.data.message,
icon: "none",
duration: 2000
});
});
@ -149,11 +159,11 @@
getExpress() {
if (!this.id) {
uni.showToast({
title: err.msg || err.response.data.msg|| err.response.data.message,
icon: 'none',
title: err.msg || err.response.data.msg || err.response.data.message,
icon: "none",
duration: 2000
});
return
return;
}
this.loaded = false;
orderDetail(this.id)
@ -168,53 +178,53 @@
// this.cartInfo = res.data.order.cartInfo;
// this.expressList = result.list || [];
// this.loaded = true;
})
.catch(err => {
uni.showToast({
title: err.msg || err.response.data.msg|| err.response.data.message,
icon: 'none',
title:
err.msg || err.response.data.msg || err.response.data.message,
icon: "none",
duration: 2000
});
});
}
}
};
};
</script>
<style scoped lang="less">
.no-express {
margin: 1.5*100rpx 0;
}
.no-express {
margin: 1.5 * 100rpx 0;
}
.no-express image {
width: 6*100rpx;
.no-express image {
width: 6 * 100rpx;
margin: 0 auto;
display: block;
}
}
.message-text {
.message-text {
font-family: MicrosoftYaHei;
font-size: 1*100rpx;
font-size: 1 * 100rpx;
font-weight: normal;
font-stretch: normal;
line-height: 3*100rpx;
letter-spacing: 0*100rpx;
line-height: 3 * 100rpx;
letter-spacing: 0 * 100rpx;
color: #333333;
width: 50%;
}
}
.fontblack {
.fontblack {
color: #999999;
}
}
.img2 {
width: 0.81*100rpx;
height: 0.8*100rpx;
.img2 {
width: 0.81 * 100rpx;
height: 0.8 * 100rpx;
float: right;
}
}
.addressshow2 {
.addressshow2 {
height: auto;
overflow: hidden;
text-overflow: ellipsis;
@ -225,10 +235,10 @@
white-space: normal;
word-wrap: break-word;
word-break: break-all;
font-size: 1*100rpx;
}
font-size: 1 * 100rpx;
}
.addressshow1 {
.addressshow1 {
height: auto;
overflow: hidden;
text-overflow: ellipsis;
@ -239,11 +249,11 @@
white-space: normal;
word-wrap: break-word;
word-break: break-all;
font-size: 1*100rpx;
}
font-size: 1 * 100rpx;
}
.orderTitle {
font-size: 1*100rpx;
.orderTitle {
font-size: 1 * 100rpx;
color: #333333;
height: auto;
overflow: hidden;
@ -254,83 +264,90 @@
white-space: normal;
word-wrap: break-word;
word-break: break-all;
height: 2.5*100rpx;
}
height: 2.5 * 100rpx;
}
.orderDetail {
font-size: 0.26*100rpx;
.orderDetail {
font-size: 0.26 * 100rpx;
color: #666666;
text-align: left;
}
}
.border-ceter {
.border-ceter {
width: 92%;
padding-left: 15px;
padding-right: 15px;
}
}
.pay-button {
.pay-button {
width: 88%;
height: 2.6*100rpx;
height: 2.6 * 100rpx;
position: relative;
background-color: red;
color: white;
margin-left: 6%;
}
}
ul view {
ul view {
list-style: none;
font-size: 0.24*100rpx;
}
font-size: 0.24 * 100rpx;
}
ul {}
ul {
}
.track-rcol {}
.track-rcol {
}
.track-list {
.track-list {
position: relative;
}
}
.track-list view {
.track-list > view {
position: relative;
padding: 0 0 0.5*100rpx 5px;
line-height: 0.3*100rpx;
padding: 0 0 0.5 * 100rpx 20rpx;
}
.track-list .track-list-item {
position: relative;
padding: 0 0 0.5 * 100rpx 20rpx;
line-height: 0.3 * 100rpx;
border-left: 1px solid #d9d9d9;
color: #999;
}
}
.track-list view.first {
.track-list view.first {
color: red;
padding-top: 0;
width: 100%;
text-align: left;
border-left: 1px solid #d9d9d9;
}
}
.track-list view.node-icon {
.track-list view.node-icon {
position: absolute;
left: -6.5px;
border-radius: 50%;
width: 0.2*100rpx;
height: 0.2*100rpx;
width: 0.2 * 100rpx;
height: 0.2 * 100rpx;
top: 4px;
background-color: #b2b2b2;
}
padding: 0 !important;
}
.track-list view.active .node-icon {
background-position: 0-72px;
.track-list view.active .node-icon {
background-position: 0 -72px;
background-color: #ea7c0a;
width: 0.3*100rpx;
width: 0.3 * 100rpx;
z-index: 2;
height: 0.3*100rpx;
height: 0.3 * 100rpx;
position: absolute;
left: -0.19*100rpx;
left: -0.19 * 100rpx;
top: 0;
border-radius: 50%;
}
}
.track-list view.time {
.track-list view.time {
margin-right: 20px;
position: relative;
top: 4px;
@ -339,43 +356,42 @@
color: #999;
width: 100%;
text-align: left;
}
}
.track-list view.txt {
.track-list view.txt {
position: relative;
display: inline-block;
vertical-align: top;
color: #999;
left: 0.2*100rpx;
top: 0.04*100rpx;
}
left: 0.2 * 100rpx;
top: 0.04 * 100rpx;
}
.track-list view.first .time {
.track-list view.first .time {
text-align: left;
width: 94%;
color: red;
}
}
.track-list view.first .txt {
.track-list view.first .txt {
color: red;
text-align: left;
width: 94%;
}
}
.track-list view.finall {
position: relative;
padding: 0px 0 0.5*100rpx 5px;
.track-list view.finall {
padding: 0px 0 0.5 * 100rpx 5px;
line-height: 18px;
border-color: white;
border-left: 1px solid #ffffff;
color: #999;
}
}
.track-list view.finall .div-spilander {
.track-list view.finall .div-spilander {
width: 1px;
position: absolute;
left: -1.5px;
height: 0.5*100rpx;
height: 0.5 * 100rpx;
background-color: #d9d9d9;
}
}
</style>

2
pages/order/OrderDetails/index.vue

@ -542,8 +542,6 @@ export default {
}
},
goBack() {
const history = this.app.history,
last = history[history.length - 1] || {};
if (last.name === "MyOrder") return this.$yrouter.back();
else
return this.$yrouter.replace({

4
pages/order/OrderSubmission/index.vue

@ -90,8 +90,8 @@
</view>
</view>
<view class="item">
<view>备注信息</view>
<textarea placeholder="请添加备注(150字以内)" v-model="mark"></textarea>
<view>备注信息150字以内</view>
<textarea v-model="mark"></textarea>
</view>
</view>
<view class="wrapper">

164
pages/shop/ShoppingCart/index.vue

@ -3,16 +3,13 @@
<view v-if="$store.getters.token||userInfo.uid">
<view class="labelNav acea-row row-around row-middle">
<view class="item">
<text class="iconfont icon-xuanzhong"></text>
100%正品保证
<text class="iconfont icon-xuanzhong"></text>100%正品保证
</view>
<view class="item">
<text class="iconfont icon-xuanzhong"></text>
所有商品精挑细选
<text class="iconfont icon-xuanzhong"></text>所有商品精挑细选
</view>
<view class="item">
<text class="iconfont icon-xuanzhong"></text>
售后无忧
<text class="iconfont icon-xuanzhong"></text>售后无忧
</view>
</view>
<view class="nav acea-row row-between-wrapper">
@ -20,15 +17,25 @@
购物数量
<text class="num font-color-red">{{ count }}</text>
</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 v-if="validList.length > 0 || cartList.invalid.length > 0">
<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="checkbox-wrapper">
<checkbox-group @change="switchSelect(cartListValidIndex)">
<label class="well-check"><checkbox value :checked="item.checked"></checkbox></label>
<label class="well-check">
<checkbox value :checked="item.checked"></checkbox>
</label>
</checkbox-group>
</view>
</view>
@ -39,28 +46,31 @@
</view>
<view class="text">
<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>
<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="plus"
v-if="validList[cartListValidIndex].attrInfo"
:class="validList[cartListValidIndex].cartNum >= validList[cartListValidIndex].attrInfo.stock ? 'on' : ''"
@click.prevent="plus(cartListValidIndex)"
>
+
</view>
>+</view>
<view
class="plus"
v-else
:class="validList[cartListValidIndex].cartNum >= validList[cartListValidIndex].stock ? 'on' : ''"
@click.prevent="plus(cartListValidIndex)"
>
+
</view>
>+</view>
</view>
</view>
</view>
@ -68,17 +78,25 @@
<view class="invalidGoods" v-if="cartList.invalid.length > 0">
<view class="goodsNav acea-row row-between-wrapper">
<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 class="del" @click="delInvalidGoods">
<text class="iconfont icon-shanchu1"></text>
清空
<text class="iconfont icon-shanchu1"></text>清空
</view>
</view>
<view class="goodsList" :hidden="goodsHidden">
<view 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
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="pictrue">
<image :src="item.productInfo.attrInfo.image" v-if="item.productInfo.attrInfo" />
@ -86,8 +104,13 @@
</view>
<view class="text acea-row row-column-between">
<view class="line1">{{ item.productInfo.storeName }}</view>
<view class="infor line1" v-if="item.productInfo.attrInfo">属性{{ item.productInfo.attrInfo.suk }}</view>
<view class="acea-row row-between-wrapper"><view class="end">该商品已下架</view></view>
<view
class="infor line1"
v-if="item.productInfo.attrInfo"
>属性{{ item.productInfo.attrInfo.suk }}</view>
<view class="acea-row row-between-wrapper">
<view class="end">该商品已下架</view>
</view>
</view>
</view>
</view>
@ -96,7 +119,9 @@
</view>
<!--购物车暂无商品-->
<view class="noCart" v-if="cartList.valid.length === 0 && cartList.invalid.length === 0">
<view class="pictrue"><image src="@/static/images/noCart.png" /></view>
<view class="pictrue">
<image src="@/static/images/noCart.png" />
</view>
<Recommend></Recommend>
</view>
<view style="height:210rpx"></view>
@ -139,19 +164,24 @@
</view>
</template>
<script>
import Recommend from '@/components/Recommend';
import Authorization from '@/pages/authorization/index';
import { mapGetters } from 'vuex';
import Recommend from "@/components/Recommend";
import Authorization from "@/pages/authorization/index";
import { mapGetters } from "vuex";
import { getCartList, postCartDel, changeCartNum, getCartCount } from '@/api/store';
import { postCollectAll } from '@/api/user';
import { mul, add } from '@/utils/bc';
import cookie from '@/utils/store/cookie';
import {
getCartList,
postCartDel,
changeCartNum,
getCartCount
} from "@/api/store";
import { postCollectAll } from "@/api/user";
import { mul, add } from "@/utils/bc";
import cookie from "@/utils/store/cookie";
const CHECKED_IDS = 'cart_checked';
const CHECKED_IDS = "cart_checked";
export default {
name: 'ShoppingCart',
name: "ShoppingCart",
components: {
Recommend,
Authorization
@ -174,7 +204,7 @@ export default {
loaded: false
};
},
computed: mapGetters(['userInfo', 'token']),
computed: mapGetters(["userInfo", "token"]),
// watch: {
// $yroute(n) {
@ -223,7 +253,7 @@ export default {
methods: {
goGoodsCon(item) {
this.$yrouter.push({
path: '/pages/shop/GoodsCon/index',
path: "/pages/shop/GoodsCon/index",
query: {
id: item.productId
}
@ -260,17 +290,18 @@ export default {
});
if (id.length === 0) {
uni.showToast({
title: '请选择产品',
icon: 'none',
title: "请选择产品",
icon: "none",
duration: 2000
});
return;
}
postCartDel(id).then(function() {
list.forEach(function(val, i) {
if (val.checked === false || val.checked === undefined) valid.push(list[i]);
if (val.checked === false || val.checked === undefined)
valid.push(list[i]);
});
that.$set(that.cartList, 'valid', valid);
that.$set(that.cartList, "valid", valid);
that.carnum();
that.countMoney();
that.gainCount();
@ -303,7 +334,7 @@ export default {
let that = this,
data = {
id: [],
category: ''
category: ""
},
list = that.cartList.valid;
list.forEach(function(val) {
@ -314,16 +345,16 @@ export default {
});
if (data.id.length === 0) {
uni.showToast({
title: '请选择产品',
icon: 'none',
title: "请选择产品",
icon: "none",
duration: 2000
});
return;
}
postCollectAll(data).then(function() {
uni.showToast({
title: '收藏成功!',
icon: 'none',
title: "收藏成功!",
icon: "none",
duration: 2000
});
});
@ -340,16 +371,16 @@ export default {
});
if (id.length === 0) {
uni.showToast({
title: '请选择产品',
icon: 'none',
title: "请选择产品",
icon: "none",
duration: 2000
});
return;
}
this.$yrouter.push({
path: '/pages/order/OrderSubmission/index',
path: "/pages/order/OrderSubmission/index",
query: {
id: id.join(',')
id: id.join(",")
}
});
},
@ -368,11 +399,11 @@ export default {
list.cartNum++;
if (list.attrInfo) {
if (list.cartNum >= list.attrInfo.stock) {
that.$set(list, 'cart_num', list.attrInfo.stock);
that.$set(list, "cart_num", list.attrInfo.stock);
}
} else {
if (list.cartNum >= list.stock) {
that.$set(list, 'cart_num', list.stock);
that.$set(list, "cart_num", list.stock);
}
}
that.carnum();
@ -385,15 +416,15 @@ export default {
let list = that.cartList.valid[index];
if (list.cartNum <= 1) {
uni.showToast({
title: '已经是底线啦!',
icon: 'none',
title: "已经是底线啦!",
icon: "none",
duration: 2000
});
return;
}
list.cartNum--;
if (list.cartNum < 1) {
that.$set(list, 'cart_num', 1);
that.$set(list, "cart_num", 1);
}
that.carnum();
that.countMoney();
@ -404,11 +435,13 @@ export default {
changeCartNum(cart.id, Math.max(cart.cartNum, 1) || 1)
.then(res => {
this.getCartList();
this.gainCount();
})
.catch(error => {
this.gainCount();
uni.showToast({
title: error.response.data.msg,
icon: 'none',
icon: "none",
duration: 2000
});
});
@ -433,18 +466,19 @@ export default {
}
}
that.isAllSelect = selectnum.length === len;
that.$set(that, 'cartList', that.cartList);
that.$set(that, 'isAllSelect', that.isAllSelect);
that.$set(that, "cartList", that.cartList);
that.$set(that, "isAllSelect", that.isAllSelect);
cookie.set(CHECKED_IDS, that.checkedIds);
that.carnum();
that.gainCount();
that.countMoney();
},
//
allChecked: function(e) {
console.log(e)
console.log(e);
let that = this;
let selectAllStatus = e.mp.detail.value[0]=='allSelect' ? true : false;
console.log(selectAllStatus)
let selectAllStatus = e.mp.detail.value[0] == "allSelect" ? true : false;
console.log(selectAllStatus);
// let selectAllStatus = that.isAllSelect;
let checkedIds = [];
// for (let i = 0; i < array.length; i++) {
@ -462,9 +496,9 @@ export default {
};
that.cartList = [];
that.cartList = cartList;
console.log(this.cartList)
this.$set(this, 'cartList', this.cartList);
this.$set(this, 'isAllSelect', selectAllStatus);
console.log(this.cartList);
this.$set(this, "cartList", this.cartList);
this.$set(this, "isAllSelect", selectAllStatus);
this.checkedIds = checkedIds;
cookie.set(CHECKED_IDS, checkedIds);
that.carnum();
@ -481,7 +515,7 @@ export default {
carnum += parseInt(array[i].cartNum);
}
}
that.$set(that, 'cartCount', carnum);
that.$set(that, "cartCount", carnum);
},
//
countMoney: function() {

9
pages/user/UserVip/index.vue

@ -44,8 +44,7 @@
<view class="item" v-for="(item, vipCompleteIndex) in vipComplete" :key="vipCompleteIndex">
<view class="top acea-row row-between-wrapper">
<view class="name">
{{ item.name
}}
{{ item.name}}
<text class="iconfont icon-wenti" v-if="item.illustrate" @click="showGrow(item)"></text>
</view>
<view>{{ item.finish ? "已满足条件" : "未满足条件" }}</view>
@ -165,7 +164,8 @@ export default {
},
err => {
uni.showToast({
title: err.msg || err.response.data.msg|| err.response.data.message,
title:
err.msg || err.response.data.msg || err.response.data.message,
icon: "none",
duration: 2000
});
@ -182,7 +182,8 @@ export default {
},
err => {
uni.showToast({
title: err.msg || err.response.data.msg|| err.response.data.message,
title:
err.msg || err.response.data.msg || err.response.data.message,
icon: "none",
duration: 2000
});

2
pages/user/signIn/Sign/index.vue

@ -101,6 +101,7 @@
};
},
mounted: function() {
uni.showLoading({ title: "加载中", mask: true });
this.signUser();
this.signConfig();
this.getSignList();
@ -129,6 +130,7 @@
postSignUser({
sign: 1
}).then(res => {
uni.hideLoading();
res.data.integral = parseInt(res.data.integral);
var sumSginDay = res.data.sumSignDay;
that.userInfo = res.data;

26
utils/index.js

@ -114,17 +114,19 @@ export const replaceLogin = (msg) => {
uni.hideLoading();
if (msg) {
uni.showToast({
title: msg,
title: '重新登录中...',
icon: 'none',
duration: 2000
});
}
// 这里代表已经失去登录状态以及401强制退出登录了
// 这里代表已经失去登录状态以及401强制出登录了
store.commit('LOGOUT')
console.log('如果是微信小程序,跳转到授权页', Vue.prototype.$deviceType, msg)
if (Vue.prototype.$deviceType == 'routine') {
// 如果是微信小程序,跳转到授权页
login({
fail: () => {
console.log('如果是微信小程序,跳转到授权页')
replace({
path: '/pages/authorization/index',
query: {
@ -176,6 +178,10 @@ export const authorize = (authorizeStr) => {
resolve('获取授权成功')
},
fail() {
switchTab({
path: '/pages/home/index',
// query
});
reject('获取授权失败')
}
})
@ -252,13 +258,14 @@ export const login = (option) => {
export const handleGetUserInfo = () => {
getUser().then(res => {
console.log('获取用户信息')
store.dispatch('setUserInfo', res.data)
var pages = getCurrentPages() //获取加载的页面
var currentPage = pages[pages.length - 1] //获取当前页面的对象
let url = "/pages/home/index"
let query = {}
console.log('currentPage')
if (currentPage) {
// 获取到最后一个页面
if (
@ -278,16 +285,21 @@ export const handleGetUserInfo = () => {
}
}
}
console.log(url)
if (url == '/pages/home/index' || url == '/pages/shop/GoodsClass/index' || url == '/pages/shop/ShoppingCart/index' || url == '/pages/user/User/index') {
switchTab({
path: `${url}`,
query
});
} else {
push({
path: `${url}`,
query
})
switchTab({
path: '/pages/home/index',
// query
});
// push({
// path: `${url}`,
// query
// })
}
})
}

5
utils/request.js

@ -10,10 +10,12 @@ fly.config.baseURL = VUE_APP_API_URL
fly.interceptors.response.use(
response => {
console.log(response)
// 定时刷新access-token
return response;
},
error => {
console.log(error)
if (error.toString() == 'Error: Network Error') {
toLogin();
return Promise.reject({ msg: "未登录", toLogin: true });
@ -47,7 +49,6 @@ function baseRequest(options) {
// 提示错误信息
return Promise.reject({ msg: "未登录", toLogin: true });
}
console.log(options)
// 结构请求需要的参数
const { url, params, data, login, ...option } = options
@ -55,10 +56,8 @@ console.log(options)
return fly.request(url, params || data, {
...option
}).then(res => {
console.log(res)
const data = res.data || {};
if (res.status !== 200) {
return Promise.reject({ msg: "请求失败", res, data });
}
if ([410000, 410001, 410002].indexOf(data.status) !== -1) {

Loading…
Cancel
Save