123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- import {
- get, post,
- } from '../../utils/http';
- Page({
-
- data: {
- userInfo: {},
- visible: false,
- genders: ["男","女"],
- genderIndex: 0,
- date: '2016-09-01',
- region: ['广东省', '广州市', '海珠区'],
- },
-
- onLoad: function (options) {
- console.log(options)
- if(options.userId) {
- this.setData({
- userId: options.userId
- },() => {
-
- })
- }
- },
-
- onReady: function () {
- },
-
- onShow: function () {
-
- this.getUserInfo()
- },
-
- onHide: function () {
- this.setData({
- visible: false
- })
- },
-
- onUnload: function () {
-
- },
-
- onPullDownRefresh: function () {
- },
-
- onReachBottom: function () {
- },
-
- onShareAppMessage: function () {
- },
- isShow() {},
-
- onPopupState(e, key, value) {
- if (e) {
- key = e.currentTarget.dataset.key
- value = e.currentTarget.dataset.value
- }
- console.log(key)
- console.log(value)
- this.setData({
- [key]: value
- })
- },
-
- bindGenderChange(e) {
- this.setData({
- ['userInfo.sex']: Number(e.detail.value) + 1,
- },() => {
- this.setUserFiles()
- })
- },
-
- bindDateChange: function(e) {
- console.log(e)
- this.setData({
- ['userInfo.birthday']: e.detail.value,
-
- },() => {
- this.setUserFiles()
- })
- },
-
- bindRegionChange: function (e) {
- this.setData({
- region: e.detail.value,
- ['userInfo.city']: e.detail.value.toString(),
- },() => {
- this.setUserFiles()
- })
- },
-
- getUserFiles() {
- get('api/user/files',{},(res) => {
- this.setData({
- userInfo: res.data
- })
- console.log(res)
- })
- },
-
- setUserFiles() {
- let { user_id,avatar_url,nickname,realname,sex,birthday,mobile,city,tags } = this.data.userInfo;
- post('api/user/update',{
- user_id,
- avatar_url,
- nickname,
- realname,
- sex,
- birthday,
- mobile,
- city,
- tags
- },() => {
- })
- },
-
- getUserInfo() {
- let { userId } = this.data;
- get('api/user/info',{
- user_id: userId
- },(res) => {
- this.setData({
- userInfo: res.data
- })
- console.log(res)
- })
- },
-
- })
|