Skip to content

Commit 1f02af5

Browse files
committed
增加主从表demo
1 parent 1573b5c commit 1f02af5

File tree

7 files changed

+455
-41
lines changed

7 files changed

+455
-41
lines changed

Vue.H5/src/Login.vue

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,49 @@
11
<template >
22
<div class="login-container">
3-
<vol-header :back="false" title="vol.vue-h5演示环境"></vol-header>
3+
<vol-header :back="false"
4+
title="vol.vue-h5演示环境"></vol-header>
45
<h2>帐号登陆</h2>
56
<div class="login-input">
6-
<van-field
7-
size="large"
8-
v-model="userInfo.userName"
9-
placeholder="请输入帐号"
10-
type="text"
11-
label="帐号"
12-
/>
13-
<van-field
14-
size="large"
15-
v-model="userInfo.password"
16-
placeholder="请输入密码"
17-
type="password"
18-
label="密码"
19-
/>
20-
<van-field
21-
v-model="userInfo.verificationCode"
22-
center
23-
clearable
24-
label="验证码"
25-
placeholder="请输入验证码"
26-
>
7+
<van-field size="large"
8+
v-model="userInfo.userName"
9+
placeholder="请输入帐号"
10+
type="text"
11+
label="帐号" />
12+
<van-field size="large"
13+
v-model="userInfo.password"
14+
placeholder="请输入密码"
15+
type="password"
16+
label="密码" />
17+
<van-field v-model="userInfo.verificationCode"
18+
center
19+
clearable
20+
label="验证码"
21+
placeholder="请输入验证码">
2722
<template #button>
28-
<img @click="()=>{getVierificationCode()}" v-show="codeImgSrc!=''" :src="codeImgSrc" />
23+
<img @click="()=>{getVierificationCode()}"
24+
v-show="codeImgSrc!=''"
25+
:src="codeImgSrc" />
2926
</template>
3027
</van-field>
3128
</div>
3229
<div class="login-btn">
33-
<van-button @click="login()" v-show="!loading" block type="info">登陆</van-button>
34-
<van-button disabled v-show="loading" block loading type="info" loading-text="正在登陆..." />
30+
<van-button @click="login()"
31+
v-show="!loading"
32+
block
33+
type="info">登陆</van-button>
34+
<van-button disabled
35+
v-show="loading"
36+
block
37+
loading
38+
type="info"
39+
loading-text="正在登陆..." />
3540
</div>
3641
<div class="login-account">
3742
<a>注册</a>
3843
<a>忘记密码</a>
3944
</div>
40-
<van-divider class="login-line" dashed>其他方式登陆</van-divider>
45+
<van-divider class="login-line"
46+
dashed>其他方式登陆</van-divider>
4147
<div class="login-other">
4248
<div class="item"></div>
4349
<div class="item">
@@ -60,12 +66,17 @@
6066
import { Field, Divider } from "vant";
6167
import VolHeader from "@/components/VolHeader.vue";
6268
export default {
69+
watch: {
70+
'$route' (to, from) {
71+
console.log(to, from);
72+
}
73+
},
6374
components: {
6475
"vol-header": VolHeader,
6576
"van-field": Field,
6677
"van-divider": Divider
6778
},
68-
data() {
79+
data () {
6980
return {
7081
codeImgSrc: "",
7182
loading: false,
@@ -76,17 +87,17 @@ export default {
7687
}
7788
};
7889
},
79-
created() {
90+
created () {
8091
this.getVierificationCode();
8192
},
8293
methods: {
83-
getVierificationCode() {
94+
getVierificationCode () {
8495
this.http.get("/api/User/getVierificationCode").then(x => {
8596
this.codeImgSrc = "data:image/png;base64," + x.img;
8697
this.userInfo.UUID = x.uuid;
8798
});
8899
},
89-
login() {
100+
login () {
90101
if (this.userInfo.userName == "" || this.userInfo.userName.trim() == "")
91102
return this.$Message.error("请输入用户名");
92103
if (this.userInfo.password == "" || this.userInfo.password.trim() == "")
@@ -107,10 +118,11 @@ export default {
107118
return;
108119
}
109120
this.$store.commit("setUserInfo", x.data);
110-
this.$router.push({ path: "/" });
121+
let _lastPage = this.$store.getters.data().lastPage || '/';
122+
this.$router.push({ path: _lastPage == '/login' ? '/' : _lastPage });
111123
});
112124
}
113-
}
125+
},
114126
};
115127
</script>
116128
<style lang="less" scoped>

Vue.H5/src/components/VolForm.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
</div>
5454
</van-actionsheet>
5555

56-
<div class="ds-from-content">
56+
<div class="vol-from-content">
5757
<div style="display:none;">
5858
<van-field label-class="form-label"
5959
:label-width="120"
@@ -602,7 +602,7 @@ export default {
602602
margin-right: -4px;
603603
}
604604
}
605-
.scroll .ds-from-content {
605+
.scroll .vol-from-content {
606606
// height: calc(100vh - 50px);
607607
// overflow-y: scroll;
608608
}

Vue.H5/src/components/VolHeader.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
@click-right="onClickRight"
99
:right-text="rightText">
1010
<template #right>
11-
<van-icon name="search"
11+
<van-icon v-show="showIcon"
12+
name="search"
1213
size="16" />
1314
</template>
1415
</van-nav-bar>
@@ -20,6 +21,10 @@
2021
import { NavBar, Icon } from "vant";
2122
export default {
2223
props: {
24+
showIcon: {
25+
type: Boolean,
26+
default: true
27+
},
2328
back: {
2429
type: Boolean,
2530
default: true

Vue.H5/src/components/VolVanUploader.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,18 @@ export default {
102102
var forms = new FormData();
103103
let _count = 0;
104104
_files.forEach((file) => {
105-
this.bf = file.name + "压缩前大小:" + (file.size / 1024)
105+
// this.bf = file.name + "压缩前大小:" + (file.size / 1024)
106106
var result = this.compress(file, (data) => {
107107
var _file = this.base64ToBlob(data);
108108
_count++;
109-
this.af = file.name + "压缩后大小:" + (_file.size / 1024)
109+
// this.af = file.name + "压缩后大小:" + (_file.size / 1024)
110110
forms.append("fileInput", _file, file.name);
111111
if (_count == _files.length) {
112112
//"api/App_Expert/Upload"
113113
this.http.post(this.url, forms, true).then(x => {
114-
console.log(x);
114+
if(!x.status){
115+
return this.$toast(x.message)
116+
}
115117
var _urls = _files.map(item => {
116118
return { url: this.http.ipAddress + x.data + item.name };
117119
})
@@ -120,8 +122,6 @@ export default {
120122
}
121123
});
122124
});
123-
124-
// console.log(file)
125125
},
126126
beforeDelete (file, detail) {
127127
this.selfChange = true;

Vue.H5/src/router/index.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Vue from 'vue'
22
import Router from 'vue-router'
33
import store from '@/store'
44
import doc from './doc'
5+
import { Form } from 'vant'
56
const routerPush = Router.prototype.push
67
Router.prototype.push = function push (location) {
78
return routerPush.call(this, location).catch(error => { console.log(error) })
@@ -99,6 +100,21 @@ const router = new Router({
99100
}
100101
}
101102
,
103+
{
104+
path: '/sellOrder',
105+
name: 'SellOrder',
106+
component: () => import('@/views/page/sellOrder/SellOrder.vue'),
107+
meta: {
108+
}
109+
},
110+
{
111+
path: '/sellOrder/detail',
112+
name: 'SellOrder_detail',
113+
component: () => import('@/views/page/sellOrder/detail.vue'),
114+
meta: {
115+
}
116+
}
117+
,
102118
{
103119
path: '/test',
104120
name: 'test',
@@ -113,15 +129,22 @@ const router = new Router({
113129
router.beforeEach((to, from, next) => {
114130
if (to.matched.length == 0) return next({ path: '/404' });
115131
store.dispatch("onLoading", true);
116-
132+
if (store.getters.data().lastPage && from.path != "/login" && to.path == "/login") {
133+
store.getters.data().lastPage = "";
134+
return next({ path: '/' });
135+
}
117136
let navigate = store.getters.data().navigate;
118137
if (navigate && navigate.path.indexOf(to.path) != -1) {
119138
navigate.active = navigate.path.indexOf(to.path);
120139
}
121140

141+
if (to.path == "/login") {
142+
store.getters.data().lastPage = from.path;
143+
}
122144
if ((to.hasOwnProperty('meta') && to.meta.anonymous) || store.getters.isLogin()) {
123145
return next();
124146
}
147+
125148
next({ path: '/login', query: { redirect: Math.random() } });
126149
})
127150

0 commit comments

Comments
 (0)