device-param-110602.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. function GateParam(option) {
  2. var _el = option.el
  3. var _priceParam = option.priceParam
  4. var _controlParam = option.controlParam
  5. var _gateDoorArray = option.gateDoorArray
  6. var app = (this.app = new Vue({
  7. el: _el,
  8. template: `
  9. <div>
  10. <h5 class="mui-content-padded tips-event">
  11. 计费配置
  12. <i class="tips" title="
  13. 计费方式为周期性计费,每个周期的单价累加即为用户最终需要支付价格;
  14. 例如 设置单价为 1 元,计费周期为2小时,用户临时停车7小时;
  15. 则最终支付价格 为 4个周期 ✖ 周期价格 1元 = 4元
  16. ">?</i>
  17. </h5>
  18. <div class="mui-input-group" >
  19. <div class="mui-input-row ">
  20. <label class="">单价: </label>
  21. <input type="number" min=0 max=999 step="0.01" v-model="info.price" />
  22. <span class="mini-unit">元</span>
  23. </div>
  24. <div class="mui-input-row">
  25. <label class="">计费周期:</label>
  26. <input type="number" min=0 max=999 step="0.01" v-model="info.cycle" />
  27. <span class="mini-unit">小时</span>
  28. </div>
  29. <div class="mui-input-row">
  30. <label class="">费用上限:</label>
  31. <input type="number" min=0 max=999 step="0.01" v-model="info.maxFee" />
  32. <span class="mini-unit">元</span>
  33. </div>
  34. <div class="mui-input-row">
  35. <label class="">免费时间:</label>
  36. <input type="number" min=0 max=999 step="0.01" v-model="info.freeHour" />
  37. <span class="mini-unit">小时</span>
  38. </div>
  39. </div>
  40. <h5 class="mui-content-padded tips-event">
  41. 控制配置
  42. <i class="tips" title="
  43. 从主板中选择可用的门ID作为进门或出门控制;
  44. ">?</i>
  45. </h5>
  46. <div class="mui-input-group">
  47. <div class="mui-input-row" @click="choiceDoor('in')">
  48. <label class="">进</label>
  49. <input type="text" v-model="info.in" disabled/>
  50. </div>
  51. <div class="mui-input-row" @click="choiceDoor('out')">
  52. <label class="">出</label>
  53. <input type="text" v-model="info.out" disabled/>
  54. </div>
  55. </div>
  56. <template v-if='info.showDoors'>
  57. <hr>
  58. <div class="mui-table-view-cell" v-for="(obj,index) in info.gateDoorArray" @click="closeChoice(obj)">
  59. <span class="left">名称 </span>
  60. <span class="right">{{obj.doorName}}</span>
  61. </div>
  62. </template>
  63. </div>
  64. `,
  65. data: {
  66. info: {
  67. price: 0,
  68. cycle: 0,
  69. in: 0,
  70. out: 0,
  71. freeHour: 0,
  72. maxFee: 0,
  73. inDoor: {},
  74. outDoor: {},
  75. showDoors: false,
  76. gateDoorArray: [],
  77. curChoiceId: '',
  78. },
  79. },
  80. mounted: function () {
  81. var that = this
  82. that.initPackages()
  83. },
  84. methods: {
  85. initPackages: function () {
  86. var that = this
  87. console.log(_gateDoorArray)
  88. if (!_gateDoorArray || _gateDoorArray.length === 0) {
  89. mui.confirm('尚未配置账号,是否需要跳转配置账号?', '温馨提示', ['取消', '确定'], function (e) {
  90. if (e.index === 1) {
  91. that.toSetAccount()
  92. }
  93. })
  94. }
  95. // 初始化参数
  96. this.info.price = _priceParam.price || this.info.price
  97. this.info.cycle = _priceParam.cycle || this.info.cycle
  98. this.info.maxFee = _priceParam.maxFee || this.info.maxFee
  99. this.info.freeHour = _priceParam.freeHour || this.info.freeHour
  100. this.info.inDoor = _controlParam.in || this.info.inDoor
  101. this.info.outDoor = _controlParam.out || this.info.outDoor
  102. this.info.in = this.info.inDoor.doorName || this.info.in
  103. this.info.out = this.info.outDoor.doorName || this.info.out
  104. this.info.gateDoorArray = _gateDoorArray
  105. },
  106. toSetAccount: function () {
  107. var logicalCode = getQueryString('logicalCode') || ''
  108. var code = getQueryString('code') || ''
  109. var typeName = getQueryString('type') || ''
  110. console.log(logicalCode)
  111. console.log(code)
  112. console.log(typeName)
  113. var url = '/app/device-param/accountParam-110602.html'
  114. var option = {
  115. logicalCode: logicalCode,
  116. type: typeName,
  117. code: code,
  118. }
  119. if (url) {
  120. goPage(url, option)
  121. }
  122. },
  123. choiceDoor: function (currentTarget) {
  124. this.info.showDoors = true
  125. this.curChoiceId = currentTarget
  126. },
  127. closeChoice: function (item) {
  128. this.info[this.curChoiceId] = item.doorName
  129. this.info.showDoors = false
  130. this.info[this.curChoiceId + 'Door'] = { doorID: item.doorID, doorName: item.doorName }
  131. }
  132. },
  133. }))
  134. }
  135. // 获取设置的计费参数
  136. GateParam.prototype.getPriceParam = function () {
  137. return {
  138. price: this.app.info.price,
  139. cycle: this.app.info.cycle,
  140. maxFee: this.app.info.maxFee,
  141. freeHour: this.app.info.freeHour,
  142. }
  143. }
  144. GateParam.prototype.getControlParam = function () {
  145. return { in: this.app.info.inDoor, out: this.app.info.outDoor }
  146. }