qiyunfeng-create
3 天以前 b15a997e95d715c41df3a76aecbf58ec1141ab53
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<template>
  <div class="pageHeader">
    <div class="headerBox">
      <div class="logoBox">
        <el-image :src="logo" class="logo" @click="goHome" style="cursor: pointer" />
        <div class="titleName"><img :src="titleName" /></div>
      </div>
      <div class="inputBox f1">
        <div class="signIn">
          <p v-if="!userStore.userInfo?.name" class="signInBox">
            <span @click="loginBtn">注册</span>
            <span>|</span>
            <span @click="signupBtn">登录</span>
          </p>
          <!-- 用户名 -->
          <el-dropdown trigger="click" v-else>
            <p class="el-dropdown-link signInBox">
              <span>{{ userStore.userInfo?.name }}</span>
              <el-icon class="el-icon--right">
                <CaretBottom />
              </el-icon>
            </p>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item @click="router.push('/personalCenter')"
                  >个人中心</el-dropdown-item
                >
                <el-dropdown-item @click="logOut">退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
      </div>
    </div>
  </div>
  <login ref="loginRef"></login>
  <!-- 导航栏 -->
 
  <!-- 温馨提示弹窗 -->
  <el-dialog v-model="tipsDialogState" width="420" align-center class="tipsDialog">
    <template #title>温馨提示</template>
    <el-icon color="#e6a23c" size="24">
      <WarningFilled />
    </el-icon>
    <p>
      如果您已使用【京师智教扫一扫】或【云上书房】 微信注册过,请使用微信扫码登录;如果您已在【
      京师智教】PC端注册过,请使用手机号登录!继续注册将创建全新账户!
    </p>
    <template #footer>
      <el-button @click="goPhoneSignup">手机号登录</el-button>
      <el-button @click="goWechatSignUp">微信登录</el-button>
      <el-button type="primary" @click="goLogin">继续注册</el-button>
    </template>
  </el-dialog>
</template>
 
<script setup lang="ts">
import login from '@/layout/components/login.vue'
import { onMounted, ref, watchEffect, inject, watch } from 'vue'
import { ElMessage, ElMessageBox, type FormInstance } from 'element-plus'
import logo from '@/assets/images/header/logo.png'
import titleName from '@/assets/images/header/titleName.png'
import { useRouter } from 'vue-router'
import { useUserStore, applyBookStore } from '@/store'
const loginRef = ref()
const router = useRouter()
const userStore = useUserStore()
const applyBook = applyBookStore()
const MG = inject('MG')
const config = inject('config')
const tipsDialogState = ref<boolean>(false) // 温馨提示弹窗状态
const wechatTipsState = ref<boolean>(false)
const localData = ref(localStorage.getItem('jsek-token'))
onMounted(() => {
  // 判断是否微信扫码登录
  var url = window.location.href
  if (url.indexOf('WeChatScanningCodeLogin') > -1) {
    var querys = url.substring(url.indexOf('?') + 1).split('&')
    var result = {}
    for (var i = 0; i < querys.length; i++) {
      var temp = querys[i].split('=')
      if (temp.length < 2) {
        result[temp[0]] = ''
      } else {
        result[temp[0]] = temp[1]
      }
    }
    if (result && result.code) {
      MG.identity
        .loginByWeChatOpenCode({
          code: result.code,
          appRefCode: config.appRefCode,
          platform: 'PCWeb'
        })
        .then((res) => {
          if (res && res.status == 'Ok') {
            userStore.setToken(res.token)
            loginRef.value.getUserInfo()
            MG.app.creatUserBehavior({
              refCode:"sign"
            }).then(res => {
              if(res){
              console.log("今日已积分")
              }
            });
          }
        })
    }
  }
})
watchEffect(() => {
  localData.value = localStorage.getItem('jsek-token') || '0'
})
 
// 注册按钮
const loginBtn = () => {
  tipsDialogState.value = true
}
// 登录按钮
const signupBtn = () => {
  loginRef.value.logIn()
}
 
// 继续注册
const goLogin = () => {
  tipsDialogState.value = false
  loginRef.value.signUp()
}
// 去微信登录
const goWechatSignUp = () => {
  tipsDialogState.value = false
  // loginRef.value.logIn()
  loginRef.value.setWechatTipsState()
}
// 去手机号登录
const goPhoneSignup = () => {
  tipsDialogState.value = false
  loginRef.value.logIn()
  loginRef.value.changeSignUp('authSignUp')
}
// 退出登录
const logOut = () => {
  router.push('/home')
  userStore.delteUserInfo()
  applyBook.emptyBookList()
  sessionStorage.removeItem('cartNumber')
  localStorage.removeItem('alreadyElectronicBook')
  localStorage.removeItem('alreadyPaperBook')
  ElMessage.success('退出成功')
}
 
// logo首页定向
const goHome = () => {
  router.push('/home')
}
 
</script>
 
<style lang="less">
.tipsDialog {
  .el-dialog__header {
    font-size: 18px;
  }
 
  .el-dialog__body {
    display: flex;
    align-items: center;
 
    p {
      margin-left: 10px;
      line-height: 24px;
    }
  }
}
</style>
<style lang="less" scoped>
.pageHeader {
  width: 100%;
  background: #fff;
  // border-bottom:1px solid #C0C0C0;
}
 
.headerBox {
  width: 1200px;
  margin: 0 auto;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  .logoBox {
    display: flex;
    align-items: center;
    .titleName {
      font-size: 24px;
      padding: 0 10px;
      margin-left: 15px;
      border-left: 1px solid #C0C0C0;
      color:#181818;
      font-family: Microsoft YaHei, Microsoft YaHei;
      font-weight: 400;
    }
    /deep/.el-image__inner {
      height: 48px;
      border: 0;
      padding: 0;
    }
  }
}
 
/** 验证码图片 */
.imgCode {
  height: 40px;
  margin-top: 5px;
}
 
/** 看不清换一张 */
.linkHight {
  height: 20px;
 
  /deep/ .el-link__inner {
    height: 100%;
  }
}
 
/** header登录注册文字 */
.signIn {
  height: 40px;
  width: 95px;
  min-width: 90px;
  text-align: right;
  margin-left: 80px;
  font-weight: 400;
  justify-content: space-around;
  color: #000;
  font-size: 14px;
 
  span:first-child,
  span:last-child {
    cursor: pointer;
  }
 
  .signInBox {
    height: 100%;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
 
  span {
    padding: 5px;
  }
 
  .el-dropdown {
    width: 100%;
    height: 100%;
 
    span {
      height: 40px;
      line-height: 40px;
      padding: 0;
      display: block;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }
}
 
.selectPhone {
  background: #fff;
}
 
.el-select {
  width: 100px;
  height: 40px;
  color: red;
 
  /deep/ .select-trigger {
    height: 100%;
 
    .el-input--suffix {
      height: 100%;
      background-color: #fff;
    }
  }
}
</style>