bindLock.vue 9.3 KB

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