|
@@ -5,292 +5,321 @@
|
|
*/
|
|
*/
|
|
// import requestUrl from './config.js'
|
|
// import requestUrl from './config.js'
|
|
const caimeiApi = {
|
|
const caimeiApi = {
|
|
- /**
|
|
|
|
|
|
+ /**
|
|
* @封装公共get数据请求方法无加载动画
|
|
* @封装公共get数据请求方法无加载动画
|
|
* @方法参数:请求地址,请求后台需要的参数字段,回调函数
|
|
* @方法参数:请求地址,请求后台需要的参数字段,回调函数
|
|
* @自定义请求头信息
|
|
* @自定义请求头信息
|
|
*/
|
|
*/
|
|
- get:function(url,data,callback){
|
|
|
|
|
|
+ get:function(url,data,callback){
|
|
uni.request({
|
|
uni.request({
|
|
- url: requestUrl + url,
|
|
|
|
- data:data,
|
|
|
|
- header: {
|
|
|
|
- 'Accept': 'application/json',
|
|
|
|
- 'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
|
- 'X-Token': uni.getStorageSync('token') ? uni.getStorageSync('token') : 'token',
|
|
|
|
- 'cookie': uni.getStorageSync('sessionid')
|
|
|
|
- },
|
|
|
|
- method: 'GET',
|
|
|
|
- success: (response) => {
|
|
|
|
- if(response.statusCode !== 200){
|
|
|
|
- uni.showToast({icon: 'none',title:'服务器连接错误',duration: 2000})
|
|
|
|
- callback(response.statusCode);
|
|
|
|
- }else{
|
|
|
|
- callback(response.data);
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- fail: (error) => {
|
|
|
|
- if (error) {
|
|
|
|
- uni.showToast({icon: 'none',title: '网络错误,请稍后重试',duration: 2000})
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- /**
|
|
|
|
|
|
+ url: requestUrl + url,
|
|
|
|
+ data:data,
|
|
|
|
+ header: {
|
|
|
|
+ 'Accept': 'application/json',
|
|
|
|
+ 'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
|
+ 'X-Token': uni.getStorageSync('token') ? uni.getStorageSync('token') : 'token',
|
|
|
|
+ 'cookie': uni.getStorageSync('sessionid')
|
|
|
|
+ },
|
|
|
|
+ method: 'GET',
|
|
|
|
+ success: (response) => {
|
|
|
|
+ if(response.statusCode !== 200){
|
|
|
|
+ uni.showToast({icon: 'none',title:'服务器连接错误',duration: 2000})
|
|
|
|
+ callback(response.statusCode)
|
|
|
|
+ }else{
|
|
|
|
+ callback(response.data)
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ fail: (error) => {
|
|
|
|
+ if (error) {
|
|
|
|
+ uni.showToast({icon: 'none',title: '网络错误,请稍后重试',duration: 2000})
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ /**
|
|
* @封装公共get数据请求方法有加载动画
|
|
* @封装公共get数据请求方法有加载动画
|
|
* @方法参数:请求地址,请求后台需要的参数字段,回调函数
|
|
* @方法参数:请求地址,请求后台需要的参数字段,回调函数
|
|
* @自定义请求头信息
|
|
* @自定义请求头信息
|
|
*/
|
|
*/
|
|
- lodingGet:function(url,data,callback){
|
|
|
|
- uni.showLoading({mask: true,title:'加载中~',});
|
|
|
|
|
|
+ lodingGet:function(url,data,callback){
|
|
|
|
+ uni.showLoading({mask: true,title:'加载中~',})
|
|
uni.request({
|
|
uni.request({
|
|
- url: requestUrl + url,
|
|
|
|
- data:data,
|
|
|
|
- header: {
|
|
|
|
- 'Accept': 'application/json',
|
|
|
|
- 'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
|
- 'X-Token': uni.getStorageSync('token') ? uni.getStorageSync('token') : 'token',
|
|
|
|
- 'cookie': uni.getStorageSync('sessionid')
|
|
|
|
- },
|
|
|
|
- method: 'GET',
|
|
|
|
- success: (response) => {
|
|
|
|
- if(response.statusCode !== 200){
|
|
|
|
- uni.showToast({icon: 'none',title: '服务器连接错误',duration: 2000})
|
|
|
|
- callback(response.statusCode);
|
|
|
|
- }else{
|
|
|
|
- callback(response.data);
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- fail: (error) => {
|
|
|
|
- if (error) {
|
|
|
|
- uni.showToast({icon: 'none',title: '网络错误,请稍后重试',duration: 2000})
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- complete: () => {
|
|
|
|
- setTimeout(function () {
|
|
|
|
- uni.hideLoading();
|
|
|
|
- }, 250);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- /**
|
|
|
|
|
|
+ url: requestUrl + url,
|
|
|
|
+ data:data,
|
|
|
|
+ header: {
|
|
|
|
+ 'Accept': 'application/json',
|
|
|
|
+ 'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
|
+ 'X-Token': uni.getStorageSync('token') ? uni.getStorageSync('token') : 'token',
|
|
|
|
+ 'cookie': uni.getStorageSync('sessionid')
|
|
|
|
+ },
|
|
|
|
+ method: 'GET',
|
|
|
|
+ success: (response) => {
|
|
|
|
+ if(response.statusCode !== 200){
|
|
|
|
+ uni.showToast({icon: 'none',title: '服务器连接错误',duration: 2000})
|
|
|
|
+ callback(response.statusCode)
|
|
|
|
+ }else{
|
|
|
|
+ callback(response.data)
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ fail: (error) => {
|
|
|
|
+ if (error) {
|
|
|
|
+ uni.showToast({icon: 'none',title: '网络错误,请稍后重试',duration: 2000})
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ complete: () => {
|
|
|
|
+ setTimeout(function () {
|
|
|
|
+ uni.hideLoading()
|
|
|
|
+ }, 250)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ /**
|
|
* @封装公共post数据请求方法
|
|
* @封装公共post数据请求方法
|
|
* @方法参数:请求地址,请求后台需要的参数字段,回调函数
|
|
* @方法参数:请求地址,请求后台需要的参数字段,回调函数
|
|
*/
|
|
*/
|
|
- post:function(url,data,loadingStatus,callback){
|
|
|
|
- if(loadingStatus){uni.showLoading({mask: true,title:'加载中~'})}
|
|
|
|
- uni.request({
|
|
|
|
- url: requestUrl+url,
|
|
|
|
- data:data,
|
|
|
|
- header: {
|
|
|
|
- 'Accept': 'application/json',
|
|
|
|
- 'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
|
- 'X-Token': uni.getStorageSync('token') ? uni.getStorageSync('token') : 'token',
|
|
|
|
- 'cookie': uni.getStorageSync('sessionid')
|
|
|
|
- },
|
|
|
|
- method: 'POST',
|
|
|
|
- success: (response) => {
|
|
|
|
- if(loadingStatus){uni.hideLoading()}
|
|
|
|
- const result = response.data
|
|
|
|
- callback(result)
|
|
|
|
- },
|
|
|
|
- fail: (error) => {
|
|
|
|
- uni.hideLoading()
|
|
|
|
- if (error) {
|
|
|
|
- uni.showToast({icon: 'none',title: '网络错误,请稍后重试',duration: 2000})
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- getComStorage:function(key){// 获取本地Storage
|
|
|
|
- return new Promise(function(resolve,reject) {
|
|
|
|
- uni.getStorage({
|
|
|
|
- key: key,
|
|
|
|
- success: function (res){
|
|
|
|
- resolve(res.data);
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- setStorage:function(key,data){// 存储本地Storage
|
|
|
|
- return new Promise(function(resolve,reject) {
|
|
|
|
- uni.setStorage({
|
|
|
|
- key: key,
|
|
|
|
- data:data,
|
|
|
|
- success: function (res){
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- getStorage:function(){// 获取本地userInfo
|
|
|
|
- return new Promise(function(resolve,reject) {
|
|
|
|
- uni.getStorage({
|
|
|
|
- key: 'userInfo',
|
|
|
|
- success: function (res){
|
|
|
|
- resolve(res.data);
|
|
|
|
- },
|
|
|
|
- fail: function(res){
|
|
|
|
- reject(false)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- getStorageAddressKey:function(){// 获取本地地址信息
|
|
|
|
- return new Promise(function(resolve,reject) {
|
|
|
|
- uni.getStorage({
|
|
|
|
- key: 'address_key',
|
|
|
|
- success: function (res){
|
|
|
|
- resolve(res.data);
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- loginStatus:function(){
|
|
|
|
- // 获取用户是否登陆 1:已登陆,否则未登陆
|
|
|
|
- return new Promise(function(resolve,reject) {
|
|
|
|
- uni.getStorage({
|
|
|
|
- key: 'userInfo',
|
|
|
|
- success: function (res){
|
|
|
|
- if(res.data.code == '1'){
|
|
|
|
- resolve(true);
|
|
|
|
- } else {
|
|
|
|
- resolve(false);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- navToListPage:function({type,value,id,lType} = {}){
|
|
|
|
- // 跳转到列表页
|
|
|
|
- if(lType=='4'){
|
|
|
|
- const pages = getCurrentPages();
|
|
|
|
- const prevPage = pages[pages.length-2];
|
|
|
|
- prevPage.refresh = true;
|
|
|
|
- prevPage.listData = {
|
|
|
|
- type: type,
|
|
|
|
- from: value,
|
|
|
|
- id: id
|
|
|
|
- }
|
|
|
|
- uni.navigateBack({
|
|
|
|
- delta: 1
|
|
|
|
- })
|
|
|
|
- }else{
|
|
|
|
- uni.navigateTo({
|
|
|
|
- url:`/pages/goods/goods?type=${type}&from=${value}&id=${id}`
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- navigateTo:function(url){
|
|
|
|
- //路由跳转:页面之间路由跳转
|
|
|
|
- uni.navigateTo({
|
|
|
|
- url:url
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- redirectTo:function(url){
|
|
|
|
- //路由跳转:关闭当前页跳转到新页面
|
|
|
|
- uni.redirectTo({
|
|
|
|
- url:url
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- switchTabTo:function(url){
|
|
|
|
- //路由跳转:底部 tab页
|
|
|
|
- uni.switchTab({
|
|
|
|
- url:url
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- isNumber:function(value){
|
|
|
|
- //验证是否为数字
|
|
|
|
- var patrn = /^(-)?\d+(\.\d+)?$/;
|
|
|
|
- if (patrn.exec(value) == null || value == "") {
|
|
|
|
|
|
+ post:function(url,data,loadingStatus,callback){
|
|
|
|
+ if(loadingStatus){uni.showLoading({mask: true,title:'加载中~'})}
|
|
|
|
+ uni.request({
|
|
|
|
+ url: requestUrl+url,
|
|
|
|
+ data:data,
|
|
|
|
+ header: {
|
|
|
|
+ 'Accept': 'application/json',
|
|
|
|
+ 'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
|
+ 'X-Token': uni.getStorageSync('token') ? uni.getStorageSync('token') : 'token',
|
|
|
|
+ 'cookie': uni.getStorageSync('sessionid')
|
|
|
|
+ },
|
|
|
|
+ method: 'POST',
|
|
|
|
+ success: (response) => {
|
|
|
|
+ if(loadingStatus){uni.hideLoading()}
|
|
|
|
+ const result = response.data
|
|
|
|
+ callback(result)
|
|
|
|
+ },
|
|
|
|
+ fail: (error) => {
|
|
|
|
+ uni.hideLoading()
|
|
|
|
+ if (error) {
|
|
|
|
+ uni.showToast({icon: 'none',title: '网络错误,请稍后重试',duration: 2000})
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ getComStorage:function(key){// 获取本地Storage
|
|
|
|
+ return new Promise(function(resolve,reject) {
|
|
|
|
+ uni.getStorage({
|
|
|
|
+ key: key,
|
|
|
|
+ success: function (res){
|
|
|
|
+ resolve(res.data)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ setStorage:function(key,data){// 存储本地Storage
|
|
|
|
+ return new Promise(function(resolve,reject) {
|
|
|
|
+ uni.setStorage({
|
|
|
|
+ key: key,
|
|
|
|
+ data:data,
|
|
|
|
+ success: function (res){
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ getStorage:function(){// 获取本地userInfo
|
|
|
|
+ return new Promise(function(resolve,reject) {
|
|
|
|
+ uni.getStorage({
|
|
|
|
+ key: 'userInfo',
|
|
|
|
+ success: function (res){
|
|
|
|
+ resolve(res.data)
|
|
|
|
+ },
|
|
|
|
+ fail: function(res){
|
|
|
|
+ reject(false)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ getStorageAddressKey:function(){// 获取本地地址信息
|
|
|
|
+ return new Promise(function(resolve,reject) {
|
|
|
|
+ uni.getStorage({
|
|
|
|
+ key: 'address_key',
|
|
|
|
+ success: function (res){
|
|
|
|
+ resolve(res.data)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ loginStatus:function(){
|
|
|
|
+ // 获取用户是否登陆 1:已登陆,否则未登陆
|
|
|
|
+ return new Promise(function(resolve,reject) {
|
|
|
|
+ uni.getStorage({
|
|
|
|
+ key: 'userInfo',
|
|
|
|
+ success: function (res){
|
|
|
|
+ if(res.data.code == '1'){
|
|
|
|
+ resolve(true)
|
|
|
|
+ } else {
|
|
|
|
+ resolve(false)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ navToListPage:function({type,value,id,lType} = {}){
|
|
|
|
+ // 跳转到列表页
|
|
|
|
+ if(lType=='4'){
|
|
|
|
+ const pages = getCurrentPages()
|
|
|
|
+ const prevPage = pages[pages.length-2]
|
|
|
|
+ prevPage.refresh = true
|
|
|
|
+ prevPage.listData = {
|
|
|
|
+ type: type,
|
|
|
|
+ from: value,
|
|
|
|
+ id: id
|
|
|
|
+ }
|
|
|
|
+ uni.navigateBack({
|
|
|
|
+ delta: 1
|
|
|
|
+ })
|
|
|
|
+ }else{
|
|
|
|
+ uni.navigateTo({
|
|
|
|
+ url:`/pages/goods/goods?type=${type}&from=${value}&id=${id}`
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ navigateTo:function(url){
|
|
|
|
+ //路由跳转:页面之间路由跳转
|
|
|
|
+ uni.navigateTo({
|
|
|
|
+ url:url
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ redirectTo:function(url){
|
|
|
|
+ //路由跳转:关闭当前页跳转到新页面
|
|
|
|
+ uni.redirectTo({
|
|
|
|
+ url:url
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ switchTabTo:function(url){
|
|
|
|
+ //路由跳转:底部 tab页
|
|
|
|
+ uni.switchTab({
|
|
|
|
+ url:url
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ isNumber:function(value){
|
|
|
|
+ //验证是否为数字
|
|
|
|
+ var patrn = /^(-)?\d+(\.\d+)?$/
|
|
|
|
+ if (patrn.exec(value) == null || value == '') {
|
|
return false
|
|
return false
|
|
} else {
|
|
} else {
|
|
return true
|
|
return true
|
|
- }
|
|
|
|
- },
|
|
|
|
- getWindowHeight:function(){
|
|
|
|
- // 获取窗口高度
|
|
|
|
- const {windowHeight, pixelRatio} = wx.getSystemInfoSync();
|
|
|
|
- return windowHeight;
|
|
|
|
- },
|
|
|
|
- adaptRichTextImg:function(res){
|
|
|
|
- /**
|
|
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ getWindowHeight:function(){
|
|
|
|
+ // 获取窗口高度
|
|
|
|
+ const {windowHeight, pixelRatio} = wx.getSystemInfoSync()
|
|
|
|
+ return windowHeight
|
|
|
|
+ },
|
|
|
|
+ adaptRichTextImg:function(res){
|
|
|
|
+ /**
|
|
*@富文本实现图片自适应
|
|
*@富文本实现图片自适应
|
|
*@style再添加自适应样式
|
|
*@style再添加自适应样式
|
|
*/
|
|
*/
|
|
- const html = res.replace(/<img[^>]*>/gi,function(match,capture){
|
|
|
|
- let match1 = match.replace(/<img*/gi, '<img style="width:100% !important;height:auto !important;float:left !important;"'),
|
|
|
|
- results = match1.replace(/style=/gi, 'style="width:100%;height:auto;float:left;"');
|
|
|
|
- return results;
|
|
|
|
- })
|
|
|
|
- return html;
|
|
|
|
- },
|
|
|
|
- FormatMoney:function(num){
|
|
|
|
- // 金额千分位
|
|
|
|
- return num.toString().replace(/\d+/, function (n) { // 先提取整数部分
|
|
|
|
- return n.replace(/(\d)(?=(\d{3})+$)/g, function ($1) { // 对整数部分添加分隔符
|
|
|
|
- return $1 + ",";
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- formatDate:function(){
|
|
|
|
- //获取当前时间
|
|
|
|
- let date = new Date();
|
|
|
|
- let y = date.getFullYear();
|
|
|
|
- let MM = date.getMonth() + 1;
|
|
|
|
- MM = MM < 10 ? ('0' + MM) : MM;
|
|
|
|
- let d = date.getDate();
|
|
|
|
- d = d < 10 ? ('0' + d) : d;
|
|
|
|
- let h = date.getHours();
|
|
|
|
- h = h < 10 ? ('0' + h) : h;
|
|
|
|
- let m = date.getMinutes();
|
|
|
|
- m = m < 10 ? ('0' + m) : m;
|
|
|
|
- let s = date.getSeconds();
|
|
|
|
- s = s < 10 ? ('0' + s) : s;
|
|
|
|
- return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s;
|
|
|
|
- },
|
|
|
|
- regexSets:function() {
|
|
|
|
- let sets = {
|
|
|
|
- 'companyName': /^[\u4e00-\u9fa5\(\)()\s\da-zA-Z&]{2,50}$/gi,
|
|
|
|
- 'phoneAndTelephone': /^([1]\d{10}|([\((]?0[0-9]{2,3}[)\)]?[-]?)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?)$/,
|
|
|
|
- 'bankNum': /^([1-9]{1})(\d{18})$/,
|
|
|
|
- 'invalidChar': /^[\s\u4e00-\u9fa5a-z0-9_-]{0,}$/
|
|
|
|
- };
|
|
|
|
- return sets;
|
|
|
|
- },
|
|
|
|
- timestampToTime:function(timestamp) {
|
|
|
|
- // 时间戳转日期
|
|
|
|
- let date = new Date(timestamp * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
|
|
|
|
- let Y = date.getFullYear() + '-';
|
|
|
|
- let M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
|
|
|
|
- let D = (date.getDate() < 10 ? '0'+date.getDate() : date.getDate()) + ' ';
|
|
|
|
- let h = (date.getHours() < 10 ? '0'+date.getHours() : date.getHours()) + ':';
|
|
|
|
- let m = (date.getMinutes() < 10 ? '0'+date.getMinutes() : date.getMinutes()) + ':';
|
|
|
|
- let s = (date.getSeconds() < 10 ? '0'+date.getSeconds() : date.getSeconds());
|
|
|
|
- return `${Y}${M}${D}${h}${m}${s}`;
|
|
|
|
- }
|
|
|
|
|
|
+ const html = res.replace(/<img[^>]*>/gi,function(match,capture){
|
|
|
|
+ let match1 = match.replace(/<img*/gi, '<img style="width:100% !important;height:auto !important;float:left !important;"'),
|
|
|
|
+ results = match1.replace(/style=/gi, 'style="width:100%;height:auto;float:left;"')
|
|
|
|
+ return results
|
|
|
|
+ })
|
|
|
|
+ return html
|
|
|
|
+ },
|
|
|
|
+ FormatMoney:function(num){
|
|
|
|
+ // 金额千分位
|
|
|
|
+ return num.toString().replace(/\d+/, function (n) { // 先提取整数部分
|
|
|
|
+ return n.replace(/(\d)(?=(\d{3})+$)/g, function ($1) { // 对整数部分添加分隔符
|
|
|
|
+ return $1 + ','
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ formatDate:function(){
|
|
|
|
+ //获取当前时间
|
|
|
|
+ let date = new Date()
|
|
|
|
+ let y = date.getFullYear()
|
|
|
|
+ let MM = date.getMonth() + 1
|
|
|
|
+ MM = MM < 10 ? ('0' + MM) : MM
|
|
|
|
+ let d = date.getDate()
|
|
|
|
+ d = d < 10 ? ('0' + d) : d
|
|
|
|
+ let h = date.getHours()
|
|
|
|
+ h = h < 10 ? ('0' + h) : h
|
|
|
|
+ let m = date.getMinutes()
|
|
|
|
+ m = m < 10 ? ('0' + m) : m
|
|
|
|
+ let s = date.getSeconds()
|
|
|
|
+ s = s < 10 ? ('0' + s) : s
|
|
|
|
+ return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s
|
|
|
|
+ },
|
|
|
|
+ regexSets:function() {
|
|
|
|
+ let sets = {
|
|
|
|
+ 'companyName': /^[\u4e00-\u9fa5\(\)()\s\da-zA-Z&]{2,50}$/gi,
|
|
|
|
+ 'phoneAndTelephone': /^([1]\d{10}|([\((]?0[0-9]{2,3}[)\)]?[-]?)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?)$/,
|
|
|
|
+ 'bankNum': /^([1-9]{1})(\d{18})$/,
|
|
|
|
+ 'invalidChar': /^[\s\u4e00-\u9fa5a-z0-9_-]{0,}$/
|
|
|
|
+ }
|
|
|
|
+ return sets
|
|
|
|
+ },
|
|
|
|
+ timestampToTime:function(timestamp) {
|
|
|
|
+ // 时间戳转日期
|
|
|
|
+ let date = new Date(timestamp * 1000)//时间戳为10位需*1000,时间戳为13位的话不需乘1000
|
|
|
|
+ let Y = date.getFullYear() + '-'
|
|
|
|
+ let M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-'
|
|
|
|
+ let D = (date.getDate() < 10 ? '0'+date.getDate() : date.getDate()) + ' '
|
|
|
|
+ let h = (date.getHours() < 10 ? '0'+date.getHours() : date.getHours()) + ':'
|
|
|
|
+ let m = (date.getMinutes() < 10 ? '0'+date.getMinutes() : date.getMinutes()) + ':'
|
|
|
|
+ let s = (date.getSeconds() < 10 ? '0'+date.getSeconds() : date.getSeconds())
|
|
|
|
+ return `${Y}${M}${D}${h}${m}${s}`
|
|
|
|
+ },
|
|
|
|
+ getNowFormatDate:function () {
|
|
|
|
+ var date = new Date()
|
|
|
|
+ var seperator1 = '-'
|
|
|
|
+ var year = date.getFullYear()
|
|
|
|
+ var month = date.getMonth() + 1
|
|
|
|
+ var strDate = date.getDate()
|
|
|
|
+ var bours =date.getHours()
|
|
|
|
+ var min = date.getMinutes()
|
|
|
|
+ var s = date.getSeconds()
|
|
|
|
+ if (month >= 1 && month <= 9) {
|
|
|
|
+ month = '0' + month
|
|
|
|
+ }
|
|
|
|
+ if (strDate >= 0 && strDate <= 9) {
|
|
|
|
+ strDate = '0' + strDate
|
|
|
|
+ }
|
|
|
|
+ if (bours >= 0 && bours <= 9) {
|
|
|
|
+ bours = '0' + bours
|
|
|
|
+ }
|
|
|
|
+ if (min >= 0 && min <= 9) {
|
|
|
|
+ min = '0' + min
|
|
|
|
+ }
|
|
|
|
+ if (s >= 0 && s <= 9) {
|
|
|
|
+ s = '0' + s
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var currentdate = year + seperator1 + month + seperator1 + strDate +' ' + bours+ ':'+ min+ ':'+ s
|
|
|
|
+ return currentdate
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
*@导出
|
|
*@导出
|
|
*/
|
|
*/
|
|
module.exports = {
|
|
module.exports = {
|
|
- get: caimeiApi.get,
|
|
|
|
- post: caimeiApi.post,
|
|
|
|
- lodingGet: caimeiApi.lodingGet,
|
|
|
|
- isNumber: caimeiApi.isNumber,
|
|
|
|
- FormatMoney: caimeiApi.FormatMoney,
|
|
|
|
- navigateTo: caimeiApi.navigateTo,
|
|
|
|
- redirectTo: caimeiApi.redirectTo,
|
|
|
|
- switchTabTo: caimeiApi.switchTabTo,
|
|
|
|
- formatDate: caimeiApi.formatDate,
|
|
|
|
- loginStatus: caimeiApi.loginStatus,
|
|
|
|
- setStorage: caimeiApi.setStorage,
|
|
|
|
- getStorage: caimeiApi.getStorage,
|
|
|
|
- getComStorage: caimeiApi.getComStorage,
|
|
|
|
- navToListPage: caimeiApi.navToListPage,
|
|
|
|
- getWindowHeight: caimeiApi.getWindowHeight,
|
|
|
|
- adaptRichTextImg: caimeiApi.adaptRichTextImg,
|
|
|
|
- getStorageAddressKey: caimeiApi.getStorageAddressKey,
|
|
|
|
- regexSets: caimeiApi.regexSets,
|
|
|
|
- timestampToTime: caimeiApi.timestampToTime
|
|
|
|
-};
|
|
|
|
|
|
+ get: caimeiApi.get,
|
|
|
|
+ post: caimeiApi.post,
|
|
|
|
+ lodingGet: caimeiApi.lodingGet,
|
|
|
|
+ isNumber: caimeiApi.isNumber,
|
|
|
|
+ FormatMoney: caimeiApi.FormatMoney,
|
|
|
|
+ navigateTo: caimeiApi.navigateTo,
|
|
|
|
+ redirectTo: caimeiApi.redirectTo,
|
|
|
|
+ switchTabTo: caimeiApi.switchTabTo,
|
|
|
|
+ formatDate: caimeiApi.formatDate,
|
|
|
|
+ loginStatus: caimeiApi.loginStatus,
|
|
|
|
+ setStorage: caimeiApi.setStorage,
|
|
|
|
+ getStorage: caimeiApi.getStorage,
|
|
|
|
+ getComStorage: caimeiApi.getComStorage,
|
|
|
|
+ navToListPage: caimeiApi.navToListPage,
|
|
|
|
+ getWindowHeight: caimeiApi.getWindowHeight,
|
|
|
|
+ adaptRichTextImg: caimeiApi.adaptRichTextImg,
|
|
|
|
+ getStorageAddressKey: caimeiApi.getStorageAddressKey,
|
|
|
|
+ regexSets: caimeiApi.regexSets,
|
|
|
|
+ timestampToTime: caimeiApi.timestampToTime,
|
|
|
|
+ getNowFormatDate : caimeiApi.getNowFormatDate
|
|
|
|
+}
|