提交 fc48313c 作者: 王定

feat: 完成可信农资申请入驻的添加,列表接口对接,详情页接口对接

上级 227bef02
# API 接口地址
VITE_GLOB_API_URL=http://111.22.182.169:49600
# VITE_GLOB_API_URL=http://36.133.16.81:42111
# VITE_GLOB_API_URL=http://111.22.182.169:49600
VITE_GLOB_API_URL=http://36.133.16.81:42111
# API 接口地址前缀
VITE_GLOB_API_URL_PREFIX=/jeecgboot
# VITE_GLOB_API_URL_PREFIX=/jeecg-boot
# VITE_GLOB_API_URL_PREFIX=/jeecgboot
VITE_GLOB_API_URL_PREFIX=/jeecg-boot
......@@ -3,6 +3,45 @@ import { otherHttp } from '/@/utils/http/axios'
enum Api {
goodsList = '/trade/goods/list', // 农资列表
getEnterpriseList = '/server/enterprise/list', // 可信农资列表
postEnterpriseAdd = '/server/enterprise/add', // 入驻申请
getEnterpriseDetail= '/server/enterprise/detail', // 企业详情
postGoodsAdd = '/trade/goods/add', // 农资商品管理-添加
}
/**
* @param params 请求参数
* @description: 农资商品管理-添加
*/
export function postGoodsAdd(params = {}) {
return otherHttp.post({
url: Api.postGoodsAdd,
params,
})
}
/**
* @param params 请求参数
* @description: APP可信农资列表
*/
export function getEnterpriseDetail(params = {}) {
return otherHttp.get({
url: Api.getEnterpriseDetail,
params,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
})
}
/**
* @param params 请求参数
* @description: 农贸入驻 新增
*/
export function postEnterpriseAdd(params = {}) {
return otherHttp.post({
url: Api.postEnterpriseAdd,
params,
})
}
/**
......
......@@ -690,7 +690,21 @@
"path" : "pages/kexinnongzi/kexinnongzi",
"style" :
{
"navigationBarTitleText" : "可信农资"
"navigationBarTitleText" : "可信农资",
"app-plus": {
"titleNView": {
"buttons": [
{
"text": "\uE674 申请入驻",
"fontSrc": "/static/fonts/tihuan.ttf",
"color": "#fff",
"fontSize": "26rpx",
"width": "auto",
"icon": "map"
}
]
}
}
}
},
{
......@@ -699,6 +713,13 @@
{
"navigationBarTitleText" : "详情"
}
},
{
"path" : "pages/kexinnongzi/shenqingruzhu",
"style" :
{
"navigationBarTitleText" : "农贸入驻申请"
}
}
],
"easycom": {
......
......@@ -2,12 +2,141 @@
import { onLoad } from '@dcloudio/uni-app'
import Navigate from '@/utils/page/navigate'
import { reactive, ref } from 'vue'
import { useUserStore } from '@/store/modules/user'
import { useGlobSetting } from '/@/hooks/setting'
import * as NongzhiAPI from '@/api/model/nongzhi'
import * as LinghuoyonggongAPI from '@/api/model/linghuoyonggong'
const userStore = useUserStore()
const globSetting = useGlobSetting()
onLoad((options) => {
let param = JSON.parse(decodeURIComponent(options.param));
uni.setNavigationBarTitle({
title: param.name
});
getDetailData(param.id);
queryByCategoryAndCode(0,null)
})
const toastRef = ref()
const unitPopupRef = ref(null);
const uploadRef = ref()
const bgColorData = ["#EEFAEB","#EFF1FF","#FFF3F1","#E8F7F7","#FFF3E7","#FAF8EA"];
let testDataList = ['营业执照','食品经营许可证','有机产品认证书','无公害农产品证书','有机产品认证书','营业执照','营业执照2','营业执照3']
const pageData = reactive({
data:null,
enterpriseCers:[],
isPopupShow:false,
unitPopup:false,
unitOptions:[],
unitVal:[],
unitText:"",
productImageArr:[],
})
let productInfo = reactive({
id:"",
name:"",// 商品名称
category:"", // 分类
minSellPrice:"", // 最小销售价
maxSellPrice: "", // 最大销售价
unit: "", // 单位
unitCode:"", // 单位编码
enterpriseId:"", // 企业ID
})
// 文件上传
function handleUpload(file) {
const tempFilePaths = file.tempFilePaths;
// 处理每张选中的图片
for(let i = 0; i < tempFilePaths.length; i++){
uni.uploadFile({
url: `${globSetting.apiUrl + globSetting.urlPrefix}/sys/common/upload`, // 直接使用上传接口URL
filePath: tempFilePaths[i],
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.productImageArr[0] = data.message // 保存返回的图片信息
}
}
},
fail: (err) => {
toastRef.value.show({
type: 'error',
text: '上传失败',
})
uploadRef.value.clearFiles()
pageData.productImageArr[0] = null
},
})
}
}
// 文件删除
function handleDelete(file,type) {
uploadRef.value.clearFiles()
pageData.productImageArr[0] = null
}
function selectCompleteUnit(e){
productInfo.unit = e.text[e.text.length-1];
pageData.unitPopup = false;
}
function handleSelectUnit(){
pageData.unitPopup = true;
}
function changeUnit(e){
let val = e.value;
queryByCategoryAndCode(val,e);
}
function queryByCategoryAndCode(code,e){
LinghuoyonggongAPI.queryByCategoryAndCode({ category : 2,code : code}).then(res=>{
if(res.length){
let dataArr = [];
for(let i = 0; i < res.length; i++){
let obj = {text:"",value:""};
obj.text = res[i].name;
obj.value = res[i].code;
dataArr.push(obj);
}
if(!pageData.unitOptions.length){
pageData.unitOptions = dataArr;
}else{
unitPopupRef.value.setRequestData(dataArr, e.layer);
}
}else{
unitPopupRef.value.end();
}
})
}
// 发布
function addData(){
NongzhiAPI.postGoodsAdd(productInfo).then((res) => {
console.log("发布成功了");
console.log(res);
/* pageData.enterpriseCers = res.enterpriseCers.split(",");
pageData.data = res; */
})
}
function getDetailData(id){
NongzhiAPI.getEnterpriseDetail({ id }).then((res) => {
pageData.enterpriseCers = res.enterpriseCers.split(",");
pageData.data = res;
productInfo.unitCode = res.enterpriseCode;
productInfo.enterpriseId = res.id;
})
}
function getBgColor(index:any){
if(index < 6){
return bgColorData[index];
......@@ -16,23 +145,23 @@
}
}
function handlePublish() {
Navigate.to('/pages/linghuoyonggong/publishEmployment')
pageData.isPopupShow = true;
}
</script>
<template>
<view class="w-full h-95vh bg-#E6F5E8 detail_page">
<view class="module_width top_content">
<view class="enterprise_logo_view"><image class="enterprise_logo" mode="heightFix" src="/static/images/test/test_logo.png" /></view>
<view class="enterprise_business">主营:粮、油、糖、棉、肉、乳等品类的全球一体化运营</view>
<view class="enterprise_description">中粮集团下设中粮粮油、中国粮油、中国食品、地产酒店、中国土畜、中粮屯河、中粮包装、中粮发展、金融等9大业务板块,拥有中国食品、中粮控股两家香港上市公司,中粮屯河、中粮地产和丰原生化3家内地上市公司。福临门食用油、长城葡萄酒、金帝巧克力、屯河番茄制品、家佳康肉制品以及大悦城Shopping Mall、亚龙湾度假区、凯莱酒店、雪莲羊绒、中茶茶叶、中英人寿保险农村金融服务等等。 </view>
<view class="enterprise_logo_view"><image class="enterprise_logo" mode="heightFix" :src="pageData.data.enterpriseLogoUrl" /></view>
<view class="enterprise_business">主营:{{pageData.data.businessScope}}</view>
<view class="enterprise_description">{{pageData.data.profile}}</view>
</view>
<view class="module_width middle_content">
<view class="module_title">资质证书</view>
<view class="module_separate"></view>
<view class="module_qualification">
<view class="qualification_item" :style="`background:${getBgColor(index)}`" v-for="(item,index) in testDataList" :key="index">
<image class="enterprise_logo" mode="heightFix" src="/static/images/test/test_business.png" />
<view class="qualification_name ellipsis">{{item}}</view>
<view class="qualification_item" :style="`background:${getBgColor(index)}`" v-for="(item,index) in pageData.enterpriseCers" :key="index">
<image class="enterprise_logo" mode="heightFix" :src="item" />
<!-- <view class="qualification_name ellipsis">{{item}}</view> -->
</view>
</view>
</view>
......@@ -54,6 +183,53 @@
<view style="font-size: 24rpx">发布产品</view>
</view>
</fui-fab>
<fui-bottom-popup :show="pageData.isPopupShow" @close="pageData.isPopupShow = false">
<view class="fui-custom__wrap yr_person_popup">
<view class="popup_top">
<uni-icons type="left" size="24" color="#333333" @click="pageData.isPopupShow = false"></uni-icons>
<view class="add_person_text">产品信息</view>
<view class="del_person_btn"></view>
</view>
<view class="popup_content">
<fui-form error-position="1" ref="form" top="0" :show="false">
<fui-form-item asterisk label="商品名称" labelSize="28" label-width="180" size="28">
<fui-input :borderBottom="false" v-model="productInfo.name" :padding="[0]" placeholder="请输入商品名称"></fui-input>
</fui-form-item>
<fui-form-item asterisk label="联系方式" labelSize="28" label-width="180" size="28">
<fui-input :borderBottom="false" :padding="[0]" placeholder="请输入联系方式"></fui-input>
</fui-form-item>
<fui-form-item asterisk label="价格(元)" labelSize="28" label-width="180" size="28">
<fui-input v-model="productInfo.minSellPrice" style="width: 120rpx !important" :borderBottom="false" :padding="[0]" placeholder="最低价"></fui-input>
<template v-slot:right>
<view style="color: #CCCCCC;margin-right: 40rpx;"></view>
<fui-input v-model="productInfo.maxSellPrice" style="width: 120rpx !important;" :borderBottom="false" :padding="[0]" placeholder="最高价"></fui-input>
<fui-text v-if="productInfo.unit==''" text="单位" color="#cccccc" @click="handleSelectUnit()"></fui-text>
<fui-text v-else :text="productInfo.unit" @click="handleSelectUnit()"></fui-text>
</template>
</fui-form-item>
<fui-form-item asterisk label="产品图片" :bottomBorder="false" prop="descr" error-align="left">
<template v-slot:vertical>
<uni-file-picker :value="pageData.productImageArr" ref="uploadRef" limit="1" :auto-upload="false" @select="handleUpload" @delete="handleDelete"/>
</template>
</fui-form-item>
</fui-form>
</view>
<fui-button text="保存" bold radius="96rpx" @click="addData" height="80rpx"/>
</view>
</fui-bottom-popup>
<fui-bottom-popup :show="pageData.unitPopup">
<view class="fui-scroll__wrap">
<view class="fui-title">请选择</view>
<fui-cascader ref="unitPopupRef" :value="pageData.unitVal" stepLoading @change="changeUnit" @complete="selectCompleteUnit" :options="pageData.unitOptions"></fui-cascader>
<view class="fui-icon__close" @tap.stop="pageData.unitPopup=false">
<fui-icon name="close" :size="48"></fui-icon>
</view>
</view>
</fui-bottom-popup>
<fui-toast ref="toastRef" />
</template>
<style lang="less" scoped>
......@@ -216,4 +392,22 @@
background: linear-gradient(124.25deg, #a5d63f 0%, #5db66f 100%) !important;
box-shadow: 0px 1px 8px #5db66f;
}
.fui-scroll__wrap {
padding-top: 30rpx;
position: relative;
}
.fui-title {
font-size: 30rpx;
font-weight: bold;
text-align: center;
padding-bottom: 24rpx;
}
.fui-icon__close {
position: absolute;
top: 24rpx;
right: 24rpx;
}
</style>
......@@ -3,7 +3,19 @@
import Navigate from '@/utils/page/navigate'
import { reactive, ref } from 'vue'
import * as NongzhiAPI from '@/api/model/nongzhi'
onPullDownRefresh(() => {
resetData()
getList(pageData.params)
})
onShow(() => {
resetData()
getList(pageData.params)
})
onNavigationBarButtonTap(() => {
Navigate.to('/pages/kexinnongzi/shenqingruzhu')
})
const pageData = reactive({
params: {
pageNo: 1,
......@@ -41,7 +53,8 @@
function toDetail(item) {
let param = encodeURIComponent(JSON.stringify({id:1,name:"中粮集团"}));
console.log(item);
let param = encodeURIComponent(JSON.stringify({id:item.id,name:item.enterpriseName}));
Navigate.to(`/pages/kexinnongzi/detail?param=${param}`)
}
......@@ -50,16 +63,6 @@
pageData.hasMore = true
pageData.loading = false
}
onPullDownRefresh(() => {
resetData()
getList(pageData.params)
})
onShow(() => {
resetData()
getList(pageData.params)
})
</script>
<template>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论