| | |
| | | <template>
|
| | | <view class="contaier">
|
| | | <view class="top-bg">
|
| | | <view class="text-white text-bold text-xxxl">智能中草药干燥设备配套系统</view>
|
| | | <view class="text-white text-bold text-xxxl">兰浦<text @longpress="showModal">智能</text>干燥</view>
|
| | | <view class="margin-top-xs text-white">欢迎使用,请先登录</view>
|
| | | </view>
|
| | | <u-form labelPosition="left" :model="model" ref="form">
|
| | |
| | | <view class="padding margin-top-xs">
|
| | | <button @click="submit" class="cu-btn block round bg-login-zl margin-tb-sm lg">立即登录</button>
|
| | | <view class="text-gray flex justify-between padding-lr-sm">
|
| | | <text>注册账号</text>
|
| | | <text>忘记密码</text>
|
| | | <!-- <text @click="switchMode">局域网模式</text> -->
|
| | | <!-- <text>忘记密码</text> -->
|
| | | </view>
|
| | | </view>
|
| | | </u-form>
|
| | |
|
| | | <u-modal :show="show" title="提示" @confirm="handleSwitchMode">
|
| | | <view class="slot-content">
|
| | | <u-input v-model="pass" style="width: 100%;" placeholder="请输入管理员密码" border="surround" password
|
| | | clearable></u-input>
|
| | | </view>
|
| | | </u-modal>
|
| | |
|
| | | </view>
|
| | | </template>
|
| | | <script>
|
| | | export default {
|
| | | data() {
|
| | | return {
|
| | | show: false,
|
| | | pass: "",
|
| | | model: {
|
| | | username: "",
|
| | | password: ""
|
| | |
| | |
|
| | | };
|
| | | },
|
| | |
|
| | | onLoad() {
|
| | | const account = uni.getStorageSync('account');
|
| | | if (account) {
|
| | | this.model = account
|
| | | }
|
| | |
|
| | | },
|
| | | mounted() {
|
| | | setTimeout(() => {
|
| | | //this.model.username = this.clientPushId
|
| | | }, 1000)
|
| | | },
|
| | | computed: {
|
| | | clientPushId() {
|
| | | return this.$store.getters.getClientPushId;
|
| | |
|
| | | },
|
| | | },
|
| | | methods: {
|
| | | forget() {
|
| | | showModal() {
|
| | | this.pass = ""
|
| | | this.show = true
|
| | | },
|
| | | handleSwitchMode() {
|
| | | this.show = false
|
| | | if (this.pass === 'lanbaoit') {
|
| | | this.switchMode()
|
| | | }
|
| | | },
|
| | | switchMode() {
|
| | | uni.navigateTo({
|
| | | url: "/pages/tabBar/demo"
|
| | | url: "/packageA/pages/login/switchMode"
|
| | | })
|
| | | },
|
| | | forget() {
|
| | | |
| | | },
|
| | | submit() {
|
| | |
|
| | | if (this.model.username.startsWith("http")) {
|
| | | uni.setStorageSync('baseurl', this.model.username);
|
| | | this.model.username = null
|
| | | uni.$u.toast('配置baseUrl成功,请退出程序重新启动~')
|
| | | return false;
|
| | | const mode = uni.getStorageSync('mode');
|
| | | //首次登录没有配置,默认为云服务模式
|
| | | if (!mode) {
|
| | | uni.setStorageSync('mode', 'cloud');
|
| | | }
|
| | | const curMode = uni.getStorageSync('mode');
|
| | |
|
| | | getApp().globalData.mode = curMode;
|
| | |
|
| | |
|
| | |
|
| | | this.$refs.form.validate().then(res => {
|
| | | this.login()
|
| | |
| | | login() {
|
| | | this.$api.login(this.model).then((res) => {
|
| | | if (res.success) {
|
| | |
|
| | | console.log('request success', res)
|
| | | uni.showToast({
|
| | | title: '登录成功',
|
| | | icon: 'success',
|
| | | mask: true
|
| | | });
|
| | |
|
| | | //缓存信息
|
| | | uni.setStorageSync('account', this.model);
|
| | | uni.setStorageSync('userinfo', res.result.userInfo);
|
| | | uni.setStorageSync('token', res.result.token);
|
| | |
| | | console.log('request fail', err);
|
| | | })
|
| | | },
|
| | | onReset(e) {
|
| | | console.log(e)
|
| | | }
|
| | |
|
| | | },
|
| | | onReady() {
|
| | | //onReady 为uni-app支持的生命周期之一
|