From 1f4e7d0f73a73e7350cf5a1df279d5f30904c5d5 Mon Sep 17 00:00:00 2001 From: jiangping <jp@doumee.com> Date: 星期三, 06 十二月 2023 08:41:32 +0800 Subject: [PATCH] bug --- h5_standard/src/views/wxLogin.vue | 69 ++++++++++++++++++++++++++++++++-- 1 files changed, 65 insertions(+), 4 deletions(-) diff --git a/h5_standard/src/views/wxLogin.vue b/h5_standard/src/views/wxLogin.vue index 44af9fb..bfe84b5 100644 --- a/h5_standard/src/views/wxLogin.vue +++ b/h5_standard/src/views/wxLogin.vue @@ -7,26 +7,86 @@ <div class="wx_login_list"> <div class="wx_login_list_item"> <img src="@/assets/icon/login_ic_code@2x.png" alt="" /> - <input type="text" placeholder="浼佷笟浠g爜" /> + <input type="text" v-model="from.companyId" placeholder="浼佷笟浠g爜" /> </div> <div class="wx_login_list_item"> <img src="@/assets/icon/login_ic_phone@2x.png" alt="" /> - <input type="text" placeholder="鎵嬫満鍙�" /> + <input type="text" maxlength="11" v-model="from.username" placeholder="鎵嬫満鍙�" /> </div> <div class="wx_login_list_item"> <img src="@/assets/icon/login_ic_password@2x.png" alt="" /> - <input type="text" placeholder="瀵嗙爜" /> + <input type="password" v-model="from.password" placeholder="瀵嗙爜" /> </div> </div> <div class="wx_login_footer"> - <div class="wx_login_footer_btn">绔嬪嵆鐧诲綍</div> + <div class="wx_login_footer_btn" @click="login">绔嬪嵆鐧诲綍</div> </div> </div> </div> </template> <script setup lang="ts"> +import { onMounted, reactive } from 'vue'; +import { useRoute, useRouter } from 'vue-router'; +import { useStore } from 'vuex'; +import { wxLogin, wxAccountLogin, getUserInfo } from '@/apis/index'; +import { Toast } from 'vant'; +const route = useRoute() +const router = useRouter() +const store = useStore() + +let from: any = reactive({ + openid: '', + unionid: '', + companyId: '', + username: '', + password: '' +}) + +const login = async () => { + // if (!from.openid) return Toast('openid涓嶈兘涓虹┖') + // if (!from.unionid) return Toast('unionid涓嶈兘涓虹┖') + if (!from.companyId) return Toast('浼佷笟浠g爜涓嶈兘涓虹┖') + if (!from.username) return Toast('鎵嬫満鍙蜂笉鑳戒负绌�') + if (!from.password) return Toast('瀵嗙爜涓嶈兘涓虹┖') + Toast.loading({ + message: '鐧诲綍涓�...', + forbidClick: true + }); + let res = await wxAccountLogin(from) + if (res.code === 200) { + let info = await getUserInfo() + if (info.code === 200) { + await store.commit('setEntrance', 'WX') + await store.commit('setUserInfo', info.data) + await store.dispatch('getMenuList', 2) + await router.replace('/workbench') + } + } + Toast.clear(); +} + +onMounted(() => { + wxLogin({ code: route.query.code }) + .then(async (res) => { + if (res.code === 200) { + // 鍏嶇櫥褰曪紝鐩存帴璺抽椤� + if (res.data.loginStatus == 0) { + let info = await getUserInfo() + if (info.code === 200) { + await store.commit('setEntrance', 'WX') + await store.commit('setUserInfo', info.data) + await store.dispatch('getMenuList', 2) + await router.replace('/workbench') + } + } else { + from.openid = res.data.openid + from.unionid = res.data.unionid + } + } + }) +}) </script> <style lang="scss" scoped> @@ -97,6 +157,7 @@ input { flex: 1; height: 100%; + padding: 0 !important; font-size: 30px; font-family: PingFangSC-Regular, PingFang SC; font-weight: 400; -- Gitblit v1.9.3