diff --git a/config/config.js b/config/config.js index 39ca670..96c0ad9 100755 --- a/config/config.js +++ b/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: { diff --git a/pages/edit/edit.js b/pages/edit/edit.js index 87f9139..c13db5c 100644 --- a/pages/edit/edit.js +++ b/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") }, /** diff --git a/pages/edit/edit.wxml b/pages/edit/edit.wxml index a66c2b9..c4ed0fa 100644 --- a/pages/edit/edit.wxml +++ b/pages/edit/edit.wxml @@ -1,7 +1,8 @@