bindLock.vue 9.3 KB

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