Commit 84bf24d4 by TengFengLian

用户信息编辑

parent dce4892b
......@@ -110,6 +110,10 @@ App({
wx.setStorageSync('nickName', res.data.nickName)
wx.setStorageSync('avatarUrl', res.data.avatarUrl)
wx.setStorageSync('userType', res.data.userType) // 0 游客 1 业主
wx.setStorageSync('sex', res.data.sex)
wx.setStorageSync('birthday', res.data.birthday)
wx.setStorageSync('address', res.data.address)
if (obj.success) {
obj.success(res.data.token)
}
......
......@@ -105,7 +105,7 @@ Page({
url: '/api/v1/activity/getDetail',
data: { id: that.data.id },
success: function(res) {
var response = res.data.jsonobject
var response = res.data
that.setData({
banner: response.banners,
info: {
......
......@@ -153,7 +153,7 @@ Page({
url: '/api/v1/activity/getEnrollView',
data: { id: that.data.id },
success: function(res) {
var response = res.data.jsonobject
var response = res.data
var activityTimes = []
response.activityTimes.forEach(item => {
var obj = item
......
......@@ -98,13 +98,16 @@ Page({
console.log('userInfo', res)
let avatarUrl = res.detail.userInfo.avatarUrl
let nickName = res.detail.userInfo.nickName
let gender = res.detail.userInfo.gender
wx.setStorageSync('avatarUrl', avatarUrl)
wx.setStorageSync('nickName', nickName)
wx.setStorageSync('sex', gender)
let that = this
this.registUserInfo({
param: {
avatarUrl: avatarUrl,
nickName: nickName,
sex: gender,
sessionKey: '',
encryptedData: '',
iv: '',
......
......@@ -77,7 +77,7 @@ Page({
let userType = wx.getStorageSync('userType')
if (mobile && nickName && avatarUrl) {
that.setData({
mobile: mobile,
mobile: that.toHide(mobile),
nickName: nickName,
avatarUrl: avatarUrl,
type: userType == 1 ? 1 : 0,
......
// pages/myInfo/myInfo.js
import iMiment from '../../npm/miment.js'
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
birthdayEnd: iMiment(new Date().getTime()).format('YYYY-MM-DD'),
mobile: '',
nickName: '',
avatarUrl: '',
genderArray: [
{ id: 1, name: '男' },
{ id: 2, name: '女' },
],
genderIndex: 0,
birthday: '',
address: '',
},
/**
......@@ -18,10 +29,16 @@ Page({
let mobile = wx.getStorageSync('mobile')
let nickName = wx.getStorageSync('nickName')
let avatarUrl = wx.getStorageSync('avatarUrl')
let sex = wx.getStorageSync('sex')
let birthday = wx.getStorageSync('birthday')
let address = wx.getStorageSync('address')
this.setData({
mobile: this.toHide(mobile),
nickName: nickName,
avatarUrl: avatarUrl,
genderIndex: sex == 1 ? 0 : 1,
birthday: birthday ? birthday : this.data.birthdayEnd,
address: address,
})
},
......@@ -77,5 +94,76 @@ Page({
toHide: function(array) {
var mphone = array.substring(0, 3) + '****' + array.substring(7);
return mphone;
},
onInputBlur: function (event) {
let funcType = event.target.dataset.type
let funcValue = event.detail.value
switch (funcType) {
case 'name':
this.setData({
nickName: funcValue
})
break
case 'address':
this.setData({
address: funcValue
})
break
}
this.doUpdateInfo()
},
// 性别选择
onSelectionGender(e) {
this.setData({
genderIndex: e.detail.value
})
this.doUpdateInfo()
},
// 生日选择
onSelectionDate: function (event) {
this.setData({
birthday: event.detail.value,
})
this.doUpdateInfo()
},
doUpdateInfo() {
let nickName = this.data.nickName
let sex = this.data.genderArray[this.data.genderIndex].id
let birthday = this.data.birthday
let address = this.data.address
if (nickName == '') {
wx.lin.showToast({
icon: 'error',
title: '请填写姓名',
})
return
}
let param = {
sex: sex,
name: nickName,
address: address,
birthday: birthday,
}
console.log(param)
app.wxRequest({
url: '/api/v1/smUser/doUpdateInfo',
data: param,
success: function(res) {
wx.setStorageSync('nickName', nickName)
wx.setStorageSync('sex', sex)
wx.setStorageSync('birthday', birthday)
wx.setStorageSync('address', address)
}
})
}
})
\ No newline at end of file
<!--pages/myInfo/myInfo.wxml-->
<l-toast></l-toast>
<navigation class="navigation" titleText="个人资料" backIcon="/image/back.png"></navigation>
<view class="container">
......@@ -10,22 +11,28 @@
</l-list>
<l-list is-hover="{{false}}" l-content-class="menu-title" title="姓名" is-link="{{false}}">
<view slot="right-section">
<input style="text-align:right;" value="{{nickName}}" />
<input style="text-align:right;" placeholder="请填写姓名" placeholder-class="phone" value="{{nickName}}" data-type="name" bindblur="onInputBlur"/>
</view>
</l-list>
<l-list is-hover="{{false}}" l-content-class="menu-title" title="性别" is-link="{{false}}">
<view slot="right-section">
<picker slot="right-section" class="input-picker" mode="selector" range-key="{{'name'}}" range="{{genderArray}}" bindchange="onSelectionGender">
<view class="picker">{{genderArray[genderIndex].name}}</view>
</picker>
<!-- <view slot="right-section">
<input style="text-align:right;" value="女" />
</view>
</view> -->
</l-list>
<l-list is-hover="{{false}}" l-content-class="menu-title" title="生日" is-link="{{false}}">
<view slot="right-section">
<!-- <view slot="right-section">
<input style="text-align:right;" value="1990-01-01" />
</view>
</view> -->
<picker slot="right-section" class="input-picker" mode="date" value="{{birthday}}" end="{{birthdayEnd}}" bindchange="onSelectionDate">
<view class="picker">{{birthday}}</view>
</picker>
</l-list>
<l-list is-hover="{{false}}" l-content-class="menu-title" title="地址" is-link="{{false}}">
<view slot="right-section">
<input style="text-align:right;" value="福建省厦门市思明区" />
<input style="text-align:right;" placeholder="请填写地址" placeholder-class="phone" value="{{address}}" data-type="address" bindblur="onInputBlur"/>
</view>
</l-list>
<l-list is-hover="{{false}}" l-content-class="menu-title" title="手机号" is-link="{{false}}">
......
......@@ -7,4 +7,12 @@
}
.phone{
color: rgb(177, 176, 182);
}
.input-picker{
width: 400rpx;
height: 44rpx;
}
.picker{
text-align: right;
line-height: 44rpx;
}
\ No newline at end of file
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 sign in to comment