@@ -58,17 +58,17 @@ | |||
快速办理 | |||
</view> | |||
<view class="express-lane"> | |||
<view class="item keche"> | |||
<view class="item keche" @click="showMask(1)"> | |||
<view class="item-con"> | |||
<view class="top-txt"> | |||
客车用户 | |||
</view> | |||
<view class="btn"> | |||
<view class="btn" > | |||
进入 | |||
</view> | |||
</view> | |||
</view> | |||
<view class="item huoche"> | |||
<view class="item huoche" @click="showMask(2)"> | |||
<view class="item-con"> | |||
<view class="top-txt"> | |||
货车用户 | |||
@@ -181,6 +181,28 @@ | |||
</view> | |||
<!-- ETC选择弹窗 --> | |||
<view class="mask" v-if="isShowMask"> | |||
<view class="mask-content"> | |||
<filter> | |||
<view class="mask-close"> | |||
<image :src="fileURL + 'image/index/icon-close.png'" class="icon-closed" @click="closeMask"></image> | |||
</view> | |||
<view class="mask-title" :style="{ '--color': color }">选择ETC用户类型</view> | |||
<view class="mask-tab"> | |||
<view class="tab-item active" @click="toCreatOrder('1')"> | |||
<image :src="fileURL + 'image/index/icon-personal.png'" mode="aspectFill"></image> | |||
<text class="tab-tit on">个人办理</text> | |||
</view> | |||
<view class="tab-item" @click="toCreatOrder('2')"> | |||
<image :src="fileURL + 'image/index/icon-unit.png'" mode="aspectFill"></image> | |||
<text class="tab-tit on">单位办理</text> | |||
</view> | |||
</view> | |||
</filter> | |||
</view> | |||
</view> | |||
</template> | |||
<script setup lang="ts"> | |||
import { | |||
@@ -453,13 +475,14 @@ | |||
const toCreatOrder = (val : number) => { | |||
console.log(typeof (val)); | |||
state.userType = val; | |||
navTo(`/subpackage/orders/choice-product?type=${state.type}&&userType=${state.userType}`) | |||
navTo(`/subpackage/orders/choice-product?vanType=${state.type}&&userType=${state.userType}`) | |||
closeMask(); | |||
}; | |||
const showMask = (val : any) => { | |||
state.type = val; //1 客车 2货车 | |||
isShowMask.value = true; | |||
console.log("showMask",val) | |||
}; | |||
const closeMask = () => { | |||
@@ -1018,4 +1041,63 @@ | |||
} | |||
} | |||
} | |||
.mask { | |||
background: $uni-bg-color-mask; | |||
position: fixed; | |||
left: 0; | |||
top: 0; | |||
right: 0; | |||
bottom: 0; | |||
} | |||
.mask-content { | |||
background: $uni-bg-color; | |||
width: 570rpx; | |||
height: 480rpx; | |||
position: absolute; | |||
left: 50%; | |||
top: 50%; | |||
transform: translate(-50%, -50%); | |||
display: flex; | |||
flex-direction: column; | |||
border-radius: 20rpx; | |||
} | |||
.mask-close { | |||
text-align: right; | |||
} | |||
.mask-title { | |||
text-align: center; | |||
font-size: 32rpx; | |||
color: $uni-text-color-black; | |||
margin-bottom: 50rpx; | |||
} | |||
.mask-tab { | |||
display: flex; | |||
justify-content: space-evenly; | |||
} | |||
.tab-item { | |||
display: flex; | |||
flex-direction: column; | |||
justify-content: center; | |||
align-items: center; | |||
} | |||
.tab-tit { | |||
font-size: 32rpx; | |||
margin-top: 20rpx; | |||
color: #666; | |||
} | |||
.tab-item image { | |||
width: 160rpx; | |||
height: 160rpx; | |||
} | |||
.icon-closed { | |||
width: 48rpx; | |||
height: 48rpx; | |||
margin: 24rpx 24rpx 0 0; | |||
} | |||
</style> |
@@ -26,16 +26,10 @@ | |||
import empty from "@/components/empty/empty.vue"; | |||
import { onLoad, onReachBottom } from "@dcloudio/uni-app"; | |||
import { reactive } from "vue"; | |||
import { equityProductsApi, addEquityListApi } from "@/utils/network/api.js"; | |||
import { stringToJson } from "@/utils/network/encryption"; | |||
import { request } from "@/utils/network/request"; | |||
import { msg, navTo } from "@/utils/utils"; | |||
import { getEquityListApi } from "@/utils/network/api"; | |||
import { | |||
getItem, | |||
StorageKeys, | |||
setItem | |||
} from "@/utils/storage"; | |||
const state = reactive({ | |||
list: [], //权益数据 |
@@ -6,13 +6,13 @@ | |||
<view :style="`background-color:${bgc}`" style="border-radius: 16rpx;padding: 20rpx;margin-top: 20rpx;"> | |||
<view class="title" style="display: flex;flex-direction: row;justify-content: flex-start;"> | |||
<view style="font-weight: bold;margin-right: 10rpx;font-size: 18px;"> | |||
{{ item.promoteName }} | |||
{{ item.productName }} | |||
</view> | |||
<view> | |||
{{ item['releaseProductStandards']['productStandards']['cardTypeArr'] }} | |||
{{ item['cardTypeArr'] }} | |||
</view> | |||
</view> | |||
<view v-for="(str, index) in item.releaseProductStandards.equityList" :key="index" class="ul-item" | |||
<view v-for="(str, index) in item.equityList" :key="index" class="ul-item" | |||
style="padding: 0rpx;margin-top: 20rpx;" @click="savaHandle(item,index)"> | |||
<image style="width: 100%; height: 170rpx; border-radius: 20rpx" | |||
:src="`${$imgUrl}applyCard/product-bg.png`"></image> | |||
@@ -22,14 +22,14 @@ | |||
</image> | |||
<view class="content"> | |||
<view class="title"> | |||
{{ str.equityName }} | |||
{{ str.productName }} | |||
</view> | |||
<view style="margin-top: 15rpx" class="tip"> | |||
<!-- <view style="margin-top: 15rpx" class="tip"> | |||
{{ str.sellingPoint.substring(0,15) }} | |||
</view> | |||
</view> --> | |||
</view> | |||
<view class="money"> | |||
¥:{{ str.discountPrice * 0.01 }} | |||
¥:{{ item.fee * 0.01 }} | |||
</view> | |||
</view> | |||
</view> | |||
@@ -66,8 +66,8 @@ | |||
<script setup lang="ts"> | |||
import { onLoad, onPageScroll, onShow } from "@dcloudio/uni-app"; | |||
import { reactive, ref } from "vue"; | |||
import { etcQueryProduct } from "@/utils/network/api.js"; | |||
import { request } from "@/utils/network/request.js"; | |||
import { etcQueryProduct, pageQuery } from "@/utils/network/api.js"; | |||
import { request,requestNew } from "@/utils/network/request.js"; | |||
import { stringToJson } from "@/utils/network/encryption"; | |||
import { fileURL } from "@/datas/fileURL.js"; | |||
import navBgCar from "./components/nav-bg-car1"; | |||
@@ -108,17 +108,16 @@ | |||
setItem("promoteId", val.promoteId); | |||
state.isSign = val.isSign; | |||
state.signAgencyId = val['releaseProductStandards']['deviceType']; | |||
state.equityId = val.releaseProductStandards.equityList[idx].equityId; | |||
state.signAgencyId = val['deviceType']; | |||
state.equityId = val.equityList[idx].equityId; | |||
// 产品金额+权益金额 | |||
state.fee = Number(val.fee) + Number(val.releaseProductStandards.equityList[idx].discountPrice); | |||
state.fee = Number(val.fee) + Number(val.equityList[idx].discountPrice); | |||
// 判断是几张卡 | |||
console.log("state.dataArray[i]['releaseProductStandards']['productStandards']", val['releaseProductStandards']['productStandards']) | |||
if (val['releaseProductStandards']['productStandards']['cardTypeArr'].split(",").length == 1) { | |||
if (val['releaseProductStandards']['productStandards']['cardTypeArr'].split(",")[0] == "记账卡") { | |||
if (val['cardTypeArr'].split(",").length == 1) { | |||
if (val['cardTypeArr'].split(",")[0] == "记账卡") { | |||
state.isValueCard = 2 | |||
} else if (val['releaseProductStandards']['productStandards']['cardTypeArr'].split(",")[0] == '储值卡') { | |||
} else if (val['cardTypeArr'].split(",")[0] == '储值卡') { | |||
state.isValueCard = 1 | |||
} else { | |||
state.isValueCard = 2 | |||
@@ -126,14 +125,14 @@ | |||
console.log("state.isValueCard", state.isValueCard) | |||
setItem("isValueCard", state.isValueCard); | |||
uni.navigateTo({ | |||
url: `/subpackage/orders/interestsList?equityId=${val.releaseProductStandards.equityList[idx].equityId}&promoteId=${val['promoteId']}&userType=${state.userType}&type=${state.type}&isValueCard=${state.isValueCard}&fee=${state.fee}&signAgencyId=${val['releaseProductStandards']['deviceType']}`, | |||
url: `/subpackage/orders/interestsList?equityId=${val.equityList[idx].equityId}&promoteId=${val['promoteId']}&userType=${state.userType}&vanType=${state.vanType}&isValueCard=${state.isValueCard}&fee=${state.fee}&signAgencyId=${val['deviceType']}`, | |||
}); | |||
} else { | |||
state.radiolist1 = []; | |||
// 处理卡的数据 | |||
for (var i = 0; i < val['releaseProductStandards']['productStandards']['cardTypeArr'].split(",").length; i++) { | |||
for (var i = 0; i < val['cardTypeArr'].split(",").length; i++) { | |||
const obj = {}; | |||
obj["name"] = val['releaseProductStandards']['productStandards']['cardTypeArr'].split(",")[i]; | |||
obj["name"] = val['cardTypeArr'].split(",")[i]; | |||
obj["disabled"] = false; | |||
state.radiolist1.push(obj) | |||
} | |||
@@ -149,8 +148,8 @@ | |||
// #ifdef MP-WEIXIN | |||
state.sysType = 'WECHAT'; | |||
// #endif | |||
state.userType = option.userType; | |||
state.type = option.type; | |||
state.userType = Number(option.userType); | |||
state.vanType = Number(option.vanType); | |||
productList(); | |||
console.log("option选择产品列表", option) | |||
}); | |||
@@ -161,35 +160,33 @@ | |||
var data = { | |||
userType: state.userType, | |||
agencyId: agentId, | |||
vanType: state.type, | |||
promotionMode: 1 | |||
vanType: state.vanType, | |||
}; | |||
console.log("data",data) | |||
const options = { | |||
type: 2, | |||
data: data, | |||
method: "POST", | |||
showLoading: true, | |||
}; | |||
console.log("输出内容", options); | |||
request(etcQueryProduct, options).then((res) => { | |||
const data = stringToJson(res.bizContent); | |||
console.log("产品列表", data.list); | |||
requestNew(pageQuery, options).then((res) => { | |||
console.log("产品列表", res); | |||
const data = res; | |||
if (data.list && data.list.length > 0) { | |||
state.dataArray = data.list ? data.list : []; | |||
console.log("state.dataArray", state.dataArray); | |||
for (var i = 0; i < state.dataArray.length; i++) { | |||
const cardTypeArr = [] | |||
for (var j = 0; j < state.dataArray[i]['releaseProductStandards']['productStandards'].cardType.length; j++) { | |||
if (state.dataArray[i]['releaseProductStandards']['productStandards'].cardType[j] == '2') { | |||
for (var j = 0; j < state.dataArray[i].cardType.length; j++) { | |||
if (state.dataArray[i].cardType[j] == '2') { | |||
cardTypeArr.push('储值卡') | |||
} else if (state.dataArray[i]['releaseProductStandards']['productStandards'].cardType[j] == '1') { | |||
} else if (state.dataArray[i].cardType[j] == '1') { | |||
cardTypeArr.push('记账卡') | |||
} else if (state.dataArray[i]['releaseProductStandards']['productStandards'].cardType[j] == '3') { | |||
} else if (state.dataArray[i].cardType[j] == '3') { | |||
cardTypeArr.push('预存卡') | |||
} | |||
} | |||
state.dataArray[i]['releaseProductStandards']['productStandards']['cardTypeArr'] = cardTypeArr.toString() | |||
state.dataArray[i]['cardTypeArr'] = cardTypeArr.toString() | |||
} | |||
} else { | |||
uni.showModal({ | |||
@@ -199,9 +196,6 @@ | |||
success: function (res) { | |||
if (res.confirm) { | |||
console.log('用户点击确定'); | |||
uni.switchTab({ | |||
url: '/pages/index/index' | |||
}) | |||
} else if (res.cancel) { | |||
console.log('用户点击取消'); | |||
} | |||
@@ -225,7 +219,7 @@ | |||
sysType: "", | |||
orderId: "", | |||
userType: 1, //1 个人 2单位 | |||
type: 0, //0 客车 1货车 | |||
vanType: 0, //0 客车 1货车 | |||
vehiclePlateColor: "", | |||
data: { | |||
show: false, |
@@ -1,5 +1,5 @@ | |||
<template> | |||
<navBar title="九州ETC" :scrollTop="scrollTop" :type="state.data.type" :userType="state.data.userType"></navBar> | |||
<navBar title="九州ETC" :scrollTop="scrollTop" :type="state.data.vanType" :userType="state.data.userType"></navBar> | |||
<navBgCar></navBgCar> | |||
<view class="content-wrap"> | |||
<view> | |||
@@ -101,9 +101,10 @@ | |||
infoQuery, | |||
envs, | |||
addProduct, | |||
isSubmitOrderApi | |||
isSubmitOrderApi, | |||
orderAdd | |||
} from "@/utils/network/api.js"; | |||
import { request } from "@/utils/network/request.js"; | |||
import { request,requestNew } from "@/utils/network/request.js"; | |||
import { reactive, ref } from "vue"; | |||
import { msg, noticeUser } from "@/utils/utils"; | |||
const scrollTop = ref(0); | |||
@@ -112,9 +113,9 @@ | |||
vehiclePlate: undefined, //车牌号 | |||
vehiclePlateNumber: "", //车牌号 | |||
vehiclePlateColor: 0, //车牌颜色 | |||
type: "1", //车牌类型 | |||
vanType: 1, //客货类型 | |||
userType: 1, | |||
whetherToMail: getItem(StorageKeys.OpenId) ? 0 : "", //是否需要邮寄 小程序默认邮寄 0邮寄||1不邮寄 不登录为1 | |||
whetherToMail: getItem(StorageKeys.OpenId) ? true : "", //是否需要邮寄 小程序默认邮寄 true邮寄||1不邮寄 不登录为1 | |||
orderSource: "WECHAT", | |||
opId: "", | |||
consignee: "", //收货人 | |||
@@ -173,7 +174,7 @@ | |||
showLoading: true, | |||
}; | |||
request(etcCreatOrder, options).then((res) => { | |||
requestNew(orderAdd, options).then((res) => { | |||
console.log(res); | |||
if (res.statusCode === 600) { | |||
orderGoAction(); | |||
@@ -190,11 +191,11 @@ | |||
console.log("state.data.vehiclePlate", state.data.vehiclePlate, state.data.vehiclePlateColor, vehicleId) | |||
if (state.data.userType == 1) { | |||
uni.navigateTo({ | |||
url: `/subpackage/orders/opening-account-people?orderId=${data.orderId}&&vehiclePlateColor=${state.data.vehiclePlateColor}&isSign=${state.isValueCard}&type=${state.data.type}&vehicleId=${vehicleId}`, | |||
url: `/subpackage/orders/opening-account-people?orderId=${data.orderId}&&vehiclePlateColor=${state.data.vehiclePlateColor}&isSign=${state.isValueCard}&vanType=${state.data.vanType}&vehicleId=${vehicleId}`, | |||
}); | |||
} else { | |||
uni.navigateTo({ | |||
url: `/subpackage/orders/opening-account-unit?orderId=${data.orderId}&&vehiclePlateColor=${state.data.vehiclePlateColor}&isSign=${state.isValueCard}&type=${state.data.type}&vehicleId=${vehicleId}`, | |||
url: `/subpackage/orders/opening-account-unit?orderId=${data.orderId}&&vehiclePlateColor=${state.data.vehiclePlateColor}&isSign=${state.isValueCard}&vanType=${state.data.vanType}&vehicleId=${vehicleId}`, | |||
}); | |||
} | |||
}) | |||
@@ -255,9 +256,9 @@ | |||
}; | |||
onLoad((option : any) => { | |||
state.data.type = option.type; //1客车 2货车 | |||
state.data.vanType = Number(option.vanType); //1客车 2货车 | |||
state.data.opId = getItem(StorageKeys.OpenId); | |||
state.data.userType = option.userType; | |||
state.data.userType =Number(option.userType); | |||
state.data.promoteId = option.promoteId; | |||
state.data.vehiclePlate = option.vehiclePlate; | |||
state.data.vehiclePlateColor = option.vehiclePlateColor; |
@@ -1,5 +1,5 @@ | |||
<template> | |||
<navBar title="九州ETC" :scrollTop="scrollTop" :type="state.data.type" :userType="state.data.userType"></navBar> | |||
<navBar title="九州ETC" :scrollTop="scrollTop" :type="state.data.vanType" :userType="state.data.userType"></navBar> | |||
<navBgCar></navBgCar> | |||
<view class="content-wrap"> | |||
<!-- 车牌输入 --> | |||
@@ -10,7 +10,7 @@ | |||
<!-- 车牌颜色 --> | |||
<view class="chepai-lane"> | |||
<view class="title">选择车牌颜色</view> | |||
<numberplate-color :numberplate="state.data.vehiclePlateNumber" :type="state.data.type" | |||
<numberplate-color :numberplate="state.data.vehiclePlateNumber" :type="state.data.vanType" | |||
@numberplateResult="checkNumberplateColor"> | |||
</numberplate-color> | |||
</view> | |||
@@ -92,7 +92,7 @@ | |||
vehiclePlate: undefined, //车牌号 | |||
vehiclePlateNumber: "", //车牌号 | |||
vehiclePlateColor: 0, //车牌颜色 | |||
type: "1", //车牌类型 | |||
vanType: 1, //车牌类型 | |||
userType: 1, | |||
whetherToMail: getItem(StorageKeys.OpenId) ? 0 : "", //是否需要邮寄 小程序默认邮寄 0邮寄||1不邮寄 不登录为1 | |||
orderSource: "WECHAT", | |||
@@ -188,7 +188,7 @@ | |||
console.log("车牌信息", options) | |||
request(etcVehiclePlateVer, options).then((res) => { | |||
uni.redirectTo({ | |||
url: `/subpackage/orders/essential-information-two?promoteId=${getItem("promoteId")}&userType=${state.data.userType}&type=${state.data.type}&isValueCard=${state.isValueCard}&totalAmount=${state.totalAmount}&equityId=${state.equityId}&vehiclePlate=${state.data.vehiclePlate}&vehiclePlateColor=${state.data.vehiclePlateColor}`, | |||
url: `/subpackage/orders/essential-information-two?promoteId=${getItem("promoteId")}&userType=${state.data.userType}&vanType=${state.data.vanType}&isValueCard=${state.isValueCard}&totalAmount=${state.totalAmount}&equityId=${state.equityId}&vehiclePlate=${state.data.vehiclePlate}&vehiclePlateColor=${state.data.vehiclePlateColor}`, | |||
}); | |||
}); | |||
} else { | |||
@@ -249,7 +249,7 @@ | |||
}; | |||
onLoad((option : any) => { | |||
state.data.type = option.type; //1客车 2货车 | |||
state.data.vanType = option.vanType; //1客车 2货车 | |||
state.data.opId = getItem(StorageKeys.OpenId); | |||
state.data.userType = option.userType; | |||
state.data.promoteId = option.promoteId; |
@@ -34,7 +34,7 @@ import { deviceType } from "@/utils/network/difference"; | |||
choiceValue: [], //选择的权益数据的下标 | |||
choiceValueComplete: [], //选择的权益数据的具体数据 | |||
isValueCard: "", | |||
type: 0, | |||
vanType: 0, | |||
userType: 0, | |||
promoteId: "", //产品id | |||
totalAmount: 0, //产品+权益产品金额 | |||
@@ -58,7 +58,7 @@ import { deviceType } from "@/utils/network/difference"; | |||
state.clientFee = option.clientFee; | |||
state.equityId = option.equityId; | |||
state.userType = option.userType; | |||
state.type = option.type; | |||
state.vanType = option.vanType; | |||
state.isValueCard = option.isValueCard; | |||
state.promoteId = option.promoteId; | |||
state.totalAmount = option.fee; | |||
@@ -74,7 +74,7 @@ import { deviceType } from "@/utils/network/difference"; | |||
console.log("state.signAgencyId",state.signAgencyId,deviceType) | |||
if(state.signAgencyId==deviceType){ | |||
let obj={ | |||
type:state.type, | |||
type:state.vanType, | |||
userType:state.userType, | |||
promoteId:state.promoteId | |||
} | |||
@@ -88,7 +88,7 @@ import { deviceType } from "@/utils/network/difference"; | |||
} else { | |||
// 正常流程 | |||
uni.redirectTo({ | |||
url: `/subpackage/orders/essential-information?promoteId=${getItem("promoteId")}&userType=${state.userType}&type=${state.type}&isValueCard=${state.isValueCard}&totalAmount=${state.totalAmount}&equityId=${state.equityId}`, | |||
url: `/subpackage/orders/essential-information?promoteId=${getItem("promoteId")}&userType=${state.userType}&vanType=${state.vanType}&isValueCard=${state.isValueCard}&totalAmount=${state.totalAmount}&equityId=${state.equityId}`, | |||
}); | |||
} | |||
} |
@@ -249,11 +249,12 @@ | |||
register, | |||
envs, | |||
getUserMsg, | |||
ocrAllQuery | |||
ocrAllQuery, | |||
userUpload | |||
} from "@/utils/network/api.js"; | |||
import { | |||
request | |||
request, requestNew | |||
} from "@/utils/network/request.js"; | |||
import { | |||
@@ -296,7 +297,7 @@ | |||
sceneType: "", //用户协议支撑服务场景(发行服务机构和用户签订的协议) | |||
channelId: "", //渠道id | |||
gender: "", | |||
customerIdVld: "", | |||
customerIdVld: "", //用户证件有效期 | |||
agentName: "", | |||
agentGender: "", | |||
agentTel: '', | |||
@@ -381,7 +382,7 @@ | |||
method: "POST", | |||
showLoading: true, | |||
}; | |||
request(etcUserCardInfoSubmit, options).then((res) => { | |||
requestNew(userUpload, options).then((res) => { | |||
console.log(res); | |||
uni.redirectTo({ | |||
url: `/subpackage/orders/car-release?orderId=${state.orderId}&vehiclePlateColor=${state.vehiclePlateColor}&type=${state.type}&isSign=${state.isSign}&vehicleId=${state.vehicleId}`, |
@@ -310,4 +310,10 @@ export const versionVerificationApi = "d4f9dd3758ca41a1baa4f191df728f8b" //卡 | |||
export const interceptNDApi = "d8445c8b368d4b57bb6774aa51b91bb0" //拦截诺德 | |||
export const getOnLineUrlApi = "4b173ee5f550478ca22d4681fa9d8b42" //在线客服 | |||
export const signTest = "880ae48d40704572bac521b2fa11e93e" //异地支付宝签约检测 | |||
export const signTest = "880ae48d40704572bac521b2fa11e93e" //异地支付宝签约检测 | |||
// 新接口 | |||
export const pageQuery = "/iaw/issue/product/pageQuery" //产品分页查询 | |||
export const orderAdd = "/iaw/issue/order/add" //创建订单 | |||
export const userUpload = "/iaw/issue/user/userUpload" //用户信息上传 | |||
export const vehicleUpload= "/iaw/issue/vehicle/vehicleUpload" //车辆信息上传 |
@@ -298,4 +298,110 @@ export function request(code, options = {}, start = false) { | |||
} | |||
}); | |||
}); | |||
} | |||
//请求 | |||
export function requestNew(code, options = {}, start = false) { | |||
//公参 | |||
const Common = { | |||
// agentId: agentId, | |||
// channelId: channelId, | |||
// channelType: "1", | |||
// staffId: "54623263cb4d4a289dccbc983b22a4af", | |||
// terminalId: "999999999999", | |||
// loginSource: getItem("loginSource"), | |||
// rbacSource: 'MINI_PROGRAM', | |||
// accessToken: getItem(StorageKeys.Token), | |||
// openId: getItem(StorageKeys.OpenId), | |||
opId: getItem(StorageKeys.OpenId), | |||
orderSource:'WECHAT' | |||
} | |||
options.url = envs[process.env.NODE_ENV].baseUrl+'/ndev' + code | |||
//默认json数据格式提交` | |||
let contentType = 'application/json' | |||
//判断baseUri是否为空 | |||
if (options.baseUrlNew) { | |||
options.url = options.baseUrlNew | |||
} | |||
//根据type判断数据传输格式 | |||
if (options.type && options.type === 2) { | |||
contentType = 'application/json;charset=UTF-8' | |||
} | |||
//默认POST提交 | |||
options.method = options.method ? options.method : 'POST' | |||
//设置请求超时时间 | |||
options.timeout = 60000 | |||
options.header = { | |||
'content-type': contentType, | |||
'Access-Token': getItem(StorageKeys.Token) | |||
} | |||
if (!start) { | |||
//判断code不为空 | |||
if (code) { | |||
options.data =Object.assign(Common,{...options.data}); | |||
} | |||
} | |||
console.log('code', code, options.data) | |||
//是否显示加载中 | |||
if (options.showLoading) { | |||
uni.showLoading({ | |||
title: '请稍后', | |||
mask: true | |||
}); | |||
} | |||
//参数返回 | |||
return new Promise((resolve, reject) => { | |||
options.success = (res) => { | |||
// 请求返回后,隐藏loading(如果请求返回快的话,可能会没有loading) | |||
if (options.showLoading) { | |||
uni.hideLoading() | |||
} | |||
console.log("返回结果"+code,res) | |||
if (res.statusCode == 200 && res.data.code == 0) { | |||
resolve(res.data.data) | |||
} else { | |||
uni.showModal({ | |||
title: '提示', | |||
content: res.data.message, | |||
success: function(res) { | |||
if (res.confirm) { | |||
console.log('用户点击确定2'); | |||
} else if (res.cancel) { | |||
console.log('用户点击取消2'); | |||
} | |||
} | |||
}); | |||
reject(res.data.message) | |||
return | |||
} | |||
} | |||
options.fail = (err) => { | |||
uni.hideLoading() | |||
console.log('请求错误', err) | |||
//处理请求错误 | |||
reject(err) | |||
} | |||
uni.getNetworkType({ | |||
success: function(res) { | |||
if (res.networkType == 'none') { | |||
uni.showModal({ | |||
title: '提示', | |||
content: "网络异常", | |||
success: function(res) { | |||
if (res.confirm) { | |||
console.log('用户点击确定'); | |||
} else if (res.cancel) { | |||
console.log('用户点击取消'); | |||
} | |||
} | |||
}); | |||
} else { | |||
uni.request(options) | |||
} | |||
console.log("res.networkType", res.networkType); | |||
} | |||
}); | |||
}); | |||
} |