captain-ui
Version:
有赞vue wap业务组件库
128 lines (116 loc) • 3.28 kB
JavaScript
import "vant/es/dialog/style";
import _Dialog from "vant/es/dialog";
import _extends from "@babel/runtime/helpers/esm/extends";
import "vant/es/toast/style";
import _Toast from "vant/es/toast";
import ajax from '../utils/ajax';
import PageMixin from '../mixins/page-mixin';
export default {
render: function render() {
var _vm = this;
var _h = _vm.$createElement;
var _c = _vm._self._c || _h;
return _c('div', {
staticClass: "cap-login__form cap-login__register-phone"
}, [_c('van-cell-group', [_vm.showCountrySelect ? _c('vm-form-item', {
attrs: {
"title": "国家",
"is-link": ""
},
on: {
"click": _vm.doSelectCountry
}
}, [_vm._v("\n " + _vm._s(_vm.country.name) + " " + _vm._s(_vm.country.code) + "\n ")]) : _vm._e(), _c('vm-form-item', {
attrs: {
"title": "手机号"
}
}, [_c('vm-input', {
attrs: {
"type": "tel",
"placeholder": "请输入手机号"
},
model: {
value: _vm.loginData.phone,
callback: function callback($$v) {
_vm.$set(_vm.loginData, "phone", $$v);
},
expression: "loginData.phone"
}
})], 1)], 1), _c('p', {
staticClass: "cap-login__tip"
}, [_vm._v("手机号即为登录帐号,我们将发送验证码到该号码")]), _c('vm-actions', [_c('template', {
slot: "button"
}, [_c('van-button', {
attrs: {
"type": "danger",
"block": ""
},
on: {
"click": _vm.handleSubmit
}
}, [_vm._v("\n 下一步\n ")])], 1), _c('template', {
slot: "tips"
}, [_c('span', {
staticClass: "cap-login--pull-right",
on: {
"click": _vm.goLogin
}
}, [_vm._v("\n 去登录\n ")])])], 2)], 1);
},
mixins: [PageMixin],
props: {
autoConfirmUrl: String,
source: String
},
data: function data() {
return {
loginData: {
phone: this.phone || ''
}
};
},
methods: {
handleSubmit: function handleSubmit() {
var _this2 = this;
var source = this.source;
var phoneReg = /^\d{1,20}$/;
var loginData = this.loginData;
var phone = loginData.phone;
if (!phone) {
_Toast('请输入手机号');
return;
}
if (!phoneReg.test(phone)) {
_Toast('手机号格式不正确');
return;
}
var _this = this;
ajax({
url: this.autoConfirmUrl,
method: 'POST',
data: _extends({}, this.loginData, {
country_code: this.country && this.country.code,
source: source
})
}).then(function (res) {
_Dialog.confirm({
message: '该手机号码已注册过有赞帐号',
confirmButtonText: '立即登录'
}).then(function (action) {
if (action === 'confirm') {
_this.goLogin();
}
}).catch(function () {});
}, function (res) {
if (+res.code === 135000003) {
_this2.$emit('typeChange', 'register');
return;
}
_Toast(res.msg || '网络错误');
});
},
goLogin: function goLogin() {
this.$emit('typeChange', 'login');
}
}
};