Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
smart-agriculture
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张泽丹
smart-agriculture
Commits
3839be55
Commit
3839be55
authored
Apr 04, 2019
by
zhangzedan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
index user_registe
parent
4d147219
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
285 additions
and
129 deletions
+285
-129
app.js
app.js
+60
-60
app.json
app.json
+4
-3
app.wxss
app.wxss
+32
-5
farm.png
image/farm.png
+0
-0
self.png
image/self.png
+0
-0
pages.js
js/pages.js
+8
-0
index.js
pages/index/index.js
+10
-1
index.wxml
pages/index/index.wxml
+5
-6
index.wxss
pages/index/index.wxss
+23
-27
user_write.js
pages/report/user/user_write.js
+89
-0
user_write.json
pages/report/user/user_write.json
+3
-0
user_write.wxml
pages/report/user/user_write.wxml
+14
-0
user_write.wxss
pages/report/user/user_write.wxss
+3
-0
user.js
pages/user/user.js
+27
-26
project.config.json
project.config.json
+1
-1
weui.wxss
weui.wxss
+6
-0
No files found.
app.js
View file @
3839be55
//app.js
var
jsonData
=
require
(
'app.json'
);
App
({
onLaunch
:
function
()
{
// 展示本地存储能力
var
logs
=
wx
.
getStorageSync
(
'logs'
)
||
[]
logs
.
unshift
(
Date
.
now
())
wx
.
setStorageSync
(
'logs'
,
logs
)
var
pages
=
require
(
'js/pages.js'
);
// 将code传输到服务器
function
getIdInfo
(
code
){
wx
.
request
({
url
:
'http://192.168.31.6:8080/login/getMessageByCode'
,
//自己的服务接口地址
method
:
'post'
,
data
:
{
code
:
code
},
success
(
res
)
{
console
.
log
(
res
)
},
fail
(
res
)
{
wx
.
showToast
({
title
:
"系统错误"
,
duration
:
5000
,
icon
:
"none"
})
}
})
return
{}
}
function
getUserInfo
(){
wx
.
getUserInfo
({
success
:
function
(
res
)
{
return
res
.
rawData
},
fail
:
function
(
res
){
wx
.
showToast
({
title
:
"系统错误"
,
duration
:
3000
})
}
})
}
App
({
globalData
:
{
userId
:
null
,
farmId
:
null
,
userInfo
:
null
},
onLaunch
:
function
()
{
// 登录
wx
.
login
({
success
:
res
=>
{
// 发送 res.code 到后台换取 openId, sessionKey, unionId
console
.
log
(
res
)
var
_this
=
this
;
// // 发送 res.code 到后台换取 openId, sessionKey, unionId
let
code
=
res
.
code
if
(
code
){
wx
.
getUserInfo
({
success
:
function
(
res
)
{
// console.log({encryptedData: res.encryptedData, iv: res.iv, code: code})
//3.解密用户信息 获取unionId
//...
},
fail
:
function
()
{
// console.log('获取用户信息失败')
}
})
if
(
code
)
{
// 根据code获取openid,以及是否是绑定用户
let
info
=
getIdInfo
(
code
)
// 以后修改为从info获取
let
isUser
=
false
if
(
!
isUser
){
wx
.
showToast
({
title
:
"第一次登录,请先填写个人信息"
,
icon
:
"none"
})
this
.
globalData
.
userInfo
=
getUserInfo
()
setTimeout
(
function
(){
wx
.
navigateTo
({
url
:
"../../pages/report/user/user_write"
})
},
1000
)
}
}
}
})
// 获取用户信息
wx
.
getSetting
({
success
:
res
=>
{
if
(
res
.
authSetting
[
'scope.userInfo'
])
{
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx
.
getUserInfo
({
success
:
res
=>
{
// 可以将 res 发送给后台解码出 unionId
this
.
globalData
.
userInfo
=
res
.
userInfo
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
if
(
this
.
userInfoReadyCallback
)
{
this
.
userInfoReadyCallback
(
res
)
}
}
})
}
}
})
},
globalData
:
{
userInfo
:
null
},
router
:
function
(
id
){
console
.
log
(
id
);
switch
(
id
)
{
case
0
:
wx
.
navigateTo
({
url
:
'pages/index/index'
,
})
break
;
case
1
:
wx
.
navigateTo
({
url
:
'pages/user/user'
,
})
break
;
default
:
// statements_def
break
;
}
}
})
\ No newline at end of file
app.json
View file @
3839be55
...
...
@@ -2,12 +2,13 @@
"pages"
:[
"pages/index/index"
,
"pages/logs/logs"
,
"pages/user/user"
"pages/user/user"
,
"pages/report/user/user_write"
],
"window"
:{
"backgroundTextStyle"
:
"light"
,
"navigationBarBackgroundColor"
:
"#
fff
"
,
"navigationBarTitleText"
:
"
WeChat
"
,
"navigationBarBackgroundColor"
:
"#
1cd8d7
"
,
"navigationBarTitleText"
:
"
智慧农场
"
,
"navigationBarTextStyle"
:
"black"
}
}
app.wxss
View file @
3839be55
/**app.wxss**/
@import 'weui.wxss';
input{
display: inline-block;
}
.container {
height: 100%;
width: 100%;
display: flex;
flex-direction: column;
/* align-items: center; */
align-items: center;
justify-content: space-between;
/* padding: 200rpx 0; */
box-sizing: border-box;
}
.top{
width: 100%;
height:
10%
;
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 .button{
width: 50%;
.top .left{
text-align: left;
margin-left: 10rpx;
}
.top .right{
text-align: right;
margin-right: 10rpx;
}
/* .top .left{
} */
\ No newline at end of file
image/farm.png
0 → 100644
View file @
3839be55
13.2 KB
image/self.png
0 → 100644
View file @
3839be55
6.63 KB
js/pages.js
0 → 100644
View file @
3839be55
var
pages
=
[
"pages/index/index"
,
"pages/logs/logs"
,
"pages/user/user"
]
module
.
exports
=
{
pages
}
\ No newline at end of file
pages/index/index.js
View file @
3839be55
...
...
@@ -9,6 +9,15 @@ Page({
hasUserInfo
:
false
,
canIUse
:
wx
.
canIUse
(
'button.open-type.getUserInfo'
)
},
onShow
:
function
(){
if
(
app
.
userId
){
wx
.
showToast
({
title
:
"欢迎来到智慧农场~"
,
icon
:
"none"
,
duration
:
1500
})
}
},
// //事件处理函数
// bindViewTap: function() {
// wx.navigateTo({
...
...
@@ -54,7 +63,7 @@ Page({
// },
toUser
:
function
(){
wx
.
navigateTo
({
url
:
'../user/user'
,
url
:
"../../pages/user/user"
})
}
})
pages/index/index.wxml
View file @
3839be55
<!--index.wxml-->
<view class="container">
<view class="top">
<
button>我的</button
>
<
button>农场</button
>
<
a class="left"><image src="../../image/self.png"></image>我的</a
>
<
a class="right"><image src="../../image/farm.png"></image>农场</a
>
<!-- <block wx:else>
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
<text class="userinfo-nickname">{{userInfo.nickName}}</text>
</block> -->
</view>
<view class="bottom">
<button>历史体检报告</button>
<button>开始体检</button>
<button>历史体检报告</button>
<text class="user-motto" bindtap='toUser'>{{motto}}</text>
<button class="analy">体检报告解析</button>
<button class="start">开始体检</button>
<button class="curr" bindtap="toUser">我的体检报告</button>
</view>
</view>
pages/index/index.wxss
View file @
3839be55
/**index.wxss**/
/* .userinfo {
display: flex;
flex-direction: column;
align-items: center;
}
.userinfo-avatar {
width: 128rpx;
height: 128rpx;
margin: 20rpx;
border-radius: 50%;
}
.userinfo-nickname {
color: #aaa;
.bottom{
position: fixed;
bottom: 10rpx;
}
.usermotto {
margin-top: 200px;
} */
/* .container{
} */
/* .top{
margin-top: 0;
.bottom button{
display: inline;
margin: 5rpx;
padding-left: 15rpx;
padding-right: 15rpx;
padding-top: 8rpx;
padding-bottom: 8rpx;
/* background-color: blue; */
}
.bottom{
margin-bottom: 0;
} */
\ No newline at end of file
/* .bottom */
.bottom .start{
width: 130rpx;
background-color: rgb(28,216,215);
box-shadow: 0rpx 0rpx 10px 2px #54fdfb;
padding-left: 25rpx;
padding-right: 25rpx;
padding-top: 15rpx;
padding-bottom: 15rpx;
/* background-color: orange; */
/* border-radius: 65rpx; */
}
\ No newline at end of file
pages/report/user/user_write.js
0 → 100644
View file @
3839be55
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
pages/report/user/user_write.json
0 → 100644
View file @
3839be55
{
"navigationBarTitleText"
:
"负责人基本信息"
}
\ No newline at end of file
pages/report/user/user_write.wxml
0 → 100644
View file @
3839be55
<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
pages/report/user/user_write.wxss
0 → 100644
View file @
3839be55
input{
border: 1px solid black;
}
pages/user/user.js
View file @
3839be55
...
...
@@ -16,32 +16,33 @@ Page({
})
},
onLoad
:
function
()
{
if
(
app
.
globalData
.
userInfo
)
{
this
.
setData
({
userInfo
:
app
.
globalData
.
userInfo
,
hasUserInfo
:
true
})
}
else
if
(
this
.
data
.
canIUse
){
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
app
.
userInfoReadyCallback
=
res
=>
{
this
.
setData
({
userInfo
:
res
.
userInfo
,
hasUserInfo
:
true
})
}
}
else
{
// 在没有 open-type=getUserInfo 版本的兼容处理
wx
.
getUserInfo
({
success
:
res
=>
{
app
.
globalData
.
userInfo
=
res
.
userInfo
this
.
setData
({
userInfo
:
res
.
userInfo
,
hasUserInfo
:
true
})
}
})
}
console
.
log
(
app
.
globalData
.
unionId
);
// if (app.globalData.userInfo) {
// this.setData({
// userInfo: app.globalData.userInfo,
// hasUserInfo: true
// })
// } else if (this.data.canIUse){
// // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// // 所以此处加入 callback 以防止这种情况
// app.userInfoReadyCallback = res => {
// this.setData({
// userInfo: res.userInfo,
// hasUserInfo: true
// })
// }
// } else {
// // 在没有 open-type=getUserInfo 版本的兼容处理
// wx.getUserInfo({
// success: res => {
// app.globalData.userInfo = res.userInfo
// this.setData({
// userInfo: res.userInfo,
// hasUserInfo: true
// })
// }
// })
// }
},
getUserInfo
:
function
(
e
)
{
console
.
log
(
e
)
...
...
project.config.json
View file @
3839be55
...
...
@@ -4,7 +4,7 @@
"ignore"
:
[]
},
"setting"
:
{
"urlCheck"
:
tru
e
,
"urlCheck"
:
fals
e
,
"es6"
:
true
,
"postcss"
:
true
,
"minified"
:
true
,
...
...
weui.wxss
0 → 100644
View file @
3839be55
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment