guifei zhu
2024-11-27 6017f46b762663b9393cdae8422e0de1ed3db218
pages/login/login.vue
@@ -2,7 +2,7 @@
<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">智能中草药干燥设备配套系统</view>
         <view class="margin-top-xs text-white">欢迎使用,请先登录</view>
      </view>
      <u-form labelPosition="left" :model="model" ref="form">
@@ -34,8 +34,8 @@
      data() {
         return {
            model: {
               username: "",
               password: ""
               username: "tongjitang",
               password: "123456"
            },
            rules: {
               'username': {
@@ -59,17 +59,41 @@
         if (account) {
            this.model = account
         }
         let _that = this
         // uni-app客户端获取push客户端标记
         // uni.getPushClientId({
         //    success: (res) => {
         //       let push_clientid = res.cid
         //       _that.model.username  = push_clientid
         //       console.log('客户端推送标识:', push_clientid)
         //    },
         //    fail(err) {
         //       _that.model.username  = err
         //       console.log(err)
         //    }
         // })
         // uni.onPushMessage((res) => {
         //    _that.model.username  = JSON.stringify(res)
         //    console.log("收到推送消息:", res) //监听推送消息
         // })
      },
      computed: {
         cid() {
            return this.$store.getters.getCid; // 使用 getter 获取 cid
         },
      },
      methods: {
         forget() {
            uni.navigateTo({
               url: "/pages/tabBar/demo"
            })
         },
         submit() {
            if (this.model.username.startsWith("http")) {
               uni.setStorageSync('baseurl', this.model.username);
               this.model.username = null
@@ -88,6 +112,7 @@
            this.$api.login(this.model).then((res) => {
               if (res.success) {
                  console.log('request success', res)
                  uni.showToast({
                     title: '登录成功',
@@ -99,6 +124,8 @@
                  uni.setStorageSync('userinfo', res.result.userInfo);
                  uni.setStorageSync('token', res.result.token);
                  uni.switchTab({
                     url: '/pages/tabBar/general'
                  })