openPass.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <template>
  2. <view style="background-color: #FFFFFF;height: 100vh;">
  3. <!--pages/openPass/openPass.wxml-->
  4. <view class="container edit_wrap">
  5. <view class="form_group">
  6. <text class="type">选择房间:</text>
  7. <view class="ar_picker " style="background:#fff;border-bottom: 1rpx solid #ddd;"
  8. @click="roomSelectShow=true">
  9. <view class="ar_picker_wrap">
  10. <text>{{selectRoomName?selectRoomName:room_list[0].address}}</text>
  11. </view>
  12. </view>
  13. </view>
  14. <view class="form_group">
  15. <view class="tui-picker-content">
  16. <text class="type">访客类型:</text>
  17. <view class="flex between itemBox">
  18. <view v-for="(item, index) in guestTypeArray" :key="index"
  19. :class="guestTypeIndex == index ? 'active':''" @tap="guestTypethis" :data-thisindex="index">
  20. <text>{{item}}</text>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="form_group">
  26. <view class="tui-picker-content">
  27. <text class="type">授权有效时间:</text>
  28. <view class="flex between itemBox">
  29. <view v-for="(item, index) in numArray" :key="index" :class="activeIndex == index ? 'active':''"
  30. @tap="activethis" :data-thisindex="index">
  31. <text>{{item}}小时</text>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <view @tap="getGuestAuthorize" class=" footer-fixed " style="z-index: 99;"
  37. :style="{marginBottom:safeAreaBottom + 'rpx'}">
  38. <view class="cu-btn flex text-lg bg-red-btn" style="padding: 46rpx 0;">
  39. 确认授权
  40. </view>
  41. </view>
  42. </view>
  43. <!--弹窗-->
  44. <view class="modal-mask" @tap="closeModal" catchtouchmove="preventTouchMove" v-if="showModal"></view>
  45. <view class="modal-dialog" v-if="showModal">
  46. <view class="modal-title">提示</view>
  47. <view class="modal-content">
  48. <view class="modal-input">
  49. <text class="password">授权成功,请转发给好友填写表单</text>
  50. </view>
  51. </view>
  52. <view class="modal-footer">
  53. <button class="btn-confirm" @click="showModal=false" data-status="confirm">暂不转发</button>
  54. <button class="btn-cancel" open-type="share" data-status="cancel">立即转发</button>
  55. </view>
  56. </view>
  57. <u-select z-index="999" mode="single-column" value-name="id" label-name="address" v-model="roomSelectShow"
  58. :list="room_list" @confirm="roomChange"></u-select>
  59. </view>
  60. </template>
  61. <script>
  62. // 访客授权
  63. //获取app实例
  64. var app = getApp();
  65. var util = require("../../../utils/util.js");
  66. export default {
  67. data() {
  68. return {
  69. //是否需要审核通过访客表单后才能开门
  70. doorNeedAudit: 0,
  71. roomSelectShow: false,
  72. selectRoomName: '',
  73. selectRoomId: 0,
  74. //授权记录 的id
  75. id: '',
  76. room_list: null,
  77. minusStatus: 'disable',
  78. //获取开门密码
  79. showModal: false,
  80. //访客类型
  81. guestTypeIndex: 0,
  82. //默认选中第一个
  83. guestTypeArray: ['朋友', '外卖', '快递', '其他'],
  84. //密码有效期
  85. activeIndex: 0,
  86. //默认选中第一个
  87. numArray: [1, 2, 5, 8, 24, 48],
  88. begin_date: "",
  89. end_date: ""
  90. };
  91. },
  92. components: {},
  93. props: {},
  94. /**
  95. * 监听页面加载
  96. */
  97. onLoad() {
  98. this.doorNeedAudit = uni.getStorageSync("doorNeedAudit")
  99. //禁用头部分享
  100. uni.hideShareMenu({});
  101. //获取房屋信息
  102. this.geRoomByMemberId();
  103. },
  104. onShareAppMessage: function(ops) {
  105. this.showModal = false
  106. let roomName = this.selectRoomName ? this.selectRoomName : this.room_list[0].name
  107. let title = `访问房间:${roomName};
  108. 开始日期:${this.begin_date};
  109. 结束日期:${this.end_date}`
  110. return {
  111. title: title,
  112. path: "/pages/guest/guest_form?id=" + this.id + "&doorNeedAudit=" + this.doorNeedAudit + "&memberId=" +
  113. app.globalData.member.id,
  114. imageUrl: "/static/clock.png"
  115. };
  116. },
  117. methods: {
  118. //选择房间
  119. roomChange: function(e) {
  120. console.log(e, "e");
  121. this.selectRoomId = e[0].value
  122. this.selectRoomName = e[0].label
  123. },
  124. //访客类型
  125. guestTypethis: function(event) {
  126. //点击选中事件
  127. var thisindex = event.currentTarget.dataset.thisindex; //当前index
  128. this.setData({
  129. guestTypeIndex: thisindex
  130. });
  131. },
  132. //密码有效时间
  133. activethis: function(event) {
  134. //点击选中事件
  135. var thisindex = event.currentTarget.dataset.thisindex; //当前index
  136. this.setData({
  137. activeIndex: thisindex
  138. });
  139. },
  140. //关闭弹窗
  141. closeModal: function() {
  142. this.setData({
  143. showModal: false
  144. });
  145. },
  146. //获取开门密码
  147. getGuestAuthorize: function() {
  148. let avalidTime = this.numArray[this.activeIndex]
  149. let beginDate = new Date()
  150. let endDate = new Date()
  151. endDate.setHours(endDate.getHours() + avalidTime)
  152. let params = {
  153. roomId: this.selectRoomId,
  154. beginDate: this.$u.timeFormat(beginDate, 'yyyy-mm-dd hh:MM:ss'),
  155. endDate: this.$u.timeFormat(endDate, 'yyyy-mm-dd hh:MM:ss'),
  156. memberId: this.vuex_member.id,
  157. userName: this.vuex_member.name,
  158. guestType: this.guestTypeIndex
  159. }
  160. this.$http.addGuestAuthorize(params).then(res => {
  161. if (res.data.success) {
  162. uni.setStorageSync("isFlush", true);
  163. this.showModal = true,
  164. this.id = res.data.data.id,
  165. this.begin_date = res.data.data.beginDate,
  166. this.end_date = res.data.data.endDate
  167. } else {
  168. app.globalData.oneFailHint(res.data.msg);
  169. }
  170. });
  171. },
  172. //根据会员id获取我的房屋列表
  173. geRoomByMemberId: function() {
  174. let params = {
  175. id: getApp().globalData.member.id,
  176. residentialId: uni.getStorageSync('residentialId')
  177. }
  178. this.$http.getRoomByMemberId(params).then(res => {
  179. let records = res.data.data
  180. if (this.$isNotEmpty(records)) {
  181. records.forEach(item => {
  182. item.address =
  183. `${item.residentialName}-${item.buildingName}-${item.unitName}-${item.name}`
  184. })
  185. this.room_list = records
  186. this.selectRoomId = this.room_list[0].id
  187. this.selectRoomName = this.room_list[0].address
  188. app.globalData.room_list = records
  189. }
  190. });
  191. }
  192. }
  193. };
  194. </script>
  195. <style lang="scss">
  196. .edit_wrap {
  197. font-size: 30rpx;
  198. color: #333;
  199. }
  200. .form_group {
  201. margin: 0 20rpx;
  202. line-height: 60rpx;
  203. background: #fff;
  204. border-radius: 10rpx;
  205. padding: 20rpx;
  206. }
  207. .form_group input,
  208. .form_group picker {
  209. width: 100%;
  210. border-bottom: 1px solid #ddd;
  211. color: $base-btn-color;
  212. height: 60rpx;
  213. line-height: 60rpx;
  214. padding: 0rpx 20rpx;
  215. }
  216. .ar_picker_wrap picker {
  217. width: 100%;
  218. box-sizing: border-box;
  219. }
  220. .tui-picker-content picker {
  221. width: 260rpx;
  222. display: inline-block;
  223. padding: 0 10rpx;
  224. }
  225. .tui-picker-content .time_text {
  226. margin: 0 20rpx;
  227. }
  228. /*主容器*/
  229. .stepper {
  230. width: 214rpx;
  231. height: 60rpx;
  232. border: 2rpx solid #ddd;
  233. border-radius: 10rpx;
  234. background: #fff;
  235. margin-top: 10rpx;
  236. }
  237. /*加号和减号*/
  238. .stepper text {
  239. float: left;
  240. width: 70rpx;
  241. line-height: 52rpx;
  242. text-align: center;
  243. }
  244. /*数值*/
  245. .stepper input {
  246. width: 70rpx;
  247. height: 60rpx;
  248. float: left;
  249. margin: 0 auto;
  250. text-align: center;
  251. font-size: 12px;
  252. border: none;
  253. border-left: 1px solid #ddd;
  254. border-right: 1px solid #ddd;
  255. padding: 0;
  256. border-radius: 0;
  257. color: $base-btn-color;
  258. }
  259. /*普通样式*/
  260. .stepper .normal {
  261. color: black;
  262. }
  263. /*禁用样式*/
  264. .stepper .disable {
  265. color: #ccc;
  266. }
  267. .get_code {
  268. padding: 0rpx 60rpx;
  269. position: fixed;
  270. bottom: 20rpx;
  271. width: 100%;
  272. box-sizing: border-box;
  273. }
  274. .ar_book {
  275. background: $base-btn-color;
  276. font-size: 28rpx;
  277. color: #fff;
  278. border-radius: 10rpx;
  279. margin: 40rpx 0rpx 10rpx;
  280. padding: 0rpx 60rpx;
  281. }
  282. .show-btn {
  283. margin-top: 100rpx;
  284. color: #2c2;
  285. }
  286. .modal-mask {
  287. width: 100%;
  288. height: 100%;
  289. position: fixed;
  290. top: 0;
  291. left: 0;
  292. background: #000;
  293. opacity: 0.5;
  294. overflow: hidden;
  295. z-index: 9000;
  296. color: #fff;
  297. }
  298. .modal-dialog {
  299. width: 540rpx;
  300. overflow: hidden;
  301. position: fixed;
  302. top: 45%;
  303. left: 0;
  304. z-index: 9999;
  305. background: #f9f9f9;
  306. margin: -180rpx 105rpx;
  307. border-radius: 36rpx;
  308. }
  309. .modal-title {
  310. padding-top: 50rpx;
  311. font-size: 36rpx;
  312. color: #030303;
  313. text-align: center;
  314. }
  315. .modal-content {
  316. padding: 60rpx 0;
  317. }
  318. .modal-input {
  319. display: flex;
  320. font-size: 30rpx;
  321. }
  322. .password {
  323. width: 100%;
  324. height: 80rpx;
  325. font-size: 30rpx;
  326. line-height: 80rpx;
  327. padding: 0 20rpx;
  328. box-sizing: border-box;
  329. color: #606266;
  330. text-align: center;
  331. }
  332. input-holder {
  333. color: #666;
  334. font-size: 28rpx;
  335. }
  336. .modal-footer {
  337. display: flex;
  338. flex-direction: row;
  339. height: 86rpx;
  340. border-top: 1px solid #dedede;
  341. font-size: 34rpx;
  342. line-height: 86rpx;
  343. }
  344. .modal-footer button::after {
  345. border: none;
  346. }
  347. .modal-footer .btn-cancel {
  348. width: 50%;
  349. color: #2a7fff;
  350. text-align: center;
  351. border-right: 1px solid #dedede;
  352. border-radius: 0;
  353. }
  354. .modal-footer .btn-confirm {
  355. width: 50%;
  356. color: #666;
  357. text-align: center;
  358. }
  359. /* 密码有效期 */
  360. .itemBox {
  361. flex-flow: wrap;
  362. }
  363. .itemBox view {
  364. width: 30%;
  365. box-sizing: border-box;
  366. margin: 10rpx;
  367. }
  368. .itemBox view.active text {
  369. background: $base-btn-color;
  370. color: #fff;
  371. }
  372. .itemBox view text {
  373. text-align: center;
  374. width: 100%;
  375. background: #fff;
  376. color: $base-btn-color;
  377. font-size: 28rpx;
  378. display: inline-block;
  379. border: 2rpx solid $base-btn-color;
  380. border-radius: 40rpx;
  381. }
  382. </style>