小程序源码

This commit is contained in:
mindskip
2020-09-02 08:44:41 +08:00
parent 30b54a23ff
commit 593017f562
277 changed files with 5497 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
// pages/user/info/index.js
const app = getApp()
Page({
data: {
userInfo: null,
spinShow: false,
levelIndex: 0
},
onLoad: function(options) {
this.loadUserInfo()
},
loadUserInfo() {
let _this = this
_this.setData({
spinShow: true
});
app.formPost('/api/wx/student/user/current', null).then(res => {
if (res.code == 1) {
_this.setData({
userInfo: res.response,
levelIndex: res.response.userLevel-1
});
}
_this.setData({
spinShow: false
});
}).catch(e => {
_this.setData({
spinShow: false
});
app.message(e, 'error')
})
},
bindLevelChange: function(e) {
this.setData({
levelIndex: e.detail.value
})
},
bindDateChange(e) {
let {
value
} = e.detail;
this.setData({
"userInfo.birthDay": value
})
},
formSubmit: function(e) {
let _this = this
wx.showLoading({
title: '提交中',
mask: true
})
app.formPost('/api/wx/student/user/update', e.detail.value)
.then(res => {
if (res.code == 1) {
wx.reLaunch({
url: '/pages/my/index/index',
});
} else {
app.message(res.message, 'error')
}
wx.hideLoading()
}).catch(e => {
app.message(e, 'error')
wx.hideLoading()
})
}
})

View File

@@ -0,0 +1,11 @@
{
"usingComponents": {
"i-button": "/component/iView/button/index",
"i-panel": "/component/iView/panel/index",
"i-input": "/component/iView/input/index",
"i-message": "/component/iView/message/index",
"i-spin": "/component/iView/spin/index",
"i-radio-group": "/component/iView/radio-group/index",
"i-radio": "/component/iView/radio/index"
}
}

View File

@@ -0,0 +1,40 @@
<wxs module="enumItem" src="../../../wxs/enumItem.wxs"></wxs>
<form bindsubmit='formSubmit'>
<i-panel title="真实姓名">
<i-input value="{{ userInfo.realName }}" name="realName" maxlength="-1" />
</i-panel>
<i-panel title="年龄">
<i-input value="{{ userInfo.age }}" name="age" maxlength="-1" />
</i-panel>
<i-panel title="性别">
<radio-group class="radio-group my-info-sex" name="sex">
<label class="radio my-info-sex-item" wx:for="{{ enumItem.state.user.sexEnum }}" wx:key="{{item.key}}" wx:for-item="radioItem">
<radio color="#2d8cf0" value="{{radioItem.key}}" checked="{{radioItem.key===userInfo.sex}}" />
<text>{{radioItem.value}}</text>
</label>
</radio-group>
</i-panel>
<i-panel title="出生日期">
<picker class="weui-btn" mode="date" value="{{userInfo.birthDay}}" bindchange="bindDateChange">
<view class="i-cell i-input exam-pick-input">{{ userInfo.birthDay }}</view>
<i-input value="{{ userInfo.birthDay }}" class="exam-hidden" name="birthDay" maxlength="-1" />
</picker>
</i-panel>
<i-panel title="手机">
<i-input value="{{ userInfo.phone }}" name="phone" maxlength="-1" />
</i-panel>
<i-panel title="年级">
<picker mode="selector" range="{{ enumItem.state.user.levelEnum }}" range-key="{{'value'}}" value="{{levelIndex}}" bindchange="bindLevelChange">
<view class="i-cell i-input exam-pick-input">{{ enumItem.state.user.levelEnum[levelIndex].value }}</view>
<i-input value="{{enumItem.state.user.levelEnum[levelIndex].key}}" maxlength="-1" name="userLevel" class="exam-hidden" />
</picker>
</i-panel>
<view>
<button class="i-btn i-btn- i-btn-primary i-btn-square" form-type='submit'>保存</button>
</view>
</form>
<i-spin size="large" fix wx:if="{{ spinShow }}"></i-spin>
<i-message id="message" />

View File

@@ -0,0 +1,18 @@
.my-info-sex {
height: 45px;
font-size: 13px;
}
.my-info-sex-item {
line-height: 45px;
margin-left: 20px;
}
.my-info-level {
font-size: 13px;
}
.my-info-level-item {
line-height: 45px;
margin-left: 25px;
}