bindLock.vue 8.3 KB

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