瀏覽代碼

[我的][增加]:个人用户信息增加编辑的功能

tags/2.2.4
meo 6 年之前
父節點
當前提交
e4d5569e71
共有 5 個文件被更改,包括 153 次插入26 次删除
  1. +7
    -1
      config/config.js
  2. +121
    -12
      pages/edit/edit.js
  3. +2
    -1
      pages/edit/edit.wxml
  4. +22
    -11
      pages/user/index.js
  5. +1
    -1
      pages/user/index.wxml

+ 7
- 1
config/config.js 查看文件

@@ -1,4 +1,5 @@
var config = {
// url: "http://10.11.205.51:7000/C/api",
url: "https://ciformall.youlane.cn/C/api",
// url:"https://c.malls.iformall.com/C/api",
// url: "http://31adc9ce.ngrok.io/C/api",
@@ -147,7 +148,12 @@ var config = {
/**
* 小程序获取游戏路径
*/
getGame:'/game/getOne'
getGame:'/game/getOne',
/**
* 用户更新信息
*/
updateInfo:"/user/updateUserInfo"

},

weapp: {


+ 121
- 12
pages/edit/edit.js 查看文件

@@ -1,4 +1,6 @@
const app = getApp();
const util = require("../../utils/util.js");
const Http = require("../../utils/HttpBasics");
const config = require("../../config/config");
Page({

/**
@@ -6,10 +8,11 @@ Page({
*/
data: {
date: '1988-03-12',
flag:1,
flag: 1,
flagsex: 0,
items: [
{ name: 'male', value: '男' },
{ name: 'famale', value: '女' },
{ name: 1, value: '男', checked: false },
{ name: 2, value: '女', checked: false },
]
},
/**
@@ -17,36 +20,142 @@ Page({
*/
bindDateChange: function (e) {
console.log('picker发送选择改变,携带值为', e.detail.value);

console.log(typeof (e.detail.value))
this.setData({
date: e.detail.value,
flag:2
flag: 2
})
},
address: function () {
let that = this;
wx.chooseLocation({
success:function(res){
success: function (res) {
console.log(res);
that.setData({
name: res.name
name: res.name,
address: res,
})
},
fail:function(error){
fail: function (error) {
console.log(error)
},
complete:function(data){
complete: function (data) {
console.log(data);
}
})
},
formSubmit: function (e) {
console.log(e);
let that = this;
/**
* sex
* 0 保密
* 1 男
* 2 女
*/
if (that.data.flagsex == 0) {
var sex = 0;
} else {
var sex = that.data.sex;
}
if (that.data.address) {
var address = JSON.stringify(that.data.address);
}
else {
var address = null;
}
if (e.detail.value.username) {
var username = e.detail.value.username;
} else if (that.data.username) {
var username = that.data.username;
}
else {
var username = null;
}
if (that.data.flag == 2 && that.data.date) {
var birthdate = new Date(that.data.date).getTime();
} else {
var birthdate = null;
}
console.log(username);
console.log(address);
console.log(sex);
console.log(birthdate);

if (username == null || address == null || sex == 0 || birthdate == null) {
wx.showModal({
title: '提示',
content: '请输入完整的用户信息',
showCancel: false
})
} else {
Http.post({
url: config.api.updateInfo,
data: {
sex: sex,
address: address,
name: username,
birthdate: birthdate,
}
})
.then(res => {
console.log(res);
wx.showModal({
title: '提示',
content: '修改成功',
showCancel: false,
success: function (res) {
wx.switchTab({
url: '/pages/user/index',
})
}
})
})
}

},
radioChange: function (e) {
console.log('radio发生change事件,携带value值为:', e.detail.value)
console.log(e.detail.value)
this.setData({
sex: e.detail.value,
flagsex: 1
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {

let that = this;
that.setData({
username: options.name,
sex: options.sex,
date: util.fmtDate(parseInt(options.birthdate)),
name: JSON.parse(options.address).name,
address: JSON.parse(options.address),
flag: 2
});
if (options.sex == "1") {
console.log(that.data.items);
that.data.items[0].checked = true;
var checked = 'items[' + 0 + '].checked'
that.setData({
[checked]: true
})
that.setData({
flagsex: 1
})
} else if (options.sex == "2") {
that.data.items[1].checked = true;
var checked = 'items[' + 1 + '].checked'
that.setData({
[checked]: true
})
that.setData({
flagsex: 1
})
console.log(that.data.items);
}
},

/**
@@ -60,7 +169,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
let that = this;
console.log("oShow")
},

/**


+ 2
- 1
pages/edit/edit.wxml 查看文件

@@ -1,7 +1,8 @@
<form bindsubmit="formSubmit">
<view class='section'>
<text>姓名</text>
<input type="text" placeholder='请填写名字' />
<input wx:if="{{username}}" type="text" placeholder='{{username}}'/>
<input wx:if="{{!username}}" type="text" placeholder='请填写名字' disabled/>
</view>
<view class="section sec">
<text>生日</text>


+ 22
- 11
pages/user/index.js 查看文件

@@ -38,16 +38,19 @@ Page({
// }
// })
// },
getxinghao:function(){
wx.getSystemInfo({
success:function(res){
console.log(res);
wx.showModal({
content: res.brand,
})
}
})
},
/**
*
*/
// getxinghao:function(){
// wx.getSystemInfo({
// success:function(res){
// console.log(res);
// wx.showModal({
// content: res.brand,
// })
// }
// })
// },
navigateTo() {
wx.navigateTo({
url: `/pages/login/index`
@@ -67,7 +70,7 @@ Page({
},
gotoedit:function(){
wx.navigateTo({
url: '/pages/edit/edit',
url: `/pages/edit/edit?name=${this.data.name}&birthdate=${this.data.birthdate}&sex=${this.data.sex}&address=${this.data.address}`,
})
},
/**
@@ -114,6 +117,14 @@ Page({
score: res.data.score,
levelName: res.data.levelName
})
if(res.data.address&&res.data.name&&res.data.sex&&res.data.birthdate){
that.setData({
address: res.data.address,
name: res.data.name,
sex: res.data.sex,
birthdate: res.data.birthdate
})
}
});
// that.getrun();
},


+ 1
- 1
pages/user/index.wxml 查看文件

@@ -8,7 +8,7 @@
</view>
<view class="user-phone" bindtap='gotoedit'>
<open-data type="userNickName"></open-data>
<view class='chengzhang'>点击编辑资料</view>
<view class='chengzhang'>完善个人信息(获得成长值)</view>
</view>
<view class='chengzhang1' bindtap='gotograde'>
<text style="color:#01bffe;">当前成长值</text>


Loading…
取消
儲存