myLock.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  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">来自{{item.addWhiteUserName}}的共享</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. //'u-button': () => import('@/uni_modules/uview-ui/components/u-button/u-button'),
  86. //'u-keyboard': () => import('@/uni_modules/uview-ui/components/u-keyboard/u-keyboard'),
  87. //'u-popup': () => import('@/uni_modules/uview-ui/components/u-popup/u-popup'),
  88. //'u-select': () => import('@/uni_modules/uview-ui/components/u-select/u-select'),
  89. //'u-input': () => import('@/uni_modules/uview-ui/components/u-input/u-input'),
  90. },
  91. data() {
  92. return {
  93. popupShow:false,
  94. whiteList:[],
  95. list:[],
  96. mylist:[],
  97. vipUser: {},
  98. abc:false,
  99. carshow: false,
  100. selectFloorShow:false,
  101. selectFloorIndex:[0],
  102. customStyle: {
  103. "border-radius": "50px",
  104. "background-color": 'rgba(242, 244, 246, 1)',
  105. padding: "5px 20px",
  106. margin: "5px 0 ",
  107. },
  108. }
  109. },
  110. onLoad() {
  111. },
  112. onShow() {
  113. this.getFloorlockList()
  114. },
  115. methods: {
  116. addUser() {
  117. this.popupShow = true;
  118. this.vipUser = {
  119. carNumber:""
  120. }
  121. this.selectFloorIndex=[0]
  122. if(this.mylist.length==1){
  123. this.vipUser.floorlockId = this.mylist[0].id
  124. }
  125. },
  126. confirm(e) {
  127. console.log(e);
  128. this.vipUser.floorlockId=e[0].value
  129. var i =this.mylist.findIndex(item=>{
  130. return item.id==this.vipUser.floorlockId
  131. })
  132. this.selectFloorIndex=[i]
  133. },
  134. backspace(){
  135. //
  136. var value=this.vipUser.carNumber
  137. if(value.length){
  138. value = value.substr(0, value.length - 1);
  139. }
  140. this.vipUser.carNumber=value
  141. this.valInit()
  142. },
  143. valChange(val){
  144. if(this.vipUser.carNumber.length>=8){
  145. return
  146. }
  147. this.vipUser.carNumber+=val
  148. this.valInit()
  149. this.$forceUpdate()
  150. },
  151. submitUser() {
  152. if (!this.vipUser.floorlockId) {
  153. uni.showToast({
  154. title: "请先选择需要绑定的车位"
  155. })
  156. return
  157. }
  158. if (!this.vipUser.nickName) {
  159. uni.showToast({
  160. title: "请填写白名单车主姓名"
  161. })
  162. return
  163. }
  164. if (!this.vipUser.phone) {
  165. uni.showToast({
  166. title: "请填写白名单车主手机号码"
  167. })
  168. return
  169. }
  170. uni.showLoading({
  171. title: "加载中",
  172. mask: true,
  173. })
  174. this.vipUser.name = this.vipUser.nickName
  175. API.addWhite(this.vipUser).then((res) => {
  176. //this.obj = res.data
  177. uni.hideLoading()
  178. this.delShow = false
  179. this.popupShow = false
  180. //this.getWhiteList(1)
  181. uni.showModal({
  182. title: '提示',
  183. showCancel: false,
  184. content: "操作成功",
  185. success: res1 => {
  186. if (res1.confirm) {
  187. // uni.navigateTo({
  188. // url:"/pages/searchPile/stationAndPile/chargingPileDetails?isback=1&id="+gunNo
  189. // })
  190. } else if (res1.cancel) {
  191. //('用户点击取消');
  192. }
  193. }
  194. })
  195. this.getFloorlockList()
  196. }).catch(error => {
  197. uni.showToast({
  198. title: error
  199. })
  200. })
  201. },
  202. valInit(bl){
  203. if(bl){
  204. this.abc=this.vipUser.carNumber.length>0
  205. }else{
  206. if(this.vipUser.carNumber.length==1&&this.abc==false){
  207. this.abc=true
  208. }
  209. if(this.vipUser.carNumber.length==0&&this.abc==true){
  210. this.abc=false
  211. }
  212. }
  213. },
  214. gotoItem(item){
  215. if(item.phonetype==1){
  216. this.gotoUrl('pages/mylock/infoLock?id='+item.id)
  217. }
  218. if(item.phonetype==2){
  219. this.gotoUrl('pages/business/lockInfo?id='+item.id)
  220. }
  221. },
  222. getFloorlockList() {
  223. uni.showLoading({
  224. title: "加载中",
  225. mask: true,
  226. })
  227. this.list=[]
  228. API.myParkingSpot().then((res) => {
  229. this.mylist = res.data.floorList
  230. this.whiteList = res.data.whiteList
  231. for(var i in this.mylist ){
  232. var item = this.mylist[i]
  233. item.phonetype=1
  234. this.list.push(item)
  235. }
  236. for(var i in this.whiteList ){
  237. var item = this.whiteList[i]
  238. item.phonetype=2
  239. this.list.push(item)
  240. }
  241. uni.hideLoading();
  242. }).catch(error => {
  243. uni.hideLoading();
  244. uni.showToast({
  245. title: error,
  246. icon: "none"
  247. })
  248. })
  249. }
  250. }
  251. }
  252. </script>
  253. <style>
  254. page {
  255. background-color: rgba(242, 244, 246, 1);
  256. }
  257. </style>
  258. <style scoped lang="scss">
  259. /* styles.css */
  260. .body {
  261. padding: 32rpx;
  262. }
  263. .page {
  264. .page-content {
  265. .item {
  266. padding: 32rpx;
  267. margin-bottom: 32rpx;
  268. background-color: rgba(255, 255, 255, 1);
  269. border-radius: 16rpx;
  270. display: flex;
  271. justify-content: space-between;
  272. align-items: center;
  273. font-size: 32rpx;
  274. .title {
  275. .name {
  276. display: flex;
  277. align-items: center;
  278. color: rgba(22, 119, 255, 1);
  279. font-size: 32rpx;
  280. font-weight: bold;
  281. margin-bottom: 8rpx;
  282. .img {
  283. width: 36rpx;
  284. height: 32rpx;
  285. margin-right: 8rpx;
  286. }
  287. }
  288. .value {
  289. color: rgba(119, 119, 119, 1);
  290. font-size: 24rpx;
  291. span {
  292. margin-right: 16rpx;
  293. }
  294. }
  295. }
  296. .goto {
  297. color: rgba(119, 119, 119, 1);
  298. }
  299. }
  300. }
  301. }
  302. .floating-button {
  303. position: fixed;
  304. bottom: 0;
  305. width: 100%;
  306. height: 120rpx;
  307. display: flex;
  308. background-color:#fff;
  309. justify-content: center;
  310. padding-top: 20rpx;
  311. .button {
  312. border-radius: 50px;
  313. background-color: rgba(49, 51, 52, 1);
  314. color: rgba(255, 255, 255, 1);
  315. font-size: 28rpx;
  316. width: 240rpx;
  317. height: 80rpx;
  318. display: flex;
  319. align-items: center;
  320. justify-content: center;
  321. padding: 12rpx;
  322. .img {
  323. width: 40rpx;
  324. height: 40rpx;
  325. margin-right: 8rpx;
  326. }
  327. }
  328. .lt1{
  329. border-radius: 50px 0 0 50px;
  330. background-color: #53B56B;
  331. }
  332. .lt2{
  333. border-radius:0 50px 50px 0;
  334. background-color: #307AF6;
  335. }
  336. }
  337. .tag{
  338. border-radius: 4px;
  339. background-color: rgba(255,255,255,1);
  340. color: rgba(0,185,98,1);
  341. font-size: 24rpx;
  342. text-align: center;
  343. margin: 0 8rpx;
  344. padding: 2rpx 8rpx;
  345. border: 1px solid rgba(0,185,98,1);
  346. }
  347. .tag1{
  348. color: #1677FF ;
  349. border: 1px solid #1677FF ;
  350. }
  351. .tag2{
  352. color: rgba(0,185,98,1);
  353. border: 1px solid rgba(0,185,98,1);
  354. }
  355. ::v-deep.u-keyboard-grids-btn:nth-child(15){
  356. background-color: red;
  357. }
  358. .popup-screen {
  359. padding: 40rpx 40rpx 60rpx 40rpx;
  360. .carNumber {
  361. background-color: #F2F4F6;
  362. padding: 5px 20px;
  363. margin: 5px 0 15px 0;
  364. height: 90rpx;
  365. display: flex;
  366. align-items: center;
  367. border-radius: 50px;
  368. }
  369. .carNumber1{
  370. color: #bcbcbc;
  371. }
  372. .popup-title {
  373. font-size: 36rpx;
  374. color: rgba(51, 51, 51, 1);
  375. font-weight: bold;
  376. padding-bottom: 10px;
  377. }
  378. .cardList {
  379. display: flex;
  380. justify-content: space-evenly;
  381. .cardInfo {
  382. display: flex;
  383. flex-direction: column;
  384. justify-content: center;
  385. width: 160rpx;
  386. height: 160rpx;
  387. border-radius: 8px;
  388. background-color: rgba(255, 255, 255, 1);
  389. text-align: center;
  390. border: 1px solid rgba(187, 187, 187, 1);
  391. .name {
  392. color: rgba(16, 16, 16, 1);
  393. font-size: 28rpx;
  394. }
  395. .price {
  396. color: rgba(16, 16, 16, 1);
  397. font-size: 48rpx;
  398. font-weight: bold;
  399. }
  400. }
  401. .cardInfoCk {
  402. background-color: rgba(225, 247, 237, 1);
  403. border: 1px solid rgba(0, 185, 98, 1);
  404. .price {
  405. color: rgba(0, 161, 85, 1);
  406. }
  407. }
  408. }
  409. }
  410. </style>