myLock.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. <template>
  2. <view class="jpmain ">
  3. <view class="body">
  4. <view class="page">
  5. <view class="page-content">
  6. <view class="item" v-for="(item,i) in list"
  7. @click="gotoItem(item)">
  8. <view class="title">
  9. <view class="name">
  10. <img class="img" src="@/assets/img/mylock/item1.svg" alt="">
  11. {{item.name}}
  12. <span v-if="item.phonetype==1" class="tag tag1">自有</span>
  13. <span v-if="item.phonetype==2" class="tag tag2">被授权</span>
  14. </view>
  15. <view class="value">
  16. <span v-if="item.parkingName">{{item.parkingName}}</span>
  17. <span v-if="item.typeN">{{item.typeN}}</span>
  18. <span v-if="item.addWhiteUserName">授权人:<span class="aspan" style="color:#00b962 ;">{{item.addWhiteUserName}}</span></span>
  19. <span v-if="item.whitePhoneNum">授权名单:{{item.whitePhoneNum}}</span>
  20. </view>
  21. </view>
  22. <view class="goto">
  23. <u-icon name="arrow-right" size="24" color="#BBBBBB"></u-icon>
  24. </view>
  25. </view>
  26. <u-empty text="列表为空" mode="list" margin-top="80" v-if="!list.length">
  27. </u-empty>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="floating-button">
  32. <view class="button " :class="{
  33. lt1:mylist.length
  34. }"
  35. @click="gotoUrl('pages/mylock/bindLock')" >
  36. <img class="img" src="@/assets/img/mylock/item2.svg" alt="">
  37. 绑定新地锁
  38. </view>
  39. <view class="button lt2" v-if="mylist.length"
  40. @click="addUser()" >
  41. <img class="img" src="@/assets/img/mylock/item4.svg" alt="">
  42. 添加授权
  43. </view>
  44. </view>
  45. <u-popup v-model="popupShow" mode="bottom" :closeable="true" border-radius="30">
  46. <view class="popup-screen">
  47. <u-keyboard ref="uKeyboard" @change="valChange" @backspace="backspace"
  48. :tips="vipUser.carNumber?vipUser.carNumber:'请输入车牌号'"
  49. mode="car" v-model="carshow" :abc="abc" ></u-keyboard>
  50. <view class="popup-title">{{vipUser.id?'修改':'添加'}}授权信息</view>
  51. <view style="padding: 4px;">绑定的地锁<span style="color: red;">*</span></view>
  52. <view class="carNumber" @click="selectFloorShow=true"
  53. :class="{
  54. 'carNumber1':!vipUser.floorlockId
  55. }">
  56. {{vipUser.floorlockId?mylist[selectFloorIndex[0]].name:'请先选择需要绑定的地锁'}}
  57. </view>
  58. <view style="padding: 4px;">授权车主姓名<span style="color: red;">*</span></view>
  59. <u-input :customStyle="customStyle" maxlength="8" v-model="vipUser.nickName" placeholder="授权车主姓名(必填)"></u-input>
  60. <view style="padding: 4px;">授权车主手机号码<span style="color: red;">*</span></view>
  61. <u-input :customStyle="customStyle" maxlength="13" type="number" v-model="vipUser.phone"
  62. placeholder="授权车主手机号码(必填)"></u-input>
  63. <view style="padding: 4px;">授权车主车牌号</view>
  64. <!-- <u-input :customStyle="customStyle" v-model="vipUser.carNumber" placeholder="授权车主车牌号"></u-input> -->
  65. <view class="carNumber" @click="carshow=true,valInit(1)"
  66. :class="{
  67. 'carNumber1':!vipUser.carNumber
  68. }">
  69. {{vipUser.carNumber?vipUser.carNumber:'授权车主车牌号'}}
  70. </view>
  71. <view >
  72. <u-button type="success" style="margin-top: 10px;" shape="circle"
  73. @click="submitUser()">保存</u-button>
  74. </view>
  75. <u-select v-model="selectFloorShow" value-name="id" label-name="name"
  76. :list="mylist" :default-value="selectFloorIndex" @confirm="confirm"></u-select>
  77. </view>
  78. </u-popup>
  79. </view>
  80. </template>
  81. <script>
  82. import * as API from '@/apis/pagejs/mylock.js'
  83. export default {
  84. components: {
  85. },
  86. data() {
  87. return {
  88. popupShow:false,
  89. whiteList:[],
  90. list:[],
  91. mylist:[],
  92. vipUser: {},
  93. abc:false,
  94. carshow: false,
  95. selectFloorShow:false,
  96. selectFloorIndex:[0],
  97. customStyle: {
  98. "border-radius": "50px",
  99. "background-color": 'rgba(242, 244, 246, 1)',
  100. padding: "5px 20px",
  101. margin: "5px 0 ",
  102. },
  103. }
  104. },
  105. onLoad() {
  106. },
  107. onShow() {
  108. this.getFloorlockList()
  109. },
  110. methods: {
  111. addUser() {
  112. this.popupShow = true;
  113. this.vipUser = {
  114. carNumber:""
  115. }
  116. this.selectFloorIndex=[0]
  117. if(this.mylist.length==1){
  118. this.vipUser.floorlockId = this.mylist[0].id
  119. }
  120. },
  121. confirm(e) {
  122. console.log(e);
  123. this.vipUser.floorlockId=e[0].value
  124. var i =this.mylist.findIndex(item=>{
  125. return item.id==this.vipUser.floorlockId
  126. })
  127. this.selectFloorIndex=[i]
  128. },
  129. backspace(){
  130. //
  131. var value=this.vipUser.carNumber
  132. if(value.length){
  133. value = value.substr(0, value.length - 1);
  134. }
  135. this.vipUser.carNumber=value
  136. this.valInit()
  137. },
  138. valChange(val){
  139. if(this.vipUser.carNumber.length>=8){
  140. return
  141. }
  142. this.vipUser.carNumber+=val
  143. this.valInit()
  144. this.$forceUpdate()
  145. },
  146. submitUser() {
  147. if (!this.vipUser.floorlockId) {
  148. uni.showToast({
  149. title: "请先选择需要绑定的地锁"
  150. })
  151. return
  152. }
  153. if (!this.vipUser.nickName) {
  154. uni.showToast({
  155. title: "请填写授权车主姓名"
  156. })
  157. return
  158. }
  159. if (!this.vipUser.phone) {
  160. uni.showToast({
  161. title: "请填写授权车主手机号码"
  162. })
  163. return
  164. }
  165. uni.showLoading({
  166. title: "加载中",
  167. mask: true,
  168. })
  169. this.vipUser.name = this.vipUser.nickName
  170. API.addWhite(this.vipUser).then((res) => {
  171. //this.obj = res.data
  172. uni.hideLoading()
  173. this.delShow = false
  174. this.popupShow = false
  175. //this.getWhiteList(1)
  176. uni.showModal({
  177. title: '提示',
  178. showCancel: false,
  179. content: "操作成功",
  180. success: res1 => {
  181. if (res1.confirm) {
  182. // uni.navigateTo({
  183. // url:"/pages/searchPile/stationAndPile/chargingPileDetails?isback=1&id="+gunNo
  184. // })
  185. } else if (res1.cancel) {
  186. //('用户点击取消');
  187. }
  188. }
  189. })
  190. this.getFloorlockList()
  191. }).catch(error => {
  192. uni.showToast({
  193. title: error
  194. })
  195. })
  196. },
  197. valInit(bl){
  198. if(bl){
  199. this.abc=this.vipUser.carNumber.length>0
  200. }else{
  201. if(this.vipUser.carNumber.length==1&&this.abc==false){
  202. this.abc=true
  203. }
  204. if(this.vipUser.carNumber.length==0&&this.abc==true){
  205. this.abc=false
  206. }
  207. }
  208. },
  209. gotoItem(item){
  210. if(item.phonetype==1){
  211. this.gotoUrl('pages/mylock/infoLock?id='+item.id)
  212. }
  213. if(item.phonetype==2){
  214. this.gotoUrl('pages/business/lockInfo?from=1&id='+item.id)
  215. }
  216. },
  217. getFloorlockList() {
  218. uni.showLoading({
  219. title: "加载中",
  220. mask: true,
  221. })
  222. this.list=[]
  223. API.myParkingSpot().then((res) => {
  224. this.mylist = res.data.floorList
  225. this.whiteList = res.data.whiteList
  226. for(var i in this.mylist ){
  227. var item = this.mylist[i]
  228. item.phonetype=1
  229. this.list.push(item)
  230. }
  231. for(var i in this.whiteList ){
  232. var item = this.whiteList[i]
  233. item.phonetype=2
  234. this.list.push(item)
  235. }
  236. uni.hideLoading();
  237. }).catch(error => {
  238. uni.hideLoading();
  239. uni.showToast({
  240. title: error,
  241. icon: "none"
  242. })
  243. })
  244. }
  245. }
  246. }
  247. </script>
  248. <style>
  249. page {
  250. background-color: rgba(242, 244, 246, 1);
  251. }
  252. </style>
  253. <style scoped lang="scss">
  254. /* styles.css */
  255. .body {
  256. padding: 32rpx;
  257. }
  258. .page {
  259. .page-content {
  260. .item {
  261. padding: 32rpx;
  262. margin-bottom: 32rpx;
  263. background-color: rgba(255, 255, 255, 1);
  264. border-radius: 16rpx;
  265. display: flex;
  266. justify-content: space-between;
  267. align-items: center;
  268. font-size: 32rpx;
  269. .title {
  270. .name {
  271. display: flex;
  272. align-items: center;
  273. color: rgba(22, 119, 255, 1);
  274. font-size: 32rpx;
  275. font-weight: bold;
  276. margin-bottom: 8rpx;
  277. .img {
  278. width: 36rpx;
  279. height: 32rpx;
  280. margin-right: 8rpx;
  281. }
  282. }
  283. .value {
  284. color: rgba(119, 119, 119, 1);
  285. font-size: 24rpx;
  286. span {
  287. margin-right: 16rpx;
  288. }
  289. }
  290. }
  291. .goto {
  292. color: rgba(119, 119, 119, 1);
  293. }
  294. }
  295. }
  296. }
  297. .floating-button {
  298. position: fixed;
  299. bottom: 0;
  300. width: 100%;
  301. height: 120rpx;
  302. display: flex;
  303. background-color:#fff;
  304. justify-content: center;
  305. padding-top: 20rpx;
  306. .button {
  307. border-radius: 50px;
  308. background-color: rgba(49, 51, 52, 1);
  309. color: rgba(255, 255, 255, 1);
  310. font-size: 28rpx;
  311. width: 240rpx;
  312. height: 80rpx;
  313. display: flex;
  314. align-items: center;
  315. justify-content: center;
  316. padding: 12rpx;
  317. .img {
  318. width: 40rpx;
  319. height: 40rpx;
  320. margin-right: 8rpx;
  321. }
  322. }
  323. .lt1{
  324. border-radius: 50px 0 0 50px;
  325. background-color: #53B56B;
  326. }
  327. .lt2{
  328. border-radius:0 50px 50px 0;
  329. background-color: #307AF6;
  330. }
  331. }
  332. .tag{
  333. border-radius: 4px;
  334. background-color: rgba(255,255,255,1);
  335. color: rgba(0,185,98,1);
  336. font-size: 24rpx;
  337. text-align: center;
  338. margin: 0 8rpx;
  339. padding: 2rpx 8rpx;
  340. border: 1px solid rgba(0,185,98,1);
  341. }
  342. .tag1{
  343. color: #1677FF ;
  344. border: 1px solid #1677FF ;
  345. }
  346. .tag2{
  347. color: rgba(0,185,98,1);
  348. border: 1px solid rgba(0,185,98,1);
  349. }
  350. ::v-deep.u-keyboard-grids-btn:nth-child(15){
  351. background-color: red;
  352. }
  353. .popup-screen {
  354. padding: 40rpx 40rpx 60rpx 40rpx;
  355. .carNumber {
  356. background-color: #F2F4F6;
  357. padding: 5px 20px;
  358. margin: 5px 0 15px 0;
  359. height: 90rpx;
  360. display: flex;
  361. align-items: center;
  362. border-radius: 50px;
  363. }
  364. .carNumber1{
  365. color: #bcbcbc;
  366. }
  367. .popup-title {
  368. font-size: 36rpx;
  369. color: rgba(51, 51, 51, 1);
  370. font-weight: bold;
  371. padding-bottom: 10px;
  372. }
  373. .cardList {
  374. display: flex;
  375. justify-content: space-evenly;
  376. .cardInfo {
  377. display: flex;
  378. flex-direction: column;
  379. justify-content: center;
  380. width: 160rpx;
  381. height: 160rpx;
  382. border-radius: 8px;
  383. background-color: rgba(255, 255, 255, 1);
  384. text-align: center;
  385. border: 1px solid rgba(187, 187, 187, 1);
  386. .name {
  387. color: rgba(16, 16, 16, 1);
  388. font-size: 28rpx;
  389. }
  390. .price {
  391. color: rgba(16, 16, 16, 1);
  392. font-size: 48rpx;
  393. font-weight: bold;
  394. }
  395. }
  396. .cardInfoCk {
  397. background-color: rgba(225, 247, 237, 1);
  398. border: 1px solid rgba(0, 185, 98, 1);
  399. .price {
  400. color: rgba(0, 161, 85, 1);
  401. }
  402. }
  403. }
  404. }
  405. </style>