Browse Source

新增退出登录接口,注册加密码字段

shibei
mk 1 year ago
parent
commit
cf3615b3c9
  1. 15
      miniprogram/pages/formid/formid.js
  2. 18
      miniprogram/pages/formid/formid.wxml
  3. 126
      miniprogram/pages/home/home.js
  4. 12
      miniprogram/pages/login/login.js
  5. 36
      miniprogram/pages/my/my.js
  6. 2
      miniprogram/project.private.config.json
  7. 4
      miniprogram/utils/api.js

15
miniprogram/pages/formid/formid.js

@ -568,6 +568,10 @@ Page({
this.showToast('请输入姓名')
return false
}
if(this.data.form.password != this.data.checkPassword){
this.showToast('两次密码不一致')
return false
}
if (!this.data.form.identityNo) {
this.showToast('请填写身份证号')
return false
@ -676,6 +680,17 @@ Page({
visible: false
})
},
bindPassWordInput(e){
this.setData({
'form.password':e.detail.value
})
console.log(this.data.form);
},
bindCheckPassWordInput(e){
this.setData({
checkPassword:e.detail.value
})
},
dispose() {
if (!this.data.form.realName) {
this.showToast('请输入姓名')

18
miniprogram/pages/formid/formid.wxml

@ -27,6 +27,24 @@
<input confirm-type="next" bindblur="bindRealMobileInput" bindinput="bindRealMobileInput" value="{{form.mobile}}" placeholder-class="placeholder-style" placeholder="请输入" />
</view>
</view>
<view class="list-item ">
<view class="left">
<text class="must">*</text>
<view class="title">密码</view>
</view>
<view class="right">
<input confirm-type="next" password bindblur="bindPassWordInput" bindinput="bindPassWordInput" value="{{form.password}}" placeholder-class="placeholder-style" placeholder="请输入" />
</view>
</view>
<view class="list-item ">
<view class="left">
<text class="must">*</text>
<view class="title">确认密码</view>
</view>
<view class="right">
<input confirm-type="next" password bindblur="bindCheckPassWordInput" bindinput="bindCheckPassWordInput" value="{{checkPassword}}" placeholder-class="placeholder-style" placeholder="请输入" />
</view>
</view>
<view class="list-item gray">
<view class="left">
<text class="must">*</text>

126
miniprogram/pages/home/home.js

@ -44,10 +44,10 @@ Page({
},
async onLoad(options) {
wx.showLoading({
title: "加载中,请稍后",
mask: true
})
// wx.showLoading({
// title: "加载中,请稍后",
// mask: true
// })
this.setData({
statusHeight: app.globalData.deviceInfo.statusHeight,
navigationHeight: app.globalData.deviceInfo.navigationHeight,
@ -82,65 +82,65 @@ Page({
},
// 根据微信code查询用户当前状态
getUserState() {
let that = this
wx.showLoading({
title: '登录中',
mask:true
})
wx.login({
success(res) {
if (res.code) {
let code = res.code
api.getToken(code).then(res => {
wx.hideLoading()
const state = res.data.userState
app.globalData.infoCompleted = state
wx.setStorageSync("topGridName", res.data.grid)
wx.setStorageSync("gridId", res.data.gridId) //当前网格id,新闻、议题、项目分享时用
wx.setStorageSync("token", res.data.token)
wx.setStorageSync("userId", res.data.userId)
that.setData({
departmentName: res.data.grid,
departmentId: res.data.gridId,
userId: res.data.userId
})
// that.getComplete()
// that.getUserLoginlog()
if (state == "4") {
// 非扫码进入,通过搜索小程序直接进入的情况
if (wx.getStorageSync("shareObj")) {
const para = JSON.parse(wx.getStorageSync("shareObj"))
app.globalData.tempGridId = "1222489495054602241"
wx.redirectTo({
url: "/pages/formid/formid?gid=1222489495054602241"
})
} else {
wx.redirectTo({
url: "/pages/formid/formid?gid=1222489495054602241"
})
}
} else {
if (wx.getStorageSync("shareObj")) {
const para = JSON.parse(wx.getStorageSync("shareObj"))
if (para.shareType === "newsDetail") {
wx.navigateTo({
url: `/subpages/home/pages/newsDetail/newsDetail?id=${para.detailId}`
})
} else if (para.shareType === "discussionDetail") {
wx.navigateTo({
url: `/subpages/discussion/pages/discussionDetail/discussionDetail?detailId=${para.detailId}&type=${para.type}&showClassify=${para.showClassify}`
})
}
wx.removeStorageSync("shareObj")
}
that.initLoad()
}
})
} else {
console.log("登录失败" + res.errMsg)
}
}
})
// let that = this
// wx.showLoading({
// title: '登录中',
// mask:true
// })
// wx.login({
// success(res) {
// if (res.code) {
// let code = res.code
// api.getToken(code).then(res => {
// wx.hideLoading()
// const state = res.data.userState
// app.globalData.infoCompleted = state
// wx.setStorageSync("topGridName", res.data.grid)
// wx.setStorageSync("gridId", res.data.gridId) //当前网格id,新闻、议题、项目分享时用
// wx.setStorageSync("token", res.data.token)
// wx.setStorageSync("userId", res.data.userId)
// that.setData({
// departmentName: res.data.grid,
// departmentId: res.data.gridId,
// userId: res.data.userId
// })
// // that.getComplete()
// // that.getUserLoginlog()
// if (state == "4") {
// // 非扫码进入,通过搜索小程序直接进入的情况
// if (wx.getStorageSync("shareObj")) {
// const para = JSON.parse(wx.getStorageSync("shareObj"))
// app.globalData.tempGridId = "1222489495054602241"
// wx.redirectTo({
// url: "/pages/formid/formid?gid=1222489495054602241"
// })
// } else {
// wx.redirectTo({
// url: "/pages/formid/formid?gid=1222489495054602241"
// })
// }
// } else {
// if (wx.getStorageSync("shareObj")) {
// const para = JSON.parse(wx.getStorageSync("shareObj"))
// if (para.shareType === "newsDetail") {
// wx.navigateTo({
// url: `/subpages/home/pages/newsDetail/newsDetail?id=${para.detailId}`
// })
// } else if (para.shareType === "discussionDetail") {
// wx.navigateTo({
// url: `/subpages/discussion/pages/discussionDetail/discussionDetail?detailId=${para.detailId}&type=${para.type}&showClassify=${para.showClassify}`
// })
// }
// wx.removeStorageSync("shareObj")
// }
// that.initLoad()
// }
// })
// } else {
// console.log("登录失败" + res.errMsg)
// }
// }
// })
},
handleXinxin() {
wx.navigateToMiniProgram({

12
miniprogram/pages/login/login.js

@ -7,8 +7,8 @@ Page({
* 页面的初始数据
*/
data: {
userName: '13000000001',
password: '123456'
userName: '',//13000000001
password: ''//123456
},
/**
@ -97,17 +97,16 @@ Page({
wxCode: code
};
api.userLogin(params).then( (res) =>{
console.log(res);
if (res.code == 0) {
wx.setStorageSync('token', res.data.token);
wx.setStorageSync('userTagKey', res.data.userTagKey);
// this.getToken()
wx.setStorageSync('deptDataScopeList', JSON.stringify(res.data.deptDataScopeList));
wx.redirectTo({
wx.switchTab({
url: '/pages/home/home'
});
}
else {
console.log(222);
wx.showToast({
title: res.msg,
icon: 'none',
@ -120,6 +119,9 @@ Page({
}
});
},
// getToken(){
// },
getUserName(e) {
this.setData({
userName: e.detail.value

36
miniprogram/pages/my/my.js

@ -112,28 +112,44 @@ Page({
})
},
logoout() {
let than = this
wx.showModal({
title: '提示',
content: '确定退出登录',
success(res) {
if (res.confirm) {
// wx.setStorageSync("token", res.data.token)
wx.showLoading({
title: "退出中,请稍后...",
mask: true,
success() {
setTimeout(() => {
than.logout()
// wx.showLoading({
// title: "退出中,请稍后...",
// mask: true,
// success() {
// setTimeout(() => {
// wx.removeStorage({
// key: 'token',
// })
// wx.reLaunch({
// url: '/pages/login/login'
// })
// }, 1000)
// }
// })
}
}
})
},
logout(){
api.logout().then(res=>{
if(res.code === 0){
wx.removeStorage({
key: 'token',
})
wx.reLaunch({
url: '/pages/login/login'
})
}, 1000)
}
})
}
}
}).catch(err=>{
console.log(err);
})
},
tapchangeImg() {

2
miniprogram/project.private.config.json

@ -186,7 +186,7 @@
]
}
},
"libVersion": "2.14.1",
"libVersion": "2.19.6",
"setting": {
"compileHotReLoad": true,
"bigPackageSizeSupport": false

4
miniprogram/utils/api.js

@ -1,6 +1,7 @@
var fly = require("./request.js")
module.exports = {
getToken: getToken,
logout:logout,
getCompleteName: getCompleteName,
saveWxFormid: saveWxFormid,
getScanSwitch: getScanSwitch,
@ -76,6 +77,9 @@ function bannerList(position) {
position
})
}
function logout() {
return fly.get("analysis/user/logout")
}
// function getIssueList(param) {
// return fly.get("events/issue/list", param)

Loading…
Cancel
Save