*/ | */ | ||||
function alertF(msg) { | function alertF(msg) { | ||||
// 隐藏加载框 | // 隐藏加载框 | ||||
tools.hideLoadingAlert(); | |||||
// tools.hideLoadingAlert(); | |||||
// 提示对话框 | // 提示对话框 | ||||
tools.showModalAlert(msg); | tools.showModalAlert(msg); | ||||
} | } |
completeFun(res); | completeFun(res); | ||||
} | } | ||||
//添加安全锁,防止Loading不会关闭 | //添加安全锁,防止Loading不会关闭 | ||||
setTimeout(() => { | |||||
hideLoadingAlert() | |||||
}, 5000) | |||||
// setTimeout(() => { | |||||
// hideLoadingAlert() | |||||
// }, 5000) | |||||
} | } | ||||
}); | }); | ||||
} | } |
</view> | </view> | ||||
</view> | </view> | ||||
<view class="up_btn" v-if="state.showBtn"> | <view class="up_btn" v-if="state.showBtn"> | ||||
<button aria-disabled="true" @click="btn" v-if="!state.isSuccess" | |||||
:class="state.disabled?'button':'hui'"> | |||||
<button aria-disabled="true" @click="btn" v-if="!state.isSuccess" :class="state.disabled?'button':'hui'"> | |||||
点击开始激活 | 点击开始激活 | ||||
</button> | </button> | ||||
<button aria-disabled="true" @click="back" v-else> | <button aria-disabled="true" @click="back" v-else> | ||||
customerTel: "", | customerTel: "", | ||||
customerId: "", | customerId: "", | ||||
orderId: "", | orderId: "", | ||||
vehicleClassStr:"" | |||||
vehicleClassStr: "" | |||||
}); | }); | ||||
function cmdResult() { | function cmdResult() { | ||||
uni.showToast({ | |||||
title: '正在激活,请等待', | |||||
mask: true, | |||||
duration:10000, | |||||
icon:"loading" | |||||
}); | |||||
const options = { | |||||
type: 2, //type: 2,JSON格式提交数据(默认表单形式提交) | |||||
data: { | |||||
orderId: orderInfo.orderId, | |||||
issueType: state.transfer?2:1 //1正常激活 2 过户激活 | |||||
}, //请求参数 | |||||
method: "POST", //提交方式(默认POST) | |||||
}; | |||||
console.log("options==",options) | |||||
//BDS-二发指令申请 | |||||
request('4b001421f5354c248a7759971881b52f', options) | |||||
.then((res) => { | |||||
console.log("在线激活 请求"); | |||||
console.log(stringToJson(res.bizContent)); | |||||
const datas = stringToJson(res.bizContent).data; | |||||
console.log("datas===",datas) | |||||
bluetoothUtil.transCmd(datas.cmd.split(','), datas.cmdType=='CARD'?'10':'20', function(res) { | |||||
console.log("res申请",res) | |||||
implementCmd(datas.transOrderId,datas.cmd,res.toString(),datas.stepNo) | |||||
const options = { | |||||
type: 2, //type: 2,JSON格式提交数据(默认表单形式提交) | |||||
showLoading: false, | |||||
data: { | |||||
orderId: orderInfo.orderId, | |||||
issueType: state.transfer ? 2 : 1 //1正常激活 2 过户激活 | |||||
}, //请求参数 | |||||
method: "POST", //提交方式(默认POST) | |||||
}; | |||||
console.log("options==", options) | |||||
tools.showLoadingAlert('正在激活,请等待') | |||||
//BDS-二发指令申请 | |||||
request('4b001421f5354c248a7759971881b52f', options) | |||||
.then((res) => { | |||||
console.log("在线激活 请求"); | |||||
console.log(stringToJson(res.bizContent)); | |||||
const datas = stringToJson(res.bizContent).data; | |||||
bluetoothUtil.transCmd(datas.cmd.split(','), datas.cmdType == 'CARD' ? '10' : '20', function(res) { | |||||
implementCmd(datas.transOrderId, datas.cmd, res.toString(), datas.stepNo) | |||||
}, () => { | |||||
showModals('在线激活异常') | |||||
tools.hideLoadingAlert(); | |||||
}); | |||||
}) | |||||
.catch((err) => { | |||||
console.log(err); | |||||
tools.hideLoadingAlert(); | |||||
}); | |||||
} | |||||
function implementCmd(transOrderId, cmd, cmdResult, stepNo) { | |||||
const options = { | |||||
type: 2, //type: 2,JSON格式提交数据(默认表单形式提交) | |||||
showLoading: false, | |||||
data: { | |||||
transOrderId, //步骤号 | |||||
cmd, | |||||
cmdResult, | |||||
stepNo | |||||
}, //请求参数 | |||||
method: "POST", //提交方式(默认POST) | |||||
}; | |||||
console.log("options2222", options) | |||||
//BDS-二发指令回传 | |||||
request('88d98f2db7df4f06b22d58b507db7854', options) | |||||
.then((res) => { | |||||
console.log(stringToJson(res.bizContent)); | |||||
const datas = stringToJson(res.bizContent).data; | |||||
console.log("在线激活 请求", datas); | |||||
if (datas.stepNo == 100) { | |||||
state.disabled = true | |||||
tools.hideLoadingAlert(); | |||||
msg("激活成功", { | |||||
'icon': 'success', | |||||
'duration': 3000 | |||||
}) | |||||
setTimeout(() => { | |||||
uni.navigateTo({ | |||||
url: "/subpackage/after-sale/deviceInfo/deviceInfo", | |||||
}); | |||||
}, 3000) | |||||
} else { | |||||
console.log("datas.stepNo", datas.stepNo) | |||||
bluetoothUtil.transCmd(datas.cmd.split(','), datas.cmdType == 'CARD' ? '10' : '20', function(res) { | |||||
implementCmd(transOrderId, datas.cmd, res.toString(), datas.stepNo) | |||||
}, () => { | }, () => { | ||||
showModals('在线激活异常') | showModals('在线激活异常') | ||||
// tools.hideLoadingAlert(); | // tools.hideLoadingAlert(); | ||||
uni.hideToast() | |||||
}); | }); | ||||
}) | |||||
.catch((err) => { | |||||
console.log(err); | |||||
// tools.hideLoadingAlert(); | |||||
uni.hideToast() | |||||
console.log("Yin") | |||||
}); | |||||
} | |||||
function implementCmd(transOrderId, cmd, cmdResult, stepNo) { | |||||
uni.showToast({ | |||||
title: '正在激活,请等待', | |||||
mask: true, | |||||
duration:5000, | |||||
icon:"loading" | |||||
} | |||||
}) | |||||
.catch((err) => { | |||||
console.log(err); | |||||
tools.hideLoadingAlert(); | |||||
}); | }); | ||||
const options = { | |||||
type: 2, //type: 2,JSON格式提交数据(默认表单形式提交) | |||||
data: { | |||||
transOrderId, //步骤号 | |||||
cmd, | |||||
cmdResult, | |||||
stepNo | |||||
}, //请求参数 | |||||
method: "POST", //提交方式(默认POST) | |||||
}; | |||||
console.log("options2222",options) | |||||
//BDS-二发指令回传 | |||||
request('88d98f2db7df4f06b22d58b507db7854', options) | |||||
.then((res) => { | |||||
console.log(stringToJson(res.bizContent)); | |||||
const datas = stringToJson(res.bizContent).data; | |||||
console.log("在线激活 请求",datas); | |||||
if (datas.stepNo == 100) { | |||||
state.disabled = true | |||||
// tools.hideLoadingAlert(); | |||||
uni.hideToast() | |||||
msg("激活成功",{'icon':'success','duration':3000}) | |||||
setTimeout(() => { | |||||
uni.navigateTo({ | |||||
url: "/subpackage/after-sale/deviceInfo/deviceInfo", | |||||
}); | |||||
}, 3000) | |||||
} else { | |||||
console.log("datas.stepNo",datas.stepNo) | |||||
bluetoothUtil.transCmd(datas.cmd.split(','), datas.cmdType=='CARD'?'10':'20', function(res) { | |||||
implementCmd(transOrderId,datas.cmd,res.toString(),datas.stepNo) | |||||
}, () => { | |||||
showModals('在线激活异常') | |||||
// tools.hideLoadingAlert(); | |||||
uni.hideToast() | |||||
}); | |||||
} | |||||
}) | |||||
.catch((err) => { | |||||
console.log(err); | |||||
// tools.hideLoadingAlert(); | |||||
uni.hideToast() | |||||
}); | |||||
} | |||||
} | |||||
//开始激活 按钮事件 | //开始激活 按钮事件 | ||||
const btn = () => { | const btn = () => { | ||||
state.disabled = false | state.disabled = false | ||||
console.log('orderInfo参数', orderInfo, state.disabled) | console.log('orderInfo参数', orderInfo, state.disabled) | ||||
cmdResult() | cmdResult() | ||||
}; | }; | ||||
id: id, | id: id, | ||||
}, | }, | ||||
method: "POST", | method: "POST", | ||||
showLoading: true, | |||||
showLoading: false, | |||||
}; | }; | ||||
state.disabled = false | state.disabled = false | ||||
request(IFCODE.orderDetail, options).then((res) => { | request(IFCODE.orderDetail, options).then((res) => { | ||||
orderId: orderId, | orderId: orderId, | ||||
}, | }, | ||||
method: "POST", | method: "POST", | ||||
showLoading: true, | |||||
showLoading: false | |||||
// showLoading: true, | |||||
}; | }; | ||||
request(IFCODE.cancelOrderApi, options).then((res) => { | request(IFCODE.cancelOrderApi, options).then((res) => { | ||||
const getObuId = () => { | const getObuId = () => { | ||||
console.log('======获取OBU号======') | console.log('======获取OBU号======') | ||||
let cmdArray = [cmd.HOME_DIRECTORY, cmd.OBU_SYSTEM_FILE, cmd.RANDOM_NUMBER]; | let cmdArray = [cmd.HOME_DIRECTORY, cmd.OBU_SYSTEM_FILE, cmd.RANDOM_NUMBER]; | ||||
tools.showLoadingAlert("正在执行指令"); | |||||
// tools.showLoadingAlert("正在执行指令"); | |||||
bluetoothUtil.transCmd(cmdArray, "20", function(res) { | bluetoothUtil.transCmd(cmdArray, "20", function(res) { | ||||
tools.hideLoadingAlert(); | |||||
// tools.hideLoadingAlert(); | |||||
var status = res[1].substring(res[1].length - 4, res[1].length); | var status = res[1].substring(res[1].length - 4, res[1].length); | ||||
console.log('获取OBU号执行结果' + status, res) | console.log('获取OBU号执行结果' + status, res) | ||||
// #ifdef MP-WEIXIN | // #ifdef MP-WEIXIN | ||||
msg("激活成功",{'icon':'success','duration':2000}) | |||||
msg("激活成功", { | |||||
'icon': 'success', | |||||
'duration': 2000 | |||||
}) | |||||
setTimeout(() => { | setTimeout(() => { | ||||
uni.navigateTo({ | uni.navigateTo({ | ||||
url: "/subpackage/after-sale/deviceInfo/deviceInfo", | url: "/subpackage/after-sale/deviceInfo/deviceInfo", |
</view> | </view> | ||||
</view> | </view> | ||||
<view class="btns"> | <view class="btns"> | ||||
<view class="btn btn-primary as-gravity-center" @click="gotoConfirmReceipt(item)" | |||||
v-if="item.orderStep==9 && item.orderStatus=='0'">确认收货</view> | |||||
<view class="btn btn-primary as-gravity-center" @click="gotoActiveOrder(item)" | |||||
v-if="item.orderStep==10 && item.orderStatus=='0'">去激活</view> | |||||
<view class="btn btn-primary as-gravity-center" @click="gotoOnceActivate(item)" | |||||
v-if="item.orderStep==11 && item.orderStatus=='1'">OBU重新激活</view> | |||||
<view class="btn btn-primary as-gravity-center" @click="gotoConfirmReceipt(item)" v-if="item.orderStep==9 && item.orderStatus=='0'">确认收货</view> | |||||
<view class="btn btn-primary as-gravity-center" @click="gotoActiveOrder(item)" v-if="item.orderStep==10 && item.orderStatus=='0'">去激活</view> | |||||
<view class="btn btn-primary as-gravity-center" @click="gotoOnceActivate(item)" v-if="item.orderStep==11 && item.orderStatus=='1'">OBU重新激活</view> | |||||
</view> | </view> | ||||
</view> | </view> | ||||
import { request } from "@/utils/network/request.js"; | import { request } from "@/utils/network/request.js"; | ||||
import { stringToJson } from "@/utils/network/encryption"; | import { stringToJson } from "@/utils/network/encryption"; | ||||
import { onLoad, onUnload, onReachBottom, onPullDownRefresh } from "@dcloudio/uni-app"; | import { onLoad, onUnload, onReachBottom, onPullDownRefresh } from "@dcloudio/uni-app"; | ||||
import { getItem, StorageKeys,setItem } from "@/utils/storage"; | |||||
import { hasLogin, msg, getOrderStatusName, getOrderTypeName, navTo } from "@/utils/utils"; | |||||
import { noActivationOrder,ndActivateVerification,silentLoginApi} from "@/utils/network/api"; | |||||
import { getItem, StorageKeys } from "@/utils/storage"; | |||||
import { hasLogin, msg, getOrderStatusName, getOrderTypeName,navTo} from "@/utils/utils"; | |||||
import { noActivationOrder } from "@/utils/network/api"; | |||||
import { PageData } from "@/datas/enum"; | import { PageData } from "@/datas/enum"; | ||||
import useOrderSkip from "@/composables/order/useOrderSkip"; | import useOrderSkip from "@/composables/order/useOrderSkip"; | ||||
//跳转 | //跳转 | ||||
const { gotoActiveOrder, gotoConfirmReceipt } = useOrderSkip(); | |||||
const gotoOnceActivate = (item) => { | |||||
// #ifdef MP-WEIXIN | |||||
navTo( | |||||
`/subpackage/after-sale/activation-once-again/activation-once-again?id=${item.id}` | |||||
); | |||||
// #endif | |||||
// #ifdef MP-ALIPAY | |||||
navTo( | |||||
`/subpackage/after-sale/activation-once-again/activation-once-again-ali?id=${item.id}` | |||||
); | |||||
// #endif | |||||
} | |||||
const { gotoActiveOrder,gotoConfirmReceipt } = useOrderSkip(); | |||||
const gotoOnceActivate=(item)=>{ | |||||
// #ifdef MP-WEIXIN | |||||
navTo( | |||||
`/subpackage/after-sale/activation-once-again/activation-once-again?id=${item.id}` | |||||
); | |||||
// #endif | |||||
// #ifdef MP-ALIPAY | |||||
navTo( | |||||
`/subpackage/after-sale/activation-once-again/activation-once-again-ali?id=${item.id}` | |||||
); | |||||
// #endif | |||||
} | |||||
const config = { | const config = { | ||||
emptyHint: { | emptyHint: { | ||||
hint: '~ 暂无待激活订单 ~', | hint: '~ 暂无待激活订单 ~', | ||||
status: 'more', | status: 'more', | ||||
reload: false, | reload: false, | ||||
ordersList: [], | ordersList: [], | ||||
vehicleId:"", | |||||
tel:"", | |||||
qdOrderNo:"" | |||||
}) | }) | ||||
/* 刷新列表 */ | /* 刷新列表 */ | ||||
} | } | ||||
} | } | ||||
onLoad((option) => { | |||||
// 诺德数据过来 验证+无感登录 | |||||
if(option.qdOrderNo){ | |||||
params.qdOrderNo=option.qdOrderNo | |||||
params.tel=option.tel | |||||
params.vehicleId=option.vehicleId | |||||
ndActivateVerificationQuery().then((data) => { | |||||
console.log("验证") | |||||
silentLogin(data).then(() => { | |||||
//监听订单刷新信息 | |||||
uni.$on('refreshOrder', (data) => { | |||||
refreshList(); | |||||
}); | |||||
console.log("guoliale") | |||||
refreshList(); | |||||
}) | |||||
}) | |||||
}else{ | |||||
//监听订单刷新信息 | |||||
uni.$on('refreshOrder', (data) => { | |||||
refreshList(); | |||||
onLoad(() => { | |||||
if (!hasLogin()) { | |||||
uni.showModal({ | |||||
title: '提示', | |||||
content: '您还未登录小程序,请先登录小程序', | |||||
showCancel: false, | |||||
success: function (res) { | |||||
if (res.confirm) { | |||||
navTo(`/login/login?back=1`) | |||||
} | |||||
} | |||||
}); | }); | ||||
console.log("guoliale") | |||||
refreshList(); | |||||
} | } | ||||
}); | |||||
// 诺德激活验证接口 | |||||
const ndActivateVerificationQuery = () => { | |||||
const options = { | |||||
type: 2, | |||||
data: { | |||||
"code": "1", //诺德 | |||||
"qdOrderNo": params.qdOrderNo, //渠道订单号 | |||||
"tel": params.tel, | |||||
"vehicleId": params.vehicleId, | |||||
}, | |||||
method: "POST", | |||||
showLoading: true, | |||||
}; | |||||
return new Promise(async (resolve, reject) => { | |||||
const res = await request(ndActivateVerification, options); | |||||
const data = stringToJson(res.bizContent); | |||||
console.log("data==", data) | |||||
resolve(data); | |||||
}).catch((error) => { | |||||
reject(error); | |||||
//监听订单刷新信息 | |||||
uni.$on('refreshOrder', (data) => { | |||||
refreshList(); | |||||
}); | }); | ||||
console.log("guoliale") | |||||
refreshList(); | |||||
}); | |||||
} | |||||
const silentLogin = (data) => { | |||||
if (data.userType == "1") { | |||||
var datas = { | |||||
userType: data.userType, | |||||
account: data.mobile, | |||||
loginSource: getItem("loginSource"), | |||||
}; | |||||
} else { | |||||
var datas = { | |||||
userType: data.userType, | |||||
account: data.userIdNum, | |||||
loginSource: getItem("loginSource"), | |||||
}; | |||||
} | |||||
const options = { | |||||
type: 2, | |||||
data: datas, | |||||
method: "POST", | |||||
showLoading: true, | |||||
}; | |||||
return new Promise(async (resolve, reject) => { | |||||
const res = await request(silentLoginApi, options); | |||||
const data = stringToJson(res.bizContent); | |||||
setItem("openId", data.openId); | |||||
setItem("token", data.accessToken); | |||||
resolve(data); | |||||
}).catch((error) => { | |||||
reject(error); | |||||
}); | |||||
} | |||||
onUnload(() => { | onUnload(() => { | ||||
uni.$off('refreshOrder'); | uni.$off('refreshOrder'); | ||||
}); | }); | ||||
border: 1px solid #dcdcdc; | border: 1px solid #dcdcdc; | ||||
color: #333; | color: #333; | ||||
} | } | ||||
</style> | |||||
</style> |
}); | }); | ||||
} | } | ||||
//请求 | //请求 | ||||
export function request(code, options = {}, start = false) { | export function request(code, options = {}, start = false) { | ||||
//公参 | //公参 | ||||
accessToken: getItem(StorageKeys.Token), | accessToken: getItem(StorageKeys.Token), | ||||
openId: getItem(StorageKeys.OpenId), | openId: getItem(StorageKeys.OpenId), | ||||
opId: getItem(StorageKeys.OpenId), | opId: getItem(StorageKeys.OpenId), | ||||
} | } | ||||
// options.url = envs[process.env.NODE_ENV].baseUrl + '/api/interfaceMidGroundIn' | // options.url = envs[process.env.NODE_ENV].baseUrl + '/api/interfaceMidGroundIn' | ||||
} | } | ||||
}); | }); | ||||
} else { | } else { | ||||
tools.hideLoadingAlert(); | |||||
uni.hideToast() | |||||
if (options.showLoading) { | |||||
tools.hideLoadingAlert(); | |||||
uni.hideToast() | |||||
} | |||||
console.log("请求失败返回参数", code, res) | console.log("请求失败返回参数", code, res) | ||||
uni.showModal({ | uni.showModal({ | ||||
title: '提示', | title: '提示', |