您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

activeAgain.js 8.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. // plugin/etc/pages/activeAgain/activeAgain.js
  2. import {
  3. uploadFile
  4. } from "../../../network/upload"
  5. const network = require('../../../network/index');
  6. let timeInterVal = null
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. plateNum: "",
  13. vehicle: '',
  14. vehicleColor: '',
  15. modelInfo: {
  16. activeType: "",
  17. cardId: "",
  18. mobile: "",
  19. obuId: "",
  20. orderId: "",
  21. orderNo: "",
  22. vehiclePlate: "",
  23. vehiclePlateColor: "",
  24. vehicleType: ""
  25. },
  26. disabled: false,
  27. smsName: '获取',
  28. sendCode: '',
  29. isAgainActive: false, // 是否可二次激活
  30. vehPosImgUrl: '',
  31. vehPosImgUrlStr: '',
  32. vehNegImgUrl: '',
  33. vehNegImgUrlStr: '',
  34. vehBodyUrl: '',
  35. vehBodyUrlStr: '',
  36. installImgUrl: '',
  37. installImgUrlStr: '',
  38. chooseImageIndex: 0
  39. },
  40. /**
  41. * 生命周期函数--监听页面加载
  42. */
  43. onLoad(options) {
  44. this.configData(options)
  45. this.againAactiveGetCarDetail()
  46. },
  47. /**
  48. * 生命周期函数--监听页面卸载
  49. */
  50. onUnload() {
  51. if (timeInterVal) {
  52. clearInterval(timeInterVal)
  53. timeInterVal = null
  54. }
  55. },
  56. $openUploadPopup(e) {
  57. console.log(e)
  58. },
  59. againAactiveGetCarDetail() {
  60. wx.showLoading()
  61. network.etc.againAactiveGetCarDetail({
  62. vehicleId: this.data.plateNum,
  63. sourceType: 'CHANNEL'
  64. }).then(res => {
  65. console.log(res)
  66. if (res.code == 0) {
  67. let data = res.data
  68. if (data.modelList && data.modelList.length) {
  69. let model = data.modelList[0]
  70. this.setData({
  71. modelInfo: model
  72. })
  73. // activeType 1. 发行激活 2. 脱落激活
  74. if (model.activeType == 2) {
  75. this.activeCheckCanActive() // 判断当前设备是否可二次激活
  76. // 测试代码
  77. // let data = this.data
  78. // wx.navigateTo({
  79. // url: `plugin://issuer-plugin/activeAgainStep?plateNum=${data.plateNum}&cardId=${data.modelInfo.cardId}&obuId=${data.modelInfo.obuId}`,
  80. // })
  81. // 测试代码
  82. } else {
  83. this.unActiveTip()
  84. }
  85. } else {
  86. this.unActiveTip()
  87. }
  88. wx.hideLoading()
  89. } else {
  90. wx.hideLoading()
  91. wx.showModal({
  92. title: '提示',
  93. content: res.message,
  94. showCancel: false
  95. })
  96. }
  97. }).catch(() => {
  98. wx.hideLoading()
  99. })
  100. },
  101. onSend() {
  102. console.log("this.data", this.data)
  103. if (!this.data.disabled) this.getSsoSendlossmsgReq()
  104. },
  105. getSsoSendlossmsgReq() {
  106. let mobile = this.data.modelInfo.mobile
  107. if (!mobile) {
  108. return
  109. }
  110. let params = {
  111. mobile: this.data.modelInfo.mobile,
  112. businessType: 4,
  113. loginSource: 'CHANNEL'
  114. }
  115. network.etc.getPortalSendCode(params).then(res => {
  116. if (res.code !== 0) {
  117. wx.showModal({
  118. title: '提示',
  119. content: res.message,
  120. showCancel: false
  121. })
  122. return false
  123. }
  124. wx.showToast({
  125. title: '发送成功,请注意查收',
  126. icon: 'none'
  127. })
  128. let countdown = 60
  129. timeInterVal = setInterval(() => {
  130. countdown = countdown - 1
  131. console.log("countdown", countdown, countdown === 0)
  132. this.setData({
  133. smsName: `(${countdown}s)`,
  134. })
  135. if (countdown === 0) {
  136. clearInterval(timeInterVal)
  137. timeInterVal = null
  138. this.setData({
  139. disabled: false,
  140. smsName: "获取",
  141. })
  142. }
  143. }, 1000)
  144. this.setData({
  145. disabled: true,
  146. })
  147. })
  148. },
  149. // 下一步
  150. onTapSign() {
  151. // 测试阶段,正式要删除
  152. let data = this.data
  153. // 是否可二次激活
  154. if (!this.data.isAgainActive) {
  155. wx.showToast({
  156. title: '当前设备不可二次激活',
  157. icon: 'none'
  158. })
  159. return
  160. }
  161. let sendCode = this.data.sendCode
  162. if (!sendCode) {
  163. wx.showToast({
  164. title: '请添加手机验证码',
  165. icon: 'none'
  166. })
  167. return false
  168. } else if (!data.vehPosImgUrl) {
  169. wx.showToast({
  170. title: '请上传车辆行驶证主页',
  171. icon: 'none'
  172. })
  173. return
  174. } else if (!data.vehNegImgUrl) {
  175. wx.showToast({
  176. title: '请上传车辆行驶证副页',
  177. icon: 'none'
  178. })
  179. return
  180. } else if (!data.vehBodyUrl) {
  181. wx.showToast({
  182. title: '请上传车辆45度角照片',
  183. icon: 'none'
  184. })
  185. return
  186. } else if (!data.installImgUrl) {
  187. wx.showToast({
  188. title: '请上传车辆安装照片',
  189. icon: 'none'
  190. })
  191. return
  192. }
  193. let params = {
  194. mobile: this.data.modelInfo.mobile,
  195. code: sendCode,
  196. loginSource: "431bfdc8b9c645e0b293b85d6ce1925b"
  197. }
  198. wx.showLoading()
  199. // 校验验证码是否正确
  200. network.etc.checkSendCode(params).then(res => {
  201. if (res.code !== 0) {
  202. wx.hideLoading()
  203. wx.showModal({
  204. title: '提示',
  205. content: res.message,
  206. showCancel: false
  207. })
  208. return false
  209. }
  210. let resData = res.data
  211. wx.hideLoading()
  212. if (resData.errorMsg) {
  213. wx.showModal({
  214. title: '提示',
  215. content: resData.errorMsg,
  216. showCancel: false
  217. })
  218. } else {
  219. let data = this.data
  220. wx.redirectTo({
  221. 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}&vehicleType=${data.vehicleType}`,
  222. })
  223. }
  224. }).catch(() => {
  225. wx.hideLoading()
  226. })
  227. // let data = this.data
  228. // wx.redirectTo({
  229. // url: `plugin://issuer-plugin/activeAgainStep?plateNum=${data.plateNum}&cardId=${data.modelInfo.cardId}&obuId=${data.modelInfo.obuId}`,
  230. // })
  231. },
  232. // 配置默认参数
  233. configData(options) {
  234. const plateNum = options?.plateNum
  235. // const plateNum = '贵ZYTH66_0'
  236. // const plateNum = '贵Z81001_0'
  237. // const plateNum = '贵Z99882_0'
  238. let vehicleArr = plateNum.split('_')
  239. if (plateNum) {
  240. this.setData({
  241. plateNum,
  242. vehicle: vehicleArr[0],
  243. vehicleColor: vehicleArr[1]
  244. })
  245. }
  246. },
  247. // 判断设备是否可以二次激活
  248. activeCheckCanActive() {
  249. let modelInfo = this.data.modelInfo
  250. let params = {
  251. vehiclePlate: modelInfo.vehiclePlate,
  252. vehiclePlateColor: modelInfo.vehiclePlateColor,
  253. cardId: modelInfo.cardId,
  254. obuId: modelInfo.obuId
  255. }
  256. network.etc.activeCheckCanActive(params).then(res => {
  257. console.log(res)
  258. let data = res.data
  259. if (data.code !== 0) {
  260. this.setData({
  261. isAgainActive: true
  262. })
  263. } else {
  264. this.unActiveTip()
  265. }
  266. })
  267. },
  268. // 设备不可二次激活提示
  269. unActiveTip() {
  270. wx.showModal({
  271. title: '提示',
  272. content: '当前设备不可再次激活',
  273. showCancel: false,
  274. complete: () => {
  275. wx.navigateBack()
  276. }
  277. })
  278. },
  279. // 上传照片
  280. chooseImage(e) {
  281. const that = this;
  282. console.log(e)
  283. let index = e.detail.currentTarget.dataset.type
  284. console.log(index)
  285. wx.chooseMedia({
  286. count: 1, //默认9
  287. mediaType: ['image'],
  288. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  289. success: (res) => {
  290. let path = res.tempFiles[0].tempFilePath
  291. wx.showLoading({
  292. title: '上传中...',
  293. })
  294. uploadFile(path).then(res => {
  295. console.log(res)
  296. let fileUrl = res.ossFilePath
  297. console.log(fileUrl)
  298. if (index === '1') {
  299. this.setData({
  300. vehPosImgUrl: fileUrl,
  301. vehPosImgUrlStr: `https://qtzl.etcjz.cn/${fileUrl}`
  302. })
  303. } else if (index === '2') {
  304. this.setData({
  305. vehNegImgUrl: fileUrl,
  306. vehNegImgUrlStr: `https://qtzl.etcjz.cn/${fileUrl}`
  307. })
  308. } else if (index === '3') {
  309. this.setData({
  310. vehBodyUrl: fileUrl,
  311. vehBodyUrlStr: `https://qtzl.etcjz.cn/${fileUrl}`
  312. })
  313. } else if (index === '4') {
  314. this.setData({
  315. installImgUrl: fileUrl,
  316. installImgUrlStr: `https://qtzl.etcjz.cn/${fileUrl}`
  317. })
  318. }
  319. that.setData({
  320. imagePath: fileUrl,
  321. imagePathUrl: `https://qtzl.etcjz.cn/${fileUrl}`
  322. })
  323. console.log(`https://qtzl.etcjz.cn/${fileUrl}`)
  324. wx.hideLoading();
  325. })
  326. },
  327. fail: function (e) {
  328. wx.hideLoading();
  329. console.log(e)
  330. },
  331. })
  332. },
  333. })