修改浙政钉登录
This commit is contained in:
1 parent
a8c7b33331
commit
ec3d9cdd38
9 files changed
+484
-281
No files matched your search
+190
-152
@@ -1,188 +1,226 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from "vue";
|
||||
import { onLoad, onShow } from "@dcloudio/uni-app";
|
||||
import { ref, reactive, computed } from "vue"
|
||||
import { onLoad, onShow } from "@dcloudio/uni-app"
|
||||
import { isEmpty } from "radash"
|
||||
|
||||
import { hooks, router } from "@@/index"
|
||||
import { orderApi, refundApi, commonApi } from "@@/api"
|
||||
|
||||
import { filePath } from "@@/utils/file";
|
||||
import { filePath } from "@@/utils/file"
|
||||
|
||||
const data = {
|
||||
payType: [
|
||||
{ text: "仅退款", disabled: false, visible: true, type: "10", value: "10" },
|
||||
{ text: "退款退货", disabled: true, visible: false, type: "20", value: "20" },
|
||||
]
|
||||
payType: [
|
||||
{ text: "仅退款", disabled: false, visible: true, type: "10", value: "10" },
|
||||
{ text: "退款退货", disabled: true, visible: false, type: "20", value: "20" },
|
||||
],
|
||||
}
|
||||
const state = reactive<any>({
|
||||
detailId: null,
|
||||
detail: {},
|
||||
shopCarList: [],
|
||||
setting: {},
|
||||
selectList: []
|
||||
detailId: null,
|
||||
detail: {},
|
||||
shopCarList: [],
|
||||
setting: {},
|
||||
selectList: [],
|
||||
})
|
||||
const uploadApplyPicUrls = ref<Array<Record<string, any> | string>>([]) // 补充凭证图片
|
||||
const applyPicUrls = computed(() =>
|
||||
uploadApplyPicUrls.value.map((item: any) => JSON.parse(item.response).data.url).join(","),
|
||||
)
|
||||
|
||||
const applyForm = reactive<any>({
|
||||
way: data.payType[0].type,
|
||||
remark: "",
|
||||
reason: "",
|
||||
reasonStr: "",
|
||||
way: data.payType[0].type,
|
||||
remark: "",
|
||||
reason: "",
|
||||
reasonStr: "",
|
||||
})
|
||||
|
||||
onLoad((options: any) => {
|
||||
if (!isEmpty(options.id)) {
|
||||
state.detailId = options.id
|
||||
}
|
||||
});
|
||||
if (!isEmpty(options.id)) {
|
||||
state.detailId = options.id
|
||||
}
|
||||
state.header = hooks.useDefaultHeader()
|
||||
})
|
||||
onShow(() => {
|
||||
getDetail()
|
||||
getSetting()
|
||||
getShopCarList()
|
||||
getDetail()
|
||||
getSetting()
|
||||
getShopCarList()
|
||||
})
|
||||
|
||||
const getSetting = async () => {
|
||||
const _pa = {};
|
||||
const { data } = await commonApi.setting(_pa)
|
||||
state.setting = data
|
||||
state.selectList = data.afterSaleRefundReasons?.split(",").map(v => {
|
||||
return {
|
||||
id: v,
|
||||
title: v,
|
||||
}
|
||||
})
|
||||
const _pa = {}
|
||||
const { data } = await commonApi.setting(_pa)
|
||||
state.setting = data
|
||||
state.selectList = data.afterSaleRefundReasons?.split(",").map((v) => {
|
||||
return {
|
||||
id: v,
|
||||
title: v,
|
||||
}
|
||||
})
|
||||
}
|
||||
const getDetail = async () => {
|
||||
if (isEmpty(state.detailId)) return
|
||||
const _pa = { id: state.detailId };
|
||||
const { data } = await orderApi.detail(_pa)
|
||||
state.detail = data
|
||||
if (isEmpty(state.detailId)) return
|
||||
const _pa = { id: state.detailId }
|
||||
const { data } = await orderApi.detail(_pa)
|
||||
state.detail = data
|
||||
}
|
||||
const getShopCarList = async () => {
|
||||
if (isEmpty(state.detailId)) return
|
||||
const _pa = { orderId: state.detailId };
|
||||
const { data } = await orderApi.shopCarList(_pa)
|
||||
state.shopCarList = data
|
||||
if (isEmpty(state.detailId)) return
|
||||
const _pa = { orderId: state.detailId }
|
||||
const { data } = await orderApi.shopCarList(_pa)
|
||||
state.shopCarList = data
|
||||
}
|
||||
|
||||
const radioChange = (e: any) => {
|
||||
switch (e) {
|
||||
case "10":
|
||||
state.selectList = state.setting.afterSaleRefundReasons.map(v => {
|
||||
return {
|
||||
id: v,
|
||||
title: v,
|
||||
}
|
||||
})
|
||||
break
|
||||
case "20":
|
||||
state.selectList = state.setting.afterSaleReturnReasons.map(v => {
|
||||
return {
|
||||
id: v,
|
||||
title: v,
|
||||
}
|
||||
})
|
||||
break
|
||||
}
|
||||
switch (e) {
|
||||
case "10":
|
||||
state.selectList = state.setting.afterSaleRefundReasons.map((v) => {
|
||||
return {
|
||||
id: v,
|
||||
title: v,
|
||||
}
|
||||
})
|
||||
break
|
||||
case "20":
|
||||
state.selectList = state.setting.afterSaleReturnReasons.map((v) => {
|
||||
return {
|
||||
id: v,
|
||||
title: v,
|
||||
}
|
||||
})
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
const doSubmit = async () => {
|
||||
if (isEmpty(applyForm.reasonStr)) {
|
||||
uni.showToast({ title: '请选择申请原因', icon: "none" });
|
||||
return
|
||||
}
|
||||
const _pa = {
|
||||
way: applyForm.way,
|
||||
refundPrice: state.detail.practicalTotalPrice,
|
||||
orderId: state.detailId,
|
||||
images: [],
|
||||
applyReason: applyForm.reasonStr,
|
||||
applyDescription: applyForm.remark,
|
||||
}
|
||||
try {
|
||||
uni.showLoading({ title: '申请中...', mask: false });
|
||||
const data = await refundApi.create(_pa)
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: '申请成功', icon: "none" });
|
||||
router.jump("/pages/order/detail", { id: state.detailId }, 2)
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
uni.hideLoading()
|
||||
}
|
||||
if (isEmpty(applyForm.reasonStr)) {
|
||||
uni.showToast({ title: "请选择申请原因", icon: "none" })
|
||||
return
|
||||
}
|
||||
const _pa = {
|
||||
way: applyForm.way,
|
||||
refundPrice: state.detail.practicalTotalPrice,
|
||||
orderId: state.detailId,
|
||||
images: [],
|
||||
applyReason: applyForm.reasonStr,
|
||||
applyDescription: applyForm.remark,
|
||||
applyPicUrls: applyPicUrls.value,
|
||||
}
|
||||
try {
|
||||
uni.showLoading({ title: "申请中...", mask: false })
|
||||
const data = await refundApi.create(_pa)
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: "申请成功", icon: "none" })
|
||||
router.jump("/pages/order/detail", { id: state.detailId }, 2)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
uni.hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<template>
|
||||
<crud-layout title="申请售后" mainIsScroll bg="/static/page/blue-bg.png">
|
||||
<view class="h-30rpx" />
|
||||
<view class="flex-col justify-center card p-x-20rpx p-y-30rpx m-b-20rpx">
|
||||
<view class="m-t-15rpx">
|
||||
<view class="flex-row items-start justify-between" v-for="(v, i) in state.shopCarList" :key="i"
|
||||
@tap.stop="router.jump('/pages/merchant/product-detail', { id: v.productId })">
|
||||
<view class="flex-row items-center">
|
||||
<image class="w-160rpx h-160rpx rounded-8rpx" :src="filePath(v.productPic)" mode="aspectFill" />
|
||||
<view class="flex-col m-l-15rpx second-text-26">
|
||||
<view class="sub-text-28">{{ v.productName }}</view>
|
||||
<view class="m-t-5rpx">¥ {{ hooks.useMoney(v.productPrice) }}</view>
|
||||
<view class="m-t-5rpx">x {{ v.productCount }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex-row-center">
|
||||
<view class="sub-text-32">¥ {{ hooks.useMoney(v.totalPrice) }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="m-y-15rpx h-1px bg-#999 bg-opacity-5" />
|
||||
<view class="flex-row items-center justify-between">
|
||||
<view class="sub-text-28">实付款</view>
|
||||
<view class="flex-row items-end">
|
||||
<view class="sub-text-28">¥</view>
|
||||
<view class="m-l-5rpx sub-text-28">{{ hooks.useMoney(state.detail.payPrice) }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="card p-x-20rpx p-y-30rpx m-b-20rpx">
|
||||
<view class="sub-text-28">售后类型</view>
|
||||
<view class="m-t-20rpx">
|
||||
<tm-radio-group @change="radioChange" direction="column" gap="20" v-model="applyForm.way">
|
||||
<tm-radio :disabled="v.disabled" v-for="(v, i) in data.payType" :key="i" v-show="v.visible"
|
||||
:value="v.type" :label="v.text" />
|
||||
</tm-radio-group>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex-row items-center justify-between card p-x-20rpx p-y-30rpx m-b-20rpx">
|
||||
<view class="sub-text-28">退款金额</view>
|
||||
<view class="sub-text-28 color-red!">¥{{ hooks.useMoney(state.detail.payPrice) }}</view>
|
||||
</view>
|
||||
<view class="card p-x-20rpx p-y-30rpx m-b-20rpx">
|
||||
<tm-picker rang-key="title" rang-text="title" v-model="applyForm.reason"
|
||||
v-model:model-str="applyForm.reasonStr" :list="state.selectList">
|
||||
<view class="flex-row items-center justify-between">
|
||||
<view class="sub-text-28">申请原因</view>
|
||||
<view class="flex-row items-center second-text-24">
|
||||
<text>{{ applyForm.reasonStr || '请选择申请原因' }} </text>
|
||||
<text class="m-l-10rpx color-#b1b1b1 iconfont icon-xiangxiajiantouxiao" />
|
||||
</view>
|
||||
</view>
|
||||
</tm-picker>
|
||||
</view>
|
||||
<view class="flex-col justify-center card p-x-20rpx p-y-30rpx m-b-20rpx">
|
||||
<view class="sub-text-28">相关描述</view>
|
||||
<view class="m-t-20rpx">
|
||||
<tm-input v-model="applyForm.remark" type="textarea" :showClear="false"
|
||||
placeholder="客官~请描述您遇到的问题"></tm-input>
|
||||
</view>
|
||||
</view>
|
||||
<view class="h-30rpx" />
|
||||
<template #main-bottom>
|
||||
<view v-if="state.detailType != 'view'"
|
||||
class="bg-#0094ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-y-30rpx sub-text-30 color-white!"
|
||||
@tap="doSubmit">
|
||||
提交申请
|
||||
</view>
|
||||
</template>
|
||||
</crud-layout>
|
||||
<crud-layout title="申请售后" mainIsScroll bg="/static/page/blue-bg.png">
|
||||
<view class="h-30rpx" />
|
||||
<view class="flex-col justify-center card p-x-20rpx p-y-30rpx m-b-20rpx">
|
||||
<view class="m-t-15rpx">
|
||||
<view
|
||||
class="flex-row items-start justify-between"
|
||||
v-for="(v, i) in state.shopCarList"
|
||||
:key="i"
|
||||
@tap.stop="router.jump('/pages/merchant/product-detail', { id: v.productId })"
|
||||
>
|
||||
<view class="flex-row items-center">
|
||||
<image class="w-160rpx h-160rpx rounded-8rpx" :src="filePath(v.productPic)" mode="aspectFill" />
|
||||
<view class="flex-col m-l-15rpx second-text-26">
|
||||
<view class="sub-text-28">{{ v.productName }}</view>
|
||||
<view class="m-t-5rpx">¥ {{ hooks.useMoney(v.productPrice) }}</view>
|
||||
<view class="m-t-5rpx">x {{ v.productCount }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex-row-center">
|
||||
<view class="sub-text-32">¥ {{ hooks.useMoney(v.totalPrice) }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="m-y-15rpx h-1px bg-#999 bg-opacity-5" />
|
||||
<view class="flex-row items-center justify-between">
|
||||
<view class="sub-text-28">实付款</view>
|
||||
<view class="flex-row items-end">
|
||||
<view class="sub-text-28">¥</view>
|
||||
<view class="m-l-5rpx sub-text-28">{{ hooks.useMoney(state.detail.payPrice) }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="card p-x-20rpx p-y-30rpx m-b-20rpx">
|
||||
<view class="sub-text-28">售后类型</view>
|
||||
<view class="m-t-20rpx">
|
||||
<tm-radio-group @change="radioChange" direction="column" gap="20" v-model="applyForm.way">
|
||||
<tm-radio
|
||||
:disabled="v.disabled"
|
||||
v-for="(v, i) in data.payType"
|
||||
:key="i"
|
||||
v-show="v.visible"
|
||||
:value="v.type"
|
||||
:label="v.text"
|
||||
/>
|
||||
</tm-radio-group>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex-row items-center justify-between card p-x-20rpx p-y-30rpx m-b-20rpx">
|
||||
<view class="sub-text-28">退款金额</view>
|
||||
<view class="sub-text-28 color-red!">¥{{ hooks.useMoney(state.detail.payPrice) }}</view>
|
||||
</view>
|
||||
<view class="card p-x-20rpx p-y-30rpx m-b-20rpx">
|
||||
<tm-picker
|
||||
rang-key="title"
|
||||
rang-text="title"
|
||||
v-model="applyForm.reason"
|
||||
v-model:model-str="applyForm.reasonStr"
|
||||
:list="state.selectList"
|
||||
>
|
||||
<view class="flex-row items-center justify-between">
|
||||
<view class="sub-text-28">申请原因</view>
|
||||
<view class="flex-row items-center second-text-24">
|
||||
<text>{{ applyForm.reasonStr || "请选择申请原因" }} </text>
|
||||
<text class="m-l-10rpx color-#b1b1b1 iconfont icon-xiangxiajiantouxiao" />
|
||||
</view>
|
||||
</view>
|
||||
</tm-picker>
|
||||
</view>
|
||||
<view class="flex-col justify-center card p-x-20rpx p-y-30rpx m-b-20rpx">
|
||||
<view class="sub-text-28">补充凭证图片</view>
|
||||
<view class="m-t-20rpx">
|
||||
<tm-upload-photo
|
||||
v-model="uploadApplyPicUrls"
|
||||
:maxFileSize="1024 * 1024 * 5"
|
||||
:url="'/api/admin/sys-file/upload'"
|
||||
:header="state.header"
|
||||
:maxCount="6"
|
||||
/>
|
||||
</view>
|
||||
<view class="sub-text-20 c-red!">注:图片大小不超过5M,最多上传6张</view>
|
||||
</view>
|
||||
<view class="flex-col justify-center card p-x-20rpx p-y-30rpx m-b-20rpx">
|
||||
<view class="sub-text-28">相关描述</view>
|
||||
<view class="m-t-20rpx">
|
||||
<tm-input
|
||||
v-model="applyForm.remark"
|
||||
type="textarea"
|
||||
:showClear="false"
|
||||
placeholder="客官~请描述您遇到的问题"
|
||||
></tm-input>
|
||||
</view>
|
||||
</view>
|
||||
<view class="h-30rpx" />
|
||||
<template #main-bottom>
|
||||
<view
|
||||
v-if="state.detailType != 'view'"
|
||||
class="bg-#0094ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-y-30rpx sub-text-30 color-white!"
|
||||
@tap="doSubmit"
|
||||
>
|
||||
提交申请
|
||||
</view>
|
||||
</template>
|
||||
</crud-layout>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
<style lang="scss" scoped></style>
|
||||
+67
-67
@@ -1,83 +1,83 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from "vue";
|
||||
import { onLoad, onShow } from "@dcloudio/uni-app";
|
||||
import { ref, reactive } from "vue"
|
||||
import { onLoad, onShow } from "@dcloudio/uni-app"
|
||||
|
||||
import { hooks, router } from "@@/index";
|
||||
import { merchantApi } from "@@/api";
|
||||
import { filePath } from "@@/utils/file";
|
||||
import { hooks, router } from "@@/index"
|
||||
import { merchantApi } from "@@/api"
|
||||
import { filePath } from "@@/utils/file"
|
||||
|
||||
const state = reactive<any>({
|
||||
pa: {
|
||||
pagesize: 10,
|
||||
type: "1",
|
||||
},
|
||||
});
|
||||
pa: {
|
||||
pagesize: 10,
|
||||
type: "1",
|
||||
},
|
||||
})
|
||||
|
||||
onLoad(() => {});
|
||||
onLoad(() => {})
|
||||
onShow(() => {
|
||||
if (pageRef.value) {
|
||||
pageRef.value.reload(false);
|
||||
}
|
||||
});
|
||||
if (pageRef.value) {
|
||||
pageRef.value.reload(false)
|
||||
}
|
||||
})
|
||||
|
||||
const pageRef = ref<any>(null);
|
||||
const pageHook = hooks.usePage(pageRef, merchantApi.page, null, "data.records");
|
||||
const pageRef = ref<any>(null)
|
||||
const pageHook = hooks.usePage(pageRef, merchantApi.page, null, "data.records")
|
||||
const query = (page: number, pagesize: number) => {
|
||||
pageHook.startPage(page, pagesize, false, state.pa);
|
||||
};
|
||||
pageHook.startPage(page, pagesize, false, state.pa)
|
||||
}
|
||||
|
||||
const toDetail = async (v: any) => {
|
||||
const isLogin = await hooks.useCheckLogin();
|
||||
if (isLogin) {
|
||||
router.jump("/pages/merchant/detail", { id: v.id });
|
||||
}
|
||||
};
|
||||
const isLogin = await hooks.useCheckLogin()
|
||||
if (isLogin) {
|
||||
router.jump("/pages/merchant/detail", { id: v.id })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<crud-layout bg="/static/page/blue-bg.png">
|
||||
<z-paging
|
||||
ref="pageRef"
|
||||
height="100%"
|
||||
:fixed="false"
|
||||
v-model="pageHook.list"
|
||||
:default-page-size="10"
|
||||
safe-area-inset-bottom
|
||||
:loading-more-enabled="true"
|
||||
:show-scrollbar="false"
|
||||
@query="query"
|
||||
:auto-clean-list-when-reload="false"
|
||||
:auto-scroll-to-top-when-reload="false"
|
||||
@scroll="pageHook.scroll"
|
||||
>
|
||||
<template #top> </template>
|
||||
<view class="flex-row card p-20rpx m-b-20rpx" v-for="(v, i) in pageHook.list" :key="i" @tap="toDetail(v)">
|
||||
<image class="w-160rpx h-160rpx rounded-12rpx" :src="filePath(v.logoPic)" mode="aspectFill" />
|
||||
<view class="flex-1 flex-col m-l-20rpx">
|
||||
<view class="flex-row items-center justify-between">
|
||||
<view class="flex-row-center sub-text-34">
|
||||
<text> {{ v.name }}</text>
|
||||
</view>
|
||||
<view>
|
||||
<tm-tag size="s">{{ v.deptName }}</tm-tag>
|
||||
</view>
|
||||
</view>
|
||||
<view class="m-t-10rpx second-text-28">
|
||||
<text>营业时间</text>
|
||||
<text class="m-l-10rpx">
|
||||
{{ v.jobStartTime }}
|
||||
~
|
||||
{{ v.jobEndTime }}
|
||||
</text>
|
||||
</view>
|
||||
<view v-if="v.addressDes" class="m-t-10rpx second-text-28">
|
||||
<text>食堂地址</text>
|
||||
<text class="m-l-10rpx">{{ v.addressDes }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</z-paging>
|
||||
</crud-layout>
|
||||
<crud-layout bg="/static/page/blue-bg.png">
|
||||
<z-paging
|
||||
ref="pageRef"
|
||||
height="100%"
|
||||
:fixed="false"
|
||||
v-model="pageHook.list"
|
||||
:default-page-size="10"
|
||||
safe-area-inset-bottom
|
||||
:loading-more-enabled="true"
|
||||
:show-scrollbar="false"
|
||||
@query="query"
|
||||
:auto-clean-list-when-reload="false"
|
||||
:auto-scroll-to-top-when-reload="false"
|
||||
@scroll="pageHook.scroll"
|
||||
>
|
||||
<template #top> </template>
|
||||
<view class="flex-row card p-20rpx m-b-20rpx" v-for="(v, i) in pageHook.list" :key="i" @tap="toDetail(v)">
|
||||
<image class="w-160rpx h-160rpx rounded-12rpx" :src="filePath(v.logoPic)" mode="aspectFill" />
|
||||
<view class="flex-1 flex-col m-l-20rpx">
|
||||
<view class="flex-row items-center justify-between">
|
||||
<view class="flex-row-center sub-text-34">
|
||||
<text> {{ v.name }}</text>
|
||||
</view>
|
||||
<view>
|
||||
<tm-tag size="s">{{ v.deptName }}</tm-tag>
|
||||
</view>
|
||||
</view>
|
||||
<view class="m-t-10rpx second-text-28">
|
||||
<text>营业时间</text>
|
||||
<text class="m-l-10rpx">
|
||||
{{ v.jobStartTime }}
|
||||
~
|
||||
{{ v.jobEndTime }}
|
||||
</text>
|
||||
</view>
|
||||
<view v-if="v.addressDes" class="m-t-10rpx second-text-28">
|
||||
<text>食堂地址</text>
|
||||
<text class="m-l-10rpx">{{ v.addressDes }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</z-paging>
|
||||
</crud-layout>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
+38
-13
@@ -5,6 +5,7 @@ import { isEmpty } from "radash"
|
||||
|
||||
import { hooks, router, constant } from "@@/index"
|
||||
import { merchantApi, userApi, walletApi } from "@@/api"
|
||||
import isDevEnv from "@/sheep/utils/isDevEnv"
|
||||
|
||||
const data = {
|
||||
serviceList: [
|
||||
@@ -13,7 +14,6 @@ const data = {
|
||||
{ text: "外来人员就餐", icon: "/static/icon/service_1.png", router: "/pages/apply/foreign-list" },
|
||||
{ text: "跨单位就餐", icon: "/static/icon/service_1.png", router: "/pages/apply/stride-list" },
|
||||
{ text: "人脸管理", icon: "/static/icon/service_5.png", router: "/pages/human-face/list" },
|
||||
{ text: "测试登录", icon: "/static/icon/login.png", router: "/pages/test/login" },
|
||||
],
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ const state = reactive<any>({
|
||||
userInfo: {},
|
||||
})
|
||||
|
||||
onLoad((options) => {
|
||||
// 开发环境可以账号密码登录,生产环境不可
|
||||
const checkAppInfo = () => {
|
||||
;(window as any).CP2.getAppInfo().then((res) => {
|
||||
console.log(res)
|
||||
if (res.code == 1) {
|
||||
//诗画
|
||||
console.log("诗画环境")
|
||||
@@ -34,17 +34,26 @@ onLoad((options) => {
|
||||
doLogin(1, null, accountId, sessionId)
|
||||
})
|
||||
} else {
|
||||
//浙政钉或者h5
|
||||
console.log("浙政钉或者h5环境")
|
||||
const url = window.location.href
|
||||
const params = new URL(url).searchParams
|
||||
const token = params.get("uabaseToken") // 获取 uabaseToken 参数值
|
||||
console.log("Token:", token)
|
||||
// const token =
|
||||
// "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjJiZGQzODE1LWFlMWYtNDFmZi04MTE2LTU3OWVkMjY3MDI5OCJ9.nuCBrYAkGh5-FG8S_ZTe8mcVVORAuUT7bl0qUIspL9gCNtwtcae2D6DhOO8Q2RtVhuFO5IKtOQ65Xd2Vd7pAUg"
|
||||
console.log("uabaseToken:", token)
|
||||
if (null != token) {
|
||||
//浙政钉
|
||||
doLogin(2, token, null, null)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onLoad((options) => {
|
||||
if (isDevEnv()) {
|
||||
data.serviceList.push({ text: "测试登录", icon: "/static/icon/login.png", router: "/pages/test/login" })
|
||||
}
|
||||
checkAppInfo()
|
||||
})
|
||||
onShow(() => {
|
||||
getUserInfo()
|
||||
@@ -80,21 +89,29 @@ const doLogin = async (loginType, token, accountId, sessionId) => {
|
||||
authData = response.data
|
||||
} else if (loginType == 2) {
|
||||
//浙政钉
|
||||
const response = await userApi.auth(token)
|
||||
const response: any = await userApi.auth(token)
|
||||
if (!response) return
|
||||
authData = response.data
|
||||
} else {
|
||||
//后期手机号+验证码登录
|
||||
router.jump("/pages/test/login")
|
||||
if (isDevEnv()) router.jump("/pages/test/login")
|
||||
uni.hideLoading()
|
||||
return
|
||||
}
|
||||
// const {data: authData} = await userApi.auth(token);
|
||||
console.log("authData", authData)
|
||||
|
||||
uni.setStorageSync(tokenKey, authData)
|
||||
const { data: userData } = await userApi.userInfo()
|
||||
uni.setStorageSync(userInfoKey, userData)
|
||||
getUserInfo()
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: "登录成功", icon: "none" })
|
||||
try {
|
||||
const { data: userData } = await userApi.userInfo()
|
||||
uni.setStorageSync(userInfoKey, userData)
|
||||
getUserInfo()
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: "登录成功", icon: "none" })
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: "登录失败", icon: "none" })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,6 +141,14 @@ const doLogout = async () => {
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: "退出登录成功", icon: "none" })
|
||||
}
|
||||
|
||||
const onTabLogin = () => {
|
||||
if (isDevEnv()) {
|
||||
router.jump("/pages/test/login")
|
||||
} else {
|
||||
checkAppInfo()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -143,7 +168,7 @@ const doLogout = async () => {
|
||||
</view>
|
||||
<text class="sub-text-26">ID {{ state.userInfo?.sysUser?.userId }}</text>
|
||||
</view>
|
||||
<view v-else class="flex-row items-center m-l-30rpx" @tap="doLogin">
|
||||
<view v-else class="flex-row items-center m-l-30rpx" @tap="onTabLogin">
|
||||
<text class="sub-text-32">请先登录</text>
|
||||
<text class="iconfont icon-youjiantou"></text>
|
||||
</view>
|
||||
|
||||
@@ -16,7 +16,8 @@ export default {
|
||||
|
||||
auth: (str: any) =>
|
||||
request({
|
||||
url: `/sys/auth/zzdsso/${str}`,
|
||||
// url: `/sys/auth/zzdsso/${str}`,
|
||||
url: `/thirdparty/thirdPartyOAth2/zzdsso/${str}`,
|
||||
method: "GET",
|
||||
custom: {
|
||||
showLoading: false,
|
||||
|
||||
@@ -1,49 +1,50 @@
|
||||
import storageConstant from "../constant/storage-constant";
|
||||
import { jump } from "../router/index";
|
||||
import storageConstant from "../constant/storage-constant"
|
||||
import { jump } from "../router/index"
|
||||
import isDevEnv from "../utils/isDevEnv"
|
||||
|
||||
export const useToken = () => {
|
||||
const tokenKey = storageConstant.TOKEN;
|
||||
const tokenStorage = uni.getStorageSync(tokenKey);
|
||||
if (!tokenStorage.access_token) return "";
|
||||
return `Bearer ${tokenStorage.access_token}`;
|
||||
};
|
||||
const tokenKey = storageConstant.TOKEN
|
||||
const tokenStorage = uni.getStorageSync(tokenKey)
|
||||
if (!tokenStorage.access_token) return ""
|
||||
return `Bearer ${tokenStorage.access_token}`
|
||||
}
|
||||
|
||||
export const useDefaultHeader = () => {
|
||||
const token = useToken();
|
||||
return {
|
||||
"TENANT-ID": "1",
|
||||
"CLIENT-TOC": "Y",
|
||||
Authorization: token,
|
||||
};
|
||||
};
|
||||
const token = useToken()
|
||||
return {
|
||||
"TENANT-ID": "1",
|
||||
"CLIENT-TOC": "Y",
|
||||
Authorization: token,
|
||||
}
|
||||
}
|
||||
|
||||
export const useStaticCheckLogin = () => {
|
||||
const tokenKey = storageConstant.TOKEN;
|
||||
const tokenStorage = uni.getStorageSync(tokenKey);
|
||||
if (tokenStorage) return true;
|
||||
return false;
|
||||
};
|
||||
const tokenKey = storageConstant.TOKEN
|
||||
const tokenStorage = uni.getStorageSync(tokenKey)
|
||||
if (tokenStorage) return true
|
||||
return false
|
||||
}
|
||||
|
||||
export const useCheckLogin = async (): Promise<boolean> => {
|
||||
const tokenKey = storageConstant.TOKEN;
|
||||
const tokenStorage = uni.getStorageSync(tokenKey);
|
||||
if (tokenStorage) return true;
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "您还未登录,请先登录",
|
||||
confirmColor: "#0094ff",
|
||||
cancelText: "取消",
|
||||
confirmText: "去登录",
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
jump("/pages/test/login", {}, 3);
|
||||
return;
|
||||
}
|
||||
if (!res.confirm) {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
},
|
||||
});
|
||||
return false;
|
||||
};
|
||||
const tokenKey = storageConstant.TOKEN
|
||||
const tokenStorage = uni.getStorageSync(tokenKey)
|
||||
if (tokenStorage) return true
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "您还未登录,请先登录",
|
||||
confirmColor: "#0094ff",
|
||||
cancelText: "取消",
|
||||
confirmText: "去登录",
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
isDevEnv() ? jump("/pages/test/login", {}, 3) : jump("/pages/tabbar/my", {}, 3)
|
||||
return
|
||||
}
|
||||
if (!res.confirm) {
|
||||
return
|
||||
}
|
||||
return
|
||||
},
|
||||
})
|
||||
return false
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export default () => import.meta.env.VITE_DEV_ENV === "dev"
|
||||
@@ -3,6 +3,7 @@ import { isEmpty } from "radash"
|
||||
|
||||
import { userApi } from "@@/api"
|
||||
import { router, constant } from "@@/index"
|
||||
import isDevEnv from "./isDevEnv"
|
||||
|
||||
const options = {
|
||||
// 显示操作成功消息 默认不显示
|
||||
@@ -149,7 +150,7 @@ http.interceptors.response.use(
|
||||
const tokenKey = constant.storageConstant.TOKEN
|
||||
uni.removeStorageSync(tokenKey)
|
||||
uni.showToast({ title: "登录已过期,请重新登录", icon: "none" })
|
||||
router.jump("/pages/test/login")
|
||||
isDevEnv() ? router.jump("/pages/test/login") : undefined
|
||||
return false
|
||||
}
|
||||
let errorMessage = error.data.msg
|
||||
|
||||
Reference in new issue
Block a user