<script setup lang="ts"> | <script setup lang="ts"> | ||||
import { reactive } from "vue"; | import { reactive } from "vue"; | ||||
import { checkStr, msg, navTo } from "@/utils/utils"; | |||||
import { checkStr, msg, navTo, subscribeMessages } from "@/utils/utils"; | |||||
import { onLoad, onUnload } from "@dcloudio/uni-app"; | import { onLoad, onUnload } from "@dcloudio/uni-app"; | ||||
import { login, loginCode, loginTime, wechatAppID } from "@/utils/network/api.js"; | import { login, loginCode, loginTime, wechatAppID } from "@/utils/network/api.js"; | ||||
import { request } from "@/utils/network/request.js"; | import { request } from "@/utils/network/request.js"; | ||||
}); | }); | ||||
}); | }); | ||||
}; | }; | ||||
// 订阅消息 | |||||
const subscribeMessages = () => { | |||||
uni.requestSubscribeMessage({ | |||||
tmplIds: ['aNr4T2JEtaLtR9dihM2w3NAznz4bFMkutVZCbaSTjxg'], | |||||
success(res) { | |||||
console.log("订阅消息", res) | |||||
} | |||||
}) | |||||
} | |||||
</script> | </script> | ||||
<style lang="scss" scoped> | <style lang="scss" scoped> |
} | } | ||||
}, | }, | ||||
{ | { | ||||
"path" : "account-opening-template/account-opening-template", | |||||
"style" : | |||||
{ | |||||
"navigationBarTitleText" : "", | |||||
"enablePullDownRefresh" : false | |||||
"path": "account-opening-template/account-opening-template", | |||||
"style": { | |||||
"navigationBarTitleText": "", | |||||
"enablePullDownRefresh": false | |||||
} | } | ||||
} | } | ||||
] | ] | ||||
} | } | ||||
} | } | ||||
}, | }, | ||||
{ | |||||
"path": "takePhoto", | |||||
"style": { | |||||
"navigationBarTitleText": "" | |||||
} | |||||
}, | |||||
{ | { | ||||
"path": "changeInformation", | "path": "changeInformation", | ||||
"style": { | "style": { |
console.log("state.data.opId", state.data.opId) | console.log("state.data.opId", state.data.opId) | ||||
if (state.data.opId) { | if (state.data.opId) { | ||||
getUserInfo(); | getUserInfo(); | ||||
} else { | |||||
state.userVehicleInfoSumQueryVo = { | |||||
vehicleSum: 0, | |||||
orderStatus0: 0 | |||||
} | |||||
state.monthFlowingVo = { | |||||
duration: 0, | |||||
mileage: 0, | |||||
flowingNum: 0, | |||||
num: 0, | |||||
parkingLotMoney: 0, | |||||
parkingLotNum: 0, | |||||
money: 0, | |||||
}, | |||||
state.list = [], | |||||
state.carNumber = 0 | |||||
} | } | ||||
}); | }); | ||||
// 查询车辆信息 | // 查询车辆信息 | ||||
openId: state.data.opId | openId: state.data.opId | ||||
}, | }, | ||||
method: "POST", | method: "POST", | ||||
// showLoading: true, | |||||
showLoading: true, | |||||
}; | }; | ||||
//调用方式 | //调用方式 | ||||
request(userInfoIndex, options) | request(userInfoIndex, options) |
<template> | |||||
<view> | |||||
<viewfinder :phoneType="state.phoneType" @confirmReturn="confirmReturn"></viewfinder> | |||||
</view> | |||||
</template> | |||||
<script setup lang="ts"> | |||||
import viewfinder from "../../components/viewfinder.vue" | |||||
import { | |||||
onLoad | |||||
} from "@dcloudio/uni-app"; | |||||
import { | |||||
reactive | |||||
} from "vue"; | |||||
const state = reactive({ | |||||
phoneType: 1, | |||||
allParams: {} | |||||
}) | |||||
onLoad((option : any) => { | |||||
state.phoneType = option.phoneType; | |||||
state.allParams = option.allParams; | |||||
}); | |||||
const confirmReturn = (val) => { | |||||
// uni.navigateTo({ | |||||
// url: `` | |||||
// }) | |||||
uni.navigateBack({ | |||||
delta: 1 | |||||
}) | |||||
console.log("val", val) | |||||
} | |||||
</script> | |||||
<style> | |||||
.content { | |||||
display: flex; | |||||
flex-direction: column; | |||||
align-items: center; | |||||
justify-content: center; | |||||
} | |||||
.logo { | |||||
height: 200rpx; | |||||
width: 200rpx; | |||||
margin-top: 200rpx; | |||||
margin-left: auto; | |||||
margin-right: auto; | |||||
margin-bottom: 50rpx; | |||||
} | |||||
.text-area { | |||||
display: flex; | |||||
justify-content: center; | |||||
} | |||||
.title { | |||||
font-size: 36rpx; | |||||
color: #8f8f94; | |||||
} | |||||
</style> |
<script setup lang="ts"> | <script setup lang="ts"> | ||||
import { reactive } from "vue"; | import { reactive } from "vue"; | ||||
import { checkStr, msg, navTo } from "@/utils/utils"; | |||||
import { checkStr, msg, navTo, subscribeMessages } from "@/utils/utils"; | |||||
import { onLoad, onUnload } from "@dcloudio/uni-app"; | import { onLoad, onUnload } from "@dcloudio/uni-app"; | ||||
import { checkCode } from "@/utils/network/api.js"; | |||||
import { checkCode, loginCode, loginTime } from "@/utils/network/api.js"; | |||||
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 { useUserStore } from "@/stores/user"; | import { useUserStore } from "@/stores/user"; | ||||
console.log(q); | console.log(q); | ||||
state.json = getRequest(q) | state.json = getRequest(q) | ||||
console.log("state.json", state.json, getItem("mobile"), getItem("mobile") == state.json.phone) | console.log("state.json", state.json, getItem("mobile"), getItem("mobile") == state.json.phone) | ||||
setItem('scanCode', state.json) | |||||
if (!getItem("mobile")) { | |||||
uni.showModal({ | |||||
title: '提示', | |||||
content: '您还未登录小程序,请先登录小程序', | |||||
showCancel: false, | |||||
success: function (res) { | |||||
if (res.confirm) { | |||||
navTo('/login/login') | |||||
} | |||||
} | |||||
}); | |||||
} | |||||
// setItem('scanCode', state.json) | |||||
// if (!getItem("mobile")) { | |||||
// uni.showModal({ | |||||
// title: '提示', | |||||
// content: '您还未登录小程序,请先登录小程序', | |||||
// showCancel: false, | |||||
// success: function (res) { | |||||
// if (res.confirm) { | |||||
// navTo('/login/login') | |||||
// } | |||||
// } | |||||
// }); | |||||
// } | |||||
// 直接用传过来的手机号(不让他修改) | // 直接用传过来的手机号(不让他修改) | ||||
state.mobile = state.json.phone | state.mobile = state.json.phone | ||||
} else { | } else { | ||||
msg("请输入正确的手机号!"); | msg("请输入正确的手机号!"); | ||||
return; | return; | ||||
} | } | ||||
// 直接去登录 | |||||
reqLogin(loginCode, { | |||||
mobile: state.mobile, | |||||
code: state.code, | |||||
loginTime: loginTime, | |||||
}); | |||||
}; | |||||
/* 执行登录 */ | |||||
const reqLogin = (code : string, data : object) => { | |||||
console.log(code, data); | |||||
const options = { | const options = { | ||||
type: 2, | type: 2, | ||||
data: { | |||||
mobile: state.mobile, | |||||
code: state.code | |||||
}, | |||||
data: data, | |||||
method: "POST", | method: "POST", | ||||
showLoading: true, | showLoading: true, | ||||
}; | }; | ||||
request(checkCode, options).then((res) => { | |||||
console.log("过来了", res) | |||||
// type 1扫码支付 2扫描协议确认 | |||||
if (state.json.type == 1) { | |||||
uni.navigateTo({ | |||||
url: `/subpackage/orders/order_payment?orderId=${state.json.orderId}`, | |||||
}); | |||||
} else if (state.json.type == 2) { | |||||
uni.navigateTo({ | |||||
url: `/subpackage/orders/product-detail?orderId=${state.json.orderId}&url=${state.json.url}&typeScanCode=${state.json.type}`, | |||||
}); | |||||
} | |||||
}) | |||||
.catch((err) => { | |||||
// msg("验证码错误"); | |||||
request(code, options).then((res) => { | |||||
const result = stringToJson(res.bizContent); | |||||
console.log(result); | |||||
console.log(typeof (result)); | |||||
fetchToken(result.code).then((data : any) => { | |||||
console.log("登录", data); | |||||
setItem('mobile', state.mobile) | |||||
subscribeMessages(); | |||||
if (state.json.type == 1) { | |||||
uni.navigateTo({ | |||||
url: `/subpackage/orders/order_payment?orderId=${state.json.orderId}`, | |||||
}); | |||||
} else if (state.json.type == 2) { | |||||
uni.navigateTo({ | |||||
url: `/subpackage/orders/product-detail?orderId=${state.json.orderId}&url=${state.json.url}&typeScanCode=${state.json.type}`, | |||||
}); | |||||
} | |||||
}); | }); | ||||
}); | |||||
}; | }; | ||||
//解析URL获取参数 | //解析URL获取参数 | ||||
const getRequest = (urlStr) => { | const getRequest = (urlStr) => { | ||||
if (typeof urlStr == "undefined") { | if (typeof urlStr == "undefined") { |
options.success = (res) => { | options.success = (res) => { | ||||
console.log('请求成功返回参数:', code, res) | console.log('请求成功返回参数:', code, res) | ||||
// 请求返回后,隐藏loading(如果请求返回快的话,可能会没有loading) | // 请求返回后,隐藏loading(如果请求返回快的话,可能会没有loading) | ||||
uni.hideLoading() | |||||
if (options.showLoading) { | |||||
uni.hideLoading() | |||||
} | |||||
if (res.data.statusCode !== 0) { | if (res.data.statusCode !== 0) { | ||||
if (res.data.statusCode == 600) { | if (res.data.statusCode == 600) { | ||||
resolve(res.data) | resolve(res.data) |
} | } | ||||
return diffObj | return diffObj | ||||
} | |||||
// 订阅消息 | |||||
export function subscribeMessages() { | |||||
uni.requestSubscribeMessage({ | |||||
tmplIds: ['aNr4T2JEtaLtR9dihM2w3NAznz4bFMkutVZCbaSTjxg'], | |||||
success(res) { | |||||
console.log("订阅消息", res) | |||||
} | |||||
}) | |||||
} | } |