openPass.vue 10 KB

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