bindLock.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. <template>
  2. <view class="jpmain ">
  3. <!-- <view class="body">
  4. <u-steps :list="numList" mode="number" :current="current" un-active-color="#999999"></u-steps >
  5. </view>-->
  6. <view class="list" >
  7. <view class="item" @click="gotoscan">
  8. <view class="name">
  9. <span>*</span>地锁编号
  10. </view>
  11. <view class="value">
  12. <view :style="bindInfo.lockNo?'':'color:rgb(187, 187, 187)'">{{bindInfo.lockNo?bindInfo.lockNo:'请扫码识别地锁'}}</view>
  13. <view><img class="img" src="@/assets/img/mylock/item3.svg" alt=""></view>
  14. </view>
  15. </view>
  16. <view class="item">
  17. <view class="name">
  18. <span>*</span>管理者
  19. </view>
  20. <view class="value">
  21. <input v-model="bindInfo.name" placeholder="请填写用户真实姓名" />
  22. </view>
  23. </view>
  24. <view class="item">
  25. <view class="name">
  26. <span>*</span>联系电话
  27. </view>
  28. <view class="value">
  29. <input v-model="bindInfo.phone" placeholder="请填写手机号码" />
  30. </view>
  31. </view>
  32. </view>
  33. <view class="list">
  34. <view class="item" >
  35. <view class="name">
  36. <span>*</span>地锁类型
  37. </view>
  38. <view class="value">
  39. <view>
  40. <u-radio-group v-model="bindInfo.type" >
  41. <u-radio
  42. v-for="(item, index) in bindInfotypelist" :key="index"
  43. :name="item.id"
  44. >
  45. {{item.name}}
  46. </u-radio>
  47. </u-radio-group>
  48. </view>
  49. <!-- <u-icon name="arrow-right" size="24" color="#BBBBBB"></u-icon> -->
  50. </view>
  51. </view>
  52. <view class="item" >
  53. <view class="name">
  54. <span>*</span>所属停车场
  55. </view>
  56. <view class="value" @click="gotoSelectParking()">
  57. <view :style="bindInfo.parkingIdN?'':'color:#BBB'"
  58. >{{bindInfo.parkingIdN?bindInfo.parkingIdN:'请选择所属停车场'}}</view>
  59. <u-icon name="arrow-right" size="24" color="#BBBBBB"></u-icon>
  60. </view>
  61. </view>
  62. <view class="item">
  63. <view class="name">
  64. <span>*</span>地锁名称
  65. </view>
  66. <view class="value">
  67. <input placeholder="如智泊地锁" v-model="bindInfo.lockName" />
  68. </view>
  69. </view>
  70. <view class="item">
  71. <view class="name">
  72. 地锁定位
  73. </view>
  74. <view class="value" @click="getUserLocation" >
  75. <view :style="bindInfo.address?'':'color:#BBB'"
  76. >{{bindInfo.address?bindInfo.address:'点击获取地锁定位信息'}}</view>
  77. <view><img class="img" src="@/assets/img/mylock/item5.svg" alt=""></view>
  78. </view>
  79. </view>
  80. <view class="floating-button">
  81. <view class="button" @click="submit" >
  82. 提交
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. </template>
  88. <script>
  89. import * as API from '@/apis/pagejs/mylock.js'
  90. export default {
  91. components: {
  92. // //'u-radio-group': () => import('@/uni_modules/uview-ui/components/u-radio-group/u-radio-group'),
  93. // //'u-radio': () => import('@/uni_modules/uview-ui/components/u-radio/u-radio'),
  94. //'u-picker': () => import('@/uni_modules/uview-ui/components/u-picker/u-picker'),
  95. },
  96. options:{styleIsolation: 'shared'},
  97. data() {
  98. return {
  99. id:"",
  100. current: 0,
  101. nowscan:{},
  102. columnsindex:[0],
  103. bindInfo:{
  104. name:"",
  105. lockName:"",
  106. phone:"",
  107. lockNo:"",
  108. type:"",
  109. remark:"",
  110. describe:"",
  111. parkingNumber:"",
  112. address:"",
  113. },
  114. bindInfotypelist:[
  115. {id:"1",name:"公共地锁"},
  116. {id:"2",name:"私人地锁"}
  117. ],
  118. isswitchshow:false,
  119. allList:[],
  120. numList: [{
  121. name: '绑定地锁'
  122. }, {
  123. name: '等待审核'
  124. }, {
  125. name: '完成绑定'
  126. }],
  127. };
  128. },
  129. onLoad(op) {
  130. this.userInfo = this.jphelp.getPersonInfo()
  131. this.bindInfo.phone=this.userInfo.phone
  132. if(op.id){
  133. this.id=op.id
  134. }
  135. },
  136. computed:{
  137. columns(){
  138. var sz=[]
  139. for(var i in this.allList){
  140. var obj=this.allList[i]
  141. sz.push({
  142. value:obj.id,
  143. label:obj.name
  144. })
  145. }
  146. return sz
  147. }
  148. },
  149. methods:{
  150. gotoSelectParking(){
  151. uni.navigateTo({
  152. url: '/pages/mylock/selectParking',
  153. events: {
  154. // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
  155. acceptDataFromOpenerPage: (item)=>{
  156. console.log(item)
  157. this.bindInfo.parkingIdN=item.data
  158. this.bindInfo.parkingId=item.dataid
  159. this.bindInfo.parkingName=item.data
  160. this.$forceUpdate()
  161. },
  162. }
  163. // ,
  164. // success: function(res) {
  165. // // 通过eventChannel向被打开页面传送数据
  166. //
  167. // }
  168. })
  169. },
  170. chooseLocationsuccess(res){
  171. console.log('位置名称:' + res.name);
  172. console.log('详细地址:' + res.address);
  173. console.log('纬度:' + res.latitude);
  174. console.log('经度:' + res.longitude);
  175. this.bindInfo.address=res.address
  176. this.bindInfo.latitude=res.latitude
  177. this.bindInfo.longitude=res.longitude
  178. },
  179. getUserLocation(){
  180. var _this=this;
  181. // #ifdef H5
  182. this.bindInfo.address='湖北省荆州市'
  183. this.bindInfo.latitude='30.31098'
  184. this.bindInfo.longitude='112.25494'
  185. // #endif
  186. // #ifdef MP-WEIXIN
  187. uni.authorize({
  188. scope: 'scope.userLocation',
  189. success() {
  190. uni.chooseLocation({
  191. success: function (res) {
  192. _this.chooseLocationsuccess(res)
  193. }
  194. });
  195. }
  196. })
  197. // #endif
  198. },
  199. switchBtn(e){
  200. this.columnsindex=[e[0]]
  201. var obj=this.columns[e[0]]
  202. this.bindInfo.parkingId=obj.value
  203. this.bindInfo.parkingIdN=obj.label
  204. },
  205. isswitchshowBtn(){
  206. if(this.allList.length){
  207. this.isswitchshow=true
  208. }else{
  209. this.getParkingList()
  210. }
  211. },
  212. getParkingList() {
  213. uni.showLoading({
  214. title: "加载中",
  215. mask: true,
  216. })
  217. var obj = {
  218. pageIndex: 1,
  219. pageSize: 900,
  220. type:"bindLock"
  221. }
  222. API.parkingList(obj).then((res) => {
  223. this.allList = res.data.data
  224. this.isswitchshow=true
  225. uni.hideLoading();
  226. }).catch(error => {
  227. uni.hideLoading();
  228. uni.showToast({
  229. title: error,
  230. icon: "none"
  231. })
  232. })
  233. },
  234. submit(){
  235. if(!this.bindInfo.lockNo){
  236. uni.showToast({
  237. title: "请扫码识别地锁",
  238. icon: "none"
  239. })
  240. return
  241. }
  242. if(!this.bindInfo.name){
  243. uni.showToast({
  244. title: "请填写用户真实姓名",
  245. icon: "none"
  246. })
  247. return
  248. }
  249. if(!this.bindInfo.phone){
  250. uni.showToast({
  251. title: "请填写手机号码",
  252. icon: "none"
  253. })
  254. return
  255. }
  256. if(!this.bindInfo.type){
  257. uni.showToast({
  258. title: "请选择地锁类型",
  259. icon: "none"
  260. })
  261. return
  262. }
  263. if(!this.bindInfo.parkingIdN){
  264. uni.showToast({
  265. title: "请选择所属停车场",
  266. icon: "none"
  267. })
  268. return
  269. }
  270. if(!this.bindInfo.lockName){
  271. uni.showToast({
  272. title: "请填写地锁名称",
  273. icon: "none"
  274. })
  275. return
  276. }
  277. if(!this.bindInfo.address){
  278. uni.showToast({
  279. title: "点击获取地锁定位信息",
  280. icon: "none"
  281. })
  282. return
  283. }
  284. uni.showLoading({
  285. title: "加载中",
  286. mask: true,
  287. })
  288. API.add( this.bindInfo ).then((res) => {
  289. uni.redirectTo({
  290. url:"/pages/mylock/bindLockStatus?id="+this.nowscan.id
  291. })
  292. uni.hideLoading();
  293. }).catch(error => {
  294. uni.showToast({
  295. title: error,
  296. icon: "none"
  297. })
  298. })
  299. },
  300. gotoscanMP(){
  301. // 允许从相机和相册扫码
  302. var _this=this
  303. uni.scanCode({
  304. success: function (res) {
  305. console.log('条码类型:' + res.scanType);
  306. console.log('条码内容:' + res.result);
  307. _this.getscan(res.result)
  308. }
  309. });
  310. },
  311. gotoscan() {
  312. // #ifdef H5
  313. this.gotoscanH5()
  314. // #endif
  315. // #ifdef MP-WEIXIN
  316. this.gotoscanMP()
  317. // #endif
  318. },
  319. getscan(val) {
  320. uni.showLoading({
  321. title: "加载中",
  322. mask: true,
  323. })
  324. API.bindStatusByNo({
  325. lockNo: val,
  326. }).then((res) => {
  327. uni.hideLoading();
  328. if (process.env.NODE_ENV === "development") {
  329. var nowscan=res.data.floorlockInfoList;
  330. if(nowscan&&nowscan.length){
  331. this.nowscan=nowscan[0];
  332. this.bindInfo.lockNo=nowscan[0].lockNo
  333. this.bindInfo.type=nowscan[0].type
  334. this.bindInfo.lockName="智泊地锁"
  335. }
  336. uni.showToast({
  337. title: "扫码成功",
  338. icon: "none"
  339. })
  340. }
  341. if (res.data.openBind) {
  342. var nowscan=res.data.floorlockInfoList;
  343. if(nowscan&&nowscan.length){
  344. this.nowscan=nowscan[0];
  345. this.bindInfo.lockNo=nowscan[0].lockNo
  346. this.bindInfo.type=nowscan[0].type
  347. this.bindInfo.name="智泊地锁"
  348. }
  349. uni.showToast({
  350. title: "扫码成功",
  351. icon: "none"
  352. })
  353. } else {
  354. uni.showToast({
  355. title: "当前地锁不可绑定",
  356. icon: "none"
  357. })
  358. }
  359. }).catch(error => {
  360. uni.showToast({
  361. title: error,
  362. icon: "none"
  363. })
  364. })
  365. },
  366. gotoscanH5() {
  367. console.log('111')
  368. var _this = this;
  369. uni.showModal({
  370. title: '提示',
  371. editable: true,
  372. //content: '这是一个模态弹窗',
  373. success: function(res) {
  374. if (res.confirm) {
  375. _this.getscan(res.content)
  376. } else if (res.cancel) {
  377. console.log('用户点击取消');
  378. }
  379. }
  380. });
  381. },
  382. }
  383. }
  384. </script>
  385. <style>
  386. page {
  387. background-color: rgba(242, 244, 246, 1);
  388. }
  389. </style>
  390. <style lang="scss" scoped>
  391. .body {
  392. padding: 32rpx;
  393. }
  394. .list{
  395. background-color: rgba(255,255,255,1);
  396. margin: 20rpx 0;
  397. .item:not(:last-child) {
  398. border-bottom:1px solid rgba(232,232,232,1);
  399. }
  400. .item{
  401. padding: 32rpx;
  402. display: flex;
  403. justify-content: space-between;
  404. .name{
  405. width: 40%;
  406. font-size: 32rpx;
  407. color: #777777;
  408. span{
  409. color:red
  410. }
  411. white-space: pre;
  412. }
  413. .value{
  414. font-size: 32rpx;
  415. width: 60%;
  416. display: flex;
  417. justify-content: space-between;
  418. input::placeholder{
  419. color:#AAAAAA;
  420. }
  421. .img{
  422. width: 40rpx;
  423. height: 40rpx;
  424. }
  425. }
  426. }
  427. }
  428. .uni-input-placeholder{
  429. color:#AAAAAA;
  430. }
  431. .floating-button {
  432. position: fixed;
  433. bottom: 0; /* 距离底部 20px */
  434. width: 100%;
  435. display: flex;
  436. height: 120rpx;
  437. justify-content: center;
  438. background-color: rgba(255,255,255,1);
  439. .button{
  440. margin-top: 24rpx;
  441. border-radius: 50px;
  442. height: 80rpx;
  443. width: 80%;
  444. display: flex;
  445. align-items: center;
  446. justify-content: center;
  447. padding:12rpx;
  448. background-color: rgba(22,119,255,1);
  449. color: rgba(255,255,255,1);
  450. font-size: 36rpx;
  451. }
  452. }
  453. </style>