|
|
@@ -1,20 +1,101 @@
|
|
|
import {
|
|
|
imgServerUrl
|
|
|
} from '../../config/config.js'
|
|
|
+import $wuxCountDown from '../../utils/coutdown.js'
|
|
|
+import {
|
|
|
+ sendPhoneCode,
|
|
|
+ saveMinaPhone
|
|
|
+} from '../../services/index.js'
|
|
|
+import {
|
|
|
+ showToast
|
|
|
+} from '../../utils/tips.js'
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
- imgServerUrl: imgServerUrl
|
|
|
+ imgServerUrl: imgServerUrl,
|
|
|
+ iphone: '',
|
|
|
+ yzm: "",
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
- onLoad: function (options) {
|
|
|
+ onLoad: function(options) {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ // 手机号输入
|
|
|
+ bindPhoneInput(e) {
|
|
|
+ this.setData({
|
|
|
+ iphone: e.detail.value
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 验证码号输入
|
|
|
+ bindYzmInput(e) {
|
|
|
+ this.setData({
|
|
|
+ yzm: e.detail.value
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ // 验证码发送
|
|
|
+ sendCode(e) {
|
|
|
+ if (this.data.iphone.length != 11) {
|
|
|
+ showToast('请输入11位手机号码!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.data.djs && this.data.djs != '获取验证码') {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ sendPhoneCode({
|
|
|
+ phone: this.data.iphone
|
|
|
+ }).then(data => {
|
|
|
+
|
|
|
+ })
|
|
|
+ this.vcode()
|
|
|
+ },
|
|
|
+ //倒计时
|
|
|
+ vcode() {
|
|
|
+ if (this.djs && this.djs.interval) return !1
|
|
|
+ this.djs = new $wuxCountDown({
|
|
|
+ date: +(new Date) + 60000,
|
|
|
+ onEnd() {
|
|
|
+ this.setData({
|
|
|
+ djs: '获取验证码',
|
|
|
+ })
|
|
|
+ },
|
|
|
+ render(date) {
|
|
|
+ const sec = this.leadingZeros(date.sec, 2) + ' 秒 '
|
|
|
+ date.sec !== 0 && this.setData({
|
|
|
+ djs: '剩余' + sec + '',
|
|
|
+ })
|
|
|
+ },
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //绑定手机号
|
|
|
+ phone_login() {
|
|
|
+ if (this.data.phone.length != 11) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (this.data.ymz.length != 6) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ var openId = wx.getStorageSync('openId');
|
|
|
+ var sessionKey = wx.getStorageSync('sessionKey');
|
|
|
+ var unionId = wx.getStorageSync('unionId');
|
|
|
+ let paramsObj = {
|
|
|
+ phone: this.data.phone,
|
|
|
+ code: this.data.ymz,
|
|
|
+ openId: openId,
|
|
|
+ unionId: unionId,
|
|
|
+ sessionKey: sessionKey
|
|
|
+ }
|
|
|
+ Object.assign(paramsObj);
|
|
|
+ saveMinaPhone(paramsObj).then(data => {
|
|
|
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
})
|