20260325稳定版

This commit is contained in:
2026-03-25 15:59:24 +08:00
commit 0decd78604
470 changed files with 53100 additions and 0 deletions
+238
View File
@@ -0,0 +1,238 @@
import {getLocation, getUserInfo, setLocation} from "@/util/user";
import {API, MAIN_API} from "@/config";
import {get} from "@/api/request";
import {areaInfoByNameReq, areaInfoReq} from "@/api/common";
export const ORDER_STATUS_LIST = ['已取消', '进行中', '已完成', '申请退款中', '退款完成', '退款失败']
export const CHECK_STATUS_LIST = [
{
label: '审核中',
color: 'info'
},
{
label: '审核通过',
color: 'success'
},
{
label: '审核拒绝',
color: 'error'
},
{
label: '已到账',
color: 'success'
},
]
export const chooseImg = (limit = 1, sourceType = ['album', 'camera']) => {
return new Promise(resolveMain => {
const {token} = getUserInfo()
uni.chooseImage({
count: limit,
sourceType,
extension: ['png', 'jpg', 'jpeg'],
sizeType: ['compressed'],
success: ({tempFiles}) => {
const resList = []
tempFiles.forEach(file => {
console.log('file', file)
const res = new Promise(resolve => {
uni.uploadFile({
url: `${MAIN_API}/api/oss/upload`,
name: 'file',
filePath: file.path,
header: {
Authorization: token,
TenantId: 10543
},
formData: {
file: file
},
success: uploadRes => {
const {data} = JSON.parse(uploadRes.data)
resolve({
path: data.url,
})
}
})
})
resList.push(res)
})
Promise.all(resList).then(result => {
resolveMain(result)
})
}
})
})
}
export const uploadImg = filePath => {
const {token} = getUserInfo()
uni.showLoading({title: '上传中'})
return new Promise(resolve => {
uni.uploadFile({
url: `${MAIN_API}/api/file/upload`,
name: 'file',
filePath,
header: {
Authorization: token,
TenantId: 10543
},
formData: {
type: 'header'
},
success: uploadRes => {
uni.hideLoading()
const {data: {url}} = JSON.parse(uploadRes.data)
resolve({
path: url,
})
}
})
})
}
export const getLocationAction = (save = true) => {
return new Promise((resolve, reject) => {
const res = getLocation()
if (res.area_id) resolve(res)
else {
uni.authorize({
scope: 'scope.userLocation',
success: () => {
uni.getLocation({
isHighAccuracy: true,
success: async ({longitude, latitude}) => {
const {result} = await get(`https://api.tianditu.gov.cn/geocoder?postStr={'lon':${longitude},'lat':${latitude},'ver':1}&type=geocode&tk=1099ec280e86f4e9b632173326cde90b`)
const areaRes = await areaInfoByNameReq({name: result.addressComponent.county}).catch(() => {
if (!this.areaId) reject(false)
})
if (save) setLocation({
longitude,
latitude,
province_str: result.addressComponent.province,
city_str: result.addressComponent.city,
area_str: result.addressComponent.county,
area_id: areaRes.data.id,
city_id: areaRes.data.fid,
province_id: areaRes.data.city.fid
})
resolve({
longitude,
latitude,
area_id: areaRes.data.id,
city_id: areaRes.data.fid,
province_id: areaRes.data.city.fid,
province_str: result.addressComponent.province,
city_str: result.addressComponent.city,
area_str: result.addressComponent.county,
})
},
fail: () => {
reject(false)
}
})
},
fail: () => {
uni.showModal({
title: '提示',
content: '为了更好的提供服务,请开启定位服务',
success: ({confirm}) => {
if (confirm) uni.openSetting()
}
})
}
})
}
})
}
export const chooseVideo = (sourceType = ['album', 'camera']) => {
return new Promise((resolveMain, reject) => {
uni.chooseVideo({
sourceType,
compressed: true,
maxDuration: 60,
success: async ({tempFilePath, duration, size}) => {
if (duration > 180) {
uni.showToast({
title: '暂时不支持3分钟以上的视频',
icon: 'none'
})
return reject(false)
}
// 50M限制
if (size > 50 * 1024 * 1024) {
uni.showToast({
title: '暂时不支持50M以上的视频',
icon: 'none'
})
return reject(false)
}
const {token} = getUserInfo()
uni.showLoading({title: '上传中...'})
uni.uploadFile({
url: `${MAIN_API}/api/file/upload`,
name: 'file',
filePath: tempFilePath,
header: {
Authorization: token
},
success: uploadRes => {
const {data} = JSON.parse(uploadRes.data)
uni.hideLoading()
resolveMain({
path: data.url,
})
}
})
}
})
})
}
export const getLocationOnly = () => {
return new Promise((resolve, reject) => {
uni.authorize({
scope: 'scope.userLocation',
success: () => {
uni.getLocation({
isHighAccuracy: true,
success: async ({longitude, latitude}) => {
const {result} = await get(`https://api.tianditu.gov.cn/geocoder?postStr={'lon':${longitude},'lat':${latitude},'ver':1}&type=geocode&tk=1099ec280e86f4e9b632173326cde90b`)
const {data} = await areaInfoByNameReq({name: result.addressComponent.county}).catch(() => {
if (!this.areaId) reject(false)
})
resolve({
longitude,
latitude,
area_id: data.id,
city_id: data.fid,
province_id: data.city.fid,
province_str: result.addressComponent.province,
city_str: result.addressComponent.city,
area_str: result.addressComponent.county,
})
},
fail: () => {
uni.setStorageSync("no_more_realtime_location", 1)
reject(false)
}
})
},
fail: err => {
uni.showModal({
title: '提示',
content: '为了更好的提供服务,请开启定位服务',
success: ({confirm}) => {
if (confirm) uni.openSetting()
}
})
}
})
})
}
export const getExpressMode = () => parseInt(uni.getStorageSync("express_mode"))
+100
View File
@@ -0,0 +1,100 @@
import {BLUE, BLUE_LIGHT, GREEN, ORANGE, RED} from "@/config/color";
// -1已取消、0待付款、1待发货/配送中、2待收货、3已完成、4退款中、5退款成功、6退款失败
export const ORDER_STATUS_LIST = [
{
label: '已取消',
value: -1,
color: '#BBB',
},
{
label: '待付款',
value: 0,
color: RED,
},
{
label: '配送中',
value: 1,
color: BLUE_LIGHT,
},
{
label: '待收货',
value: 2,
color: BLUE,
},
{
label: '已完成',
value: 3,
color: GREEN,
},
{
label: '退款中',
value: 4,
color: '#F9A8D4',
},
{
label: '退款成功',
value: 5,
color: '#DB2777',
},
{
label: '退款失败',
value: 6,
color: '#831843',
},
]
export const EXPRESS_ORDER_STATUS_LIST = [
{
label: '已取消',
value: -1,
color: '#BBB',
},
{
label: '待支付',
value: 0,
color: RED,
},
{
label: '待接单',
value: 1,
color: BLUE_LIGHT,
},
{
label: '配送中',
value: 2,
color: BLUE,
},
{
label: '待确认',
value: 20,
color: BLUE,
},
{
label: '已完成',
value: 3,
color: GREEN,
},
{
label: '退款中',
value: 4,
color: '#F9A8D4',
},
{
label: '退款成功',
value: 5,
color: '#DB2777',
},
{
label: '退款失败',
value: 6,
color: '#831843',
},
]
export const getOrderStatusItem = (type, orderStatus) => {
if ([1, 2, 3, 4, 5].includes(type))
return EXPRESS_ORDER_STATUS_LIST.filter(item => item.value === orderStatus)[0]
else return ORDER_STATUS_LIST.filter(item => item.value === orderStatus)[0]
}
+51
View File
@@ -0,0 +1,51 @@
import {MAIN_API} from "@/config";
export const setLocation = ({latitude, longitude, province_str, city_str, area_str, area_id, city_id, province_id}) => {
if (latitude) uni.setStorageSync("latitude", latitude)
if (longitude) uni.setStorageSync("longitude", longitude)
uni.setStorageSync("province_str", province_str)
uni.setStorageSync("city_str", city_str)
uni.setStorageSync("area_str", area_str)
uni.setStorageSync("area_id", area_id)
uni.setStorageSync("city_id", city_id)
uni.setStorageSync("province_id", province_id)
}
export const getLocation = () => {
return {
latitude: uni.getStorageSync("latitude"),
longitude: uni.getStorageSync("longitude"),
province_str: uni.getStorageSync("province_str"),
city_str: uni.getStorageSync("city_str"),
area_str: uni.getStorageSync("area_str"),
area_id: uni.getStorageSync("area_id"),
city_id: uni.getStorageSync("city_id"),
province_id: uni.getStorageSync("province_id")
}
}
export const setUserInfo = (user) => {
if (user.uid) uni.setStorageSync("uid", user.uid)
if (user.username) uni.setStorageSync("username", user.username)
if (user.token) uni.setStorageSync("token", user.token)
if (user.header) uni.setStorageSync("header", `${MAIN_API}${user.header}`)
if (user.phone) uni.setStorageSync("phone", user.phone)
}
export const getUserInfo = () => {
return {
uid: uni.getStorageSync("uid"),
username: uni.getStorageSync("username"),
token: uni.getStorageSync("token"),
header: uni.getStorageSync("header"),
phone: uni.getStorageSync("phone"),
}
}
export const clearUserInfo = () => {
uni.removeStorageSync("uid");
uni.removeStorageSync("username");
uni.removeStorageSync("token");
uni.removeStorageSync("header");
uni.removeStorageSync("phone");
}