- 弃用 service 请求,重新设计了 request 请求方案。
- 用户信息绑定方式更改为 userInfo
This commit is contained in:
@@ -42,11 +42,11 @@ const data = ref<ClListViewItem[]>([]);
|
||||
onReady(() => {
|
||||
ui.showLoading();
|
||||
|
||||
request<UTSJSONObject[]>({
|
||||
request({
|
||||
url: "https://unix.cool-js.com/data/pca_flat.json"
|
||||
})
|
||||
.then((res) => {
|
||||
data.value = useListView(res);
|
||||
data.value = useListView(res as UTSJSONObject[]);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<view class="flex flex-col justify-center items-center pt-6 pb-3">
|
||||
<view class="relative overflow-visible" @tap="toEdit">
|
||||
<cl-avatar
|
||||
:src="user.info.avatarUrl"
|
||||
:src="userInfo?.avatarUrl"
|
||||
:size="150"
|
||||
:pt="{ className: '!rounded-3xl', icon: { size: 60 } }"
|
||||
>
|
||||
@@ -38,9 +38,9 @@
|
||||
|
||||
<view class="flex-1 flex flex-col justify-center items-center w-full" @tap="toEdit">
|
||||
<cl-text :pt="{ className: '!text-xl mt-5 mb-1 font-bold' }">{{
|
||||
user.info.nickName ?? t("未登录")
|
||||
userInfo?.nickName ?? t("未登录")
|
||||
}}</cl-text>
|
||||
<cl-text color="info" v-if="!user.isNull()">{{ user.info.phone }}</cl-text>
|
||||
<cl-text color="info" v-if="!user.isNull()">{{ userInfo?.phone }}</cl-text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -242,7 +242,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { router, useStore } from "@/cool";
|
||||
import { router, userInfo, useStore } from "@/cool";
|
||||
import { t } from "@/locale";
|
||||
import { useUi } from "@/uni_modules/cool-ui";
|
||||
import Tabbar from "@/components/tabbar.uvue";
|
||||
|
||||
@@ -73,7 +73,7 @@ import { t } from "@/locale";
|
||||
import { computed, inject, ref, type PropType } from "vue";
|
||||
import type { LoginForm } from "../../types";
|
||||
import SmsBtn from "@/components/sms-btn.uvue";
|
||||
import { isDark, parseClass, service, useRefs, type Response } from "@/cool";
|
||||
import { isDark, parseClass, request, useRefs, type Response } from "@/cool";
|
||||
import { useUi } from "@/uni_modules/cool-ui";
|
||||
|
||||
const props = defineProps({
|
||||
@@ -112,11 +112,14 @@ async function toLogin() {
|
||||
|
||||
loading.value = true;
|
||||
|
||||
await service.user.login
|
||||
.phone({
|
||||
await request({
|
||||
url: "/app/user/login/phone",
|
||||
method: "POST",
|
||||
data: {
|
||||
phone,
|
||||
smsCode
|
||||
})
|
||||
}
|
||||
})
|
||||
.then((res) => {
|
||||
emit("success", res);
|
||||
})
|
||||
|
||||
@@ -74,7 +74,17 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { parse, router, service, upload, useStore, useWx, type Response, type Token } from "@/cool";
|
||||
import {
|
||||
parse,
|
||||
request,
|
||||
router,
|
||||
upload,
|
||||
userInfo,
|
||||
useStore,
|
||||
useWx,
|
||||
type Response,
|
||||
type Token
|
||||
} from "@/cool";
|
||||
import { t } from "@/locale";
|
||||
import { useUi } from "@/uni_modules/cool-ui";
|
||||
import { reactive, ref } from "vue";
|
||||
@@ -176,8 +186,11 @@ async function miniLogin() {
|
||||
ui.showLoading(t("登录中"));
|
||||
|
||||
await wx.miniLogin().then(async (data) => {
|
||||
await service.user.login
|
||||
.mini(data)
|
||||
await request({
|
||||
url: "/app/user/login/mini",
|
||||
method: "POST",
|
||||
data
|
||||
})
|
||||
.then(async (res) => {
|
||||
// 设置token
|
||||
user.setToken(parse<Token>(res)!);
|
||||
@@ -186,7 +199,7 @@ async function miniLogin() {
|
||||
await user.get();
|
||||
|
||||
// 是否首次注册,根据业务情况调整判断逻辑
|
||||
if (user.info.nickName == "微信用户") {
|
||||
if (userInfo.value?.nickName == "微信用户") {
|
||||
// 打开编辑弹窗
|
||||
editOpen();
|
||||
} else {
|
||||
@@ -202,12 +215,13 @@ async function miniLogin() {
|
||||
});
|
||||
|
||||
ui.hideLoading();
|
||||
|
||||
// #endif
|
||||
}
|
||||
|
||||
// 微信APP登录
|
||||
function appLogin() {}
|
||||
function appLogin() {
|
||||
// 开发中
|
||||
}
|
||||
|
||||
// 微信登录
|
||||
async function login() {
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { router, useStore } from "@/cool";
|
||||
import { router, userInfo, useStore } from "@/cool";
|
||||
import { t } from "@/locale";
|
||||
import { useUi } from "@/uni_modules/cool-ui";
|
||||
import { ref } from "vue";
|
||||
@@ -47,6 +47,6 @@ async function confirm() {
|
||||
}
|
||||
|
||||
onReady(() => {
|
||||
content.value = user.info.description ?? "";
|
||||
content.value = userInfo.value?.description ?? "";
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { router, useStore } from "@/cool";
|
||||
import { router, userInfo, useStore } from "@/cool";
|
||||
import { t } from "@/locale";
|
||||
import { useUi } from "@/uni_modules/cool-ui";
|
||||
import { ref } from "vue";
|
||||
@@ -75,6 +75,6 @@ async function confirm() {
|
||||
|
||||
// 页面加载时,设置输入框内容
|
||||
onReady(() => {
|
||||
content.value = user.info.nickName ?? "";
|
||||
content.value = userInfo.value?.nickName ?? "";
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<!-- #endif -->
|
||||
|
||||
<cl-avatar
|
||||
:src="user.info.avatarUrl"
|
||||
:src="userInfo?.avatarUrl"
|
||||
:size="150"
|
||||
:pt="{ className: '!rounded-3xl', icon: { size: 60 } }"
|
||||
@tap="uploadAvatar"
|
||||
@@ -35,10 +35,10 @@
|
||||
justify="start"
|
||||
@tap="router.to('/pages/user/edit-name')"
|
||||
>
|
||||
<cl-text>{{ user.info.nickName }}</cl-text>
|
||||
<cl-text>{{ userInfo?.nickName }}</cl-text>
|
||||
</cl-list-item>
|
||||
<cl-list-item label="手机号" hoverable justify="start">
|
||||
<cl-text>{{ user.info.phone }}</cl-text>
|
||||
<cl-text>{{ userInfo?.phone }}</cl-text>
|
||||
</cl-list-item>
|
||||
</cl-list>
|
||||
|
||||
@@ -50,10 +50,10 @@
|
||||
justify="start"
|
||||
@tap="router.to('/pages/user/edit-description')"
|
||||
>
|
||||
<cl-text color="info" v-if="user.info.description == null">{{
|
||||
<cl-text color="info" v-if="userInfo?.description == null">{{
|
||||
t("介绍一下自己")
|
||||
}}</cl-text>
|
||||
<cl-text ellipsis v-else>{{ user.info.description }}</cl-text>
|
||||
<cl-text ellipsis v-else>{{ userInfo?.description }}</cl-text>
|
||||
</cl-list-item>
|
||||
</cl-list>
|
||||
|
||||
@@ -76,8 +76,8 @@
|
||||
justify="start"
|
||||
@tap="open('birthday')"
|
||||
>
|
||||
<cl-text>{{ user.info.birthday }}</cl-text>
|
||||
<cl-text color="info" v-if="user.info.birthday == null">{{
|
||||
<cl-text>{{ userInfo?.birthday }}</cl-text>
|
||||
<cl-text color="info" v-if="userInfo?.birthday == null">{{
|
||||
t("选择生日")
|
||||
}}</cl-text>
|
||||
</cl-list-item>
|
||||
@@ -98,7 +98,7 @@
|
||||
|
||||
<cl-select
|
||||
:title="t('选择性别')"
|
||||
:model-value="user.info.gender"
|
||||
:model-value="userInfo?.gender"
|
||||
:ref="refs.set('gender')"
|
||||
:options="genderOptions"
|
||||
:show-trigger="false"
|
||||
@@ -107,7 +107,7 @@
|
||||
|
||||
<cl-select-date
|
||||
:title="t('选择生日')"
|
||||
:model-value="user.info.birthday"
|
||||
:model-value="userInfo?.birthday"
|
||||
:ref="refs.set('birthday')"
|
||||
type="date"
|
||||
:end="today"
|
||||
@@ -127,7 +127,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { dayUts, router, upload, useRefs, useStore, type Response } from "@/cool";
|
||||
import { dayUts, router, upload, useRefs, useStore, type Response, userInfo } from "@/cool";
|
||||
import { t } from "@/locale";
|
||||
import { useCascader, useUi, type ClSelectOption } from "@/uni_modules/cool-ui";
|
||||
import { computed, ref } from "vue";
|
||||
@@ -158,7 +158,7 @@ const genderOptions = ref<ClSelectOption[]>([
|
||||
|
||||
// 性别文本
|
||||
const genderText = computed(() => {
|
||||
return [t("保密"), t("男"), t("女")][user.info.gender!];
|
||||
return [t("保密"), t("男"), t("女")][userInfo.value?.gender!];
|
||||
});
|
||||
|
||||
// 性别改变
|
||||
@@ -188,7 +188,7 @@ const regionOptions = useCascader(pca);
|
||||
|
||||
// 地区文本
|
||||
const regionText = computed(() => {
|
||||
return [user.info.province, user.info.city, user.info.district]
|
||||
return [userInfo.value?.province, userInfo.value?.city, userInfo.value?.district]
|
||||
.filter((e) => e != null)
|
||||
.join(" - ");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user