|
@@ -27,68 +27,68 @@
|
|
</el-dialog>
|
|
</el-dialog>
|
|
</template>
|
|
</template>
|
|
<script>
|
|
<script>
|
|
-import { reactive, ref, getCurrentInstance, watch } from "vue";
|
|
|
|
|
|
+import { reactive, ref, getCurrentInstance, watch } from 'vue'
|
|
// import { Phonepin, verifyCode, bindUserid } from "@/api/index.js";
|
|
// import { Phonepin, verifyCode, bindUserid } from "@/api/index.js";
|
|
-import { ElMessage } from "element-plus";
|
|
|
|
-import { useRouter } from "vue-router";
|
|
|
|
-import { useStore } from "vuex";
|
|
|
|
|
|
+import { ElMessage } from 'element-plus'
|
|
|
|
+import { useRouter } from 'vue-router'
|
|
|
|
+import { useStore } from 'vuex'
|
|
export default {
|
|
export default {
|
|
setup(props, content) {
|
|
setup(props, content) {
|
|
- let { proxy } = getCurrentInstance();
|
|
|
|
- let store = useStore();
|
|
|
|
- console.log(store.state.binDingstatus);
|
|
|
|
- let centerDialogVisible = ref(true);
|
|
|
|
|
|
+ let { proxy } = getCurrentInstance()
|
|
|
|
+ let store = useStore()
|
|
|
|
+ console.log(store.state.binDingstatus)
|
|
|
|
+ let centerDialogVisible = ref(true)
|
|
let phonenum = reactive({
|
|
let phonenum = reactive({
|
|
- phone: "",
|
|
|
|
- code: "",
|
|
|
|
- });
|
|
|
|
|
|
+ phone: '',
|
|
|
|
+ code: '',
|
|
|
|
+ })
|
|
//验证冷却
|
|
//验证冷却
|
|
let showCode = reactive({
|
|
let showCode = reactive({
|
|
status: true,
|
|
status: true,
|
|
- count: "",
|
|
|
|
|
|
+ count: '',
|
|
timer: null,
|
|
timer: null,
|
|
- });
|
|
|
|
|
|
+ })
|
|
var phoneData = {
|
|
var phoneData = {
|
|
to: phonenum.phone,
|
|
to: phonenum.phone,
|
|
- lang: "zh-cn",
|
|
|
|
|
|
+ lang: 'zh-cn',
|
|
HasUser: true,
|
|
HasUser: true,
|
|
- country: "86",
|
|
|
|
- };
|
|
|
|
- var { phoneCode } = pin(proxy);
|
|
|
|
|
|
+ country: '86',
|
|
|
|
+ }
|
|
|
|
+ var { phoneCode } = pin(proxy)
|
|
//路由
|
|
//路由
|
|
- const router = useRouter();
|
|
|
|
|
|
+ const router = useRouter()
|
|
//关闭弹窗
|
|
//关闭弹窗
|
|
function close() {
|
|
function close() {
|
|
- centerDialogVisible.value = false;
|
|
|
|
- store.commit("BindStatus", false);
|
|
|
|
|
|
+ centerDialogVisible.value = false
|
|
|
|
+ store.commit('BindStatus', false)
|
|
}
|
|
}
|
|
//监听状态值
|
|
//监听状态值
|
|
watch(
|
|
watch(
|
|
() => store.state.binDingstatus,
|
|
() => store.state.binDingstatus,
|
|
(a) => {
|
|
(a) => {
|
|
- store.state.binDingstatus = a;
|
|
|
|
- centerDialogVisible.value = a;
|
|
|
|
|
|
+ store.state.binDingstatus = a
|
|
|
|
+ centerDialogVisible.value = a
|
|
}
|
|
}
|
|
- );
|
|
|
|
|
|
+ )
|
|
//验证码冷却及发送验证码
|
|
//验证码冷却及发送验证码
|
|
function getCode() {
|
|
function getCode() {
|
|
//验证码冷却部分
|
|
//验证码冷却部分
|
|
- const TIME_COUNT = 60;
|
|
|
|
|
|
+ const TIME_COUNT = 60
|
|
if (!showCode.timer) {
|
|
if (!showCode.timer) {
|
|
- showCode.count = TIME_COUNT;
|
|
|
|
- showCode.status = false;
|
|
|
|
|
|
+ showCode.count = TIME_COUNT
|
|
|
|
+ showCode.status = false
|
|
showCode.timer = setInterval(() => {
|
|
showCode.timer = setInterval(() => {
|
|
if (showCode.count > 0 && showCode.count <= TIME_COUNT) {
|
|
if (showCode.count > 0 && showCode.count <= TIME_COUNT) {
|
|
- showCode.count--;
|
|
|
|
|
|
+ showCode.count--
|
|
} else {
|
|
} else {
|
|
- showCode.status = true;
|
|
|
|
- clearInterval(showCode.timer);
|
|
|
|
- showCode.timer = null;
|
|
|
|
|
|
+ showCode.status = true
|
|
|
|
+ clearInterval(showCode.timer)
|
|
|
|
+ showCode.timer = null
|
|
}
|
|
}
|
|
- }, 1000);
|
|
|
|
|
|
+ }, 1000)
|
|
}
|
|
}
|
|
//请求接口
|
|
//请求接口
|
|
- phoneCode(phoneData);
|
|
|
|
|
|
+ phoneCode(phoneData)
|
|
}
|
|
}
|
|
//手机号码绑定流程
|
|
//手机号码绑定流程
|
|
function bindUser(proxy) {
|
|
function bindUser(proxy) {
|
|
@@ -96,40 +96,39 @@ export default {
|
|
let codeNum = {
|
|
let codeNum = {
|
|
mobile: phonenum.phone,
|
|
mobile: phonenum.phone,
|
|
Authorization_Pin: phonenum.code,
|
|
Authorization_Pin: phonenum.code,
|
|
- };
|
|
|
|
- console.log(codeNum, "手机号和验证码");
|
|
|
|
|
|
+ }
|
|
|
|
+ console.log(codeNum, '手机号和验证码')
|
|
//验证手机号和验证码
|
|
//验证手机号和验证码
|
|
proxy.$api.verifyCode(codeNum).then((res) => {
|
|
proxy.$api.verifyCode(codeNum).then((res) => {
|
|
- console.log(res, "验证手机号和验证码");
|
|
|
|
|
|
+ console.log(res, '验证手机号和验证码')
|
|
if (res.error) {
|
|
if (res.error) {
|
|
res.error === 3 || res.error === 4
|
|
res.error === 3 || res.error === 4
|
|
- ? ElMessage.error("验证码错误")
|
|
|
|
|
|
+ ? ElMessage.error('验证码错误')
|
|
: res.error === 1
|
|
: res.error === 1
|
|
- ? ElMessage.error("无手机绑定的醍摩豆账号")
|
|
|
|
|
|
+ ? ElMessage.error('无手机绑定的醍摩豆账号')
|
|
: res.error === 5
|
|
: res.error === 5
|
|
- ? ElMessage.error("无效的手机号码")
|
|
|
|
- : ElMessage.error("接口异常请重新尝试绑定");
|
|
|
|
|
|
+ ? ElMessage.error('无效的手机号码')
|
|
|
|
+ : ElMessage.error('接口异常请重新尝试绑定')
|
|
} else if (res.status && res.status === 200) {
|
|
} else if (res.status && res.status === 200) {
|
|
- let userInfo = JSON.parse(localStorage.getItem("DingUser"));
|
|
|
|
- console.log(userInfo, "用户信息");
|
|
|
|
- let paramData = { mobile: phonenum.phone, param: userInfo };
|
|
|
|
- bindId(paramData, proxy);
|
|
|
|
|
|
+ let userInfo = JSON.parse(localStorage.getItem('DingUser'))
|
|
|
|
+ console.log(userInfo, '用户信息')
|
|
|
|
+ let paramData = { mobile: phonenum.phone, param: userInfo }
|
|
|
|
+ bindId(paramData, proxy)
|
|
}
|
|
}
|
|
- });
|
|
|
|
|
|
+ })
|
|
}
|
|
}
|
|
//绑定操作
|
|
//绑定操作
|
|
function bindId(paramData, proxy) {
|
|
function bindId(paramData, proxy) {
|
|
proxy.$api.bindUserid(paramData).then((res) => {
|
|
proxy.$api.bindUserid(paramData).then((res) => {
|
|
- console.log(res, "返回的结果");
|
|
|
|
|
|
+ console.log(res, '返回的结果')
|
|
res.status === 1 || res.status === 3
|
|
res.status === 1 || res.status === 3
|
|
- ? ElMessage.error("绑定失败,请稍后重试")
|
|
|
|
|
|
+ ? ElMessage.error('绑定失败,请稍后重试')
|
|
: res.status === 2
|
|
: res.status === 2
|
|
- ? ElMessage.error("账户已被绑定,请选择其他账号绑定")
|
|
|
|
|
|
+ ? ElMessage.error('账户已被绑定,请选择其他账号绑定')
|
|
: res.status === 200
|
|
: res.status === 200
|
|
- ? (ElMessage.success("绑定成功,即将跳转..."),
|
|
|
|
- router.push("/home"))
|
|
|
|
- : ElMessage.error("出现未知错误");
|
|
|
|
- });
|
|
|
|
|
|
+ ? (ElMessage.success('绑定成功,即将跳转...'), router.push('/home'))
|
|
|
|
+ : ElMessage.error('出现未知错误')
|
|
|
|
+ })
|
|
}
|
|
}
|
|
return {
|
|
return {
|
|
store,
|
|
store,
|
|
@@ -143,9 +142,9 @@ export default {
|
|
bindUser,
|
|
bindUser,
|
|
bindId,
|
|
bindId,
|
|
close,
|
|
close,
|
|
- };
|
|
|
|
|
|
+ }
|
|
},
|
|
},
|
|
-};
|
|
|
|
|
|
+}
|
|
//发送验证码API
|
|
//发送验证码API
|
|
function pin(proxy) {
|
|
function pin(proxy) {
|
|
let phoneCode = (datas) => {
|
|
let phoneCode = (datas) => {
|
|
@@ -154,18 +153,16 @@ function pin(proxy) {
|
|
lang: datas.lang,
|
|
lang: datas.lang,
|
|
HasUser: datas.HasUser,
|
|
HasUser: datas.HasUser,
|
|
country: datas.country,
|
|
country: datas.country,
|
|
- };
|
|
|
|
|
|
+ }
|
|
let { codesInfo } = proxy.$api.Phonepin(parameter).then((res) => {
|
|
let { codesInfo } = proxy.$api.Phonepin(parameter).then((res) => {
|
|
- console.log(res, "接口返回");
|
|
|
|
- res.status === 200
|
|
|
|
- ? ElMessage.success("验证码发送成功")
|
|
|
|
- : ElMessage.error("验证码发送失败");
|
|
|
|
- });
|
|
|
|
- console.log("codesInfo", codesInfo);
|
|
|
|
- };
|
|
|
|
|
|
+ console.log(res, '接口返回')
|
|
|
|
+ res.status === 200 ? ElMessage.success('验证码发送成功') : ElMessage.error('验证码发送失败')
|
|
|
|
+ })
|
|
|
|
+ console.log('codesInfo', codesInfo)
|
|
|
|
+ }
|
|
return {
|
|
return {
|
|
phoneCode,
|
|
phoneCode,
|
|
- };
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
<style scoped>
|
|
<style scoped>
|