activate_customer_password
生成 激活账号 表单,必填字段 password。激活账号需要token,从激活邮件中点击跳转会在url上携带token参数。
表单输入
| 输入项 | 输入类型 | 字段名 | 是否必填 | 备注 |
|---|---|---|---|---|
| 密码 | password | customer[password] | 必填 | |
| 邮箱订阅 | checkbox | customer[acceptsEmailMarketing] | 选填 |
例子
{{#form 'activate_customer_password' id="customer-activate-form"}}
<div class="password">
<label for="customer[password]">用户密码</label>
<input type="password" name="customer[password]" placeholder="用户密码" />
</div>
<div class="accepts-marketing">
<input type="checkbox" name="customer[acceptsEmailMarketing]" value="true">
<label for="accepts-marketing">Subscribe to email marketing</label>
</div>
<div class="submit">
<input class="submit-button" type="submit" value="提交">
</div>
{{/form}}
配合使用
以上代码需要结合下面的脚本一起使用
class Activate {
constructor() {
this.form = document.querySelector('#customer-activate-form');
this.form.addEventListener('submit', this.onSubmitHandler.bind(this));
this.activate = new window.Shopline.customerAccount.Activate(this.form)
}
onSubmitHandler(e) {
e.preventDefault();
this.activate.submit()
.then(response => {
window.location.href = '/user/signIn';
})
.catch(error => {
// 处理注册失败异常场景
console.log(error)
})
}
}
// 初始化 JS SDK
window.Shopline.loadFeatures(
[
{
name: 'customer-account-api',
version: '0.3'
}
],
function(error) {
if (error) {
throw error;
}
new Activate();
}
);
这篇文章对你有帮助吗?
SHOPLINE