提交 83f41262 作者: guolinhua

feat:更新

# API 接口地址
# VITE_GLOB_API_URL=http://111.22.182.169:49600
VITE_GLOB_API_URL=http://36.133.16.81:42111
VITE_GLOB_API_URL=http://111.22.182.169:49600
# VITE_GLOB_API_URL=http://36.133.16.81:42111
# API 接口地址前缀
VITE_GLOB_API_URL_PREFIX=/jeecg-boot
VITE_GLOB_API_URL_PREFIX=/jeecgboot
{
"name": "湖南省农业服务平台",
"version": "1.0.4",
"version": "1.0.7",
"description": "数智农服",
"keywords": [
"app",
......@@ -79,22 +79,22 @@
"@dcloudio/uni-mp-toutiao": "3.0.0-4060620250520001",
"@dcloudio/uni-mp-weixin": "3.0.0-4060620250520001",
"@dcloudio/uni-quickapp-webview": "3.0.0-4060620250520001",
"@dcloudio/uni-ui": "^1.5.7",
"@faker-js/faker": "^9.8.0",
"@dcloudio/uni-ui": "^1.5.11",
"@faker-js/faker": "^9.9.0",
"@vant/area-data": "^2.1.0",
"@vue/runtime-core": "3.4.21",
"@vueuse/core": "^12.3.0",
"@vueuse/shared": "^12.3.0",
"axios": "^1.9.0",
"@vueuse/core": "^10.11.1",
"@vueuse/shared": "^11.3.0",
"axios": "^1.13.1",
"crypto-js": "^4.2.0",
"dayjs": "^1.11.13",
"dayjs": "^1.11.19",
"dayjs-plugin-lunar": "^1.4.1",
"lodash-es": "^4.17.21",
"nanoid": "^5.1.5",
"nanoid": "^5.1.6",
"pinia": "2.0.36",
"qs": "6.9.7",
"stompjs": "^2.3.3",
"tyme4ts": "^1.3.7",
"tyme4ts": "^1.3.8",
"urijs": "^1.19.11",
"vue": "3.4.21",
"vue-demi": "^0.14.10",
......@@ -106,49 +106,49 @@
"@antfu/eslint-config": "^0.43.1",
"@commitlint/cli": "^19.8.1",
"@commitlint/config-conventional": "^19.8.1",
"@dcloudio/types": "^3.4.15",
"@dcloudio/types": "^3.4.28",
"@dcloudio/uni-automator": "3.0.0-4060620250520001",
"@dcloudio/uni-cli-shared": "3.0.0-4060620250520001",
"@dcloudio/uni-helper-json": "^1.0.13",
"@dcloudio/uni-stacktracey": "3.0.0-4060620250520001",
"@dcloudio/uni-uts-v1": "3.0.0-4060620250520001",
"@dcloudio/vite-plugin-uni": "3.0.0-4060620250520001",
"@iconify/json": "^2.2.345",
"@iconify/json": "^2.2.403",
"@types/crypto-js": "^4.2.2",
"@types/lodash-es": "^4.17.12",
"@types/node": "^22.15.29",
"@types/node": "^22.19.0",
"@types/qs": "^6.14.0",
"@types/stompjs": "^2.3.9",
"@types/urijs": "^1.19.25",
"@types/urijs": "^1.19.26",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"commitizen": "^4.3.1",
"conventional-changelog-cli": "^5.0.0",
"cz-conventional-changelog": "^3.3.0",
"cz-customizable": "^7.4.0",
"cz-git": "^1.11.1",
"czg": "^1.11.1",
"dotenv": "^16.5.0",
"cz-customizable": "^7.5.1",
"cz-git": "^1.12.0",
"czg": "^1.12.0",
"dotenv": "^16.6.1",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.4.1",
"eslint-config-prettier": "^9.1.2",
"eslint-plugin-prettier": "^5.5.4",
"eslint-plugin-vue": "^9.33.0",
"husky": "^8.0.3",
"jest": "27.0.4",
"jest-environment-node": "27.5.1",
"less": "^4.3.0",
"lint-staged": "^16.1.0",
"less": "^4.4.2",
"lint-staged": "^16.2.6",
"npm-run-all": "^4.1.5",
"picocolors": "^1.1.1",
"pont-engine": "^1.6.3",
"postcss": "^8.5.4",
"postcss": "^8.5.6",
"postcss-html": "^1.8.0",
"postcss-less": "^6.0.0",
"prettier": "^3.5.3",
"rimraf": "^6.0.1",
"sass": "^1.89.1",
"sort-package-json": "^3.2.1",
"stylelint": "^16.20.0",
"prettier": "^3.6.2",
"rimraf": "^6.1.0",
"sass": "^1.93.3",
"sort-package-json": "^3.4.0",
"stylelint": "^16.25.0",
"stylelint-config-html": "^1.1.0",
"stylelint-config-recommended": "^14.0.1",
"stylelint-config-standard": "^36.0.1",
......@@ -158,7 +158,7 @@
"unocss-preset-weapp": "^0.58.9",
"unplugin-auto-import": "^0.17.8",
"unplugin-vue-components": "^0.28.0",
"vite": "^5.4.19",
"vite": "^5.4.21",
"vue-eslint-parser": "^9.4.3"
},
"engines": {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2,12 +2,6 @@
import { onExit } from '@dcloudio/uni-app'
import { isDevMode } from '@/utils/env'
import { usePermissions } from '@/hooks/app/usePermissions'
import * as UserInfoAPI from '@/api/model/userInfo'
import { useDictStore } from '@/store/modules/dict'
import { useUserStore } from '@/store/modules/user'
const userStore = useUserStore()
const dictStore = useDictStore()
// import * as Push from '@/utils/push'
......@@ -35,13 +29,6 @@
}
// #endif
})
function getDictList() {
if (!userStore.getToken) return
if (Object.keys(dictStore.getDictList).length !== 0) return
UserInfoAPI.dictList().then((res) => {
dictStore.setDictList(res)
})
}
onExit(() => {
// 停用监听权限
......@@ -50,7 +37,6 @@
onShow(() => {
console.log('App Show')
getDictList()
})
onHide(() => {
......@@ -58,7 +44,7 @@
})
onError((err) => {
// Message.toast(`App Error: ${err}`)
Message.toast(`App Error: ${err}`)
console.error('App Error:', err)
})
......
......@@ -4,7 +4,8 @@ import { otherHttp } from '/@/utils/http/axios'
enum Api {
farmMachineList = '/farmMachine/machineWork/app/list', // 农机服务列表列表
farmMachineDetails = '/farmMachine/machineWork/queryById', // 农机服务详情
farmMachineAdd = '/farmMachine/machineWork/app/register', // 发布农机服务
farmMachineAddMachine = '/farmMachine/machineWork/app/addMachine', // 发布农机服务
farmMachineAddFarm = '/farmMachine/machineWork/app/addFarm', // 发布农活服务
farmMachineEdit = '/farmMachine/machineWork/edit', // 编辑农机服务
}
......@@ -40,9 +41,19 @@ export function farmMachineDetails(params = {}) {
* @param params 请求参数
* @description: 发布农机服务
*/
export function farmMachineAdd(params = {}) {
export function farmMachineAddMachine(params = {}) {
return otherHttp.post({
url: Api.farmMachineAdd,
url: Api.farmMachineAddMachine,
params,
})
}
/**
* @param params 请求参数
* @description: 发布农活服务
*/
export function farmMachineAddFarm(params = {}) {
return otherHttp.post({
url: Api.farmMachineAddFarm,
params,
})
}
......
import { otherHttp } from '/@/utils/http/axios'
enum Api {
bizCommonFileList = '/mine/bizCommonFile/list', // 文件列表
}
/**
* @param params 请求参数
* @description: 文件列表
*/
export function bizCommonFileList(params = {}) {
return otherHttp.get({
url: Api.bizCommonFileList,
params,
})
}
{
"name" : "数智农服",
"appid" : "__UNI__290B7FC",
"appid" : "__UNI__FD09823",
"description" : "数智农服 APP",
"versionName" : "1.0.4",
"versionCode" : 10005,
"versionName" : "1.0.7",
"versionCode" : 10007,
"transformPx" : false,
"locale" : "zh-Hans",
"vueVersion" : "3",
......@@ -28,7 +28,10 @@
/* 模块配置 */
"modules" : {
"Geolocation" : {},
"Camera" : {}
"Camera" : {},
"VideoPlayer" : {},
"Barcode" : {},
"Bluetooth" : {}
},
/* 应用发布信息 */
"distribute" : {
......
......@@ -168,6 +168,32 @@
}
},
{
"path": "pages/nongjifuwu/machine-form",
"style": {
"navigationBarTitleText": "农机查看/新增",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#5DB66F",
"navigationBarTextStyle": "white",
"backgroundColorBottom": "#F2F2F2",
"app-plus": {
"titleNView": {}
}
}
},
{
"path": "pages/nongjifuwu/farm-form",
"style": {
"navigationBarTitleText": "农活查看/新增",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#5DB66F",
"navigationBarTextStyle": "white",
"backgroundColorBottom": "#F2F2F2",
"app-plus": {
"titleNView": {}
}
}
},
{
"path": "pages/linghuoyonggong/linghuoyonggong",
"style": {
"navigationBarTitleText": "灵活用工",
......@@ -254,12 +280,14 @@
{
"path": "pages/common/about/index",
"style": {
"navigationBarTextStyle": "white",
"navigationBarTitleText": "关于我们"
}
},
{
"path": "pages/common/feedback/index",
"style": {
"navigationBarTextStyle": "white",
"navigationBarTitleText": "问题反馈"
}
},
......@@ -272,6 +300,7 @@
{
"path": "pages/common/viewer/pdf",
"style": {
"navigationBarTextStyle": "white",
"navigationBarTitleText": ""
}
},
......@@ -279,6 +308,7 @@
"path": "pages/common/coding/coding",
"style": {
"titleNView": false,
"navigationBarTextStyle": "white",
"navigationBarTitleText": "开发中"
}
},
......@@ -326,8 +356,8 @@
}
},
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarTextStyle": "white",
"navigationBarTitleText": "",
"navigationBarBackgroundColor": "#5DB66F",
"backgroundColor": "#5DB66F",
"backgroundColorTop": "#5DB66F",
......
<script setup lang="ts">
import dayjs from 'dayjs'
import Navigate from '@/utils/page/navigate'
import { useRuntime } from '@/hooks/app/useRuntime'
import { checkUpgrade } from '@/utils/upgrade'
const startYear = ref(2005)
const { app } = useRuntime()
const version = computed(() => app.value.version)
const currentYear = ref(dayjs().year())
const { privacy, services, copyright, company } = Navigate.links
</script>
......@@ -19,7 +22,8 @@
<text class="underline" @tap="Navigate.webview(services, '服务协议')">服务协议</text>
<text class="underline" @tap="Navigate.webview(privacy, '隐私政策')">隐私政策</text>
</view>
<view class="mt-1">Copyright © {{ startYear }}-{{ currentYear }} {{ copyright.name }}</view>
<view class="mt-1 hidden" v-if="version" @tap="checkUpgrade(true)">V{{ version }}</view>
<view class="mt-2">Copyright © {{ currentYear }} {{ copyright.name }}</view>
<view class="mt-2" v-if="copyright.name !== company.name">
技术支持:
<fui-link underline color="#b2b2b2" size="24" :href="company.link" :text="company.name" />
......
......@@ -272,6 +272,7 @@
function onFarmMachineryServiceClick(service: any) {
console.log('点击农机服务:', service)
// 在这里添加具体的服务点击逻辑
Navigate.to('/pages/nongjifuwu/nongjifuwu?type=' + service.id)
}
// 技能培训点击事件
......
......@@ -8,7 +8,7 @@
const userStore = useUserStore()
onLoad(async () => {
onShow(async () => {
// 获取推送标识并设置 PushClientId 缓存
// uni.getPushClientId({
// success: (res) => {
......@@ -37,6 +37,7 @@
// 跳转到登录页
goHome()
Message.toast(`欢迎回来~`)
} else {
// 关闭启动页并检查更新
try {
......@@ -59,7 +60,7 @@
show: false,
isLogin: false,
loading: false,
text: '',
text: defaultText,
form: {
rules: [
{
......@@ -128,7 +129,7 @@
// 打开登录页
goHome()
Message.toast(`登录成功, 欢迎回来!`)
Message.toast(`登录成功, 欢迎回来~`)
} else {
Message.toast(body.message)
return false
......@@ -153,7 +154,7 @@
// 添加欢迎登录的文字打字动态效果
let loop = null
let direction = 'right'
const count = ref(0)
const count = ref(defaultText.length)
watch(
() => model.show,
(show) => {
......@@ -185,9 +186,12 @@
},
)
onUnload(() => {
model.show = false
onHide(() => {
loop && clearInterval(loop)
loop = null
direction = 'right'
count.value = 0
model.show = false
})
function onReadConfirm(val) {
......@@ -312,7 +316,7 @@
title="服务协议及隐私保护"
:buttons="[
{ text: '不同意', plain: true },
{ text: '同意', plain: false },
{ text: '同意', plain: false, color: '#fff' },
]"
@click="onReadConfirm"
>
......@@ -392,7 +396,7 @@
// position: absolute;
// left: 40rpx;
// bottom: 40rpx;
font-size: 40rpx;
font-size: 38rpx;
color: #474747;
display: flex;
flex-direction: column;
......
......@@ -229,26 +229,7 @@
<fui-list class="rd-3 overflow-hidden shadow !mt-20rpx" :top-border="false">
<fui-list-cell
arrow
v-for="(item, index) in items.slice(2, 6)"
:key="index"
:bottom-border="false"
:class="{ disabled: item.disabled }"
v-show="item.show"
@tap="item.handle(item)"
>
<CacheImage
:src="`/static/images/mine/${item.icon}.png`"
width="42"
height="42"
background="transparent"
/>
<text class="ml-3.5 text-30 text-#333333 font-500">{{ item.title }}</text>
</fui-list-cell>
</fui-list>
<fui-list class="rd-3 overflow-hidden shadow !mt-20rpx" :top-border="false">
<fui-list-cell
arrow
v-for="(item, index) in items.slice(7, 10)"
v-for="(item, index) in items.slice(2, 10)"
:key="index"
:bottom-border="false"
class="pos-relative"
......
......@@ -286,6 +286,10 @@
function onBaseManagementClick(item: any) {
console.log('点击基地管理项:', item)
// 在这里添加具体的基地管理点击逻辑
uni.navigateTo({
url: '/pages/jidiguanli/jidiguanli',
})
}
// 查看更多监测预警
......@@ -311,7 +315,7 @@
// 在这里添加具体的查看逻辑
// 跳转到灵活用工界面
Navigate.to('/pages/linghuoyonggong/linghuoyonggong?type=' + type)
Navigate.to(`/pages/linghuoyonggong/linghuoyonggong?type=${type}`)
}
// 查看金融服务
......@@ -345,9 +349,9 @@
}
// 解决轮播视频切换时,上一个视频不停止播放的问题
const handleVideoPlay = (currentIndex) => {
function handleVideoPlay(currentIndex) {
pageData.agricultureClass.videoList.forEach((_, index) => {
if (index != currentIndex) {
if (index !== currentIndex) {
const videoContext = uni.createVideoContext(`video${index}`)
videoContext.pause()
}
......@@ -477,7 +481,7 @@
<view class="codefun-flex-col group_15">
<view class="codefun-flex-row codefun-justify-between codefun-items-baseline">
<text class="font text_28">基地管理</text>
<text class="font_6 text_29">更多</text>
<text class="font_6 text_29" @click="onBaseManagementClick">更多</text>
</view>
<view class="codefun-flex-row equal-division_5 mt-17">
<view
......@@ -679,7 +683,7 @@
>
<swiper-item v-for="(video, index) in pageData.agricultureClass.videoList" :key="index">
<video
:id="'video' + index"
:id="`video${index}`"
:src="video.media_video"
:poster="video.cover_image"
:controls="false"
......
<script setup lang="ts">
import { reactive } from 'vue'
import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong'
import { useUserStore } from '@/store/modules/user'
const { getUserInfo } = useUserStore()
const pageData = reactive({
show: false,
content: '',
form: {
employmentId: '',
userId: '',
reservedname: null,
reservedmobile: null,
},
rules: [
{
name: 'reservedname',
rule: ['required'],
msg: ['请输入预留姓名'],
},
{
name: 'reservedmobile',
rule: ['required', 'isMobile'],
msg: ['请输入预留手机', '请输入正确的手机号'],
},
],
})
function open(params) {
pageData.form.employmentId = params.id
pageData.form.userId = getUserInfo.id
pageData.show = true
}
function close() {
pageData.show = false
}
function reset() {
pageData.form = {
employmentId: '',
userId: '',
reservedname: null,
reservedmobile: null,
}
}
const formRef = ref()
function submit() {
formRef.value.validator(pageData.form, pageData.rules, true).then((res) => {
if (res.isPassed) {
LinghuoyonggongAPI.employmentRegister(pageData.form).then(() => {
reset()
close()
uni.showToast({
title: '报价成功',
icon: 'success',
})
})
}
})
}
defineExpose({
open,
close,
})
</script>
<template>
<fui-dialog title="" :buttons="[]" :show="pageData.show" maskClosable>
<view class="title flex justify-center">
<view class="flex-1">我有需要</view>
<fui-icon class="close flex-basis" name="close" size="46" color="#999999" @click="close"></fui-icon>
</view>
<view class="text-left">
<fui-form ref="formRef">
<fui-row :gutter="10">
<fui-col :span="12">
<fui-input
marginTop="30"
size="24"
placeholder="请填写预留姓名"
v-model="pageData.form.reservedname"
></fui-input>
</fui-col>
<fui-col :span="12">
<fui-input
marginTop="30"
size="24"
placeholder="请填写预留手机"
v-model="pageData.form.reservedmobile"
></fui-input>
</fui-col>
</fui-row>
<fui-input
marginTop="30"
size="24"
placeholder="请填写作业地点"
v-model="pageData.form.reservedmobile"
></fui-input>
<fui-input
marginTop="30"
size="24"
placeholder="请选择作业时间"
v-model="pageData.form.reservedmobile"
></fui-input>
<fui-textarea :marginTop="30" size="24" placeholder="简要说明作业需求"></fui-textarea>
<view style="margin-top: 30rpx">
<fui-button type="warning" text="确定" bold radius="96rpx" @click="submit"></fui-button>
</view>
</fui-form>
</view>
</fui-dialog>
</template>
<style lang="scss" scoped>
:deep(.fui-dialog__body) {
background: linear-gradient(0deg, rgba(93, 182, 111, 0) 0%, rgba(93, 182, 111, 0.25) 100%);
margin: 0;
}
:deep(.fui-dialog__footer) {
display: none;
}
:deep(.fui-input) {
margin-top: 40rpx;
}
</style>
<script setup lang="ts">
import { reactive, toRefs } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { useUserStore } from '@/store/modules/user'
import { useGlobSetting } from '/@/hooks/setting'
import * as nongjifuwu from '@/api/model/nongjifuwu'
import { useDictStore } from '@/store/modules/dict'
const dictStore = useDictStore()
const userStore = useUserStore()
const globSetting = useGlobSetting()
onLoad((option) => {
pageData.form.type = option.type
// 获取数据详情
if (option.id) {
pageData.title = '查看农活详情'
getDetails(option.id)
} else {
pageData.title = '新增农活作业'
}
uni.setNavigationBarTitle({
title: pageData.title,
})
})
onShow(() => {
// 数据字典赋值
initDict()
})
const pageData = reactive({
title: '农活表单',
loading: false,
show: {
time1: false,
time2: false,
},
form: {
id: '',
name: '',
type: '',
scope: '',
address: '',
phone: '',
demand: '',
startTime: '',
endTime: '',
picture: '',
},
rules: [
{
name: 'name',
rule: ['required'],
msg: ['请填写服务名称'],
},
{
name: 'scope',
rule: ['required'],
msg: ['请填写服务范围'],
},
{
name: 'address',
rule: ['required'],
msg: ['请填写详细地址'],
},
{
name: 'phone',
rule: ['required'],
msg: ['请填写联系方式'],
},
{
name: 'demand',
rule: ['required'],
msg: ['请填写需求描述'],
},
{
name: 'startTime',
rule: ['required'],
msg: ['请选择开始时间'],
},
{
name: 'endTime',
rule: ['required'],
msg: ['请选择结束时间'],
},
],
})
const { show, form } = toRefs(pageData)
function initDict() {
console.log(dictStore.getDictList)
}
function getDetails(id) {
pageData.loading = true
nongjifuwu
.farmMachineDetails({ id })
.then((res) => {
console.log(res)
pageData.form = res
})
.finally(() => {
pageData.loading = false
})
}
function handleChangeTime1(e) {
pageData.form.startTime = e.result
pageData.show.time1 = false
}
function handleChangeTime2(e) {
pageData.form.endTime = e.result
pageData.show.time2 = false
}
const toastRef = ref()
const uploadRef = ref()
// 文件上传
function handleUpload(file) {
uni.uploadFile({
url: globSetting.apiUrl + globSetting.urlPrefix + '/sys/common/upload', // 直接使用上传接口URL
filePath: file.tempFiles[0].path,
name: 'file',
formData: {
biz: 'temp',
},
header: {
'X-Access-Token': userStore.getToken,
},
success: (res) => {
if (res.statusCode === 200) {
const data = JSON.parse(res.data)
if (data.code === 200 || data.code === 0) {
toastRef.value.show({
type: 'success',
text: '上传成功',
})
pageData.form.picture = data.message // 保存返回的图片信息
}
}
},
fail: () => {
toastRef.value.show({
type: 'error',
text: '上传失败',
})
uploadRef.value.clearFiles()
pageData.form.picture = null
},
})
}
// 文件删除
function handleDelete() {
uploadRef.value.clearFiles()
pageData.form.picture = null
}
const formRef = ref()
function submit() {
formRef.value.validator(pageData.form, pageData.rules, true).then((res) => {
if (res.isPassed) {
nongjifuwu.farmMachineAddFarm(pageData.form).then(() => {
toastRef.value.show({
type: 'success',
text: '发布成功',
})
uni.redirectTo({
url: '/pages/nongjifuwu/nongjifuwu',
})
})
}
})
}
</script>
<template>
<fui-form ref="formRef" :disabled="form.id ? true : false">
<fui-input required label="服务名称" placeholder="请输入服务名称" v-model="form.name"></fui-input>
<fui-input required label="服务范围" placeholder="请输入服务范围" v-model="form.scope"></fui-input>
<fui-input required label="详细地址" placeholder="请输入详细地址" v-model="form.address"></fui-input>
<fui-input required label="联系方式" borderTop placeholder="请输入联系方式" v-model="form.phone"></fui-input>
<fui-input required label="作业需求" borderTop placeholder="请输入作业需求" v-model="form.demand"></fui-input>
<fui-input
required
label="作业开始时间"
borderTop
placeholder="请选择开始时间"
v-model="form.startTime"
@click="show.time1 = true"
></fui-input>
<fui-input
required
label="作业结束时间"
borderTop
placeholder="请选择结束时间"
v-model="form.endTime"
@click="show.time2 = true"
></fui-input>
<view class="bg-white" style="padding: 0.875rem 0.35rem">
<view class="mb-1 flex justify-start"> 图片 </view>
<uni-file-picker
ref="uploadRef"
limit="1"
:auto-upload="false"
@select="handleUpload"
@delete="handleDelete"
></uni-file-picker>
</view>
<view class="fui-btn__box bg-white p-4" v-if="!form.id">
<fui-button text="发布作业" bold radius="96rpx" @click="submit"></fui-button>
</view>
</fui-form>
<fui-date-picker
:show="show.time1"
type="3"
@change="handleChangeTime1"
@cancel="show.time1 = false"
></fui-date-picker>
<fui-date-picker
:show="show.time2"
type="3"
@change="handleChangeTime2"
@cancel="show.time2 = false"
></fui-date-picker>
<fui-toast ref="toastRef"></fui-toast>
<fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)"></fui-loading>
</template>
<style lang="scss" scoped>
:deep(.fui-button) {
border-color: #ff9800 !important;
background: #ff9800 !important;
}
</style>
<script setup lang="ts">
import { reactive, toRefs } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { useUserStore } from '@/store/modules/user'
import { useGlobSetting } from '/@/hooks/setting'
import * as nongjifuwu from '@/api/model/nongjifuwu'
import { useDictStore } from '@/store/modules/dict'
const dictStore = useDictStore()
const userStore = useUserStore()
const globSetting = useGlobSetting()
onLoad((option) => {
pageData.form.type = option.type
// 获取数据详情
if (option.id) {
pageData.title = '查看农机详情'
getDetails(option.id)
} else {
pageData.title = '新增农机作业'
}
uni.setNavigationBarTitle({
title: pageData.title,
})
})
onShow(() => {
// 数据字典赋值
initDict()
})
const pageData = reactive({
title: '农机表单',
loading: false,
form: {
id: '',
name: '',
phone: '',
price: 0,
scope: '',
type: '',
picture: '',
},
rules: [
{
name: 'name',
rule: ['required'],
msg: ['请填写农机名称'],
},
{
name: 'name',
rule: ['required'],
msg: ['请填写联系方式'],
},
{
name: 'scope',
rule: ['required'],
msg: ['请填写服务范围'],
},
{
name: 'price',
rule: ['required'],
msg: ['请填写价格'],
},
{
name: 'picture',
rule: ['required'],
msg: ['请上传图片'],
},
],
})
const { form } = toRefs(pageData)
function initDict() {
console.log(dictStore.getDictList)
}
function getDetails(id) {
pageData.loading = true
nongjifuwu
.farmMachineDetails({ id })
.then((res) => {
console.log(res)
pageData.form = res
})
.finally(() => {
pageData.loading = false
})
}
const toastRef = ref()
const uploadRef = ref()
// 文件上传
function handleUpload(file) {
uni.uploadFile({
url: globSetting.apiUrl + globSetting.urlPrefix + '/sys/common/upload', // 直接使用上传接口URL
filePath: file.tempFiles[0].path,
name: 'file',
formData: {
biz: 'temp',
},
header: {
'X-Access-Token': userStore.getToken,
},
success: (res) => {
if (res.statusCode === 200) {
const data = JSON.parse(res.data)
if (data.code === 200 || data.code === 0) {
toastRef.value.show({
type: 'success',
text: '上传成功',
})
pageData.form.picture = data.message // 保存返回的图片信息
}
}
},
fail: () => {
toastRef.value.show({
type: 'error',
text: '上传失败',
})
uploadRef.value.clearFiles()
pageData.form.picture = null
},
})
}
// 文件删除
function handleDelete() {
uploadRef.value.clearFiles()
pageData.form.picture = null
}
const formRef = ref()
function submit() {
formRef.value.validator(pageData.form, pageData.rules, true).then((res) => {
if (res.isPassed) {
nongjifuwu.farmMachineAddMachine(pageData.form).then(() => {
toastRef.value.show({
type: 'success',
text: '发布成功',
})
uni.redirectTo({
url: '/pages/nongjifuwu/nongjifuwu',
})
})
}
})
}
</script>
<template>
<fui-form ref="formRef" :disabled="form.id ? true : false">
<fui-input required label="农机名称" placeholder="请输入农机名称" v-model="form.name"></fui-input>
<fui-input required label="联系方式" placeholder="请输入联系方式" v-model="form.phone"></fui-input>
<fui-input required label="服务范围" placeholder="请输入服务范围" v-model="form.scope"></fui-input>
<fui-input
required
label="价格(元/亩)"
borderTop
placeholder="请输入价格"
number
v-model="form.price"
></fui-input>
<view class="bg-white" style="padding: 0.875rem 0.35rem">
<view class="mb-1 flex justify-start">
<text class="pr-1" style="color: #ff2b2b">*</text>
图片
</view>
<uni-file-picker
ref="uploadRef"
limit="1"
:auto-upload="false"
@select="handleUpload"
@delete="handleDelete"
></uni-file-picker>
</view>
<view class="fui-btn__box bg-white p-4" v-if="!form.id">
<fui-button text="发布作业" bold radius="96rpx" @click="submit"></fui-button>
</view>
</fui-form>
<fui-toast ref="toastRef"></fui-toast>
<fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)"></fui-loading>
</template>
<style lang="scss" scoped>
:deep(.fui-button) {
border-color: #ff9800 !important;
background: #ff9800 !important;
}
</style>
......@@ -12,24 +12,8 @@
})
onLoad(() => {
uni.getLocation({
type: 'wgs84',
success: function (res) {
pageData.weather.lon = res.longitude
pageData.weather.lat = res.latitude
uni.setStorageSync('location', {
// 缓存地址
lon: res.longitude,
lat: res.latitude,
})
},
fail: function (error) {
uni.showToast({
title: '获取地址失败,将导致部分功能不可用',
icon: 'none',
})
},
})
// 关闭启动页并检查更新
closeSplashscreenAndChechUpgrade()
})
onShow(() => {
......@@ -42,16 +26,24 @@
if (res.longitude === 0 || res.latitude === 0) {
return
}
pageData.weather.lon = res.longitude
pageData.weather.lat = res.latitude
uni.setStorageSync('location', {
// 缓存地址
lon: res.longitude,
lat: res.latitude,
})
model.location = `${res.longitude},${res.latitude}`
reloadWeather()
},
fail(res) {
console.log('获取位置失败:', res)
reloadWeather()
},
complete() {
// 关闭启动页并检查更新
closeSplashscreenAndChechUpgrade()
uni.showToast({
title: '获取地址失败,将导致部分功能不可用',
icon: 'none',
})
},
})
......@@ -243,7 +235,9 @@
})
}
function getWarningInfo() {
if (!pageData.weather.lon || !pageData.weather.lat) return
if (!pageData.weather.lon || !pageData.weather.lat) {
return
}
HomeAPI.warningInfo({
lon: pageData.weather.lon,
......@@ -319,9 +313,9 @@
pageData.agricultureClass.time = e.target.duration
}
// 解决轮播视频切换时,上一个视频不停止播放的问题
const handleVideoPlay = (currentIndex) => {
function handleVideoPlay(currentIndex) {
pageData.agricultureClass.videoList.forEach((_, index) => {
if (index != currentIndex) {
if (index !== currentIndex) {
const videoContext = uni.createVideoContext(`video${index}`)
videoContext.pause()
}
......@@ -367,12 +361,12 @@
/>
<view class="codefun-flex-col codefun-items-start codefun-flex-1 codefun-ml-10">
<text class="text_5">{{ pageData.weather.temperature }}</text>
<text class="font_2 text_8 !text-26rpx codefun-mt-16">{{
<text class="font_2 text_8 !text-24rpx codefun-mt-16">{{
pageData.weather.condition
}}</text>
</view>
</view>
<view class="codefun-flex-col group_6 codefun-ml-22">
<view class="codefun-flex-col group_6 ml-2">
<view class="codefun-flex-row codefun-justify-between group_7">
<!-- <image
class="image_9"
......@@ -587,7 +581,7 @@
>
<swiper-item v-for="(video, index) in pageData.agricultureClass.videoList" :key="index">
<video
:id="'video' + index"
:id="`video${index}`"
:src="video.media_video"
:poster="video.cover_image"
:controls="false"
......
<script setup lang="ts">
import { reactive } from 'vue'
import { onPullDownRefresh } from '@dcloudio/uni-app'
import { onPullDownRefresh, onLoad, onShow } from '@dcloudio/uni-app'
import * as WodeAPI from '@/api/model/wode'
// 下拉刷新
onPullDownRefresh(() => {
......@@ -10,6 +11,10 @@
}, 1000)
})
onLoad(() => {
getBizCommonFileList()
})
// 页面数据
const pageData = reactive({
// 用户信息
......@@ -67,7 +72,7 @@
// 常用资源
commonResources: {
title: '常用资源',
actionText: '全部',
actionText: '',
resources: [
{
id: 1,
......@@ -145,6 +150,17 @@
},
})
function getBizCommonFileList() {
WodeAPI.bizCommonFileList({
pageNo: 1,
pageSize: 4,
}).then((res) => {
console.log(res)
// const { records } = res
// pageData.commonResources.resources = records
})
}
// 用户信息设置点击事件
function onSettingsClick() {
console.log('点击设置')
......@@ -333,15 +349,15 @@
<view class="codefun-flex-row">
<image class="image_15" :src="resource.icon" />
<view class="codefun-flex-col codefun-items-start group_14 codefun-ml-12">
<text class="font_9">{{ resource.title }}</text>
<text class="font_6 codefun-mt-12">{{ resource.size }}</text>
<text class="font_9">{{ resource.fileName }}</text>
<text class="font_6 codefun-mt-12">{{ resource.fileSize }}</text>
</view>
</view>
<view
class="codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_4"
@click.stop="onDownloadClick(resource)"
>
<text class="font_10">{{ resource.actionText }}</text>
<text class="font_10">下载</text>
</view>
</view>
</view>
......
......@@ -158,7 +158,7 @@
margin-left: 18rpx;
}
.page {
padding-bottom: 148rpx;
padding-bottom: 28rpx;
background-color: #e6f5e8;
mix-blend-mode: NOTTHROUGH;
width: 100%;
......
import { defineStore } from 'pinia'
import { store } from '/@/store'
import * as UserInfoAPI from '@/api/model/userInfo'
interface dictItem {
color: string
......@@ -20,6 +21,12 @@ export const useDictStore = defineStore({
}),
getters: {
getDictList(): DictListVO {
if (Object.keys(this.dictList).length === 0) {
UserInfoAPI.dictList().then((res) => {
this.dictList = res
})
return this.dictList
}
return this.dictList
},
},
......
import { defineStore } from 'pinia'
import { store } from '/@/store'
import { useDictStore } from './dict'
import { Storage } from '@/utils/storage'
import { TOKEN_KEY, USER_INFO_KEY } from '@/enums/cacheEnum'
import Navigate from '@/utils/page/navigate'
import * as API from '/@/api/model/userInfo'
import { useDictStore } from './dict'
export interface UserInfo {
id: string
......@@ -37,6 +36,8 @@ export const useUserStore = defineStore({
this.token = token
return token
}
return null
},
getUserInfo(): Nullable<UserInfo> {
if (this.userInfo) {
......@@ -62,11 +63,19 @@ export const useUserStore = defineStore({
actions: {
setToken(token: string) {
this.token = token
if (!token) {
Storage.remove(TOKEN_KEY)
} else {
Storage.set(TOKEN_KEY, token)
}
},
setUserInfo(info: UserInfo) {
this.userInfo = info
if (!info) {
Storage.remove(USER_INFO_KEY)
} else {
Storage.set(USER_INFO_KEY, info ? JSON.stringify(info) : null)
}
},
async logout() {
if (this.loading) {
......@@ -84,8 +93,10 @@ export const useUserStore = defineStore({
const dictStore = useDictStore(store)
dictStore.clearDict()
await Navigate.to('/pages/login/login')
this.loading = false
uni.reLaunch({
url: '/pages/login/login',
})
}
},
async refreshUserInfo() {
......
......@@ -48,8 +48,9 @@ const transform: AxiosTransform = {
// 错误的时候返回
const { data } = res
if (!data) {
if (!data || typeof data !== 'object') {
// return '[HTTP] Request has no return value';
// Message.toast(`${JSON.stringify(options)} --- ${res.data}`)
throw new Error(t('sys.api.apiRequestFailed'))
}
// 这里 status,body,message为 后台统一的字段,需要在 types.ts 内修改为项目自己的接口返回格式
......
......@@ -9,6 +9,9 @@ const PROXY_LIST: [[string, string]?] = [
// ['http://10.111.117.15:18100', `http://proxy.yiring.com:42180`],
// eg: 生产环境
// [`http://192.168.0.100:18100`, `https://oss.beta.app.yiring.com`],
// 开发环境(预览)
[`http://192.168.0.156:18100`, `http://111.22.182.169:49091`],
]
/**
......@@ -47,9 +50,15 @@ export function getIntranetUrl(url: string): string {
*/
export function handleResponseResource<T>(body: T, options: Recordable) {
for (const [intranet, extranet] of PROXY_LIST) {
// FIXME: 临时处理,解决内网文件上传后预览,但是实际上传存储时还是内网地址的问题
const host = options.apiUrl.replace(/https?:\/\/(.*):\d+/, '$1')
const isIntranet = intranet.includes(host)
const isExtranet = extranet.includes(host)
// console.log('handleResponseResource', body, options.apiUrl, host, isIntranet, isExtranet)
// 当需要处理内外网资源地址映射时,进行内容处理
const isIntranet = options.apiUrl.includes(intranet)
const isExtranet = options.apiUrl.includes(extranet)
// const isIntranet = options.apiUrl.includes(intranet)
// const isExtranet = options.apiUrl.includes(extranet)
if (isIntranet || isExtranet) {
const isString = typeof body === 'string'
const isObject = typeof body === 'object'
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论