Browse Source

1.修改小程序段拼团未登录情况下无法进行登录回跳的问题

2.新增订单扫码核销的功能
3.修改cookie方法未取到值返回null导致报错的问题
4.修改loading页面跳转登录的问题
master
Gaoxs 4 years ago
parent
commit
95a8589448
  1. 2
      pages/Loading/index.vue
  2. 348
      pages/activity/GroupRule/index.vue
  3. 5
      pages/authorization/index.vue
  4. 348
      pages/orderAdmin/OrderCancellation/index.vue
  5. BIN
      static/images/scan.gif
  6. 15
      utils/index.js
  7. 2
      utils/store/cookie.js

2
pages/Loading/index.vue

@ -71,7 +71,7 @@
toLaunch() { toLaunch() {
console.log("loading home"); console.log("loading home");
this.changeAuthorization(false); this.changeAuthorization(false);
let redirect = cookie.get('redirect') let redirect = cookie.get('redirect').replace(/\ /g, '')
if (redirect && redirect.indexOf('/pages') != -1) { if (redirect && redirect.indexOf('/pages') != -1) {
this.$yrouter.replace({ this.$yrouter.replace({
path: '/pages' + redirect.split('/pages')[1], path: '/pages' + redirect.split('/pages')[1],

348
pages/activity/GroupRule/index.vue

@ -1,6 +1,6 @@
<template> <template>
<view class="group-con"> <view class="group-con">
<view class="header acea-row row-between-wrapper"> <view class="header acea-row row-between-wrapper" v-if="storeCombination">
<view class="pictrue"> <view class="pictrue">
<image :src="storeCombination.image" /> <image :src="storeCombination.image" />
</view> </view>
@ -15,20 +15,13 @@
<view v-if="pinkBool === -1" class="iconfont icon-pintuanshibai"></view> <view v-if="pinkBool === -1" class="iconfont icon-pintuanshibai"></view>
<view v-else-if="pinkBool === 1" class="iconfont icon-pintuanchenggong font-color-red"></view> <view v-else-if="pinkBool === 1" class="iconfont icon-pintuanchenggong font-color-red"></view>
</view> </view>
<view class="wrapper"> <view class="wrapper" v-if="pinkT">
<view class="title acea-row row-center-wrapper"> <view class="title acea-row row-center-wrapper">
<view class="line"></view> <view class="line"></view>
<view class="name acea-row row-center-wrapper"> <view class="name acea-row row-center-wrapper">
<text>剩余</text> <text>剩余</text>
<count-down <count-down :isDay="true" :tipText="'倒计时 '" :dayText="' 天 '" :hourText="' 时 '" :minuteText="' 分 '"
:isDay="false" :secondText="' 秒'" :datatime="pinkT.stopTime/1000"></count-down>
:tipText="false"
:dayText="false"
:hourText="' : '"
:minuteText="' : '"
:secondText="false"
:datatime="pinkT.stopTime/1000"
></count-down>
<text>结束</text> <text>结束</text>
</view> </view>
<view class="line"></view> <view class="line"></view>
@ -38,11 +31,10 @@
<text class="tips" v-else-if="pinkBool === -1">还差{{ count }}拼团失败</text> <text class="tips" v-else-if="pinkBool === -1">还差{{ count }}拼团失败</text>
<text class="tips font-color-red" v-else-if="pinkBool === 0">拼团中还差{{ count }}人拼团成功</text> <text class="tips font-color-red" v-else-if="pinkBool === 0">拼团中还差{{ count }}人拼团成功</text>
</view> </view>
<view
class="list acea-row row-middle" <view class="list acea-row row-middle"
:class="[pinkBool === 1 || pinkBool === -1 ? 'result' : '',iShidden ? 'on' : '']" :class="[pinkBool === 1 || pinkBool === -1 ? 'result' : '',iShidden ? 'on' : '']">
> <view class="pictrue" v-if="pinkT">
<view class="pictrue">
<image :src="pinkT.avatar" /> <image :src="pinkT.avatar" />
</view> </view>
<view class="acea-row row-middle" v-if="pinkAll.length > 0"> <view class="acea-row row-middle" v-if="pinkAll.length > 0">
@ -54,29 +46,17 @@
<image class="img-none" src="@/static/images/vacancy.png" /> <image class="img-none" src="@/static/images/vacancy.png" />
</view> </view>
</view> </view>
<view <view v-if="(pinkBool === 1 || pinkBool === -1) && count > 9" class="lookAll acea-row row-center-wrapper"
v-if="(pinkBool === 1 || pinkBool === -1) && count > 9" @click="lookAll">
class="lookAll acea-row row-center-wrapper"
@click="lookAll"
>
{{ iShidden ? "收起" : "查看全部" }} {{ iShidden ? "收起" : "查看全部" }}
<text class="iconfont" :class="iShidden ? 'icon-xiangshang' : 'icon-xiangxia'"></text> <text class="iconfont" :class="iShidden ? 'icon-xiangshang' : 'icon-xiangxia'"></text>
</view> </view>
<view <view class="teamBnt bg-color-red" v-if="userBool === 1 && isOk == 0 && pinkBool === 0" @click="goPoster">邀请好友参团
class="teamBnt bg-color-red" </view>
v-if="userBool === 1 && isOk == 0 && pinkBool === 0" <view class="teamBnt bg-color-red" v-else-if="userBool === 0 && pinkBool === 0 && count > 0" @click="pay">我要参团
@click="goPoster" </view>
>邀请好友参团</view> <view class="teamBnt bg-color-red" v-if="pinkBool === 1 || pinkBool === -1"
<view @click="goDetail(storeCombination.id)">再次开团</view>
class="teamBnt bg-color-red"
v-else-if="userBool === 0 && pinkBool === 0 && count > 0"
@click="pay"
>我要参团</view>
<view
class="teamBnt bg-color-red"
v-if="pinkBool === 1 || pinkBool === -1"
@click="goDetail(storeCombination.id)"
>再次开团</view>
<view class="cancel" @click="getCombinationRemove" v-if="pinkBool === 0 && userBool === 1"> <view class="cancel" @click="getCombinationRemove" v-if="pinkBool === 0 && userBool === 1">
<text class="iconfont icon-guanbi3"></text> <text class="iconfont icon-guanbi3"></text>
<text>取消开团</text> <text>取消开团</text>
@ -89,161 +69,169 @@
</view> </view>
</template> </template>
<script> <script>
import CountDown from "@/components/CountDown"; import CountDown from "@/components/CountDown";
import { getCombinationPink, getCombinationRemove } from "@/api/activity"; import {
import { postCartAdd } from "@/api/store"; getCombinationPink,
import { isWeixin, parseQuery, handleQrCode } from "@/utils/index"; getCombinationRemove
} from "@/api/activity";
import {
postCartAdd
} from "@/api/store";
import {
isWeixin,
parseQuery,
handleQrCode
} from "@/utils/index";
const NAME = "GroupRule"; const NAME = "GroupRule";
export default { export default {
name: NAME, name: NAME,
components: { components: {
CountDown CountDown
},
props: {},
data: function() {
return {
currentPinkOrder: "", //
isOk: 0, //
pinkBool: 0, //|0=,1=
userBool: 0, //|0=,1=
pinkAll: [], //
pinkT: [], //
storeCombination: [], //
pinkId: 0,
uniqueId: "",
count: 0, //
iShidden: false
};
},
watch: {
$yroute(n) {
var that = this;
if (n.name === NAME) {
that.pinkId = that.$yroute.query.id;
that.getCombinationPink();
}
}
},
mounted: function() {
var that = this;
let url = handleQrCode();
if (url) {
that.pinkId = url.pinkId;
} else {
that.pinkId = that.$yroute.query.id;
}
that.getCombinationPink();
},
methods: {
pay: function() {
var that = this;
var data = {};
data.productId = that.storeCombination.productId;
data.cartNum = that.pinkT.totalNum;
data.uniqueId = that.uniqueId;
data.combinationId = that.storeCombination.id;
data.new = 1;
postCartAdd(data)
.then(res => {
that.$yrouter.push({
path: "/pages/order/OrderSubmission/index",
query: {
id: res.data.cartId,
pinkid: that.pinkId
}
});
})
.catch(err => {
uni.showToast({
title:
err.msg || err.response.data.msg || err.response.data.message,
icon: "none",
duration: 2000
});
});
},
goPoster: function() {
var that = this;
this.$yrouter.push({
path: "/pages/activity/Poster/index",
query: {
id: that.pinkId,
type: 1
}
});
},
goOrder: function() {
var that = this;
this.$yrouter.push({
path: "/pages/order/OrderDetails/index",
query: {
id: that.currentPinkOrder
}
});
}, },
// props: {},
goList: function() { data: function () {
this.$yrouter.push({ return {
path: "/pages/activity/GoodsGroup/index" currentPinkOrder: "", //
}); isOk: 0, //
pinkBool: 0, //|0=,1=
userBool: 0, //|0=,1=
pinkAll: [], //
pinkT: {}, //
storeCombination: {}, //
pinkId: 0,
uniqueId: "",
count: 0, //
iShidden: false
};
}, },
// watch: {
goDetail: function(id) { $yroute(n) {
this.$yrouter.push({ var that = this;
path: "/pages/activity/GroupDetails/index", if (n.name === NAME) {
query: { that.pinkId = that.$yroute.query.id;
id that.getCombinationPink();
} }
}); }
}, },
// mounted: function () {
getCombinationPink: function() {
var that = this; var that = this;
getCombinationPink(that.pinkId).then(res => { let url = handleQrCode();
that.$set(that, "storeCombination", res.data.storeCombination); if (url) {
that.$set(that, "pinkT", res.data.pinkT); that.pinkId = url.pinkId;
that.$set(that, "pinkAll", res.data.pinkAll); } else {
that.$set(that, "count", res.data.count); that.pinkId = that.$yroute.query.id;
that.$set(that, "userBool", res.data.userBool); }
that.$set(that, "pinkBool", res.data.pinkBool); that.getCombinationPink();
that.$set(that, "isOk", res.data.isOk);
that.$set(that, "currentPinkOrder", res.data.currentPinkOrder);
that.$set(that, "uniqueId", res.data.uniqueId);
});
}, },
// methods: {
getCombinationRemove: function() { pay: function () {
var that = this; var that = this;
getCombinationRemove({ var data = {};
id: that.pinkId, data.productId = that.storeCombination.productId;
cid: that.storeCombination.id data.cartNum = that.pinkT.totalNum;
}) data.uniqueId = that.uniqueId;
.then(res => { data.combinationId = that.storeCombination.id;
uni.showToast({ data.new = 1;
title: res.msg, postCartAdd(data)
icon: "none", .then(res => {
duration: 2000 that.$yrouter.push({
}); path: "/pages/order/OrderSubmission/index",
}) query: {
.catch(res => { id: res.data.cartId,
uni.showToast({ pinkid: that.pinkId
title: res.msg, }
icon: "none", });
duration: 2000 })
.catch(err => {
uni.showToast({
title: err.msg || err.response.data.msg || err.response.data.message,
icon: "none",
duration: 2000
});
}); });
},
goPoster: function () {
var that = this;
this.$yrouter.push({
path: "/pages/activity/Poster/index",
query: {
id: that.pinkId,
type: 1
}
}); });
}, },
lookAll: function() { goOrder: function () {
this.iShidden = !this.iShidden; var that = this;
this.$yrouter.push({
path: "/pages/order/OrderDetails/index",
query: {
id: that.currentPinkOrder
}
});
},
//
goList: function () {
this.$yrouter.push({
path: "/pages/activity/GoodsGroup/index"
});
},
//
goDetail: function (id) {
this.$yrouter.push({
path: "/pages/activity/GroupDetails/index",
query: {
id
}
});
},
//
getCombinationPink: function () {
var that = this;
getCombinationPink(that.pinkId).then(res => {
that.$set(that, "storeCombination", res.data.storeCombination);
that.$set(that, "pinkT", res.data.pinkT);
that.$set(that, "pinkAll", res.data.pinkAll);
that.$set(that, "count", res.data.count);
that.$set(that, "userBool", res.data.userBool);
that.$set(that, "pinkBool", res.data.pinkBool);
that.$set(that, "isOk", res.data.isOk);
that.$set(that, "currentPinkOrder", res.data.currentPinkOrder);
that.$set(that, "uniqueId", res.data.uniqueId);
});
},
//
getCombinationRemove: function () {
var that = this;
getCombinationRemove({
id: that.pinkId,
cid: that.storeCombination.id
})
.then(res => {
uni.showToast({
title: res.msg,
icon: "none",
duration: 2000
});
})
.catch(res => {
uni.showToast({
title: res.msg,
icon: "none",
duration: 2000
});
});
},
lookAll: function () {
this.iShidden = !this.iShidden;
}
} }
} };
};
</script> </script>
<style lang="less"> <style lang="less">
.tips-warp { .tips-warp {
text-align: center; text-align: center;
margin-top: 20rpx; margin-top: 20rpx;
} }
</style> </style>

5
pages/authorization/index.vue

@ -90,8 +90,9 @@
}); });
login() login()
.then((res) => { .then((res) => {
this.$yrouter.replace({ console.log('重定向')
path: cookie.get("redirect") this.$yrouter.reLaunch({
path: cookie.get("redirect").replace(/\ /g, '')
}); });
}) })
.catch((error) => { .catch((error) => {

348
pages/orderAdmin/OrderCancellation/index.vue

@ -1,179 +1,199 @@
<template> <template>
<view class="OrderCancellation"> <view class="OrderCancellation">
<view class="header"> <view class="header">
<image mode="aspectFit" src="@/static/images/writeOffBg.jpg" @click="openQRCode" /> <image mode="aspectFit" src="@/static/images/writeOffBg.jpg" @click="openQRCode" />
</view> </view>
<view class="whiteBg"> <view class="whiteBg">
<view class="input"> <view class="input">
<input type="number" placeholder="0" v-model="verify_code" /> <input type="number" placeholder="0" v-model="verify_code" />
</view> </view>
<view class="bnt" @click="storeCancellation">立即核销</view> <view class="bnt" @click="storeCancellation">立即核销</view>
</view> </view>
<!-- <view class="scan" v-if="iswechat"> <!-- #ifndef H5 -->
<image src="@/static/images/scan.gif" @click="openQRCode" /> <view class="scan" v-if="iswechat">
</view> --> <image src="@/static/images/scan.gif" @click="openQRCode" />
<WriteOff :iShidden="iShidden" :orderInfo="orderInfo" @cancel="cancel" @confirm="confirm"></WriteOff> </view>
</view> <!-- #endif -->
<WriteOff :iShidden="iShidden" :orderInfo="orderInfo" @cancel="cancel" @confirm="confirm"></WriteOff>
</view>
</template> </template>
<script> <script>
import WriteOff from "@/components/WriteOff"; import WriteOff from "@/components/WriteOff";
import { isWeixin } from "@/utils"; import {
// import { wechatEvevt } from "@/libs/wechat"; isWeixin
import { orderVerific } from "@/api/order"; } from "@/utils";
const NAME = "OrderCancellation"; // import { wechatEvevt } from "@/libs/wechat";
import {
orderVerific
} from "@/api/order";
const NAME = "OrderCancellation";
export default { export default {
name: NAME, name: NAME,
components: { components: {
WriteOff WriteOff
}, },
props: {}, props: {},
data: function() { data: function() {
return { return {
iShidden: true, iShidden: true,
iswechat: isWeixin(), orderInfo: {},
orderInfo: {}, verify_code: ""
verify_code: "" };
}; },
}, mounted: function() {},
mounted: function() {}, methods: {
methods: { cancel: function(res) {
cancel: function(res) { this.iShidden = res;
this.iShidden = res; },
}, confirm: function() {
confirm: function() { orderVerific(this.verify_code, 1)
orderVerific(this.verify_code, 1) .then(res => {
.then(res => { this.iShidden = true;
this.iShidden = true; this.verify_code = "";
this.verify_code = ""; uni.showToast({
uni.showToast({ title: res.msg,
title: res.msg, icon: "none",
icon: "none", duration: 2000
duration: 2000 });
}); })
}) .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, duration: 2000
icon: "none", });
duration: 2000 });
}); },
}); storeCancellation: function() {
}, let ref = /[0-9]{12}/;
storeCancellation: function() { if (!this.verify_code) {
let ref = /[0-9]{12}/; uni.showToast({
if (!this.verify_code) { title: "请输入核销码",
uni.showToast({ icon: "none",
title: "请输入核销码", duration: 2000
icon: "none", });
duration: 2000 return;
}); }
return; if (!ref.test(this.verify_code)) {
} uni.showToast({
if (!ref.test(this.verify_code)) { title: "请输入正确的核销码",
uni.showToast({ icon: "none",
title: "请输入正确的核销码", duration: 2000
icon: "none", });
duration: 2000 return;
}); }
return; uni.showLoading({
} title: "查询中"
uni.showLoading({ });
title: "查询中" orderVerific(this.verify_code, 0)
}); .then(res => {
orderVerific(this.verify_code, 0) uni.hideLoading();
.then(res => { this.orderInfo = res.data;
uni.hideLoading(); this.iShidden = false;
this.orderInfo = res.data; uni.showToast({
this.iShidden = false; title: res.msg,
uni.showToast({ icon: "success",
title: res.msg, duration: 2000
icon: "success", });
duration: 2000 })
}); .catch(error => {
}) uni.hideLoading();
.catch(error => { uni.showToast({
uni.hideLoading(); title: error.msg ||
uni.showToast({ error.response.data.msg ||
title: error.response.data.message,
error.msg || icon: "none",
error.response.data.msg || duration: 2000
error.response.data.message, });
icon: "none", });
duration: 2000 },
}); openQRCode: function() {
}); let that = this;
}, //
openQRCode: function() { uni.scanCode({
let that = this; success: (res) => {
// var result = res.result;
} if (result) {
} that.verify_code = res.result;
}; that.storeCancellation();
} else {
uni.showToast({
title: '没有扫描到什么!',
icon: "none",
duration: 2000
});
}
}
})
}
}
};
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
.OrderCancellation .header { .OrderCancellation .header {
width: 100%; width: 100%;
height: 3 * 100rpx; height: 3 * 100rpx;
background-size: 100% 100%; background-size: 100% 100%;
image {
width: 100%; image {
height: 3 * 100rpx; width: 100%;
} height: 3 * 100rpx;
} }
}
.OrderCancellation .whiteBg { .OrderCancellation .whiteBg {
width: 6.9 * 100rpx; width: 6.9 * 100rpx;
background-color: #fff; background-color: #fff;
margin: -0.93 * 100rpx auto 0 auto; margin: -0.93 * 100rpx auto 0 auto;
padding-top: 0.8 * 100rpx; padding-top: 0.8 * 100rpx;
padding-bottom: 30rpx; padding-bottom: 30rpx;
z-index:20; z-index: 20;
position: relative; position: relative;
border-radius: 0.06 * 100rpx 0.06 * 100rpx 0 0; border-radius: 0.06 * 100rpx 0.06 * 100rpx 0 0;
} }
.OrderCancellation .whiteBg .input { .OrderCancellation .whiteBg .input {
width: 5.8 * 100rpx; width: 5.8 * 100rpx;
margin: 0 auto; margin: 0 auto;
border-bottom: 0.01 * 100rpx solid #eee; border-bottom: 0.01 * 100rpx solid #eee;
} }
.OrderCancellation .whiteBg .input input { .OrderCancellation .whiteBg .input input {
padding-bottom: 0.25 * 100rpx; padding-bottom: 0.25 * 100rpx;
font-size: 0.6 * 100rpx; font-size: 0.6 * 100rpx;
height: auto; height: auto;
color: #282828; color: #282828;
width: 100%; width: 100%;
text-align: center; text-align: center;
} }
.OrderCancellation .whiteBg .bnt { .OrderCancellation .whiteBg .bnt {
font-size: 0.32 * 100rpx; font-size: 0.32 * 100rpx;
color: #fff; color: #fff;
width: 5.8 * 100rpx; width: 5.8 * 100rpx;
height: 0.86 * 100rpx; height: 0.86 * 100rpx;
border-radius: 0.43 * 100rpx; border-radius: 0.43 * 100rpx;
background-image: linear-gradient(to right, #eb3729 0%, #eb3729 100%); background-image: linear-gradient(to right, #eb3729 0%, #eb3729 100%);
background-image: -webkit-linear-gradient(to right, #eb3729 0%, #eb3729 100%); background-image: -webkit-linear-gradient(to right, #eb3729 0%, #eb3729 100%);
background-image: -moz-linear-gradient(to right, #eb3729 0%, #eb3729 100%); background-image: -moz-linear-gradient(to right, #eb3729 0%, #eb3729 100%);
text-align: center; text-align: center;
line-height: 0.86 * 100rpx; line-height: 0.86 * 100rpx;
margin: 0.55 * 100rpx auto 0 auto; margin: 0.55 * 100rpx auto 0 auto;
} }
.OrderCancellation .scan { .OrderCancellation .scan {
width: 3 * 100rpx; width: 3 * 100rpx;
height: 3 * 100rpx; height: 3 * 100rpx;
margin: 1.1 * 100rpx auto 0 auto; margin: 1.1 * 100rpx auto 0 auto;
} }
.OrderCancellation .scan image { .OrderCancellation .scan image {
width: 100%; width: 100%;
height: 100%; height: 100%;
display: block; display: block;
} }
</style> </style>

BIN
static/images/scan.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

15
utils/index.js

@ -211,7 +211,7 @@ export const login = () => {
if (code) { if (code) {
auth(code) auth(code)
.then(() => { .then(() => {
let redirect = cookie.get('redirect') let redirect = cookie.get('redirect').replace(/\ /g, '')
console.log(redirect) console.log(redirect)
if (redirect) { if (redirect) {
redirect = redirect.split('/pages')[1] redirect = redirect.split('/pages')[1]
@ -327,7 +327,7 @@ export const handleGetUserInfo = () => {
store.dispatch('setUserInfo', res.data) store.dispatch('setUserInfo', res.data)
console.log('获取用户信息后跳转回显的页面') console.log('获取用户信息后跳转回显的页面')
let redirect = cookie.get('redirect') let redirect = cookie.get('redirect').replace(/\ /g, '')
if (redirect) { if (redirect) {
reLaunch({ reLaunch({
path: redirect, path: redirect,
@ -585,11 +585,9 @@ export function routerPermissions(url, type) {
}) })
return return
} }
{ push({
push({ path,
path, })
})
}
}).catch(error => { }).catch(error => {
console.log('————————') console.log('————————')
console.log('自动登录失败,跳转到授权页面') console.log('自动登录失败,跳转到授权页面')
@ -661,7 +659,7 @@ export function reLaunch(location, complete, fail, success) {
uni.reLaunch(params) uni.reLaunch(params)
}).catch(error => { }).catch(error => {
// 没有权限 // 没有权限
console.log(error)
}) })
} }
@ -850,6 +848,7 @@ export const handleLoginFailure = () => {
// 改为授权取消 // 改为授权取消
store.commit("updateAuthorization", false); store.commit("updateAuthorization", false);
let currentPageUrl = getCurrentPageUrl() let currentPageUrl = getCurrentPageUrl()
if (store.state.$deviceType == 'weixin') { if (store.state.$deviceType == 'weixin') {
// 如果不是授权页面, // 如果不是授权页面,

2
utils/store/cookie.js

@ -5,7 +5,7 @@ const doc = null;
function get(key) { function get(key) {
if (!key || !_has(key)) { if (!key || !_has(key)) {
return null; return '';
} }
return uni.getStorageSync(key) return uni.getStorageSync(key)
} }

Loading…
Cancel
Save