editLock.vue 8.9 KB

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