Browse Source

处理首页app步数不显示

接口签名整理
master
vee 3 years ago
parent
commit
12dc39eb24
  1. 122
      pages/home/index.vue
  2. 168
      utils/api.js
  3. 121
      utils/axios.js
  4. 24
      utils/constant.js

122
pages/home/index.vue

@ -44,7 +44,9 @@
<view class="steps"> <view class="steps">
<view class="content"> <view class="content">
<view class="title">{{ i18n.TodaySteps }}</view> <view class="title">{{ i18n.TodaySteps }}</view>
<view id="chart" style="width: 280rpx;height:280rpx; font-size: 40rpx;"></view> <view id="chart" :stepsNum="stepsNum" :stepTarget="stepTarget"
:change:stepTarget="echarts.receive" :change:stepsNum="echarts.receive"
style="width: 280rpx;height:280rpx; font-size: 40rpx;"></view>
<!-- <canvas id="chart" ref="chart" style="width: 280rpx;height:280rpx; font-size: 40rpx;"></canvas> --> <!-- <canvas id="chart" ref="chart" style="width: 280rpx;height:280rpx; font-size: 40rpx;"></canvas> -->
<u-button class="button" color="#00E8A2">{{ i18n.ReceiveEarnings }}</u-button> <u-button class="button" color="#00E8A2">{{ i18n.ReceiveEarnings }}</u-button>
</view> </view>
@ -81,6 +83,7 @@
<script> <script>
import languagePopups from '@/components/language-popups/language-popups.vue' import languagePopups from '@/components/language-popups/language-popups.vue'
import languageData from '@/utils/language/config' import languageData from '@/utils/language/config'
import api from '@/utils/api'
// echarts // echarts
// import * as echarts from 'echarts'; // import * as echarts from 'echarts';
@ -89,7 +92,9 @@ let videoPlayer;
let myChart; let myChart;
export default { export default {
name: 'home', name: 'home',
components: { languagePopups }, components: {
languagePopups
},
data() { data() {
return { return {
languageShow: false, languageShow: false,
@ -103,8 +108,7 @@ export default {
], ],
videoShow: false, videoShow: false,
videoUrl: '', videoUrl: '',
videoList: [ videoList: [{
{
url: 'https://cdn.uviewui.com/uview/resources/video.mp4', url: 'https://cdn.uviewui.com/uview/resources/video.mp4',
title: 'Video name 1', title: 'Video name 1',
poster: 'https://cdn.uviewui.com/uview/swiper/swiper1.png' poster: 'https://cdn.uviewui.com/uview/swiper/swiper1.png'
@ -132,10 +136,12 @@ export default {
} }
}, },
onLoad() { onLoad() {
this.stepsNum = 2000
}, },
onShow() { onShow() {
this.getBanner();
//const post2 = api.banner();
// //
// this.videoList.forEach((item, index) => { // this.videoList.forEach((item, index) => {
// const VideoPlayer = uni.createVideoContext(`video-${index}`, this) // const VideoPlayer = uni.createVideoContext(`video-${index}`, this)
@ -161,6 +167,9 @@ export default {
} }
}, },
methods: { methods: {
getBanner(){
const returnData=api.noticeList({'mark':'APP_INDEX'});
},
// //
laug() { laug() {
this.laugValue = true; this.laugValue = true;
@ -201,7 +210,9 @@ export default {
playVideo(data) { playVideo(data) {
this.videoUrl = data.url; this.videoUrl = data.url;
this.videoShow = true; this.videoShow = true;
videoPlayer.requestFullScreen({ direction: 0 }) videoPlayer.requestFullScreen({
direction: 0
})
}, },
/** /**
* 跳转 * 跳转
@ -236,96 +247,15 @@ export default {
}); });
} }
},
initChart() {
// let myChart = echarts.init(this.$refs.chart);
// console.log(document);
// console.log(this.$refs.chart);
// this.myChart = echarts.init(document.getElementById('chart'));
// this.myChart = echarts.init(this.$refs.chart);
// myChart = echarts.init(document.getElementById('chart'))
this.option = {
title: {
text: this.stepsNum,
//
subtext: "",
//
itemGap: 0,
left: 'center',
top: 'center',
//
textStyle: {
fontSize: '20',
color: '#fff'
},
},
series: [{
name: '环形饼图',
type: 'pie',
radius: ['48%', '70%'],
avoidLabelOverlap: false,
label: {
show: false,
position: 'center'
},
itemStyle: {
//
shadowBlur: 30,
shadowColor: '#15141F',
shadowOffsetX: 'center',
shadowOffsetY: 'center'
},
data: [{
value: +this.stepsNum / this.stepTarget
,
name: '步数',
itemStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: .2,
color: '#47BDFF'
}, {
offset: .5,
color: '#34AEFF'
}, {
offset: 1,
color: '#0589FF'
}
]),
borderRadius: 800,
} }
},
{
value: (this.stepTarget - this.stepsNum) / this.stepTarget,
name: '剩余步数',
itemStyle: {
color: '#15141F',
}
}
]
}]
}
// myChart.setOption(this.option, true);
// window.addEventListener('resize', () => {
// myChart.resize();
// });
} }
} }
}
</script> </script>
<script module="echarts" lang="renderjs"> <script module="echarts" lang="renderjs">
let myChart let myChart
export default { export default {
mounted() { mounted() {
console.log(0); console.log(0);
console.log(window); console.log(window);
@ -341,7 +271,7 @@ export default {
const script = document.createElement('script'); const script = document.createElement('script');
console.log(2); console.log(2);
// view www www // view www www
script.src = '/static/echarts.js'; script.src = './static/echarts.js';
console.log(3); console.log(3);
script.onload = this.initEcharts.bind(this); script.onload = this.initEcharts.bind(this);
console.log(4); console.log(4);
@ -351,6 +281,14 @@ export default {
}, },
methods: { methods: {
//
receive(newValue, oldValue, ownerVm, vm) {
console.log('msg变化了newValue', newValue)
console.log('msg变化了oldValue', oldValue)
},
initEcharts() { initEcharts() {
console.log(31); console.log(31);
// let t1=null; // let t1=null;
@ -419,8 +357,7 @@ export default {
}, },
data: [{ data: [{
value: +this.stepsNum / this.stepTarget value: +this.stepsNum / this.stepTarget,
,
name: '步数', name: '步数',
itemStyle: { itemStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
@ -432,8 +369,7 @@ export default {
}, { }, {
offset: 1, offset: 1,
color: '#0589FF' color: '#0589FF'
} }]),
]),
borderRadius: 800, borderRadius: 800,

168
utils/api.js

@ -1,80 +1,100 @@
import Vue from 'vue'; import Vue from 'vue';
import qs from 'qs' import qs from 'qs'
const api = { const api = {
//---------------------------------account--------------------------------- //---------------------------------recharge充值---------------------------------
siteInfo: () => Vue.prototype.$axios.get('/api/home/siteInfo'), rechargeConfig: (qs.stringify(params) => Vue.prototype.$axios.post('/api/recharge/rechargeConfig',qs.stringify(params),//获取充值配置
register: (params) => Vue.prototype.$axios.post('/api/home/register',params), rechargeAddress: (qs.stringify(params) => Vue.prototype.$axios.post('/api/recharge/rechargeAddress',qs.stringify(params),//获取对应数字币种的充值地址
login: (params) => Vue.prototype.$axios.post('/api/user/login',params), recharge: (qs.stringify(params) => Vue.prototype.$axios.post('/api/recharge/recharge',qs.stringify(params),//法币在线充值下单
loginOut: (params) => Vue.prototype.$axios.post('/api/user/loginOut',params), rechargeList: (qs.stringify(params) => Vue.prototype.$axios.post('/api/recharge/rechargeList',qs.stringify(params),//充值记录
forgotPassword: (params) => Vue.prototype.$axios.post('/api/user/forgotPassword',params),
updatePassword: (params) => Vue.prototype.$axios.post('/api/user/updatePassword',params),
userInfo: (params) => Vue.prototype.$axios.post('/api/user/userInfo',params),
updateNickname: (params) => Vue.prototype.$axios.post('/api/user/updateNickname',params), //--------------------------------- withdraw提现 ---------------------------------
updateGender: (params) => Vue.prototype.$axios.post('/api/user/updateGender',params), withdrawConfig: (qs.stringify(params) => Vue.prototype.$axios.post('/api/withdraw/withdrawConfig',qs.stringify(params),//获取提现配置
withdrawAddressList: (qs.stringify(params) => Vue.prototype.$axios.post('/api/withdraw/withdrawAddressList',qs.stringify(params),//提现地址列表
withdrawAddressAdd: (qs.stringify(params) => Vue.prototype.$axios.post('/api/withdraw/withdrawAddressAdd',qs.stringify(params),//保存提现地址
//--------------------------------- free --------------------------------- withdrawAddressDel: (qs.stringify(params) => Vue.prototype.$axios.post('/api/withdraw/withdrawAddressDel',qs.stringify(params),//删除提现地址
imgCode: () => Vue.prototype.$axios.get('/api/home/imgCode'), withdraw: (qs.stringify(params) => Vue.prototype.$axios.post('/api/withdraw/withdraw',qs.stringify(params),//提现下单
sendSmsCode: (params) => Vue.prototype.$axios.post('/api/home/sendSmsCode',params), withdrawList: (qs.stringify(params) => Vue.prototype.$axios.post('/api/withdraw/withdrawList',qs.stringify(params),//提现记录
article: (params) => Vue.prototype.$axios.post('/api/index/article',params),
appVersion: (params) => Vue.prototype.$axios.post('/api/index/appVersion',params),
//--------------------------------- mine 挖矿 ---------------------------------
info: () => Vue.prototype.$axios.post('/api/index/info'), mineList: (qs.stringify(params) => Vue.prototype.$axios.post('/api/mine/mineList',qs.stringify(params),//获取挖矿产品列表、
//--------------------------------- bet --------------------------------- mineRecord: (qs.stringify(params) => Vue.prototype.$axios.post('/api/mine/mineRecord',qs.stringify(params),//获取购买挖矿记录
lotteryClassList: (params) => Vue.prototype.$axios.post('/api/lottery/lotteryClassList',params), showMineDetails: (qs.stringify(params) => Vue.prototype.$axios.post('/api/mine/showMineDetails',qs.stringify(params),//获取挖矿产品详情和用户余额
nextLotteryPeriod: (params) => Vue.prototype.$axios.post('/api/lottery/nextLotteryPeriod',params), mineSubmit: (qs.stringify(params) => Vue.prototype.$axios.post('/api/mine/mineSubmit',qs.stringify(params),//提交购买挖矿产品订单
bettingConfig: (params) => Vue.prototype.$axios.post('/api/lottery/bettingConfig',params),
betting: (params) => Vue.prototype.$axios.post('/api/lottery/betting',params), //--------------------------------- 行情 ---------------------------------
lotteryRecords: (params) => Vue.prototype.$axios.post('/api/lottery/lotteryRecords',params), addFavor: (qs.stringify(params) => Vue.prototype.$axios.post('/market/addFavor',qs.stringify(params),//关注交易对
myLotteryRecords: (params) => Vue.prototype.$axios.post('/api/lottery/myLotteryRecords',params), removeFavor: (qs.stringify(params) => Vue.prototype.$axios.post('/market/removeFavor',qs.stringify(params),//取消关注交易对
symbolGroup: (qs.stringify(params) => Vue.prototype.$axios.post('/market/symbolGroup',qs.stringify(params),//(新)获取交易对列表(HTTP)
marketDetail: (qs.stringify(params) => Vue.prototype.$axios.post('/market/detail',qs.stringify(params),//获取24显示行情(HTTP)
//--------------------------------- me --------------------------------- bboList: (qs.stringify(params) => Vue.prototype.$axios.post('/market/bboList',qs.stringify(params),//获取买卖单(HTTP)
getPayType: (params) => Vue.prototype.$axios.post('/api/recharge/getPayType',params), tradeList: (qs.stringify(params) => Vue.prototype.$axios.post('/market/tradeList',qs.stringify(params),//获取成交记录(HTTP)
rechargeConfig: (params) => Vue.prototype.$axios.post('/api/recharge/rechargeConfig',params),
recharge: (params) => Vue.prototype.$axios.post('/api/recharge/recharge',params), //--------------------------------- contract ---------------------------------
rechargeList: (params) => Vue.prototype.$axios.post('/api/recharge/rechargeList',params), contractOrder: (qs.stringify(params) => Vue.prototype.$axios.post('/api/contract/order',qs.stringify(params),//合约下单接口
toPay: (params) => Vue.prototype.$axios.post('/api/recharge/toPay',params), setWinOrLossStopPrice: (qs.stringify(params) => Vue.prototype.$axios.post('/api/contract/setWinOrLossStopPrice',qs.stringify(params),//设置止盈止损
withdrawConfig: (params) => Vue.prototype.$axios.post('/api/withdraw/withdrawConfig',params), contractCancel: (qs.stringify(params) => Vue.prototype.$axios.post('/api/contract/cancel',qs.stringify(params),//订单撤销
withdrawServiceCharge: (params) => Vue.prototype.$axios.post('/api/withdraw/withdrawServiceCharge',params), contractClosed: (qs.stringify(params) => Vue.prototype.$axios.post('/api/contract/closed',qs.stringify(params),//合约订单平仓
withdraw: (params) => Vue.prototype.$axios.post('/api/withdraw/withdraw',params), contractConfig: (qs.stringify(params) => Vue.prototype.$axios.post('/api/contract/contractConfig',qs.stringify(params),//合约配置
withdrawList: (params) => Vue.prototype.$axios.post('/api/withdraw/withdrawList',params), contractOrderList: (qs.stringify(params) => Vue.prototype.$axios.post('/api/contract/orderList',qs.stringify(params),//合约订单列表
billList: (params) => Vue.prototype.$axios.post('/api/summary/billList',params),
//--------------------------------- transfer ---------------------------------
//--------------------------------- invite --------------------------------- getTransferConfig: (qs.stringify(params) => Vue.prototype.$axios.post('/api/transfer/getTransferConfig',qs.stringify(params),//获取转账配置配置
inviteCode: (params) => Vue.prototype.$axios.post('/api/user/inviteCode',params), changeCoinWays: (qs.stringify(params) => Vue.prototype.$axios.post('/api/transfer/changeCoinWays',qs.stringify(params),//切换币种或转出账户
bonusOut: (params) => Vue.prototype.$axios.post('/api/summary/bonusOut',params), transfer: (qs.stringify(params) => Vue.prototype.$axios.post('/api/transfer/transfer',qs.stringify(params),//提交划转资金
bonusOutRecords: (params) => Vue.prototype.$axios.post('/api/summary/bonusOutRecords',params),
promotionRecords: (params) => Vue.prototype.$axios.post('/api/summary/promotionRecords',params), //--------------------------------- invitation ---------------------------------
bonusRecords: (params) => Vue.prototype.$axios.post('/api/summary/bonusRecords',params), invitation: (qs.stringify(params) => Vue.prototype.$axios.post('/api/invitation/invitRules',qs.stringify(params),//获取邀请规则文案
bonusSummary: (params) => Vue.prototype.$axios.post('/api/summary/bonusSummary',params), invitData: (qs.stringify(params) => Vue.prototype.$axios.post('/api/invitation/invitData',qs.stringify(params),//获取用户邀请数据
//--------------------------------- bankCard --------------------------------- invitationRecord: (qs.stringify(params) => Vue.prototype.$axios.post('/api/invitation/invitationRecord',qs.stringify(params),//获取用户邀请记录
bankcardList: (params) => Vue.prototype.$axios.post('/api/user/bankcardList',params), //--------------------------------- 申购 ---------------------------------
bindBank: (params) => Vue.prototype.$axios.post('/api/user/bindBank',params), subscriptionList: (qs.stringify(params) => Vue.prototype.$axios.post('/api/exchange/subscriptionList',qs.stringify(params),//申购币列表
delBankCard: (params) => Vue.prototype.$axios.post('/api/user/delBankCard',params), subscription: (qs.stringify(params) => Vue.prototype.$axios.post('/api/exchange/subscription',qs.stringify(params),//申购币详情
selCoin: (qs.stringify(params) => Vue.prototype.$axios.post('api/exchange/selCoin',qs.stringify(params),//申购详情页切换币种
//--------------------------------- address --------------------------------- exchangeCoin: (qs.stringify(params) => Vue.prototype.$axios.post('/api/exchange/exchangeCoin',qs.stringify(params),//提交申购订单
addressList: (params) => Vue.prototype.$axios.post('/api/user/addressList',params), subscriptionRecord: (qs.stringify(params) => Vue.prototype.$axios.post('/api/exchange/subscriptionRecord',qs.stringify(params),//用户申购记录
addressSave: (params) => Vue.prototype.$axios.post('/api/user/addressSave',params),
delAddress: (params) => Vue.prototype.$axios.post('/api/user/delAddress',params),
//--------------------------------- goods --------------------------------- //--------------------------------- charity ---------------------------------
banner: () => Vue.prototype.$axios.get('/api/home/banner'), charityList: (qs.stringify(params) => Vue.prototype.$axios.post('/api/charity/charityList',qs.stringify(params),//获取慈善产品列表
goodsList: (params) => Vue.prototype.$axios.post('/api/index/goodsList',params), charityRecord: (qs.stringify(params) => Vue.prototype.$axios.post('/api/charity/charityRecord',qs.stringify(params),//获取慈善捐赠记录
goodsDetail: (params) => Vue.prototype.$axios.post('/api/index/goods',params), charitySubmit: (qs.stringify(params) => Vue.prototype.$axios.post('/api/charity/charitySubmit',qs.stringify(params),//提交捐赠
showCharityDetails: (qs.stringify(params) => Vue.prototype.$axios.post('/api/charity/showCharityDetails',qs.stringify(params),//获取慈善产品详情和用户余额
//--------------------------------- moni --------------------------------- //--------------------------------- 步数 ---------------------------------
// lotteryClassListM: (params) => Vue.prototype.$axios.post('/api/demo/lotteryClassListDemo',params), updateSteps: (qs.stringify(params) => Vue.prototype.$axios.post('/api/steps/updateSteps',qs.stringify(params),// 更新步数
nextLotteryPeriodM: (params) => Vue.prototype.$axios.post('/api/demo/nextLotteryPeriodDemo',params), receivStepsAward: (qs.stringify(params) => Vue.prototype.$axios.post('/api/steps/receivStepsAward',qs.stringify(params),//领取奖励
bettingConfigM: (params) => Vue.prototype.$axios.post('/api/demo/bettingConfigDemo',params),
bettingM: (params) => Vue.prototype.$axios.post('/api/demo/bettingDemo',params), //--------------------------------- home ---------------------------------
lotteryRecordsM: (params) => Vue.prototype.$axios.post('/api/demo/lotteryRecordsDemo',params), indexInfo: () => Vue.prototype.$axios.get('/api/index/info'),//获取系统通用配置
myLotteryRecordsM: (params) => Vue.prototype.$axios.post('/api/demo/myLotteryRecordsDemo',params), indexLang: (qs.stringify(params) => Vue.prototype.$axios.post('/api/index/lang',qs.stringify(params),//切换语言
//--------------------------------- hongbao --------------------------------- customerService: (qs.stringify(params) => Vue.prototype.$axios.post('/api/index/customerService',qs.stringify(params),//获取客服联系方式
launchRedEnvelop: (params) => Vue.prototype.$axios.post('/api/user/launchRedEnvelop',params), sendEmailCode: (qs.stringify(params) => Vue.prototype.$axios.post('/api/index/sendEmailCode',qs.stringify(params),//发送邮箱验证码
redEnvelopList: (params) => Vue.prototype.$axios.post('/api/user/redEnvelopList',params), indexBanner: (qs.stringify(params) => Vue.prototype.$axios.post('/api/index/banner',qs.stringify(params),//获取banner图列表
cancelRedEnvelop: (params) => Vue.prototype.$axios.post('/api/user/cancelRedEnvelop',params), noticeList: (qs.stringify(params) => Vue.prototype.$axios.post('/api/index/noticeList',qs.stringify(params),//获取公告滚动数据
redEnvelop: (params) => Vue.prototype.$axios.post('/api/user/redEnvelop',params), notices: (qs.stringify(params) => Vue.prototype.$axios.post('/api/index/notices',qs.stringify(params),//获取公告分页列表
receiveRedEnvelop: (params) => Vue.prototype.$axios.post('/api/user/receiveRedEnvelop',params), noticeRead: (qs.stringify(params) => Vue.prototype.$axios.post('/api/index/noticeRead',qs.stringify(params),//标记公告已读
noticeDetail: (qs.stringify(params) => Vue.prototype.$axios.post('/api/index/noticeDetail',qs.stringify(params),//获取公告详情
appVersion: (qs.stringify(params) => Vue.prototype.$axios.post('/api/index/appVersion',qs.stringify(params),//校验APP应用版本
//--------------------------------- 个人中心 ---------------------------------
register: (qs.stringify(params) => Vue.prototype.$axios.post('/api/index/register',qs.stringify(params),//注册
login: (qs.stringify(params) => Vue.prototype.$axios.post('/api/user/login',qs.stringify(params),//登录
loginOut: (qs.stringify(params) => Vue.prototype.$axios.post('/api/user/loginOut',qs.stringify(params),//退出登录
forgotPassword: (qs.stringify(params) => Vue.prototype.$axios.post('/api/user/forgotPassword',qs.stringify(params),//忘记密码
updatePassword: () => Vue.prototype.$axios.get('/api/user/updatePassword'),//修改登录密码
userAccount: (qs.stringify(params) => Vue.prototype.$axios.post('/api/user/userAccount',qs.stringify(params),//用户余额信息
bankCardInfo: (qs.stringify(params) => Vue.prototype.$axios.post('/api/user/bankCardInfo',qs.stringify(params),//获取银行卡信息
bindBank: (qs.stringify(params) => Vue.prototype.$axios.post('/api/user/bindBank',qs.stringify(params),//绑定/修改银行卡
certification: (qs.stringify(params) => Vue.prototype.$axios.post('/api/user/certification',qs.stringify(params),//保存实名认证信息
certificationInfo: (qs.stringify(params) => Vue.prototype.$axios.post('/api/user/certificationInfo',qs.stringify(params),//获取实名认证信息
billList: (qs.stringify(params) => Vue.prototype.$axios.post('/api/user/billList',qs.stringify(params),//账单记录
userInfo: (qs.stringify(params) => Vue.prototype.$axios.post('/api/user/userInfo',qs.stringify(params),//会员基本信息
updatePayPassword: (qs.stringify(params) => Vue.prototype.$axios.post('/api/user/updatePayPassword',qs.stringify(params),//修改提现密码
} }

121
utils/axios.js

@ -17,121 +17,119 @@ key = constant.APP_KEY
const service = axios.create({ const service = axios.create({
withCredentials: true, withCredentials: true,
crossDomain: true, crossDomain: true,
baseURL, baseURL: constant.BASE_URL,
timeout: 160000 timeout: 160000
}) })
console.log(constant.BASE_URL)
// request拦截器,在请求之前做一些处理 // request拦截器,在请求之前做一些处理
service.interceptors.request.use( service.interceptors.request.use(
config => { config => {
// console.log('showDialog' + Vue.prototype.$showDialog) const language = uni.getStorageSync("language") || 'en_US';
if (Vue.prototype.$showDialog) { console.log('语言', uni.getStorageSync('language'))
if (constant.SHOW_DIALOG) {
uni.showLoading({ uni.showLoading({
title: 'loading', title: 'loading',
mask: true mask: true
}) })
} }
if (config.url.indexOf('market') > -1) {
config.baseURL = Vue.prototype.MARKET_URL;
}
const ticket = uni.getStorageSync('ticket') const ticket = uni.getStorageSync('ticket')
if (ticket != '') {
config.data['ticket'] = ticket
}
if (Vue.prototype.$showDialog) {
uni.showLoading({
title: 'loading',
mask: true
})
}
// if (store.state.token) {
// // 给请求头添加user-token
// config.headers["user-token"] = store.state.token;
// }
//const ticket = Vue.prototype.$store.state.ticket
let dataStr = []; let dataStr = [];
if (config.method == 'get') { if (config.method == 'get') {
if (config.url.split('?').length > 1) { if (config.url.split('?').length > 1) {
dataStr = config.url.split('?')[1].split('&'); dataStr = config.url.split('?')[1].split('&');
} }
} }
if (config.method == 'post') { if (config.method == 'post') {
dataStr = qs.stringify(config.data).split('&'); console.log(config.data)
// dataStr = JSON.stringify(config.data); dataStr = config.data.split('&');
// dataStr = config.data;
// dataStr = config.data.name;
} }
//console.log(config.url,111111,config.data,dataStr)
config.data = {}; config.data = {};
dataStr.forEach(function(e) { dataStr.forEach(function(e) {
console.log(e, 666666)
config.data[e.split('=')[0]] = e.split('=')[1]; config.data[e.split('=')[0]] = e.split('=')[1];
}); });
// console.log(ticket)
if (ticket != '') {
config.data['ticket'] = ticket
}
var keys = []; var keys = [];
let sign = ''; let sign = '';
var t = Date.now() - 2901;
// config.headers["timestamp"] = t;
// config.data["timestamp"] = t
for (var k in config.data) for (var k in config.data)
keys.push(k); keys.push(k);
keys.sort(function(a, b) { keys.sort(function(a, b) {
return a < b ? -1 : 1; return a < b ? -1 : 1;
}) })
// console.log("keys===========");
//console.log("keys===========",keys);
keys.forEach(function(e) { keys.forEach(function(e) {
if (config.data[e] || config.data[e] == '') { if (config.data[e] || config.data[e] == '') {
sign += e + '=' + config.data[e] + '&' sign += e + '=' + config.data[e] + '&'
} }
}); });
// console.log("签名参数===========");
// console.log(config.url); key = "key=" + constant.KEY;
// console.log(sign + key);
sign = md5(sign + key); sign = md5(sign + key);
// console.log("提交参数==========="); config.data['timestamp'] = null
// console.log(qs.stringify(config.data));
if (config.method == 'post') { if (config.method == 'post') {
// console.log(config.data,666666)
config.data['sign'] = sign config.data['sign'] = sign
config.data = qs.stringify(config.data)
// config.data = config.data.replace(/(\w+)\s*, \s*(\w+)/, "$2 $1");
// if(config.url == ){
// #ifdef H5 config.data = qs.stringify(config.data).replace("timestamp=&", "")
if (config.url == '/api/index/goodsList') {
config.data = config.data.replaceAll('20', "");
config.data = config.data.replaceAll('26', "");
config.data = config.data.replaceAll('2F', "/");
config.data = config.data.replaceAll('28', "");
config.data = config.data.replaceAll('29', "");
// config.data = config.data.replaceAll('%C2%AE', "&reg;");
}
// #endif
// #ifdef APP-PLUS
if (config.url == '/api/index/goodsList') {
config.data = config.data.replace(new RegExp('20', "gm"), "");
config.data = config.data.replace(new RegExp('26', "gm"), "");
config.data = config.data.replace(new RegExp('2F', "gm"), "/");
config.data = config.data.replace(new RegExp('28', "gm"), "");
config.data = config.data.replace(new RegExp('29', "gm"), "");
// config.data = config.data.replaceAll('%C2%AE', "&reg;");
}
// #endif
// config.data = config.data.replaceAll('2528',"(");
// config.data = config.data.replaceAll('2529',")");
// config.data = config.data.replaceAll('252',"%2F");
// }
} }
if (config.method == 'get') { if (config.method == 'get') {
if (ticket != '') {
config.url = config.url + '&ticket=' + ticket + '&sign=' + sign config.url = config.url + '&sign=' + sign
} else {
config.url = config.url + '?sign=' + sign
}
} }
// console.log(config)
return config; return config;
}, },
error => { error => {
// console.log(error); // for debug // console.log(error); // for debug
uni.hideLoading();
return Promise.reject(error); return Promise.reject(error);
} }
); );
//配置成功后的拦截器 //配置成功后的拦截器
service.interceptors.response.use(res => { service.interceptors.response.use(res => {
console.log('过期了吗') console.log('过期了吗', res)
uni.hideLoading() uni.hideLoading()
// console.log(res) // console.log(res)
// console.log(res.data) // console.log(res.data)
@ -150,10 +148,11 @@ service.interceptors.response.use(res => {
uni.removeStorage({ uni.removeStorage({
key: 'logInfo', key: 'logInfo',
success: function(res) { success: function(res) {
uni.reLaunch({ url: '/pages/login/index' }) uni.reLaunch({
url: '/pages/login/index'
})
}, },
fail: (err) => { fail: (err) => {}
}
}); });
@ -178,6 +177,7 @@ service.interceptors.response.use(res => {
return Promise.reject(res.data.errMsg); return Promise.reject(res.data.errMsg);
} }
}, error => { }, error => {
uni.hideLoading();
return Promise.reject(error) return Promise.reject(error)
}) })
@ -208,10 +208,9 @@ axios.defaults.adapter = function (config) { //自己定义个适配器,用来
settle(resolve, reject, response); settle(resolve, reject, response);
}, },
fail: res => { fail: res => {
uni.showToast({ uni.showLoading({
title: res, title: res,
icon: 'none', mask: true
duration: 1500
}) })
} }
}) })

24
utils/constant.js

@ -1,14 +1,14 @@
const H5 = '/start'; const IS_TEST = true;
const H5_KEY = 'key=PBcGdWvA7dUintx7WNOR11cOdCrEpasM'; const BASE_URL = IS_TEST?'https://sapi.payairs.com':'';
const MARKET_URL = IS_TEST?'https://market.acefinex.com':'';
const APP = 'https://api.wingold6.com'; //正式 const KEY = IS_TEST?'jsabdjhfbsjndfksnjndja,sndmbstart':'';
// const APP = 'https://apitest.luck-work.com'; //测试 const WSSURL = IS_TEST?'wss://market.acefinex.com/wss/':'';
const APP_KEY = 'key=PBcGdWvA7dUintx7WNOR11cOdCrEpasM'; const SHOW_DIALOG=true
const showDialog = true
export default { export default {
H5, IS_TEST,
H5_KEY, BASE_URL,
APP, MARKET_URL,
APP_KEY, KEY,
showDialog, WSSURL,
SHOW_DIALOG
} }
Loading…
Cancel
Save