選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

report-loss.js 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. // plugin/pages/reportingloss/report-loss/report-loss.js
  2. import Api from "../../../api/index"
  3. import { requestFnc } from "../../../utils/request"
  4. import { getStore } from "../../../utils/index"
  5. import {
  6. getApplyReqSender,
  7. getVehicleInformation,
  8. getCpuInfo,
  9. getObuInfo,
  10. } from "../../../utils/commonReq"
  11. import {
  12. plateColorToColorMap,
  13. aftersalesBusinessTypeMap,
  14. obuStatusMap,
  15. cpuStatusMap,
  16. } from "../../../utils/systemConstant"
  17. let timeInterVal = null
  18. Page({
  19. /**
  20. * 页面的初始数据
  21. */
  22. data: {
  23. info: {
  24. ownerName: "",
  25. licensePlate: "",
  26. },
  27. obus: {
  28. obuId: "",
  29. status: "",
  30. },
  31. cards: {
  32. cardId: "",
  33. status: "",
  34. },
  35. identitys: {
  36. number: getStore("mobile"),
  37. imgCode: "",
  38. code: "",
  39. reason: "",
  40. },
  41. identitysImgCode: "",
  42. value: "1111",
  43. smsName: "获取验证码",
  44. disabled: false,
  45. isLoading: false,
  46. imgCode: "",
  47. },
  48. /**
  49. * 生命周期函数--监听页面加载
  50. */
  51. onLoad(options) {
  52. let { type = "" } = options
  53. let name = ""
  54. if (type === "1") name = "ETC卡挂失"
  55. if (type === "2") name = "标签挂失"
  56. if (type === "3") name = "设备挂失"
  57. wx.setNavigationBarTitle({
  58. title: name,
  59. })
  60. this.data.identitys.number = getStore("mobile")
  61. this.setData({
  62. identitys: this.data.identitys,
  63. })
  64. getVehicleInformation((data) => {
  65. let { ownerName = "", plateColor, plateNum, vehicleType } = data
  66. this.setData({
  67. info: {
  68. ownerName,
  69. licensePlate: `[${plateColorToColorMap.get(
  70. `${plateColor}`
  71. )}]${plateNum}[${vehicleType}]`,
  72. },
  73. })
  74. })
  75. getCpuInfo((data) => {
  76. let { cardId = "", status } = data[0]
  77. this.setData({
  78. cards: {
  79. cardId,
  80. status: cpuStatusMap.get(`${status}`),
  81. },
  82. })
  83. })
  84. getObuInfo((data) => {
  85. let { obuId = "", status } = data[0]
  86. this.setData({
  87. obus: {
  88. obuId,
  89. status: obuStatusMap.get(`${status}`),
  90. },
  91. })
  92. })
  93. this.getCode()
  94. },
  95. /**
  96. * 生命周期函数--监听页面初次渲染完成
  97. */
  98. onReady() {},
  99. /**
  100. * 生命周期函数--监听页面显示
  101. */
  102. onShow() {},
  103. /**
  104. * 生命周期函数--监听页面隐藏
  105. */
  106. onHide() {},
  107. /**
  108. * 生命周期函数--监听页面卸载
  109. */
  110. onUnload() {},
  111. /**
  112. * 页面相关事件处理函数--监听用户下拉动作
  113. */
  114. onPullDownRefresh() {},
  115. /**
  116. * 页面上拉触底事件的处理函数
  117. */
  118. onReachBottom() {},
  119. /**
  120. * 用户点击右上角分享
  121. */
  122. onShareAppMessage() {},
  123. getSsoSendlossmsgReq() {
  124. let params = {
  125. filename: Api.getSsoSendlossmsgReq.filename,
  126. data: {
  127. accountId: getStore("accountId"),
  128. authCode: this.data.identitys.imgCode,
  129. },
  130. }
  131. requestFnc(Api.getSsoSendlossmsgReq.url, params, (res) => {
  132. let countdown = 60
  133. timeInterVal = setInterval(() => {
  134. countdown = countdown - 1
  135. this.setData({
  136. smsName: `重新获取(${countdown}s)`,
  137. })
  138. if (countdown === 0) {
  139. clearInterval(timeInterVal)
  140. timeInterVal = null
  141. this.setData({
  142. disabled: false,
  143. smsName: "获取验证码",
  144. })
  145. }
  146. }, 1000)
  147. this.setData({
  148. disabled: true,
  149. })
  150. })
  151. },
  152. getAftersaleVehiclelostReq(authCode) {
  153. let params = {
  154. filename: Api.getAftersaleVehiclelostReq.filename,
  155. data: {
  156. accountId: getStore("accountId"),
  157. vehicleId: getStore("vehicleId"),
  158. plateNum: getStore("plateNum"),
  159. plateColor: getStore("plateColor"),
  160. code: this.data.identitys.code,
  161. reason: this.data.identitys.reason,
  162. authCode,
  163. },
  164. }
  165. requestFnc(
  166. Api.getAftersaleVehiclelostReq.url,
  167. params,
  168. (res) => {
  169. this.setData({
  170. isLoading: false,
  171. })
  172. wx.navigateTo({
  173. url: "plugin://issuer-plugin/loss-success?type=loss",
  174. })
  175. },
  176. () => {
  177. this.setData({
  178. isLoading: true,
  179. })
  180. }
  181. )
  182. },
  183. // 获取图形验证码
  184. getCode() {
  185. let params = {
  186. filename: Api.getImgCode.filename,
  187. data: {
  188. mobile: getStore("mobile"),
  189. },
  190. }
  191. requestFnc(Api.getImgCode.url, params, (res) => {
  192. this.setData({
  193. imgCode: res.authCode,
  194. })
  195. })
  196. },
  197. changeInput(e) {
  198. let key = e.currentTarget.dataset.type
  199. this.data.identitys[key] = e.detail
  200. this.setData({
  201. identitys: {
  202. ...this.data.identitys,
  203. },
  204. })
  205. },
  206. onNext() {
  207. let title = ""
  208. if (!this.data.identitys.reason) {
  209. title = "请输入挂失原因"
  210. }
  211. if (!this.data.identitys.code) {
  212. title = "请输入短信验证码"
  213. }
  214. if (title) {
  215. wx.showToast({
  216. title,
  217. icon: "none",
  218. })
  219. return
  220. }
  221. this.setData({
  222. isLoading: true,
  223. })
  224. let { type = "" } = this.options
  225. //1 卡 2 Obu 3 卡和obu
  226. let obj = {
  227. 1: "卡挂失",
  228. 2: "OBU挂失",
  229. 3: "卡和OBU挂失",
  230. }
  231. let code = aftersalesBusinessTypeMap.get(obj[type])
  232. getApplyReqSender(code, (authCode) => {
  233. console.log(authCode, "----getApplyReqSender---")
  234. this.getAftersaleVehiclelostReq(authCode)
  235. })
  236. },
  237. onSend() {
  238. if (!this.data.disabled) this.getSsoSendlossmsgReq()
  239. },
  240. })