new Vue({
|
el: '#app', // 选择器
|
data: {
|
show: 0,
|
count: '',
|
timer: null,
|
agreeType: true, //
|
tel: "", //手机号
|
verification: '', //验证码
|
showType: false,
|
invitationInfo: "",
|
privacyAgreement:"",
|
userAgreement:"",
|
appName: "",
|
appLogo:"",
|
beian:"",
|
iosUrl:"",
|
androidUrl:"",
|
tips: "恭喜你,注册成功~",
|
tips2: "欢迎您加入,赶紧下载APP,领取您的新人免单专属福利吧~",
|
goodslist: [
|
{"image": "https://img.alicdn.com/i3/880734502/O1CN01eDKk7i1j7xhJ5c7jV_!!880734502.jpg_310x310.jpg_.webp",
|
"title": "手撕面包2斤"
|
},
|
{"image": "https://img.alicdn.com/imgextra/i2/2201188731272/O1CN01sR96eg1LGcSFr2aTK_!!2201188731272.jpg_310x310.jpg_.webp",
|
"title": "Unifree洗脸巾"
|
},
|
{"image": "https://img.alicdn.com/imgextra/i4/2479240580/O1CN01g1cwOs1G9gTFkXFGZ_!!2479240580.png_310x310.jpg_.webp",
|
"title": "手持小风扇"
|
},
|
{"image": "https://img.alicdn.com/i4/2203738468138/O1CN01glAoIC29zFvNJAGhW_!!2203738468138.jpg_310x310.jpg_.webp",
|
"title": "牛油果沐浴露"
|
},
|
{"image": "https://img.alicdn.com/imgextra/i4/438927567/O1CN01vaRzJN25ljmb0wxZR_!!438927567.jpg_310x310.jpg_.webp",
|
"title": "无糖薄荷糖"
|
},
|
{"image": "https://img.alicdn.com/imgextra/i1/503512336/O1CN01wTeXWv1T7vxTSWEr2_!!503512336.jpg_310x310.jpg_.webp",
|
"title": "高蛋白鸡胸肉"
|
},
|
{"image": "https://img.alicdn.com/imgextra/i4/441512085/O1CN017tZRxE1RGyY2vgJF2_!!441512085.jpg_310x310.jpg_.webp",
|
"title": "4只鲜肉粽子"
|
},
|
{"image": "https://img.alicdn.com/imgextra/i1/1952819637/O1CN01rQrJu32L3nddEPV0l_!!1952819637.jpg_310x310.jpg_.webp",
|
"title": "加厚无芯卷纸"
|
},
|
{"image": "https://img.alicdn.com/i1/54801414/O1CN01jaEMbE1MJemh7RYJK_!!54801414.jpg_310x310.jpg_.webp",
|
"title": "大樱桃车厘子"
|
}],
|
},
|
created() {
|
this.getInvitationInfo();
|
this. judgeWeb();
|
this.goDownload();
|
},
|
mounted() {
|
|
// 访问vm1 data的数据
|
},
|
methods: {
|
getcode() {
|
const times = 60; // 倒计时时间
|
if (!this.timer) {
|
this.count = times;
|
this.show = 1;
|
this.timer = setInterval(() => {
|
if (this.count > 0 && this.count <= times) {
|
this.count--;
|
} else {
|
this.show = 2;
|
clearInterval(this.timer);
|
this.timer = null;
|
}
|
}, 1000)
|
}
|
},
|
//立即下载
|
download() {
|
this.showType = true;
|
},
|
//注册即同意
|
agreeCen() {
|
this.agreeType = !this.agreeType
|
},
|
//复制
|
handleClipboard() {
|
var _this = this;
|
var clipboardImg = new Clipboard('.yqm', {
|
text: function() {
|
return _this.invitationInfo.invitation_code;
|
},
|
});
|
clipboardImg.on('success', function(e) {
|
alert("邀请码复制成功,赶快下载APP,尽享优惠吧~")
|
});
|
|
clipboardImg.on('error', function(e) {
|
alert("邀请码复制失败,您可直接至APP中注册后填写此邀请码")
|
});
|
},
|
getInvitationInfo() {
|
var code = vmRequest("code");
|
//alert(code);
|
//以param属性的形式来传递参数
|
axios({
|
method: "post", //请求方式
|
url: "/index/user/getInvitationInfo", //请求路径
|
params: {
|
"code": code
|
} //传递参数
|
//使用 箭头表达式=> 在代替原有的function来做回调函数
|
}).then(result => {
|
if (result.data.code == 1) {
|
alert(result.data.msg);
|
} else {
|
this.invitationInfo = result.data.info.user;
|
this.appName = result.data.info.appName;
|
this.privacyAgreement = result.data.info.privacyAgreement;
|
this.userAgreement = result.data.info.userAgreement;
|
this.appLogo = result.data.info.logo;
|
this.beian = result.data.info.beian;
|
this.iosUrl = result.data.info.appIosDownUrl;
|
this.androidUrl = result.data.info.appAndroidDownUrl;
|
}
|
})
|
|
},
|
phoneIsRegister() {
|
if (!this.tel) {
|
alert("手机号不能为空")
|
return false;
|
}
|
axios({
|
method: "post", //请求方式
|
url: "/index/user/phoneIsRegister", //请求路径
|
params: {
|
"phone": this.tel
|
} //传递参数
|
//使用 箭头表达式=> 在代替原有的function来做回调函数
|
}).then(result => {
|
if (result.data.code == 1) {
|
alert(result.data.msg);
|
} else {
|
// 号码未注册 发送验证码请求
|
// 号码已经注册
|
console.log(result.data)
|
if(result.data.is_registered == 1){
|
this.tips = "您的帐号已经注册";
|
this.tips2 = "欢迎您加入"+this.appName+",赶紧下载APP,赚取佣金吧~";
|
this.showType = true;
|
this.show = 1 //结束验证码
|
//alert(result.data.message);
|
}else{
|
this.sendCode();
|
}
|
|
|
}
|
})
|
|
},
|
|
// 发送验证码
|
sendCode() {
|
console.log("发送验证码")
|
var timerChuo = new Date().getTime()
|
// 拼凑数据
|
var sendInfo = {
|
event: 'register',
|
mobile: this.tel,
|
};
|
axios({
|
method: "post", //请求方式
|
url: "/api/sms/send", //请求路径
|
data: sendInfo
|
// headers: {
|
// 'Content-Type': 'application/json;charset=UTF-8'
|
// },
|
//传递参数
|
//使用 箭头表达式=> 在代替原有的function来做回调函数
|
}).then(result => {
|
if (result.data.code == 1) {
|
// 号码已经注册
|
alert( result.data.msg);
|
} else {
|
// 号码未注册 发送验证码请求
|
//alert("验证码发送成功" + result.data.message);
|
this.getcode();
|
}
|
})
|
},
|
goDownload() {
|
// 判断是IOS还是安卓? 跳转对应下载页面
|
/* var u = navigator.userAgent;
|
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
|
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
|
if (isiOS) {
|
//window.location = this.iosUrl;
|
window.location="https://apps.apple.com/cn/app/id6449449829"
|
} else if (isAndroid) {
|
window.location = this.androidUrl;
|
} */
|
var agen=this.verifyBrand();
|
var marketUrl=this.androidUrl;
|
switch(agen)
|
{
|
case'iphone':
|
marketUrl="https://apps.apple.com/cn/app/id6449449829";
|
break;
|
case'xiaomi':
|
marketUrl="mimarket://details?id=com.dafanguan.app";
|
break;
|
case'huawei':
|
marketUrl="appmarket://details?id=com.dafanguan.app";
|
break;
|
case'oppo':
|
marketUrl="oppomarket://details?packagename=com.dafanguan.app";
|
break;
|
case'vivo':
|
marketUrl="vivomarket://details?id=com.dafanguan.app";
|
break;
|
default:
|
marketUrl = this.androidUrl;
|
}
|
window.location = marketUrl;
|
},
|
verifyBrand()
|
{//判断机子类型
|
const userAgent = navigator.userAgent.toLowerCase()
|
const isIphone = userAgent.match(/(iphone|ipad|ipod)/i);
|
const isHuawei = userAgent.match(/huawei/i);
|
const isHonor = userAgent.match(/honor/i);
|
const isOppo = userAgent.match(/oppo/i);
|
const isOppoR15 = userAgent.match(/PACM00/i);
|
const isVivo = userAgent.match(/vivo/i);
|
const isXiaomi = userAgent.match(/mi\s/i);
|
const isXIAOMI = userAgent.match(/xiaomi/i);
|
const isXiaomi2s = userAgent.match(/mix\s/i);
|
const isRedmi = userAgent.match(/redmi/i);
|
|
if (isIphone) {
|
return 'iphone'
|
} else if (isHuawei || isHonor) {
|
return 'huawei';
|
} else if (isOppo || isOppoR15) {
|
return 'oppo';
|
} else if (isVivo) {
|
return 'vivo';
|
} else if (isXiaomi || isRedmi || isXiaomi2s || isXIAOMI) {
|
return 'xiaomi';
|
} else {
|
return 'other';
|
}
|
},
|
judgeWeb()
|
{
|
var webName=this.isNeizhi();
|
if(webName=='weixin')
|
{
|
alert("请点击右上角,选择'在浏览器打开'~");
|
}
|
else if(webName=='QQ')
|
{
|
alert("请点击右上角,选择'浏览器',打开本网址~");
|
}
|
},
|
isNeizhi()
|
{//判断是否内置浏览器
|
var ua = navigator.userAgent.toLowerCase();
|
// var browserName = "unknow";
|
if (ua.match(/MicroMessenger/i) == "micromessenger") {
|
return "weixin";
|
} else if (ua.match(/QQ/i) == "qq") {
|
return "QQ";
|
} else if (ua.match(/Alipay/i) == "alipay" && payway == 2) {
|
return "alipay";
|
}
|
},
|
/* 用户注册 */
|
userRegist() {
|
if (!this.tel) {
|
alert("手机号不能为空")
|
return false;
|
}
|
if (!this.verification) {
|
alert("验证码不能为空")
|
return false;
|
}
|
if (this.agreeType) {
|
alert("请先阅读并同意《"+this.appName+"用户协议》《隐私政策》")
|
return false;
|
}
|
// 拼凑数据
|
var sendInfo = {
|
mobile: this.tel,
|
captcha: this.verification,
|
invitation_code: this.invitationInfo.invitation_code
|
};
|
axios({
|
method: "post", //请求方式
|
url: "/api/user/register", //请求路径
|
data: sendInfo,
|
headers: {
|
'Content-Type': 'application/json;charset=UTF-8'
|
},
|
//传递参数
|
//使用 箭头表达式=> 在代替原有的function来做回调函数
|
}).then(result => {
|
if (result.data.code == 0) {
|
// 注册成功
|
this.tips2 = "欢迎您加入"+this.appName+",赶紧下载APP,赚取佣金吧~";
|
this.showType = true;
|
} else {
|
//失败
|
alert("注册失败" + result.data.message);
|
|
}
|
})
|
|
},
|
}
|
|
})
|