<!--设备选择 --> | |||||
<template> | |||||
<view class="devices"> | |||||
<view class="device" v-for="(item, index) in deviceList" :key="index" @click="connectDevice(item)"> | |||||
<image :src="`${$imgUrl}bluetooth/card1.png`" class="head" mode="aspectFill"></image> | |||||
<view class="center"> | |||||
<view class="name">{{ item._name }}</view> | |||||
<view class="desc">编号 {{ item.name }}</view> | |||||
</view> | |||||
<image :src="item.selected ? selectedUrl : unSelectedUrl" class="icon" mode="aspectFill"></image> | |||||
</view> | |||||
<view class="hint"> | |||||
<view class="orange-txt as-layout-horizontal as-gravity-center-start"> | |||||
<image :src="`${$imgUrl}common/icon-hint.png`" mode="aspectFill"></image> | |||||
<view>温馨提示:</view> | |||||
</view> | |||||
<view class="grey-txt"> | |||||
指令执行过程中,请勿关闭蓝牙,勿将手机远离电子标签,以免导致写卡、写签失败。</view> | |||||
</view> | |||||
<view class="btn"> | |||||
<submit-button title="点击重新搜索蓝牙" @submit="load"></submit-button> | |||||
</view> | |||||
</view> | |||||
</template> | |||||
<script setup lang="ts"> | |||||
import { ref, reactive } from "vue"; | |||||
import { onLoad, onReady } from "@dcloudio/uni-app"; | |||||
import { fileURL } from "@/datas/fileURL.js"; | |||||
const imgURL = `${fileURL}image/`; | |||||
const selectedUrl = "common/selected.png`"; | |||||
const unSelectedUrl = "common/unselected.png`"; | |||||
const jyApi = require("../../static/etc/JYAPI/GenvictBleUtil.js"); | |||||
const jlQZApi = require("../../static/etc/JLQZAPI/JLObuSDK.js"); | |||||
const atApi = require("../../static/etc/ATAPI/ArtcBleUtil.js"); | |||||
const wqApi = require("../../static/etc/WQAPI/WCDObuSdk.js"); | |||||
const cgApi = require("../../static/etc/CGAPI/cguBle.js"); | |||||
const tools = require("../../static/etcUtil/tools.js"); | |||||
const datas = require("../../static/etcUtil/datas.js"); | |||||
const bluetoothUtil = require("../../static/etcUtil/index.js"); | |||||
let jlApi = require("../../static/etc/JLAPI/JLObuSDK.js"); //聚力SDK | |||||
let wjApi = require("../../static/etc/WJAPI/wjBleAPI"); | |||||
let tdApi = require("../../static/etc/TDAPI/TDRObuSDK.js"); | |||||
let zzApi = require("../../static/etc/WJAPI/wjBleAPI.js"); | |||||
let jtApi = require("../../static/etc/JTAPI/BleUtil.js"); | |||||
// #ifdef MP-ALIPAY | |||||
// 这部分代码将仅在支付宝小程序平台下执行 | |||||
jlApi = require("../../static/etc/JLObuSDK/JLObuSDK.js"); | |||||
wjApi = require("../../static/etc/wjBle/WJBleAPI"); | |||||
zzApi = require("../../static/etc/wjBle/WJBleAPI.js"); | |||||
tdApi = require("../../static/etc/TDRAPI/TDRObuSDK.js"); | |||||
jtApi = require("../../static/etc/JTAPIS/BleUtil.js"); | |||||
// 执行支付宝小程序的特定功能 | |||||
// #endif | |||||
const state = reactive({ | |||||
fee: "", | |||||
cardId: "", | |||||
showPopup: false, //显示激活成功提示 | |||||
curDeviceId: "", //当前选中的设备ID | |||||
deviceList: [ | |||||
//设备列表 | |||||
{ | |||||
id: "1", | |||||
image: imgURL + "bluetooth/card1.png`", | |||||
name: "聚力", | |||||
number: "235564444558855", | |||||
}, | |||||
], | |||||
}); | |||||
const deviceList = ref([]); | |||||
const connectPrefixName = ref(null); | |||||
const routeType = ref(null); //来源 1激活 2圈存 3信息重写 4信息读取 | |||||
interface DeviceType { | |||||
name : string; //设备名称 | |||||
deviceId : string; //uuid | |||||
prefixName : string; //前缀名称 | |||||
selected : boolean; //判断点击次数 | |||||
_name : string; //中文名称 | |||||
} | |||||
let device : DeviceType = reactive({ | |||||
name: "", //设备名称 | |||||
deviceId: "", //uuid | |||||
prefixName: "", //前缀名称 | |||||
selected: false, //判断点击次数 | |||||
_name: "", //中文名称 | |||||
}); | |||||
onReady(() => { | |||||
load(); | |||||
}); | |||||
const props = defineProps({ | |||||
//手机号 | |||||
routeType: { | |||||
type: String, | |||||
default: "", | |||||
}, | |||||
//短信模板编码 | |||||
cardId: { | |||||
type: String, | |||||
default: "", | |||||
}, | |||||
}); | |||||
onLoad((option) => { | |||||
routeType.value = props.routeType ? props.routeType : "1"; | |||||
state.cardId = props.cardId; | |||||
console.log("props", props) | |||||
}); | |||||
/* | |||||
* 蓝牙初始化 | |||||
*/ | |||||
const load = () => { | |||||
deviceList.value = []; | |||||
console.log("****************蓝牙getsetting******************"); | |||||
//断开蓝牙 | |||||
bluetoothUtil.disconnectDevice(); | |||||
uni.getSetting({ | |||||
success(res) { | |||||
console.log("****************成功******************"); | |||||
console.log("scopebluetooth:" + res.authSetting["scope.bluetooth"]); | |||||
console.log("成功结果:" + JSON.stringify(res)); | |||||
if (res.authSetting["scope.bluetooth"] == undefined) { | |||||
//不存在 | |||||
uni.authorize({ | |||||
scope: "scope.bluetooth", | |||||
success() { | |||||
console.log("扫描蓝牙中"); | |||||
tools.showLoadingAlert("扫描蓝牙中"); | |||||
console.log("11111111") | |||||
openBluetooth(); | |||||
}, | |||||
fail() { | |||||
uni.showToast({ | |||||
title: "蓝牙授权失败", | |||||
icon: "error", | |||||
duration: 1500, | |||||
}); | |||||
}, | |||||
}); | |||||
} else if (!res.authSetting["scope.bluetooth"]) { | |||||
//false | |||||
uni.showModal({ | |||||
title: "是否授权读取蓝牙", | |||||
content: "需要获取你的蓝牙,请确认授权,否则无法获取蓝牙", | |||||
success: function (mres) { | |||||
if (mres.confirm) { | |||||
uni.openSetting({ | |||||
success(authData) { | |||||
if (authData.authSetting["scope.bluetooth"] == true) { | |||||
tools.showLoadingAlert("扫描蓝牙中"); | |||||
console.log("2222222") | |||||
openBluetooth(); | |||||
} else { | |||||
uni.closeBluetoothAdapter(); | |||||
uni.showToast({ | |||||
title: "蓝牙授权失败", | |||||
icon: "error", | |||||
duration: 1500, | |||||
}); | |||||
} | |||||
}, | |||||
}); | |||||
} else if (mres.cancel) { | |||||
uni.showToast({ | |||||
title: "蓝牙授权失败", | |||||
icon: "error", | |||||
duration: 1000, | |||||
}); | |||||
} | |||||
}, | |||||
}); | |||||
} else { | |||||
tools.showLoadingAlert("扫描蓝牙中"); | |||||
openBluetooth(); | |||||
} | |||||
}, | |||||
fail(res) { | |||||
console.log("****************失败******************"); | |||||
console.log("失败结果:" + JSON.stringify(res)); | |||||
}, | |||||
}); | |||||
}; | |||||
/* | |||||
* 打开蓝牙 | |||||
*/ | |||||
const openBluetooth = () => { | |||||
console.log("进来了") | |||||
let foundDevices = []; //扫描到的蓝牙列表 | |||||
uni.closeBluetoothAdapter(); //先关闭蓝牙 | |||||
//打开蓝牙 | |||||
uni.openBluetoothAdapter({ | |||||
success: function (res) { | |||||
uni.startBluetoothDevicesDiscovery({ | |||||
success: function (res) { | |||||
console.log(res); | |||||
//扫描结果的监听 | |||||
uni.onBluetoothDeviceFound(function (res) { | |||||
// console.log(res.devices); | |||||
for (let i = 0; i < res.devices.length; i++) { | |||||
let name = res.devices[i]["name"]; | |||||
let prefixName = ""; | |||||
let deviceId = res.devices[i]["deviceId"]; | |||||
console.log(res.devices[i]["name"]); | |||||
if (name != "" && name != undefined && name != "undefined") { | |||||
if ( | |||||
name.indexOf("G-WJ") != -1 || | |||||
name.indexOf("ETC") != -1 || | |||||
name.indexOf("G-JL") != -1 | |||||
) { | |||||
//前装设备 | |||||
prefixName = "ETC"; | |||||
} else { | |||||
//聚力临时设备 | |||||
if (name.indexOf("5201121") != -1) { | |||||
prefixName = "JL"; | |||||
} else { | |||||
prefixName = name.substring(0, 2); | |||||
} | |||||
} | |||||
prefixName = prefixName.toUpperCase(); | |||||
if ( | |||||
prefixName == "WJ" || | |||||
prefixName == "JL" || | |||||
prefixName == "JY" || | |||||
prefixName == "AT" || | |||||
prefixName == "JT" || | |||||
prefixName == "WQ" || | |||||
prefixName == "CG" || | |||||
prefixName == "TD" || | |||||
prefixName == "ZZ" || | |||||
prefixName == "ETC" | |||||
) { | |||||
// //隐藏加载框 | |||||
tools.hideLoadingAlert(); | |||||
device.name = name; | |||||
device.deviceId = deviceId; | |||||
device.prefixName = prefixName; | |||||
device.selected = false; //防止重复点击 | |||||
console.log("device._prefixName", prefixName) | |||||
let _name = ""; | |||||
switch (prefixName) { | |||||
case "WJ": | |||||
_name = "万集"; | |||||
break; | |||||
case "JL": | |||||
_name = "聚利"; | |||||
break; | |||||
case "JY": | |||||
_name = "金溢"; | |||||
break; | |||||
case "AT": | |||||
_name = "埃特斯"; | |||||
break; | |||||
case "JT": | |||||
_name = "建投"; | |||||
break; | |||||
case "WQ": | |||||
_name = "握奇"; | |||||
break; | |||||
case "CG": | |||||
_name = "成谷"; | |||||
break; | |||||
case "TD": | |||||
_name = "天地融"; | |||||
break; | |||||
case "ZZ": | |||||
_name = "智载"; | |||||
break; | |||||
case "ETC": | |||||
_name = "前装"; | |||||
break; | |||||
default: | |||||
_name = "未知"; | |||||
break; | |||||
} | |||||
device._name = _name; | |||||
console.log("device._name11111", device._name) | |||||
if (deviceList.value.length == 0) { | |||||
// #ifdef MP-ALIPAY | |||||
if (device._name == '聚利' || device._name == '万集' || device._name == '天地融') { | |||||
foundDevices.push(device); | |||||
console.log("device._name", device._name) | |||||
} | |||||
// #endif | |||||
// #ifdef MP-WEIXIN | |||||
foundDevices.push(device); | |||||
// #endif | |||||
} else { | |||||
let isHave = false; | |||||
for (let j = 0; j < foundDevices.length; j++) { | |||||
if (name == foundDevices[j].deviceId) { | |||||
isHave = true; | |||||
break; | |||||
} | |||||
} | |||||
if (!isHave) { | |||||
foundDevices.push(device); | |||||
} | |||||
} | |||||
console.log("deviceList.value", foundDevices) | |||||
// deviceList.value = foundDevices; | |||||
foundDevices = []; | |||||
// console.log(foundDevices); | |||||
} | |||||
} | |||||
} | |||||
}); | |||||
}, | |||||
fail: function (res) { | |||||
console.log(res); | |||||
}, | |||||
}); | |||||
}, | |||||
fail: function (res) { | |||||
console.log(res); | |||||
alertF("手机蓝牙未打开或不支持蓝牙"); | |||||
}, | |||||
}); | |||||
}; | |||||
/** | |||||
* 连接蓝牙 | |||||
*/ | |||||
const connectDevice = (e) => { | |||||
console.log(e); | |||||
let item = e; | |||||
//停止扫描蓝牙 | |||||
console.info("停止扫描蓝牙"); | |||||
uni.stopBluetoothDevicesDiscovery({ | |||||
success: function (res) { | |||||
console.log(device, item); | |||||
if (item.selected == false) { | |||||
console.log("第一次点击了"); | |||||
item.selected = true; | |||||
setTimeout(function () { | |||||
if (device.selected == undefined) { | |||||
console.info("selected is undefined"); | |||||
linkFail(); //未找到设备, 请重新搜索 | |||||
return; | |||||
} | |||||
item.selected = false; | |||||
}, 4000); | |||||
} else { | |||||
console.log("第二次点击了"); | |||||
return; | |||||
} | |||||
if ( | |||||
item.prefixName == undefined || | |||||
item.prefixName == "undefined" || | |||||
item.prefixName == "" | |||||
) { | |||||
console.info("device.prefixName is undefined"); | |||||
linkFail(); //未找到设备, 请重新搜索 | |||||
return; | |||||
} | |||||
let prefixName = item.prefixName; | |||||
connectPrefixName.value = item.prefixName; | |||||
// delete device.prefixName | |||||
// delete device._name | |||||
console.log(item); | |||||
datas.setData("deviceId", device, device.deviceId); | |||||
tools.showLoadingAlert("蓝牙连接中"); | |||||
console.info("连接的是" + prefixName); | |||||
switch (prefixName) { | |||||
case "WJ": | |||||
wjApi.connectDevice( | |||||
device, | |||||
function (res) { | |||||
console.log('WJ输出内容1', res) | |||||
connectSuccess(res); | |||||
}, | |||||
function (res) { | |||||
console.log('WJ输出内容2', res) | |||||
listenStatus(res); | |||||
} | |||||
); | |||||
break; | |||||
case "JL": | |||||
jlApi.connectDevice( | |||||
device, | |||||
function (res) { | |||||
connectSuccess(res); | |||||
}, | |||||
function (res) { | |||||
listenStatus(res); | |||||
} | |||||
); | |||||
break; | |||||
case "ETC": | |||||
jlQZApi.connectDevice( | |||||
device, | |||||
function (res) { | |||||
preDevice(res); | |||||
}, | |||||
function (res) { | |||||
listenStatus(res); | |||||
} | |||||
); | |||||
break; | |||||
case "JY": | |||||
jyApi.connectDevice( | |||||
device, | |||||
function (res) { | |||||
connectSuccess(res); | |||||
}, | |||||
function (res) { | |||||
listenStatus(res); | |||||
} | |||||
); | |||||
break; | |||||
case "AT": | |||||
atApi.connectDevice( | |||||
device, | |||||
function (res) { | |||||
connectSuccess(res); | |||||
}, | |||||
function (res) { | |||||
listenStatus(res); | |||||
} | |||||
); | |||||
break; | |||||
case "JT": | |||||
jtApi.connectDevice( | |||||
device, | |||||
function (res) { | |||||
connectSuccess(res); | |||||
}, | |||||
function (res) { | |||||
listenStatus(res); | |||||
} | |||||
); | |||||
break; | |||||
case "WQ": | |||||
wqApi.connectDevice( | |||||
device, | |||||
function (res) { | |||||
connectSuccess(res); | |||||
}, | |||||
function (res) { | |||||
listenStatus(res); | |||||
} | |||||
); | |||||
break; | |||||
case "CG": | |||||
cgApi.connectDevice( | |||||
device, | |||||
function (res) { | |||||
connectSuccess(res); | |||||
}, | |||||
function (res) { | |||||
listenStatus(res); | |||||
} | |||||
); | |||||
break; | |||||
case "TD": | |||||
tdApi.connectDevice( | |||||
device, | |||||
function (res) { | |||||
connectSuccess(res); | |||||
}, | |||||
function (res) { | |||||
listenStatus(res); | |||||
} | |||||
); | |||||
break; | |||||
case "ZZ": | |||||
zzApi.connectDevice( | |||||
device, | |||||
function (res) { | |||||
connectSuccess(res); | |||||
}, | |||||
function (res) { | |||||
listenStatus(res); | |||||
} | |||||
); | |||||
break; | |||||
default: //未找到设备, 请重新搜索 | |||||
linkFail(); | |||||
break; | |||||
} | |||||
}, | |||||
fail: function (res) { | |||||
console.log(res); | |||||
linkFail(); //未找到设备, 请重新搜索 | |||||
}, | |||||
}); | |||||
}; | |||||
/** | |||||
* 未找到设备, 请重新搜索 | |||||
*/ | |||||
const linkFail = () => { | |||||
datas.setData("bluLinkStatus", false); | |||||
datas.setData("connectPrefixName", ""); | |||||
tools.showModalAlert("未找到设备, 请重新搜索", function successFunc() { | |||||
load(); | |||||
}); | |||||
}; | |||||
/** | |||||
* 连接成功 | |||||
*/ | |||||
const emit = defineEmits<{ | |||||
(e : "submit", connectSuccess : any, cardId : any) : void; | |||||
}>(); | |||||
const connectSuccess = (res) => { | |||||
console.log("================================================") | |||||
console.log("连接回调函数func1"); | |||||
console.log(res); | |||||
if (res.code == 0) { | |||||
console.log("连接成功"); | |||||
datas.setData("bluLinkStatus", true); | |||||
datas.setData("connectPrefixName", connectPrefixName.value); | |||||
//routeType 1.激活(订单来) 2.圈存 (/pages/recharge/recharge来)3.信息重写 4.信息读取 5从哪里来回哪里去监听bluetoothLink | |||||
if (routeType.value == "1") { | |||||
uni.navigateTo({ | |||||
url: "/subpackage/after-sale/activation/activate", | |||||
}); | |||||
} else if (routeType.value == "2") { | |||||
// uni.navigateTo({ | |||||
// url: `/pages/recharge/recharge?connectSuccess=1&&cardId=${state.cardId}`, | |||||
// }); | |||||
emit("submit", 1, state.cardId); | |||||
} else if (routeType.value == "3") { | |||||
} else if (routeType.value == "4") { | |||||
uni.navigateTo({ | |||||
url: "/subpackage/after-sale/deviceInfo/deviceInfo", | |||||
}); | |||||
} | |||||
else if (routeType.value == "5") { | |||||
uni.$emit('bluetoothLink', { status: true }) | |||||
uni.navigateBack({ | |||||
delta: 1 | |||||
}) | |||||
} else { | |||||
return; | |||||
} | |||||
} else { | |||||
alertF(res.msg); | |||||
} | |||||
}; | |||||
/** | |||||
* 前装设备 | |||||
*/ | |||||
const preDevice = (res) => { | |||||
if (res.code == 0) { | |||||
console.log("连接成功"); | |||||
datas.setData("bluLinkStatus", true); | |||||
datas.setData("connectPrefixName", connectPrefixName.value); | |||||
// tools.toUrl(route.preActivateInfo);//跳转 前装设备 | |||||
} else { | |||||
alertF(res.msg); | |||||
console.log(res.msg); | |||||
} | |||||
}; | |||||
/** | |||||
* 监听蓝牙状态 | |||||
*/ | |||||
const listenStatus = (res) => { | |||||
console.log("时时监听蓝牙状态func234"); | |||||
console.log(res); | |||||
if (res.code == 0) { | |||||
datas.setData("bluLinkStatus", true); | |||||
datas.setData("connectPrefixName", connectPrefixName.value); | |||||
connectSuccess(res); | |||||
} else { | |||||
console.log('输出内容', '=====================================') | |||||
datas.setData("bluLinkStatus", false); | |||||
datas.setData("connectPrefixName", ""); | |||||
tools.showToastAlert("蓝牙已断开"); | |||||
} | |||||
}; | |||||
/** | |||||
* 提示加关蓝牙 | |||||
*/ | |||||
const alertF = (msg : string) => { | |||||
//隐藏加载框 | |||||
tools.hideLoadingAlert(); | |||||
//断开蓝牙 | |||||
bluetoothUtil.disconnectDevice(); | |||||
//提示对话框 | |||||
tools.showModalAlert(msg); | |||||
}; | |||||
</script> | |||||
<style> | |||||
page { | |||||
background-color: #f3f3f3; | |||||
} | |||||
:deep(.u-mode-center-box) { | |||||
border-radius: 20rpx; | |||||
} | |||||
</style> | |||||
<style lang="scss" scoped> | |||||
.devices { | |||||
.device { | |||||
width: calc(100% - 30rpx); | |||||
margin-left: 30rpx; | |||||
display: flex; | |||||
flex-direction: row; | |||||
align-items: center; | |||||
margin-top: 30rpx; | |||||
background: white; | |||||
padding: 25rpx 20rpx; | |||||
border-top-left-radius: 20rpx; | |||||
border-bottom-left-radius: 20rpx; | |||||
box-shadow: 0px 10px 10rpx 10rpx rgba(223, 223, 223, 0.3); | |||||
.head { | |||||
width: 120rpx; | |||||
height: 120rpx; | |||||
border-radius: 10rpx; | |||||
background-color: #f3f3f3; | |||||
} | |||||
.center { | |||||
flex: 1; | |||||
margin-left: 30rpx; | |||||
margin-right: 30rpx; | |||||
.name { | |||||
font-size: 30rpx; | |||||
color: #333333; | |||||
} | |||||
.desc { | |||||
font-size: 26rpx; | |||||
color: #666666; | |||||
margin-top: 25rpx; | |||||
} | |||||
} | |||||
.icon { | |||||
width: 43rpx; | |||||
height: 43rpx; | |||||
margin-right: 10rpx; | |||||
} | |||||
} | |||||
.hint { | |||||
margin: 60rpx 30rpx 0px; | |||||
.orange-txt { | |||||
font-size: 26rpx; | |||||
color: #ff8000; | |||||
image { | |||||
width: 30rpx; | |||||
height: 30rpx; | |||||
margin-right: 10rpx; | |||||
} | |||||
} | |||||
.grey-txt { | |||||
font-size: 26rpx; | |||||
color: #666666; | |||||
line-height: 40rpx; | |||||
margin-top: 16rpx; | |||||
} | |||||
} | |||||
.btn { | |||||
margin: 70rpx 40rpx; | |||||
} | |||||
} | |||||
</style> |
}); | }); | ||||
} else if (routeType.value == "2") { | } else if (routeType.value == "2") { | ||||
// #ifdef MP-ALIPAY | // #ifdef MP-ALIPAY | ||||
uni.navigateTo({ | |||||
url: `/pages/recharge/recharge?connectSuccess=1&&cardId=${state.cardId}&&fee=${state.fee}`, | |||||
}); | |||||
// uni.navigateTo({ | |||||
// url: `/pages/recharge/recharge?connectSuccess=1&&cardId=${state.cardId}&&fee=${state.fee}`, | |||||
// }); | |||||
// #endif | // #endif | ||||
// #ifdef MP-WEIXIN | |||||
uni.navigateTo({ | uni.navigateTo({ | ||||
url: `/pages/recharge/recharge-weixin?connectSuccess=${state.connectSuccess}`, | url: `/pages/recharge/recharge-weixin?connectSuccess=${state.connectSuccess}`, | ||||
}); | }); | ||||
// #endif | |||||
} else if (routeType.value == "3") { | } else if (routeType.value == "3") { | ||||
} else if (routeType.value == "4") { | } else if (routeType.value == "4") { |
} | } | ||||
const cardRecharge = (val) => { | const cardRecharge = (val) => { | ||||
// #ifdef MP-ALIPAY | // #ifdef MP-ALIPAY | ||||
msg("业务升级中,请前往九州ETC公众号进行办理。或拨打客服电话400-800-8787") | |||||
// val==1 navTo('/pages/recharge/select-car', true) 去圈存的 支付宝 | |||||
// msg("业务升级中,请前往九州ETC公众号进行办理。或拨打客服电话400-800-8787") | |||||
if (val == 1) { | |||||
navTo('/pages/recharge/recharge-pay', true) | |||||
} | |||||
// #endif | // #endif | ||||
// #ifdef MP-WEIXIN | // #ifdef MP-WEIXIN | ||||
if (val == 1) { | if (val == 1) { | ||||
navTo('/pages/recharge/recharge-pay', true) | navTo('/pages/recharge/recharge-pay', true) | ||||
// navTo('/pages/recharge/recharge', true) | |||||
} else if (val == 2) { | } else if (val == 2) { | ||||
navTo('/subpackage/after-sale/rescind-carId/rescind-carId-select', true) | navTo('/subpackage/after-sale/rescind-carId/rescind-carId-select', true) | ||||
} | } |
gotoActiveOrder, | gotoActiveOrder, | ||||
gotoReturnOrder, | gotoReturnOrder, | ||||
gotoExchangeOrder, | gotoExchangeOrder, | ||||
gotoPay, | |||||
gotoOrderDetailsPay, | gotoOrderDetailsPay, | ||||
gotoOrderDetails, | gotoOrderDetails, | ||||
gotoAgainUseOrder, | gotoAgainUseOrder, |
<template> | <template> | ||||
<view class="oderPage"> | |||||
<view class="head"> | |||||
您的ETC卡类型是记账卡,需要先解约,才可继续办理更换业务,请确认您的签约信息 | |||||
</view> | |||||
<u-form :model="form" ref="myForm" :error-type="errorType"> | |||||
<view class="from"> | |||||
<u-form-item prop="name"> | |||||
<view class="from_item"> | |||||
<text><text style="color: red"></text>签约银行</text> | |||||
<u-input v-model="form.bank" value="" class="input" disabled /> | |||||
</view> | |||||
</u-form-item> | |||||
<u-form-item prop="name"> | |||||
<view class="from_item"> | |||||
<text><text style="color: red"></text>签约时间</text> | |||||
<u-input | |||||
v-model="form.time" | |||||
value="2022-10-11 12:11:12" | |||||
class="input" | |||||
disabled | |||||
/> | |||||
</view> | |||||
</u-form-item> | |||||
<u-form-item prop="name"> | |||||
<view class="from_item"> | |||||
<text><text style="color: red"></text>卡号</text> | |||||
<u-input | |||||
v-model="form.code" | |||||
value="12312313213123" | |||||
class="input" | |||||
disabled | |||||
/> | |||||
</view> | |||||
</u-form-item> | |||||
<u-form-item prop="name"> | |||||
<view class="from_item"> | |||||
<text><text style="color: red"></text>车牌号</text> | |||||
<u-input | |||||
v-model="form.carID" | |||||
value="贵A123321" | |||||
class="input" | |||||
disabled | |||||
/> | |||||
</view> | |||||
</u-form-item> | |||||
</view> | |||||
</u-form> | |||||
<button class="submit" @click="toPage()">下一步</button> | |||||
</view> | |||||
<view class="oderPage"> | |||||
<view class="head"> | |||||
您的ETC卡类型是记账卡,需要先解约,才可继续办理更换业务,请确认您的签约信息 | |||||
</view> | |||||
<u-form :model="form" ref="myForm" :error-type="errorType"> | |||||
<view class="from"> | |||||
<u-form-item prop="name"> | |||||
<view class="from_item"> | |||||
<text><text style="color: red"></text>签约银行</text> | |||||
<u-input v-model="form.bank" value="" class="input" disabled /> | |||||
</view> | |||||
</u-form-item> | |||||
<u-form-item prop="name"> | |||||
<view class="from_item"> | |||||
<text><text style="color: red"></text>签约时间</text> | |||||
<u-input v-model="form.time" value="2022-10-11 12:11:12" class="input" disabled /> | |||||
</view> | |||||
</u-form-item> | |||||
<u-form-item prop="name"> | |||||
<view class="from_item"> | |||||
<text><text style="color: red"></text>卡号</text> | |||||
<u-input v-model="form.code" value="12312313213123" class="input" disabled /> | |||||
</view> | |||||
</u-form-item> | |||||
<u-form-item prop="name"> | |||||
<view class="from_item"> | |||||
<text><text style="color: red"></text>车牌号</text> | |||||
<u-input v-model="form.carID" value="贵A123321" class="input" disabled /> | |||||
</view> | |||||
</u-form-item> | |||||
</view> | |||||
</u-form> | |||||
<button class="submit" @click="toPage()">下一步</button> | |||||
</view> | |||||
</template> | </template> | ||||
<script setup lang="ts"> | <script setup lang="ts"> | ||||
import navBar from "./components/nav-bar.vue"; | |||||
import { checkStr } from "@/utils/utils"; | |||||
import { ref, reactive } from "vue"; | |||||
import { navTo } from "@/utils/utils"; | |||||
import { onReady } from "@dcloudio/uni-app"; | |||||
// 表单数据 | |||||
const form = reactive({ | |||||
bank: "工商银行", | |||||
time: "2022-10-11 10:12:30", | |||||
code: "12321123312313", | |||||
carID: "贵A123321", | |||||
}); | |||||
// 验证规则 | |||||
const rules = { | |||||
receiving1: [ | |||||
{ | |||||
required: true, | |||||
message: "请选择", | |||||
trigger: ["change", "blur"], | |||||
}, | |||||
], | |||||
receiving2: [ | |||||
{ | |||||
required: true, | |||||
message: "请选择", | |||||
trigger: ["change", "blur"], | |||||
}, | |||||
], | |||||
code: [ | |||||
{ | |||||
required: true, | |||||
message: "请输入", | |||||
trigger: ["change", "blur"], | |||||
}, | |||||
], | |||||
phone: [ | |||||
{ | |||||
required: true, | |||||
message: "请输入手机号", | |||||
trigger: ["change", "blur"], | |||||
}, | |||||
{ | |||||
// 自定义验证函数,见上说明 | |||||
validator: (rule, value, callback) => { | |||||
// 上面有说,返回true表示校验通过,返回false表示不通过 | |||||
console.log(checkStr(value, "mobile"), "0011"); | |||||
return checkStr(value, "mobile"); | |||||
}, | |||||
message: "手机号码不正确", | |||||
trigger: ["change", "blur"], | |||||
}, | |||||
], | |||||
// status: [{ | |||||
// required: true, | |||||
// message: '请选择状态', | |||||
// | |||||
// trigger: ['change', 'blur'], | |||||
}; | |||||
// 验证提示类型(toast要版本为1.3.5才支持) | |||||
const errorType = ["message", "border-bottom", "toast"]; | |||||
// 设置验证规则 | |||||
const myForm = ref(null); | |||||
onReady(() => { | |||||
myForm.value.setRules(rules); | |||||
}); | |||||
// 单选数据列表 | |||||
const radiolist1 = reactive([ | |||||
{ | |||||
name: "营业点自提", | |||||
disabled: false, | |||||
}, | |||||
{ | |||||
name: "邮寄", | |||||
disabled: false, | |||||
}, | |||||
]); | |||||
// 单选 | |||||
const radioChange = (n) => { | |||||
console.log("radioChange", n); | |||||
// if (n == '卡退费') { | |||||
// flag.value = true | |||||
// console.log(flag.value); | |||||
// } else { | |||||
// flag.value = false | |||||
// console.log(flag.value); | |||||
// } | |||||
}; | |||||
// // 提交 | |||||
// const submit = () => { | |||||
// myForm.value.validate((valid) => { | |||||
// console.log(valid); | |||||
// if (valid) { | |||||
// console.log('验证通过', form); | |||||
// } else { | |||||
// console.log('验证未通过'); | |||||
// } | |||||
// }) | |||||
// } | |||||
const toPage = () => { | |||||
navTo("/subpackage/after-sale/replace-equipment/release-products"); | |||||
// uni.showModal({ | |||||
// title: '模拟两种情况', | |||||
// confirmText: '有卡有签', | |||||
// cancelText: '无卡无签', | |||||
// success: function(res) { | |||||
// if (res.confirm) { | |||||
// console.log('用户点击确定'); | |||||
// navTo('/pages/bluetooth/bluetooth') | |||||
// } else if (res.cancel) { | |||||
// console.log('用户点击取消'); | |||||
// navTo('/subpackage/after-sale/ETC-log-off/upload-card') | |||||
// } | |||||
// } | |||||
// }); | |||||
}; | |||||
import navBar from "./components/nav-bar.vue"; | |||||
import { checkStr } from "@/utils/utils"; | |||||
import { ref, reactive } from "vue"; | |||||
import { navTo } from "@/utils/utils"; | |||||
import { onReady } from "@dcloudio/uni-app"; | |||||
// 表单数据 | |||||
const form = reactive({ | |||||
bank: "工商银行", | |||||
time: "2022-10-11 10:12:30", | |||||
code: "12321123312313", | |||||
carID: "贵A123321", | |||||
}); | |||||
// 验证规则 | |||||
const rules = { | |||||
receiving1: [ | |||||
{ | |||||
required: true, | |||||
message: "请选择", | |||||
trigger: ["change", "blur"], | |||||
}, | |||||
], | |||||
receiving2: [ | |||||
{ | |||||
required: true, | |||||
message: "请选择", | |||||
trigger: ["change", "blur"], | |||||
}, | |||||
], | |||||
code: [ | |||||
{ | |||||
required: true, | |||||
message: "请输入", | |||||
trigger: ["change", "blur"], | |||||
}, | |||||
], | |||||
phone: [ | |||||
{ | |||||
required: true, | |||||
message: "请输入手机号", | |||||
trigger: ["change", "blur"], | |||||
}, | |||||
{ | |||||
// 自定义验证函数,见上说明 | |||||
validator: (rule, value, callback) => { | |||||
// 上面有说,返回true表示校验通过,返回false表示不通过 | |||||
console.log(checkStr(value, "mobile"), "0011"); | |||||
return checkStr(value, "mobile"); | |||||
}, | |||||
message: "手机号码不正确", | |||||
trigger: ["change", "blur"], | |||||
}, | |||||
], | |||||
// status: [{ | |||||
// required: true, | |||||
// message: '请选择状态', | |||||
// | |||||
// trigger: ['change', 'blur'], | |||||
}; | |||||
// 验证提示类型(toast要版本为1.3.5才支持) | |||||
const errorType = ["message", "border-bottom", "toast"]; | |||||
// 设置验证规则 | |||||
const myForm = ref(null); | |||||
onReady(() => { | |||||
myForm.value.setRules(rules); | |||||
}); | |||||
// 单选数据列表 | |||||
const radiolist1 = reactive([ | |||||
{ | |||||
name: "营业点自提", | |||||
disabled: false, | |||||
}, | |||||
{ | |||||
name: "邮寄", | |||||
disabled: false, | |||||
}, | |||||
]); | |||||
// 单选 | |||||
const radioChange = (n) => { | |||||
console.log("radioChange", n); | |||||
// if (n == '卡退费') { | |||||
// flag.value = true | |||||
// console.log(flag.value); | |||||
// } else { | |||||
// flag.value = false | |||||
// console.log(flag.value); | |||||
// } | |||||
}; | |||||
// // 提交 | |||||
// const submit = () => { | |||||
// myForm.value.validate((valid) => { | |||||
// console.log(valid); | |||||
// if (valid) { | |||||
// console.log('验证通过', form); | |||||
// } else { | |||||
// console.log('验证未通过'); | |||||
// } | |||||
// }) | |||||
// } | |||||
const toPage = () => { | |||||
navTo("/subpackage/after-sale/replace-equipment/release-products"); | |||||
}; | |||||
</script> | </script> | ||||
<style> | <style> | ||||
page { | |||||
width: 100%; | |||||
height: 100%; | |||||
display: flex; | |||||
flex-direction: column; | |||||
background: #eef7f7; | |||||
} | |||||
page { | |||||
width: 100%; | |||||
height: 100%; | |||||
display: flex; | |||||
flex-direction: column; | |||||
background: #eef7f7; | |||||
} | |||||
</style> | </style> | ||||
<style lang="scss" scoped> | <style lang="scss" scoped> | ||||
.oderPage { | |||||
flex: 1; | |||||
width: 100%; | |||||
.head { | |||||
padding: 30rpx; | |||||
font-size: 28rpx; | |||||
color: #303133; | |||||
padding-bottom: 0; | |||||
} | |||||
.from { | |||||
background-color: #fff; | |||||
margin-top: 30rpx; | |||||
padding: 0 30rpx; | |||||
::v-deep .u-form-item { | |||||
padding: 0; | |||||
line-height: normal; | |||||
.u-form-item__message { | |||||
margin-bottom: 12rpx; | |||||
} | |||||
} | |||||
.from_item { | |||||
display: flex; | |||||
flex-wrap: nowrap; | |||||
justify-content: space-between; | |||||
align-items: center; | |||||
height: 80rpx; | |||||
border-bottom: 1rpx solid #dcdcdc; | |||||
.btn { | |||||
font-size: 24rpx; | |||||
font-family: Microsoft YaHei; | |||||
font-weight: 400; | |||||
color: #ffffff; | |||||
background: #00b38b; | |||||
border-radius: 10rpx; | |||||
padding: 10rpx 15rpx; | |||||
} | |||||
::v-deep .input { | |||||
text-align: right; | |||||
flex: 1; | |||||
background: transparent; | |||||
input { | |||||
text-align: right; | |||||
} | |||||
} | |||||
} | |||||
.from_item1 { | |||||
display: flex; | |||||
flex-wrap: nowrap; | |||||
flex-direction: column; | |||||
justify-content: space-between; | |||||
padding: 30rpx; | |||||
border-bottom: #dcdcdc 1px solid; | |||||
input { | |||||
text-align: right; | |||||
} | |||||
.textarea { | |||||
background-color: #f1f1f1; | |||||
width: 100%; | |||||
border-radius: 20rpx; | |||||
margin-top: 10rpx; | |||||
text-indent: 1rem; | |||||
height: 180rpx; | |||||
padding: 20rpx; | |||||
box-sizing: border-box; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
.submit { | |||||
background: linear-gradient(to left, #43a1e0 0%, #13e7c1 100%); | |||||
width: 670rpx; | |||||
height: 80rpx; | |||||
color: #fff; | |||||
border-radius: 100rpx; | |||||
position: fixed; | |||||
left: 50%; | |||||
transform: translate(-50%); | |||||
bottom: 60rpx; | |||||
font-size: 32rpx; | |||||
} | |||||
</style> | |||||
.oderPage { | |||||
flex: 1; | |||||
width: 100%; | |||||
.head { | |||||
padding: 30rpx; | |||||
font-size: 28rpx; | |||||
color: #303133; | |||||
padding-bottom: 0; | |||||
} | |||||
.from { | |||||
background-color: #fff; | |||||
margin-top: 30rpx; | |||||
padding: 0 30rpx; | |||||
::v-deep .u-form-item { | |||||
padding: 0; | |||||
line-height: normal; | |||||
.u-form-item__message { | |||||
margin-bottom: 12rpx; | |||||
} | |||||
} | |||||
.from_item { | |||||
display: flex; | |||||
flex-wrap: nowrap; | |||||
justify-content: space-between; | |||||
align-items: center; | |||||
height: 80rpx; | |||||
border-bottom: 1rpx solid #dcdcdc; | |||||
.btn { | |||||
font-size: 24rpx; | |||||
font-family: Microsoft YaHei; | |||||
font-weight: 400; | |||||
color: #ffffff; | |||||
background: #00b38b; | |||||
border-radius: 10rpx; | |||||
padding: 10rpx 15rpx; | |||||
} | |||||
::v-deep .input { | |||||
text-align: right; | |||||
flex: 1; | |||||
background: transparent; | |||||
input { | |||||
text-align: right; | |||||
} | |||||
} | |||||
} | |||||
.from_item1 { | |||||
display: flex; | |||||
flex-wrap: nowrap; | |||||
flex-direction: column; | |||||
justify-content: space-between; | |||||
padding: 30rpx; | |||||
border-bottom: #dcdcdc 1px solid; | |||||
input { | |||||
text-align: right; | |||||
} | |||||
.textarea { | |||||
background-color: #f1f1f1; | |||||
width: 100%; | |||||
border-radius: 20rpx; | |||||
margin-top: 10rpx; | |||||
text-indent: 1rem; | |||||
height: 180rpx; | |||||
padding: 20rpx; | |||||
box-sizing: border-box; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
.submit { | |||||
background: linear-gradient(to left, #43a1e0 0%, #13e7c1 100%); | |||||
width: 670rpx; | |||||
height: 80rpx; | |||||
color: #fff; | |||||
border-radius: 100rpx; | |||||
position: fixed; | |||||
left: 50%; | |||||
transform: translate(-50%); | |||||
bottom: 60rpx; | |||||
font-size: 32rpx; | |||||
} | |||||
</style> |
import { getItem, StorageKeys } from "@/utils/storage.ts"; | import { getItem, StorageKeys } from "@/utils/storage.ts"; | ||||
import { | import { | ||||
checkOrderStatus, | checkOrderStatus, | ||||
orderPay, | |||||
wechatAppID, | wechatAppID, | ||||
wechatPayConfigId, | wechatPayConfigId, | ||||
wechatSecret, | wechatSecret, | ||||
const flag = ref(1); | const flag = ref(1); | ||||
const savaHandle = () => { | const savaHandle = () => { | ||||
// wxPayment() | |||||
uni.redirectTo({ | uni.redirectTo({ | ||||
url: "/subpackage/after-sale/to-bookkeeping-card/result", | url: "/subpackage/after-sale/to-bookkeeping-card/result", | ||||
}); | }); | ||||
}); | }); | ||||
// #endif | // #endif | ||||
} | } | ||||
//掉起微信支付 | |||||
const wxPayment = () => { | |||||
// #ifdef MP-WEIXIN | |||||
const options = { | |||||
type: 2, | |||||
data: { | |||||
openid: state.openid, | |||||
productId: "027af827c70140d1ab4c68940f4793f2", //TODO 后端给的,用于调试测试 | |||||
orderId: state.orderId, | |||||
payConfigId: wechatPayConfigId, | |||||
}, | |||||
method: "POST", | |||||
showLoading: true, | |||||
}; | |||||
request(orderPay, options).then((res) => { | |||||
const data = stringToJson(res.bizContent); | |||||
uni.requestPayment({ | |||||
provider: "wxpay", | |||||
orderInfo: "", | |||||
timeStamp: data.timestamp, | |||||
nonceStr: data.noncestr, | |||||
package: data.wxPackage ? data.wxPackage : "", | |||||
signType: data.signType, | |||||
paySign: data.sign, | |||||
success: function (e) { | |||||
console.log("支付成功", e); | |||||
checkOrder(); | |||||
}, | |||||
fail: function (err) { | |||||
confirm(err, () => { }, "支付失败", false); | |||||
}, | |||||
}); | |||||
}); | |||||
// #endif | |||||
}; | |||||
//支付成功改变订单状态 | //支付成功改变订单状态 | ||||
const checkOrder = () => { | const checkOrder = () => { | ||||
const options = { | const options = { |
<button type="default" class="button" @click="savaHandle()"> | <button type="default" class="button" @click="savaHandle()"> | ||||
确认支付 | 确认支付 | ||||
</button> | </button> | ||||
<!-- <button type="default" class="button" @click="addInterestsList()"> | |||||
加购权益 | |||||
</button> --> | |||||
</view> | </view> | ||||
</template> | </template> | ||||
} from "@/utils/storage.ts"; | } from "@/utils/storage.ts"; | ||||
import { | import { | ||||
checkOrderStatus, | checkOrderStatus, | ||||
orderPay, | |||||
wechatAppID, | wechatAppID, | ||||
wechatPayConfigId, | wechatPayConfigId, | ||||
wechatSecret, | wechatSecret, | ||||
const savaHandle = () => { | const savaHandle = () => { | ||||
console.log("state.productId.length", state.productId.length) | console.log("state.productId.length", state.productId.length) | ||||
//判断是否有加购权益 | |||||
// if (state.productId.length > 0) { | |||||
// queryAddProduct(); | |||||
// } | |||||
// uni.showModal({ | |||||
// // title: '提示', | |||||
// content: '确定支付', | |||||
// success: function (res) { | |||||
// if (res.confirm) { | |||||
// console.log('用户点击确定'); | |||||
// wxPayment(); | |||||
// } else if (res.cancel) { | |||||
// console.log('用户点击取消'); | |||||
// } | |||||
// } | |||||
// }); | |||||
// msg("确定绑定权益产品"); | |||||
// wxPayment(); | |||||
if (state.typeScanCode == 2) { | if (state.typeScanCode == 2) { | ||||
console.log("state.typeScanCode", state.typeScanCode) | console.log("state.typeScanCode", state.typeScanCode) | ||||
// 扫码进来 | // 扫码进来 | ||||
}); | }); | ||||
// #endif | // #endif | ||||
} | } | ||||
//唤起微信支付 | |||||
const wxPayment = () => { | |||||
// #ifdef MP-WEIXIN | |||||
const options = { | |||||
type: 2, | |||||
data: { | |||||
openid: state.openid, | |||||
productId: state.id, | |||||
orderId: state.orderId, | |||||
payConfigId: wechatPayConfigId, | |||||
}, | |||||
method: "POST", | |||||
showLoading: true, | |||||
}; | |||||
request(orderPay, options).then((res) => { | |||||
const data = stringToJson(res.bizContent); | |||||
uni.requestPayment({ | |||||
provider: "wxpay", | |||||
orderInfo: "", | |||||
timeStamp: data.timestamp, | |||||
nonceStr: data.noncestr, | |||||
package: data.wxPackage ? data.wxPackage : "", | |||||
signType: data.signType, | |||||
paySign: data.sign, | |||||
success: function (e) { | |||||
console.log("支付成功", e); | |||||
checkOrder(); | |||||
}, | |||||
fail: function (err) { | |||||
// checkOrder(); | |||||
confirm(err, () => { }, "支付失败", false); | |||||
}, | |||||
}); | |||||
}); | |||||
// #endif | |||||
}; | |||||
//支付成功改变订单状态 | //支付成功改变订单状态 | ||||
const checkOrder = () => { | const checkOrder = () => { |