Files
youlegames/codes/agent/game/dlweb/api/web2/components/common_mixin.js
2026-03-15 01:27:05 +08:00

108 lines
2.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 组件公共部分
*/
var commonMixin = {
data: function () {
return {
params: {},
wxInfo: {},
userInfo: {},
tel: '',
captcha: '',
btnMsg: '发送验证码',
verity: 0
}
},
methods: {
/**
* 使用手机号代替微信的openid、unionid自动生成用户信息
* @param func
*/
phoneToWechat: function (func) {
var that = this;
$.api
(
'agent.user.login',
{
agentid: that.params.agentid,
channelid: that.params.channelid,
openid: that.tel,
unionid: that.tel,
nickname: ( that.wxInfo.nickname ? that.wxInfo.nickname : '代理'+$.randomString(4, '0123456789')),
avatar: (that.wxInfo.headimgurl ? that.wxInfo.headimgurl : 'https://dlwebv3.tscce.cn/images/noavatar.png'),
sex: (that.wxInfo.sex ? that.wxInfo.sex : 0),
province: (that.wxInfo.province ? that.wxInfo.province : ''),
islog: 0
},
function (res) {
that.userInfo = res;
func && func(res);
}, true
);
},
/**
* 绑定手机号
*/
bindPhone: function (func) {
var param = {
agentid: this.params.agentid,
channelid: this.params.channelid,
salesid: this.userInfo.salesid,
phone: this.tel,
msgcode: this.captcha
};
$.api(
"sms.sms.bindPhone",
param,
function (res) {
func && func();
}.bind(this), true
);
},
/**
* 发送手机验证码
*/
getCheckCode: function (r) {
var that = this;
$.api(
"sms.sms.sendBindCode",
{
agentid: this.params.agentid,
channelid: this.params.channelid,
salesid: '',
isbind: 0,
phone: this.tel
},
function (res) {
if(res.code)
that.verity = res.code;
that.disabled = true;
that.timeout(60);
}.bind(this), true
);
},
/**
* 发送验证码后的倒计时
* @param time 倒计时的时间(单位:秒)
*/
timeout: function (time) {
time--;
if(time > 0) {
this.btnMsg=time;
var that = this;
setTimeout(function () {
that.timeout(time);
}, 1000);
} else {
this.btnMsg='发送验证码';
this.disabled = false;
}
},
}
};