|
@@ -24,9 +24,9 @@ const caimeiApi = {
|
|
|
success: (response) => {
|
|
|
if(response.statusCode !== 200){
|
|
|
uni.showToast({icon: 'none',title:'服务器连接错误',duration: 2000})
|
|
|
- callback(response.statusCode);
|
|
|
+ callback(response.statusCode)
|
|
|
}else{
|
|
|
- callback(response.data);
|
|
|
+ callback(response.data)
|
|
|
}
|
|
|
},
|
|
|
fail: (error) => {
|
|
@@ -34,7 +34,7 @@ const caimeiApi = {
|
|
|
uni.showToast({icon: 'none',title: '网络错误,请稍后重试',duration: 2000})
|
|
|
}
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
/**
|
|
|
* @封装公共get数据请求方法有加载动画
|
|
@@ -42,7 +42,7 @@ const caimeiApi = {
|
|
|
* @自定义请求头信息
|
|
|
*/
|
|
|
lodingGet:function(url,data,callback){
|
|
|
- uni.showLoading({mask: true,title:'加载中~',});
|
|
|
+ uni.showLoading({mask: true,title:'加载中~',})
|
|
|
uni.request({
|
|
|
url: requestUrl + url,
|
|
|
data:data,
|
|
@@ -56,9 +56,9 @@ const caimeiApi = {
|
|
|
success: (response) => {
|
|
|
if(response.statusCode !== 200){
|
|
|
uni.showToast({icon: 'none',title: '服务器连接错误',duration: 2000})
|
|
|
- callback(response.statusCode);
|
|
|
+ callback(response.statusCode)
|
|
|
}else{
|
|
|
- callback(response.data);
|
|
|
+ callback(response.data)
|
|
|
}
|
|
|
},
|
|
|
fail: (error) => {
|
|
@@ -68,16 +68,17 @@ const caimeiApi = {
|
|
|
},
|
|
|
complete: () => {
|
|
|
setTimeout(function () {
|
|
|
- uni.hideLoading();
|
|
|
- }, 250);
|
|
|
+ uni.hideLoading()
|
|
|
+ }, 250)
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
/**
|
|
|
* @封装公共post数据请求方法
|
|
|
* @方法参数:请求地址,请求后台需要的参数字段,回调函数
|
|
|
*/
|
|
|
post:function(url,data,loadingStatus,callback){
|
|
|
+ console.info(data)
|
|
|
if(loadingStatus){uni.showLoading({mask: true,title:'加载中~'})}
|
|
|
uni.request({
|
|
|
url: requestUrl+url,
|
|
@@ -85,11 +86,11 @@ const caimeiApi = {
|
|
|
header: {
|
|
|
'Accept': 'application/json',
|
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
- 'X-Token': uni.getStorageSync('token') ? uni.getStorageSync('token') : 'token',
|
|
|
- 'cookie': uni.getStorageSync('sessionid')
|
|
|
+ // 'Content-Type': 'application/json',
|
|
|
},
|
|
|
method: 'POST',
|
|
|
success: (response) => {
|
|
|
+ console.log(response)
|
|
|
if(loadingStatus){uni.hideLoading()}
|
|
|
const result = response.data
|
|
|
callback(result)
|
|
@@ -107,13 +108,13 @@ const caimeiApi = {
|
|
|
uni.getStorage({
|
|
|
key: key,
|
|
|
success: function (res){
|
|
|
- resolve(res.data);
|
|
|
+ resolve(res.data)
|
|
|
},
|
|
|
fail: function(res){
|
|
|
reject(false)
|
|
|
}
|
|
|
})
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
setStorage:function(key,data){// 存储本地Storage
|
|
|
return new Promise(function(resolve,reject) {
|
|
@@ -123,30 +124,30 @@ const caimeiApi = {
|
|
|
success: function (res){
|
|
|
}
|
|
|
})
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
getStorage:function(){// 获取本地userInfo
|
|
|
return new Promise(function(resolve,reject) {
|
|
|
uni.getStorage({
|
|
|
key: 'userInfo',
|
|
|
success: function (res){
|
|
|
- resolve(res.data);
|
|
|
+ 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);
|
|
|
+ resolve(res.data)
|
|
|
}
|
|
|
})
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
loginStatus:function(){
|
|
|
// 获取用户是否登陆 1:已登陆,否则未登陆
|
|
@@ -155,20 +156,20 @@ const caimeiApi = {
|
|
|
key: 'userInfo',
|
|
|
success: function (res){
|
|
|
if(res.data.code == '1'){
|
|
|
- resolve(true);
|
|
|
+ resolve(true)
|
|
|
} else {
|
|
|
- resolve(false);
|
|
|
+ resolve(false)
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
navToListPage:function({type,value,id,lType} = {}){
|
|
|
// 跳转到列表页
|
|
|
if(lType=='4'){
|
|
|
- const pages = getCurrentPages();
|
|
|
- const prevPage = pages[pages.length-2];
|
|
|
- prevPage.refresh = true;
|
|
|
+ const pages = getCurrentPages()
|
|
|
+ const prevPage = pages[pages.length-2]
|
|
|
+ prevPage.refresh = true
|
|
|
prevPage.listData = {
|
|
|
type: type,
|
|
|
from: value,
|
|
@@ -186,9 +187,9 @@ const caimeiApi = {
|
|
|
navigateToGoods:function({type,value,id,lType} = {}){
|
|
|
// 跳转到列表页
|
|
|
if(lType=='4'){
|
|
|
- const pages = getCurrentPages();
|
|
|
- const prevPage = pages[pages.length-2];
|
|
|
- prevPage.refresh = true;
|
|
|
+ const pages = getCurrentPages()
|
|
|
+ const prevPage = pages[pages.length-2]
|
|
|
+ prevPage.refresh = true
|
|
|
prevPage.listData = {
|
|
|
type: type,
|
|
|
from: value,
|
|
@@ -229,21 +230,21 @@ const caimeiApi = {
|
|
|
4:`/h5/pages/activity/activity?title=${pros.crmTitle}&link=${pros.crmLink}`,
|
|
|
5:`/pages/goods/product?id=${pros.linkParam.id}`,
|
|
|
7:`/supplier/pages/user/my-shop?shopId=${pros.linkParam.id}`,
|
|
|
- 8:`/h5/pages/activity/activity-list`,
|
|
|
- 9:`/second/pages/form/introduce`,
|
|
|
- 10:`/second/pages/product/product-list`,
|
|
|
- 11:`/second/pages/form/form`,
|
|
|
+ 8:'/h5/pages/activity/activity-list',
|
|
|
+ 9:'/second/pages/form/introduce',
|
|
|
+ 10:'/second/pages/product/product-list',
|
|
|
+ 11:'/second/pages/form/form',
|
|
|
12:`/search/pages/search/search?keyWord=${pros.linkParam.keyword}`,
|
|
|
13:`/h5/pages/article/path?link=${pros.link}`,
|
|
|
14:`/h5/pages/article/path?link=${pros.link}`,
|
|
|
15:`/h5/pages/article/path?link=${pros.link}`,
|
|
|
- 17:`/pages/login/register-select`,
|
|
|
+ 17:'/pages/login/register-select',
|
|
|
18:`/h5/pages/article/path?link=${pros.link}`,
|
|
|
19:`/search/pages/search/search-supplier?keyWord=${pros.linkParam.keyword}`,
|
|
|
- 21:`/h5/pages/activity/meobohui`
|
|
|
+ 21:'/h5/pages/activity/meobohui'
|
|
|
|
|
|
}
|
|
|
- const url = typeMap[pros.linkType];
|
|
|
+ const url = typeMap[pros.linkType]
|
|
|
uni.navigateTo({
|
|
|
url:url
|
|
|
})
|
|
@@ -258,20 +259,20 @@ const caimeiApi = {
|
|
|
4:`/h5/pages/activity/activity?id=${linkId}`,
|
|
|
5:`/pages/goods/product?id=${linkId}`,
|
|
|
7:`/supplier/pages/user/my-shop?shopId=${linkId}`,
|
|
|
- 8:`/h5/pages/activity/activity-list`,
|
|
|
- 9:`/second/pages/form/introduce`,
|
|
|
- 10:`/second/pages/product/product-list`,
|
|
|
- 11:`/second/pages/form/form`,
|
|
|
+ 8:'/h5/pages/activity/activity-list',
|
|
|
+ 9:'/second/pages/form/introduce',
|
|
|
+ 10:'/second/pages/product/product-list',
|
|
|
+ 11:'/second/pages/form/form',
|
|
|
12:`/search/pages/search/search?keyWord=${keyword}`,
|
|
|
13:`/h5/pages/article/path?link=${linkHref}`,
|
|
|
14:`/h5/pages/article/path?link=${linkHref}`,
|
|
|
15:`/h5/pages/article/path?link=${linkHref}`,
|
|
|
- 17:`/pages/login/register-select`,
|
|
|
+ 17:'/pages/login/register-select',
|
|
|
18:`/h5/pages/article/path?link=${linkHref}`,
|
|
|
19:`/search/pages/search/search-supplier?keyWord=${keyword}`,
|
|
|
- 21:`/h5/pages/activity/meobohui`
|
|
|
+ 21:'/h5/pages/activity/meobohui'
|
|
|
}
|
|
|
- const url = typeMap[linkType];
|
|
|
+ const url = typeMap[linkType]
|
|
|
uni.navigateTo({
|
|
|
url:url
|
|
|
})
|
|
@@ -296,8 +297,8 @@ const caimeiApi = {
|
|
|
})
|
|
|
},
|
|
|
isNumber:function(value){//验证是否为数字
|
|
|
- var patrn = /^(-)?\d+(\.\d+)?$/;
|
|
|
- if (patrn.exec(value) == null || value == "") {
|
|
|
+ var patrn = /^(-)?\d+(\.\d+)?$/
|
|
|
+ if (patrn.exec(value) == null || value == '') {
|
|
|
return false
|
|
|
} else {
|
|
|
return true
|
|
@@ -305,8 +306,8 @@ const caimeiApi = {
|
|
|
},
|
|
|
getWindowHeight:function(){
|
|
|
// 获取窗口高度
|
|
|
- const {windowHeight, pixelRatio} = wx.getSystemInfoSync();
|
|
|
- return windowHeight;
|
|
|
+ const {windowHeight, pixelRatio} = wx.getSystemInfoSync()
|
|
|
+ return windowHeight
|
|
|
},
|
|
|
adaptRichTextImg:function(res){
|
|
|
/**
|
|
@@ -315,34 +316,34 @@ const caimeiApi = {
|
|
|
*/
|
|
|
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;
|
|
|
+ results = match1.replace(/style=/gi, 'style="width:100%;height:auto;float:left;"')
|
|
|
+ return results
|
|
|
})
|
|
|
- return html;
|
|
|
+ return html
|
|
|
},
|
|
|
FormatMoney:function(num){
|
|
|
// 金额千分位
|
|
|
return num.toString().replace(/\d+/, function (n) { // 先提取整数部分
|
|
|
return n.replace(/(\d)(?=(\d{3})+$)/g, function ($1) { // 对整数部分添加分隔符
|
|
|
- return $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;
|
|
|
+ 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 = {
|
|
@@ -350,19 +351,19 @@ const caimeiApi = {
|
|
|
'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;
|
|
|
+ }
|
|
|
+ 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}`;
|
|
|
+ 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}`
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -392,4 +393,4 @@ module.exports = {
|
|
|
timestampToTime: caimeiApi.timestampToTime,
|
|
|
BannerNavigateTo:caimeiApi.BannerNavigateTo,
|
|
|
FlooryNavigateTo:caimeiApi.FlooryNavigateTo
|
|
|
-};
|
|
|
+}
|