Pārlūkot izejas kodu

定位与选择广场

soldDate
HolyKnightIX pirms 2 gadiem
vecāks
revīzija
5ee8b8a5ec
6 mainītis faili ar 321 papildinājumiem un 231 dzēšanām
  1. +43
    -41
      app.js
  2. +80
    -37
      index/index.js
  3. +15
    -129
      index/index.ttml
  4. +28
    -14
      index/index.ttss
  5. +120
    -0
      index/indexOld.txt
  6. +35
    -10
      utils/HttpBasics.js

+ 43
- 41
app.js Parādīt failu

@@ -1,44 +1,44 @@
const Http = require("./utils/HttpBasics.js")
const config = require("./config/config.js");
App({
data:{},
globalData:{
data: {},
globalData: {
token: null,
imgHttps: 'https://formall.oss-accelerate.aliyuncs.com/douyin/drawable-xhdpi/',
platform:null,//手机型号
systemInfo:"",
curHtml:"",
marketName:"",
mouldType:1,
appId:config.weapp.AppId,
selected:0,
goHomeUrl:"/index/index",
type:"",//存放跳转标记
platform: null, //手机型号
systemInfo: "",
curHtml: "",
marketName: "",
mouldType: 1,
appId: config.weapp.AppId,
selected: 0,
goHomeUrl: "/index/index",
type: "", //存放跳转标记
previewFlag: false, //解决图片预览调用noshow
skipUrl:"",//存放授权跳转地址
skip:"",
avatarUrl:"",//用户头像
nickName:"",//用户姓名
templateId:[],//订阅消息模板id
ifshowtab:false,
skipUrl: "", //存放授权跳转地址
skip: "",
avatarUrl: "", //用户头像
nickName: "", //用户姓名
templateId: [], //订阅消息模板id
ifshowtab: false,
},
onLaunch: function () {
let that = this
try {
var res = tt.getSystemInfoSync();
that.statusBarHeight = res.statusBarHeight
console.log(`手机型号为`,that.statusBarHeight);
console.log(`手机型号为`, that.statusBarHeight);
this.globalData.platform = res.platform
} catch (error) {
console.log(`获取系统信息失败`);
}
that.logn();
that.login();
tt.getSystemInfo({
success(res) {
console.log(res,"**");
console.log(res, "**");
that.globalData.systemInfo = res
},
fail(res) {
console.log(`getSystemInfo 调用失败`);
@@ -46,7 +46,7 @@ App({
});

},
statusBarHeight: 0,
getTemplateId(that) {
// console.log("隐藏")
@@ -72,41 +72,43 @@ App({
}
})
},
logn(){
login() {
let that = this;
tt.login({
success:(res=>{
let {code} = res
console.log(code,"code");
success: (res => {
let {
code
} = res
console.log(code, "code");
Http.post({
url:config.api.login,
data:{
code:code,
appId:that.globalData.appId,
systemInfo:JSON.stringify(this.globalData.systemInfo)
url: config.api.login,
data: {
code: code,
appId: that.globalData.appId,
systemInfo: JSON.stringify(this.globalData.systemInfo)
}
}).then(res=>{
}).then(res => {
tt.setStorageSync("openId", res.data.openId);
if (res.data.mall){
if (res.data.mall) {
that.globalData.marketName = res.data.mall.name ? res.data.mall.name : ""
}
that.globalData.mouldType = res.data.mouldType ? res.data.mouldType:0;
that.globalData.mouldType = res.data.mouldType ? res.data.mouldType : 0;
if (res.data.subMalls) {
const squareList = JSON.parse(res.data.subMalls)
tt.setStorageSync("squareList", squareList)
if (res.data.mall){
if (res.data.mall) {
tt.setStorageSync("selectedMall", res.data.mall.tenantId)
}
}
Http.setToken(res.data.token);
that.globalData.token = res.data.token
that.getTemplateId(that);//获取订阅消息模板id
that.getTemplateId(that); //获取订阅消息模板id
if (that.tokenCallback) {
that.tokenCallback(res.data.token);
}
}).catch(err=>{
}).catch(err => {
console.log(err);
tt.showModal({
title: '提示',
@@ -129,4 +131,4 @@ App({

});
}
})
})

+ 80
- 37
index/index.js Parādīt failu

@@ -114,6 +114,10 @@ Page({
squareName: "", //当前广场
isShowSqare: false,
moduleList: [], //按钮列表
currentMall: '富茂广场',
shopList: [],
mallTenantId: tt.getStorageSync('mallTenantId') || '',
index: tt.getStorageSync('mallIndex') || 0
},

getCongig() { //获取小程序是否开通授权手机号
@@ -129,6 +133,37 @@ Page({
})
},

getsubMallList() {
Http.get({
url: '/mall/subMall?isAll=1',
}).then(res => {
this.setData({
shopList: res.data,
mallTenantId: res.data[0].tenantId
});
const index = this.data.index
const mallTenantId = this.data.shopList[index].tenantId
tt.setStorageSync('mallTenantId', mallTenantId)
tt.setStorageSync('mallIndex', index)
Http.setMallTenantId(mallTenantId);
}).catch(err => {
console.log(err, 'err');
})
},

bindPickerChange(e) {
const index = e.detail.value
const mallTenantId = this.data.shopList[index].tenantId
tt.setStorageSync('mallTenantId', mallTenantId)
tt.setStorageSync('mallIndex', index)
this.setData({
index: index,
mallTenantId: mallTenantId,
allow_load: true
});
Http.setMallTenantId(mallTenantId);
},

getBusineData(e) {
this.setData({
businePageNum: 1,
@@ -514,6 +549,7 @@ Page({
}
})
},

/**
* 生命周期函数--监听页面初次渲染完成
*/
@@ -543,6 +579,9 @@ Page({
// util.barcode("barcode", optionss.quancode, 510, 100);
// console.log(Http.headers.token, "?")
this.getLocation()
setTimeout(() => {
this.getsubMallList()
}, 1000)
},
/**
* 获得经纬度
@@ -569,8 +608,12 @@ Page({
},
fail: error => {
console.log(error);
},
complete: finish => {

}
})

},


@@ -752,19 +795,19 @@ Page({

that.getmemberId(app.globalData.token);
that.getBannerlist();
if (that.data.mouldType == 0) { //富茂原版
that.topicShow();
that.getxsList();
} else if (that.data.mouldType == 1) { //欢乐城模板
that.getShowList()
that.topicShowall(2);
that.topicShowall(3);
that.topicShowall(4);
that.topicShowall(5);
that.topicShowall(6);
that.getBusinessList();
that.getCouponChannelList(0)
}
// if (that.data.mouldType == 0) { //富茂原版
// that.topicShow();
// that.getxsList();
// } else if (that.data.mouldType == 1) { //欢乐城模板
// }
that.getShowList()
that.topicShowall(2);
that.topicShowall(3);
that.topicShowall(4);
that.topicShowall(5);
that.topicShowall(6);
that.getBusinessList();
that.getCouponChannelList(0)


that.getType()
@@ -826,19 +869,19 @@ Page({
// that.getModule()
that.getmemberId(app.globalData.token);
that.getBannerlist();
if (that.data.mouldType == 0) { //富茂原版
that.topicShow();
that.getxsList();
} else if (that.data.mouldType == 1) { //欢乐城模板
that.getShowList()
that.topicShowall(2);
that.topicShowall(3);
that.topicShowall(4);
that.topicShowall(5);
that.topicShowall(6);
that.getBusinessList();
that.getCouponChannelList(0)
}
// if (that.data.mouldType == 0) { //富茂原版
// that.topicShow();
// that.getxsList();
// } else if (that.data.mouldType == 1) { //欢乐城模板
// }
that.getShowList()
that.topicShowall(2);
that.topicShowall(3);
that.topicShowall(4);
that.topicShowall(5);
that.topicShowall(6);
that.getBusinessList();
that.getCouponChannelList(0)
that.getType()
that.uesrInfo()
// that.getLocation();
@@ -1314,17 +1357,17 @@ Page({
});
console.log("加载更多页数" + that.data.page, );
console.log("加载更多key" + that.data.code);
if (that.data.mouldType == 0) { //富茂源模板
//父组件获得子组件的方法
//如果code == 0
if (that.data.code == 0 || that.data.code == undefined) {
that.selectComponent("#lists").getList(0, that.data.page);
} else {
that.selectComponent("#lists").getList(that.data.code, that.data.page);
}
} else if (that.data.mouldType == 1) {
this.getCouponChannelList(that.data.busineKye)
}
// if (that.data.mouldType == 0) { //富茂源模板
// //父组件获得子组件的方法
// //如果code == 0
// if (that.data.code == 0 || that.data.code == undefined) {
// that.selectComponent("#lists").getList(0, that.data.page);
// } else {
// that.selectComponent("#lists").getList(that.data.code, that.data.page);
// }
// } else if (that.data.mouldType == 1) {
// }
this.getCouponChannelList(that.data.busineKye)

},
// 用户点击右上角分享


+ 15
- 129
index/index.ttml Parādīt failu

@@ -1,126 +1,5 @@
<!-- 初始模板 -->
<view tt:if="{{mouldType==0}}">
<!-- <navbar color="{{typeLsit.sy_top_f.styleClass}}" background="{{typeLsit.sy_top.styleClass}}" text="首页"></navbar> -->
<!-- style="padding-top:{{navigationBarHeight}}" -->
<view class="container">
<!-- <view style="height:{{navigationBarHeight1}} "></view> -->
<!-- 会员信息 -->
<view class="color_box" style="{{typeLsit.sy_bbg.styleClass}}">
<!-- 所属集团 -->
<view class="underling" bindtap="goSquareList" tt:if="{{squareName}}">
<image class="underlingImg" mode="widthFix" src="https://formall.oss-accelerate.aliyuncs.com/cimg/dingwei.png">
</image>
<view class="underlingName">{{squareName}} ↓</view>
</view>
<view class='userinfo' tt:if="{{ifStoreApp!=1}}">
<!-- 头像 -->
<view class='infoLeft' style="{{typeLsit.sy_xxb.styleClass}}">
<view class="user-avatar">
<open-data class="open" type="userAvatarUrl"></open-data>
</view>
<!-- 成长值 -->
<view class="user-data fl" bindtap='gotoChengzhangzhi' style="{{typeLsit.sy_xxb.styleClass}}">
<view class='nameBox'>
<open-data type="userNickName" style="{{typeLsit.sy_xxb_nf.styleClass}}"></open-data>
<view class='chengzhangBox' style='background:{{chengzhangBox}}'>
<text class='chengzhang'>{{levelName}}</text>
</view>
</view>
<view class="view">
<progress percent="{{upgradePercent}}" stroke-width="6" activeColor="{{activeColor}}" />
<view class='remainchengzhangzhi' style="{{typeLsit.sy_xxb_cf.styleClass}}">还需{{upgradeScore}}成长值可升级
</view>
</view>
</view>
</view>

<!-- 二维码 -->
<view class='qrcode fr' bindtap='qrcode' style="{{typeLsit.sy_qrc.styleClass}}">
<image src="{{typeLsit.sy_qrc.icon}}" class='qrcodeimg' mode='widthFix'></image>
</view>
</view>
<!-- banner -->
<c-banner tt:key="unique" list="{{list}}" />
<!-- 频道 -->
<view class="channelBox" tt:if="{{ifStoreApp!=1&&moduleList.length>0}}" style="{{typeLsit.sy_mbg.styleClass}}">
<view class='kjBox' bindtap='goPage' data-obj="{{item}}" tt:for="{{moduleList}}" tt:key="{{index}}">
<image src='{{item.icon}}' mode='aspectFill'></image>
<view class="text">{{item.name}}</view>
</view>
</view>

<view class='channelBox' tt:if="{{ifStoreApp==1}}" style="width:525rpx;">
<view class='kjBox' bindtap='gotoBargain'>
<image src='{{kanjia}}' mode='aspectFill'></image>
<text>砍价</text>
</view>
<view class='kjBox' bindtap='gotoSpellGroup'>
<image src='{{pintuan}}' mode='aspectFill'></image>
<text>拼团</text>
</view>
<view class='kjBox' bindtap='gotoRushBuy'>
<image src='{{xiaofeika}}' mode='aspectFill'></image>
<text>限时抢购</text>
</view>
</view>

</view>
<view class='toutiao1' tt:if="{{showQg&&ifStoreApp!=1}}">
<view class='xianshi' bindtap='gotoRushBuy'>
<text>限时专区</text>
<text>限时惊爆价 轻松拎回家</text>
</view>
<view class='xsCon'>
<view tt:for="{{xslist}}" tt:key="index">
<view class='igBox' data-couponId="{{item.couponId}}" data-couponChannelId="{{item.id}}"
data-targetAd="{{item.targetAd}}" bindtap='gotodetail'>
<image src='{{xslist[index].coverImg}}' mode='widthFix' class='imageH'></image>
<view class='imTit'>{{xslist[index].title}}</view>
</view>
</view>
<view>
<view class='igBox' bindtap='gotoRushBuy'>
<image src='{{more}}' mode='widthFix' class='more'></image>
<view class='imTit'>更多...</view>
</view>
</view>
</view>
</view>

<!-- 爆款专区 -->
<c-hot id="hot" />
<view class='product' tt:if="{{showTopic}}" bindtap='gotoTopic'>
<image src='{{cover}}' mode='widthFix'></image>
</view>


<c-coupons id="lists" bind:myevent="onGetCode" class="business" loadingtext="{{loadingtext}}"
loading="{{loading}}" />
<!-- 广告蒙层 -->
<!-- <c-advertisement id="advertisement" tt:if="{{showGg&&!played&&!havePlayEd1}}" ggdata="{{ggdata}}" /> -->
</view>
<!-- 顶部签到成长值 -->
<view class='signin' tt:if="{{fistLogin}}" animation="{{alphaData}}">
<open-data class="open" type="userAvatarUrl"></open-data>
<text class='text'>您今日签到成功,获得{{fistLogin}}成长值</text>
</view>
<view class="integralBox" tt:if="{{businessSwitch}}">
<!--是未授权微信且未授权手机号 -->
<navigator url="/pages/getuserinfo/index" open-type="navigate" tt:if="{{accreditFlag==1}}">
<image src='https://formall.oss-accelerate.aliyuncs.com/cimg/self-help-integral.png' mode='widthFix'
style="width: 100%;height: 100%;"></image>
</navigator>
<!-- 授权了微信 没授权手机号 -->
<navigator url="/pages/getuserinfo/index" open-type="navigate" tt:if="{{accreditFlag==2}}">
<image src='https://formall.oss-accelerate.aliyuncs.com/cimg/self-help-integral.png' mode='widthFix'
style="width: 100%;height: 100%;"></image>
</navigator>
</view>
</view>


<!-- 欢乐城模板 -->
<view tt:if="{{mouldType==1}}">
<view>
<view class="container1">
<!-- 会员信息 -->

@@ -135,13 +14,19 @@
<image src="{{huanlechengImgurl}}home_ic_xialajt.png" class="xia">
</image>
</view>

</view> -->
</view>



<view class="pickerMall" tt:if="{{shopList.length>1}}">
<picker mode="selector" bindchange="bindPickerChange" value="{{index}}" range="{{shopList}}" range-key="name"
disabled="{{false}}">
<view>
<view>
当前广场:{{ shopList[index].name }} ↓
</view>
</view>
</picker>
</view>

<!-- banner -->
<c-banner tt:key="unique" list="{{list}}" />
@@ -185,8 +70,9 @@
<!-- <c-mould tt:if="{{topicObj5}}" obj="{{topicObj5}}"
titleImgUrl="https://formall.oss-accelerate.aliyuncs.com/cimg/v20211214/home_txt_xfk.png" /> -->
<!-- 积分商城 -->
<c-mould tt:if="{{topicObj6}}" obj="{{topicObj6}}"
titleImgUrl="https://formall.oss-accelerate.aliyuncs.com/cimg/v20211214/home_txt_jfsc.png" />

<!-- <c-mould tt:if="{{topicObj6}}" obj="{{topicObj6}}"
titleImgUrl="https://formall.oss-accelerate.aliyuncs.com/cimg/v20211214/home_txt_jfsc.png" /> -->

<optimization tt:if="{{businessList.length>0}}" businessList="{{businessList}}" businessData="{{businessData}}"
bind:businessid="getBusineData" />
@@ -214,4 +100,4 @@
</view>
</view>
<tabbar />
<s-title/>
<s-title />

+ 28
- 14
index/index.ttss Parādīt failu

@@ -3,11 +3,13 @@
page {
background: #f4f5f9;
}
.temp{

.temp {
width: 100rpx;
height: 100rpx;
background-color: darkcyan
}

.xia {
width: 24rpx;
height: 14rpx;
@@ -18,7 +20,7 @@ page {
left: 0;
right: 0;
bottom: 0;
/* margin: auto; */
}

@@ -26,9 +28,10 @@ page {
display: flex;
justify-content: space-around;
}

.goSqunar1 {
display: flex;
justify-content: center;
justify-content: center;
background-image: url('https://formall.oss-accelerate.aliyuncs.com/douyin_ifomall/imgData/topback_1.png');
background-size: 100% 100%;
background-repeat: no-repeat;
@@ -36,7 +39,7 @@ page {
height: 190rpx;
}

.squareLogo{
.squareLogo {
width: 94rpx;
height: 40rpx;
position: absolute;
@@ -48,11 +51,11 @@ page {
font-size: 32rpx;
font-family: OPPOSans;
font-weight: bold;
}

.title1 {
max-width:320rpx;
max-width: 320rpx;
color: #402e1e;
font-family: "PingFangSC-Medium";
font-size: 28rpx;
@@ -66,9 +69,9 @@ page {
width: 24rpx;
/* height: 15rpx; */
}
.marketName{

}
.marketName {}

.f {
float: left;
}
@@ -108,10 +111,17 @@ page {
}

.color_box {
/* padding-top: 20rpx; *//* background-image: linear-gradient(#DC143C, #F4F5F9); */
/* padding-top: 20rpx; */
/* background-image: linear-gradient(#DC143C, #F4F5F9); */
background-color: #f4f5f9;
}

.pickerMall {
height: auto;
margin: 10rpx 0 15rpx 10rpx;
}


.underlingImg {
width: 30rpx;
height: 60rpx;
@@ -222,18 +232,20 @@ page {
padding: 0 38rpx;
}

.section >view, .sellsection>view {
.section>view,
.sellsection>view {
width: 25%;
display: inline-block;
position: relative;
}

.section >view image, .sellsection>view image {
.section>view image,
.sellsection>view image {
display: block;
margin: 0 auto;
}

.section >view image {
.section>view image {
width: 55rpx;
height: 55rpx;
margin-top: 20rpx;
@@ -604,9 +616,11 @@ page {
text-overflow: ellipsis;
white-space: nowrap;
}
.remainchengzhangzhi p{

.remainchengzhangzhi p {
display: inline;
}

progress {
width: 200rpx;
border-radius: 60rpx;
@@ -838,4 +852,4 @@ i-tabs i-tabs-scroll {
right: 20rpx;
position: fixed;
z-index: 1000000;
}
}

+ 120
- 0
index/indexOld.txt Parādīt failu

@@ -0,0 +1,120 @@
<!-- 初始模板 -->

<view tt:if="{{mouldType==0}}">
<!-- <navbar color="{{typeLsit.sy_top_f.styleClass}}" background="{{typeLsit.sy_top.styleClass}}" text="首页"></navbar> -->
<!-- style="padding-top:{{navigationBarHeight}}" -->
<view class="container">
<!-- <view style="height:{{navigationBarHeight1}} "></view> -->
<!-- 会员信息 -->
<view class="color_box" style="{{typeLsit.sy_bbg.styleClass}}">
<!-- 所属集团 -->
<view class="underling" bindtap="goSquareList" tt:if="{{squareName}}">
<image class="underlingImg" mode="widthFix" src="https://formall.oss-accelerate.aliyuncs.com/cimg/dingwei.png">
</image>
<view class="underlingName">{{squareName}} ↓</view>
</view>
<view class='userinfo' tt:if="{{ifStoreApp!=1}}">
<!-- 头像 -->
<view class='infoLeft' style="{{typeLsit.sy_xxb.styleClass}}">
<view class="user-avatar">
<open-data class="open" type="userAvatarUrl"></open-data>
</view>
<!-- 成长值 -->
<view class="user-data fl" bindtap='gotoChengzhangzhi' style="{{typeLsit.sy_xxb.styleClass}}">
<view class='nameBox'>
<open-data type="userNickName" style="{{typeLsit.sy_xxb_nf.styleClass}}"></open-data>
<view class='chengzhangBox' style='background:{{chengzhangBox}}'>
<text class='chengzhang'>{{levelName}}</text>
</view>
</view>
<view class="view">
<progress percent="{{upgradePercent}}" stroke-width="6" activeColor="{{activeColor}}" />
<view class='remainchengzhangzhi' style="{{typeLsit.sy_xxb_cf.styleClass}}">还需{{upgradeScore}}成长值可升级
</view>
</view>
</view>
</view>

<!-- 二维码 -->
<view class='qrcode fr' bindtap='qrcode' style="{{typeLsit.sy_qrc.styleClass}}">
<image src="{{typeLsit.sy_qrc.icon}}" class='qrcodeimg' mode='widthFix'></image>
</view>
</view>
<!-- banner -->
<c-banner tt:key="unique" list="{{list}}" />
<!-- 频道 -->
<view class="channelBox" tt:if="{{ifStoreApp!=1&&moduleList.length>0}}" style="{{typeLsit.sy_mbg.styleClass}}">
<view class='kjBox' bindtap='goPage' data-obj="{{item}}" tt:for="{{moduleList}}" tt:key="{{index}}">
<image src='{{item.icon}}' mode='aspectFill'></image>
<view class="text">{{item.name}}</view>
</view>
</view>

<view class='channelBox' tt:if="{{ifStoreApp==1}}" style="width:525rpx;">
<view class='kjBox' bindtap='gotoBargain'>
<image src='{{kanjia}}' mode='aspectFill'></image>
<text>砍价</text>
</view>
<view class='kjBox' bindtap='gotoSpellGroup'>
<image src='{{pintuan}}' mode='aspectFill'></image>
<text>拼团</text>
</view>
<view class='kjBox' bindtap='gotoRushBuy'>
<image src='{{xiaofeika}}' mode='aspectFill'></image>
<text>限时抢购</text>
</view>
</view>

</view>
<view class='toutiao1' tt:if="{{showQg&&ifStoreApp!=1}}">
<view class='xianshi' bindtap='gotoRushBuy'>
<text>限时专区</text>
<text>限时惊爆价 轻松拎回家</text>
</view>
<view class='xsCon'>
<view tt:for="{{xslist}}" tt:key="index">
<view class='igBox' data-couponId="{{item.couponId}}" data-couponChannelId="{{item.id}}"
data-targetAd="{{item.targetAd}}" bindtap='gotodetail'>
<image src='{{xslist[index].coverImg}}' mode='widthFix' class='imageH'></image>
<view class='imTit'>{{xslist[index].title}}</view>
</view>
</view>
<view>
<view class='igBox' bindtap='gotoRushBuy'>
<image src='{{more}}' mode='widthFix' class='more'></image>
<view class='imTit'>更多...</view>
</view>
</view>
</view>
</view>

<!-- 爆款专区 -->
<c-hot id="hot" />
<view class='product' tt:if="{{showTopic}}" bindtap='gotoTopic'>
<image src='{{cover}}' mode='widthFix'></image>
</view>


<c-coupons id="lists" bind:myevent="onGetCode" class="business" loadingtext="{{loadingtext}}"
loading="{{loading}}" />
<!-- 广告蒙层 -->
<!-- <c-advertisement id="advertisement" tt:if="{{showGg&&!played&&!havePlayEd1}}" ggdata="{{ggdata}}" /> -->
</view>
<!-- 顶部签到成长值 -->
<view class='signin' tt:if="{{fistLogin}}" animation="{{alphaData}}">
<open-data class="open" type="userAvatarUrl"></open-data>
<text class='text'>您今日签到成功,获得{{fistLogin}}成长值</text>
</view>
<view class="integralBox" tt:if="{{businessSwitch}}">
<!--是未授权微信且未授权手机号 -->
<navigator url="/pages/getuserinfo/index" open-type="navigate" tt:if="{{accreditFlag==1}}">
<image src='https://formall.oss-accelerate.aliyuncs.com/cimg/self-help-integral.png' mode='widthFix'
style="width: 100%;height: 100%;"></image>
</navigator>
<!-- 授权了微信 没授权手机号 -->
<navigator url="/pages/getuserinfo/index" open-type="navigate" tt:if="{{accreditFlag==2}}">
<image src='https://formall.oss-accelerate.aliyuncs.com/cimg/self-help-integral.png' mode='widthFix'
style="width: 100%;height: 100%;"></image>
</navigator>
</view>
</view>

+ 35
- 10
utils/HttpBasics.js Parādīt failu

@@ -21,21 +21,39 @@ class HttpBasics {
headers = {
"Content-Type": "application/json;charset=UTF-8",
token: "",
mallTenantId: ""
// token:"3ab2afa2-f704-4086-b6e5-ad0715c7e2a1:1027:tt-cuser"
};

/**
* 设置token
* @description 设置token
* @param {*} token
*/
setToken(token) {
this.headers.token = token;
}

/**
* @description 设置mallTenantId
* @param {*} mallTenantId
*/
setMallTenantId(mallTenantId) {
this.headers.mallTenantId = mallTenantId;
}

/**
* 获取数据
* @param {url,data,headers} param0
*/
get({ url, data, headers }) {
headers = { ...this.headers, ...headers };
get({
url,
data,
headers
}) {
headers = {
...this.headers,
...headers
};
url = `${this.address}${url}`;
return new Promise((resolve, reject) => {
tt.request({
@@ -45,16 +63,16 @@ class HttpBasics {
method: "get",
success: res => {
this.responseMap(res, resolve, reject);
},
},
fail: err => {
console.log(err)
if (err.errMsg == 'request:fail timeout') {
err.errMsg = '请求超时,请检查您的网络设置!'
} else if (err.errMsg == 'request:fail'){
} else if (err.errMsg == 'request:fail') {
err.errMsg = '未检查到您的网络,请检查您的网络设置!'
} else if (err.errMsg == 'request:fail request connect error') {
err.errMsg = '连接失败'
}
}
reject(err);
}
});
@@ -64,8 +82,15 @@ class HttpBasics {
* 提交数据
* @param {url,data,headers} param0
*/
post({ url, data, headers }) {
headers = { ...this.headers, ...headers };
post({
url,
data,
headers
}) {
headers = {
...this.headers,
...headers
};
url = `${this.address}${url}`;
return new Promise((resolve, reject) => {
tt.request({
@@ -83,7 +108,7 @@ class HttpBasics {
err.errMsg = '未检查到您的网络,请检查您的网络设置!'
} else if (err.errMsg == 'request:fail request connect error') {
err.errMsg = '连接失败'
}
}
reject(err);
},
complete: res => {}
@@ -117,4 +142,4 @@ class HttpBasics {
/** 日志 */
log(url, body, headers) {}
}
module.exports = new HttpBasics();
module.exports = new HttpBasics();

Notiek ielāde…
Atcelt
Saglabāt