提交 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 LinghuoyonggongAPI from '@/api/model/linghuoyonggong'
import * as UserInfoAPI from '@/api/model/userInfo'
import { areaTree, getTextByCode, getCodeByText } from '@/utils/areaData'
import { useDictStore } from '@/store/modules/dict'
const dictStore = useDictStore()
const userStore = useUserStore()
const globSetting = useGlobSetting()
onLoad((option) => {
// 获取数据详情
if (option.id) {
getDetails(option.id)
} else {
// 获取当前位置
getCurrentAddressInfo()
}
})
onShow(() => {
// 数据字典赋值
initDict()
})
const pageData = reactive({
loading: false,
show: {
time1: false,
time2: false,
area: false,
urgentdegree: false,
type: false,
},
options: {
area: [],
urgentdegree: [],
type: [],
},
form: {
id: '',
name: '',
content: '',
workers: 0,
price: 0,
typeText: '',
type: null,
area: '',
areaText: '',
province: '',
city: '',
country: '',
address: '',
urgentdegreeText: '',
urgentdegree: null,
starttime: '',
estimatedendtime: '',
picture: null,
},
rules: [
{
name: 'name',
rule: ['required'],
msg: ['请输入名称'],
},
{
name: 'workers',
rule: ['required'],
msg: ['请输入工作内容'],
},
{
name: 'workers',
rule: ['required'],
msg: ['请输入工人数量'],
},
{
name: 'price',
rule: ['required'],
msg: ['请输入价钱'],
},
{
name: 'type',
rule: ['required'],
msg: ['请选择类型'],
},
{
name: 'area',
rule: ['required'],
msg: ['请选择地区'],
},
{
name: 'address',
rule: ['required'],
msg: ['请选择详细地址'],
},
{
name: 'urgentdegree',
rule: ['required'],
msg: ['请选择紧急程度'],
},
{
name: 'starttime',
rule: ['required'],
msg: ['请选择开始时间'],
},
{
name: 'estimatedendtime',
rule: ['required'],
msg: ['请选择预计结束时间'],
},
{
name: 'picture',
rule: ['required'],
msg: ['请上传图片'],
},
],
})
const { show, options, form } = toRefs(pageData)
function initDict() {
pageData.options.area = areaTree
console.log(dictStore.getDictList['purchase_status'])
pageData.options.urgentdegree = dictStore.getDictList['employment_urgent'].map((item) => {
return {
value: item.value,
text: item.text,
}
})
pageData.options.type = dictStore.getDictList['employment_type'].map((item) => {
return {
value: item.value,
text: item.text,
}
})
}
function getCurrentAddressInfo() {
if (!uni.getStorageSync('location')) return
const { lon, lat } = uni.getStorageSync('location')
UserInfoAPI.location({
lon,
lat,
}).then((res) => {
pageData.form.province = res.province
pageData.form.city = res.city
pageData.form.country = res.country
pageData.form.areaText = `${res.province}/${res.city}/${res.country}`
pageData.form.area =
getCodeByText(res.province) + ',' + getCodeByText(res.city) + ',' + getCodeByText(res.country)
})
}
function getDetails(id) {
pageData.loading = true
LinghuoyonggongAPI.employmentDetails({ id })
.then((res) => {
console.log(res)
pageData.form = res
let areaCopy = pageData.form.area.split(',')
pageData.form.areaText = `${getTextByCode(areaCopy[0])}/${getTextByCode(areaCopy[1])}/${getTextByCode(areaCopy[2])}`
pageData.form.urgentdegreeText = pageData.options.urgentdegree.find(
(item) => item.value == pageData.form.urgentdegree,
)?.text
pageData.form.typeText = pageData.options.type.find((item) => item.value == pageData.form.type)?.text
})
.finally(() => {
pageData.loading = false
})
}
function handleChangeTime1(e) {
pageData.form.starttime = e.result
pageData.show.time1 = false
}
function handleChangeTime2(e) {
pageData.form.estimatedendtime = e.result
pageData.show.time2 = false
}
function handleChangetype(e) {
pageData.form.type = e.value
pageData.form.typeText = e.text
pageData.show.type = false
}
function handleChangeUrgentdegree(e) {
pageData.form.urgentdegree = e.value
pageData.form.urgentdegreeText = e.text
pageData.show.urgentdegree = false
}
function handleChangeAddress(e) {
pageData.form.areaText = e.text.join('/')
pageData.form.area = e.value.join(',')
pageData.show.area = 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: (err) => {
toastRef.value.show({
type: 'error',
text: '上传失败',
})
uploadRef.value.clearFiles()
pageData.form.picture = null
},
})
}
// 文件删除
function handleDelete(file) {
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) {
LinghuoyonggongAPI.employmentAdd(pageData.form).then((res) => {
toastRef.value.show({
type: 'success',
text: '用工发布成功',
})
uni.switchTab({
url: '/pages/chanxiao/chanxiao',
})
})
}
})
}
</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="工作内容" borderTop placeholder="请输入工作内容" v-model="form.content"></fui-input>
<fui-input required label="工人数量" borderTop placeholder="请输入工人数量" v-model="form.workers"></fui-input>
<fui-input required label="价钱" borderTop placeholder="请输入价钱" v-model="form.price"></fui-input>
<fui-input
required
label="类型"
placeholder="请选择类型"
v-model="form.typeText"
@click="show.type = true"
></fui-input>
<fui-input
required
label="地区"
placeholder="请选择地区"
v-model="form.areaText"
@click="show.area = true"
></fui-input>
<fui-input label="详细地址" placeholder="请输入详细地址" v-model="form.address"></fui-input>
<fui-input
required
label="紧急程度"
placeholder="请选择紧急程度"
v-model="form.urgentdegreeText"
@click="show.urgentdegree = true"
></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.estimatedendtime"
@click="show.time2 = true"
></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-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-picker
:show="show.type"
:layer="1"
:linkage="true"
:options="options.type"
@change="handleChangetype"
@cancel="show.type = false"
></fui-picker>
<fui-picker
:show="show.urgentdegree"
:layer="1"
:linkage="true"
:options="options.urgentdegree"
@change="handleChangeUrgentdegree"
@cancel="show.urgentdegree = false"
></fui-picker>
<fui-picker
:show="show.area"
:options="options.area"
:linkage="true"
:layer="3"
@change="handleChangeAddress"
@cancel="show.area = false"
></fui-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>
<script setup lang="ts">
import { reactive } from 'vue'
import ApplyDialog from './components/apply-dialog.vue'
import { onPullDownRefresh, onLoad, onShow, onReachBottom } from '@dcloudio/uni-app'
import * as NongjifuwuAPI from '@/api/model/nongjifuwu'
import Navigate from '@/utils/page/navigate'
......@@ -15,6 +17,7 @@
})
const pageData = reactive({
loading: false,
// 分类标签
categoryTabs: [
{ id: 1, name: '找农机' },
......@@ -30,11 +33,16 @@
})
function getFarmMachineList() {
NongjifuwuAPI.farmMachineList(pageData.search).then((res) => {
const { records, total } = res
pageData.farmMachineList = [...pageData.farmMachineList, ...records]
pageData.total = total
})
pageData.loading = true
NongjifuwuAPI.farmMachineList(pageData.search)
.then((res) => {
const { records, total } = res
pageData.farmMachineList = [...pageData.farmMachineList, ...records]
pageData.total = total
})
.finally(() => {
pageData.loading = false
})
}
// 分类标签点击事件
......@@ -47,6 +55,29 @@
getFarmMachineList()
}
function handlePublish() {
if (pageData.search.serviceType === 1) {
Navigate.to(`/pages/nongjifuwu/machine-form?type=${pageData.search.serviceType}`)
}
if (pageData.search.serviceType === 2) {
Navigate.to(`/pages/nongjifuwu/farm-form?type=${pageData.search.serviceType}`)
}
}
// 查看详情
function handleDetails(item: any) {
if (pageData.search.serviceType === 1) {
Navigate.to(`/pages/nongjifuwu/machine-form?id=${item.id}&&type=${pageData.search.serviceType}`)
}
if (pageData.search.serviceType === 2) {
Navigate.to(`/pages/nongjifuwu/farm-form?id=${item.id}&&type=${pageData.search.serviceType}`)
}
}
// 我有需要
const applyDialogRef = ref()
function handleApply(item: any) {
applyDialogRef.value.open(item)
}
onReachBottom(() => {
console.log('触底了')
if (pageData.total <= pageData.farmMachineList.length) return
......@@ -64,7 +95,7 @@
<text class="font_2 text_3">选择市县乡镇</text>
<image
class="codefun-shrink-0 image_7 codefun-ml-4"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=774cfe989f8417dc655fb301635f5893.png"
src="/static/images/codefun/774cfe989f8417dc655fb301635f5893.png"
/>
</view>
</view>
......@@ -81,25 +112,39 @@
}}</text>
</view>
</view>
<view
v-if="!pageData.farmMachineList || pageData.farmMachineList.length == 0"
class="codefun-flex-col codefun-relative section_4"
style="height: 700rpx"
>
<fui-empty marginTop="100" src="/src/static/images/no-data.png" title="暂无数据"></fui-empty>
</view>
<view class="codefun-flex-col codefun-relative section_4">
<view class="codefun-flex-row group_6" v-for="item in pageData.farmMachineList" :key="item.id">
<image class="codefun-shrink-0 codefun-self-center image_8" :src="item.picture" />
<image
class="codefun-shrink-0 codefun-self-center image_8"
:src="item.picture"
@click="handleDetails(item)"
/>
<view style="width: 75%">
<view class="codefun-flex-col codefun-items-start codefun-flex-1 codefun-self-center">
<view
class="codefun-flex-col codefun-items-start codefun-flex-1 codefun-self-center"
@click="handleDetails(item)"
>
<text class="font text_6">{{ item.name }}</text>
<text class="font_3 text_7 ellipsis" style="width: 100%; margin: 26rpx 0"
>服务范围:{{ item.scope }}{{ item.scope }}{{ item.scope }}{{ item.scope
}}{{ item.scope }}</text
>服务范围:{{ item.scope }}</text
>
</view>
<view class="flex justify-between" style="width: 100%">
<view class="group_5">
<view class="group_5" @click="handleDetails(item)">
<text class="font_6">¥</text>
<text class="font_4 text_8">{{ item.price }}</text>
<text class="font_7">/亩</text>
</view>
<view
class="codefun-flex-col codefun-justify-start codefun-items-center codefun-shrink-0 codefun-self-start text-wrapper_2"
@click="handleApply(item)"
>
<text class="font_5">我有需要</text>
</view>
......@@ -110,7 +155,7 @@
<view class="codefun-flex-row codefun-items-center codefun-flex-1 codefun-self-center">
<image
class="codefun-shrink-0 image_8"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=e3f873f79cdddaee3655c048852302e3.png"
src="/static/images/codefun/e3f873f79cdddaee3655c048852302e3.png"
/>
<view class="codefun-flex-col codefun-items-start codefun-flex-1 codefun-ml-12">
<text class="font text_9">小麦播种机</text>
......@@ -132,7 +177,7 @@
<view class="codefun-flex-row codefun-items-center codefun-flex-1 codefun-self-center">
<image
class="codefun-shrink-0 image_8"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=da314c458ad5d6714cfe7ee8524ccd9c.png"
src="/static/images/codefun/da314c458ad5d6714cfe7ee8524ccd9c.png"
/>
<view class="codefun-flex-col codefun-items-start codefun-flex-1 codefun-ml-12">
<text class="font text_12">多功能拖拉机</text>
......@@ -161,7 +206,7 @@
<view class="codefun-flex-row codefun-items-center codefun-flex-1 codefun-self-center">
<image
class="codefun-shrink-0 image_8"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=3500502108a998fe7f49363a276af806.png"
src="/static/images/codefun/3500502108a998fe7f49363a276af806.png"
/>
<view class="codefun-flex-col codefun-items-start codefun-flex-1 codefun-ml-12">
<text class="font">水稻插秧机</text>
......@@ -184,51 +229,36 @@
<view class="grid">
<view class="codefun-flex-row codefun-justify-between codefun-items-center grid-item">
<text class="font_3 text_19">农机类型</text>
<image
class="image_10"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=a13c36a46232de65d09f43b1720ba29d.png"
/>
<image class="image_10" src="/static/images/codefun/a13c36a46232de65d09f43b1720ba29d.png" />
</view>
<view class="codefun-flex-row codefun-justify-between codefun-items-center grid-item_2">
<view class="codefun-flex-row codefun-items-center">
<image
class="codefun-shrink-0 image_9"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=bf7b1672e65ba021aa79827f30014280.png"
src="/static/images/codefun/bf7b1672e65ba021aa79827f30014280.png"
/>
<text class="font_3 text_20 codefun-ml-8">作业地点</text>
</view>
<image
class="image_10"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=a13c36a46232de65d09f43b1720ba29d.png"
/>
<image class="image_10" src="/static/images/codefun/a13c36a46232de65d09f43b1720ba29d.png" />
</view>
<view class="codefun-flex-row codefun-justify-between codefun-items-center grid-item_4">
<view class="codefun-flex-row codefun-items-center">
<image
class="codefun-shrink-0 image_11"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=206576465476f031295c48dcef261286.png"
src="/static/images/codefun/206576465476f031295c48dcef261286.png"
/>
<text class="font_3 text_21 codefun-ml-4">作业时间</text>
</view>
<image
class="image_10"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=a13c36a46232de65d09f43b1720ba29d.png"
/>
<image class="image_10" src="/static/images/codefun/a13c36a46232de65d09f43b1720ba29d.png" />
</view>
<view class="codefun-flex-row codefun-items-center grid-item_4">
<image
class="image_12"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=43220b5bebf6a41ff3f05e6ec94ce9f0.png"
/>
<image class="image_12" src="/static/images/codefun/43220b5bebf6a41ff3f05e6ec94ce9f0.png" />
<text class="font_3 text_22 codefun-ml-4">联系方式</text>
</view>
</view>
<view class="codefun-flex-col codefun-mt-12">
<view class="codefun-flex-row codefun-items-center grid-item group_12">
<image
class="image_13"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=a83082710831140b897349a7f3bd46d9.png"
/>
<image class="image_13" src="/static/images/codefun/a83082710831140b897349a7f3bd46d9.png" />
<text class="font_3 text_23 codefun-ml-8">简要说明作业需求</text>
</view>
<view
......@@ -240,11 +270,22 @@
</view> -->
</view>
</view>
<fui-fab background="#5db66f" position="right" distance="10" bottom="240" width="130" @click="handlePublish">
<view class="text-white text-center">
<image src="/src/static/images/chanxiao/notepad.svg" style="width: 40rpx" mode="widthFix"></image>
<view style="font-size: 24rpx"
>发布{{ pageData.categoryTabs.find((item) => item.id === pageData.search.serviceType)?.name }}</view
>
</view>
</fui-fab>
<ApplyDialog ref="applyDialogRef"></ApplyDialog>
<fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)"></fui-loading>
</template>
<style scoped lang="scss">
.page {
padding-bottom: 64rpx;
padding-bottom: 12rpx;
background-color: #e6f5e8;
mix-blend-mode: NOTTHROUGH;
width: 100%;
......@@ -330,7 +371,7 @@
border: solid 2rpx #ffffffcc;
.text-50p {
width: 50%;
height: 102rpx;
height: 122rpx;
padding: 0.75rem 0 1.625rem;
}
.text-wrapper {
......
......@@ -18,7 +18,7 @@
<view class="codefun-flex-col equal-division-item group_4">
<image
class="codefun-self-center image_6"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=1d8e91708cae6b6244d183b5c3eb1c5e.png"
src="/static/images/codefun/1d8e91708cae6b6244d183b5c3eb1c5e.png"
/>
<view
class="codefun-flex-row codefun-justify-center codefun-items-baseline codefun-self-stretch group_7 codefun-mt-8"
......@@ -32,12 +32,12 @@
>
<image
class="codefun-self-start image_9 image_10"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=ac7a11ec05eb9854a6d3ee34633c53c0.png"
src="/static/images/codefun/ac7a11ec05eb9854a6d3ee34633c53c0.png"
/>
<view class="codefun-flex-col group_6">
<image
class="codefun-self-center image_7"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=5d6c7fea65df7f4528d28301a632acca.png"
src="/static/images/codefun/5d6c7fea65df7f4528d28301a632acca.png"
/>
<view class="codefun-flex-row codefun-items-baseline codefun-self-center codefun-mt-8">
<text class="font_3">开花</text>
......@@ -48,12 +48,12 @@
<view class="codefun-flex-row codefun-justify-center group_5 equal-division-item_2">
<image
class="codefun-self-center image_9 pos_3"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=ac7a11ec05eb9854a6d3ee34633c53c0.png"
src="/static/images/codefun/ac7a11ec05eb9854a6d3ee34633c53c0.png"
/>
<view class="codefun-flex-col">
<image
class="codefun-self-center image_7"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=23995baf95335d84a302baeadeeeb5d3.png"
src="/static/images/codefun/23995baf95335d84a302baeadeeeb5d3.png"
/>
<view class="codefun-flex-row codefun-items-baseline codefun-self-stretch codefun-mt-8">
<text class="font_3 text_5">结果</text>
......@@ -90,10 +90,7 @@
<view class="codefun-flex-row horiz-list group_13 codefun-mt-16">
<view class="codefun-flex-col horiz-list-item section_5">
<view class="codefun-flex-row codefun-items-center codefun-self-stretch">
<image
class="image_11"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=22109e59215c3e6f8e24b54d126d851f.png"
/>
<image class="image_11" src="/static/images/codefun/22109e59215c3e6f8e24b54d126d851f.png" />
<text class="font_7 text_16 codefun-ml-4">智能预警</text>
</view>
<text class="codefun-self-start font_12 text_18 codefun-mt-10">如何提前预防柑橘黄龙病?</text>
......@@ -104,10 +101,7 @@
</view>
<view class="codefun-flex-col horiz-list-item_2 section_6 mx-3.5">
<view class="codefun-flex-row codefun-items-center">
<image
class="image_12"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=93b830e77b49a5d5a885dba853cca4f2.png"
/>
<image class="image_12" src="/static/images/codefun/93b830e77b49a5d5a885dba853cca4f2.png" />
<text class="font_7 text_17 codefun-ml-4">精准施肥</text>
</view>
<text class="font_12 text_19 codefun-mt-10">柑橘园精准水肥管理方案</text>
......@@ -124,7 +118,7 @@
<view class="codefun-flex-col equal-division-item_4 group_16">
<image
class="codefun-self-center image_13"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=8d95c077ff410c467d25f1d02b84cd3c.png"
src="/static/images/codefun/8d95c077ff410c467d25f1d02b84cd3c.png"
/>
<view class="codefun-flex-col codefun-self-stretch codefun-mt-20">
<text class="codefun-self-center font_9">数据录入</text>
......@@ -134,13 +128,13 @@
<view class="codefun-flex-col equal-division-item_5 group_17">
<image
class="codefun-self-center image_14"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=e4453ccb0959797614bc6ffb5d62d56f.png"
src="/static/images/codefun/e4453ccb0959797614bc6ffb5d62d56f.png"
/>
<view class="codefun-flex-col codefun-self-stretch codefun-mt-16">
<view class="codefun-flex-col codefun-self-stretch group_20">
<image
class="codefun-shrink-0 codefun-self-start image_9 image_16"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=b31cf305e90b1547bca2725e5a2ea5be.png"
src="/static/images/codefun/b31cf305e90b1547bca2725e5a2ea5be.png"
/>
<text class="codefun-self-center font_9 text_22">模型选择</text>
</view>
......@@ -150,12 +144,12 @@
<view class="codefun-flex-row codefun-justify-between equal-division-item_6 group_18">
<image
class="codefun-self-start image_9 image_17"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=b31cf305e90b1547bca2725e5a2ea5be.png"
src="/static/images/codefun/b31cf305e90b1547bca2725e5a2ea5be.png"
/>
<view class="codefun-flex-col group_19">
<image
class="codefun-self-center image_15"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=a8dc70a912aaa771eddc3a2bd607fdc3.png"
src="/static/images/codefun/a8dc70a912aaa771eddc3a2bd607fdc3.png"
/>
<view class="codefun-flex-col codefun-self-stretch codefun-mt-16">
<text class="codefun-self-center font_9 text_21">查看结果</text>
......@@ -184,10 +178,7 @@
<text class="font_12 text_28 text_31">何时适合采摘?</text>
</view>
</view>
<image
class="image_18 pos_4"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=8ecf54ab157b99371d9e1fecfa1ef085.png"
/>
<image class="image_18 pos_4" src="/static/images/codefun/8ecf54ab157b99371d9e1fecfa1ef085.png" />
</view>
</view>
<view class="codefun-flex-col codefun-mt-24">
......@@ -199,10 +190,7 @@
<view
class="codefun-flex-col codefun-justify-start codefun-items-center codefun-shrink-0 codefun-self-center image-wrapper"
>
<image
class="image_19"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=ad2e6d5cc57cc9e4a91adc18b3a155e2.png"
/>
<image class="image_19" src="/static/images/codefun/ad2e6d5cc57cc9e4a91adc18b3a155e2.png" />
</view>
<view class="codefun-flex-col codefun-flex-1 codefun-self-start group_23 codefun-ml-12">
<text class="codefun-self-start font_12 text_33">胡萝卜高产种植技术要点</text>
......@@ -210,14 +198,14 @@
<view class="codefun-flex-row codefun-items-center">
<image
class="codefun-shrink-0 image_20"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=74964a1e25c0e7d8c97198b99483e54a.png"
src="/static/images/codefun/74964a1e25c0e7d8c97198b99483e54a.png"
/>
<text class="font_4 text_34 codefun-ml-4">12:30</text>
</view>
<view class="codefun-flex-row codefun-items-center codefun-ml-20">
<image
class="codefun-shrink-0 image_21"
src="https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=e8cae542eda3d68f054b3e0ce2afa242.png"
src="/static/images/codefun/e8cae542eda3d68f054b3e0ce2afa242.png"
/>
<text class="font_4 text_35 codefun-ml-6">99</text>
</view>
......@@ -240,7 +228,7 @@
overflow-x: hidden;
.group {
.section_2 {
background-image: url('https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=c122979639a1f9d27d7c57245ab420a6.png');
background-image: url('/static/images/codefun/c122979639a1f9d27d7c57245ab420a6.png');
background-size: 100% 100%;
background-repeat: no-repeat;
.section_3 {
......@@ -587,7 +575,7 @@
backdrop-filter: blur(4rpx);
.image-wrapper {
padding: 48rpx 0;
background-image: url('https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=5149f97303e2fa97daa823a1452dce11.png');
background-image: url('/static/images/codefun/5149f97303e2fa97daa823a1452dce11.png');
background-size: 100% 100%;
background-repeat: no-repeat;
width: 240rpx;
......
......@@ -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
Storage.set(TOKEN_KEY, token)
if (!token) {
Storage.remove(TOKEN_KEY)
} else {
Storage.set(TOKEN_KEY, token)
}
},
setUserInfo(info: UserInfo) {
this.userInfo = info
Storage.set(USER_INFO_KEY, info ? JSON.stringify(info) : null)
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论