微信小程序以ssm做后台开发的实现示例(2)

Page({ data: { industryarr: [], industryindex: 0, statusarr: [], statusindex: 0, jobarr: [], jobindex: 0, }, onLoad: function () { this.fetchData() }, fetchData: function () { this.setData({ industryarr: ["请选择","男", "女"], statusarr: ["是否注册vip会员","是", "否"], }) }, // bindPickerChange1: function (e){ // var sex = e.detail.value; // console.log(sex) // if(sex==1){ // var app=getApp() // app.sex='男' // }else{ // var app = getApp() // app.sex = '女' // } // }, // bindPickerChange2: function (e) { // var vip = e.detail.value; // console.log(vip) // if(vip==1){ // var app=getApp() // app.vip='是' // }else{ // var app = getApp() // app.vip = '否' // } // }, bindPickerChange: function (e) { //下拉选择 const eindex = e.detail.value; //onsole.log(industryarr[e.detail.value]) const name = e.currentTarget.dataset.pickername; console.log(name) // this.setData(Object.assign({},this.data,{name:eindex})) switch (name) { case 'industry': var app=getApp() app.sex = this.data.industryarr[eindex] console.log(app.sex) this.setData({ industryindex: eindex }) case 'status': var app = getApp() app.vip = this.data.statusarr[eindex] console.log(app.vip) this.setData({ statusindex: eindex }) break; case 'job': this.setData({ jobindex: eindex }) break; default: return } }, formSubmit(e) { var name = e.detail.value.name; var tel = e.detail.value.tel; var email = e.detail.value.email; var userpassword = e.detail.value.password; console.log('form发生了submit事件,携带数据为:', name, tel, email) wx.login({ success: function (res) { var code1 = res.code var app = getApp() var appid1 = app.globalData.appid var secret1 = app.globalData.secret console.log('获取的code', code1, appid1, secret1) var ul = 'https://api.weixin.qq.com/sns/jscode2session?appid=' + appid1 + '&secret=' + secret1 + '&js_code=' + code1 + '&grant_type=authorization_code' wx.request({ url: ul, method: 'GET', success: function (e) { var openid = e.data.openid console.log('获取登录身份的唯一openid', openid) // wx.setStorageSync('openid', openid) //wx.setStorageSync('name', name) wx.request({ url: 'http://localhost:8080/lg/wechat/add', data: { openid: openid, userpassword: userpassword, name: name, sex: app.sex, tel: tel, email: email, vip: app.vip, }, //method:'POST', success: function (res) { const mess=res.data if (res.data){ console.log("fhgdshxcbxcbxcbcxbxcbxcfj") wx.showToast({ title: '注册成功', icon:'success', }) }else{ wx.showModal({ title: '温馨提示', content: '您已注册过,请不要重复注册', success: function (res) { if (res.confirm) { wx.navigateTo({ url: '../../pages/login/login', }) } else if (res.cancel) { wx.navigateTo({ url: '../../pages/hotel/hotel' }) } } }) } } }) } }) } }) }, })

4、ssm的后端实现

因为小程序的数据格式都是json格式,所以我们的ssm后台也必须是就json的格式,Java要实现json的格式,需要对应的jar包,打下自行下载。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/144b2c0656af8ce5e3cd5f9f56f62001.html