Commit 14290eba by liimin

style(api): 统一代码格式和修复严格相等判断

- 统一导入路径引号使用双引号并移除多余空格
- 将松散相等(==)改为严格相等(===)和严格不等(!==)判断
- 修复 qs.uts 中 null 和 undefined 的严格判断
- 移除登录页面未使用的类型定义和冗余日志
- 调整 system-api.uts 的导入顺序和代码格式
1 parent 2f29f6dc
/** /**
* 精品/轻改 API(从 gl_tape/api/module/boutique.js 迁移) * 精品/轻改 API(从 gl_tape/api/module/boutique.js 迁移)
*/ */
import http from '@/api/request/http.uts' import http from "@/api/request/http.uts";
/** 轻改素材配置 */ /** 轻改素材配置 */
export function getBoutiqueMaterialConfig(data: UTSJSONObject): Promise<any> { export function getBoutiqueMaterialConfig(data: UTSJSONObject): Promise<any> {
return http.post({ return http.post({
'method': 'dj.api.boutique.recepiton.material.merchant.detail', "method": "dj.api.boutique.recepiton.material.merchant.detail",
'projectName': 'boutique', "projectName": "boutique",
...data ...data
} as UTSJSONObject) } as UTSJSONObject);
} }
/** 查询商户套餐推荐配置列表 */ /** 查询商户套餐推荐配置列表 */
export function getBoutiquePackageList(data: UTSJSONObject): Promise<any> { export function getBoutiquePackageList(data: UTSJSONObject): Promise<any> {
return http.post({ return http.post({
'method': 'dj.api.smartcarlife.receptionMaterialRecommendPackageConfig.getByMerchantId', "method": "dj.api.smartcarlife.receptionMaterialRecommendPackageConfig.getByMerchantId",
'projectName': 'boutique', "projectName": "boutique",
...data ...data
} as UTSJSONObject) } as UTSJSONObject);
} }
...@@ -6,23 +6,23 @@ import http from "@/api/request/http.uts"; ...@@ -6,23 +6,23 @@ import http from "@/api/request/http.uts";
/** 获取交付人员列表 */ /** 获取交付人员列表 */
export function getEmployeeList(data: UTSJSONObject): Promise<any> { export function getEmployeeList(data: UTSJSONObject): Promise<any> {
return http.post({ return http.post({
'method': 'dj.api.smartcarlife.employee.getByMerchantId', "method": "dj.api.smartcarlife.employee.getByMerchantId",
'projectName': 'boutique', "projectName": "boutique",
'sceneList': [0], "sceneList": [0],
...data ...data
} as UTSJSONObject) } as UTSJSONObject);
} }
/** 获取门店主营车品牌 */ /** 获取门店主营车品牌 */
export function getMerchantCarBrandList(merchantIdList: Array<string | number>): Promise<any> { export function getMerchantCarBrandList(merchantIdList: Array<number | string>): Promise<any> {
return http.post({ return http.post({
method: 'merchants.api.open.merchant.info', method: "merchants.api.open.merchant.info",
projectName: 'merchants', projectName: "merchants",
merchantIdList: merchantIdList, merchantIdList,
merchantInfoSwitch: { merchantInfoSwitch: {
brandFlag: true brandFlag: true
} }
} as UTSJSONObject, false, 'merchant') } as UTSJSONObject, false, "merchant");
} }
/** /**
...@@ -30,7 +30,7 @@ export function getMerchantCarBrandList(merchantIdList: Array<string | number>): ...@@ -30,7 +30,7 @@ export function getMerchantCarBrandList(merchantIdList: Array<string | number>):
*/ */
export function getCarBrandsListApi(data: UTSJSONObject): Promise<any> { export function getCarBrandsListApi(data: UTSJSONObject): Promise<any> {
return http.post({ return http.post({
method: 'scrm.api.carlife.common.getCarSeriesList', method: "scrm.api.carlife.common.getCarSeriesList",
...data ...data
} as UTSJSONObject, false, 'scrm') } as UTSJSONObject, false, "scrm");
} }
import * as receiption from "./receiption.uts";
export {
receiption
} export * as receiption from "./receiption.uts";
...@@ -46,16 +46,16 @@ function stringifyRecursive( ...@@ -46,16 +46,16 @@ function stringifyRecursive(
options: StringifyOptions options: StringifyOptions
): string { ): string {
const prefix = options.prefix ?? ""; const prefix = options.prefix ?? "";
const encoder = options.encoder != null ? options.encoder! : (str: string): string => defaultEncoder(str); const encoder = options.encoder !== null ? options.encoder : (str: string): string => defaultEncoder(str);
const filter = options.filter; const filter = options.filter;
const sort = options.sort; const sort = options.sort;
const strictNullHandling = options.strictNullHandling ?? false; const strictNullHandling = options.strictNullHandling ?? false;
const skipNulls = options.skipNulls ?? false; const skipNulls = options.skipNulls ?? false;
const encodeValuesOnly = options.encodeValuesOnly ?? false; const encodeValuesOnly = options.encodeValuesOnly ?? false;
const generateArrayPrefix = options.generateArrayPrefix != null ? options.generateArrayPrefix! : (p: string, k: string): string => defaultGenerateArrayPrefix(p, k); const generateArrayPrefix = options.generateArrayPrefix !== null ? options.generateArrayPrefix : (p: string, k: string): string => defaultGenerateArrayPrefix(p, k);
const allowDots = options.allowDots ?? false; const allowDots = options.allowDots ?? false;
const formatter = options.formatter != null ? options.formatter! : (str: string): string => defaultFormatter(str); const formatter = options.formatter !== null ? options.formatter : (str: string): string => defaultFormatter(str);
const serializeDate = options.serializeDate != null ? options.serializeDate! : (date: Date): string => defaultSerializeDate(date); const serializeDate = options.serializeDate !== null ? options.serializeDate : (date: Date): string => defaultSerializeDate(date);
let processedObj: any | null = obj; let processedObj: any | null = obj;
...@@ -83,7 +83,7 @@ function stringifyRecursive( ...@@ -83,7 +83,7 @@ function stringifyRecursive(
const values: string[] = []; const values: string[] = [];
if (processedObj == null) { if (processedObj === null) {
return ""; return "";
} }
...@@ -98,7 +98,7 @@ function stringifyRecursive( ...@@ -98,7 +98,7 @@ function stringifyRecursive(
targetObj = new UTSJSONObject(processedObj); targetObj = new UTSJSONObject(processedObj);
} }
} else { } else {
if (processedObj != null) { if (processedObj !== null) {
if (Array.isArray(processedObj)) { if (Array.isArray(processedObj)) {
const arr = processedObj as any[]; const arr = processedObj as any[];
for (let i = 0; i < arr.length; i++) { for (let i = 0; i < arr.length; i++) {
...@@ -117,7 +117,7 @@ function stringifyRecursive( ...@@ -117,7 +117,7 @@ function stringifyRecursive(
objKeys.push(key); objKeys.push(key);
}); });
} }
if (sort != null) { if (sort !== null) {
objKeys = objKeys.sort(sort); objKeys = objKeys.sort(sort);
} }
} }
...@@ -128,7 +128,7 @@ function stringifyRecursive( ...@@ -128,7 +128,7 @@ function stringifyRecursive(
if (Array.isArray(targetObj)) { if (Array.isArray(targetObj)) {
const idx = Number.parseInt(key); const idx = Number.parseInt(key);
if (!isNaN(idx)) { if (!Number.isNaN(idx)) {
value = (targetObj as any[])[idx]; value = (targetObj as any[])[idx];
} }
} else { } else {
...@@ -140,8 +140,8 @@ function stringifyRecursive( ...@@ -140,8 +140,8 @@ function stringifyRecursive(
} }
const nextPrefix = Array.isArray(targetObj) const nextPrefix = Array.isArray(targetObj)
? (prefix != "" ? generateArrayPrefix(prefix, key) : key) ? (prefix !== "" ? generateArrayPrefix(prefix, key) : key)
: (prefix != "" ? prefix + (allowDots ? `.${key}` : `[${key}]`) : key); : (prefix !== "" ? prefix + (allowDots ? `.${key}` : `[${key}]`) : key);
const newOptions: StringifyOptions = { const newOptions: StringifyOptions = {
prefix: nextPrefix, prefix: nextPrefix,
...@@ -158,7 +158,7 @@ function stringifyRecursive( ...@@ -158,7 +158,7 @@ function stringifyRecursive(
}; };
const result = stringifyRecursive(value, newOptions); const result = stringifyRecursive(value, newOptions);
if (result != "") { if (result !== "") {
values.push(result); values.push(result);
} }
} }
......
...@@ -42,7 +42,7 @@ export function sign(params: UTSJSONObject, secret: string, noSignAttr: string[] ...@@ -42,7 +42,7 @@ export function sign(params: UTSJSONObject, secret: string, noSignAttr: string[]
// 4. 获取 key 列表并排序 // 4. 获取 key 列表并排序
const sortedKeys: string[] = []; const sortedKeys: string[] = [];
for (const key in realObj) { for (const key in realObj) {
if (key == "sign") { if (key === "sign") {
continue; continue;
} }
sortedKeys.push(key); sortedKeys.push(key);
...@@ -53,7 +53,7 @@ export function sign(params: UTSJSONObject, secret: string, noSignAttr: string[] ...@@ -53,7 +53,7 @@ export function sign(params: UTSJSONObject, secret: string, noSignAttr: string[]
for (const key of sortedKeys) { for (const key of sortedKeys) {
let obj: any | null = realObj[key]; let obj: any | null = realObj[key];
if (obj == null) { if (obj === null) {
obj = ""; obj = "";
} else if (typeof obj === "object") { } else if (typeof obj === "object") {
obj = JSON.stringify(obj); obj = JSON.stringify(obj);
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
maxlength="11" maxlength="11"
placeholder="请输入手机号" placeholder="请输入手机号"
type="tel" /> type="tel" />
<view v-if="mobile != ''" <view v-if="mobile !== ''"
class="icon" class="icon"
@click="clearMobile"> @click="clearMobile">
<icon color="#000" <icon color="#000"
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
maxlength="4" maxlength="4"
placeholder="请输入验证码" placeholder="请输入验证码"
type="number" /> type="number" />
<view v-if="code != ''" <view v-if="code !== ''"
class="icon" class="icon"
@click="clearCode"> @click="clearCode">
<icon color="#000" <icon color="#000"
...@@ -98,14 +98,6 @@ import { onLoad } from "@dcloudio/uni-app"; ...@@ -98,14 +98,6 @@ import { onLoad } from "@dcloudio/uni-app";
// 手机号正则 // 手机号正则
const phoneRex = /^1([3-9])\d{9}$/; const phoneRex = /^1([3-9])\d{9}$/;
// 登录返回 data 的结构(这里只挑我们需要的字段)
type LoginResultData = {
loginUserInfoList: any[] | null
noSignInUuid: null | string
sessionId: null | string
}
const mobile = ref<string>(""); const mobile = ref<string>("");
const code = ref<string>(""); const code = ref<string>("");
const count = ref<number>(0); const count = ref<number>(0);
...@@ -119,7 +111,7 @@ const LOGIN_INTERVAL_MS = 200; ...@@ -119,7 +111,7 @@ const LOGIN_INTERVAL_MS = 200;
// 先定义会被其他函数调用的函数:getAccountLoginList / jump / doLogin / login / countDown // 先定义会被其他函数调用的函数:getAccountLoginList / jump / doLogin / login / countDown
const getAccountLoginList = (loginUserInfoList: any[]): void => { const getAccountLoginList = (loginUserInfoList: any[]): void => {
const stepIndex = loginUserInfoList.length == 1 ? 1 : 0; const stepIndex = loginUserInfoList.length === 1 ? 1 : 0;
uni.navigateTo({ uni.navigateTo({
url: `/pages/common/accountItems/index?stepIndex=${stepIndex}` url: `/pages/common/accountItems/index?stepIndex=${stepIndex}`
}); });
...@@ -132,11 +124,11 @@ const jump = (data: any, remember: boolean): void => { ...@@ -132,11 +124,11 @@ const jump = (data: any, remember: boolean): void => {
const sessionIdVal = loginData.sessionId as null | string; const sessionIdVal = loginData.sessionId as null | string;
const noSignInUuidVal = loginData.noSignInUuid as null | string; const noSignInUuidVal = loginData.noSignInUuid as null | string;
if (loginUserInfoList != null && loginUserInfoList.length > 0) { if (loginUserInfoList !== null && loginUserInfoList.length > 0) {
if (sessionIdVal != null && sessionIdVal != "") { if (sessionIdVal !== null && sessionIdVal !== "") {
storage.set("sessionId", sessionIdVal, 0); storage.set("sessionId", sessionIdVal, 0);
} }
if (noSignInUuidVal != null && noSignInUuidVal != "" && remember) { if (noSignInUuidVal !== null && noSignInUuidVal !== "" && remember) {
storage.set("noSignInUuid", noSignInUuidVal, 0); storage.set("noSignInUuid", noSignInUuidVal, 0);
} }
getAccountLoginList(loginUserInfoList); getAccountLoginList(loginUserInfoList);
...@@ -155,16 +147,16 @@ const doLogin = async (): Promise<void> => { ...@@ -155,16 +147,16 @@ const doLogin = async (): Promise<void> => {
const agreed = readingStatus.value; const agreed = readingStatus.value;
console.log("agreed:", agreed, "type:", typeof agreed); console.log("agreed:", agreed, "type:", typeof agreed);
try { try {
if (m == "") { if (m === "") {
throw new Error("请输入手机号"); throw new Error("请输入手机号");
} }
if (!phoneRex.test(m)) { if (!phoneRex.test(m)) {
throw new Error("请输入正确的手机号"); throw new Error("请输入正确的手机号");
} }
if (smsCode == "") { if (smsCode === "") {
throw new Error("请输入验证码"); throw new Error("请输入验证码");
} }
if (agreed != true) { if (agreed !== true) {
throw new Error("请您阅读并同意《隐私协议》"); throw new Error("请您阅读并同意《隐私协议》");
} }
...@@ -184,11 +176,11 @@ const doLogin = async (): Promise<void> => { ...@@ -184,11 +176,11 @@ const doLogin = async (): Promise<void> => {
const res = await apiSmsLogin(params); const res = await apiSmsLogin(params);
console.log("res", res); console.log("res", res);
uni.hideLoading(); uni.hideLoading();
const resCode = res != null ? res.code : null; const resCode = res !== null ? res.code : null;
const data = res != null ? (res.data as any | null) : null; const data = res !== null ? (res.data as any | null) : null;
const message = res != null ? (res.message as null | string) : null; const message = res !== null ? (res.message as null | string) : null;
if (`${resCode}` == "0" && data != null) { if (`${resCode}` === "0" && data !== null) {
jump(data, remember); jump(data, remember);
} else { } else {
uni.showModal({ uni.showModal({
...@@ -240,7 +232,7 @@ function countDown(initial: number): void { ...@@ -240,7 +232,7 @@ function countDown(initial: number): void {
const autoLoginByMobile = (): void => { const autoLoginByMobile = (): void => {
const m = mobile.value; const m = mobile.value;
const c = code.value; const c = code.value;
if (c != "" && m != "" && c.length == 4 && phoneRex.test(m)) { if (c !== "" && m !== "" && c.length === 4 && phoneRex.test(m)) {
login(); login();
} }
}; };
...@@ -266,7 +258,7 @@ const copyDeviceId = (): void => { ...@@ -266,7 +258,7 @@ const copyDeviceId = (): void => {
}; };
const autoLogin = async (noSignInUuid: string): Promise<void> => { const autoLogin = async (noSignInUuid: string): Promise<void> => {
if (noSignInUuid == "") return; if (noSignInUuid === "") return;
uni.showLoading({ uni.showLoading({
title: "加载中", title: "加载中",
mask: true mask: true
...@@ -276,8 +268,8 @@ const autoLogin = async (noSignInUuid: string): Promise<void> => { ...@@ -276,8 +268,8 @@ const autoLogin = async (noSignInUuid: string): Promise<void> => {
noSignInUuid noSignInUuid
} as UTSJSONObject); } as UTSJSONObject);
uni.hideLoading(); uni.hideLoading();
const data = res != null ? (res.data as any | null) : null; const data = res !== null ? (res.data as any | null) : null;
if (data != null) { if (data !== null) {
jump(data, true); jump(data, true);
} }
} catch { } catch {
...@@ -289,7 +281,7 @@ const getSmsCode = async (): Promise<void> => { ...@@ -289,7 +281,7 @@ const getSmsCode = async (): Promise<void> => {
const m = mobile.value; const m = mobile.value;
const c = count.value; const c = count.value;
try { try {
if (m == "") { if (m === "") {
throw new Error("请输入手机号"); throw new Error("请输入手机号");
} }
if (!phoneRex.test(m)) { if (!phoneRex.test(m)) {
...@@ -308,9 +300,9 @@ const getSmsCode = async (): Promise<void> => { ...@@ -308,9 +300,9 @@ const getSmsCode = async (): Promise<void> => {
mobile: m mobile: m
} as UTSJSONObject); } as UTSJSONObject);
uni.hideLoading(); uni.hideLoading();
const codeVal = res != null ? (res.code as null | string) : null; const codeVal = res !== null ? (res.code as null | string) : null;
const message = res != null ? (res.message as null | string) : null; const message = res !== null ? (res.message as null | string) : null;
if (codeVal == "0") { if (codeVal === "0") {
uni.showToast({ uni.showToast({
title: "验证码已发送", title: "验证码已发送",
icon: "none" icon: "none"
...@@ -337,18 +329,18 @@ const openPrivacy = (): void => { ...@@ -337,18 +329,18 @@ const openPrivacy = (): void => {
}; };
onLoad((options: null | UTSJSONObject) => { onLoad((options: null | UTSJSONObject) => {
const optMobile = options != null ? (options.mobile as null | string) : null; const optMobile = options !== null ? (options.mobile as null | string) : null;
if (optMobile != null && optMobile != "") { if (optMobile !== null && optMobile !== "") {
mobile.value = optMobile; mobile.value = optMobile;
} }
const noSignInUuid = storage.get("noSignInUuid") as null | string; const noSignInUuid = storage.get("noSignInUuid") as null | string;
if (noSignInUuid != null && noSignInUuid != "") { if (noSignInUuid !== null && noSignInUuid !== "") {
autoLogin(noSignInUuid); autoLogin(noSignInUuid);
} }
const info = uni.getDeviceInfo(); const info = uni.getDeviceInfo();
if (info != null && info.deviceId != null) { if (info !== null && info.deviceId !== null) {
deviceId.value = info.deviceId; deviceId.value = info.deviceId;
} }
}); });
...@@ -362,9 +354,7 @@ watch(code, () => { ...@@ -362,9 +354,7 @@ watch(code, () => {
}); });
function toggleReadingStatus(): void { function toggleReadingStatus(): void {
console.log("toggleReadingStatus before:", readingStatus.value);
readingStatus.value = !readingStatus.value; readingStatus.value = !readingStatus.value;
console.log("toggleReadingStatus after:", readingStatus.value);
} }
function toggleNoSignIn(): void { function toggleNoSignIn(): void {
...@@ -400,4 +390,3 @@ function goToTest(): void { ...@@ -400,4 +390,3 @@ function goToTest(): void {
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!