Merge branch 'main' of https://gitea.lihaink.cn/sjeam/digital_village_uni
This commit is contained in:
commit
8db7579875
2
env/.env
vendored
2
env/.env
vendored
@ -12,7 +12,7 @@ VITE_LOGIN_URL = '/pages/login/index'
|
|||||||
|
|
||||||
# 数字乡村
|
# 数字乡村
|
||||||
VITE_SERVER_BASEURL = 'http://test.data-middle.lihaink.cn'
|
VITE_SERVER_BASEURL = 'http://test.data-middle.lihaink.cn'
|
||||||
VITE_UPLOAD_BASEURL = 'http://test.data-middle.lihaink.cn/upload'
|
VITE_UPLOAD_BASEURL = 'http://test.data-middle.lihaink.cn/api/upload/image'
|
||||||
# 商城
|
# 商城
|
||||||
VITE_SHOP_SERVER_BASEURL = 'https://shop.lihaink.cn'
|
VITE_SHOP_SERVER_BASEURL = 'https://shop.lihaink.cn'
|
||||||
|
|
||||||
|
12
src/api/user.ts
Normal file
12
src/api/user.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { http } from '@/utils/http'
|
||||||
|
|
||||||
|
export function userListApi(data: { code: any }) {
|
||||||
|
return http.get('/api/user/list', data)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function userInfoApi() {
|
||||||
|
return http.get('/api/user/info')
|
||||||
|
}
|
||||||
|
export function commitProduct(data) {
|
||||||
|
return http.post('/api/user/commitProduct', data)
|
||||||
|
}
|
@ -117,6 +117,13 @@
|
|||||||
"navigationBarTitleText": "设置"
|
"navigationBarTitleText": "设置"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/my/uploadProduct",
|
||||||
|
"type": "page",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "上传商品"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/service/find",
|
"path": "pages/service/find",
|
||||||
"type": "page"
|
"type": "page"
|
||||||
|
@ -92,6 +92,13 @@
|
|||||||
icon: '/static/icons/my7.png',
|
icon: '/static/icons/my7.png',
|
||||||
color: 'red',
|
color: 'red',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: '上传商品',
|
||||||
|
url: '/pages/my/uploadProduct',
|
||||||
|
type: 1,
|
||||||
|
icon: '/static/icons/rural_ecommerce.png',
|
||||||
|
color: 'red',
|
||||||
|
},
|
||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
<wd-grid-item use-slot>
|
<wd-grid-item use-slot>
|
||||||
|
123
src/pages/my/uploadProduct.vue
Normal file
123
src/pages/my/uploadProduct.vue
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
<route lang="json5">
|
||||||
|
{
|
||||||
|
style: { navigationBarTitleText: '上传商品' },
|
||||||
|
}
|
||||||
|
</route>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { commitProduct, userInfoApi, userListApi } from '@/api/user'
|
||||||
|
import { useUserStore } from '@/store'
|
||||||
|
import { getEnvBaseUploadUrl } from '@/utils'
|
||||||
|
|
||||||
|
const action: string = `${getEnvBaseUploadUrl()}`
|
||||||
|
const userInfo = useUserStore().userInfo
|
||||||
|
const isManager = ref(false)
|
||||||
|
const userList = ref([])
|
||||||
|
|
||||||
|
const formData = reactive({
|
||||||
|
store_name: '',
|
||||||
|
number: '',
|
||||||
|
price: '',
|
||||||
|
image: [],
|
||||||
|
user_id: '',
|
||||||
|
})
|
||||||
|
|
||||||
|
function getUserInfo() {
|
||||||
|
userInfoApi().then((res) => {
|
||||||
|
if (res.data.group_id == 2) {
|
||||||
|
isManager.value = true
|
||||||
|
userListApi({ code: res.data.village }).then((res) => {
|
||||||
|
res.data.forEach((item) => {
|
||||||
|
userList.value.push({
|
||||||
|
label: item.nickname,
|
||||||
|
value: item.id,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
formData.user_id = res.data.id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSubmit() {
|
||||||
|
commitProduct(formData).then((res) => {
|
||||||
|
if (res.code == 1) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '上传成功',
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: res.data.msg,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
function goBack() {
|
||||||
|
uni.navigateBack({
|
||||||
|
delta: 1,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
function uploadSuccess(res) {
|
||||||
|
const response = JSON.parse(res.file.response)
|
||||||
|
if (response.code === 1) {
|
||||||
|
formData.image.push(response.data.uri)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getUserInfo()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="p-2">
|
||||||
|
<view class="detail-box bg-white p-2">
|
||||||
|
<wd-form ref="form" :model="formData">
|
||||||
|
<wd-cell-group border>
|
||||||
|
<wd-select-picker
|
||||||
|
v-if="isManager"
|
||||||
|
v-model="formData.user_id"
|
||||||
|
label="村民"
|
||||||
|
type="radio"
|
||||||
|
:columns="userList"
|
||||||
|
filterable
|
||||||
|
:rules="[{ required: true, message: '请选择村民' }]"
|
||||||
|
/>
|
||||||
|
<wd-input
|
||||||
|
v-model="formData.store_name"
|
||||||
|
label="商品名称"
|
||||||
|
prop="store_name"
|
||||||
|
placeholder="请输入商品名称"
|
||||||
|
:rules="[{ required: true, message: '请填写商品名称' }]"
|
||||||
|
/>
|
||||||
|
<wd-input
|
||||||
|
v-model="formData.number"
|
||||||
|
label="数量"
|
||||||
|
prop="number"
|
||||||
|
placeholder="请输入数量"
|
||||||
|
:rules="[{ required: true, message: '请填写数量' }]"
|
||||||
|
/>
|
||||||
|
<wd-input
|
||||||
|
v-model="formData.price"
|
||||||
|
label="单价"
|
||||||
|
prop="price"
|
||||||
|
placeholder="请输入单价"
|
||||||
|
:rules="[{ required: true, message: '请填写单价' }]"
|
||||||
|
/>
|
||||||
|
<view class="flex items-center">
|
||||||
|
<view class="w-[33%] text-[14px]">图片</view>
|
||||||
|
<wd-upload
|
||||||
|
v-model="formData.image"
|
||||||
|
image-mode="aspectFill"
|
||||||
|
:action="action"
|
||||||
|
:limit="9"
|
||||||
|
@success="uploadSuccess"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
</wd-cell-group>
|
||||||
|
</wd-form>
|
||||||
|
</view>
|
||||||
|
<view class="mt-6">
|
||||||
|
<button type="primary" size="large" block @click="handleSubmit">提交</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
Loading…
x
Reference in New Issue
Block a user