提交 0fabce76 作者: guolinhua

暂时禁用代码效验

上级 1dbbad7a
# API 接口地址
VITE_GLOB_API_URL=http://111.22.182.169:49600
# 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=/jeecgboot
VITE_GLOB_API_URL_PREFIX=/jeecg-boot
......@@ -5,4 +5,4 @@
[ -n "$CI" ] && exit 0
# Format and submit code according to lintstagedrc.js configuration
npm run lint:lint-staged
# npm run lint:lint-staged
......@@ -81,6 +81,7 @@
"@dcloudio/uni-quickapp-webview": "3.0.0-4060620250520001",
"@dcloudio/uni-ui": "^1.5.7",
"@faker-js/faker": "^9.8.0",
"@vant/area-data": "^2.1.0",
"@vue/runtime-core": "3.4.21",
"@vueuse/core": "^12.3.0",
"@vueuse/shared": "^12.3.0",
......
......@@ -53,6 +53,9 @@ importers:
'@faker-js/faker':
specifier: ^9.8.0
version: 9.8.0
'@vant/area-data':
specifier: ^2.1.0
version: 2.1.0
'@vue/runtime-core':
specifier: 3.4.21
version: 3.4.21
......@@ -2420,6 +2423,9 @@ packages:
peerDependencies:
vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0 || ^5.0.0-0
'@vant/area-data@2.1.0':
resolution: {integrity: sha512-wx9PrUX7wSUJiFcz8UrcvZfTjV6sTc+7SHcbjGQQzEcv5y+EwOo5uV4ZKdfrR5Hzcw4MA08LQdvXPSEb4nWbug==}
'@vitalets/google-translate-api@9.2.1':
resolution: {integrity: sha512-zlwQWSjXUZhbZQ6qwtIQ7GdYXFQmJ4wYqzcrYJUxtvzQQwUP+uKUb/SRJaBOQuBntjBjzcdcJoLFrpCKUbIkOg==}
engines: {node: '>=14'}
......@@ -10137,6 +10143,8 @@ snapshots:
transitivePeerDependencies:
- rollup
'@vant/area-data@2.1.0': {}
'@vitalets/google-translate-api@9.2.1':
dependencies:
'@types/http-errors': 1.8.2
......
......@@ -2,6 +2,12 @@
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'
......@@ -29,6 +35,13 @@
}
// #endif
})
function getDictList() {
if (!userStore.getToken) return
if (Object.keys(dictStore.getDictList).length !== 0) return
UserInfoAPI.dictList().then((res) => {
dictStore.setDictList(res)
})
}
onExit(() => {
// 停用监听权限
......@@ -37,6 +50,7 @@
onShow(() => {
console.log('App Show')
getDictList()
})
onHide(() => {
......
// 上传请求
import { otherHttp } from '/@/utils/http/axios'
enum Api {
purchaseList = '/purchaseSell/bizPurchase/list', // 采购需求列表
supplyList = '/purchaseSell/bizSupply/list', // 供应需求列表
purchaseSellDetails = '/purchaseSell/bizPurchase/queryByld', // 产销详情
purchaseSell = '/purchaseSell/bizPurchase/add', // 发布采购需求
supplyAdd = '/purchaseSell/bizSupply/add', // 发布供应需求
bizPurchaseSupplyRecord = '/purchaseSell/bizPurchaseSupplyRecord/add', // 报价
}
/**
* @param params 请求参数
* @description: 采购需求列表
*/
export function purchaseList(params = {}) {
return otherHttp.get({
url: Api.purchaseList,
params,
})
}
/**
* @param params 请求参数
* @description: 供应需求列表
*/
export function supplyList(params = {}) {
return otherHttp.get({
url: Api.supplyList,
params,
})
}
/**
* @param params 请求参数
* @description: 采购需求详情
*/
export function purchaseSellDetails(params = {}) {
return otherHttp.get({
url: Api.purchaseSellDetails,
params,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
})
}
/**
* @param params 请求参数
* @description: 发布采购需求
*/
export function purchaseSellAdd(params = {}) {
return otherHttp.post({
url: Api.purchaseSell,
params,
})
}
/**
* @param params 请求参数
* @description: 发布采购需求
*/
export function supplyAdd(params = {}) {
return otherHttp.post({
url: Api.supplyAdd,
params,
})
}
/**
* @param params 请求参数
* @description: 报价
*/
export function bizPurchaseSupplyRecord(params = {}) {
return otherHttp.post({
url: Api.bizPurchaseSupplyRecord,
params,
})
}
......@@ -2,6 +2,7 @@ import { otherHttp } from '/@/utils/http/axios'
enum Api {
zoneList = '/online/cgform/api/getData/01fd687ecb164aea914e92047e144d66', // 金刚区菜单数据
warningInfo = '/tianditu/warningInfo', // 金刚区菜单数据
productMarketList = '/online/cgform/api/getData/5b71e11020d44366b2d130e200c7a640', // 热门产地行情
serviceStatsList = '/online/cgform/api/getData/491863dde351404da63a1a6e8c699c4c', // 服务展示窗
agricultureClassList = '/online/cgform/api/getData/311c300e05694ba69a063d04c8572e9e', // 农技课堂
......@@ -20,6 +21,20 @@ export function zoneList(params = {}) {
/**
* @param params 请求参数
* @description: 天气通知数据
*/
export function warningInfo(params = {}) {
return otherHttp.post({
url: Api.warningInfo,
params,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
})
}
/**
* @param params 请求参数
* @description: 热门产地行情数据
*/
export function productMarketList(params = {}) {
......
// 灵活用工
import { otherHttp } from '/@/utils/http/axios'
enum Api {
employmentList = '/employment/app/list', // 用工列表
employmentAdd = '/employment/app/add', // 发布用工
employmentDetails = '/employment/queryById', // 查看用工详情
}
/**
* @param params 请求参数
* @description: 用工列表
*/
export function employmentList(params = {}) {
return otherHttp.get({
url: Api.employmentList,
params,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
})
}
/**
* @param params 请求参数
* @description: 发布用工
*/
export function employmentAdd(params = {}) {
return otherHttp.post({
url: Api.employmentAdd,
params,
})
}
/**
* @param params 请求参数
* @description: 发布用工
*/
export function employmentDetails(params = {}) {
return otherHttp.get({
url: Api.employmentDetails,
params,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
})
}
......@@ -4,6 +4,8 @@ enum Api {
getUserInfo = '/sys/user/login/setting/getUserData', // 查询登录用户信息
logout = '/sys/logout', // 登出
sysLogin = '/sys/mLogin', // 登陆
dictList = '/sys/dict/queryAllDictItems', // 获取字典数据
location = '/tianditu/geocode', // 根据经纬度获取地址
}
/**
* @param params 请求参数
......@@ -37,3 +39,28 @@ export function logout(params = {}) {
params,
})
}
/**
* @param params 请求参数
* @description: 获取字典数据
*/
export function dictList(params = {}) {
return otherHttp.get({
url: Api.dictList,
params,
})
}
/**
* @param params 请求参数
* @description: 发布需求
*/
export function location(params = {}) {
return otherHttp.post({
url: Api.location,
params,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
})
}
......@@ -16,7 +16,6 @@
</view>
</view>
</template>
<script>
// #ifdef APP-NVUE
const animation = uni.requireNativePlugin('animation');
......
......@@ -45,6 +45,7 @@
"backgroundColorTop": "#e6f5e8",
"backgroundColorBottom": "#e6f5e8",
"enablePullDownRefresh": true,
"onReachBottomDistance": 50,
"app-plus": {
"titleNView": false,
"bounce": false
......@@ -52,6 +53,32 @@
}
},
{
"path": "pages/chanxiao/purchaseXuQiu",
"style": {
"navigationBarTitleText": "发布采购需求",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#5DB66F",
"navigationBarTextStyle": "white",
"backgroundColorBottom": "#F2F2F2",
"app-plus": {
"titleNView": {}
}
}
},
{
"path": "pages/chanxiao/supplyXuQiu",
"style": {
"navigationBarTitleText": "发布供应需求",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#5DB66F",
"navigationBarTextStyle": "white",
"backgroundColorBottom": "#F2F2F2",
"app-plus": {
"titleNView": {}
}
}
},
{
"path": "pages/nongzhi/nongzhi",
"style": {
"navigationBarTitleText": "",
......@@ -147,6 +174,20 @@
"navigationBarBackgroundColor": "#5DB66F",
"navigationBarTextStyle": "white",
"backgroundColorBottom": "#F2F2F2",
"onReachBottomDistance": 50,
"app-plus": {
"titleNView": {}
}
}
},
{
"path": "pages/linghuoyonggong/form",
"style": {
"navigationBarTitleText": "发布用工",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#5DB66F",
"navigationBarTextStyle": "white",
"backgroundColorBottom": "#F2F2F2",
"app-plus": {
"titleNView": {}
}
......
<script setup lang="ts">
import { reactive } from 'vue'
import { onPullDownRefresh } from '@dcloudio/uni-app'
import { onPullDownRefresh, onLoad, onShow, onReachBottom } from '@dcloudio/uni-app'
import Navigate from '@/utils/page/navigate'
import * as ChanxiaoAPI from '@/api/model/chanxiao'
import PriceDialog from './components/price-dialog.vue'
// 下拉刷新
onPullDownRefresh(() => {
......@@ -9,6 +13,17 @@
Message.toast('刷新成功')
}, 1000)
})
onShow(() => {
pageData.search.pageNo = 1
if (pageData.currentTransactionTab === 1) {
pageData.purchaseDemands = []
getPurchaseList()
}
if (pageData.currentTransactionTab === 2) {
pageData.supplyInfos = []
getSupplyList()
}
})
// 页面数据
const pageData = reactive({
......@@ -20,12 +35,12 @@
// 分类标签
categoryTabs: [
{ id: 1, name: '全部' },
{ id: 2, name: '蔬菜' },
{ id: 3, name: '水果' },
{ id: 4, name: '粮食' },
{ id: 5, name: '畜牧' },
{ id: 6, name: '其他' },
{ id: -1, name: '全部' },
{ id: 1, name: '蔬菜' },
{ id: 2, name: '水果' },
{ id: 3, name: '粮食' },
{ id: 4, name: '畜牧' },
{ id: 0, name: '其他' },
],
// 采购/供应标签
......@@ -33,133 +48,220 @@
{ id: 1, name: '采购需求' },
{ id: 2, name: '供应发布' },
],
currentTransactionTab: 1,
loading: false,
search: {
pageNo: 1,
pageSize: 10,
classify: null,
auditStatus: 1,
},
// 新需求提醒
newDemandNotice: {
icon: '/static/images/codefun/48f77b33e9b33c48eda3cfc9708d8c28.png',
text: '3 条新需求发布,点击刷新查看',
},
// 采购需求列表
purchaseDemands: [
{
id: 1,
image: '/static/images/codefun/028ebd16358e350cdd341698948bf156.png',
tag: {
text: '急需',
show: true,
},
title: '精品有机白菜 50吨',
deadline: '2025.11.12 前',
location: '山东合肥',
price: '1.5-2.0',
unit: '/斤',
quoteCount: '12人报价',
actionText: '立即报价',
icons: {
deadline: '/static/images/codefun/56353ebdea095baedbcb33fc53f68a03.png',
location: '/static/images/codefun/c98744e63719b5413f260ec6a899ee20.png',
quote: '/static/images/codefun/bcf6538c8728a2894c90d4463c4c9520.png',
},
},
{
id: 2,
image: '/static/images/codefun/361ea05e8940b0235c696764775a3f00.png',
tag: {
text: '',
show: false,
},
title: '红富士苹果 20吨',
deadline: '2025.11.12 前',
location: '山东烟台',
price: '5.5-6.5',
unit: '/斤',
quoteCount: '8人报价',
actionText: '立即报价',
icons: {
deadline: '/static/images/codefun/56353ebdea095baedbcb33fc53f68a03.png',
location: '/static/images/codefun/c98744e63719b5413f260ec6a899ee20.png',
quote: '/static/images/codefun/bcf6538c8728a2894c90d4463c4c9520.png',
},
},
{
id: 3,
image: '/static/images/codefun/361ea05e8940b0235c696764775a3f00.png',
tag: {
text: '',
show: false,
},
title: '胡萝卜 30吨',
deadline: '2025.11.12 前',
location: '河北石家庄',
price: '',
unit: '',
quoteCount: '8人报价',
actionText: '立即报价',
contactText: '在线咨询',
icons: {
deadline: '/static/images/codefun/56353ebdea095baedbcb33fc53f68a03.png',
location: '/static/images/codefun/c98744e63719b5413f260ec6a899ee20.png',
quote: '/static/images/codefun/bcf6538c8728a2894c90d4463c4c9520.png',
},
},
// 采购需求列表
purchaseDemands: [
// {
// id: 1,
// image: '/static/images/codefun/028ebd16358e350cdd341698948bf156.png',
// tag: {
// text: '急需',
// show: true,
// },
// title: '精品有机白菜 50吨',
// deadline: '2025.11.12 前',
// location: '山东合肥',
// price: '1.5-2.0',
// unit: '/斤',
// quoteCount: '12人报价',
// actionText: '立即报价',
// },
// {
// id: 2,
// image: '/static/images/codefun/361ea05e8940b0235c696764775a3f00.png',
// tag: {
// text: '',
// show: false,
// },
// title: '红富士苹果 20吨',
// deadline: '2025.11.12 前',
// location: '山东烟台',
// price: '5.5-6.5',
// unit: '/斤',
// quoteCount: '8人报价',
// actionText: '立即报价',
// icons: {
// deadline: '/static/images/codefun/56353ebdea095baedbcb33fc53f68a03.png',
// location: '/static/images/codefun/c98744e63719b5413f260ec6a899ee20.png',
// quote: '/static/images/codefun/bcf6538c8728a2894c90d4463c4c9520.png',
// },
// },
// {
// id: 3,
// image: '/static/images/codefun/361ea05e8940b0235c696764775a3f00.png',
// tag: {
// text: '',
// show: false,
// },
// title: '胡萝卜 30吨',
// deadline: '2025.11.12 前',
// location: '河北石家庄',
// price: '',
// unit: '',
// quoteCount: '8人报价',
// actionText: '立即报价',
// contactText: '在线咨询',
// icons: {
// deadline: '/static/images/codefun/56353ebdea095baedbcb33fc53f68a03.png',
// location: '/static/images/codefun/c98744e63719b5413f260ec6a899ee20.png',
// quote: '/static/images/codefun/bcf6538c8728a2894c90d4463c4c9520.png',
// },
// },
],
total: 0,
// 供应信息列表
supplyInfos: [
{
id: 1,
image: '/static/images/codefun/b9ce5bff0be96948372f9f688c49fdb3.png',
tag: {
text: '推广',
show: true,
},
title: '优质草莓供应商',
description: '多品种优质草莓常年供应,品质保证',
location: '广东深圳',
actionText: '立即报价',
icons: {
location: '/static/images/codefun/c98744e63719b5413f260ec6a899ee20.png',
},
},
// {
// id: 1,
// image: '/static/images/codefun/b9ce5bff0be96948372f9f688c49fdb3.png',
// tag: {
// text: '推广',
// show: true,
// },
// title: '优质草莓供应商',
// description: '多品种优质草莓常年供应,品质保证',
// location: '广东深圳',
// actionText: '立即报价',
// icons: {
// location: '/static/images/codefun/c98744e63719b5413f260ec6a899ee20.png',
// },
// },
],
})
// 获取采购需求列表
function getPurchaseList() {
pageData.loading = true
ChanxiaoAPI.purchaseList(pageData.search)
.then((res) => {
const { records, total } = res
pageData.purchaseDemands = [...pageData.purchaseDemands, ...records]
pageData.purchaseDemands = pageData.purchaseDemands.map((item) => ({
...item,
location: `${item.province}${item.city}`,
}))
pageData.total = total
})
.finally(() => {
pageData.loading = false
})
}
// 获取供应信息列表
function getSupplyList() {
pageData.loading = true
ChanxiaoAPI.supplyList(pageData.search)
.then((res) => {
const { records, total } = res
pageData.supplyInfos = [...pageData.supplyInfos, ...records]
pageData.supplyInfos = pageData.supplyInfos.map((item) => ({
...item,
location: `${item.province}${item.city}`,
}))
pageData.total = total
})
.finally(() => {
pageData.loading = false
})
}
// 分类标签点击事件
function onCategoryTabClick(tab: any) {
console.log('点击分类标签:', tab)
// 在这里添加具体的分类标签点击逻辑
if (tab.id === -1) {
pageData.search.classify = null
} else {
pageData.search.classify = tab.id
}
pageData.search.pageNo = 1
pageData.purchaseDemands = []
pageData.supplyInfos = []
if (pageData.currentTransactionTab === 1) getPurchaseList()
if (pageData.currentTransactionTab === 2) getSupplyList()
}
// 采购/供应标签点击事件
function onTransactionTabClick(tab: any) {
console.log('点击采购/供应标签:', tab)
// 在这里添加具体的采购/供应标签点击逻辑
pageData.currentTransactionTab = tab.id
pageData.search.pageNo = 1
pageData.purchaseDemands = []
pageData.supplyInfos = []
if (pageData.currentTransactionTab === 1) getPurchaseList()
if (pageData.currentTransactionTab === 2) getSupplyList()
}
// 新需求提醒点击事件
function onNewDemandNoticeClick() {
console.log('点击新需求提醒')
// 在这里添加具体的新需求提醒点击逻辑
}
// function onNewDemandNoticeClick() {
// console.log('点击新需求提醒')
// // 在这里添加具体的新需求提醒点击逻辑
// }
// 采购需求点击事件
function onPurchaseDemandClick(demand: any) {
console.log('点击采购需求:', demand)
// 在这里添加具体的采购需求点击逻辑
Navigate.to(`/pages/chanxiao/purchaseXuQiu?id=${demand.id}`)
}
const priceDialogRef = ref()
// 立即报价点击事件
function onQuoteClick(item: any) {
console.log('点击立即报价:', item)
// 在这里添加具体的立即报价点击逻辑
priceDialogRef.value.open(item)
}
// 供应信息点击事件
function onSupplyInfoClick(info: any) {
console.log('点击供应信息:', info)
// 在这里添加具体的供应信息点击逻辑
Navigate.to(`/pages/chanxiao/supplyXuQiu?id=${info.id}`)
}
// 发布需求
function handlePublish() {
if (pageData.currentTransactionTab === 1) {
Navigate.to('/pages/chanxiao/purchaseXuQiu')
return
}
if (pageData.currentTransactionTab === 2) {
Navigate.to('/pages/chanxiao/supplyXuQiu')
return
}
}
onReachBottom(() => {
console.log('触底了')
if (pageData.currentTransactionTab === 1) {
if (pageData.total <= pageData.purchaseDemands.length) return
pageData.search.pageNo++
getPurchaseList()
}
if (pageData.currentTransactionTab === 2) {
if (pageData.total <= pageData.supplyInfos.length) return
pageData.search.pageNo++
getSupplyList()
}
})
</script>
<template>
......@@ -169,23 +271,23 @@
<text class="codefun-self-center text">{{ pageData.header.title }}</text>
<view class="codefun-mt-22 codefun-flex-col codefun-self-stretch">
<image class="image_5" :src="pageData.header.bannerImage" />
<view class="codefun-mt-14 codefun-flex-row">
<view class="codefun-mt-14 codefun-flex-row gap-1">
<view
v-for="tab in pageData.categoryTabs"
:key="tab.id"
class="codefun-flex-col codefun-justify-start codefun-items-center"
:class="[tab.id === 1 ? 'section_2' : 'text-wrapper', tab.id > 1 ? 'ml-7' : '']"
class="codefun-flex-col codefun-justify-start codefun-items-center text-wrapper"
:class="[
{ section_2: pageData.search.classify === tab.id },
{
section_2:
pageData.search.classify !== 0 && !pageData.search.classify && tab.id === -1,
},
]"
@click="onCategoryTabClick(tab)"
>
<view
v-if="tab.id === 1"
class="codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_2"
>
<view class="codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_2">
<text class="font text_2">{{ tab.name }}</text>
</view>
<text v-else class="font" :class="`text_${tab.id + 1}`">
{{ tab.name }}
</text>
</view>
</view>
</view>
......@@ -195,28 +297,31 @@
<view
v-for="tab in pageData.transactionTabs"
:key="tab.id"
class="codefun-flex-col codefun-justify-start codefun-items-center"
:class="[
tab.id === 1 ? 'text-wrapper_3' : '',
tab.id > 1 ? 'codefun-self-start' : '',
tab.id > 1 ? 'ml-55' : '',
]"
class="codefun-flex-col codefun-justify-start codefun-items-center section_50p"
:class="[pageData.currentTransactionTab === tab.id ? 'text-wrapper_3' : 'codefun-self-start']"
@click="onTransactionTabClick(tab)"
>
<text class="font" :class="`text_${tab.id + 7}`">
<text class="font" :class="pageData.currentTransactionTab === tab.id ? 'text_17' : 'text_27'">
{{ tab.name }}
</text>
</view>
</view>
<view class="codefun-flex-col codefun-relative section_4">
<view class="codefun-flex-row codefun-items-center section_5" @click="onNewDemandNoticeClick">
<!-- <view class="codefun-flex-row codefun-items-center section_5" @click="onNewDemandNoticeClick">
<image class="codefun-shrink-0 image_6" :src="pageData.newDemandNotice.icon" />
<text class="codefun-ml-12 font_2 text_10">{{ pageData.newDemandNotice.text }}</text>
</view>
</view> -->
<view
v-if="pageData.currentTransactionTab === 2 && pageData.supplyInfos.length === 0"
style="height: 528rpx"
>
<fui-empty src="/src/static/images/no-data.png" title="暂无数据"></fui-empty>
</view>
<!-- 供应信息列表 -->
<template v-for="(info, index) in pageData.supplyInfos" :key="info.id">
<view
v-show="pageData.currentTransactionTab === 2"
class="codefun-flex-row"
:class="[index === 0 ? 'group_10' : 'group_12']"
@click="onSupplyInfoClick(info)"
......@@ -226,13 +331,13 @@
:class="index === 0 ? 'section_7' : 'image-wrapper view'"
>
<image class="image_7" :src="info.image" />
<view
<!-- <view
v-if="info.tag.show"
class="codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_6"
:class="index === 0 ? 'pos_2' : ''"
>
<text class="font_3" :class="`text_${index === 0 ? 25 : 31}`">{{ info.tag.text }}</text>
</view>
</view> -->
</view>
<view
class="codefun-ml-12 codefun-flex-col codefun-flex-1"
......@@ -242,28 +347,27 @@
{{ info.title }}
</text>
<text
v-if="info.description"
v-if="info.productSpecs"
class="codefun-self-start font_2"
:class="index === 0 ? 'text_26 mt-11' : 'mt-11'"
>
{{ info.description }}
{{ info.productSpecs }}
</text>
<view
class="codefun-flex-row codefun-justify-between codefun-items-center codefun-self-stretch"
:class="index === 0 ? 'mt-11' : 'mt-11'"
>
<view class="codefun-flex-row">
<image class="codefun-shrink-0 image_9" :src="info.icons.location" />
<image class="codefun-shrink-0 image_9" :src="pageData.icons.location" />
<text class="codefun-ml-4 font_2" :class="`text_${index === 0 ? 27 : 30}`">{{
info.location
}}</text>
</view>
<view
v-if="info.actionText"
class="codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_5"
@click.stop="onQuoteClick(info)"
>
<text class="font_9">{{ info.actionText }}</text>
<text class="font_9">立即报价</text>
</view>
</view>
</view>
......@@ -271,8 +375,16 @@
</template>
<!-- 采购需求列表 -->
<view
v-if="pageData.currentTransactionTab === 1 && pageData.purchaseDemands.length === 0"
style="height: 528rpx"
>
<fui-empty src="/src/static/images/no-data.png" title="暂无数据"></fui-empty>
</view>
<view v-else>
<template v-for="(demand, index) in pageData.purchaseDemands" :key="demand.id">
<view
v-show="pageData.currentTransactionTab === 1"
class="codefun-flex-row codefun-items-center my-3"
:class="[index === 0 ? 'group_2' : '', index === 1 ? 'group_6' : '']"
@click="onPurchaseDemandClick(demand)"
......@@ -282,63 +394,84 @@
:class="index === 0 ? 'section_6' : 'image-wrapper'"
>
<image class="image_7" :src="demand.image" />
<view
<!-- <view
v-if="demand.tag.show"
class="codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_4"
:class="index === 0 ? 'pos' : ''"
>
<text class="font_3 text_11">{{ demand.tag.text }}</text>
</view>
</view> -->
</view>
<view class="codefun-ml-12 codefun-flex-col codefun-flex-1">
<text class="codefun-self-start font_4">{{ demand.title }}</text>
<view class="codefun-flex-row codefun-self-stretch mt-2">
<image class="image_8" :src="demand.icons.deadline" />
<view class="codefun-flex-row codefun-self-stretch mt-2" v-if="demand.deadline">
<image class="image_8" :src="pageData.icons.deadline" />
<text class="codefun-ml-4 font_2" :class="`text_${index === 0 ? 13 : 19}`">{{
demand.deadline
}}</text>
</view>
<view class="codefun-flex-row codefun-self-stretch mt-2">
<image class="image_9" :src="demand.icons.location" />
<image class="image_9" :src="pageData.icons.location" />
<text class="codefun-ml-4 font_2" :class="`text_${index === 0 ? 14 : 20}`">{{
demand.location
}}</text>
</view>
<view class="codefun-self-start" :class="index === 0 ? 'group_4' : 'group_8'">
<text v-if="demand.price" class="font_6" :class="`text_${index === 0 ? 15 : 21}`">¥</text>
<text v-if="demand.price" class="font_5">{{ demand.price }}</text>
<text v-if="demand.unit" class="font_7" :class="`text_${index === 0 ? 16 : 22}`">{{
demand.unit
<text
v-if="demand.priceStart || demand.priceEnd"
class="font_6"
:class="`text_${index === 0 ? 15 : 21}`"
</text
>
<text v-if="demand.priceStart || demand.priceEnd" class="font_5">{{
demand.priceStart + '-' + demand.priceEnd
}}</text>
<text v-if="demand.unit" class="font_7" :class="`text_${index === 0 ? 16 : 22}`"
>/{{ demand.unit }}</text
>
</view>
</view>
</view>
<view
v-show="pageData.currentTransactionTab === 1"
class="codefun-flex-row codefun-justify-between codefun-items-center"
:class="[index === 0 ? 'group_5' : '', index === 1 ? 'group_9' : '']"
>
<view class="codefun-flex-row codefun-items-center">
<image class="codefun-shrink-0 image_10" :src="demand.icons.quote" />
<image class="codefun-shrink-0 image_10" :src="pageData.icons.quote" />
<text
class="font_8"
:class="[index === 0 ? 'text_17' : 'text_23', index === 0 ? 'ml-5' : 'codefun-ml-4']"
>
{{ demand.quoteCount }}
{{ demand.supplyCounts }}人报价
</text>
</view>
<view
class="codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_5"
@click.stop="onQuoteClick(demand)"
>
<text class="font_9">{{ demand.actionText }}</text>
<text class="font_9">立即报价</text>
</view>
</view>
<!-- 分隔线 -->
<view class="divider" v-if="index < pageData.purchaseDemands.length - 1" />
</template>
</view>
</view>
</view>
<fui-fab background="#5db66f" position="right" distance="10" bottom="240" width="120" @click="handlePublish">
<view v-show="pageData.currentTransactionTab === 1" class="text-white text-center">
<image src="/src/static/images/chanxiao/notepad.svg" style="width: 40rpx" mode="widthFix"></image>
<view style="font-size: 24rpx">发布需求</view>
</view>
<view v-show="pageData.currentTransactionTab === 2" class="text-white text-center">
<image src="/src/static/images/chanxiao/flower.svg" style="width: 50rpx" mode="widthFix"></image>
<view style="font-size: 24rpx">发布供应</view>
</view>
</fui-fab>
<price-dialog ref="priceDialogRef"></price-dialog>
<fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)"></fui-loading>
</template>
<style scoped lang="scss">
......@@ -403,14 +536,12 @@
height: 37.3333vw;
}
.section_2 {
padding: 16rpx 0;
// padding: 16rpx 0;
flex: 1 1 104rpx;
background-color: #5db66f;
background-color: #5db66f !important;
border-radius: 19998rpx;
mix-blend-mode: NOTTHROUGH;
height: 72rpx;
.text-wrapper_2 {
padding: 8rpx 0;
overflow: hidden;
width: 56rpx;
.text_2 {
......@@ -452,12 +583,13 @@
border-right: solid 2rpx #ffffffcc;
border-top: solid 2rpx #ffffffcc;
border-bottom: solid 2rpx #ffffffcc;
.text-wrapper_3 {
.section_50p {
flex: 0 0 50%;
padding: 24rpx 0 52rpx;
}
.text-wrapper_3 {
background-color: #ffffff;
border-radius: 32rpx;
width: 348rpx;
height: 102rpx;
.text_8 {
color: #333333;
line-height: 26.02rpx;
......
<script setup lang="ts">
import { reactive } from 'vue'
import * as ChanxiaoAPI from '@/api/model/chanxiao'
const pageData = reactive({
show: false,
content: '',
form: {
purchaseId: '',
supplyName: null,
supplyPrice: null,
phone: null,
remark: null,
},
rules: [
{
name: 'supplyPrice',
rule: ['required'],
msg: ['请输入姓名'],
},
{
name: 'supplyPrice',
rule: ['required'],
msg: ['请输入报价'],
},
{
name: 'phone',
rule: ['required', 'isMobile'],
msg: ['请输入手机号', '请输入正确的手机号'],
},
],
})
function open(params) {
pageData.form.purchaseId = params.id
pageData.show = true
}
function close() {
pageData.show = false
}
function reset() {
pageData.form = {
purchaseId: '',
supplyName: null,
supplyPrice: null,
phone: null,
remark: null,
}
}
const formRef = ref()
function submit() {
formRef.value.validator(pageData.form, pageData.rules, true).then((res) => {
if (res.isPassed) {
ChanxiaoAPI.bizPurchaseSupplyRecord(pageData.form).then((res) => {
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-input
marginTop="30"
size="28"
placeholder="请填写联系人姓名"
v-model="pageData.form.supplyName"
></fui-input>
<fui-input
marginTop="30"
size="28"
placeholder="请填写联系电话"
v-model="pageData.form.phone"
></fui-input>
<fui-input marginTop="30" size="28" placeholder="请填写价格" v-model="pageData.form.supplyPrice">
<view class="flex">
<view class="mr-3" style="color: #ccc">|</view>
<view></view>
</view>
</fui-input>
<fui-textarea
:marginTop="30"
size="28"
height="80rpx"
placeholder="请输入报价备注"
v-model="pageData.form.remark"
></fui-textarea>
<view style="margin-top: 30rpx">
<fui-button 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 ChanxiaoAPI from '@/api/model/chanxiao'
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) => {
uni.setNavigationBarTitle({
title: '发布采购需求',
})
// 获取数据详情
if (option.id) {
getDetails(option.id)
} else {
// 获取当前位置
getCurrentAddressInfo()
}
})
onShow(() => {
// 数据字典赋值
initDict()
})
const pageData = reactive({
title: '发布采购需求',
show: {
time: false,
classify: false,
address: false,
},
options: {
address: [],
classify: [],
},
form: {
id: '',
title: '',
count: 0,
unit: '',
deadLine: '',
priceStart: 0,
priceEnd: 0,
address: '',
province: '',
city: '',
country: '',
classify: '',
classifyText: '',
inputTextArea: '',
image: null,
},
rules: [
{
name: 'title',
rule: ['required'],
msg: ['请输入标题'],
},
{
name: 'count',
rule: ['required'],
msg: ['请输入数量'],
},
{
name: 'unit',
rule: ['required'],
msg: ['请输入单位'],
},
{
name: 'deadLine',
rule: ['required'],
msg: ['请选择截至时间'],
},
{
name: 'priceStart',
rule: ['required'],
msg: ['请输入最低价'],
},
{
name: 'priceEnd',
rule: ['required'],
msg: ['请输入最高价'],
},
{
name: 'address',
rule: ['required'],
msg: ['请选择省/市/区县'],
},
{
name: 'classify',
rule: ['required'],
msg: ['请选择分类'],
},
{
name: 'image',
rule: ['required'],
msg: ['请上传示例图片'],
},
],
})
const { show, options, form } = toRefs(pageData)
function initDict() {
pageData.options.classify = dictStore.getDictList['classify'].map((item) => {
return {
value: item.value,
text: item.text,
}
})
pageData.options.address = areaTree
}
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.address = `${res.province}/${res.city}/${res.country}`
})
}
function getDetails(id) {
ChanxiaoAPI.purchaseSellDetails({ id }).then((res) => {
console.log(res)
pageData.form = res
pageData.form.address = `${getTextByCode(res.province)}/${getTextByCode(res.city)}/${getTextByCode(res.country)}`
})
}
function handleChangeTime(e) {
pageData.form.deadLine = e.result
pageData.show.time = false
}
function handleChangeClassify(e) {
pageData.form.classify = e.value
pageData.form.classifyText = e.text
pageData.show.classify = false
}
function handleChangeAddress(e) {
pageData.form.address = e.text.join('/')
pageData.show.address = 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.image = data.message // 保存返回的图片信息
}
}
},
fail: () => {
toastRef.value.show({
type: 'error',
text: '上传失败',
})
uploadRef.value.clearFiles()
pageData.form.image = null
},
})
}
// 文件删除
function handleDelete() {
uploadRef.value.clearFiles()
pageData.form.image = null
}
const formRef = ref()
function submit() {
formRef.value.validator(pageData.form, pageData.rules, true).then((res) => {
if (res.isPassed) {
changeAddressValue(pageData.form)
ChanxiaoAPI.purchaseSellAdd(pageData.form)
.then(() => {
toastRef.value.show({
type: 'success',
text: '需求发布成功',
})
uni.switchTab({
url: '/pages/chanxiao/chanxiao',
})
})
.catch((err) => {
toastRef.value.show({
type: 'error',
text: '需求发布失败',
})
})
}
})
}
/**
* 处理地区值
* @param formData 表单数据
*/
const changeAddressValue = (formData) => {
const addressValue = formData.address.split('/')
if (addressValue.length === 3) {
formData.province = getCodeByText(addressValue[0])
formData.city = getCodeByText(addressValue[1])
formData.country = getCodeByText(addressValue[2])
}
}
</script>
<template>
<fui-form ref="formRef">
<fui-input required label="标题" borderTop placeholder="请输入标题" v-model="form.title"></fui-input>
<fui-input required label="数量" borderTop placeholder="请输入数量" v-model="form.count"></fui-input>
<fui-input required label="单位" borderTop placeholder="请输入单位" v-model="form.unit"></fui-input>
<fui-input
required
label="截至时间"
borderTop
placeholder="请选择截至时间"
v-model="form.deadLine"
@click="show.time = true"
></fui-input>
<fui-input required label="最低价" placeholder="请输入最低价" v-model="form.priceStart"></fui-input>
<fui-input required label="最高价" placeholder="请输入最高价" v-model="form.priceEnd"></fui-input>
<fui-input
required
label="省/市/区县"
placeholder="请选择省/市/区县"
v-model="form.address"
@click="show.address = true"
></fui-input>
<fui-input
required
label="分类"
placeholder="请选择分类"
v-model="form.classifyText"
@click="show.classify = true"
></fui-input>
<fui-input label="说明" placeholder="请输入说明" v-model="form.inputTextArea"></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.time"
type="3"
@change="handleChangeTime"
@cancel="show.time = false"
></fui-date-picker>
<fui-picker
:show="show.classify"
:layer="1"
:linkage="true"
:options="options.classify"
@change="handleChangeClassify"
@cancel="show.classify = false"
></fui-picker>
<fui-picker
:show="show.address"
:options="options.address"
:linkage="true"
:layer="3"
@change="handleChangeAddress"
@cancel="show.address = false"
></fui-picker>
<fui-toast ref="toastRef"></fui-toast>
</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 ChanxiaoAPI from '@/api/model/chanxiao'
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) => {
uni.setNavigationBarTitle({
title: '发布供应需求',
})
// 获取数据详情
if (option.id) {
getDetails(option.id)
} else {
// 获取当前位置
getCurrentAddressInfo()
}
})
onShow(() => {
// 数据字典赋值
initDict()
})
const pageData = reactive({
title: '发布供应需求',
show: {
time1: false,
time2: false,
address: false,
status: false,
classify: false,
},
options: {
address: [],
status: [],
classify: [],
},
form: {
id: '',
title: '',
productSpecs: '',
minPrice: 0,
maxPrice: 0,
unit: '',
currency: '',
supplyQuantity: '',
minOrderQuantity: '',
address: '',
detailedAddress: '',
supplyStartDate: '',
supplyEndDate: '',
status: '',
classifyText: '',
classify: '',
statusText: '',
province: '',
city: '',
country: '',
image: null,
},
rules: [
{
name: 'title',
rule: ['required'],
msg: ['请输入标题'],
},
{
name: 'minPrice',
rule: ['required'],
msg: ['请输入最低价格'],
},
{
name: 'maxPrice',
rule: ['required'],
msg: ['请输入最高价格'],
},
{
name: 'unit',
rule: ['required'],
msg: ['请输入单位'],
},
{
name: 'currency',
rule: ['required'],
msg: ['请选择币种'],
},
{
name: 'supplyQuantity',
rule: ['required'],
msg: ['请输入供应数量'],
},
{
name: 'minOrderQuantity',
rule: ['required'],
msg: ['请输入最小订单数量'],
},
{
name: 'address',
rule: ['required'],
msg: ['请选择省/市/区县'],
},
{
name: 'status',
rule: ['required'],
msg: ['请选择状态'],
},
{
name: 'classify',
rule: ['required'],
msg: ['请选择分类'],
},
],
})
const { show, options, form } = toRefs(pageData)
function initDict() {
pageData.options.address = areaTree
console.log(dictStore.getDictList['purchase_status'])
pageData.options.status = dictStore.getDictList['purchase_status'].map((item) => {
return {
value: item.value,
text: item.text,
}
})
pageData.options.classify = dictStore.getDictList['classify'].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.address = `${res.province}/${res.city}/${res.country}`
})
}
function getDetails(id) {
ChanxiaoAPI.purchaseSellDetails({ id }).then((res) => {
console.log(res)
pageData.form = res
pageData.form.address = `${getTextByCode(res.province)}/${getTextByCode(res.city)}/${getTextByCode(res.country)}`
})
}
function handleChangeTime1(e) {
pageData.form.supplyStartDate = e.result
pageData.show.time1 = false
}
function handleChangeTime2(e) {
pageData.form.supplyEndDate = e.result
pageData.show.time2 = false
}
function handleChangeClassify(e) {
pageData.form.classify = e.value
pageData.form.classifyText = e.text
pageData.show.classify = false
}
function handleChangeAddress(e) {
pageData.form.address = e.text.join('/')
pageData.show.address = false
}
function handleChangeStatus(e) {
pageData.form.status = e.value
pageData.form.statusText = e.text
pageData.show.status = 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.image = data.message // 保存返回的图片信息
}
}
},
fail: (err) => {
toastRef.value.show({
type: 'error',
text: '上传失败',
})
uploadRef.value.clearFiles()
pageData.form.image = null
},
})
}
// 文件删除
function handleDelete(file) {
uploadRef.value.clearFiles()
pageData.form.image = null
}
const formRef = ref()
function submit() {
formRef.value.validator(pageData.form, pageData.rules, true).then((res) => {
if (res.isPassed) {
changeAddressValue(pageData.form)
ChanxiaoAPI.supplyAdd(pageData.form)
.then((res) => {
toastRef.value.show({
type: 'success',
text: '需求发布成功',
})
uni.switchTab({
url: '/pages/chanxiao/chanxiao',
})
})
.catch((err) => {
toastRef.value.show({
type: 'error',
text: '需求发布失败',
})
})
}
})
}
/**
* 处理地区值
* @param formData 表单数据
*/
const changeAddressValue = (formData) => {
const addressValue = formData.address.split('/')
if (addressValue.length === 3) {
formData.province = getCodeByText(addressValue[0])
formData.city = getCodeByText(addressValue[1])
formData.country = getCodeByText(addressValue[2])
}
}
</script>
<template>
<fui-form ref="formRef">
<fui-input required label="供应标题" placeholder="请输入供应标题" v-model="form.title"></fui-input>
<fui-input label="规格说明" borderTop placeholder="请输入规格说明" v-model="form.productSpecs"></fui-input>
<fui-input required label="最低价" borderTop placeholder="请输入最低价" v-model="form.minPrice"></fui-input>
<fui-input required label="最高价" borderTop placeholder="请输入最高价" v-model="form.maxPrice"></fui-input>
<fui-input required label="计量单位" borderTop placeholder="请输入计量单位" v-model="form.unit"></fui-input>
<fui-input required label="币种" borderTop placeholder="请输入币种" v-model="form.currency"></fui-input>
<fui-input
required
label="供应数量"
borderTop
placeholder="请输入供应数量"
v-model="form.supplyQuantity"
></fui-input>
<fui-input
required
label="最小起订量"
borderTop
placeholder="请输入最小起订量"
v-model="form.minOrderQuantity"
></fui-input>
<fui-input
required
label="省/市/区县"
placeholder="请选择省/市/区县"
v-model="form.address"
@click="show.address = true"
></fui-input>
<fui-input label="详细地址" placeholder="请输入详细地址" v-model="form.detailedAddress"></fui-input>
<fui-input
label="供应开始时间"
borderTop
placeholder="请选择供应开始时间"
v-model="form.supplyStartDate"
@click="show.time1 = true"
></fui-input>
<fui-input
label="供应结束时间"
borderTop
placeholder="请选择供应结束时间"
v-model="form.supplyEndDate"
@click="show.time2 = true"
></fui-input>
<fui-input
required
label="分类"
placeholder="请选择分类"
v-model="form.classifyText"
@click="show.classify = true"
></fui-input>
<fui-input
label="状态"
placeholder="请选择状态"
v-model="form.statusText"
@click="show.status = true"
></fui-input>
<view class="bg-white" style="padding: 0.875rem 1rem">
<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-picker
:show="show.status"
:layer="1"
:linkage="true"
:options="options.status"
@change="handleChangeStatus"
@cancel="show.status = false"
></fui-picker>
<fui-picker
:show="show.classify"
:layer="1"
:linkage="true"
:options="options.classify"
@change="handleChangeClassify"
@cancel="show.classify = false"
></fui-picker>
<fui-picker
:show="show.address"
:options="options.address"
:linkage="true"
:layer="3"
@change="handleChangeAddress"
@cancel="show.address = false"
></fui-picker>
<fui-toast ref="toastRef"></fui-toast>
</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({
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: '',
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.area = `${res.province}/${res.city}/${res.country}`
})
}
function getDetails(id) {
LinghuoyonggongAPI.employmentDetails({ id }).then((res) => {
console.log(res)
pageData.form = res
pageData.form.area = `${getTextByCode(res.province)}/${getTextByCode(res.city)}/${getTextByCode(res.country)}`
})
}
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.area = e.text.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) {
changeAddressValue(pageData.form)
LinghuoyonggongAPI.employmentAdd(pageData.form)
.then((res) => {
toastRef.value.show({
type: 'success',
text: '用工发布成功',
})
uni.switchTab({
url: '/pages/chanxiao/chanxiao',
})
})
.catch((err) => {
toastRef.value.show({
type: 'error',
text: '用工发布失败',
})
})
}
})
}
/**
* 处理地区值
* @param formData 表单数据
*/
const changeAddressValue = (formData) => {
const addressValue = formData.area.split('/')
if (addressValue.length === 3) {
formData.province = getCodeByText(addressValue[0])
formData.city = getCodeByText(addressValue[1])
formData.country = getCodeByText(addressValue[2])
}
}
</script>
<template>
<fui-form ref="formRef">
<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.area"
@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>
</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 { onPullDownRefresh, onLoad, onShow, onReachBottom } from '@dcloudio/uni-app'
import { areaTree, getTextByCode, getCodeByText } from '@/utils/areaData'
import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong'
import Navigate from '@/utils/page/navigate'
onShow(() => {
// pageData.purchaseDemands = []
pageData.search.pageNo = 1
if (pageData.currentEmploymentId === 1) {
pageData.search.publishstatu = 1
pageData.search.createBy = ''
}
if (pageData.currentEmploymentId === 2) {
pageData.search.publishstatu = 0
pageData.search.createBy = 'admin'
}
pageData.employmentList = []
getEmploymentList()
})
// 页面数据
const pageData = reactive({
loading: false,
// 分类标签
categoryTabs: [
{ id: 1, name: '全部' },
{ id: 2, name: '种植' },
{ id: 3, name: '养殖' },
{ id: 4, name: '采摘' },
{ id: 5, name: '其他' },
{ id: null, name: '全部' },
{ id: 1, name: '种植' },
{ id: 2, name: '养殖' },
{ id: 3, name: '采摘' },
{ id: 4, name: '其他' },
],
currentCategoryId: 1,
search: {
pageNo: 1,
pageSize: 10,
publishstatu: 1,
type: null,
createBy: '',
},
// 用工类型标签
employmentTabs: [
{ id: 1, name: '推荐用工' },
......@@ -22,74 +47,93 @@
// 用工列表
employmentList: [
{
id: 1,
image: 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=f33c4419bab5b0fb3a63b5b3006059f2.png',
title: '蔬菜种植',
duration: '预计3天',
people: '需要5人',
price: '150元/天',
distance: '3.2km',
rating: '4',
actionText: '我想去',
icons: {
duration:
'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=56353ebdea095baedbcb33fc53f68a03.png',
people: 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=85c3b17d5049630ed51fd57b701f047f.png',
price: 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=9e806e0315ec11c12ec9e2b6870dd395.png',
location:
'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=39c448ae66659127e7bcd035ea16e0de.png',
},
},
{
id: 2,
image: 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=f33c4419bab5b0fb3a63b5b3006059f2.png',
title: '果树修剪',
duration: '预计5天',
people: '需要3人',
price: '180元/天',
distance: '2.1km',
rating: '5',
actionText: '我想去',
icons: {
duration:
'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=56353ebdea095baedbcb33fc53f68a03.png',
people: 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=85c3b17d5049630ed51fd57b701f047f.png',
price: 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=9e806e0315ec11c12ec9e2b6870dd395.png',
location:
'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=39c448ae66659127e7bcd035ea16e0de.png',
},
},
{
id: 3,
image: 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=f33c4419bab5b0fb3a63b5b3006059f2.png',
title: '水稻插秧',
duration: '预计7天',
people: '需要8人',
price: '120元/天',
distance: '5.6km',
rating: '3',
actionText: '我想去',
icons: {
duration:
'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=56353ebdea095baedbcb33fc53f68a03.png',
people: 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=85c3b17d5049630ed51fd57b701f047f.png',
price: 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=9e806e0315ec11c12ec9e2b6870dd395.png',
location:
'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=39c448ae66659127e7bcd035ea16e0de.png',
},
},
// {
// id: 1,
// image: 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=f33c4419bab5b0fb3a63b5b3006059f2.png',
// title: '蔬菜种植',
// duration: '预计3天',
// people: '需要5人',
// price: '150元/天',
// distance: '3.2km',
// rating: '4',
// actionText: '我想去',
// icons: {
// duration:
// 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=56353ebdea095baedbcb33fc53f68a03.png',
// people: 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=85c3b17d5049630ed51fd57b701f047f.png',
// price: 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=9e806e0315ec11c12ec9e2b6870dd395.png',
// location:
// 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=39c448ae66659127e7bcd035ea16e0de.png',
// },
// },
// {
// id: 2,
// image: 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=f33c4419bab5b0fb3a63b5b3006059f2.png',
// title: '果树修剪',
// duration: '预计5天',
// people: '需要3人',
// price: '180元/天',
// distance: '2.1km',
// rating: '5',
// actionText: '我想去',
// icons: {
// duration:
// 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=56353ebdea095baedbcb33fc53f68a03.png',
// people: 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=85c3b17d5049630ed51fd57b701f047f.png',
// price: 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=9e806e0315ec11c12ec9e2b6870dd395.png',
// location:
// 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=39c448ae66659127e7bcd035ea16e0de.png',
// },
// },
// {
// id: 3,
// image: 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=f33c4419bab5b0fb3a63b5b3006059f2.png',
// title: '水稻插秧',
// duration: '预计7天',
// people: '需要8人',
// price: '120元/天',
// distance: '5.6km',
// rating: '3',
// actionText: '我想去',
// icons: {
// duration:
// 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=56353ebdea095baedbcb33fc53f68a03.png',
// people: 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=85c3b17d5049630ed51fd57b701f047f.png',
// price: 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=9e806e0315ec11c12ec9e2b6870dd395.png',
// location:
// 'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=39c448ae66659127e7bcd035ea16e0de.png',
// },
// },
],
total: 0,
})
// 底部图片
bottomImage:
'https://ide.code.fun/api/image?token=6902c43a9520a30011f4e723&name=da7c9ea8588c4314497b9c7ce7d4e632.png',
function getEmploymentList() {
pageData.loading = true
LinghuoyonggongAPI.employmentList(pageData.search)
.then((res) => {
const { records, total } = res
console.log('records', records)
records.map((item) => {
item.area = item.area.split(',')
item.area = getTextByCode(item.area[0]) + ' ' + getTextByCode(item.area[1])
return item
})
pageData.employmentList = [...pageData.employmentList, ...records]
pageData.total = total
})
.finally(() => {
pageData.loading = false
})
}
// 分类标签点击事件
function onCategoryTabClick(tab: any) {
console.log('点击分类标签:', tab)
pageData.currentCategoryId = tab.id
pageData.search.type = tab.id
pageData.search.pageNo = 1
pageData.employmentList = []
getEmploymentList()
// 在这里添加具体的分类标签点击逻辑
}
......@@ -97,6 +141,17 @@
function onEmploymentTabClick(tab: any) {
console.log('点击用工类型标签:', tab)
pageData.currentEmploymentId = tab.id
pageData.search.pageNo = 1
pageData.employmentList = []
if (pageData.currentEmploymentId === 1) {
pageData.search.publishstatu = 1
pageData.search.createBy = ''
}
if (pageData.currentEmploymentId === 2) {
pageData.search.publishstatu = 0
pageData.search.createBy = 'admin'
}
getEmploymentList()
// 在这里添加具体的用工类型标签点击逻辑
}
......@@ -111,20 +166,50 @@
console.log('点击"我想去"按钮:', item)
// 在这里添加具体的"我想去"按钮点击逻辑
}
// 发布用工
function handlePublish() {
Navigate.to('/pages/linghuoyonggong/form')
}
// 获取时间差
function getDaysDiff(date1: Date | number | string, date2: Date | number | string): number {
// 将输入转换为Date对象
const d1 = new Date(date1)
const d2 = new Date(date2)
// 检查日期是否有效
if (isNaN(d1.getTime()) || isNaN(d2.getTime())) {
throw new Error('无效的日期格式')
}
// 设置时间部分为00:00:00,只比较日期部分
d1.setHours(0, 0, 0, 0)
d2.setHours(0, 0, 0, 0)
// 计算两个日期之间的毫秒差
const diffTime = Math.abs(d2.getTime() - d1.getTime())
// 转换为天数
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24))
return diffDays
}
onReachBottom(() => {
console.log('触底了')
if (pageData.total <= pageData.employmentList.length) return
pageData.search.pageNo++
getEmploymentList()
})
</script>
<template>
<view class="codefun-flex-col page">
<view class="codefun-flex-col codefun-self-stretch">
<view class="codefun-mt-14 codefun-flex-row group_2">
<view class="codefun-mt-14 codefun-flex-row group_2 gap-2">
<view
v-for="tab in pageData.categoryTabs"
:key="tab.id"
class="codefun-flex-col codefun-justify-start codefun-items-center"
:class="[
tab.id === pageData.currentCategoryId ? 'text-wrapper' : 'text-wrapper_2',
tab.id > 1 ? 'codefun-ml-12' : '',
]"
:class="[tab.id === pageData.search.type ? 'text-wrapper' : 'text-wrapper_2']"
@click="onCategoryTabClick(tab)"
>
<text class="font_2 text_2">
......@@ -147,6 +232,10 @@
</view>
</view>
<view class="codefun-flex-col codefun-relative list">
<view v-if="!pageData.employmentList || pageData.employmentList.length == 0" style="height: 528rpx">
<fui-empty src="/src/static/images/no-data.png" title="暂无数据"></fui-empty>
</view>
<template v-else>
<view
class="codefun-flex-col list-item"
v-for="item in pageData.employmentList"
......@@ -154,41 +243,67 @@
@click="onEmploymentItemClick(item)"
>
<view class="codefun-flex-row">
<image class="image_7" :src="item.image" />
<image class="image_7" :src="item.picture" />
<view class="codefun-flex-col codefun-flex-1 codefun-self-center group_4">
<text class="codefun-self-start font">{{ item.title }}</text>
<view class="codefun-flex-row codefun-justify-between codefun-items-center">
<text class="codefun-self-start font">{{ item.name }}</text>
<view>
<image
class="codefun-self-start image_8"
src="/src/static/images/codefun/c98744e63719b5413f260ec6a899ee20.png"
/>
<text class="codefun-self-start font_3 text_9">{{ item.area }}</text>
</view>
</view>
<view
class="codefun-flex-row codefun-justify-between codefun-items-center codefun-self-stretch mt-11"
>
<image class="image_9" :src="item.icons.duration" />
<text class="font_4">{{ item.duration }}</text>
<image class="image_9" :src="item.icons.people" />
<text class="font_4">{{ item.people }}</text>
<image class="image_9" :src="item.icons.price" />
<text class="font_4 text_10">{{ item.price }}</text>
<view class="flex codefun-items-center">
<image class="image_9" src="/src/static/images/time.svg" />
<text class="font_4"
>预计{{ getDaysDiff(item.starttime, item.estimatedendtime) }}</text
>
</view>
<view class="flex codefun-items-center">
<image class="image_9" src="/src/static/images/person.svg" />
<text class="font_4">需要{{ item.workers }}</text>
</view>
<view class="flex codefun-items-center">
<image class="image_9" src="/src/static/images/money.svg" />
<text class="font_4 text_10">{{ item.price }}</text>
</view>
</view>
</view>
<image class="codefun-self-start image_8" :src="item.icons.location" />
<text class="codefun-self-start font_3 text_9">{{ item.distance }}</text>
</view>
<view class="codefun-mt-8 codefun-flex-row codefun-justify-between codefun-items-center">
<view class="flex-center">
<fui-rate :score="item.rating" :size="36" />
<text class="font_5 ml-1">{{ item.rating }}</text>
<fui-rate :score="item.urgentdegree" :size="36" />
<text class="font_5 ml-1">{{ item.urgentdegree }}</text>
</view>
<view
v-if="pageData.currentEmploymentId !== 2"
class="codefun-flex-col codefun-justify-start codefun-items-center text-wrapper_4"
@click.stop="onActionButtonClick(item)"
>
<text class="font_6 text_12">{{ item.actionText }}</text>
<text class="font_6 text_12">我想去</text>
</view>
</view>
</view>
</template>
</view>
</view>
</view>
<!-- <image class="codefun-self-end image_7 image_12 mt-269" :src="pageData.bottomImage" /> -->
</view>
<image class="codefun-self-end image_7 image_12 mt-269" :src="pageData.bottomImage" />
<fui-fab background="#5db66f" position="right" distance="10" bottom="240" width="120" @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">发布用工</view>
</view>
</fui-fab>
<fui-loading isFixed v-if="pageData.loading" backgroundColor="rgba(0, 0, 0, 0.4)"></fui-loading>
</template>
<style scoped lang="scss">
......
......@@ -262,7 +262,7 @@
status: 1,
}).then((res) => {
const { records } = res
pageData.agricultureClass.videoList = records
pageData.agricultureClass.videoList = records.reverse()
pageData.agricultureClass.title = records[0]?.title
})
}
......@@ -335,6 +335,16 @@
function handleMetadataLoaded(e: any) {
pageData.agricultureClass.time = e.target.duration
}
// 解决轮播视频切换时,上一个视频不停止播放的问题
const handleVideoPlay = (currentIndex) => {
pageData.agricultureClass.videoList.forEach((_, index) => {
if (index != currentIndex) {
const videoContext = uni.createVideoContext(`video${index}`)
videoContext.pause()
}
})
}
</script>
<template>
......@@ -656,11 +666,13 @@
>
<swiper-item v-for="(video, index) in pageData.agricultureClass.videoList" :key="index">
<video
:id="'video' + index"
:src="video.media_video"
:poster="video.cover_image"
:controls="false"
style="width: 654rpx; height: 358rpx"
@loadedmetadata="handleMetadataLoaded"
@play="handleVideoPlay(index)"
></video>
</swiper-item>
</swiper>
......
......@@ -11,7 +11,26 @@
location: '112.982931,28.116698',
})
onLoad(() => {})
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',
})
},
})
})
onShow(() => {
uni.getLocation({
......@@ -39,6 +58,8 @@
// 查询金刚区数据
getServiceItems()
getMenuItems()
// 查询天气信息
getWarningInfo()
// 查询热门产地行情
getProductMarketList()
// 服务展示窗
......@@ -113,7 +134,9 @@
{ day: '周三', temp: '25-29°', icon: '101' },
{ day: '周四', temp: '26-31°', icon: '102' },
],
warning: '台风"尤特"12号 预计今晚登陆',
warning: '',
lon: null,
lat: null,
},
// 功能菜单
......@@ -187,7 +210,7 @@
// 农技课堂
agricultureClass: {
title: '专家实录—鸡饲养技术',
title: '',
// expert: '张教授',
time: '',
videoList: [],
......@@ -219,6 +242,16 @@
pageData.menuItems = records
})
}
function getWarningInfo() {
if (!pageData.weather.lon || !pageData.weather.lat) return
HomeAPI.warningInfo({
lon: pageData.weather.lon,
lat: pageData.weather.lat,
}).then((res) => {
pageData.weather.warning = res[0].criteria
})
}
function getProductMarketList() {
HomeAPI.productMarketList({
status: 1,
......@@ -285,6 +318,15 @@
function handleMetadataLoaded(e: any) {
pageData.agricultureClass.time = e.target.duration
}
// 解决轮播视频切换时,上一个视频不停止播放的问题
const handleVideoPlay = (currentIndex) => {
pageData.agricultureClass.videoList.forEach((_, index) => {
if (index != currentIndex) {
const videoContext = uni.createVideoContext(`video${index}`)
videoContext.pause()
}
})
}
</script>
<template>
......@@ -498,7 +540,7 @@
text_26: !product.isUp,
}"
>
{{ `${product.percent}%` }}
{{ `${product.isUp ? '' : '-'}${product.percent}%` }}
</text>
</view>
<view
......@@ -562,11 +604,13 @@
>
<swiper-item v-for="(video, index) in pageData.agricultureClass.videoList" :key="index">
<video
:id="'video' + index"
:src="video.media_video"
:poster="video.cover_image"
:controls="false"
style="width: 654rpx; height: 358rpx"
@loadedmetadata="handleMetadataLoaded"
@play="handleVideoPlay(index)"
></video>
</swiper-item>
</swiper>
......@@ -814,15 +858,19 @@
}
.text-wrapper_5 {
margin-right: 180rpx;
overflow: hidden;
width: 366rpx;
width: 90%;
height: 40rpx;
.text_12 {
margin-left: 2.3rpx;
margin-right: 13.7rpx;
color: #ff612c;
font-size: 28rpx;
line-height: 40rpx;
overflow: hidden;
text-overflow: ellipsis; /* 超出以 ...显示 */
display: -webkit-box;
-webkit-line-clamp: 1; /* // 显示1行 */
-webkit-box-orient: vertical;
color: #ff612c;
}
}
}
......
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="22.579986572265625" height="20.3499755859375" viewBox="0 0 22.579986572265625 20.3499755859375" fill="none"><path d="M11.2547 2.00277C10.7996 1.58833 10.2752 1.20597 9.69565 0.866181C8.71105 0.288975 7.90679 0.0329195 7.87295 0.0224374C7.86525 0.0200137 7.85749 0.0177827 7.84967 0.0157443C7.84185 0.0137067 7.83399 0.0118646 7.82608 0.0102179C7.81817 0.00857123 7.81022 0.00712241 7.80223 0.00587155C7.79424 0.00462058 7.78623 0.00356877 7.77819 0.00271602C7.77015 0.00186325 7.76209 0.00121121 7.75401 0.000759875C7.74594 0.000308451 7.73786 5.82036e-05 7.72977 9.03954e-06C7.72168 -4.01245e-05 7.7136 0.000111426 7.70552 0.000463599C7.69744 0.000816695 7.68937 0.00137041 7.68132 0.00212485C7.67327 0.00287928 7.66524 0.00383313 7.65724 0.0049865C7.64924 0.00613997 7.64127 0.00749166 7.63334 0.00904157C7.62541 0.0105915 7.61752 0.0123377 7.60968 0.0142801C7.60184 0.0162219 7.59405 0.0183579 7.58632 0.020688C7.57859 0.0230174 7.57092 0.0255377 7.56332 0.0282491C7.55572 0.0309605 7.54819 0.0338588 7.54074 0.0369443C7.53329 0.0400297 7.52593 0.0432984 7.51864 0.0467506C7.51136 0.0502027 7.50417 0.0538337 7.49708 0.0576438C7.48998 0.0614481 7.48299 0.0654266 7.47609 0.0695792C7.4692 0.0737317 7.46242 0.0780531 7.45575 0.0825434C7.44908 0.0870328 7.44253 0.0916851 7.4361 0.0965002C7.42968 0.101316 7.42338 0.106288 7.41721 0.111417C7.41103 0.116546 7.405 0.121824 7.3991 0.127252C7.3932 0.132682 7.38745 0.138253 7.38184 0.143968C7.37623 0.149682 7.37077 0.155533 7.36546 0.161521C7.36015 0.167511 7.355 0.173624 7.35001 0.179862C7.34502 0.186109 7.3402 0.192472 7.33553 0.198952C7.33087 0.205434 7.32638 0.212027 7.32206 0.218733C7.31774 0.225438 7.31359 0.232248 7.30962 0.239164C7.30565 0.246072 7.30187 0.253076 7.29826 0.260178C7.29465 0.267278 7.29123 0.274463 7.28799 0.281733C7.28476 0.289004 7.28171 0.29635 7.27886 0.303774C7.276 0.311197 7.27334 0.318685 7.27087 0.326237C7.26841 0.333798 7.26614 0.34141 7.26406 0.349075C7.25496 0.382722 7.04078 1.18484 7.00503 2.30922C6.98394 2.97111 7.02928 3.61046 7.13941 4.20973C7.2789 4.96819 7.52358 5.66465 7.86657 6.2799C8.20957 6.89516 8.67545 7.47283 9.25147 7.9973C9.7065 8.41174 10.231 8.7941 10.8105 9.13388C11.7951 9.7111 12.5993 9.96714 12.6332 9.97764C12.6568 9.98506 12.6809 9.99065 12.7054 9.9944C12.7299 9.99815 12.7546 10 12.7794 10C12.7894 10 12.7993 9.9997 12.8093 9.9991C12.8193 9.99848 12.8292 9.99757 12.8391 9.99635C12.849 9.99512 12.8589 9.99361 12.8687 9.99178C12.8785 9.98996 12.8882 9.98782 12.8979 9.9854C12.9076 9.98297 12.9172 9.98025 12.9267 9.97724C12.9362 9.97421 12.9456 9.97091 12.9549 9.96732C12.9641 9.96373 12.9733 9.95986 12.9823 9.9557C12.9914 9.95155 13.0003 9.94712 13.0091 9.94242C13.0162 9.93861 13.0231 9.93463 13.03 9.93048C13.0369 9.92633 13.0437 9.922 13.0504 9.91751C13.057 9.91301 13.0636 9.90837 13.07 9.90356C13.0765 9.89875 13.0828 9.89378 13.0889 9.88864C13.0951 9.88351 13.1011 9.87824 13.107 9.87282C13.1129 9.86739 13.1187 9.86181 13.1243 9.85609C13.1299 9.85038 13.1354 9.84452 13.1407 9.83854C13.146 9.83255 13.1511 9.82644 13.1561 9.8202C13.1611 9.81396 13.1659 9.80759 13.1706 9.80111C13.1753 9.79463 13.1798 9.78803 13.1841 9.78133C13.1884 9.77462 13.1925 9.76781 13.1965 9.76091C13.2005 9.75399 13.2043 9.74698 13.2079 9.73988C13.2115 9.73279 13.2149 9.72559 13.2181 9.71833C13.2214 9.71106 13.2244 9.70371 13.2273 9.69629C13.2301 9.68888 13.2328 9.68138 13.2353 9.67382C13.2377 9.66627 13.24 9.65866 13.2421 9.651C13.2512 9.61734 13.4654 8.81522 13.5011 7.69085C13.5222 7.02897 13.4769 6.38962 13.3666 5.79034C13.2271 5.03188 12.9824 4.33541 12.6394 3.72016C12.2964 3.10491 11.8305 2.52723 11.2547 2.00276L11.2547 2.00277ZM12.5448 7.63763C12.5301 8.14113 12.475 8.57685 12.4225 8.89035C12.1252 8.76451 11.7214 8.57482 11.281 8.31533C10.4736 7.83922 9.37149 7.02129 8.70673 5.829C8.04182 4.63669 7.93439 3.28553 7.96121 2.36196C7.97589 1.85847 8.03096 1.42258 8.08331 1.10924C8.38066 1.23508 8.78447 1.42477 9.22481 1.68427C10.0322 2.16038 11.1343 2.9783 11.7991 4.1706C12.4642 5.36305 12.5717 6.71422 12.5448 7.63763L12.5448 7.63763ZM16.5358 6.74208C16.0214 7.28972 15.3348 7.73264 14.4951 8.05896C14.2493 8.15444 14.129 8.42739 14.2264 8.66842C14.3009 8.8528 14.4811 8.96516 14.6717 8.96516C14.7304 8.96516 14.7901 8.95452 14.8479 8.93198C15.8224 8.55339 16.6273 8.03063 17.2402 7.37846C17.6574 6.93427 18.0096 6.40245 18.287 5.79753C18.5057 5.32065 18.6787 4.79727 18.8011 4.24197C19.0091 3.29883 19.0003 2.58577 18.9998 2.55588C18.9997 2.54795 18.9994 2.54003 18.9988 2.53211C18.9983 2.52421 18.9976 2.51631 18.9966 2.50843C18.9957 2.50056 18.9945 2.49271 18.9932 2.48489C18.9918 2.47707 18.9903 2.46929 18.9885 2.46154C18.9868 2.45381 18.9848 2.44612 18.9827 2.43847C18.9805 2.43082 18.9782 2.42324 18.9756 2.41571C18.9731 2.40818 18.9703 2.40072 18.9674 2.39332C18.9645 2.38593 18.9614 2.37862 18.9581 2.37138C18.9547 2.36414 18.9513 2.35699 18.9476 2.34993C18.9439 2.34286 18.9401 2.33589 18.936 2.32903C18.932 2.32215 18.9278 2.31538 18.9234 2.30871C18.919 2.30205 18.9144 2.2955 18.9097 2.28907C18.905 2.28262 18.9001 2.27631 18.8951 2.27012C18.89 2.26392 18.8848 2.25786 18.8794 2.25193C18.8741 2.24599 18.8686 2.24019 18.8629 2.23453C18.8572 2.22886 18.8514 2.22335 18.8455 2.21797C18.8395 2.2126 18.8335 2.20737 18.8272 2.20231C18.821 2.19724 18.8147 2.19232 18.8082 2.18756C18.8017 2.18281 18.7951 2.17821 18.7884 2.17379C18.7817 2.16936 18.7749 2.16511 18.768 2.16101C18.761 2.15692 18.754 2.15301 18.7469 2.14927C18.7397 2.14553 18.7325 2.14197 18.7252 2.13858C18.7179 2.13521 18.7105 2.13201 18.703 2.12899C18.6955 2.12598 18.688 2.12316 18.6804 2.12051C18.6727 2.11787 18.665 2.11543 18.6573 2.11317C18.6495 2.11091 18.6417 2.10885 18.6339 2.10698C18.626 2.10512 18.6181 2.10345 18.6101 2.10196C18.6022 2.10049 18.5942 2.0992 18.5862 2.09813C18.5782 2.09705 18.5702 2.09618 18.5621 2.09549C18.5541 2.09482 18.546 2.09433 18.5379 2.09405C18.5298 2.09378 18.5217 2.0937 18.5136 2.09382C18.5056 2.09395 18.4975 2.09427 18.4894 2.09479C18.4589 2.09684 17.7335 2.14644 16.792 2.42676C16.2377 2.59188 15.7198 2.80363 15.2531 3.05625C14.661 3.37678 14.1493 3.76446 13.7319 4.20864C13.5527 4.39942 13.5651 4.69633 13.7595 4.87208C13.9541 5.04785 14.2568 5.03564 14.4361 4.845C15.2231 4.00736 16.2904 3.56006 17.0471 3.33233C17.2055 3.28475 17.3654 3.24191 17.5265 3.20384C17.6876 3.16577 17.8498 3.13253 18.013 3.10413C17.9975 3.26596 17.9769 3.42717 17.9514 3.58776C17.9259 3.74836 17.8954 3.90805 17.8599 4.06683C17.6904 4.82482 17.323 5.90443 16.5358 6.74208Z" fill="#FFFFFF" ></path><path d="M3.38 18.37L0.53 18.37L0.5 18.37L0.48 18.37L0.45 18.36L0.42 18.36L0.4 18.35L0.37 18.35L0.35 18.34L0.33 18.33L0.3 18.32L0.28 18.31L0.26 18.29L0.23 18.28L0.21 18.27L0.19 18.25L0.17 18.23L0.15 18.22L0.14 18.2L0.12 18.18L0.1 18.16L0.09 18.14L0.08 18.11L0.06 18.09L0.05 18.07L0.04 18.04L0.03 18.02L0.02 18L0.02 17.97L0.01 17.95L0.01 17.92L0 17.89L0 17.87L0 17.84L0 9.53L0 9.5L0 9.47L0.01 9.45L0.01 9.42L0.02 9.4L0.02 9.37L0.03 9.35L0.04 9.32L0.05 9.3L0.06 9.28L0.08 9.25L0.09 9.23L0.1 9.21L0.12 9.19L0.14 9.17L0.15 9.15L0.17 9.13L0.19 9.12L0.21 9.1L0.23 9.09L0.26 9.07L0.28 9.06L0.3 9.05L0.33 9.04L0.35 9.03L0.37 9.02L0.4 9.01L0.42 9.01L0.45 9L0.48 9L0.5 9L0.53 9L3.38 9L3.4 9L3.43 9L3.46 9L3.48 9.01L3.51 9.01L3.53 9.02L3.56 9.03L3.58 9.04L3.6 9.05L3.63 9.06L3.65 9.07L3.67 9.09L3.69 9.1L3.71 9.12L3.73 9.13L3.75 9.15L3.77 9.17L3.79 9.19L3.8 9.21L3.82 9.23L3.83 9.25L3.84 9.28L3.85 9.3L3.87 9.32L3.87 9.35L3.88 9.37L3.89 9.4L3.9 9.42L3.9 9.45L3.9 9.47L3.9 9.5L3.91 9.53L3.91 17.84L3.9 17.87L3.9 17.89L3.9 17.92L3.9 17.95L3.89 17.97L3.88 18L3.87 18.02L3.87 18.04L3.85 18.07L3.84 18.09L3.83 18.11L3.82 18.14L3.8 18.16L3.79 18.18L3.77 18.2L3.75 18.22L3.73 18.23L3.71 18.25L3.69 18.27L3.67 18.28L3.65 18.29L3.63 18.31L3.6 18.32L3.58 18.33L3.56 18.34L3.53 18.35L3.51 18.35L3.48 18.36L3.46 18.36L3.43 18.37L3.4 18.37L3.38 18.37ZM1.05 17.31L2.85 17.31L2.85 10.05L1.05 10.05L1.05 17.31ZM11.31 20.35L8.76 20.35C8.73185 20.35 8.70782 20.34 8.68 20.34C8.65218 20.34 8.61681 20.32 8.59 20.32C7.02481 19.8012 3.53769 17.8244 3.39 17.74L3.36 17.73L3.34 17.71L3.32 17.7L3.3 17.68L3.28 17.66L3.26 17.64L3.25 17.62L3.23 17.6L3.21 17.58L3.2 17.56L3.19 17.54L3.17 17.52L3.16 17.49L3.15 17.47L3.14 17.44L3.14 17.42L3.13 17.39L3.13 17.37L3.12 17.34L3.12 17.32L3.12 17.29L3.12 17.27L3.12 17.24L3.12 17.21L3.13 17.19L3.13 17.16L3.14 17.14L3.14 17.11L3.15 17.09L3.16 17.07L3.17 17.04L3.19 17.02L3.2 17L3.21 16.98L3.23 16.95L3.25 16.93L3.26 16.92L3.28 16.9L3.3 16.88L3.32 16.86L3.34 16.85L3.36 16.83L3.39 16.82L3.41 16.81L3.43 16.8L3.46 16.79L3.48 16.78L3.51 16.77L3.53 16.76L3.56 16.76L3.58 16.76L3.61 16.75L3.63 16.75L3.66 16.75L3.69 16.75L3.71 16.76L3.74 16.76L3.76 16.76L3.79 16.77L3.81 16.78L3.84 16.79L3.86 16.8L3.88 16.81L3.91 16.82C3.94452 16.8401 7.34045 18.7706 8.85 19.3L11.22 19.3L21.37 15.45C21.1235 14.9647 20.5699 14.25 19.49 14.25L14.09 14.25L14.06 14.25L14.04 14.25L14.01 14.24L13.99 14.24L13.96 14.23L13.94 14.22L13.91 14.22L13.89 14.21L13.86 14.2L13.84 14.19L13.82 14.17L13.8 14.16L13.78 14.14L13.75 14.13L13.74 14.11L13.72 14.09L13.7 14.07L13.68 14.05L13.67 14.03L13.65 14.01L13.64 13.99L13.62 13.97L13.61 13.95L13.6 13.92L13.59 13.9L13.58 13.87L13.58 13.85L13.57 13.82L13.57 13.8L13.56 13.77L13.56 13.75L13.56 13.72L13.56 13.69L13.56 13.67L13.57 13.64L13.57 13.62L13.58 13.59L13.58 13.57L13.59 13.54L13.6 13.52L13.61 13.49L13.62 13.47L13.64 13.45L13.65 13.43L13.67 13.41L13.68 13.39L13.7 13.37L13.72 13.35L13.74 13.33L13.75 13.31L13.78 13.3L13.8 13.28L13.82 13.27L13.84 13.25L13.86 13.24L13.89 13.23L13.91 13.22L13.94 13.22L13.96 13.21L13.99 13.2L14.01 13.2L14.04 13.2L14.06 13.19L14.09 13.19L19.5 13.19C21.443 13.19 22.349 14.7889 22.56 15.63L22.57 15.65L22.57 15.67L22.58 15.7L22.58 15.72L22.58 15.74L22.58 15.77L22.58 15.79L22.58 15.82L22.57 15.84L22.57 15.86L22.56 15.89L22.56 15.91L22.55 15.93L22.54 15.96L22.53 15.98L22.52 16L22.51 16.02L22.5 16.04L22.48 16.06L22.47 16.08L22.45 16.1L22.44 16.12L22.42 16.13L22.4 16.15L22.38 16.16L22.36 16.18L22.34 16.19L22.32 16.21L22.3 16.22L22.28 16.23L22.26 16.24L22.24 16.25L11.5 20.32C11.4699 20.3311 11.4416 20.34 11.41 20.34C11.3784 20.34 11.3421 20.35 11.31 20.35ZM15.03 16.4L7.79 16.4L7.76 16.4L7.73 16.4L7.71 16.39L7.68 16.39L7.66 16.38L7.63 16.38L7.61 16.37L7.58 16.36L7.56 16.35L7.54 16.34L7.51 16.32L7.49 16.31L7.47 16.29L7.45 16.28L7.43 16.26L7.41 16.24L7.39 16.22L7.38 16.21L7.36 16.18L7.35 16.16L7.33 16.14L7.32 16.12L7.31 16.1L7.3 16.07L7.29 16.05L7.28 16.02L7.27 16L7.27 15.97L7.26 15.95L7.26 15.92L7.26 15.9L7.26 15.87L7.26 15.84L7.26 15.82L7.26 15.79L7.27 15.77L7.27 15.74L7.28 15.72L7.29 15.69L7.3 15.67L7.31 15.64L7.32 15.62L7.33 15.6L7.35 15.58L7.36 15.56L7.38 15.54L7.39 15.52L7.41 15.5L7.43 15.48L7.45 15.46L7.47 15.45L7.49 15.43L7.51 15.42L7.54 15.41L7.56 15.39L7.58 15.38L7.61 15.37L7.63 15.37L7.66 15.36L7.68 15.35L7.71 15.35L7.73 15.35L7.76 15.34L7.79 15.34L14.43 15.34C14.102 14.1047 12.7112 13.3603 12.34 13.18L8.83 13.18C8.81982 13.18 8.81016 13.18 8.8 13.18C8.78984 13.18 8.78012 13.17 8.77 13.17C8.75988 13.17 8.75004 13.17 8.74 13.17C8.72996 13.17 8.71 13.16 8.71 13.16L8.68 13.15L8.65 13.15L8.62 13.13L8.6 13.12L8.57 13.11L8.54 13.09L8.52 13.07L8.49 13.05L8.47 13.03L8.45 13.01L8.43 12.99L8.41 12.97C7.01553 11.1133 3.66355 11.01 3.63 11.01L3.61 11L3.58 11L3.55 11L3.53 11L3.5 10.99L3.48 10.98L3.45 10.97L3.43 10.96L3.4 10.95L3.38 10.94L3.36 10.93L3.33 10.91L3.31 10.9L3.29 10.88L3.27 10.87L3.25 10.85L3.23 10.83L3.22 10.81L3.2 10.79L3.19 10.77L3.17 10.74L3.16 10.72L3.15 10.7L3.14 10.67L3.13 10.65L3.12 10.62L3.11 10.6L3.11 10.57L3.11 10.54L3.1 10.52L3.1 10.49L3.1 10.46L3.1 10.44L3.11 10.41L3.11 10.39L3.11 10.36L3.12 10.33L3.13 10.31L3.14 10.28L3.15 10.26L3.16 10.24L3.17 10.21L3.19 10.19L3.2 10.17L3.22 10.15L3.23 10.13L3.25 10.11L3.27 10.09L3.29 10.07L3.31 10.06L3.33 10.04L3.36 10.03L3.38 10.01L3.4 10L3.43 9.99L3.45 9.98L3.48 9.97L3.5 9.97L3.53 9.96L3.55 9.96L3.58 9.95L3.61 9.95L3.63 9.95L3.66 9.95C3.81344 9.95 7.32535 10.0619 9.09 12.12L12.45 12.12C12.521 12.12 12.5948 12.1322 12.66 12.16C12.778 12.2108 15.56 13.4273 15.56 15.87L15.56 15.9L15.55 15.92L15.55 15.95L15.55 15.97L15.54 16L15.53 16.02L15.53 16.05L15.52 16.07L15.51 16.1L15.49 16.12L15.48 16.14L15.47 16.16L15.45 16.19L15.44 16.21L15.42 16.22L15.4 16.24L15.38 16.26L15.36 16.28L15.34 16.29L15.32 16.31L15.3 16.32L15.28 16.34L15.25 16.35L15.23 16.36L15.21 16.37L15.18 16.38L15.16 16.38L15.13 16.39L15.11 16.39L15.08 16.4L15.06 16.4L15.03 16.4Z" fill="#FFFFFF" ></path></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="17" height="17.9998779296875" viewBox="0 0 17 17.9998779296875" fill="none"><path d="M4.76541 11.3167C4.44845 11.3167 4.19031 11.0729 4.19031 10.7736C4.19031 10.4739 4.44847 10.2296 4.76541 10.2296L11.8048 10.2296C12.1222 10.2296 12.3804 10.4739 12.3804 10.7736C12.3804 11.0729 12.1222 11.3167 11.8048 11.3167L4.76541 11.3167ZM4.6797 14.2541C4.36225 14.2541 4.10409 14.0103 4.10409 13.7106C4.10409 13.4113 4.36223 13.167 4.6797 13.167L11.7186 13.167C12.036 13.167 12.2942 13.4113 12.2942 13.7106C12.2942 14.0103 12.036 14.2541 11.7186 14.2541L4.6797 14.2541ZM1.55436 17.9999C0.56037 17.9999 0 17.4073 0 16.5137L0 1.9853C0 1.12685 0.464781 0.382572 1.5926 0.382572L11.5026 0.382572C11.7451 0.382572 11.9547 0.504928 12.0634 0.709841C12.1717 0.915007 12.1502 1.14701 12.0042 1.33016C11.8866 1.47867 11.699 1.56747 11.5026 1.56747L3.23704 1.56747C2.8706 1.56747 2.5796 1.56747 2.34253 1.56747L1.87079 1.56747C1.72238 1.56747 1.60334 1.56747 1.49752 1.56747L1.25404 1.56677L1.25404 16.8149L15.661 16.8149L15.6606 16.5855C15.6591 16.2427 15.6596 15.9873 15.6601 15.664L15.6601 15.6501C15.6601 15.454 15.6606 15.2301 15.6606 14.9428L15.6606 6.31558C15.6606 6.1308 15.7536 5.9541 15.9094 5.84284C16.0221 5.76327 16.1514 5.72161 16.2842 5.72161C16.5874 5.72161 16.9151 5.94851 16.9151 6.31537L16.9151 16.5859C16.9151 17.0323 16.8123 17.3737 16.6099 17.5998C16.3733 17.8648 15.9721 17.9999 15.4176 17.9999L1.55436 17.9999ZM14.261 0.889305L14.408 0.718613C14.53 0.576386 14.6966 0.381851 14.7989 0.275702C14.9728 0.0955167 15.2119 0 15.4901 0C15.6645 0 15.8139 0.0367844 15.9089 0.067793C16.2254 0.170457 16.6432 0.515576 16.8411 0.837034C17.0547 1.18468 17.0528 1.54202 16.8362 1.81772C16.6609 2.04252 16.5223 2.2095 16.4703 2.27058L16.3375 2.42855L14.261 0.889305ZM10.3391 8.26603C10.2225 8.26603 10.128 8.23158 10.0575 8.16355C9.96832 8.0773 9.92863 7.94685 9.93302 7.75348C9.94086 7.42343 10.129 6.38449 10.2005 6.1643C10.2544 5.99869 10.32 5.84905 10.465 5.65824C10.6742 5.38391 13.2685 2.13755 13.7863 1.48948L13.9186 1.32438L15.9922 2.86268L15.8663 3.02158C15.1334 3.94347 12.7336 6.96387 12.5984 7.12715C12.4793 7.27104 12.3196 7.4128 12.1717 7.50624C11.8626 7.70215 10.8706 8.1573 10.5439 8.23779C10.467 8.25678 10.3999 8.26603 10.3391 8.26603Z" fill="#FFFFFF" ></path></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="12" height="12" viewBox="0 0 12 12" fill="none"><path d="M6 12C2.68889 12 0 9.31111 0 6C0 2.68889 2.68889 0 6 0C9.31111 0 12 2.68889 12 6C12 9.31111 9.31111 12 6 12ZM6 0.888889C3.17778 0.888889 0.888889 3.17778 0.888889 6C0.888889 8.82222 3.17778 11.1111 6 11.1111C8.82222 11.1111 11.1111 8.82222 11.1111 6C11.1111 3.17778 8.82222 0.888889 6 0.888889Z" fill="#999999" ></path><path d="M8.22226 6.53333L6.44449 6.53333L6.44449 5.64444L8.22226 5.64444C8.46671 5.64444 8.66671 5.44444 8.66671 5.19999C8.66671 4.95555 8.46671 4.75555 8.22226 4.75555L6.97782 4.75555L8.20004 3.53333C8.37782 3.35555 8.37782 3.08888 8.20004 2.9111C8.02226 2.73333 7.7556 2.73333 7.57782 2.9111L6.00004 4.48888L4.42226 2.9111C4.24449 2.73333 3.97782 2.73333 3.80004 2.9111C3.62226 3.08888 3.62226 3.35555 3.80004 3.53333L5.02226 4.75555L3.77782 4.75555C3.53337 4.75555 3.33337 4.95555 3.33337 5.19999C3.33337 5.44444 3.53337 5.64444 3.77782 5.64444L5.5556 5.64444L5.5556 6.53333L3.77782 6.53333C3.53337 6.53333 3.33337 6.73333 3.33337 6.97777C3.33337 7.22222 3.53337 7.42222 3.77782 7.42222L5.5556 7.42222L5.5556 9.19999C5.5556 9.44444 5.7556 9.64444 6.00004 9.64444C6.24449 9.64444 6.44449 9.44444 6.44449 9.19999L6.44449 7.42222L8.22226 7.42222C8.46671 7.42222 8.66671 7.22222 8.66671 6.97777C8.66671 6.73333 8.46671 6.53333 8.22226 6.53333Z" fill="#999999" ></path></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="12" height="12" viewBox="0 0 12 12" fill="none"><path d="M7.88571 6.3C8.82857 5.7 9.42857 4.62857 9.42857 3.42857C9.42857 1.54286 7.88571 0 6 0C4.11429 0 2.57143 1.54286 2.57143 3.42857C2.57143 4.62857 3.17143 5.7 4.11429 6.3C1.71429 7.07143 0 9.34286 0 12L0.857143 12C0.857143 9.17143 3.17143 6.85714 6 6.85714C8.82857 6.85714 11.1429 9.17143 11.1429 12L12 12C12 9.34286 10.2857 7.07143 7.88571 6.3ZM6 6C4.58571 6 3.42857 4.84286 3.42857 3.42857C3.42857 2.01429 4.58571 0.857143 6 0.857143C7.41429 0.857143 8.57143 2.01429 8.57143 3.42857C8.57143 4.84286 7.41429 6 6 6Z" fill="#999999" ></path></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="12" height="12" viewBox="0 0 12 12" fill="none"><path d="M6 11.0769C8.80384 11.0769 11.0769 8.80384 11.0769 6C11.0769 3.19615 8.80384 0.923077 6 0.923077C3.19615 0.923077 0.923076 3.19615 0.923076 6C0.923076 8.80384 3.19615 11.0769 6 11.0769ZM6 12C2.68615 12 0 9.31384 0 6C0 2.68615 2.68615 0 6 0C9.31384 0 12 2.68615 12 6C12 9.31384 9.31384 12 6 12Z" fill="#999999" ></path><path d="M6.00071 6.46146L8.76994 6.46146C8.7775 6.46146 8.78505 6.46165 8.79259 6.46203C8.80013 6.46239 8.80768 6.46295 8.81519 6.46369C8.8227 6.46442 8.83019 6.46534 8.83766 6.46645C8.84513 6.46756 8.85257 6.46886 8.85999 6.47033C8.86739 6.47181 8.87476 6.47346 8.88208 6.4753C8.88941 6.47713 8.89669 6.47915 8.90392 6.48134C8.91115 6.48353 8.91831 6.4859 8.92543 6.48845C8.93254 6.49099 8.93959 6.4937 8.94657 6.4966C8.95355 6.49948 8.96046 6.50254 8.96728 6.50577C8.9741 6.509 8.98085 6.51241 8.98752 6.51597C8.99417 6.51953 9.00074 6.52325 9.00722 6.52713C9.01369 6.53101 9.02008 6.53505 9.02636 6.53925C9.03263 6.54344 9.03881 6.54779 9.04488 6.55229C9.05095 6.55679 9.05691 6.56143 9.06275 6.56623C9.06859 6.57102 9.0743 6.57595 9.0799 6.58103C9.08549 6.58609 9.09096 6.5913 9.0963 6.59665C9.10165 6.60199 9.10685 6.60745 9.11192 6.61305C9.11699 6.61865 9.12193 6.62436 9.12671 6.6302C9.13152 6.63604 9.13616 6.642 9.14066 6.64807C9.14516 6.65413 9.1495 6.6603 9.1537 6.66659C9.1579 6.67286 9.16193 6.67925 9.16582 6.68573C9.16969 6.6922 9.17342 6.69877 9.17698 6.70543C9.18054 6.71209 9.18394 6.71884 9.18718 6.72567C9.19039 6.73249 9.19345 6.7394 9.19635 6.74638C9.19925 6.75336 9.20196 6.7604 9.2045 6.76751C9.20705 6.77462 9.20942 6.7818 9.21161 6.78903C9.2138 6.79625 9.21582 6.80354 9.21765 6.81086C9.21948 6.81819 9.22114 6.82556 9.22261 6.83296C9.22408 6.84037 9.22538 6.84781 9.22649 6.85529C9.2276 6.86276 9.22853 6.87024 9.22926 6.87776C9.23 6.88527 9.23056 6.89282 9.23092 6.90036C9.2313 6.9079 9.23148 6.91544 9.23148 6.923C9.23148 6.93056 9.2313 6.9381 9.23092 6.94565C9.23056 6.95319 9.23 6.96073 9.22926 6.96825C9.22853 6.97576 9.2276 6.98325 9.22649 6.99072C9.22538 6.99819 9.22408 7.00563 9.22261 7.01305C9.22114 7.02044 9.21948 7.02781 9.21765 7.03514C9.21582 7.04247 9.2138 7.04975 9.21161 7.05698C9.20942 7.0642 9.20705 7.07137 9.2045 7.07848C9.20196 7.08559 9.19925 7.09265 9.19635 7.09963C9.19345 7.10661 9.19039 7.11352 9.18718 7.12034C9.18394 7.12716 9.18054 7.13391 9.17698 7.14057C9.17342 7.14722 9.16969 7.1538 9.16582 7.16028C9.16193 7.16675 9.1579 7.17314 9.1537 7.17942C9.1495 7.18569 9.14515 7.19186 9.14066 7.19794C9.13616 7.20401 9.13152 7.20996 9.12671 7.21581C9.12193 7.22165 9.11699 7.22736 9.11192 7.23295C9.10685 7.23855 9.10165 7.24402 9.0963 7.24935C9.09096 7.2547 9.08549 7.25991 9.0799 7.26497C9.0743 7.27005 9.06857 7.27498 9.06273 7.27977C9.05689 7.28457 9.05095 7.28922 9.04488 7.29372C9.03881 7.29822 9.03263 7.30256 9.02636 7.30676C9.02008 7.31095 9.01369 7.31499 9.00722 7.31887C9.00074 7.32275 8.99417 7.32647 8.98752 7.33004C8.98085 7.3336 8.9741 7.337 8.96728 7.34023C8.96044 7.34345 8.95354 7.34651 8.94657 7.34941C8.93959 7.3523 8.93254 7.35502 8.92543 7.35755C8.91831 7.36011 8.91115 7.36247 8.90392 7.36467C8.89669 7.36686 8.88941 7.36888 8.88208 7.37071C8.87476 7.37254 8.86739 7.3742 8.85999 7.37567C8.85257 7.37714 8.84513 7.37844 8.83766 7.37955C8.83019 7.38066 8.8227 7.38158 8.81519 7.38232C8.80768 7.38306 8.80013 7.38362 8.79259 7.38398C8.78505 7.38435 8.7775 7.38454 8.76994 7.38454L5.53918 7.38454C5.53162 7.38454 5.52407 7.38435 5.51653 7.38398C5.50898 7.38362 5.50145 7.38306 5.49393 7.38232C5.48642 7.38158 5.47893 7.38066 5.47146 7.37955C5.46399 7.37844 5.45655 7.37714 5.44913 7.37567C5.44173 7.3742 5.43436 7.37254 5.42704 7.37071C5.41971 7.36888 5.41243 7.36686 5.4052 7.36467C5.39797 7.36247 5.39079 7.36011 5.38368 7.35755C5.37657 7.35502 5.36953 7.3523 5.36255 7.34941C5.35557 7.34651 5.34867 7.34345 5.34184 7.34023C5.33501 7.337 5.32827 7.3336 5.3216 7.33004C5.31494 7.32647 5.30837 7.32275 5.3019 7.31887C5.29542 7.31499 5.28904 7.31095 5.28276 7.30676C5.27648 7.30256 5.27031 7.29822 5.26424 7.29372C5.25817 7.28922 5.25222 7.28457 5.24637 7.27977C5.24054 7.27498 5.23482 7.27005 5.22922 7.26497C5.22363 7.25991 5.21816 7.2547 5.21282 7.24935C5.20748 7.24402 5.20227 7.23855 5.1972 7.23295C5.19213 7.22736 5.18719 7.22165 5.18241 7.21581C5.17761 7.20996 5.17296 7.20401 5.16846 7.19794C5.16396 7.19186 5.15961 7.18569 5.15542 7.17942C5.15122 7.17314 5.14718 7.16675 5.14331 7.16028C5.13942 7.1538 5.1357 7.14722 5.13214 7.14057C5.12857 7.13391 5.12517 7.12716 5.12194 7.12034C5.11871 7.11352 5.11566 7.10661 5.11277 7.09963C5.10988 7.09265 5.10716 7.08559 5.10462 7.07848C5.10207 7.07137 5.0997 7.0642 5.09751 7.05698C5.09532 7.04975 5.09331 7.04247 5.09147 7.03514C5.08963 7.02781 5.08798 7.02044 5.08651 7.01305C5.08504 7.00563 5.08374 6.99819 5.08263 6.99072C5.08152 6.98325 5.0806 6.97576 5.07986 6.96825C5.07912 6.96073 5.07856 6.95319 5.0782 6.94565C5.07782 6.9381 5.07764 6.93056 5.07764 6.923L5.07764 2.76916C5.07764 2.7616 5.07782 2.75405 5.0782 2.74651C5.07856 2.73896 5.07912 2.73143 5.07986 2.72391C5.0806 2.7164 5.08152 2.70891 5.08263 2.70144C5.08374 2.69397 5.08504 2.68653 5.08651 2.67911C5.08798 2.67171 5.08963 2.66434 5.09147 2.65702C5.09331 2.64969 5.09532 2.64241 5.09751 2.63518C5.0997 2.62795 5.10207 2.62078 5.10462 2.61366C5.10716 2.60655 5.10988 2.59951 5.11277 2.59253C5.11566 2.58555 5.11871 2.57865 5.12194 2.57182C5.12517 2.56499 5.12857 2.55825 5.13213 2.55158C5.13569 2.54492 5.13942 2.53835 5.14331 2.53188C5.14718 2.5254 5.15122 2.51902 5.15542 2.51274C5.15961 2.50646 5.16396 2.50029 5.16846 2.49422C5.17296 2.48816 5.17761 2.4822 5.18241 2.47635C5.18719 2.47052 5.19213 2.4648 5.1972 2.4592C5.20227 2.45361 5.20748 2.44814 5.21282 2.4428C5.21816 2.43746 5.22363 2.43225 5.22922 2.42718C5.23482 2.42211 5.24054 2.41718 5.24637 2.41239C5.25222 2.40759 5.25817 2.40294 5.26424 2.39844C5.27031 2.39394 5.27648 2.38959 5.28276 2.3854C5.28904 2.38121 5.29542 2.37717 5.3019 2.37329C5.30837 2.3694 5.31494 2.36568 5.3216 2.36212C5.32827 2.35855 5.33501 2.35516 5.34184 2.35192C5.34867 2.34869 5.35557 2.34564 5.36255 2.34275C5.36953 2.33986 5.37657 2.33714 5.38368 2.3346C5.39079 2.33205 5.39797 2.32968 5.4052 2.32749C5.41243 2.3253 5.41971 2.32329 5.42704 2.32145C5.43436 2.31961 5.44173 2.31796 5.44913 2.31649C5.45655 2.31502 5.46399 2.31372 5.47146 2.31261C5.47893 2.3115 5.48642 2.31058 5.49393 2.30984C5.50145 2.3091 5.50898 2.30855 5.51653 2.30818C5.52407 2.3078 5.53162 2.30762 5.53918 2.30762C5.54673 2.30762 5.55428 2.3078 5.56182 2.30818C5.56937 2.30855 5.5769 2.3091 5.58442 2.30984C5.59193 2.31058 5.59942 2.3115 5.60689 2.31261C5.61436 2.31372 5.62181 2.31502 5.62922 2.31649C5.63662 2.31796 5.64399 2.31961 5.65131 2.32145C5.65864 2.32329 5.66592 2.3253 5.67315 2.32749C5.68038 2.32968 5.68755 2.33205 5.69466 2.3346C5.70177 2.33714 5.70882 2.33986 5.7158 2.34275C5.72278 2.34564 5.72969 2.34869 5.73651 2.35192C5.74334 2.35516 5.75008 2.35855 5.75675 2.36212C5.7634 2.36568 5.76997 2.3694 5.77645 2.37329C5.78293 2.37717 5.78931 2.38121 5.79559 2.3854C5.80187 2.38959 5.80804 2.39394 5.81411 2.39844C5.82018 2.40294 5.82613 2.40759 5.83198 2.41239C5.83782 2.41718 5.84353 2.42211 5.84913 2.42718C5.85472 2.43225 5.86019 2.43746 5.86553 2.4428C5.87087 2.44814 5.87608 2.45361 5.88115 2.4592C5.88622 2.4648 5.89116 2.47052 5.89594 2.47635C5.90074 2.4822 5.90539 2.48816 5.90989 2.49422C5.91439 2.50029 5.91874 2.50646 5.92293 2.51274C5.92712 2.51902 5.93116 2.5254 5.93505 2.53188C5.93893 2.53835 5.94265 2.54492 5.94621 2.55158C5.94978 2.55825 5.95318 2.56499 5.95641 2.57182C5.95963 2.57865 5.96268 2.58555 5.96558 2.59253C5.96847 2.59951 5.97119 2.60655 5.97373 2.61366C5.97628 2.62078 5.97865 2.62795 5.98084 2.63518C5.98303 2.64241 5.98505 2.64969 5.98688 2.65702C5.98872 2.66434 5.99037 2.67171 5.99184 2.67911C5.99331 2.68653 5.99461 2.69397 5.99572 2.70144C5.99683 2.70891 5.99775 2.7164 5.99849 2.72391C5.99923 2.73143 5.99979 2.73896 6.00015 2.74651C6.00053 2.75405 6.00071 2.7616 6.00071 2.76916L6.00071 6.46146Z" fill="#999999" ></path></svg>
\ No newline at end of file
import { defineStore } from 'pinia'
import { store } from '/@/store'
interface dictItem {
color: string
jsonObject?: string
label: string
text: string
title: string
value: string | number
}
// 定义字典列表的类型
export interface DictListVO {
[key: string]: dictItem[]
}
export const useDictStore = defineStore({
id: 'dict',
state: () => ({
dictList: {} as DictListVO,
}),
getters: {
getDictList(): DictListVO {
return this.dictList
},
},
actions: {
setDictList(dictList: DictListVO): void {
this.dictList = dictList
},
/**
* 清空字典数据
*/
clearDict(): void {
this.dictList = {}
},
},
})
// Need to be used outside the setup
export function useAppStoreWithOut() {
return useDictStore(store)
}
......@@ -4,6 +4,7 @@ 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
......@@ -78,6 +79,11 @@ export const useUserStore = defineStore({
} finally {
this.setToken(null)
this.setUserInfo(null)
// 清空字典数据
const dictStore = useDictStore(store)
dictStore.clearDict()
await Navigate.to('/pages/login/login')
this.loading = false
}
......
import { areaList } from '@vant/area-data'
// 定义树形结构的类型
interface AreaNode {
text: string
value: string
children?: AreaNode[]
}
/**
* 将areaList转换为树形结构(省市县三级联动)
* @returns 树形结构的地区数据
*/
export const convertToTree = (): AreaNode[] => {
const { province_list, city_list, county_list } = areaList
const tree: AreaNode[] = []
// 遍历所有省份
Object.entries(province_list).forEach(([provinceCode, provinceName]) => {
const provinceNode: AreaNode = {
text: provinceName,
value: provinceCode,
children: [],
}
// 查找该省份下的所有城市
Object.entries(city_list).forEach(([cityCode, cityName]) => {
// 城市代码的前两位与省份代码的前两位相同表示属于该省份
if (cityCode.substring(0, 2) === provinceCode.substring(0, 2)) {
const cityNode: AreaNode = {
text: cityName,
value: cityCode,
children: [],
}
// 查找该城市下的所有区县
Object.entries(county_list).forEach(([countyCode, countyName]) => {
// 区县代码的前四位与城市代码的前四位相同表示属于该城市
if (countyCode.substring(0, 4) === cityCode.substring(0, 4)) {
cityNode.children!.push({
text: countyName,
value: countyCode,
})
}
})
provinceNode.children!.push(cityNode)
}
})
tree.push(provinceNode)
})
return tree
}
// 导出树形结构数据
export const areaTree = convertToTree()
/**
* 根据地区代码获取完整的地区名称(如:广东省广州市天河区)
* @param code 地区代码
* @returns 完整的地区名称
*/
export const getFullAreaName = (code: string): string => {
const { province_list, city_list, county_list } = areaList
let name = ''
if (county_list[code]) {
// 如果是区县代码,获取完整的省市县名称
const cityCode = code.substring(0, 4) + '00'
const provinceCode = code.substring(0, 2) + '0000'
name = `${province_list[provinceCode]}${city_list[cityCode]}${county_list[code]}`
} else if (city_list[code]) {
// 如果是城市代码,获取完整的省市名称
const provinceCode = code.substring(0, 2) + '0000'
name = `${province_list[provinceCode]}${city_list[code]}`
} else if (province_list[code]) {
// 如果是省份代码,直接返回省份名称
name = province_list[code]
}
return name
}
// 根据编号获取文本
export function getTextByCode(code) {
// 遍历省份
for (const provinceCode in areaList.province_list) {
if (provinceCode === code) {
return areaList.province_list[provinceCode]
}
// 遍历城市
for (const cityCode in areaList.city_list) {
if (cityCode === code) {
return areaList.city_list[cityCode]
}
// 遍历区县
for (const countyCode in areaList.county_list) {
if (countyCode === code) {
return areaList.county_list[countyCode]
}
}
}
}
return null
}
// 根据文本获取编号
export function getCodeByText(text) {
// 遍历省份
for (const provinceCode in areaList.province_list) {
if (areaList.province_list[provinceCode] === text) {
return provinceCode
}
}
// 遍历城市
for (const cityCode in areaList.city_list) {
if (areaList.city_list[cityCode] === text) {
return cityCode
}
}
// 遍历区县
for (const countyCode in areaList.county_list) {
if (areaList.county_list[countyCode] === text) {
return countyCode
}
}
return null
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论