editLock.vue 8.9 KB

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