This commit is contained in:
make
2025-04-21 17:49:17 +08:00
parent 7ef217c1b9
commit 2337ab4f7d
942 changed files with 209166 additions and 0 deletions

View File

@@ -0,0 +1,100 @@
import { fetchApi,onError} from '../public/api/fetch.js';
import { getLoginStatus }from '../public/localstorage.js';
import { getValFromBrowserAddress ,pageJumpFn,layerPopup} from '../public/commonFun.js';
import { apiFundsTransactionsList } from '../public/api/index.js';
document.addEventListener('DOMContentLoaded', function () {
// 登录状态
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)
}
})
}()
})

View File

@@ -0,0 +1,121 @@
import { apiBindPhone,apiSmsCode } from '../public/api/index.js';
import { fetchApi,onError} from '../public/api/fetch.js';
import { getLoginStatus }from '../public/localstorage.js';
$(document).ready(function() {
// 登录状态
if (getLoginStatus()) {
//getUserInfo()
}else{
location.href="/login.html"
}
const PHONE_LENGTH = 0;
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 isValidPhone = (phone) => {
if (phone.length !== 11 ) {
$(".sc-public-popup").show()
$(".sc-public-popup .sc-trends-text").text(`请填写正确的手机号码`);
return false;
}
return true;
};
//验证码验证
const isValidCode = (code) => {
if (code.length !== 6 ) {
$(".sc-public-popup").show()
$(".sc-public-popup .sc-trends-text").text(`短信验证码必须是6位数字`);
return false;
}
return true;
};
// 提交表单逻辑
const submitForm = async (isLogin) => {
const strPhoneVal = getValueAndTrim(".sc-phone");
const strCodeVal = getValueAndTrim(".sc-code");
if (isLogin ==1) {
//绑定手机号码
if (isValidPhone(strPhoneVal) && isValidCode(strCodeVal)) {
await handleSubmit(strPhoneVal,strCodeVal);
}
}
};
const handleSubmit = async (strPhone,strVCode,) => {
$(".sc-public-popup").show()
$(".sc-public-popup .sc-trends-text").text(`绑定成功`);
let postData = {
'phone':strPhone,
'vcode':strVCode,
}
fetchApi(apiBindPhone, postData,successFun, onError,false)
function successFun(res) {
if (res.code == '000') {
$("#code").val('')
pageJumpFn({ 'url': '/member/info.html?free_vip_data=' + res.data.free_vip_data, 'url_type': 1 })
localStorage.setItem(storageObj.isBingPhoneReturn, true)
} else if (res.code == '2001') {
layerPopup(res.msg, 3)
} else {
layerPopup(res.msg, 3)
}
}
};
//绑定号码
$('.sc-binding-btn').on('click', function() {
submitForm(1);
});
/**
* 发送验证码
*/
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',
}
fetchApi(apiSmsCode, postData,successFun, onError)
function successFun(res){
if (res.code == '000') {
$(".sc-public-popup").show()
$(".sc-public-popup .sc-trends-text").text(`发送成功,请注意查收`);
}else{
$(".sc-public-popup").show()
$(".sc-public-popup .sc-trends-text").text(`短信已在1分钟内发出请耐心等待`);
}
}
}
}
$(function () {
sendMsg()
//弹窗关闭公共方法2
$(".btn_sty_close").on('click', function () {
$(".sc-prompt-popup").hide()
});
});
});

View File

@@ -0,0 +1,65 @@
import { memberCountDown } from '../public/commonFun.js';
import { fetchApi,onError} from '../public/api/fetch.js';
import { layerPopup} from '../public/commonFun.js';
import { apiPayPackage } from '../public/api/index.js';
import { getLoginStatus }from '../public/localstorage.js';
$(document).ready(function() {
// 登录状态
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}">
<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);
}
}
}
})

View File

@@ -0,0 +1,196 @@
import { getValFromBrowserAddress, checkIsLoginFn, getPublictUserInfo ,layerPopup} from '../public/commonFun.js';
import { apiPayChannele,apiPayOrderCreate } from '../public/api/index.js';
import { fetchApi,onError,strSite} from '../public/api/fetch.js';
import { getLoginStatus }from '../public/localstorage.js';
$(document).ready(function() {
// 登录状态
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)
});
/**
* 创建支付订单
* @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) {
if (res.code == '000') {
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('https://render.alipay.com/p/yuyan/180020040001212700/?cid=wap_dc', '_blank');
});
})

View File

@@ -0,0 +1,93 @@
import { getValFromBrowserAddress,layerPopup} from '../public/commonFun.js';
import {storageObj ,getLoginStatus }from '../public/localstorage.js';
import { apiLoGout ,apiGetUserInfo} from '../public/api/index.js';
import { fetchApi,onError,strSite} from '../public/api/fetch.js';
if (document.querySelector(".infojs")) {
$(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(".settingjs")) {
getSetInfo()
//用户详情
function getSetInfo() {
var data = localStorage.getItem(storageObj.userInfo)
data = JSON.parse(data)
$('.user-phone').text(data.mu_phone)
}
}

View File

@@ -0,0 +1,380 @@
import { layerPopup } from '../public/commonFun-news.js';
import { fetchApi,onError,strSite} from '../public/api/fetch.js';
import { storageObj } from '../public/localstorage.js';
// import { checkoutHuiyuanTip } from '/assets/js/html.js?';
import { apiGetUserInfo,apiLoginByPhone ,apiLoginByEmail,apiReGist} from '../public/api/index.js';
$(document).ready(function() {
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) => {
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') {
//$(".sc-public-popup").show()
layerPopup('注册成功!' ,3)
let time = setTimeout(()=>{
clearTimeout(time)
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()
});
});

View File

@@ -0,0 +1,147 @@
import { layerPopup } from '../public/commonFun.js';
import { resetPasswordByKey, setPasswd } from '../public/api/index.js';
import { fetchApi,onError} from '../public/api/fetch.js';
import { getLoginStatus }from '../public/localstorage.js';
// 登录状态
if (getLoginStatus()) {
//getUserInfo()
}else{
location.href="/login.html"
}
/**
* 展示和隐藏密码
*/
export const showHidePwd = function () {
const inputElements = ['user_old_password', 'user_password', 'user_password2'];
const visibleElements = ['user_old_password_visible_img', 'user_password_visible_img', 'user_password2_visible_img'];
const isVisibleData = [false, false, false];
$('.j-closeEye').on('click', function () {
let index = $(this).data('index')
isVisibleData[index] = !isVisibleData[index];
if (isVisibleData[index]) {
$(`#${inputElements[index]}`).attr('type', 'text');
$(`#${visibleElements[index]}`).removeClass('icon-closeEye');
$(`#${visibleElements[index]}`).addClass('icon-eye1');
} else {
$(`#${inputElements[index]}`).attr('type', 'password');
$(`#${visibleElements[index]}`).addClass('icon-closeEye');
$(`#${visibleElements[index]}`).removeClass('icon-eye1');
}
})
}
/**
* 验证密码格式
* @returns obj
*/
export const verifyPwd = function () {
var strOldPassword = $("#user_old_password").val().replace(/\s*/g, "");
var strNewsPassword = $("#user_password").val().replace(/\s*/g, "");
var strConfirmPassword = $("#user_password2").val().replace(/\s*/g, "");
if (strOldPassword.length < 6) {
layerPopup('当前密码必须由6-20位的数字或者字母组成', 3)
return false;
}
if (strNewsPassword.length < 6) {
layerPopup('新密码必须由6-20位的数字或者字母组成', 3)
return false;
}
if (strConfirmPassword.length < 6) {
layerPopup('确认密码必须由6-20位的数字或者字母组成', 3)
return false;
} else {
if (strConfirmPassword !== strNewsPassword) {
layerPopup('两次密码不匹配,请确认后重新输入', 3)
return false;
}
}
return { 'strOldPassword': strOldPassword, 'strNewsPassword': strNewsPassword }
}
/**
* 修改密码-登录
*/
export const SetPasswdFun = function (strOldPassword, strEwsPassword, strSetPwdKey,Callback) {
let postData = {
'mu_old_password':strOldPassword,
'mu_new_password':strEwsPassword,
'key':strSetPwdKey,
}
fetchApi(resetPasswordByKey, postData,successFun, onError)
function successFun(res){
CallbackFun(res,Callback)
}
}
/**
* 修改密码-个人中心3
*/
export const setPasswdFun2 = function (strOldPassword, strEwsPassword,Callback=null) {
let postData = {
'oldpassword':strOldPassword,
'password':strEwsPassword,
}
fetchApi(setPasswd, postData,successFun, onError)
function successFun(res){
CallbackFun(res,Callback)
}
}
/**
* 处理回调
* @param {*} res
* @param {*} Callback
*/
const CallbackFun = function(res,Callback) {
if(Callback) Callback(res)
if (res.code == '000') {
$("#user_old_password").val('')
$("#user_password").val('')
$("#user_password2").val('');
$('.msg-dialog2').show();
$('.tip-hy').text('修改成功')
} else if (res.code == '2001') {
$('.msg-dialog').show();
$('.tip-hy').text(res.msg)
} else {
$('.msg-dialog').show();
$('.tip-hy').text(res.msg)
}
}
/**
* 邮箱找回密码-登录页入口
*/
export const resetPwdByEmail = function () {
$('.j-reset-pwd-btn').on('click', function () {
layerPopup('重置密码已经发送到你的邮箱,请按邮件里的密码重新登录!',5)
setTimeout(()=>{
location.href="/member/login.html"
},5000)
})
}
/**
* 验证邮箱-个人中心页入口
*/
export const verifyEmail = function () {
$('.j-verify-email-btn').on('click', function () {
layerPopup('重置密码已经发送到你的邮箱,请按邮件里的密码重新登录!',5)
setTimeout(()=>{
location.href="/member/login.html"
},5000)
})
}

View File

@@ -0,0 +1,112 @@
import { apiUserInfoSave } from '../public/api/index.js';
import { fetchApi,onError,strSite} from '../public/api/fetch.js';
import { layerPopup } from '../public/commonFun-news.js';
import { getLoginStatus }from '../public/localstorage.js';
$(document).ready(function() {
// 登录状态
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);
});
});