Commit 81e5433b authored by zhangzedan's avatar zhangzedan

model1&report model

parent 3839be55
...@@ -43,7 +43,6 @@ App({ ...@@ -43,7 +43,6 @@ App({
// 登录 // 登录
wx.login({ wx.login({
success: res => { success: res => {
console.log(res)
var _this = this; var _this = this;
// // 发送 res.code 到后台换取 openId, sessionKey, unionId // // 发送 res.code 到后台换取 openId, sessionKey, unionId
let code = res.code let code = res.code
...@@ -60,7 +59,7 @@ App({ ...@@ -60,7 +59,7 @@ App({
this.globalData.userInfo = getUserInfo() this.globalData.userInfo = getUserInfo()
setTimeout(function(){ setTimeout(function(){
wx.navigateTo({ wx.navigateTo({
url: "../../pages/report/user/user_write" url: "../../pages/report/baseinfo"
}) })
}, 1000) }, 1000)
} }
......
{ {
"pages":[ "pages": [
"pages/index/index", "pages/index/index",
"pages/logs/logs", "pages/logs/logs",
"pages/user/user", "pages/user/user",
"pages/report/user/user_write" "pages/report/baseinfo"
], ],
"window":{ "window": {
"backgroundTextStyle":"light", "backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#1cd8d7", "navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "智慧农场", "navigationBarTitleText": "智慧农场",
"navigationBarTextStyle":"black" "navigationBarTextStyle": "black"
},
"permission": {
"scope.userLocation": {
"desc": "您的位置信息将用于农场位置定位"
}
} }
} }
\ No newline at end of file
/**app.wxss**/ @import "weui.wxss"
@import 'weui.wxss'; \ No newline at end of file
input{
display: inline-block;
}
.container {
height: 100%;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
}
.top{
width: 100%;
height: 70rpx;
display: flex;
flex-direction: row;
align-items: center;
background-color: #1cd8d7;
border-bottom-left-radius: 20rpx;
border-bottom-right-radius: 20rpx;
}
.top image{
width: 45rpx;
height: 45rpx;
margin-right: 10rpx;
vertical-align: text-bottom;
}
.top a{
display: inline-block;
width: 50%;
padding: 30rpx;
padding-top: 0;
padding-bottom: 0;
margin-top: 5rpx;
margin-bottom: 5rpx;
}
.top .left{
text-align: left;
margin-left: 10rpx;
}
.top .right{
text-align: right;
margin-right: 10rpx;
}
/* .top .left{
} */
\ No newline at end of file
// pages/component/datashow/datashow.js
// 数据判断并存储
function checkValue(field, value, fieldData) {
if (field == "age") {
if (Number(value) > 0 && parseInt(value) < 100) {
fieldData[field] = parseInt(value)
return fieldData
}
return false
} else {
if (field.indexOf("area") >= 0 || field.indexOf("worker") >= 0 || field.indexOf("asset") >= 0) {
if (Number(value)) {
fieldData[field] = parseFloat(value)
return fieldData
}
return false
} else {
fieldData[field] = value
return fieldData
}
}
}
Component({
/**
* 组件的属性列表
*/
properties: {
items: Array
},
/**
* 组件的初始数据
*/
data: {
location: "",
fieldData: {},
error: "",
checkmul:{}
},
/**
* 组件的方法列表
*/
methods: {
// 选择地理位置
getLoc: function(e) {
wx.chooseLocation({
success(res) {
let field = e.target.dataset.field
let value = e.detail.value
let fieldData = checkValue(field, value, this.data.fieldData)
this.setData({
fieldData: fieldData
})
}
})
},
// 输入框的输入绑定事件
inputChange: function(e) {
let field = e.target.dataset.field
let value = e.detail.value
let res = checkValue(field, value, this.data.fieldData)
if (!res) {
this.setData({
error: field
})
} else {
this.setData({
error: ""
})
this.setData({
fieldData: res
})
}
},
// 单选事件
radioChange: function(e) {
let field = e.target.dataset.field
let value = e.detail.value
let res = this.data.fieldData
// 获取其他请注明的值
let otherValue = e.target.dataset.value
if(value==-1){
value=otherValue||""
}
res[field] = value
this.setData({
fieldData: res
})
},
// 多选事件
checkboxChange: function(e) {
let field = e.target.dataset.field
let value = e.detail.value
let res = this.data.fieldData
// 获取其他请注明的值
let otherValue = e.target.dataset.value
value = value.map(item=>{
if(item==-1){
return otherValue||""
}else{
return item
}
})
// 获取多选框的值
res[field] = value
this.setData({
fieldData: res
})
},
// 多选框的其他请注明
checkOther: function(e) {
let field = e.target.dataset.field
let value = e.detail.value
let checkmul = this.data.checkmul
checkmul[field]=value
this.setData({
checkmul:checkmul
})
},
// 单选的其他请注明
radioOther: function(e) {
let field = e.target.dataset.field
let value = e.detail.value
let checkmul = this.data.checkmul
checkmul[field]=value
this.setData({
checkmul:checkmul
})
}
}
})
\ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<!--pages/component/datashow/datashow.wxml-->
<view wx:for-items="{{items}}" wx:for-item="item" wx:key="{{idx}}" class="page-section">
<view class="{{'title_'+item.level}}">{{item.title}}</view>
<view wx:for="{{item.info}}" wx:key="{{idx}}" class="page-section">
<view class="weui-cells__title">{{item.label}}</view>
<!-- 输入框样式 -->
<view class="weui-cells weui-cells_after-title" wx:if="{{item.show==='input'}}">
<view class="weui-cell weui-cell_input">
<input class="weui-input {{error===item.field?'error':''}}" data-field="{{item.field}}" bindinput="inputChange" />
<!-- 简单判断数据格式 -->
<text style="color:red;font-size:20rpx" wx:if="{{error===item.field}}">请输入正确的格式</text>
</view>
</view>
<view class="page__bd">
<view class="section section_gap">
<!-- 单选样式 -->
<radio-group class="radio-group" wx:if="{{item.show==='radio'}}" bindchange="radioChange" data-field="{{item.field}}" data-value="{{checkmul[item.field]}}">
<radio class="radio" wx:for-items="{{item.selects}}" wx:for-item="select" wx:key="{{select.id}}" value="{{select.id}}">
<text wx:if="{{select.id>-1}}">{{select.value}}</text>
<!-- "其他请注明"的输入框 -->
<view class="weui-cells weui-cells_after-title" wx:if="{{select.id===-1}}">
<view class="weui-cell weui-cell_input">
<input class="weui-input" placeholder="{{select.value}}" bindinput="radioOther" data-field="{{item.field}}"/>
</view>
</view>
</radio>
</radio-group>
<!-- 多选样式 -->
<checkbox-group class="checkbox-group" wx:if="{{item.show==='checkbox'}}" bindchange="checkboxChange" data-field="{{item.field}}" data-value="{{checkmul[item.field]}}" >
<view wx:for-items="{{item.selects}}" wx:for-item="select" wx:key="{{select.id}}">
<label class="checkbox">
<checkbox value="{{select.id}}" />
<text wx:if="{{select.id>-1}}">{{select.value}}</text>
<!-- "其他请注明"的输入框 -->
<view class="weui-cells weui-cells_after-title weui-checkbox-input" wx:if="{{select.id===-1}}">
<view class="weui-cell weui-cell_input">
<input id="{{item.field}}" class="weui-input" placeholder="{{select.value}}" bindinput="checkOther" data-field="{{item.field}}"/>
</view>
</view>
</label>
</view>
</checkbox-group>
<!-- 定位地址 -->
<view wx:if="{{item.show==='location'}}" >
<button type="default" data-field="{{item.field}}" bindtap="getLoc">设置地理位置</button>
<text wx:if="{{fieldData.location}}">您的位置是 {{fieldData.location.address}}</text>
</view>
</view>
</view>
</view>
</view>
\ No newline at end of file
/* pages/component/datashow/datashow.wxss */
@import "../../public/public.wxss"
\ No newline at end of file
// 性别
const sex = [{ value: "男", id: 0 }, { value: "女", id: 1 }]
// 受教育程度
const education = [
{ value: "高中以下", id: 0 },
{ value: "高中", id: 1 },
{ value: "大专", id: 2 },
{ value: "本科", id: 3 },
{ value: "研究生", id: 4 },
{ value: "博士及以上", id: 5 },
]
// 租用方式
const renttype=[
{ value: "一次付清", id: 0 },
{ value: "半年一付", id: 1 },
{ value: "一年一付", id: 2 },
{ value: "免费租用", id: 3 },
{ value: "政府支持", id: 4 }
]
// 是否判断
const whether=[
{ value: "是", id: 0 },
{ value: "否", id: 1 }
]
// 污染检测项目
const polutionexamine=[
{ value: "重金属", id: 0 },
{ value: "农药残留", id: 1 },
{ value: "有机质", id: 2 }
]
// 组织模式
const organstruct=[
{ value: "公司/园区", id: 0 },
{ value: "家庭农场", id: 1 },
{ value: "合作社", id: 2 },
{ value: "公司+农户", id: 3 },
{ value: "其他请注明", id: -1 }
]
// 经营模式
const businessmodel=[
{ value: "农场-外部销售", id: 0 },
{ value: "农场-加工厂", id: 1 },
{ value: "农场-自销配送/实体店", id: 2 },
{ value: "农场-餐馆", id: 3 },
{ value: "农场-采摘/生态旅游", id: 4 },
{ value: "农场-教育基地", id: 5 },
{ value: "其他请注明", id: -1 }
]
// 农场投资来源
const investsource=[
{ value: "自有资金", id: 0 },
{ value: "银行贷款", id: 1 },
{ value: "风险投资", id: 2 },
{ value: "政府补贴", id: 3 },
{ value: "众筹", id: 4 },
{ value: "其他请注明", id: -1 }
]
// const
module.exports = {
sex: sex,
education: education,
renttype:renttype,
polutionexamine:polutionexamine,
organstruct:organstruct,
businessmodel:businessmodel,
whether:whether,
investsource:investsource
}
\ No newline at end of file
const datafileds=require("dataDicts.js")
const plantFarm={
"model1":{
"user":[{
level:0,
title:"负责人基本信息",
info: [
{
field:"name",
label: "姓名",
class: "",
show:"input"
},
{
field:"position",
label: "调查地点",
class: "",
show:"location"
},
{
field:"sex",
label: "性别",
class: "",
show:"radio",
selects: datafileds.sex
},
{
field:"age",
label: "年龄",
class: "",
show:"input"
},
{
field:"eduction",
label: "受教育程度",
class: "",
show:"radio",
selects: datafileds.education
},
{
field:"farmtime",
label: "从事农业时间",
class: "",
show:"input"
},
{
field:"lastjob",
label: "之前从事的行业",
class: "",
show:"input"
}
]
}],
"farmbase":[
{
level:0,
title:"农场基本信息"
},
{
level:1,
title:"农场概况",
info: [
{
field:"creatdate",
label: "成立时间",
class: "",
show:"input"
},
{
field:"totalarea",
label: "总面积",
class: "",
show:"input"
},
{
field:"croparea",
label: "种植作物面积",
class: "",
show:"input"
},
{
field:"naturearea",
label: "自然植被面积",
class: "",
show:"input"
},
{
field:"selfarea",
label: "自己的土地",
class: "",
show:"input"
},
{
field:"rentarea",
label: "租地(土地流转)面积",
class: "",
show:"input"
},
{
field:"rental",
label: "土地租金",
class: "",
show:"input"
},
{
field:"renttime",
label: "租用期限",
class: "",
show:"input"
},
{
field:"rentstartdate",
label: "租赁开始时间",
class: "",
show:"input"
},
{
field:"rentenddate",
label: "租赁截止时间",
class: "",
show:"input"
},
{
field:"renttype",
label: "租用方式",
class: "",
show:"radio",
selects: datafileds.renttype
},
{
field:"distance",
label: "与市场或加工厂的距离",
show:"input",
class: ""
}
]
},
{
level:1,
title:"农场环境",
info:[
{
field:"polutionsource",
label: "农场是否位于采矿区、化工厂或其它污染源附近",
class: "",
show:"radio",
selects: datafileds.whether
},
{
field:"polutionevent",
label: "当地近十年是否有过水、土壤、大气污染事件",
class: "",
show:"radio",
selects: datafileds.whether
},
{
field:"examine",
label: "种植地块是否经过检测",
class: "",
show:"radio",
selects: datafileds.whether
},
{
field:"examinepro",
label: "监测项目",
class: "",
show:"checkbox",
selects: datafileds.polutionexamine
}
]
},
{
level:1,
title:"农场员工人数",
info:[
{
field:"totalworker",
label:"总人数",
class:"",
show:"input"
},
{
field:"longworker",
label:"长期工",
class:"",
show:"input"
},
{
field:"shortworker",
label:"短期工",
class:"",
show:"input"
},
{
field:"locworkerratio",
label:"员工中本地人口占比",
class:"",
show:"input"
}
]
},
{
level:1,
title:"组织模式",
info:[{
field:"organstruct",
label:"",
class:"",
show:"radio",
selects:datafileds.organstruct
}]
},
{
level:1,
title:"经营模式(可多选)",
info:[{
field:"businessmodel",
label:"",
class:"",
show:"checkbox",
selects:datafileds.businessmodel
}]
},
{
level:1,
title:"资金情况",
info:[{
field:"asset",
label:"农场资产规模(万元)",
class:"",
show:"input"
},
{
field:"totalinvest",
label:"农场总投入(万元)",
class:"",
show:"input"
},
{
field:"investsource",
label:"农场投资来源",
class:"",
show:"checkbox",
selects: datafileds.investsource
},
{
field:"insurance",
label:"是否购买保险",
class:"",
show:"radio",
selects: datafileds.whether
}]
}
],
"farmmanager":[{
level:0,
title:"农场管理",
info:[{
field:"farmlicense",
label:"是否有包含农场的营业执照",
class:"",
show:"radio",
selects:datafileds.whether
},{
field:"landlicense",
label:"是否有土地使用权证书",
class:"",
show:"radio",
selects:datafileds.whether
},{
field:"managerule",
label:"是否建立了完整的管理制度/操作规程",
class:"",
show:"radio",
selects:datafileds.whether
},{
field:"plantrule",
label:"是否有作物种植的操作规程",
class:"",
show:"radio",
selects:datafileds.whether
},{
field:"record",
label:"是否有相关记录",
class:"",
show:"radio",
selects:datafileds.whether
},{
field:"train",
label:"是否有相关培训",
class:"",
show:"radio",
selects:datafileds.whether
},{
field:"prohis",
label:"是否建立了产品追溯体系",
class:"",
show:"radio",
selects:datafileds.whether
}]
}],
"farmcredent":[{
level:0,
title:"农场认证情况",
info:[{
field:"organcentify",
label:"有机认证",
class:"",
show:"radio",
selects: datafileds.whether
},{
field:"greencentify",
label:"绿色认证",
class:"",
show:"radio",
selects: datafileds.whether
},{
field:"cleancentify",
label:"无公害认证",
class:"",
show:"radio",
selects: datafileds.whether
},{
field:"geocentify",
label:"地址位置认证",
class:"",
show:"radio",
selects: datafileds.whether
},{
field:"gapcentify",
label:"良好农业规范认证(GAP认证)",
class:"",
show:"radio",
selects: datafileds.whether
}]
},
{
level:1,
title:"认证详情",
info:[{
field:"startdate",
label:"认证开始年份",
class:"",
show:"input"
},{
field:"enddate",
label:"认证结束年份",
class:"",
show:"input"
}]
}]
},
"model2":{},
"model3":{},
"model4":{}
}
// const
module.exports = {
plantFarm: plantFarm
}
\ No newline at end of file
@import "../../weui.wxss"
page{
background-color: #F8F8F8;
height: 100%;
font-size: 32rpx;
line-height: 1.6;
}
.checkbox,
.radio {
display: block;
border-top: 1px solid white;
padding: 5px;
}
.checkbox-group,
.radio-group {
border-bottom: 1px solid #ddd;
}
.checkbox-group{
display:block;
position:relative;
}
.page-section{
margin-bottom: 10rpx;
margin-left: 10rpx;
margin-right: 10rpx;
}
.weui-input{
width: 100%;
}
.title_0,
.title_1{
margin-top: 5rpx;
text-align: center;
}
.title_0{
font-weight: bold;
}
.title_0::before{
content: "---";
}
.title_0::after{
content: "---";
}
.title_1{
font-size: 30rpx;
}
.title_1::before{
content: "---";
}
.title_1::after{
content: "---";
}
.weui-checkbox-input{
display: inline-block;
}
.error{
border-top: 1px solid red;
border-bottom: 1px solid red;
}
\ No newline at end of file
// pages/report/baseinfo.js
function extendJson(a,b){
for (let obj in b) {
a[obj] = b[obj];
}
return a;
}
var datafileds = require("../data/dataFields.js")
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
reportinfo:datafileds.plantFarm.model1
})
},
commitInfo: function() {
// let n=this.selectComponent("#user")
// console.log(n)
let datas={}
for(let key in this.data.reportinfo){
console.log("#"+key)
let node = this.selectComponent("#"+key)
datas = extendJson(datas,node.data.fieldData)
}
console.log(datas)
app.userId = 1;
console.log("提交成功");
wx.navigateBack({
delta: 1
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"navigationBarTitleText": "基本信息",
"usingComponents": {
"data-show": "../component/datashow/datashow"
}
}
\ No newline at end of file
<!--pages/report/baseinfo.wxml-->
<button type="primary" bindtap="commitInfo">开启智慧农场!</button>
<data-show id="user" items="{{reportinfo.user}}"></data-show>
<data-show id="farmbase" items="{{reportinfo.farmbase}}"></data-show>
<data-show id="farmmanager" items="{{reportinfo.farmmanager}}"></data-show>
<data-show id="farmcredent" items="{{reportinfo.farmcredent}}"></data-show>
/* pages/report/baseinfo.wxss */
\ No newline at end of file
const app = getApp()
Page({
data: {
userInfo:[
{
label:"姓名",
value:"",
choosed:0
},
{
label:"调查地点",
value:"",
choosed:0
},
{
label:"性别",
value:"",
choosed:1,
selects:[
{}
]
},
{
label:"年龄",
value:"",
choosed:0
},
{
label:"受教育程度",
value:"",
choosed:1,
selects:[
"高中以下",
"高中",
"大专",
"本科",
"研究生",
"博士及以上"
// {
// label:"高中以下",
// value:0
// },
// {
// label:"高中",
// value:1
// },
// {
// label:"大专",
// value:2
// },
// {
// label:"本科",
// value:3
// },
// {
// label:"研究生",
// value:4
// },
// {
// label:"博士及以上",
// value:5
// }
]
},
{
label:"从事农业时间",
value:"",
choosed:0
},
{
label:"之前从事的行业",
value:"",
choosed:0
}
],
canIUse: wx.canIUse('button.open-type.getUserInfo')
},
onLoad:function(){
console.log("user_write.json")
},
commitInfo:function(){
app.userId=1;
console.log("提交成功");
wx.navigateBack({
delta: 1
})
}
})
\ No newline at end of file
{
"navigationBarTitleText": "负责人基本信息"
}
\ No newline at end of file
<view>
<div class="container">
<view wx:for="{{userInfo}}" wx:key="{{idx}}">
<text>{{item.label}}</text>
<input value="{{item.value}}" wx:if="{{!item.choosed}}" />
<picker mode="selector" range="{{item.selects}}" wx:else="{{item.choosed}}" ></picker>
</view>
<!-- <block>
<view>{{item.label}}</view>
</block> -->
<button class="commit" bindtap="commitInfo">开启智慧农场!</button>
</div>
</view>
\ No newline at end of file
input{
border: 1px solid black;
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment