Browse Source

uniapp-提交订单时取消订单,提示错误

uniapp-购物车编辑数量后未更新数量统计
uniapp-token失效未进行重新登录
uniapp-查看物流-点标识太大 造成部分物流信息被遮挡
master
Gao xiaosong 5 years ago
parent
commit
3a72a23bbe
  1. 3
      libs/login.js
  2. 4
      libs/wechat.js
  3. 7
      manifest.json
  4. 66
      pages/order/Logistics/index.vue
  5. 2
      pages/order/OrderDetails/index.vue
  6. 4
      pages/order/OrderSubmission/index.vue
  7. 164
      pages/shop/ShoppingCart/index.vue
  8. 2
      pages/user/signIn/Sign/index.vue
  9. 24
      utils/index.js
  10. 5
      utils/request.js

3
libs/login.js

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

4
libs/wechat.js

@ -39,7 +39,9 @@ export const weappPay = (option) => {
}, },
fail: (error) => { fail: (error) => {
console.log(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) reject(error)
} }
}) })

7
manifest.json

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

66
pages/order/Logistics/index.vue

@ -27,7 +27,10 @@
</view> </view>
</view> </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>
<view class="item" v-for="(express, expressListIndex) in expressList" :key="expressListIndex"> <view class="item" v-for="(express, expressListIndex) in expressList" :key="expressListIndex">
<view class="circular" :class="expressListIndex === 0 ? 'on' : ''"></view> <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 class="div-bg bg-white" style="font-size:12px; background:#fff;">
<!--物流跟踪--> <!--物流跟踪-->
<view style="margin-bottom:5px;"> <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"> <view style="font-size: 26rpx;color: #111111; margin: 5px 0">
物流跟踪 物流跟踪
<!--物流跟踪--> <!--物流跟踪-->
@ -51,14 +57,20 @@
<view class="track-rcol"> <view class="track-rcol">
<view class="track-list"> <view class="track-list">
<view> <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 class="active" v-if="logisticsListindex===0">
<view></view> <view></view>
<i class="node-icon"></i> <i class="node-icon"></i>
<text class="txt">{{item.acceptStation}}</text> <text class="txt">{{item.acceptStation}}</text>
<text class="time">{{item.acceptTime}}</text> <text class="time">{{item.acceptTime}}</text>
</view> </view>
<view v-if="logisticsListindex > 0 && logisticsListindex !== logisticsList.length-1"> <view
v-if="logisticsListindex > 0 && logisticsListindex !== logisticsList.length-1"
>
<i class="node-icon"></i> <i class="node-icon"></i>
<text class="txt">{{item.acceptStation}}</text> <text class="txt">{{item.acceptStation}}</text>
<text class="time">{{item.acceptTime}}</text> <text class="time">{{item.acceptTime}}</text>
@ -86,13 +98,8 @@
</template> </template>
<script> <script>
import Recommend from "@/components/Recommend"; import Recommend from "@/components/Recommend";
import { import { express, orderDetail } from "@/api/order";
express, import { copyClipboard } from "@/utils";
orderDetail
} from "@/api/order";
import {
copyClipboard
} from "@/utils";
const NAME = "Logistics"; const NAME = "Logistics";
@ -108,10 +115,12 @@
orderInfo: {}, orderInfo: {},
expressList: [], expressList: [],
loaded: false, loaded: false,
logisticsList: [{ logisticsList: [
{
message: "暂无数据", message: "暂无数据",
messageDate: "" messageDate: ""
}] }
]
}; };
}, },
watch: { watch: {
@ -140,8 +149,9 @@
}) })
.catch(err => { .catch(err => {
uni.showToast({ uni.showToast({
title: err.msg || err.response.data.msg|| err.response.data.message, title:
icon: 'none', err.msg || err.response.data.msg || err.response.data.message,
icon: "none",
duration: 2000 duration: 2000
}); });
}); });
@ -150,10 +160,10 @@
if (!this.id) { if (!this.id) {
uni.showToast({ 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', icon: "none",
duration: 2000 duration: 2000
}); });
return return;
} }
this.loaded = false; this.loaded = false;
orderDetail(this.id) orderDetail(this.id)
@ -168,12 +178,12 @@
// this.cartInfo = res.data.order.cartInfo; // this.cartInfo = res.data.order.cartInfo;
// this.expressList = result.list || []; // this.expressList = result.list || [];
// this.loaded = true; // this.loaded = true;
}) })
.catch(err => { .catch(err => {
uni.showToast({ uni.showToast({
title: err.msg || err.response.data.msg|| err.response.data.message, title:
icon: 'none', err.msg || err.response.data.msg || err.response.data.message,
icon: "none",
duration: 2000 duration: 2000
}); });
}); });
@ -284,17 +294,23 @@
font-size: 0.24 * 100rpx; font-size: 0.24 * 100rpx;
} }
ul {} ul {
}
.track-rcol {} .track-rcol {
}
.track-list { .track-list {
position: relative; position: relative;
} }
.track-list view { .track-list > view {
position: relative;
padding: 0 0 0.5 * 100rpx 20rpx;
}
.track-list .track-list-item {
position: relative; position: relative;
padding: 0 0 0.5*100rpx 5px; padding: 0 0 0.5 * 100rpx 20rpx;
line-height: 0.3 * 100rpx; line-height: 0.3 * 100rpx;
border-left: 1px solid #d9d9d9; border-left: 1px solid #d9d9d9;
color: #999; color: #999;
@ -316,6 +332,7 @@
height: 0.2 * 100rpx; height: 0.2 * 100rpx;
top: 4px; top: 4px;
background-color: #b2b2b2; background-color: #b2b2b2;
padding: 0 !important;
} }
.track-list view.active .node-icon { .track-list view.active .node-icon {
@ -363,7 +380,6 @@
} }
.track-list view.finall { .track-list view.finall {
position: relative;
padding: 0px 0 0.5 * 100rpx 5px; padding: 0px 0 0.5 * 100rpx 5px;
line-height: 18px; line-height: 18px;
border-color: white; border-color: white;

2
pages/order/OrderDetails/index.vue

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

4
pages/order/OrderSubmission/index.vue

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

164
pages/shop/ShoppingCart/index.vue

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

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

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

24
utils/index.js

@ -113,16 +113,18 @@ export const copyClipboard = (data) => {
export const replaceLogin = (msg) => { export const replaceLogin = (msg) => {
uni.hideLoading(); uni.hideLoading();
uni.showToast({ uni.showToast({
title: msg, title: '重新登录中...',
icon: 'none', icon: 'none',
duration: 2000 duration: 2000
}); });
// 这里代表已经失去登录状态以及401强制推出登录了 // 这里代表已经失去登录状态以及401强制推出登录了
store.commit('LOGOUT') store.commit('LOGOUT')
console.log('如果是微信小程序,跳转到授权页', Vue.prototype.$deviceType, msg)
if (Vue.prototype.$deviceType == 'routine') { if (Vue.prototype.$deviceType == 'routine') {
// 如果是微信小程序,跳转到授权页 // 如果是微信小程序,跳转到授权页
login({ login({
fail: () => { fail: () => {
console.log('如果是微信小程序,跳转到授权页')
replace({ replace({
path: '/pages/authorization/index', path: '/pages/authorization/index',
query: { query: {
@ -174,6 +176,10 @@ export const authorize = (authorizeStr) => {
resolve('获取授权成功') resolve('获取授权成功')
}, },
fail() { fail() {
switchTab({
path: '/pages/home/index',
// query
});
reject('获取授权失败') reject('获取授权失败')
} }
}) })
@ -250,13 +256,14 @@ export const login = (option) => {
export const handleGetUserInfo = () => { export const handleGetUserInfo = () => {
getUser().then(res => { getUser().then(res => {
console.log('获取用户信息')
store.dispatch('setUserInfo', res.data) store.dispatch('setUserInfo', res.data)
var pages = getCurrentPages() //获取加载的页面 var pages = getCurrentPages() //获取加载的页面
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('currentPage')
if (currentPage) { if (currentPage) {
// 获取到最后一个页面 // 获取到最后一个页面
if ( if (
@ -276,16 +283,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') { if (url == '/pages/home/index' || url == '/pages/shop/GoodsClass/index' || url == '/pages/shop/ShoppingCart/index' || url == '/pages/user/User/index') {
switchTab({ switchTab({
path: `${url}`, path: `${url}`,
query query
}); });
} else { } else {
push({ switchTab({
path: `${url}`, path: '/pages/home/index',
query // query
}) });
// push({
// path: `${url}`,
// query
// })
} }
}) })
} }

5
utils/request.js

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

Loading…
Cancel
Save