123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- // plugin/etc/pages/activeAgain/activeAgain.js
- import {
- uploadFile
- } from "../../../network/upload"
-
- const network = require('../../../network/index');
-
- let timeInterVal = null
-
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- plateNum: "",
- vehicle: '',
- vehicleColor: '',
- modelInfo: {
- activeType: "",
- cardId: "",
- mobile: "",
- obuId: "",
- orderId: "",
- orderNo: "",
- vehiclePlate: "",
- vehiclePlateColor: "",
- vehicleType: ""
- },
- disabled: false,
- smsName: '获取',
- sendCode: '',
- isAgainActive: false, // 是否可二次激活
- vehPosImgUrl: '',
- vehPosImgUrlStr: '',
- vehNegImgUrl: '',
- vehNegImgUrlStr: '',
- vehBodyUrl: '',
- vehBodyUrlStr: '',
- installImgUrl: '',
- installImgUrlStr: '',
- chooseImageIndex: 0
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- this.configData(options)
- this.againAactiveGetCarDetail()
- },
-
-
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- if (timeInterVal) {
- clearInterval(timeInterVal)
- timeInterVal = null
- }
- },
-
- $openUploadPopup(e) {
- console.log(e)
- },
-
- againAactiveGetCarDetail() {
- wx.showLoading()
- network.etc.againAactiveGetCarDetail({
- vehicleId: this.data.plateNum,
- sourceType: 'CHANNEL'
- }).then(res => {
- console.log(res)
- if (res.code == 0) {
- let data = res.data
- if (data.modelList && data.modelList.length) {
- let model = data.modelList[0]
- this.setData({
- modelInfo: model
- })
- // activeType 1. 发行激活 2. 脱落激活
- if (model.activeType == 2) {
- this.activeCheckCanActive() // 判断当前设备是否可二次激活
-
- // 测试代码
- // let data = this.data
- // wx.navigateTo({
- // url: `plugin://issuer-plugin/activeAgainStep?plateNum=${data.plateNum}&cardId=${data.modelInfo.cardId}&obuId=${data.modelInfo.obuId}`,
- // })
- // 测试代码
-
- } else {
- this.unActiveTip()
- }
- } else {
- this.unActiveTip()
- }
- wx.hideLoading()
- } else {
- wx.hideLoading()
- wx.showModal({
- title: '提示',
- content: res.message,
- showCancel: false
- })
- }
-
- }).catch(() => {
- wx.hideLoading()
- })
- },
-
- onSend() {
- console.log("this.data", this.data)
- if (!this.data.disabled) this.getSsoSendlossmsgReq()
- },
-
- getSsoSendlossmsgReq() {
-
- let mobile = this.data.modelInfo.mobile
- if (!mobile) {
- return
- }
-
- let params = {
- mobile: this.data.modelInfo.mobile,
- businessType: 4,
- loginSource: 'CHANNEL'
- }
- network.etc.getPortalSendCode(params).then(res => {
- if (res.code !== 0) {
- wx.showModal({
- title: '提示',
- content: res.message,
- showCancel: false
- })
- return false
- }
- wx.showToast({
- title: '发送成功,请注意查收',
- icon: 'none'
- })
- let countdown = 60
- timeInterVal = setInterval(() => {
- countdown = countdown - 1
- console.log("countdown", countdown, countdown === 0)
- this.setData({
- smsName: `(${countdown}s)`,
- })
- if (countdown === 0) {
- clearInterval(timeInterVal)
- timeInterVal = null
- this.setData({
- disabled: false,
- smsName: "获取",
- })
- }
- }, 1000)
- this.setData({
- disabled: true,
- })
- })
- },
-
- // 下一步
- onTapSign() {
- // 测试阶段,正式要删除
- let data = this.data
-
- // 是否可二次激活
- if (!this.data.isAgainActive) {
- wx.showToast({
- title: '当前设备不可二次激活',
- icon: 'none'
- })
- return
- }
-
- let sendCode = this.data.sendCode
- if (!sendCode) {
- wx.showToast({
- title: '请添加手机验证码',
- icon: 'none'
- })
- return false
- } else if (!data.vehPosImgUrl) {
- wx.showToast({
- title: '请上传车辆行驶证主页',
- icon: 'none'
- })
- return
- } else if (!data.vehNegImgUrl) {
- wx.showToast({
- title: '请上传车辆行驶证副页',
- icon: 'none'
- })
- return
- } else if (!data.vehBodyUrl) {
- wx.showToast({
- title: '请上传车辆45度角照片',
- icon: 'none'
- })
- return
- } else if (!data.installImgUrl) {
- wx.showToast({
- title: '请上传车辆安装照片',
- icon: 'none'
- })
- return
- }
- let params = {
- mobile: this.data.modelInfo.mobile,
- code: sendCode,
- loginSource: "431bfdc8b9c645e0b293b85d6ce1925b"
- }
- wx.showLoading()
- // 校验验证码是否正确
- network.etc.activeCheckSendCode(params).then(res => {
- if (res.code !== 0) {
- wx.hideLoading()
- wx.showModal({
- title: '提示',
- content: res.message,
- showCancel: false
- })
- return false
- }
- let resData = res.data
- wx.hideLoading()
- if (resData.errorMsg) {
- wx.showModal({
- title: '提示',
- content: resData.errorMsg,
- showCancel: false
- })
- } else {
- let data = this.data
- wx.redirectTo({
- url: `plugin://issuer-plugin/activeAgainStep?plateNum=${data.plateNum}&cardId=${data.modelInfo.cardId}&obuId=${data.modelInfo.obuId}&vehPosImgUrl=${data.vehPosImgUrl}&vehNegImgUrl=${data.vehNegImgUrl}&vehBodyUrl=${data.vehBodyUrl}&installImgUrl=${data.installImgUrl}`,
- })
- }
- }).catch(() => {
- wx.hideLoading()
- })
-
- // let data = this.data
- // wx.redirectTo({
- // url: `plugin://issuer-plugin/activeAgainStep?plateNum=${data.plateNum}&cardId=${data.modelInfo.cardId}&obuId=${data.modelInfo.obuId}`,
- // })
- },
-
- // 配置默认参数
- configData(options) {
- const plateNum = options?.plateNum
- // const plateNum = '贵ZYTH66_0'
- // const plateNum = '贵Z81001_0'
- // const plateNum = '贵Z99882_0'
-
- let vehicleArr = plateNum.split('_')
- if (plateNum) {
- this.setData({
- plateNum,
- vehicle: vehicleArr[0],
- vehicleColor: vehicleArr[1]
- })
- }
- },
-
- // 判断设备是否可以二次激活
- activeCheckCanActive() {
- let modelInfo = this.data.modelInfo
- let params = {
- vehiclePlate: modelInfo.vehiclePlate,
- vehiclePlateColor: modelInfo.vehiclePlateColor,
- cardId: modelInfo.cardId,
- obuId: modelInfo.obuId
- }
- network.etc.activeCheckCanActive(params).then(res => {
- console.log(res)
- let data = res.data
- if (data.code !== 0) {
- this.setData({
- isAgainActive: true
- })
- } else {
- this.unActiveTip()
- }
- })
- },
-
- // 设备不可二次激活提示
- unActiveTip() {
- wx.showModal({
- title: '提示',
- content: '当前设备不可再次激活',
- showCancel: false,
- complete: () => {
- wx.navigateBack()
- }
- })
- },
-
- // 上传照片
- chooseImage(e) {
- const that = this;
- console.log(e)
- let index = e.detail.currentTarget.dataset.type
- console.log(index)
- wx.chooseMedia({
- count: 1, //默认9
- mediaType: ['image'],
- sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
- success: (res) => {
- let path = res.tempFiles[0].tempFilePath
- wx.showLoading({
- title: '上传中...',
- })
- uploadFile(path).then(res => {
- console.log(res)
- let fileUrl = res.ossFilePath
- console.log(fileUrl)
- if (index === '1') {
- this.setData({
- vehPosImgUrl: fileUrl,
- vehPosImgUrlStr: `https://qtzl.etcjz.cn/${fileUrl}`
- })
- } else if (index === '2') {
- this.setData({
- vehNegImgUrl: fileUrl,
- vehNegImgUrlStr: `https://qtzl.etcjz.cn/${fileUrl}`
- })
- } else if (index === '3') {
- this.setData({
- vehBodyUrl: fileUrl,
- vehBodyUrlStr: `https://qtzl.etcjz.cn/${fileUrl}`
- })
- } else if (index === '4') {
- this.setData({
- installImgUrl: fileUrl,
- installImgUrlStr: `https://qtzl.etcjz.cn/${fileUrl}`
- })
- }
- that.setData({
- imagePath: fileUrl,
- imagePathUrl: `https://qtzl.etcjz.cn/${fileUrl}`
- })
- console.log(`https://qtzl.etcjz.cn/${fileUrl}`)
- wx.hideLoading();
- })
- },
- fail: function (e) {
- wx.hideLoading();
- console.log(e)
- },
- })
- },
- })
|