|
@@ -16,12 +16,31 @@
|
|
|
<view v-else>
|
|
<view v-else>
|
|
|
<password :form="formData" />
|
|
<password :form="formData" />
|
|
|
</view>
|
|
</view>
|
|
|
- <cl-button :pt="{ className: '!h-[45px] !rounded-full w-[200px] mx-auto' }" :loading="loading" @tap="toLogin">
|
|
|
|
|
- 登录
|
|
|
|
|
- </cl-button>
|
|
|
|
|
|
|
+ <view class="flex flex-row items-center justify-center gap-4">
|
|
|
|
|
+ <cl-button :pt="{ className: '!h-[45px] !rounded-full w-[140px] mx-auto' }" :loading="loading"
|
|
|
|
|
+ @tap="toLogin">
|
|
|
|
|
+ 登录
|
|
|
|
|
+ </cl-button>
|
|
|
|
|
+ <cl-button type="success" :pt="{ className: '!h-[45px] !rounded-full w-[140px] mx-auto ' }"
|
|
|
|
|
+ :loading="loading" @tap="toWechatLogin">
|
|
|
|
|
+ <view class="flex flex-row items-center justify-center gap-2">
|
|
|
|
|
+ <cl-image src="https://oss.xiaoxiongcode.com/static/个人中心/微信.png" mode="heightFix" height="20px"
|
|
|
|
|
+ width="auto"></cl-image> 登录
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </cl-button>
|
|
|
|
|
+ </view>
|
|
|
</cl-form>
|
|
</cl-form>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
+ <cl-action-sheet ref="actionSheetRef">
|
|
|
|
|
+ <template #prepend>
|
|
|
|
|
+ <view class=" mb-3 font-bold text-center">
|
|
|
|
|
+ <cl-text :size="20" color="#666">
|
|
|
|
|
+ 选择登录账号
|
|
|
|
|
+ </cl-text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </cl-action-sheet>
|
|
|
</cl-page>
|
|
</cl-page>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
@@ -33,7 +52,11 @@ import password from './components/password.uvue';
|
|
|
import { ref } from 'vue'
|
|
import { ref } from 'vue'
|
|
|
import type { ClTabsItem } from "@/uni_modules/cool-ui";
|
|
import type { ClTabsItem } from "@/uni_modules/cool-ui";
|
|
|
import { encryptPassword, user, router } from '@/.cool';
|
|
import { encryptPassword, user, router } from '@/.cool';
|
|
|
-import { loginApi } from "@/services/user";
|
|
|
|
|
|
|
+import { loginApi, wechatLogin } from "@/services/user";
|
|
|
|
|
+import type { ClActionSheetOptions } from "@/uni_modules/cool-ui";
|
|
|
|
|
+
|
|
|
|
|
+const actionSheetRef = ref<ClActionSheetComponentPublicInstance | null>(null);
|
|
|
|
|
+
|
|
|
const val = ref('quickly_login')
|
|
const val = ref('quickly_login')
|
|
|
const list: ClTabsItem[] = [
|
|
const list: ClTabsItem[] = [
|
|
|
{
|
|
{
|
|
@@ -46,8 +69,8 @@ const list: ClTabsItem[] = [
|
|
|
},
|
|
},
|
|
|
]
|
|
]
|
|
|
const formData = ref<LoginForm>({
|
|
const formData = ref<LoginForm>({
|
|
|
- username: 'xiongchao',
|
|
|
|
|
- password: '123456',
|
|
|
|
|
|
|
+ username: '',
|
|
|
|
|
+ password: '',
|
|
|
randomStr: 0,
|
|
randomStr: 0,
|
|
|
grant_type: 'quickly_login',
|
|
grant_type: 'quickly_login',
|
|
|
scope: 'server',
|
|
scope: 'server',
|
|
@@ -84,6 +107,45 @@ function toLogin() {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+function toWechatLogin() {
|
|
|
|
|
+ uni.login({
|
|
|
|
|
+ provider: 'weixin',
|
|
|
|
|
+ success(res) {
|
|
|
|
|
+ wechatLogin({
|
|
|
|
|
+ code: res.code,
|
|
|
|
|
+ }).then(res => {
|
|
|
|
|
+ console.log(res);
|
|
|
|
|
+ const list = res.map(item => ({
|
|
|
|
|
+ label: item,
|
|
|
|
|
+ icon: "user-line",
|
|
|
|
|
+ callback() {
|
|
|
|
|
+ handleSelect(item)
|
|
|
|
|
+ }
|
|
|
|
|
+ }))
|
|
|
|
|
+ actionSheetRef.value!.open({
|
|
|
|
|
+ list: list
|
|
|
|
|
+ } as ClActionSheetOptions);
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+function handleSelect(item: string) {
|
|
|
|
|
+ formData.value.username = item
|
|
|
|
|
+ formData.value.password = 'quickly_login'
|
|
|
|
|
+ formData.value.grant_type = 'quickly_login'
|
|
|
|
|
+ formData.value.loginType = 88
|
|
|
|
|
+ loginApi({
|
|
|
|
|
+ ...formData.value,
|
|
|
|
|
+ }).then(res => {
|
|
|
|
|
+ user.setToken(res)
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '登录成功',
|
|
|
|
|
+ icon: 'success'
|
|
|
|
|
+ })
|
|
|
|
|
+ router.nextLogin();
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|