Skip to content

Commit

Permalink
internalization
Browse files Browse the repository at this point in the history
  • Loading branch information
guomaimang committed Apr 11, 2024
1 parent c5a2a28 commit b8f632b
Show file tree
Hide file tree
Showing 25 changed files with 119 additions and 244 deletions.
10 changes: 0 additions & 10 deletions src/main/resources/static/dist/js/goods-details.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
function contentsPreparation(){
let id = getQueryParam("id");

//请求数据
$.ajax({
url: "/goods/info",
data: {id: id},
type: 'GET',
beforeSend: function (request) {
//设置header值
request.setRequestHeader("jwt", window.localStorage.getItem("jwt"));
},
success: function (r) {
if (r.code === 0 && r.data != null) {
//填充数据 至 card
$('#card-id').text(r.data.id);
$('#card-name').text(r.data.name);
$('#card-title').text(r.data.title);
Expand All @@ -32,27 +29,20 @@ function contentsPreparation(){
}
},
error: function (jqXHR, textStatus, errorThrown) {
// 处理错误
console.log(textStatus, errorThrown);
}
});
}


let editorD;
//富文本编辑器
const E = window.wangEditor;
editorD = new E('#wangEditor')
// 设置编辑区域高度为 400px
editorD.config.height = 800
//配置服务端图片上传地址
editorD.config.uploadImgServer = 'images/upload'
editorD.config.uploadFileName = 'file'
//限制图片大小 2M
editorD.config.uploadImgMaxSize = 2 * 1024 * 1024
//限制一次最多能传几张图片 一次最多上传 1 个图片
editorD.config.uploadImgMaxLength = 1
//插入网络图片的功能
editorD.config.showLinkImg = true
editorD.create();
editorD.disable();
Expand Down
17 changes: 4 additions & 13 deletions src/main/resources/static/dist/js/goods-hall.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
$(function () {

//隐藏错误提示框
$('.alert-danger').css("display", "none");

$('#goodsModal').modal('hide');

$("#jqGrid").jqGrid({
// 设置API
url: '/goods/list',
loadBeforeSend: function(jqXHR) {
jqXHR.setRequestHeader("jwt", window.localStorage.getItem("jwt"));
},
datatype: "json",
colModel: [
// 设置列表表头
{label: 'ID', name: 'id', index: 'id', width: 30, key: true, hidden: false},
{label: 'Name', name: 'name', index: 'name', width: 100},
{label: 'Title', name: 'title', index: 'title', width: 150},
Expand Down Expand Up @@ -43,34 +40,28 @@ $(function () {
order: "order",
},
gridComplete: function () {
//隐藏grid底部滚动条
$("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
},
onSelectRow: function () {
//返回选中的id
let selectedRowIndex = $("#" + this.id).getGridParam('selrow');
//返回点击这行xlmc的值
window.open("/goods-details.html?id=" + selectedRowIndex);
},
});

// 搜索功能
$("#searchButton").click(function(){
let searchEmail = $("#searchInput").val(); //获取输入框的值
let searchEmail = $("#searchInput").val();
$("#jqGrid").jqGrid('setGridParam',{
postData: {'keyword': searchEmail}, //设置postData参数
postData: {'keyword': searchEmail},
page: 1
}).trigger("reloadGrid"); //重新加载JqGrid
}).trigger("reloadGrid");
});

$(window).resize(function () {
$("#jqGrid").setGridWidth($(".card-body").width());
});
});

/**
* jqGrid 重新加载
*/

function reload() {
let page = $("#jqGrid").jqGrid('getGridParam', 'page');
$("#jqGrid").jqGrid('setGridParam', {
Expand Down
61 changes: 13 additions & 48 deletions src/main/resources/static/dist/js/goods-management.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,27 @@
let editorD;

$(function () {
//富文本编辑器
const E = window.wangEditor;
editorD = new E('#wangEditor')
// 设置编辑区域高度为 400px
editorD.config.height = 260
//配置服务端图片上传地址
editorD.config.uploadImgServer = 'images/upload'
editorD.config.uploadFileName = 'file'
//限制图片大小 2M
editorD.config.uploadImgMaxSize = 2 * 1024 * 1024
//限制一次最多能传几张图片 一次最多上传 1 个图片
editorD.config.uploadImgMaxLength = 1
//插入网络图片的功能
editorD.config.showLinkImg = true
editorD.create();


//隐藏错误提示框
$('.alert-danger').css("display", "none");

$('#goodsModal').modal('hide');

$("#jqGrid").jqGrid({
// 设置API
url: 'goods/list',
loadBeforeSend: function(jqXHR) {
jqXHR.setRequestHeader("jwt", window.localStorage.getItem("jwt"));
},
datatype: "json",
colModel: [
// 设置列表表头
{label: 'ID', name: 'id', index: 'id', width: 30, key: true, hidden: false},
{label: 'Name', name: 'name', index: 'name', width: 60},
{label: 'Title', name: 'title', index: 'title', width: 150},
Expand Down Expand Up @@ -61,28 +51,24 @@ $(function () {
order: "order",
},
gridComplete: function () {
//隐藏grid底部滚动条
$("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
},
});

// 搜索功能
$("#searchButton").click(function(){
let searchEmail = $("#searchInput").val(); //获取输入框的值
let searchEmail = $("#searchInput").val();
$("#jqGrid").jqGrid('setGridParam',{
postData: {'keyword': searchEmail}, //设置postData参数
postData: {'keyword': searchEmail},
page: 1
}).trigger("reloadGrid"); //重新加载JqGrid
}).trigger("reloadGrid");
});

$(window).resize(function () {
$("#jqGrid").setGridWidth($(".card-body").width());
});
});

/**
* 数据验证
*/

function validObject() {
let name = $('#modal-name').val();
if (isNull(name)) {
Expand Down Expand Up @@ -139,10 +125,7 @@ function validObject() {
return true;
}

/**
* 重置 modal 表单数据
*/
// Grid 顶部的操作按钮

function addGoods() {
reset();
$('.modal-title').html('Add');
Expand All @@ -156,20 +139,19 @@ function editGoods() {
if (id == null) {
return;
}
//请求数据

$.ajax({
url: "/goods/info",
type: "GET",
data: {
id: id
},
beforeSend: function (request) {
//设置header值

request.setRequestHeader("jwt", window.localStorage.getItem("jwt"));
},
success: function (r) {
if (r.code === 0 && r.data != null) {
//填充数据 至 modal
$('#modal-id').val(r.data.id);
$('#modal-name').val(r.data.name);
$('#modal-title').val(r.data.title);
Expand All @@ -187,7 +169,7 @@ function editGoods() {
});


//显示 modal

$('#goodsModal').modal('show');
}
function previewGoods() {
Expand All @@ -198,14 +180,9 @@ function previewGoods() {
window.open("/goods-details.html?id=" + id);
}

//绑定 modal 表单上的 SAVE 按钮
$('#saveButton').click(async function () {
//验证数据
if (validObject()) {

// Ajax 发送网络请求

// 获取表单数据
let id = $("#modal-id").val();
let name = $("#modal-name").val();
let title = $("#modal-title").val();
Expand All @@ -215,7 +192,6 @@ $('#saveButton').click(async function () {
let isAvailable = $("#modal-isAvailable").val();
let description = editorD.txt.html();

// 将即将发送数据封装为Json, 和 Pojo 对应
let data = {
"id": id,
"name": name,
Expand All @@ -230,25 +206,21 @@ $('#saveButton').click(async function () {
let url;
let method;

// 表示新增操作
if (id === null || id === "" || id === undefined || id < 0) {
url = 'admin/goods/add';
method = 'POST';
}else {
// id>=0表示编辑操作
url = 'admin/goods/edit';
method = 'PUT';
}

// 执行方法
$.ajax({
type: method, //方法类型
dataType: "json", //预期服务器返回的数据类型
url: url, //url
type: method,
dataType: "json",
url: url,
contentType: "application/json; charset=utf-8",
data: JSON.stringify(data),
beforeSend: function (request) {
//设置header值
request.setRequestHeader("jwt", window.localStorage.getItem("jwt"));
},
success: function (r) {
Expand Down Expand Up @@ -276,9 +248,7 @@ $('#saveButton').click(async function () {
});

function reset() {
//隐藏错误提示框
$('.alert-danger').css("display", "none");
//清空数据
$('#modal-id').val('');
$('#modal-name').val('');
$('#modal-title').val('');
Expand All @@ -288,9 +258,7 @@ function reset() {
$('#modal-isAvailable').val(1);
editorD.txt.html('');
}
/**
* jqGrid 重新加载
*/

function reload() {
reset();
let page = $("#jqGrid").jqGrid('getGridParam', 'page');
Expand All @@ -299,10 +267,7 @@ function reload() {
}).trigger("reloadGrid");
}

/**
* jqGrid isFrozen formatter
* @returns {string}
*/

function priceFormatter(cellValue) {
return "HKD " + cellValue;
}
Expand Down
7 changes: 2 additions & 5 deletions src/main/resources/static/dist/js/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ function prepareSSOLink(){


/**
* 用户名称验证,限制输入为邮箱
*
* @param email
* @returns {boolean}
Expand All @@ -36,7 +35,6 @@ function validUserName(email) {
}

/**
* 用户密码验证 最少6位,最多20位字母或数字的组合
*
* @param password
* @returns {boolean}
Expand Down Expand Up @@ -78,14 +76,13 @@ async function login() {

let data = {"email": email, "password":await sha256(password)};
$.ajax({
type: "POST",//方法类型
dataType: "json",//预期服务器返回的数据类型
type: "POST",
dataType: "json",
url: "userauth/login",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(data),

beforeSend: function (request) {
//设置header值
request.setRequestHeader("recaptchaToken", grecaptcha.getResponse());
},

Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/static/dist/js/order-details-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ function contentsPreparation(){
let id = getQueryParam("id");

$.ajax({
type: "GET", //方法类型
dataType: "json", //预期服务器返回的数据类型
type: "GET",
dataType: "json",
url: "/admin/order/info/"+id, //url
contentType: "application/json; charset=utf-8",
beforeSend: function (request) {
//设置header值

request.setRequestHeader("jwt", window.localStorage.getItem("jwt"));
},
success: function (r) {
Expand Down
13 changes: 5 additions & 8 deletions src/main/resources/static/dist/js/order-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ function contentsPreparation(){
let id = getQueryParam("id");

$.ajax({
type: "GET", //方法类型
dataType: "json", //预期服务器返回的数据类型
type: "GET",
dataType: "json",
url: "/order/info/"+id, //url
contentType: "application/json; charset=utf-8",
beforeSend: function (request) {
//设置header值
request.setRequestHeader("jwt", window.localStorage.getItem("jwt"));
},
success: function (r) {
Expand Down Expand Up @@ -122,15 +121,13 @@ function receiverInfoButtonClick() {
let url = "/order/pay";
let method = "POST";

// 执行方法
$.ajax({
type: method, //方法类型
dataType: "json", //预期服务器返回的数据类型
url: url, //url
type: method,
dataType: "json",
url: url,
contentType: "application/json; charset=utf-8",
data: JSON.stringify(data),
beforeSend: function (request) {
//设置header值
request.setRequestHeader("jwt", window.localStorage.getItem("jwt"));
},
success: function (r) {
Expand Down
Loading

0 comments on commit b8f632b

Please sign in to comment.