Browse Source

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

shibei
mk 1 year ago
parent
commit
cf3615b3c9
  1. 15
      miniprogram/pages/formid/formid.js
  2. 20
      miniprogram/pages/formid/formid.wxml
  3. 126
      miniprogram/pages/home/home.js
  4. 14
      miniprogram/pages/login/login.js
  5. 46
      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('请输入姓名') this.showToast('请输入姓名')
return false return false
} }
if(this.data.form.password != this.data.checkPassword){
this.showToast('两次密码不一致')
return false
}
if (!this.data.form.identityNo) { if (!this.data.form.identityNo) {
this.showToast('请填写身份证号') this.showToast('请填写身份证号')
return false return false
@ -676,6 +680,17 @@ Page({
visible: false 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() { dispose() {
if (!this.data.form.realName) { if (!this.data.form.realName) {
this.showToast('请输入姓名') this.showToast('请输入姓名')

20
miniprogram/pages/formid/formid.wxml

@ -9,7 +9,7 @@
<input confirm-type="next" bindblur="bindRealNameInput" bindinput="bindRealNameInput" value="{{form.realName}}" placeholder-class="placeholder-style" placeholder="请输入" /> <input confirm-type="next" bindblur="bindRealNameInput" bindinput="bindRealNameInput" value="{{form.realName}}" placeholder-class="placeholder-style" placeholder="请输入" />
</view> </view>
</view> </view>
<view class="list-item "> <view class="list-item ">
<view class="left"> <view class="left">
<text class="must">*</text> <text class="must">*</text>
<view class="title">身份证号</view> <view class="title">身份证号</view>
@ -27,6 +27,24 @@
<input confirm-type="next" bindblur="bindRealMobileInput" bindinput="bindRealMobileInput" value="{{form.mobile}}" placeholder-class="placeholder-style" placeholder="请输入" /> <input confirm-type="next" bindblur="bindRealMobileInput" bindinput="bindRealMobileInput" value="{{form.mobile}}" placeholder-class="placeholder-style" placeholder="请输入" />
</view> </view>
</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="list-item gray">
<view class="left"> <view class="left">
<text class="must">*</text> <text class="must">*</text>

126
miniprogram/pages/home/home.js

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

14
miniprogram/pages/login/login.js

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

46
miniprogram/pages/my/my.js

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

2
miniprogram/project.private.config.json

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

4
miniprogram/utils/api.js

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

Loading…
Cancel
Save