1211 lines
49 KiB
JavaScript
1211 lines
49 KiB
JavaScript
|
||
const strApiDoMain = `https://hyapi.${strCodeCcHy}.net`
|
||
const strSite = 1
|
||
|
||
/**
|
||
* api 接口
|
||
*/
|
||
const apiGetUserInfo = '/api/user/info' //用户详情
|
||
const apiReGist = '/api/user/regist' //注册
|
||
const apiLoGout = '/api/user/logout'//退出
|
||
const apiLoginByEmail = '/api/user/login' //邮箱登录
|
||
const apiUserInfoSave = '/api/user/info/save' //修改密码
|
||
const apiPayPackage = '/api/pay/package' //获取支付套餐
|
||
const apiPayChannele = '/api/pay/channel' //获取支付渠道
|
||
const apiPayOrderCreate = '/api/pay/order/create' //创建支付订单
|
||
const apiPayOrderList = '/api/pay/order/list' //获取充值订单列表
|
||
const apiFundsTransactionsList = '/api/funds/transactions/list' //获取交易流水
|
||
const apiLoginByPhone = '' //手机登录
|
||
|
||
/**
|
||
* layer 弹窗提示
|
||
* @param {string} strContent
|
||
* @param int intTime
|
||
*/
|
||
function layerPopup(strContent, intTime) {
|
||
layer.open({
|
||
shadeClose: false,
|
||
skin: 'msg',
|
||
content: strContent,
|
||
time: intTime
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 将ArrayBuffer转换为Base64字符串
|
||
* @param buffer buffer
|
||
* @returns {string}
|
||
*/
|
||
function arrayBufferToBase64(buffer) {
|
||
let strBinary = '';
|
||
const bytes = new Uint8Array(buffer);
|
||
for (let i = 0; i < bytes.byteLength; i++) {
|
||
strBinary += String.fromCharCode(bytes[i]);
|
||
}
|
||
return window.btoa(strBinary);
|
||
}
|
||
/**
|
||
* 终身会员倒计时
|
||
*/
|
||
export function memberCountDown() {
|
||
setInterval(() => {
|
||
var djs_time = localStorage.getItem('djs_time')
|
||
if (djs_time) {
|
||
if (djs_time < 1 * 60 * 60) {
|
||
djs_time = 23 * 60 * 60
|
||
}
|
||
djs_time -= 1
|
||
} else {
|
||
djs_time = 23 * 60 * 60
|
||
}
|
||
localStorage.setItem('djs_time', djs_time)
|
||
var djs_obj = Gettime.TimeFramtHms(djs_time * 1000)
|
||
var djs_str = djs_obj.h + ':' + djs_obj.m + ':' + djs_obj.s
|
||
$(".djs_time").text(djs_str)
|
||
}, 1000)
|
||
}
|
||
/**
|
||
* 提取url参数的方法
|
||
* @param {string} strCode
|
||
* @returns {string}
|
||
*/
|
||
export function getValFromBrowserAddress(strCode) {
|
||
var strQuery = window.location.search;
|
||
var Params = new URLSearchParams(strQuery);
|
||
var strSearchVal = Params.get(strCode);
|
||
return strSearchVal;
|
||
}
|
||
const Gettime = {
|
||
//数字补零
|
||
parseNumber(num) {
|
||
return num < 10 ? "0" + num : num;
|
||
},
|
||
//毫秒转 日时分秒
|
||
TimeFramtHms(time) {
|
||
var day = parseInt(time / (60 * 60 * 24 * 1000));
|
||
var hour = parseInt(time / (60 * 60 * 1000) % 24);
|
||
var min = parseInt(time / (60 * 1000) % 60);
|
||
var sec = parseInt(time / 1000 % 60);
|
||
let obj = {
|
||
'd': this.parseNumber(day),
|
||
'h': this.parseNumber(hour),
|
||
'm': this.parseNumber(min),
|
||
's': this.parseNumber(sec),
|
||
}
|
||
return obj
|
||
// return `剩余${day}天${hour}时${min}分${sec}秒`
|
||
}
|
||
}
|
||
//本地储存
|
||
const storageObj = {
|
||
loginStatus: window.location.hostname + 'loginStatus', //登录状态
|
||
userInfo: window.location.hostname + 'userInfo',
|
||
tokenKey: window.location.hostname + 'mi_login_token', //token 本地储存key
|
||
isMember: window.location.hostname + 'isMember', //是否会员 本地储存key
|
||
isBingPhoneReturn: window.location.hostname + 'isBingPhoneReturn', //是否绑定手机页面返回
|
||
|
||
}
|
||
/**
|
||
* 获取登录状态
|
||
*/
|
||
function getLoginStatus() {
|
||
|
||
return localStorage.getItem(storageObj.loginStatus) || false;
|
||
}
|
||
/**
|
||
* 获取会员信息
|
||
*/
|
||
function getUserInfo() {
|
||
|
||
let userInfo = localStorage.getItem(storageObj.userInfo);
|
||
// 如果 data 不为 null 且长度大于 0,解析 JSON,否则返回 null 或原始数据
|
||
return userInfo && userInfo.length > 0 ? JSON.parse(userInfo) : userInfo;
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* fetchApi
|
||
* @param {*} url
|
||
* @param {*} data
|
||
* @param {*} onSuccess
|
||
* @param {*} onError
|
||
* @param {*} loadingMessage
|
||
*/
|
||
const fetchApi = function (url, data = null, onSuccess = null, onError = null, loadingMessage = '正在加载...') {
|
||
|
||
// 检测是否是 FormData,从而决定是否设置 'Content-Type' 为 'application/json'
|
||
const isFormData = data instanceof FormData;
|
||
|
||
const headers = new Headers({
|
||
'Accept': "application/x.hubserver.admin+json",
|
||
'token': localStorage.getItem(storageObj.tokenKey)
|
||
// 如果不是 FormData,设置 'Content-Type' 为 'application/json'
|
||
});
|
||
|
||
if (!isFormData) {
|
||
headers.append('Content-Type', 'application/json');
|
||
}
|
||
|
||
let layerIndex = null;
|
||
|
||
const options = {
|
||
method: data ? 'POST' : 'GET',
|
||
headers,
|
||
};
|
||
|
||
if (data) {
|
||
options.body = isFormData ? data : JSON.stringify(data); // 如果是 FormData,则直接设置为 body
|
||
}
|
||
|
||
// 显示加载提示
|
||
function showLoading() {
|
||
|
||
if (loadingMessage) {
|
||
layerIndex = layer.open({
|
||
type: 2,
|
||
content: loadingMessage // 修改这里以使用正确的变量
|
||
});
|
||
}
|
||
}
|
||
|
||
// 关闭加载提示
|
||
function closeLoading() {
|
||
if (layerIndex !== null) {
|
||
layer.close(layerIndex);
|
||
}
|
||
}
|
||
|
||
// 封装处理成功响应的逻辑
|
||
function handleSuccessResponse(res) {
|
||
// 解密处理
|
||
// if (Configs.get('MIAO_API_ENCRYPT_STATUS') == '1') {
|
||
// let returnENC = EncAndDec.decryptData(res, Configs.get('MIAO_API_ENCRYPT_KEY'));
|
||
// res = JSON.parse(returnENC);
|
||
// }
|
||
if (res.code !== '000' && res.code != '015' && res.code != '014') {
|
||
if (res.code != '014') {
|
||
layerPopup(res.message, 3);
|
||
}
|
||
// 重新登录
|
||
if (res.code == '2000' || res.code == '995' || res.code == '996' || res.code == '992') {
|
||
localStorage.setItem(storageObj.loginStatus, false)
|
||
location.href = "/login"
|
||
}
|
||
|
||
} else if (onSuccess) {
|
||
onSuccess(res);
|
||
}
|
||
}
|
||
|
||
showLoading(); // 请求前显示加载提示
|
||
|
||
fetch(strApiDoMain + url, options)
|
||
.then(response => {
|
||
if (response.status == 204) {
|
||
return null;
|
||
}
|
||
|
||
if (!response.ok) {
|
||
throw new Error(`HTTP error! status: ${response.status}`);
|
||
}
|
||
// return response.text();
|
||
return response.json();
|
||
})
|
||
.then(data => {
|
||
closeLoading(); // 请求成功,关闭加载提示
|
||
if (typeof onSuccess === 'function') {
|
||
handleSuccessResponse(data);
|
||
}
|
||
})
|
||
.catch(error => {
|
||
closeLoading(); // 请求失败,关闭加载提示
|
||
layerPopup(error, 3);
|
||
console.error('Fetch error:', error);
|
||
if (typeof onError === 'function') {
|
||
onError(error);
|
||
}
|
||
});
|
||
}
|
||
/**
|
||
*
|
||
* 访问失败的回调函数
|
||
*
|
||
*/
|
||
const onError = function (err) {
|
||
console.log(err);
|
||
}
|
||
|
||
$(document).ready(function () {
|
||
if (document.querySelector(".login-html-js")) {
|
||
sessionStorage.setItem("fallbackPage", document.referrer);
|
||
}
|
||
|
||
if (document.querySelector(".register-html-js")) {
|
||
|
||
const PHONE_LENGTH = 11;
|
||
const PASSWORD_MIN_LENGTH = 6;
|
||
const PASSWORD_MAX_LENGTH = 20;
|
||
let intChangIndex = 0;
|
||
const $getCodeButton = $('.get-v-code');
|
||
|
||
// 去空格
|
||
const getValueAndTrim = (selector) => $(selector).length > 0 ? $(selector).val().replace(/\s*/g, "") : "";
|
||
|
||
// 用户名验证
|
||
const isValidUsername = (username) => {
|
||
if (username.length < PASSWORD_MIN_LENGTH || username.length > PASSWORD_MAX_LENGTH) {
|
||
$('.sc-username-error').text(`必须由${PASSWORD_MIN_LENGTH}-${PASSWORD_MAX_LENGTH}位数字或者字母组成`);
|
||
return false;
|
||
}
|
||
return true;
|
||
};
|
||
const validateEmail = (strAccount) => {
|
||
return true;
|
||
let regex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
|
||
if (strAccount.length < PASSWORD_MIN_LENGTH) {
|
||
$('.sc-username-error').text(`请输入大于六位数的正确邮箱!`);
|
||
return false;
|
||
} else {
|
||
if (regex.test(strAccount) || !strAccount) {
|
||
return true;
|
||
} else {
|
||
$('.sc-username-error').text(`账号格式输入不正确,请重新输入`);
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
|
||
// 手机号验证
|
||
const isValidPhone = (phone) => {
|
||
if (phone.length < PHONE_LENGTH) {
|
||
$('.sc-phone-error').text(`请填写正确的手机号码`);
|
||
return false;
|
||
}
|
||
return true;
|
||
};
|
||
|
||
//验证码验证
|
||
const isValidCode = (code) => {
|
||
if (code.length !== 6) {
|
||
$('.sc-code-error').text(`短信验证码必须是6位数字`);
|
||
return false;
|
||
}
|
||
return true;
|
||
};
|
||
|
||
// 密码验证
|
||
const isValidPassword = (password, confirmPass = null) => {
|
||
if (password.length < PASSWORD_MIN_LENGTH || password.length > PASSWORD_MAX_LENGTH) {
|
||
$('.sc-password-error').text(`密码必须由${PASSWORD_MIN_LENGTH}-${PASSWORD_MAX_LENGTH}位数字或者字母组成`);
|
||
return false;
|
||
}
|
||
if (confirmPass !== null && password !== confirmPass) {
|
||
$('.sc-confirm-password-error').text(`两次密码不匹配,请确认后重新输入`);
|
||
return false;
|
||
}
|
||
return true;
|
||
};
|
||
|
||
// 输入框监听事件
|
||
const setupInputValidation = (selector, errorSelector, validationFunc, type) => {
|
||
$(selector).bind('input propertychange', function (e) {
|
||
const value = e.target.value.replace(/\s*/g, "");
|
||
const strPasswordVal2 = getValueAndTrim(".sc-password");
|
||
const strConfirmPasswordval2 = getValueAndTrim(".sc-confirm-password");
|
||
if (!validationFunc(value)) {
|
||
if (type == 0) {
|
||
$(errorSelector).text(value.length === 0 ? `请输入邮箱` : $(errorSelector).text());
|
||
} else if (type == 2) {
|
||
$(errorSelector).text(value.length === 0 ? `请填写正确的手机号码` : $(errorSelector).text());
|
||
} else if (type == 1) {
|
||
$(errorSelector).text(value.length === 0 ? `请输入密码` : $(errorSelector).text());
|
||
} else {
|
||
$(errorSelector).text(value.length === 0 ? `短信验证码必须是6位数字` : $(errorSelector).text());
|
||
}
|
||
if (type == 1) {
|
||
// 检查确认密码是否匹配
|
||
if (strConfirmPasswordval2.length > 0 && strConfirmPasswordval2 !== strPasswordVal2) {
|
||
$('.sc-confirm-password-error').text(`两次密码不匹配,请确认后重新输入`);
|
||
} else {
|
||
$('.sc-confirm-password-error').text(``);
|
||
}
|
||
}
|
||
|
||
} else {
|
||
$(errorSelector).text('');
|
||
if (type == 1) {
|
||
// 检查确认密码是否匹配
|
||
if (strConfirmPasswordval2.length > 0 && strConfirmPasswordval2 !== strPasswordVal2) {
|
||
$('.sc-confirm-password-error').text(`两次密码不匹配,请确认后重新输入`);
|
||
} else {
|
||
$('.sc-confirm-password-error').text(``);
|
||
}
|
||
}
|
||
}
|
||
});
|
||
};
|
||
|
||
|
||
// 0代表用户名 1密码 2手机号 1确认密码 3验证码
|
||
setupInputValidation(".sc-username", ".sc-username-error", isValidUsername, 0);
|
||
setupInputValidation(".sc-code", ".sc-code-error", isValidCode, 3);
|
||
setupInputValidation(".sc-phone", ".sc-phone-error", isValidPhone, 2);
|
||
setupInputValidation(".sc-password", ".sc-password-error", (val) => isValidPassword(val), 1);
|
||
setupInputValidation(".sc-confirm-password", ".sc-confirm-password-error", (val) => isValidPassword($('.sc-password').val(), val), 1);
|
||
|
||
// 提交表单逻辑
|
||
const submitForm = async (isLogin) => {
|
||
const strUsernameVal = getValueAndTrim(".sc-username");
|
||
const strPhoneVal = getValueAndTrim(".sc-phone");
|
||
const strCodeVal = getValueAndTrim(".sc-code");
|
||
const strPasswordVal = getValueAndTrim(".sc-password");
|
||
const strConfirmPasswordval = getValueAndTrim(".sc-confirm-password");
|
||
|
||
if (isLogin == 1) {
|
||
//登录
|
||
if (intChangIndex === 0) {
|
||
if (isValidUsername(strUsernameVal) && isValidPassword(strPasswordVal)) {
|
||
await handleSubmit(strUsernameVal, strPasswordVal, isLogin);
|
||
}
|
||
} else {
|
||
if (isValidPhone(strPhoneVal) && isValidPassword(strPasswordVal)) {
|
||
await handleSubmit(strPhoneVal, strPasswordVal, isLogin);
|
||
}
|
||
}
|
||
} else if (isLogin == 2) {
|
||
//注册
|
||
if (validateEmail(strUsernameVal) && isValidPassword(strPasswordVal, strConfirmPasswordval)) {
|
||
await handleSubmit(strUsernameVal, strPasswordVal, isLogin, strConfirmPasswordval);
|
||
}
|
||
} else if (isLogin == 3) {
|
||
//忘记密码
|
||
if (isValidPhone(strPhoneVal) && isValidCode(strCodeVal) && isValidPassword(strPasswordVal, strConfirmPasswordval)) {
|
||
await handleSubmit(strPhoneVal, strPasswordVal, isLogin, strConfirmPasswordval, strCodeVal);
|
||
}
|
||
}
|
||
};
|
||
|
||
const handleSubmit = async (username, password, isLogin, confirmpassword, code,) => {
|
||
if (isLogin == 1) {
|
||
if (intChangIndex == 0) {
|
||
userLogin(username, password)
|
||
} else {
|
||
phoneLogin(username, password)
|
||
}
|
||
} else if (isLogin == 2) {
|
||
userRegister(username, password)
|
||
} else if (isLogin == 3) {
|
||
forgetPassWord(username, password, code)
|
||
}
|
||
|
||
};
|
||
|
||
/*
|
||
mu_email string Y 用户邮箱
|
||
mu_pwd string Y 用户密码
|
||
si_id int Y 站点 ID
|
||
*/
|
||
//用户名登录
|
||
function userLogin(username, password) {
|
||
let postData = {
|
||
'mu_email': username,
|
||
'mu_pwd': password,
|
||
'si_id': strSite,
|
||
}
|
||
fetchApi(apiLoginByEmail, postData, successFun, onError)
|
||
function successFun(res) {
|
||
if (res.code == '000') {
|
||
layerPopup(res.message, 3)
|
||
localStorage.setItem(storageObj.tokenKey, res.data.token)
|
||
localStorage.setItem(storageObj.loginStatus, true)
|
||
localStorage.setItem(storageObj.isMember, res.data.mu_is_vip)
|
||
localStorage.setItem(storageObj.userInfo, res.data)
|
||
history.go(-1)
|
||
// getInfo()
|
||
} else if (res.code == '014') {
|
||
// 需要重置密码
|
||
strSetPwdKey = res.data.key
|
||
localStorage.setItem(storageObj.loginStatus, true)
|
||
layerPopup(res.message, 3)
|
||
} else {
|
||
layerPopup('出错啦!请重试', 3)
|
||
}
|
||
}
|
||
}
|
||
//手机登录
|
||
function phoneLogin(username, password) {
|
||
let postData = {
|
||
'phone': username,
|
||
'password': password,
|
||
'si_id': strSite,
|
||
}
|
||
fetchApi(apiLoginByPhone, postData, successFun, onError)
|
||
function successFun(res) {
|
||
if (res.code == '000') {
|
||
layerPopup(res.message, 3)
|
||
localStorage.setItem(storageObj.tokenKey, res.data.token)
|
||
localStorage.setItem(storageObj.loginStatus, true)
|
||
localStorage.setItem(storageObj.isMember, res.data.mu_is_vip)
|
||
localStorage.setItem(storageObj.userInfo, res.data)
|
||
// history.go(-1)
|
||
// getInfo()
|
||
} else if (res.code == '014') {
|
||
// 需要重置密码
|
||
strSetPwdKey = res.data.key
|
||
localStorage.setItem(storageObj.loginStatus, true)
|
||
layerPopup(res.message, 3)
|
||
|
||
} else {
|
||
layerPopup('出错啦!请重试', 3)
|
||
}
|
||
}
|
||
}
|
||
//用户注册
|
||
function userRegister(username, password) {
|
||
let postData = {
|
||
'mu_email': username,
|
||
'mu_pwd': password,
|
||
'si_id': strSite,
|
||
mu_channel_code: localStorage.getItem(EncAndDec.encryptData('dlfx_channelcode')) || '',
|
||
mu_channel_domain: localStorage.getItem(EncAndDec.encryptData('dlfx_sourceDomain')) || '',
|
||
mu_referrer_id: localStorage.getItem(EncAndDec.encryptData('dlfx_muReferrerId')) || ''
|
||
}
|
||
fetchApi(apiReGist, postData, successFun, onError)
|
||
function successFun(res) {
|
||
if (res.code == '000') {
|
||
localStorage.setItem(storageObj.tokenKey, res.data.token)
|
||
localStorage.setItem(storageObj.loginStatus, true)
|
||
localStorage.setItem(storageObj.isMember, res.data.mu_is_vip)
|
||
localStorage.setItem(storageObj.userInfo, res.data)
|
||
//$(".sc-public-popup").show()
|
||
layerPopup('注册成功!', 3)
|
||
console.log('注册成功!')
|
||
let time = setTimeout(() => {
|
||
console.log('注册成功!2')
|
||
clearTimeout(time)
|
||
console.log('注册成功3!3')
|
||
let previousPage = document.referrer; // 获取上一个页面的 URL
|
||
console.log(previousPage)
|
||
if (previousPage.includes("login")) { // 如果上一个页面是登录页面,跳转到再上一个页面或指定页面
|
||
const fallbackPage = sessionStorage.getItem("fallbackPage") || "/";
|
||
window.location.href = fallbackPage;history.go(-2); // 返回再上一个页面
|
||
} else {
|
||
history.go(-1); // 返回上一个页面
|
||
}
|
||
}, 1500)
|
||
} else {
|
||
layerPopup('请求超时,请稍后再试', 3)
|
||
}
|
||
}
|
||
}
|
||
//忘记密码
|
||
function forgetPassWord(username, password, code) {
|
||
let postData = {
|
||
'phone': username,
|
||
'password': password,
|
||
'code': code,
|
||
|
||
}
|
||
fetchApi(apiLoginByPhone, postData, successFun, onError)
|
||
function successFun(res) {
|
||
console.log(res.message)
|
||
layerPopup(res.message, 3)
|
||
console.log(res)
|
||
|
||
}
|
||
}
|
||
|
||
|
||
//用户详情
|
||
function getInfo() {
|
||
fetchApi(apiGetUserInfo, null, successFn, onError)
|
||
function successFn(res) {
|
||
if (res.code == '000') {
|
||
var data = res.data
|
||
localStorage.setItem(storageObj.userInfo, JSON.stringify(data))
|
||
let timestamp = Date.parse(new Date());
|
||
if (data.mu_vip_expired != null) {
|
||
localStorage.setItem(storageObj.isMember, true)
|
||
let vip_timesStamp = new Date(data.mu_vip_expired).getTime()
|
||
let seconds = 2 * 24 * 60 * 60 * 1000
|
||
if (vip_timesStamp - timestamp > seconds) {
|
||
console.log('大于2天')
|
||
history.go(-1)
|
||
} else {
|
||
console.log('小于2天')
|
||
if (vip_timesStamp < timestamp) {
|
||
localStorage.setItem(storageObj.isMember, false)
|
||
$('.charge-dialog').show()
|
||
} else {
|
||
$('.vip-dialog').show()
|
||
$('.tip-date').text('你的会员即将过期,请及时续费,续费会员,纵想激情')
|
||
}
|
||
}
|
||
|
||
} else {
|
||
// $(".sc-vip_modal").show()
|
||
// $('.yh-expire').show()
|
||
localStorage.setItem(storageObj.isMember, false)
|
||
}
|
||
} else {
|
||
layerPopup(res.msg, 3)
|
||
}
|
||
}
|
||
}
|
||
|
||
//登录
|
||
$('.sc-login-btn').on('click', function () {
|
||
submitForm(1);
|
||
});
|
||
//注册
|
||
$('.sc-register-btn').on('click', function () {
|
||
submitForm(2);
|
||
});
|
||
//忘记密码
|
||
$('.sc-forget-btn').on('click', function () {
|
||
submitForm(3);
|
||
});
|
||
// 登录页 用户登录/手机登录切换
|
||
var a = $(".grid .login_item");
|
||
var c = $(".grid .input-pu-lic")
|
||
for (var i = 0; i < a.length; i++) {
|
||
a[i].index = i;
|
||
a[i].setAttribute("index", i);
|
||
a[i].onclick = function () {
|
||
for (var i = 0; i < a.length; i++) {
|
||
a[i].className = 'undefined point login_item'
|
||
c[i].className = 'align_center gap10 input-pu-lic ee58ce4adf';
|
||
}
|
||
this.className = '_2a4b899e3f point login_item';
|
||
var index = this.getAttribute("index");
|
||
intChangIndex = index
|
||
c[index].className = 'fl align_center gap10 _53fc7f89df _17d18e62bf input-pu-lic';
|
||
|
||
$(".sc-username").val('')
|
||
$(".sc-password").val('')
|
||
$(".sc-phone").val('');
|
||
$('.sc-username-error').text(`请输入邮箱`);
|
||
$('.sc-password-error').text(`请输入密码`);
|
||
$('.sc-phone-error').text(`请填写正确的手机号码`);
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 发送验证码
|
||
*/
|
||
const sendMsg = () => {
|
||
$(".yzm-btn").on('click', function () {
|
||
const intPhone = getValueAndTrim(".sc-phone");
|
||
if (isValidPhone(intPhone)) {
|
||
getSmsCode(intPhone);
|
||
} else {
|
||
// $(".sc-public-popup").show()
|
||
// $(".sc-public-popup .sc-trends-text").text(`请填写正确的手机号码`);
|
||
}
|
||
});
|
||
function getSmsCode(strPhone) {
|
||
let postData = {
|
||
'phone': strPhone,
|
||
'type': 'reg',
|
||
}
|
||
let timerCount = 60;
|
||
let timerCctvQiDon = setInterval(() => {
|
||
if (timerCount <= 0) {
|
||
$getCodeButton.text('获取验证码');
|
||
clearInterval(timerCctvQiDon);
|
||
} else {
|
||
timerCount--;
|
||
$getCodeButton.text(`${timerCount} s`);
|
||
}
|
||
}, 1000);
|
||
}
|
||
|
||
}
|
||
$(".sc-junp-vip-buy").on('click', function () {
|
||
window.open('/taochang');
|
||
});
|
||
|
||
$(function () {
|
||
sendMsg()
|
||
});
|
||
}
|
||
|
||
if (document.querySelector(".info-html-js")) {
|
||
$(function () {
|
||
// 从绑定手机页面返回到个人中心
|
||
if (getValFromBrowserAddress('free_vip_data') && localStorage.getItem(storageObj.isBingPhoneReturn)) {
|
||
$(".free_vip_data_tip").removeClass("yc")
|
||
$(".tip_zdc_body").removeClass("yc")
|
||
$(".free_vip_data_num").text(getValFromBrowserAddress('free_vip_data'))
|
||
}
|
||
|
||
//退出点击
|
||
$('.logout-url').click(function () {
|
||
getLogout()
|
||
})
|
||
})
|
||
|
||
// 登录状态
|
||
if (getLoginStatus()) {
|
||
getUserInfo()
|
||
} else {
|
||
location.href = "/login.html"
|
||
}
|
||
|
||
|
||
//退出登录
|
||
function getLogout() {
|
||
let postData = {}
|
||
fetchApi(apiLoGout, postData, successFun, onError, false)
|
||
function successFun(res) {
|
||
if (res.code == '000') {
|
||
$('.mm_id').text('')
|
||
$('.mm_name').text('')
|
||
$('.another_level_vip').hide()
|
||
$('.another_level_vip1').hide()
|
||
localStorage.setItem(storageObj.loginStatus, false)
|
||
localStorage.setItem(storageObj.isMember, false)
|
||
localStorage.setItem(storageObj.tokenKey, '')
|
||
localStorage.setItem(storageObj.userInfo, '')
|
||
layerPopup('退出成功', 3)
|
||
location.href = "/"
|
||
} else {
|
||
layerPopup(res.msg, 3)
|
||
}
|
||
}
|
||
}
|
||
|
||
//用户详情
|
||
function getUserInfo() {
|
||
let apiUrl = apiGetUserInfo + `?si_id=${strSite}`
|
||
fetchApi(apiUrl, null, successFn, onError)
|
||
function successFn(res) {
|
||
if (res.code == '000') {
|
||
var data = res.data
|
||
$("._40cfe6e5fe").text(data.mu_nickname)
|
||
$(".user_id").text(data.mu_id)
|
||
|
||
if (data.mu_email_verified == 0) {
|
||
$(".j-email-verify").show()
|
||
$(".user_email").text(data.mu_email)
|
||
}
|
||
// if(data.mu_auth_phone == 0){
|
||
// $(".j-phone-verify").show()
|
||
// }
|
||
localStorage.setItem(storageObj.userInfo, JSON.stringify(data))
|
||
|
||
if (data.mu_is_vip) {
|
||
// 会员
|
||
localStorage.setItem(storageObj.isMember, true)
|
||
$('.user_is_type').text("VIP会员")
|
||
$(".mu_vip_expired").show()
|
||
$(".user_vip_day").text(data.expire_vip_day + '天')
|
||
|
||
} else {
|
||
// 不是会员
|
||
localStorage.setItem(storageObj.isMember, false)
|
||
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if (document.querySelector(".setpwd-html-js")) {
|
||
// 登录状态
|
||
if (getLoginStatus()) {
|
||
//getUserInfo()
|
||
} else {
|
||
location.href = "/login.html"
|
||
}
|
||
const PASSWORD_MIN_LENGTH = 6;
|
||
const PASSWORD_MAX_LENGTH = 20;
|
||
// 去空格
|
||
const getValueAndTrim = (selector) => $(selector).length > 0 ? $(selector).val().replace(/\s*/g, "") : "";
|
||
// 当前密码验证
|
||
const isValidCurrentPassword = (password) => {
|
||
if (password.length < PASSWORD_MIN_LENGTH) {
|
||
$('.sc-current-password-error').text(`请输入密码`);
|
||
return false;
|
||
}
|
||
return true;
|
||
};
|
||
|
||
// 密码验证
|
||
const isValidPassword = (password, confirmPass = null) => {
|
||
if (password.length < PASSWORD_MIN_LENGTH || password.length > PASSWORD_MAX_LENGTH) {
|
||
$('.sc-password-error').text(`密码必须由${PASSWORD_MIN_LENGTH}-${PASSWORD_MAX_LENGTH}位数字或者字母组成`);
|
||
return false;
|
||
}
|
||
if (confirmPass !== null && password !== confirmPass) {
|
||
$('.sc-confirm-password-error').text(`两次密码不匹配,请确认后重新输入`);
|
||
return false;
|
||
}
|
||
return true;
|
||
};
|
||
|
||
// 输入框监听事件
|
||
const setupInputValidation = (selector, errorSelector, validationFunc, type) => {
|
||
$(selector).bind('input propertychange', function (e) {
|
||
const value = e.target.value.replace(/\s*/g, "");
|
||
const strPasswordVal = getValueAndTrim(".sc-password");
|
||
const strConfirmPasswordval = getValueAndTrim(".sc-confirm-password");
|
||
if (!validationFunc(value)) {
|
||
$(errorSelector).text(value.length === 0 ? `请输入密码` : $(errorSelector).text());
|
||
if (type == 1) {
|
||
// 检查确认密码是否匹配
|
||
if (strConfirmPasswordval.length > 0 && strConfirmPasswordval !== strPasswordVal) {
|
||
$('.sc-confirm-password-error').text(`两次密码不匹配,请确认后重新输入`);
|
||
} else {
|
||
$('.sc-confirm-password-error').text(``);
|
||
}
|
||
}
|
||
|
||
} else {
|
||
$(errorSelector).text('');
|
||
if (type == 1) {
|
||
// 检查确认密码是否匹配
|
||
if (strConfirmPasswordval.length > 0 && strConfirmPasswordval !== strPasswordVal) {
|
||
$('.sc-confirm-password-error').text(`两次密码不匹配,请确认后重新输入`);
|
||
} else {
|
||
$('.sc-confirm-password-error').text(``);
|
||
}
|
||
}
|
||
}
|
||
});
|
||
};
|
||
// 0代表用户名 1密码 2手机号 1确认密码 3验证码
|
||
setupInputValidation(".sc-current-password", ".sc-current-password-error", isValidCurrentPassword, 0);
|
||
setupInputValidation(".sc-password", ".sc-password-error", (val) => isValidPassword(val), 1);
|
||
setupInputValidation(".sc-confirm-password", ".sc-confirm-password-error", (val) => isValidPassword($('.sc-password').val(), val), 1);
|
||
|
||
// 提交表单逻辑
|
||
const submitForm = async (isLogin) => {
|
||
const strCurrentPasswordVal = getValueAndTrim(".sc-current-password");
|
||
const strPasswordVal = getValueAndTrim(".sc-password");
|
||
const strConfirmPasswordval = getValueAndTrim(".sc-confirm-password");
|
||
|
||
if (isLogin == 1) {
|
||
//修改密码
|
||
if (isValidCurrentPassword(strCurrentPasswordVal) && isValidPassword(strPasswordVal, strConfirmPasswordval)) {
|
||
await handleSubmit(strCurrentPasswordVal, strPasswordVal, strConfirmPasswordval);
|
||
}
|
||
}
|
||
};
|
||
|
||
const handleSubmit = async (strCurrentPasswordVal, strPasswordVal) => {
|
||
let postData = {
|
||
'old_mu_pwd': strCurrentPasswordVal,
|
||
'mu_pwd': strPasswordVal,
|
||
'si_id': strSite,
|
||
}
|
||
fetchApi(apiUserInfoSave, postData, successFun, onError)
|
||
function successFun(res) {
|
||
if (res.code == '000') {
|
||
layerPopup('修改成功', 3)
|
||
let time = setTimeout(() => {
|
||
clearTimeout(time)
|
||
history.go(-1)
|
||
}, 1500)
|
||
// $(".sc-public-popup").show()
|
||
// $('.sc-trends-text').text(`修改成功`);
|
||
}
|
||
}
|
||
};
|
||
|
||
//修改密码
|
||
$('.sc-modify-btn').on('click', function () {
|
||
submitForm(1);
|
||
});
|
||
}
|
||
|
||
if (document.querySelector(".bill-html-js")) {
|
||
// 登录状态
|
||
if (getLoginStatus()) {
|
||
//getUserInfo()
|
||
} else {
|
||
location.href = "/login.html"
|
||
}
|
||
const BillJs = function () {
|
||
//支付订单列表
|
||
var page = 1
|
||
var allpage = 1
|
||
$('.load-morn').text('暂无')
|
||
getOrderList(page)
|
||
function getOrderList(page) {
|
||
let apiUrl = apiFundsTransactionsList + '?limit=10' + '&page=' + page
|
||
fetchApi(apiUrl, null, successFn, onError)
|
||
function successFn(res) {
|
||
if (res.code == '000') {
|
||
allpage = res.data.total_page
|
||
var data = res.data.item
|
||
if (page >= res.data.total_page) {
|
||
$('.load-morn').text('没有了')
|
||
if (data.length == 0) {
|
||
$('.load-morn').text('暂无')
|
||
}
|
||
} else {
|
||
$('.load-morn').text('加载更多 ↓')
|
||
}
|
||
|
||
data.forEach((item) => {
|
||
if (item.vo_status == 1) {
|
||
item['vp_name'] = '已支付'
|
||
} else if (item.vo_status == 1) {
|
||
item['vp_name'] = '未支付'
|
||
} else {
|
||
item['vp_name'] = '已过期'
|
||
}
|
||
})
|
||
if (page == 1) {
|
||
data = data
|
||
} else {
|
||
data = data.concat(data)
|
||
}
|
||
var $list = $(".detail-list");
|
||
setLunDate(data)
|
||
// let data2 = [
|
||
// {vo_success_at:'2021-06888',created_at:'2021-06',vp_name:'VIP购买',vo_order_no:'171882135426094995HU',vo_price:'¥50.00'},
|
||
// {vo_success_at:'2021-07',created_at:'2021-08',vp_name:'VIP购买',vo_order_no:'171882135426094995HU',vo_price:'¥150.00'},
|
||
// {vo_success_at:'2021-08',created_at:'2021-09',vp_name:'VIP购买',vo_order_no:'171882135426094995HU',vo_price:'¥250.00'},
|
||
// {vo_success_at:'2021-07',created_at:'2021-10',vp_name:'VIP购买',vo_order_no:'171882135426094995HU',vo_price:'¥350.00'}
|
||
// ]
|
||
// setLunDate(data2)
|
||
function setLunDate(data) {
|
||
data.forEach((item) => {
|
||
var html = ''
|
||
html += `
|
||
<div class="f48f2ef5_yh">
|
||
<div class="f48f2ef5ec">${item.vo_success_at}</div>
|
||
<div class="ef9739b7e6 _7d85f9f50c _2e9da47136">
|
||
<div>
|
||
<div>${item.created_at}</div>
|
||
<div>${item.vo_order_no}</div>
|
||
</div>
|
||
<div>${item.vo_price}</div>
|
||
<div class="_4af47fba7d">${item.vp_name}</div>
|
||
</div>
|
||
</div>
|
||
`
|
||
$list.append(html);
|
||
// 这是jquery的拼接
|
||
$list.append($list);
|
||
});
|
||
}
|
||
|
||
} else {
|
||
layerPopup(res.msg, 3)
|
||
console.log(res)
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
//加载更多
|
||
$('.load-morn').click(function () {
|
||
if (page >= allpage) {
|
||
$('.load-morn').text('没有了')
|
||
} else {
|
||
page++
|
||
getOrderList(page)
|
||
}
|
||
})
|
||
|
||
}()
|
||
}
|
||
|
||
if (document.querySelector(".vip-taochang-html-js")) {
|
||
// 登录状态
|
||
if (getLoginStatus()) {
|
||
//getUserInfo()
|
||
} else {
|
||
location.href = "/login.html"
|
||
}
|
||
//限时优惠倒计时 无限循环
|
||
memberCountDown()
|
||
getOrderList()
|
||
function getOrderList() {
|
||
fetchApi(apiPayPackage, null, successFn, onError)
|
||
function successFn(res) {
|
||
if (res.code == '000') {
|
||
if (res.data.item.length != 0) {
|
||
res.data.item.forEach((card) => {
|
||
if (card.vp_id == 4) {
|
||
var $list = $(".yh-tc-yjvip");
|
||
var html = '';
|
||
html += `
|
||
<a class="relative" href="/chongzhi?id=${card.vp_id}&val=${card.vp_real_price}">
|
||
<img src="/assets/huiyuan/images/image_2024-09-26_00-06-45.png" style="width:100%" />
|
||
</a>
|
||
`;
|
||
// html += `
|
||
// <a class="relative" href="/chongzhi?id=${card.vp_id}&val=${card.vp_real_price}">
|
||
// <div style="height:9rem;background: #f4dfc2;margin-bottom:5px;border-radius: 5px;"></div>
|
||
// <div class="abs _25f0b6f3cd _25ccbe5ac8 _69aa9a34e8">
|
||
// <div class="_71ab71e6f0 cd69248791">终身VIP限时优惠</div>
|
||
// <div class="_71ab71e6f0 cd69248791 djs_time" id="sc-countdown-time">21:39:46</div>
|
||
// <div class="_584c0e0412">限时特价<span>${card.vp_real_price}</span>元 <span class="text_line">原价 ${card.vp_tag_price}</span></div>
|
||
// </div>
|
||
// </a>
|
||
// `;
|
||
$list.append(html);
|
||
}
|
||
|
||
// Render all cards, including those with card.vp_id == 4
|
||
const cardElement = document.createElement("a");
|
||
cardElement.href = `/chongzhi?id=${card.vp_id}&val=${card.vp_real_price}`;
|
||
cardElement.className = "d_none point";
|
||
cardElement.innerHTML = `
|
||
<div class="_5618db95dc _1016bcbbbd grid align_center">
|
||
<div class="grid align_center h100 gap5">
|
||
<div class="fl align_center gap10">
|
||
<div class="a9c1886f50">${card.vp_name}</div>
|
||
${card.vp_best_describe ? `<span class="c3b7fd6d8e">${card.vp_best_describe}</span>` : ''}
|
||
</div>
|
||
<div class="d83e478929">原价 ${card.vp_tag_price}</div>
|
||
</div>
|
||
<div><span class="_2b48c581b1">${card.vp_real_price}</span><span>元</span></div>
|
||
</div>
|
||
`;
|
||
document.querySelector(".cardContainer").appendChild(cardElement);
|
||
});
|
||
}
|
||
} else {
|
||
layerPopup(res.msg, 3);
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
if (document.querySelector(".chongzhi-html-js")) {
|
||
// 登录状态
|
||
if (getLoginStatus()) {
|
||
//getUserInfo()
|
||
} else {
|
||
location.href = "/login.html"
|
||
}
|
||
let intVpId = getValFromBrowserAddress('id')
|
||
let intActiveCgId = null
|
||
//支付金额
|
||
$('.sc-payment-amount').text('¥' + getValFromBrowserAddress('val'))
|
||
getChannelList()
|
||
let paymentData = [
|
||
// {
|
||
// method: { id: 'alipay', name: '支付宝88', img: '/assets/huiyuan/images/zhifubao.png' },
|
||
// channels: [
|
||
// {id: '1', name: '支付宝1', img: '/assets/huiyuan/images/zhifubao.png'},
|
||
// {id: '2', name: '支付宝2', img: '/assets/huiyuan/images/zhifubao.png'},
|
||
// {id: '3', name: '支付宝3', img: 'v/images/zhifubao.png'},
|
||
// ]
|
||
// },
|
||
// {
|
||
// method: { id: 'wechat', name: '微信88', img: '/assets/huiyuan/images/wechat.png' },
|
||
// channels: [
|
||
// {id: '11', name: '微信1', img: '/assets/huiyuan/images/zhifubao.png'},
|
||
// {id: '12', name: '微信2', img: '/assets/huiyuan/images/zhifubao.png'},
|
||
// {id: '13', name: '微信3', img: '/assets/huiyuan/images/zhifubao.png'},
|
||
// ]
|
||
// },
|
||
// {
|
||
// method: { id: 'test', name: '测试', img: '/assets/huiyuan/images/wechat.png' },
|
||
// channels: [
|
||
// {id: '21', name: '测试1', img: '/assets/huiyuan/images/zhifubao.png'},
|
||
// {id: '22', name: '测试2', img: '/assets/huiyuan/images/zhifubao.png'},
|
||
// {id: '23', name: '测试3', img: '/assets/huiyuan/images/zhifubao.png'},
|
||
// ]
|
||
// }
|
||
];
|
||
|
||
const paymentMethodsContainer = document.getElementById('payment-methods-container');
|
||
const paymentChannelsContainer = document.getElementById('payment-channels-container');
|
||
|
||
function renderPaymentMethods() {
|
||
let html = `<div class="fl"><div>支付方式</div></div><div class="mt10"><div class="fl gap5 align_center fl_wrap">`;
|
||
paymentData.forEach((data, index) => {
|
||
const method = data.method;
|
||
html += `
|
||
<div id="${method.id}" class="e21f3fa97e point relative ${index === 0 ? 'selected _71a3d26126' : ''}" onclick="selectPaymentMethod(${index})">
|
||
<img sizes="100vh" class="point fill undefined" height="33" width="33" alt="${method.name}" src="${method.icon}">
|
||
<div class="mt3 ${index === 0 ? 'c63892b6d2' : ''}">${method.name}</div>
|
||
<div class="abs eb2a18721c" style="display:${index === 0 ? 'block' : 'none'};"><img sizes="100vh" class="point fill undefined" height="25" width="25" alt="" src="/assets/huiyuan/images/user-center/charge/h.png"></div>
|
||
</div>`;
|
||
});
|
||
html += `</div></div>`;
|
||
paymentMethodsContainer.innerHTML = html;
|
||
}
|
||
|
||
function renderPaymentChannels(index) {
|
||
|
||
const channels = paymentData[index].channels;
|
||
intActiveCgId = paymentData[index].channels[0].id
|
||
let html = `<div class="fl"><div>渠道选择</div></div><div class="mt10"><div class="fl gap5 align_center fl_wrap">`;
|
||
channels.forEach((channel, idx) => {
|
||
html += `
|
||
<div id="channel-${idx}" class="e21f3fa97e point relative ${idx === 0 ? 'selected _71a3d26126' : ''}" style="height: 25px; display: flex; align-items: center; justify-content: center;" onclick="selectPaymentChannel(${idx}, ${index})">
|
||
<div class="mt3 ${idx === 0 ? 'c63892b6d2' : ''} b36fec8841">${channel.name}</div>
|
||
<div class="abs eb2a18721c" style="display:${idx === 0 ? 'block' : 'none'};"><img sizes="100vh" class="point fill undefined" height="25" width="25" alt="" src="/assets/huiyuan/images/user-center/charge/h.png"></div>
|
||
</div>`;
|
||
});
|
||
html += `</div></div>`;
|
||
paymentChannelsContainer.innerHTML = html;
|
||
}
|
||
|
||
window.selectPaymentMethod = function (index) {
|
||
document.querySelectorAll('#payment-methods-container .e21f3fa97e').forEach(el => {
|
||
el.classList.remove('selected', '_71a3d26126');
|
||
el.querySelector('.mt3').classList.remove('c63892b6d2');
|
||
});
|
||
paymentData.forEach((data) => {
|
||
document.querySelector(`#${data.method.id} .eb2a18721c`).style.display = 'none';
|
||
});
|
||
const selectedMethod = document.getElementById(paymentData[index].method.id);
|
||
intActiveCgId = paymentData[index].channels[0].id
|
||
|
||
selectedMethod.classList.add('selected', '_71a3d26126');
|
||
selectedMethod.querySelector('.mt3').classList.add('c63892b6d2');
|
||
selectedMethod.querySelector('.eb2a18721c').style.display = 'block';
|
||
renderPaymentChannels(index);
|
||
}
|
||
|
||
window.selectPaymentChannel = function (channelIdx, methodIdx) {
|
||
document.querySelectorAll('#payment-channels-container .e21f3fa97e').forEach(el => {
|
||
el.classList.remove('selected', '_71a3d26126');
|
||
el.querySelector('.mt3').classList.remove('c63892b6d2');
|
||
});
|
||
paymentData[methodIdx].channels.forEach((channel, idx) => {
|
||
document.querySelector(`#channel-${idx} .eb2a18721c`).style.display = 'none';
|
||
});
|
||
const selectedChannel = document.getElementById(`channel-${channelIdx}`);
|
||
selectedChannel.classList.add('selected', '_71a3d26126');
|
||
selectedChannel.querySelector('.mt3').classList.add('c63892b6d2');
|
||
selectedChannel.querySelector('.eb2a18721c').style.display = 'block';
|
||
|
||
// 获取点击渠道的 id
|
||
intActiveCgId = paymentData[methodIdx].channels[channelIdx].id;
|
||
}
|
||
/**
|
||
* 获取支付通道
|
||
*/
|
||
function getChannelList() {
|
||
let strApiUrl = apiPayChannele + "?vp_id=" + intVpId
|
||
fetchApi(strApiUrl, null, successFn, onError, '拼命加载中。。。')
|
||
function successFn(res) {
|
||
if (res.code == '000') {
|
||
let arrPayChannel = res.data.item
|
||
if (arrPayChannel.length <= 0) {
|
||
layerPopup('暂无支付渠道,请稍后再试!', 3)
|
||
return false
|
||
}
|
||
arrPayChannel.forEach((item) => {
|
||
item.id = item.cg_id
|
||
item.name = item.pg_channel_name
|
||
if (item.pg_channel_code == 'ZFB') {
|
||
item.icon = '/assets/huiyuan/images/zhifubao.png'
|
||
} else if (item.pg_channel_code == 'WX') {
|
||
item.icon = '/assets/huiyuan/images/wechat.png'
|
||
}
|
||
})
|
||
// 提取 pg_channel_name 和 pg_product_code 到新数组
|
||
const extractedData = arrPayChannel.map(PayChannel => {
|
||
const filteredElements = arrPayChannel.filter(item => item.pg_channel_code === PayChannel.pg_channel_code);
|
||
return {
|
||
method: {
|
||
name: PayChannel.pg_channel_name,
|
||
id: PayChannel.pg_channel_code,
|
||
pg_channel_code: PayChannel.pg_channel_code,
|
||
icon: PayChannel.icon,
|
||
},
|
||
channels: filteredElements
|
||
|
||
};
|
||
});
|
||
paymentData = extractedData
|
||
renderPaymentMethods();
|
||
renderPaymentChannels(0); // Show channels for the first payment method by default
|
||
} else {
|
||
layerPopup(res.msg, 3)
|
||
}
|
||
}
|
||
}
|
||
|
||
// 确认支付
|
||
$(".sc-pay-btn").on('click', function () {
|
||
getCreateV(intVpId, intActiveCgId)
|
||
});
|
||
|
||
let strPayUrl = ''
|
||
/**
|
||
* 创建支付订单
|
||
* @param {number} vp_id // 套餐id
|
||
* @param {number} intCgId // 通道id
|
||
*/
|
||
function getCreateV(intVpId, intCgId) {
|
||
|
||
let postData = {
|
||
'vp_id': intVpId,
|
||
'cg_id': intCgId,
|
||
'si_id': strSite,
|
||
}
|
||
if (postData.cg_id == null || postData.cg_id.length == 0) {
|
||
layerPopup('暂无支付渠道,请稍后再试!', 3)
|
||
return false
|
||
}
|
||
fetchApi(apiPayOrderCreate, postData, successFun, onError)
|
||
function successFun(res) {
|
||
console.log(res)
|
||
if (res.code == '000') {
|
||
strPayUrl = res.data.url
|
||
let time = setTimeout(() => {
|
||
$(".sc-pay-jump-popup").show()
|
||
clearTimeout(time)
|
||
}, 3000)
|
||
}
|
||
}
|
||
}
|
||
|
||
//立即跳转
|
||
$(".sc-Jump-immediately-btn").on('click', function () {
|
||
$(".sc-pay-jump-popup").hide()
|
||
window.open(strPayUrl, '_blank');
|
||
});
|
||
}
|
||
|
||
if (document.querySelector(".video-info-html-js")) {
|
||
//点击刷新vip
|
||
$(".rinseNewVip").on("click", () => {
|
||
rinseNewVipFum()
|
||
})
|
||
/**
|
||
* 刷新vip
|
||
*/
|
||
function rinseNewVipFum() {
|
||
if (getLoginStatus()) {
|
||
//用户详情
|
||
let apiUrl = apiGetUserInfo + `?si_id=${strSite}`
|
||
fetchApi(apiUrl, null, successFn, onError)
|
||
function successFn(res) {
|
||
if (res.code == '000') {
|
||
var data = res.data
|
||
|
||
localStorage.setItem(storageObj.userInfo, JSON.stringify(data))
|
||
|
||
if (data.mu_is_vip) {
|
||
// 会员
|
||
localStorage.setItem(storageObj.isMember, true)
|
||
|
||
} else {
|
||
// 不是会员
|
||
localStorage.setItem(storageObj.isMember, false)
|
||
|
||
}
|
||
checkIsMemberFn()
|
||
}
|
||
}
|
||
layerPopup('刷新VIP成功', 3)
|
||
}
|
||
}
|
||
}
|
||
}); |