diff --git a/mall4m/pages/binding-phone/binding-phone.js b/mall4m/pages/binding-phone/binding-phone.js index 17af6b9..2e78a50 100644 --- a/mall4m/pages/binding-phone/binding-phone.js +++ b/mall4m/pages/binding-phone/binding-phone.js @@ -2,7 +2,7 @@ var http = require("../../utils/http.js"); var config = require("../../utils/config.js"); - +var constant = require("../../utils/constant.js"); Page({ /** @@ -70,7 +70,7 @@ Page({ }, getCodeNumber:function(){ - if (this.data.phoneNumber == "" ) { + if (!this.data.phonenum) { wx.showToast({ title: '请输入手机号', icon: "none" @@ -83,13 +83,9 @@ Page({ data: { // phonenum: this.data.phonenum, // code: this.data.code + mobile: this.data.phonenum }, - callBack: (res) => { - this.setData({ - phonenum: this.data.phonenum, - code: this.data.code - }); - } + callBack: (res) => {} }; http.request(params); }, @@ -102,5 +98,27 @@ Page({ this.setData({ code: e.detail.value }); + }, + /** + * 绑定 + */ + bindMobile() { + var params = { + url: '/user/registerOrBindUser', + method: 'PUT', + data: { + appType: AppType.MP, + mobile: this.data.phonenum, + validCode: this.data.code, + validateType: 1, // 验证类型:1验证码验证 , + registerOrBind: 2 // 验证类型 1注册 2绑定 + }, + callBack: res => { + uni.navigateTo({ + url: '/pages/index/index' + }); + }, + } + http.request(params) } -}) \ No newline at end of file +}) diff --git a/mall4m/pages/binding-phone/binding-phone.wxml b/mall4m/pages/binding-phone/binding-phone.wxml index 6d5b097..d7d08a7 100644 --- a/mall4m/pages/binding-phone/binding-phone.wxml +++ b/mall4m/pages/binding-phone/binding-phone.wxml @@ -15,7 +15,7 @@ - 确定 - 确定 + 确定 + 确定 diff --git a/mall4m/utils/constant.js b/mall4m/utils/constant.js new file mode 100644 index 0000000..b77634b --- /dev/null +++ b/mall4m/utils/constant.js @@ -0,0 +1,28 @@ +const PayType = { + SCOREPAY: 0, // 积分支付 + WECHATPAY: 1, // 小程序支付 + ALIPAY: 2,// 支付宝支付 + WECHATPAY_SWEEP_CODE: 3,//微信扫码支付 + WECHATPAY_H5: 4, //微信H5支付 + WECHATPAY_MP: 5, //微信公众号支付 + ALIPAY_H5: 6, //支付宝H5支付 + ALIPAY_APP: 7, // 支付宝APP支付 + WECHATPAY_APP: 8, // 微信APP支付 + BALANCEPAY: 9 // 余额支付 +} + +const AppType = { + MINI: 1, // 小程序 + MP: 2,// 微信公众号 + PC: 3,//pc + H5: 4, //h5 + ANDROID: 5, //安卓 + IOS: 6, //苹果 + ALI: 7, //支付宝H5 + ALIMINI: 8, //支付宝小程序 +} + +module.exports = { + PayType, + AppType +}; diff --git a/mall4uni/pages/binding-phone/binding-phone.vue b/mall4uni/pages/binding-phone/binding-phone.vue index 4b1fdd0..21fff88 100644 --- a/mall4uni/pages/binding-phone/binding-phone.vue +++ b/mall4uni/pages/binding-phone/binding-phone.vue @@ -10,14 +10,15 @@ 验证码: - 获取验证码 + 获取验证码 + {{count}} s - 确定 - 确定 + 确定 + 确定 @@ -26,12 +27,17 @@ // pages/binding-phone/binding-phone.js var http = require("../../utils/http.js"); var config = require("../../utils/config.js"); - +import { + AppType +} from "../../utils/constant.js"; export default { data() { return { phonenum: '', - code: '' + code: '', + show: true, + count: '', + timer: null }; }, @@ -79,38 +85,74 @@ export default { onShareAppMessage: function () {}, methods: { getCodeNumber: function () { - if (this.phoneNumber == "") { + if (!this.phonenum) { uni.showToast({ title: '请输入手机号', icon: "none" }); return; } - var params = { url: "/p/sms/send", method: "POST", data: {// phonenum: this.data.phonenum, // code: this.data.code + mobile: this.phonenum }, callBack: res => { - this.setData({ - phonenum: this.phonenum, - code: this.code - }); + const timeCount = 60; + if (!this.timer) { + this.count = timeCount + this.show = false; + this.timer = setInterval(() => { + if (this.count > 0 && this.count <= timeCount) { + this.count--; + } else { + clearInterval(this.timer); + this.timer = null, + this.show = true + } + }, 1000) + } } }; http.request(params); }, onPhoneInput: function (e) { + console.log('e.detail.value:', e.detail.value) this.setData({ phonenum: e.detail.value }); + console.log('phonenum:', this.phonenum) }, onCodeInput: function (e) { this.setData({ code: e.detail.value }); + }, + + /** + * 绑定 + */ + bindMobile() { + var params = { + url: '/user/registerOrBindUser', + method: 'PUT', + data: { + appType: AppType.MP, + mobile: this.phonenum, + validCode: this.code, + validateType: 1, // 验证类型:1验证码验证 , + registerOrBind: 2 // 验证类型 1注册 2绑定 + }, + callBack: res => { + http.loginSuccess(res) + uni.navigateTo({ + url: '/pages/index/index' + }); + }, + } + http.request(params) } } };