123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- // pages/retrieve_password/index.js
- import { phoneRegisterReset, registerVerify } from '../../api/api.js';
- let app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- cloneIner: null,
- loading: false,
- errorSum: 0,
- errorNum: 3,
- disabled: false,
- active: false,
- timetext: '获取验证码',
- userInfo: {},
- phone: '', //手机号
- parameter: {
- 'navbar': '1',
- 'return': '1',
- 'title': '登录',
- 'color': true,
- 'class': '6'
- },
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- },
- getPhoneValue: function (e) {
- this.setData({
- phone: e.detail.value
- })
- },
- /**
- * 发送验证码
- *
- */
- code: function () {
- let that = this;
- if (!that.data.phone) return app.Tips({ title: '请先输入手机号' });
- var type = 'reset';
- registerVerify(that.data.phone, type).then(res => {
- return app.Tips({ title: '发送成功' }, function () {
- that.setData({ disabled: true, active: true });
- let n = 60;
- let run = setInterval(function () {
- n--;
- if (n < 0) {
- clearInterval(run);
- that.setData({ disabled: false, active: false, timetext: '重新获取' })
- } else {
- that.setData({ timetext: "剩余 " + n + "s" })
- }
- }, 1000);
- });
- }).catch(err => {
- return app.Tips({ title: err });
- });
- },
- close() {
- let pages = getCurrentPages();
- let currPage = pages[pages.length - 1];
- if (this.data.isGoIndex) {
- wx.switchTab({ url: '/pages/index/index' });
- this.setData({
- ihidden: true
- });
- } else {
- this.setData({
- iShidden: true,
- ihidden: true
- });
- if (currPage && currPage.data.iShidden != undefined) {
- currPage.setData({ iShidden: true, ihidden: true });
- }
- }
- },
- loginSubmit: function (e) {
- var that = this, data = {};
- var datainfo = e.detail.value;
- phoneRegisterReset(datainfo).then(res => {
- wx.setStorageSync('userid', res.data.id);
- var userid = wx.getStorageSync('userid');
- that.setData({
- ihidden: false
- })
- return app.Tips({ title: '修改成功', icon: 'success' }, function(){
- wx.navigateBack({ delta: 1 });
- });
- console.log(userid);
- }).catch(err => {
- return app.Tips({ title: err });
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|