From 0ebbdb8cb33b28c182fc5c7372a2dee6e2b2bf6e Mon Sep 17 00:00:00 2001
From: james <639143029@qq.com>
Date: Thu, 9 Jan 2020 23:49:16 +0800
Subject: [PATCH] Add multilingual.
---
src/config/global.js | 121 ------------------
src/i18n/en.js | 2 +-
src/i18n/zh.js | 2 +-
src/views/home/components/header/Header.vue | 6 +-
src/views/home/components/nav/Nav.vue | 2 +-
.../home/components/tabbar/ProduceItem.vue | 4 +-
6 files changed, 8 insertions(+), 129 deletions(-)
diff --git a/src/config/global.js b/src/config/global.js
index 28bd466..383a6c5 100644
--- a/src/config/global.js
+++ b/src/config/global.js
@@ -18,127 +18,6 @@ export const removeLocalStore = (name) => {
if (!name) return;
return window.localStorage.removeItem(name);
}
-/**
- *
- * @desc 判断是否为手机号
- * @param {String|Number} str
- * @return {Boolean}
- */
-export const isPhoneNum = (str) => {
- return /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/.test(str)
-}
-
-/**
- *
- * @desc 根据name读取cookie
- * @param {String} name
- * @return {String}
- */
-export const getCookie = (name) => {
- var arr = document.cookie.replace(/\s/g, "").split(';');
- for (var i = 0; i < arr.length; i++) {
- var tempArr = arr[i].split('=');
- if (tempArr[0] == name) {
- return decodeURIComponent(tempArr[1]);
- }
- }
- return '';
-}
-
-/**
- *
- * @desc 设置Cookie
- * @param {String} name
- * @param {String} value
- * @param {Number} days
- */
-export const setCookie = (name, value, days) => {
- var date = new Date();
- date.setDate(date.getDate() + days);
- document.cookie = name + '=' + value + ';expires=' + date;
-}
-
-/**
- *
- * @desc 根据name删除cookie
- * @param {String} name
- */
-export const removeCookie = (name) => {
- // 设置已过期,系统会立刻删除cookie
- setCookie(name, '1', -1);
-}
-
-/**
- *
- * @desc 获取浏览器类型和版本
- * @return {String}
- */
-export const getExplore = () => {
- var sys = {},
- ua = navigator.userAgent.toLowerCase(),
- s;
- (s = ua.match(/rv:([\d.]+)\) like gecko/)) ? sys.ie = s[1]:
- (s = ua.match(/msie ([\d\.]+)/)) ? sys.ie = s[1] :
- (s = ua.match(/edge\/([\d\.]+)/)) ? sys.edge = s[1] :
- (s = ua.match(/firefox\/([\d\.]+)/)) ? sys.firefox = s[1] :
- (s = ua.match(/(?:opera|opr).([\d\.]+)/)) ? sys.opera = s[1] :
- (s = ua.match(/chrome\/([\d\.]+)/)) ? sys.chrome = s[1] :
- (s = ua.match(/version\/([\d\.]+).*safari/)) ? sys.safari = s[1] : 0;
- // 根据关系进行判断
- if (sys.ie) return ('IE: ' + sys.ie)
- if (sys.edge) return ('EDGE: ' + sys.edge)
- if (sys.firefox) return ('Firefox: ' + sys.firefox)
- if (sys.chrome) return ('Chrome: ' + sys.chrome)
- if (sys.opera) return ('Opera: ' + sys.opera)
- if (sys.safari) return ('Safari: ' + sys.safari)
- return 'Unkonwn'
-}
-
-/**
- *
- * @desc 对象序列化
- * @param {Object} obj
- * @return {String}
- */
-export const stringfyQueryString = (obj) => {
- if (!obj) return '';
- var pairs = [];
- for (var key in obj) {
- var value = obj[key];
-
- if (value instanceof Array) {
- for (var i = 0; i < value.length; ++i) {
- pairs.push(encodeURIComponent(key + '[' + i + ']') + '=' + encodeURIComponent(value[i]));
- }
- continue;
- }
-
- pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(obj[key]));
- }
-
- return pairs.join('&');
-}
-
-
-/**
- *
- * @desc 判断是否为身份证号
- * @param {String|Number} str
- * @return {Boolean}
- */
-export const isIdCard = (str) => {
- return /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/.test(str)
-}
-
-/**
- *
- * @desc 判断是否为邮箱地址
- * @param {String} str
- * @return {Boolean}
- */
-let isEmail = (str) => {
- return /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(str);
-}
// 版本信息
export const _VERSION_ = "1.3.0";
\ No newline at end of file
diff --git a/src/i18n/en.js b/src/i18n/en.js
index 4112139..dd3edf6 100644
--- a/src/i18n/en.js
+++ b/src/i18n/en.js
@@ -75,7 +75,7 @@ export default {
mine: {
title: 'Mine',
phone: 'Tel',
- login: 'Login immediately',
+ login: 'Login',
myOrder: 'My order',
allOrder: "View all orders",
myBill: 'My coupon',
diff --git a/src/i18n/zh.js b/src/i18n/zh.js
index 1de2bae..88bc9b6 100644
--- a/src/i18n/zh.js
+++ b/src/i18n/zh.js
@@ -84,7 +84,7 @@ export default {
servier: '联系客服',
servierTime: '客服时间 07:00-22:00',
feedback: '意见反馈',
- switchLanguage: '语言切换',
+ switchLanguage: '语言',
chinese: '中文',
english: '英文',
version: '当前版本',
diff --git a/src/views/home/components/header/Header.vue b/src/views/home/components/header/Header.vue
index 4934b24..05f542e 100644
--- a/src/views/home/components/header/Header.vue
+++ b/src/views/home/components/header/Header.vue
@@ -3,7 +3,7 @@
* @Motto: 求知若渴,虚心若愚
* @Github: https://github.com/Geek-James/ddBuy
* @掘金: https://juejin.im/user/5c4ebc72e51d4511dc7306ce
- * @LastEditTime : 2020-01-06 15:37:30
+ * @LastEditTime : 2020-01-09 23:40:35
* @Description: 首页->顶部搜索栏
* @FilePath: /ddBuy/src/views/home/components/header/Header.vue
-->
@@ -21,7 +21,7 @@