first commit

This commit is contained in:
Ls
2026-02-12 12:19:20 +08:00
commit 219fd9be5c
529 changed files with 169918 additions and 0 deletions

View File

@@ -0,0 +1,225 @@
<template>
<view class="home">
<view class=""
style=" margin-top: 200rpx; display: flex; flex-direction: column; justify-content: center; align-items: center;">
<image :src="Service.GetIconImg('/static/index/logo/logo.png')" style="width: 150rpx; height: 150rpx; "
mode=""></image>
<view class="" style="font-size: 36rpx; font-weight: 800; margin-top: 20rpx;">
菜农·骑手端
</view>
</view>
<view class="" style="margin: 30rpx 30rpx; margin-top: 150rpx;">
<view class="" style="font-size: 34rpx; font-weight: 600; ">
欢迎登陆
</view>
<view class="" style="font-size: 28rpx; margin-top: 20rpx; ">
手机号登录,安全又便捷
</view>
<view v-if="type" class="" >
<view class="" style="margin-top: 30rpx;">
<up-input v-model="login.phone" type="number" shape='circle'
:customStyle="{'padding':'20rpx 30rpx','font-size':'32rpx'}" placeholder="请输入手机号"
clearable='true' border="surround"></up-input>
</view>
<view class="" style="margin-top: 30rpx;">
<up-input v-model="login.password" type="password" shape='circle'
:customStyle="{'padding':'20rpx 30rpx','font-size':'32rpx'}" placeholder="请输入密码"
clearable='true' border="surround"></up-input>
</view>
<view class="" style="margin-top: 30rpx;" v-if="!isLogin">
<up-input v-model="qudPow" type="password" shape='circle'
:customStyle="{'padding':'20rpx 30rpx','font-size':'32rpx'}" placeholder="确认密码"
clearable='true' border="surround"></up-input>
</view>
<!-- <view class=""
style=" display: flex; align-items: center; justify-content: space-between; margin-top: 30rpx; border: 1rpx solid #dadbde; box-sizing: border-box; padding: 20rpx 30rpx; border-radius: 200rpx; ">
<up-code-input v-model="login.code" mode="line" size='24'></up-code-input>
<view class="wrap">
<up-toast ref="uToastRef"></up-toast>
<up-code :seconds="seconds" @end="end" @start="start" ref="uCodeRef"
@change="codeChange"></up-code>
<view @click="getCode">{{tips}}</view>
</view>
</view> -->
</view>
<!-- <view v-else class="">
<view class="" style="margin-top: 30rpx;">
<up-input v-model="login.phone" type="number" shape='circle'
:customStyle="{'padding':'20rpx 30rpx','font-size':'32rpx'}" placeholder="请输入账号"
clearable='true' border="surround"></up-input>
</view>
<view class="" style="margin-top: 30rpx;">
<up-input v-model="login.phone" type="number" shape='circle'
:customStyle="{'padding':'20rpx 30rpx','font-size':'32rpx'}" placeholder="请输入密码"
clearable='true' border="surround"></up-input>
</view>
</view> -->
<view class="" style="margin-top: 40rpx; width: 100%; height: 80rpx; line-height: 80rpx; border-radius: 40rpx; background-color: #FFDE1D; color: #fff; font-size: 30rpx; text-align: center;" @click="loginshop()">
登录
</view>
<view class="" style="width: 90%; margin: 0 auto; margin-top: 20rpx; display: flex; justify-content: space-between; color: #999; font-size: 28rpx;">
<view class="">
忘记密码
</view>
<view class="" @click="isLogin = !isLogin">
{{isLogin?'去注册':'已有账号去登录'}}
</view>
</view>
<!-- <view class="" @click="type=!type" style="text-align: center; color: #637aff; margin: 50rpx 0; ">
{{ !type?'使用验证码登录':'使用密码登录' }}
</view> -->
<view class="" style="display: flex; justify-content: center; align-items: center;color: black; margin-top: 50rpx; " @click="isuser= !isuser">
<view class="" style="margin-right: 10rpx;">
<up-icon :name="!isuser?'checkmark-circle':'checkmark-circle-fill'" :color="!isuser?'#999':'var(--nav-mian)'" size="20"></up-icon>
</view>
我同意
<text style="color: #FF6B23;">《用户协议》</text>
<text style="color: #FF6B23;">《隐私政策》</text>
</view>
<view class="" style="text-align: center; margin-top: 20rpx;">
<!-- 新用户?系统将自动为您注册 -->
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { onShow, onLoad } from "@dcloudio/uni-app";
import { Service ,CNRiderLoginService } from "@/Service/CN/CNRiderLoginService"
import { ref } from "vue";
let qudPow = ref<string>('')
let login = ref({
phone: '',
code: '',
password:''
})
const tips = ref('');
const seconds = ref(60);
const uCodeRef = ref(null);
let type = ref(true)
let isLogin = ref<boolean>(true)//登录注册状态
let isuser = ref<boolean>(false)//用户同意协议
onLoad(() => {
});
onShow(() => {
});
//登录
const loginshop = () =>{
if(login.value.phone==''){
return Service.Msg('请输入手机号/账号!')
}
if(login.value.password==''){
return Service.Msg('请输入密码!')
}
if(!isLogin.value && qudPow.value==''){
return Service.Msg('请确认密码!')
}
if(!isLogin.value && login.value.password!=qudPow.value){
return Service.Msg('两次密码不同!')
}
console.log(isuser.value)
if(!isuser.value){
return Service.Msg('请勾选同意用户协议!')
}
CNRiderLoginService.RiderLogin(login.value).then(res=>{
if(res.code==0){
Service.Msg('登录成功!')
Service.SetUserToken(res.data.accToken)
if(res.data.type==-1){
Service.GoPage('/pages/my/completeData')
}else{
Service.GoPageTab('/pages/index/index')
}
}else{
Service.Msg(res.msg)
}
})
}
const codeChange = (text) => {
tips.value = text;
};
const getCode = () => {
if (uCodeRef.value.canGetCode) {
// 模拟向后端请求验证码
uni.showLoading({
title: '正在获取验证码',
});
setTimeout(() => {
uni.hideLoading();
// 这里此提示会被start()方法中的提示覆盖
Service.Msg('验证码已发送')
// 通知验证码组件内部开始倒计时
uCodeRef.value.start();
}, 2000);
} else {
Service.Msg('倒计时结束后再发送')
}
};
const end = () => {
console.log('倒计时结束');
};
const start = () => {
console.log('倒计时开始');
};
</script>
<style lang="scss">
.home {
width: 100vw;
height: 100vh;
background: linear-gradient(to bottom, #FFDE1D, #fff 40%);
overflow: hidden;
}
.chen{
}
</style>

View File

@@ -0,0 +1,331 @@
import { HttpRequest, StoreAssist, UploadAssist, ResultData } from '@/common/Common';
import { BaseConfig } from './BaseConfig';
export class Service extends BaseConfig {
//获取API地址
static ApiUrl(path : string) {
return `${this.servesUrl}${path}`;
}
//获取图片地址
static GetpayImg(path : string) {
if (path.startsWith('http') || path.startsWith('https')) {
return path;
} else {
return `${this.payuploadUrl}${path}`;
}
}
//获取图标地址
static GetIconImg(path : string) {
return path
if (path.startsWith('http') || path.startsWith('https')) {
return path;
} else {
return `${this.imgUrl}${path}`;
}
}
//获取图片地址
static GetMateUrlByImg(path : string) {
return path
if (path.startsWith('http') || path.startsWith('https')) {
return path;
} else {
return `${this.imgUrl}${path}`;
}
}
//获取音视频地址
static GetMateUrlByMedia(path : string) {
if (path.startsWith('http') || path.startsWith('https')) {
return path;
} else {
return `${this.mediaUrl}${path}`;
}
}
//获取登录账号token
static GetUserToken() {
return Service.GetStorageCache('token');
}
// 获取登录状态
static GetUserIsLogin() {
var token = this.GetUserToken();
if (token == null || token == '') {
return false;
} else {
return true;
}
}
//设置登录账户Token
static SetUserToken(token : string) {
this.SetStorageCache('token', token);
}
//清理登录账户Token
static OffUserToken() {
Service.DelStorageCache('token');
uni.$emit('ImComOff', 'user');
this.ClearUserStateData();
}
//获取登录账号状态信息
static GetUserStateData() {
return Service.GetStorageCache('StateDomain');
}
//设置当前登录账号状态信息
static SetUserStateData() {
return Service.GetStorageCache('StateDomain');
}
//清理当前登录账号状态信息
static ClearUserStateData() {
Service.DelStorageCache('StateDomain');
}
//获取缓存
static GetStorageCache(key : string) {
return StoreAssist.Get(key);
}
//删除缓存
static DelStorageCache(key : string) {
StoreAssist.Delete(key);
}
//设置缓存
static SetStorageCache(key : string, data : any) {
StoreAssist.Set(key, data);
}
/*****以下是基础方法调用与拦截器*****/
static Request(url : string, method : 'GET' | 'POST' | 'PUT' | undefined, data : object | any) {
const token = Service.GetUserToken();
const _url = Service.ApiUrl(url);
var result = HttpRequest.RequestWithToken(_url, method, token, data).then((retResult : any) => {
if (retResult.statusCode == '200') {
var obj = retResult.data;
if (obj.code == 401) {
//过期
this.OffUserToken();
this.Msg('登录过期,请重新登录')
this.GoPage('/pages/my/login')
return Promise.reject();
} else if (obj.code == 40101) {
//失效
this.OffUserToken();
this.GoPageDelse('/pages/mine/login/login');
return Promise.reject();
} else if (obj.code == 1004) {
//资源不存在
this.GoPageDelse('/pages/AppSet/404/404');
return Promise.reject();
// return new ResultData(-1, '', '');
} else if (obj.code == 40188) {
//无权限
this.GoPageDelse('/pages/AppSet/40188/40188');
return Promise.reject();
// return new ResultData(-1, '', '');
} else if (obj.code == 1008) {
//业务提示
return new ResultData(obj.code, obj.msg, obj.data);
} else {
return new ResultData(obj.code, obj.msg, obj.data);
}
} else {
return new ResultData(-1, '', '');
}
});
return result;
}
/*****以下是腾讯云oss上传*****/
static UpLoadMedia(code : string, fileName : string, desire : string, path : string) {
var result = this.Request(this.uploadUrl, 'GET', { code, fileName, desire }).then((retResult) => {
if (retResult.code == 0) {
var upOk = UploadAssist.Upload(retResult.data.url, path, retResult.data.cosData).then((upRet : any) => {
if (upRet.statusCode == 200) {
const retData : any = { code: retResult.data.code, file: retResult.data.file, cache: retResult.data.cache };
return new ResultData(0, '上传成功!', retData);
} else {
this.Msg('上传失败!');
return new ResultData(-1, '', '');
}
});
return upOk;
} else {
this.Msg('上传失败!');
return new ResultData(-1, retResult.msg,retResult.data);
}
});
return result;
}
/***********消息操作**************/
static Msg(message : any, icon ?: any) : void {
if (icon != null) {
uni.showToast({
title: message,
icon: icon
});
} else {
uni.showToast({
title: message,
icon: 'none'
});
}
}
static Alert(msg : string, cb ?: any) {
uni.showModal({
title: '提示',
content: msg,
showCancel: false,
cancelText: '取消',
confirmText: '确定',
success: res => {
if (res.confirm) {
cb && cb();
}
}
})
}
static LoadIng(text : any) : void {
uni.showLoading({
title: text,
icon: 'none'
});
}
static LoadClose() : void {
uni.hideLoading();
}
/**********跳转操作*********/
static GoPageTab(path : string) : void {
uni.switchTab({
url: path
});
}
/**********跳转操作*********/
static GoPage(path : string) : void {
uni.navigateTo({
url: path, //跳转的页面
success: function (res) {
// 通过eventChannel向被打开页面传送数据
}
});
}
/**********跳转并删除当前页面操作*********/
static GoPageDelse(path : string) : void {
uni.redirectTo({
url: path //跳转的页面
});
}
/**********返回上一页*********/
static GoPageBack() : void {
uni.navigateBack({ delta: 1 });
}
/*****获取图片base64*****/
static UpLoadMediaBase64(path : string) {
return new Promise(function (resolve, reject) {
uni.uploadFile({
url: 'http://cloud.pccsh.com/DefUp/UploadFileImgBase64', //仅为示例,非真实的接口地址
filePath: path,
name: 'file',
success: (uploadFileRes) => {
resolve(uploadFileRes);
},
fail: (err) => {
reject(err);
}
});
});
}
/*****获取图片位置信息*****/
//获取时间戳
static GetTimeSpan(milliSecond : number) {
return Date.now() + milliSecond;
}
// 时间戳处理
static formatDate(time : any, type : number) : string {
const date = new Date(time);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始所以加1并用0填充
const day = String(date.getDate()).padStart(2, '0'); // 用0填充
const hours = String(date.getHours()).padStart(2, '0'); // 用0填充
const minutes = String(date.getMinutes()).padStart(2, '0'); // 用0填充
const seconds = String(date.getSeconds()).padStart(2, '0'); // 用0填充
if (type == 0) {
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
else if (type == 1) {
return `${year}-${month}-${day} ${hours}:${minutes}`;
} else if (type == 2) {
return `${year}-${month}-${day}`;
} else if (type == 3) {
return `${hours}:${minutes}`;
} else if (type == 4) {
return `${year}${month}${day}`;
}
else {
return `${hours}:${minutes}`;
}
}
/*****节流*****/
static throttle(fn: () => void, time: number) {
let canRun: boolean = true;
return function () {
if (!canRun) return;
canRun = false;
setTimeout(() => {
fn(); //可以不执行
canRun = true;
}, time);
};
}
/*****防抖*****/
static debounce<T extends (...args: any[]) => void>(fn: T, time: number): (...args: Parameters<T>) => void {
let timerId: NodeJS.Timeout | null = null;
return (...args: Parameters<T>) => {
if (timerId) {
clearTimeout(timerId);
}
timerId = setTimeout(() => {
fn(...args); // 执行传入的函数
timerId = null; // 清除定时器ID
}, time);
};
}
// 普通图片上传
static uploadH5(path, dic, callback) {
console.log(this.payuploadUrl,'xxx')
uni.uploadFile({
url: this.payuploadUrl+'/Upload/Upload',
method: "POST",
header: {
'Authorization': 'Bearer ' + Service.GetUserToken(),
},
formData: {
"path": dic,
},
filePath: path,
name: 'file',
success: (data) => {
let info = data.data
callback(info)
}
})
}
}