doum
2026-04-25 b7d451c91ec40bee70f23b1e2cf6a8797643faef
small-program/shop/pages/login/login.vue
@@ -9,19 +9,13 @@
      <view class="form-wrap">
         <view class="input-row">
            <u-icon name="account" size="30" color="#B8B8B8"></u-icon>
            <input v-model="form.account" class="input-field" type="text" placeholder="请输入账号" placeholder-style="color: #999999;" />
            <input v-model="form.telephone" class="input-field" type="text" placeholder="请输入账号" placeholder-style="color: #999999;" />
         </view>
         <view class="input-divider"></view>
         <view class="input-row password-row">
            <u-icon name="lock" size="30" color="#B8B8B8"></u-icon>
            <input v-model="form.password" class="input-field" password type="text" placeholder="请输入密码" placeholder-style="color: #999999;" />
         </view>
         <view class="input-divider"></view>
         <view class="input-row password-row">
            <u-icon name="phone" size="30" color="#B8B8B8"></u-icon>
            <input v-model="form.telephone" class="input-field" type="number" maxlength="11" placeholder="请输入手机号" placeholder-style="color: #999999;" />
         </view>
         <view class="input-divider"></view>
      </view>
@@ -45,16 +39,51 @@
   export default {
      computed: {
         ...mapState(['openid'])
         ...mapState(['openid', 'userInfo','userType'])
      },
      data() {
         return {
            agreed: false,
            form: {
               account: '',
               password: '',
               telephone: ''
               telephone: '',
               password: ''
            }
         }
      },
      onLoad() {
         // 静默登录
         if (this.userInfo.bindShopId) {
            uni.showLoading({
               title:'登录中...'
            })
            try{
               console.log(this.userType,"============================================")
               this.$u.api.shopSilentLogin({})
                  .then( res => {
                     if (res.code === 200) {
                        this.$store.commit('setUserType', 1)
                        this.$store.commit('setShopToken', res.data.token)
                        // 获取门店信息
                        this.$u.api.getShopInfo({}).then( shopInfoRes => {
                           if (shopInfoRes.code === 200) {
                              this.$store.commit('setShopInfo', shopInfoRes.data)
                           }
                           uni.hideLoading();
                           // setTimeout(() => {
                              uni.reLaunch({
                                 url: '/shop/pages/store-home/store-home'
                              });
                           // }, 1000)
                        })
                     }
                  })
            }catch(e){
               uni.hideLoading()
            }
            setTimeout(() => {
               uni.hideLoading()
            }, 10000)
         }
      },
      methods: {
@@ -66,7 +95,7 @@
               })
               return
            }
            if (!this.form.account) {
            if (!this.form.telephone) {
               uni.showToast({
                  title: '请输入账号',
                  icon: 'none'
@@ -76,13 +105,6 @@
            if (!this.form.password) {
               uni.showToast({
                  title: '请输入密码',
                  icon: 'none'
               })
               return
            }
            if (!this.form.telephone) {
               uni.showToast({
                  title: '请输入手机号',
                  icon: 'none'
               })
               return
@@ -98,11 +120,16 @@
               if (res.code === 200) {
                  this.$store.commit('setUserType', 1)
                  this.$store.commit('setShopToken', res.data.token)
                  // 获取门店信息
                  const shopInfoRes = await this.$u.api.getShopInfo({})
                  if (shopInfoRes.code === 200) {
                     this.$store.commit('setShopInfo', shopInfoRes.data)
                  }
                  uni.showToast({ title: '登录成功', icon: 'success' })
                  setTimeout(() => {
                     uni.switchTab({
                        url: '/pages/shop-index/shop-index'
                     })
                     uni.reLaunch({
                        url: '/shop/pages/store-home/store-home'
                     });
                  }, 1500)
               } else {
                  uni.showToast({