bindLock.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <template>
  2. <view class="jpmain ">
  3. <u-picker mode="selector"
  4. v-model="isswitchshow"
  5. :range="columns" range-key="label"
  6. :default-selector="columnsindex"
  7. @confirm="switchBtn" ></u-picker>
  8. <view class="body">
  9. <u-steps :list="numList" mode="number" :current="current" un-active-color="#999999"></u-steps>
  10. </view>
  11. <view class="list" @click="gotoscan">
  12. <view class="item">
  13. <view class="name">
  14. <span>*</span>地锁编号
  15. </view>
  16. <view class="value">
  17. <view>{{bindInfo.lockNo?bindInfo.lockNo:'请扫码识别地锁'}}</view>
  18. <view><img class="img" src="@/assets/img/deviceTab/index2-3.svg" alt=""></view>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="list">
  23. <view class="item">
  24. <view class="name">
  25. <span>*</span>用户名
  26. </view>
  27. <view class="value">
  28. <input v-model="bindInfo.name" placeholder="请填写用户真实姓名" />
  29. </view>
  30. </view>
  31. <view class="item">
  32. <view class="name">
  33. <span>*</span>联系电话
  34. </view>
  35. <view class="value">
  36. <input v-model="bindInfo.phone" placeholder="请填写用户联系电话" />
  37. </view>
  38. </view>
  39. </view>
  40. <view class="list">
  41. <view class="item" >
  42. <view class="name">
  43. 所属停车场
  44. </view>
  45. <view class="value" @click="isswitchshowBtn">
  46. <view>{{bindInfo.parkingIdN?bindInfo.parkingIdN:'请选择所属停车场'}}</view>
  47. <u-icon name="arrow-right" size="24" color="#BBBBBB"></u-icon>
  48. </view>
  49. </view>
  50. <view class="item" v-if="bindInfo.lockNo">
  51. <view class="name">
  52. 车位类型
  53. </view>
  54. <view class="value">
  55. <view>{{bindInfo.typeN}}</view>
  56. <!-- <u-icon name="arrow-right" size="24" color="#BBBBBB"></u-icon> -->
  57. </view>
  58. </view>
  59. <view class="item">
  60. <view class="name">
  61. <span>*</span>车位编号
  62. </view>
  63. <view class="value">
  64. <input placeholder="如1号车位" v-model="bindInfo.parkingNumber" />
  65. </view>
  66. </view>
  67. <view class="item">
  68. <view class="name">
  69. 位置描述
  70. </view>
  71. <view class="value">
  72. <input placeholder="请描述车位位置信息" />
  73. </view>
  74. </view>
  75. <view class="floating-button">
  76. <view class="button" @click="submit" >
  77. 提交申请
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. </template>
  83. <script>
  84. import * as API from '@/apis/pagejs/index.js'
  85. export default {
  86. data() {
  87. return {
  88. current: 0,
  89. columnsindex:[0],
  90. bindInfo:{
  91. name:"",
  92. phone:"",
  93. lockNo:"",
  94. type:"",
  95. remark:""
  96. },
  97. isswitchshow:false,
  98. allList:[],
  99. numList: [{
  100. name: '绑定地锁'
  101. }, {
  102. name: '等待审核'
  103. }, {
  104. name: '完成绑定'
  105. }],
  106. };
  107. },
  108. onLoad() {
  109. this.userInfo = this.jphelp.getPersonInfo()
  110. this.bindInfo.phone=this.userInfo.phone
  111. },
  112. computed:{
  113. columns(){
  114. var sz=[]
  115. for(var i in this.allList){
  116. var obj=this.allList[i]
  117. sz.push({
  118. value:obj.id,
  119. label:obj.name
  120. })
  121. }
  122. return sz
  123. }
  124. },
  125. methods:{
  126. switchBtn(e){
  127. this.columnsindex=[e[0]]
  128. var obj=this.columns[e[0]]
  129. this.bindInfo.parkingId=obj.value
  130. this.bindInfo.parkingIdN=obj.label
  131. },
  132. isswitchshowBtn(){
  133. if(this.allList.length){
  134. this.isswitchshow=true
  135. }else{
  136. this.getParkingList()
  137. }
  138. },
  139. getParkingList() {
  140. uni.showLoading({
  141. title: "加载中",
  142. mask: true,
  143. })
  144. var obj = {
  145. pageIndex: 1,
  146. pageSize: 900,
  147. type:"bindLock"
  148. }
  149. API.parkingList(obj).then((res) => {
  150. this.allList = res.data.data
  151. this.isswitchshow=true
  152. uni.hideLoading();
  153. }).catch(error => {
  154. uni.hideLoading();
  155. uni.showToast({
  156. title: error,
  157. icon: "none"
  158. })
  159. })
  160. },
  161. submit(){
  162. if(!this.bindInfo.name){
  163. uni.showToast({
  164. title: "请填写用户真实姓名",
  165. icon: "none"
  166. })
  167. return
  168. }
  169. if(!this.bindInfo.phone){
  170. uni.showToast({
  171. title: "请填写用户联系电话",
  172. icon: "none"
  173. })
  174. return
  175. }
  176. if(!this.bindInfo.parkingNumber){
  177. uni.showToast({
  178. title: "请填写车位编号",
  179. icon: "none"
  180. })
  181. return
  182. }
  183. uni.showLoading({
  184. title: "加载中",
  185. mask: true,
  186. })
  187. API.add( this.bindInfo ).then((res) => {
  188. uni.redirectTo({
  189. url:"/pages/mylock/bindLockStatus?id="+res.data.applicationRecord.id
  190. })
  191. uni.hideLoading();
  192. }).catch(error => {
  193. uni.showToast({
  194. title: error,
  195. icon: "none"
  196. })
  197. })
  198. },
  199. gotoscanMP(){
  200. // 允许从相机和相册扫码
  201. var _this=this
  202. uni.scanCode({
  203. success: function (res) {
  204. console.log('条码类型:' + res.scanType);
  205. console.log('条码内容:' + res.result);
  206. _this.getscan(res.result)
  207. }
  208. });
  209. },
  210. gotoscan() {
  211. // #ifdef H5
  212. this.gotoscanH5()
  213. // #endif
  214. // #ifdef MP-WEIXIN
  215. this.gotoscanMP()
  216. // #endif
  217. },
  218. getscan(val) {
  219. uni.showLoading({
  220. title: "加载中",
  221. mask: true,
  222. })
  223. API.bindStatusByNo({
  224. lockNo: val,
  225. }).then((res) => {
  226. uni.hideLoading();
  227. if (res.data.openBind) {
  228. var nowscan=res.data.floorlockInfoList;
  229. if(nowscan&&nowscan.length){
  230. this.bindInfo.lockNo=nowscan[0].lockNo
  231. this.bindInfo.type=nowscan[0].type
  232. this.bindInfo.typeN=nowscan[0].typeN
  233. }
  234. uni.showToast({
  235. title: "扫码成功",
  236. icon: "none"
  237. })
  238. } else {
  239. uni.showToast({
  240. title: "当前地锁不可绑定",
  241. icon: "none"
  242. })
  243. }
  244. }).catch(error => {
  245. uni.showToast({
  246. title: error,
  247. icon: "none"
  248. })
  249. })
  250. },
  251. gotoscanH5() {
  252. console.log('111')
  253. var _this = this;
  254. uni.showModal({
  255. title: '提示',
  256. editable: true,
  257. //content: '这是一个模态弹窗',
  258. success: function(res) {
  259. if (res.confirm) {
  260. _this.getscan(res.content)
  261. } else if (res.cancel) {
  262. console.log('用户点击取消');
  263. }
  264. }
  265. });
  266. },
  267. }
  268. }
  269. </script>
  270. <style>
  271. page {
  272. background-color: rgba(242, 244, 246, 1);
  273. }
  274. </style>
  275. <style lang="scss" scoped>
  276. .body {
  277. padding: 32rpx;
  278. }
  279. .list{
  280. background-color: rgba(255,255,255,1);
  281. margin: 20rpx 0;
  282. .item:not(:last-child) {
  283. border-bottom:1px solid rgba(232,232,232,1);
  284. }
  285. .item{
  286. padding: 32rpx;
  287. display: flex;
  288. justify-content: space-between;
  289. .name{
  290. width: 40%;
  291. font-size: 32rpx;
  292. color: #777777;
  293. span{
  294. color:red
  295. }
  296. white-space: pre;
  297. }
  298. .value{
  299. font-size: 32rpx;
  300. width: 60%;
  301. display: flex;
  302. justify-content: space-between;
  303. input::placeholder{
  304. color:#AAAAAA;
  305. }
  306. .img{
  307. width: 40rpx;
  308. height: 40rpx;
  309. }
  310. }
  311. }
  312. }
  313. .uni-input-placeholder{
  314. color:#AAAAAA;
  315. }
  316. .floating-button {
  317. position: fixed;
  318. bottom: 0; /* 距离底部 20px */
  319. width: 100%;
  320. display: flex;
  321. height: 120rpx;
  322. justify-content: center;
  323. background-color: rgba(255,255,255,1);
  324. .button{
  325. margin-top: 24rpx;
  326. border-radius: 50px;
  327. height: 80rpx;
  328. width: 80%;
  329. display: flex;
  330. align-items: center;
  331. justify-content: center;
  332. padding:12rpx;
  333. background-color: rgba(22,119,255,1);
  334. color: rgba(255,255,255,1);
  335. font-size: 36rpx;
  336. }
  337. }
  338. </style>