You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
clothesProject/pages/navigation/userinform/userinform.js

186 lines
4.0 KiB

2 years ago
// pages/navigation/userinform/userinform.js
Page({
/**
* 页面的初始数据
*/
data: {
ip:'82.157.11.188' ,
port:8080,
insshen:'',
intti:'',
inyyao:'',
inttui:'',
inxxiong:'',
inttun:''
},
saveinform:function(){
wx.switchTab({
url: '../self/self'
})
//初始化云
wx.cloud.init({
env:'cloud1-5ggzbo3kcd4ea4e2'
});
//初始化数据库
const db=wx.cloud.database();
db.collection('user').add({
data: {
iphone:obj.iphone,
password:obj.password,
insshen:this.data.insshen,
intti:this.data.intti,
inyyao:this.data.inyyao,
inttui:this.data.inttui,
inxxiong:this.data.inxxiong,
inttun:this.data.inttun
},
sucess:function(res){
console.log("添加成功",res);
},
fail:function(res){
console.log(res.errMsg,"添加失败")
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad:function (options){
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
const self = this
var userText1 = wx.getStorageSync('userText1')
var userText2 = wx.getStorageSync('userText2')
var userText3 = wx.getStorageSync('userText3')
var userText4 = wx.getStorageSync('userText4')
var userText5 = wx.getStorageSync('userText5')
var userText6 = wx.getStorageSync('userText6')
if (userText1) {
self.data.insshen = userText1;
self.setData(self.data);
} // page载入的时候先读取一次wx.getStorageSync('userText')里面有没有内容,有内容就填充,没有则什么也不做
if (userText2) {
self.data.intti = userText2;
self.setData(self.data)
}
if (userText3) {
self.data.inyyao = userText3
self.setData(self.data)
}
if (userText4) {
self.data.inxxiong = userText4
self.setData(self.data)
}
if (userText5) {
self.data.inttui = userText5
self.setData(self.data)
}
if (userText6) {
self.data.inttun = userText6
self.setData(self.data)
}
},
outsshen(e){
const self = this
const value = e.detail.value
if (value) {
wx.setStorageSync('userText1', value)
console.log(value)
} // 监听用户输入的信息一旦有内容输入进去就会使用wx.setStorageSync('userText', value)设置usertext这个key的值使用wx.getStorageSync('userText')可以得到usertext这个key的值
},
outtti(e){
const self = this
const value = e.detail.value
if (value) {
wx.setStorageSync('userText2', value)
}
console.log(value)
},
outyyao(e){
const self = this
const value = e.detail.value
if (value) {
wx.setStorageSync('userText3', value)
}
console.log(value)
},
outxxiong(e){
const self = this
const value = e.detail.value
if (value) {
wx.setStorageSync('userText4', value)
}
console.log(value)
},
outttui(e){
const self = this
const value = e.detail.value
if (value) {
wx.setStorageSync('userText5', value)
}
console.log(value)
},
outttun(e){
const self = this
const value = e.detail.value
if (value) {
wx.setStorageSync('userText6', value)
}
console.log(value)
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})