bindLock.vue 8.2 KB

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