Browse Source

feat(login): 添加测试登录功能并优化登录页面展示

EvilDragon 3 months ago
parent
commit
86bd29b42a

+ 2 - 0
packages/app/src/core/libs/requests.ts

@@ -104,6 +104,8 @@ export const weixinMiniAppLogin = (phoneCode: string, loginCode: string, state:
     loginCode,
     state,
   })
+export const testLogin = (data: { mobile: string; password: string }) =>
+  httpPost('/app-api/member/auth/login2', data)
 export const getMemberUserInfo = () => httpGet<any>('/app-api/member/user/get')
 export const updateMemberUserInfo = (data = {}) => httpPut<any>('/app-api/member/user/update', data)
 export const getByDictType = (

+ 6 - 5
packages/app/src/pages/common/components/coupons-selector.vue

@@ -23,11 +23,12 @@ const tab = ref(0)
 const request = ref()
 const { data: coupons, run: setCoupons } = useRequest(() => request.value(), { initialData: [] })
 const handleSelect = (coupon: Coupon) => {
-  if (modelValue.value.map(({ id }) => id).includes(coupon.id)) {
-    modelValue.value = modelValue.value.filter(({ id }) => id !== coupon.id)
-  } else {
-    modelValue.value = [...modelValue.value, coupon]
-  }
+  // if (modelValue.value.map(({ id }) => id).includes(coupon.id)) {
+  //   modelValue.value = modelValue.value.filter(({ id }) => id !== coupon.id)
+  // } else {
+  //   modelValue.value = [...modelValue.value, coupon]
+  // }
+  modelValue.value = [coupon]
   emits('close')
 }
 watch(

+ 42 - 20
packages/app/src/pages/login/index.vue

@@ -3,7 +3,7 @@ style:
   navigationBarTitleText: 登录
 </route>
 <script lang="ts" setup>
-import { weixinMiniAppLogin } from '../../core/libs/requests'
+import { testLogin, weixinMiniAppLogin } from '../../core/libs/requests'
 import { logo } from '../../core/libs/svgs'
 import { useUserStore } from '../../store'
 
@@ -11,6 +11,8 @@ const userStore = useUserStore()
 const { setUserInfo } = userStore
 const loginCode = ref('')
 const phoneCode = ref('')
+const loginType = ref()
+const mobile = ref('')
 const getPhoneNumber = async ({ detail: { code: phoneCode } }) => {
   const { code } = await uni.login()
   console.log(code, phoneCode)
@@ -32,6 +34,16 @@ const getTestCode = async ({ detail }) => {
   const { code } = await uni.login()
   loginCode.value = code
 }
+const handleTestLogin = async () => {
+  // console.log('');
+  const { data } = await testLogin({ mobile: mobile.value, password: 'aaa123456' })
+  console.log(data)
+}
+onLoad(async (query: { type?: 'test' }) => {
+  if (query.type) {
+    loginType.value = query.type
+  }
+})
 </script>
 <template>
   <div class="flex-grow flex flex-col items-center justify-around px-3.5">
@@ -42,25 +54,35 @@ const getTestCode = async ({ detail }) => {
       </div>
     </div>
     <div class="w-full">
-      <button
-        type="primary"
-        size="large"
-        :style="{
-          backgroundColor: 'black',
-        }"
-        open-type="getPhoneNumber"
-        @getphonenumber="getPhoneNumber"
-      >
-        手机号一键登录
-      </button>
-      <div class="w-[318px] mt-8">
-        <span class="text-black/40 text-xs font-normal font-['PingFang_SC'] leading-tight">
-          如您点击授权,您将同意并授权
-        </span>
-        <span class="text-[#0cbe7c] text-xs font-normal font-['PingFang_SC'] leading-tight">
-          《筑巢荟用户服务协议》、《隐私政策》、《注册协议》
-        </span>
-      </div>
+      <template v-if="loginType === 'test'">
+        <div class="flex flex-col gap-4">
+          <wd-input placeholder="请输入手机号" v-model="mobile"></wd-input>
+          <div>
+            <wd-button block @click="handleTestLogin">手机号测试登录</wd-button>
+          </div>
+        </div>
+      </template>
+      <template v-else>
+        <button
+          type="primary"
+          size="large"
+          :style="{
+            backgroundColor: 'black',
+          }"
+          open-type="getPhoneNumber"
+          @getphonenumber="getPhoneNumber"
+        >
+          手机号一键登录
+        </button>
+        <div class="w-[318px] mt-8">
+          <span class="text-black/40 text-xs font-normal font-['PingFang_SC'] leading-tight">
+            如您点击授权,您将同意并授权
+          </span>
+          <span class="text-[#0cbe7c] text-xs font-normal font-['PingFang_SC'] leading-tight">
+            《筑巢荟用户服务协议》、《隐私政策》、《注册协议》
+          </span>
+        </div>
+      </template>
     </div>
   </div>
   <!-- <view class="content">