Commit 0c91ba88 authored by 罗超's avatar 罗超

1

parent c2d9530e
......@@ -3,8 +3,12 @@ import {
} from 'vue'
import App from './App.vue'
import Toast from "./wxcomponents/vant/toast/toast";
import Dialog from "./wxcomponents/vant/dialog/dialog";
import plugin from './utils/plugin'
let app = createApp(App)
app.provide("$toast", Toast)
app.provide("$dialog", Dialog)
app.use(plugin)
// app.config.globalProperties.$toast = Toast;//全局挂载方法
// app.component('v-MessageBox',MessageBox);//全局注册组件
app.mount()
......@@ -90,7 +90,6 @@ import {
} from "vue";
import { getStudentLeaveList, invalidReceiptInfo } from "../../api/index";
import Loadmore from "../../components/loadmore.vue";
import Dialog from "../../wxcomponents/vant/dialog/dialog";
export default {
components: {
Loadmore,
......@@ -98,6 +97,7 @@ export default {
setup() {
let userInfo = uni.getStorageSync("userInfo");
let Toast = inject("$toast");
let Dialog = inject("$dialog");
let data = reactive({
data: [],
pageState: "more",
......
......@@ -2,9 +2,11 @@
<view :style="{ 'padding-top': `${statusBarHeight}px` }">
<view style="height: 100rpx"></view>
<van-nav-bar fixed>
<van-icon name="cross" slot="left" size="30rpx" @click="back" />
<template #left>
<van-icon name="cross" size="30rpx" @click="back" />
</template>
<template #title>
<view
slot="title"
class="flex"
style="justify-content: center"
@click="start"
......@@ -23,6 +25,7 @@
ref="countdown"
/>
</view>
</template>
</van-nav-bar>
<view class="exam-con">
<Sub1 />
......
......@@ -131,6 +131,7 @@ import {
} from "vue";
import { getIndexInfo } from "../../api/index";
import { getSystemInfo, desensitization } from "../../utils/index";
import request from "../../utils/request.js";
export default {
name: "",
props: {},
......@@ -203,7 +204,6 @@ export default {
},
],
});
let methods = {
jumpPage(url) {
uni.navigateTo({
......@@ -232,6 +232,7 @@ export default {
};
onMounted(() => {
console.log(process.env);
getSystemInfo((res) => {
data.statusBarHeight = res.statusBarHeight;
});
......@@ -250,7 +251,10 @@ export default {
};
},
onLoad() {
console.log("index load");
// let { ctx } = getCurrentInstance();
// ctx.$test("首页");
// this.$test("首页");
// console.log(256, this);
uni.setNavigationBarTitle({
title: "首页",
});
......
......@@ -6,7 +6,7 @@
如果需要解构 prop,可以通过使用 setup 函数中的 toRefs 来完成此操作
* // ref和reactive的区别: ref()传入的是js的基本数据类型; reactive()中传入的是object普通对象,------------reactive对象不能直接赋值--------------
*@reactive:处理的是对象的双向绑定, 对象不能被***解构或展开***,一旦被解构或者展开,返回的值将失去响应式,需用...toRef()
* 没有this 通过 @getCurrentInstance,获取当前页面实例,使用const { ctx,proxy } = getCurrentInstance(); ctx或proxy.$挂载的方法
* 没有this 通过 @getCurrentInstance,获取当前页面实例,使用const { ctx,proxy,refs } = getCurrentInstance(); ctx或proxy.$挂载的方法
*/
import {
ref,
......@@ -37,11 +37,19 @@ export default {
watch(name, (newVal, oldVal) => {
console.log(51, newVal);
});
//监听对象的某一项
watch(
() => msg.Account,
(val) => {
console.log(val);
}
);
// computed 计算属性 : 适合计算一个属性, 并且绑定.
// computed将监听它里面所有的变量, 里面变量发生变化就会触发结果重新计算
// 计算出来的结果是只读的, 所以fullName是不能被改变的
const fullName = computed(() => name.firstname + name.lastname);
// const fullName = computed(() => { return name.firstname + name.lastname});
// 高级用法: 可以修改值
const fullName2 = computed({
get: () => name.firstname + name.lastname,
......@@ -57,5 +65,15 @@ export default {
fullName2,
};
},
onLoad() {
//这里有this
let { ctx } = getCurrentInstance();
ctx.$test("首页");
this.$test("首页");
console.log(69, this);
uni.setNavigationBarTitle({
title: "首页",
});
},
};
</script>
<template>
<view class="">
<van-nav-bar>
<van-icon slot="left" name="cross" size="50rpx" @click="back" />
</van-nav-bar>
<view class="top">
登录
<van-image
width="193rpx"
height="242rpx"
fit="cover"
class="yuqi"
src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/yuqi.png"
/>
</view>
<view class="main">
<van-cell-group>
<van-field
:value="Account"
clearable
placeholder="请输入用户名"
clearable
@input="usernameInput"
>
<i class="iconfont icon-user2 left-iconfont" slot="left-icon"></i>
</van-field>
<van-field
:value="Password"
password
placeholder="请输入密码"
clearable
@input="passwordInput"
>
<i class="iconfont icon-password left-iconfont" slot="left-icon"></i>
</van-field>
</van-cell-group>
</view>
<van-button block custom-class="loginBtn" @click="login">登录</van-button>
<view class="auth" @click="authLogin"> 授权手机号一键登录 </view>
<van-toast id="van-toast" />
</view>
<view class="">
<van-nav-bar>
<van-icon slot="left" name="cross" size="50rpx" @click="back" />
</van-nav-bar>
<view class="top">
登录
<van-image width="193rpx" height="242rpx" fit="cover" class="yuqi"
src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/educationStu/yuqi.png" />
</view>
<view class="main">
<van-cell-group>
<van-field :value="Account" clearable placeholder="请输入用户名" clearable @input="usernameInput">
<i class="iconfont icon-user2 left-iconfont" slot="left-icon"></i>
</van-field>
<van-field :value="Password" password placeholder="请输入密码" clearable @input="passwordInput">
<i class="iconfont icon-password left-iconfont" slot="left-icon"></i>
</van-field>
</van-cell-group>
</view>
<van-button block custom-class="loginBtn" @click="login">登录</van-button>
<view class="auth" @click="authLogin"> 授权手机号一键登录 </view>
<van-toast id="van-toast" />
</view>
</template>
<script>
import {
ref,
reactive,
toRefs,
toRef,
getCurrentInstance,
watch,
computed,
onMounted,
inject,
} from "vue";
// import Toast from "../../wxcomponents/vant/toast/toast";
import { login } from "../../api/index";
export default {
setup(props, context) {
let Toast = inject("$toast");
let msg = reactive({
Account: "18981921485",
Password: "123456",
});
let methods = {
usernameInput(val) {
msg.Account = val.detail;
console.log(74, msg);
},
passwordInput(val) {
msg.Password = val.detail;
},
back() {
uni.navigateBack();
},
jumpPage() {
uni.navigateTo({
url: "/pages/index/index",
});
clearTimeout();
},
authLogin() {
// that.getUserProfile();
},
// getUserProfile() {
// //新的获取用户资料
// wx.getUserProfile({
// desc: "用于完善资料", // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
// success: (info) => {
// console.log(83, info);
// that.getUserInfo(info);
// },
// fail: () => {
// uni.showToast({
// title: "微信登录授权失败",
// icon: "none",
// });
// },
// });
// },
// getUserInfo(info) {
// uni.getProvider({
// service: "oauth",
// success: function (res) {
// if (~res.provider.indexOf("weixin")) {
// uni.login({
// provider: "weixin",
// success: (_res) => {
// console.log(107, _res);
// that.getunionid(_res.code);
// },
// fail: () => {
// uni.showToast({
// title: "微信登录授权失败",
// icon: "none",
// });
// },
// });
// } else {
// uni.showToast({
// title: "请先安装微信或升级版本",
// icon: "none",
// });
// }
// },
// });
// },
async login() {
let res = await login(msg);
if (res) {
res.Data.Account = msg.Account;
uni.setStorageSync("userInfo", res.Data);
Toast.success("登录成功");
setTimeout(() => {
that.jumpPage();
}, 1000);
}
},
// getunionid(code) {
// let appid = "wxaa108410092fd276";
// let secret = "31cd99f321612f95b0006905032de7f0";
// uni.request({
// url: `https://api.weixin.qq.com/sns/jscode2session?appid=${appid}&secret=${secret}&js_code=${code}&grant_type=authorization_code`,
// success: (res) => {
// console.log(150, res);
// },
// fail: (err) => {
// console.log(154, err);
// },
// });
// },
};
onMounted(() => {});
let that = methods;
return {
...toRefs(msg),
...methods,
};
},
};
import {
ref,
reactive,
toRefs,
toRef,
getCurrentInstance,
watch,
computed,
onMounted,
inject,
} from "vue";
// import Toast from "../../wxcomponents/vant/toast/toast";
import {
login
} from "../../api/index";
export default {
setup(props, context) {
let Toast = inject("$toast");
let msg = reactive({
Account: "18981921485",
Password: "123456",
});
let methods = {
usernameInput(val) {
msg.Account = val.detail;
},
passwordInput(val) {
msg.Password = val.detail;
},
back() {
uni.navigateBack();
},
jumpPage() {
uni.navigateTo({
url: "/pages/index/index",
});
clearTimeout();
},
authLogin() {
// that.getUserProfile();
},
// getUserProfile() {
// //新的获取用户资料
// wx.getUserProfile({
// desc: "用于完善资料", // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
// success: (info) => {
// console.log(83, info);
// that.getUserInfo(info);
// },
// fail: () => {
// uni.showToast({
// title: "微信登录授权失败",
// icon: "none",
// });
// },
// });
// },
// getUserInfo(info) {
// uni.getProvider({
// service: "oauth",
// success: function (res) {
// if (~res.provider.indexOf("weixin")) {
// uni.login({
// provider: "weixin",
// success: (_res) => {
// console.log(107, _res);
// that.getunionid(_res.code);
// },
// fail: () => {
// uni.showToast({
// title: "微信登录授权失败",
// icon: "none",
// });
// },
// });
// } else {
// uni.showToast({
// title: "请先安装微信或升级版本",
// icon: "none",
// });
// }
// },
// });
// },
async login() {
let res = await login(msg);
if (res) {
res.Data.Account = msg.Account;
uni.setStorageSync("userInfo", res.Data);
Toast.success("登录成功");
setTimeout(() => {
that.jumpPage();
}, 1000);
}
},
// getunionid(code) {
// let appid = "wxaa108410092fd276";
// let secret = "31cd99f321612f95b0006905032de7f0";
// uni.request({
// url: `https://api.weixin.qq.com/sns/jscode2session?appid=${appid}&secret=${secret}&js_code=${code}&grant_type=authorization_code`,
// success: (res) => {
// console.log(150, res);
// },
// fail: (err) => {
// console.log(154, err);
// },
// });
// },
};
onMounted(() => {});
let that = methods;
return {
...toRefs(msg),
...methods,
};
},
};
</script>
<style scoped>
.top {
height: 242rpx;
box-sizing: border-box;
padding-left: 40rpx;
padding-top: 70rpx;
font-size: 50rpx;
font-family: PingFang SC;
font-weight: bold;
color: #0f1b35;
position: relative;
margin-bottom: 20rpx;
}
.yuqi {
position: absolute;
top: 0;
right: 1rpx;
}
.main {
height: 250rpx;
box-sizing: border-box;
padding: 0 40rpx;
margin-bottom: 165rpx;
}
/deep/.van-cell {
height: 124rpx;
padding-top: 50rpx;
}
/deep/.loginBtn {
width: 600rpx;
height: 90rpx;
background-color: #00acf9;
border-radius: 12rpx;
margin: 0 auto;
font-size: 32rpx;
font-family: PingFang SC;
font-weight: 500;
color: #ffffff;
}
.auth {
text-align: center;
font-size: 26rpx;
font-family: PingFang SC;
font-weight: 500;
color: #00acf9;
margin-top: 30rpx;
}
.left-iconfont {
margin-right: 20rpx;
font-size: 30rpx;
color: #111111;
}
.top {
height: 242rpx;
box-sizing: border-box;
padding-left: 40rpx;
padding-top: 70rpx;
font-size: 50rpx;
font-family: PingFang SC;
font-weight: bold;
color: #0f1b35;
position: relative;
margin-bottom: 20rpx;
}
.yuqi {
position: absolute;
top: 0;
right: 1rpx;
}
.main {
height: 250rpx;
box-sizing: border-box;
padding: 0 40rpx;
margin-bottom: 165rpx;
}
/deep/.van-cell {
height: 124rpx;
padding-top: 50rpx;
}
/deep/.loginBtn {
width: 600rpx;
height: 90rpx;
background-color: #00acf9;
border-radius: 12rpx;
margin: 0 auto;
font-size: 32rpx;
font-family: PingFang SC;
font-weight: 500;
color: #ffffff;
}
.auth {
text-align: center;
font-size: 26rpx;
font-family: PingFang SC;
font-weight: 500;
color: #00acf9;
margin-top: 30rpx;
}
.left-iconfont {
margin-right: 20rpx;
font-size: 30rpx;
color: #111111;
}
</style>
*{
/* *{
font-family: PingFang SC;
box-sizing: border-box;
} */
:global(*) {
font-family: PingFang SC;
box-sizing: border-box;
}
.flex {
......
let host = 'http://192.168.20.17:8017/api'
if (process.env.NODE_ENV === "development") {
host = 'http://192.168.20.17:8017/api'
} else {
host = 'http://192.168.20.17:8017/api'
}
import Toast from '../wxcomponents/vant/toast/toast';
let token = uni.getStorageSync('userInfo').Token;
let request = (param) => {
......@@ -28,7 +33,5 @@ let request = (param) => {
}
});
})
}
export default request
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment