123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- // plugin/pages/reportingloss/report-loss/report-loss.js
- import Api from "../../../api/index"
- import { requestFnc } from "../../../utils/request"
- import { getStore } from "../../../utils/index"
- import {
- getApplyReqSender,
- getVehicleInformation,
- getCpuInfo,
- getObuInfo,
- } from "../../../utils/commonReq"
- import {
- plateColorToColorMap,
- aftersalesBusinessTypeMap,
- obuStatusMap,
- cpuStatusMap,
- } from "../../../utils/systemConstant"
- let timeInterVal = null
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- info: {
- ownerName: "",
- licensePlate: "",
- },
- obus: {
- obuId: "",
- status: "",
- },
- cards: {
- cardId: "",
- status: "",
- },
- identitys: {
- number: getStore("mobile"),
- imgCode: "",
- code: "",
- reason: "",
- },
- identitysImgCode: "",
- value: "1111",
- smsName: "获取验证码",
- disabled: false,
- isLoading: false,
- imgCode: "",
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- let { type = "" } = options
- let name = ""
- if (type === "1") name = "ETC卡挂失"
- if (type === "2") name = "标签挂失"
- if (type === "3") name = "设备挂失"
-
- wx.setNavigationBarTitle({
- title: name,
- })
- this.data.identitys.number = getStore("mobile")
- this.setData({
- identitys: this.data.identitys,
- })
- getVehicleInformation((data) => {
- let { ownerName = "", plateColor, plateNum, vehicleType } = data
- this.setData({
- info: {
- ownerName,
- licensePlate: `[${plateColorToColorMap.get(
- `${plateColor}`
- )}]${plateNum}[${vehicleType}]`,
- },
- })
- })
- getCpuInfo((data) => {
- let { cardId = "", status } = data[0]
- this.setData({
- cards: {
- cardId,
- status: cpuStatusMap.get(`${status}`),
- },
- })
- })
- getObuInfo((data) => {
- let { obuId = "", status } = data[0]
- this.setData({
- obus: {
- obuId,
- status: obuStatusMap.get(`${status}`),
- },
- })
- })
-
- this.getCode()
- },
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {},
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {},
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {},
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {},
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {},
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {},
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {},
- getSsoSendlossmsgReq() {
- let params = {
- filename: Api.getSsoSendlossmsgReq.filename,
- data: {
- accountId: getStore("accountId"),
- authCode: this.data.identitys.imgCode,
- },
- }
-
- requestFnc(Api.getSsoSendlossmsgReq.url, params, (res) => {
- let countdown = 60
- timeInterVal = setInterval(() => {
- countdown = countdown - 1
- this.setData({
- smsName: `重新获取(${countdown}s)`,
- })
- if (countdown === 0) {
- clearInterval(timeInterVal)
- timeInterVal = null
- this.setData({
- disabled: false,
- smsName: "获取验证码",
- })
- }
- }, 1000)
- this.setData({
- disabled: true,
- })
- })
- },
- getAftersaleVehiclelostReq(authCode) {
- let params = {
- filename: Api.getAftersaleVehiclelostReq.filename,
- data: {
- accountId: getStore("accountId"),
- vehicleId: getStore("vehicleId"),
- plateNum: getStore("plateNum"),
- plateColor: getStore("plateColor"),
- code: this.data.identitys.code,
- reason: this.data.identitys.reason,
- authCode,
- },
- }
-
- requestFnc(
- Api.getAftersaleVehiclelostReq.url,
- params,
- (res) => {
- this.setData({
- isLoading: false,
- })
- wx.navigateTo({
- url: "plugin://issuer-plugin/loss-success?type=loss",
- })
- },
- () => {
- this.setData({
- isLoading: true,
- })
- }
- )
- },
- // 获取图形验证码
- getCode() {
- let params = {
- filename: Api.getImgCode.filename,
- data: {
- mobile: getStore("mobile"),
- },
- }
- requestFnc(Api.getImgCode.url, params, (res) => {
- this.setData({
- imgCode: res.authCode,
- })
- })
- },
- changeInput(e) {
- let key = e.currentTarget.dataset.type
- this.data.identitys[key] = e.detail
- this.setData({
- identitys: {
- ...this.data.identitys,
- },
- })
- },
- onNext() {
- let title = ""
-
- if (!this.data.identitys.reason) {
- title = "请输入挂失原因"
- }
- if (!this.data.identitys.code) {
- title = "请输入短信验证码"
- }
- if (title) {
- wx.showToast({
- title,
- icon: "none",
- })
- return
- }
-
- this.setData({
- isLoading: true,
- })
- let { type = "" } = this.options
- //1 卡 2 Obu 3 卡和obu
- let obj = {
- 1: "卡挂失",
- 2: "OBU挂失",
- 3: "卡和OBU挂失",
- }
- let code = aftersalesBusinessTypeMap.get(obj[type])
- getApplyReqSender(code, (authCode) => {
- console.log(authCode, "----getApplyReqSender---")
- this.getAftersaleVehiclelostReq(authCode)
- })
- },
- onSend() {
- if (!this.data.disabled) this.getSsoSendlossmsgReq()
- },
- })
|