openPass.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  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. // console.log("id:"+this.id+";doorNeedAudit="+this.doorNeedAudit+";memberId="+app.globalData.member.id);
  121. return {
  122. title: title,
  123. path: "/pages/guest/guest_form?id="+this.id+"&doorNeedAudit="+this.doorNeedAudit+"&memberId="+app.globalData.member.id,
  124. imageUrl: "http://139.9.103.171:1888/img/image/ps_bg.png"
  125. };
  126. },
  127. methods: {
  128. //选择房间
  129. roomChange: function (e) {
  130. this.selectRoomId=e[0].value
  131. this.selectRoomName=e[0].label
  132. },
  133. //访客类型
  134. guestTypethis: function (event) {
  135. //点击选中事件
  136. var thisindex = event.currentTarget.dataset.thisindex; //当前index
  137. this.setData({
  138. guestTypeIndex: thisindex
  139. });
  140. },
  141. //密码有效时间
  142. activethis: function (event) {
  143. //点击选中事件
  144. var thisindex = event.currentTarget.dataset.thisindex; //当前index
  145. this.setData({
  146. activeIndex: thisindex
  147. });
  148. },
  149. //关闭弹窗
  150. closeModal: function () {
  151. this.setData({
  152. showModal: false
  153. });
  154. },
  155. //获取开门密码
  156. getGuestAuthorize: function () {
  157. let that = this;
  158. let params = {};
  159. params['member_id'] = app.globalData.member.id;
  160. params['room_id'] = that.selectRoomId;
  161. params['guest_type'] = that.guestTypeIndex;
  162. let avalid_num = that.numArray[that.activeIndex]; //有效开始时间
  163. let begin_date = new Date();
  164. // begin_date.setMinutes(begin_date.getMinutes() - 30);
  165. params['begin_date'] = util.getTimestamp(begin_date); //有效结束时间
  166. let end_date = new Date(); //小时累加
  167. end_date.setHours(end_date.getHours() + avalid_num);
  168. params['end_date'] = util.getTimestamp(end_date); //有效次数
  169. console.log(that.params);
  170. let operation = 'guestAuthorize/getGuestAuthorize';
  171. app.globalData.postRequest(params, operation, function (res) {
  172. console.info("接口返回结果:" + res.data.result_msg); //获取成功
  173. if (res.data.result_code == 1) {
  174. uni.setStorageSync("isFlush", true);
  175. that.setData({
  176. //显示复制密码弹窗
  177. showModal: true,
  178. id: res.data.guestAuthorize.id,
  179. begin_date: util.formatTime(res.data.guestAuthorize.beginDate),
  180. end_date: util.formatTime(res.data.guestAuthorize.endDate)
  181. });
  182. } else {
  183. app.globalData.oneFailHint(res.data.result_msg);
  184. }
  185. });
  186. },
  187. //根据会员id获取我的房屋列表
  188. geRoomByMemberId: function () {
  189. let that = this;
  190. let params = {};
  191. params['member_id'] = app.globalData.member.id;
  192. let operation = 'estate/getRoomByMemberId';
  193. app.globalData.postRequest(params, operation, function (res) {
  194. console.info("获取成功" + res.data.result_msg); //获取成功
  195. if (res.data.result_code == 1) {
  196. let residentialId=uni.getStorageSync("residentialId")
  197. let room_list_new=[]
  198. res.data.list.forEach(item=>{
  199. if (item.residentialId==residentialId) {
  200. room_list_new.push(item)
  201. }
  202. })
  203. that.room_list=room_list_new
  204. that.selectRoomId=that.room_list[0].id
  205. app.globalData.room_list = res.data.list;
  206. }
  207. });
  208. }
  209. }
  210. };
  211. </script>
  212. <style lang="scss">
  213. .edit_wrap {
  214. font-size: 30rpx;
  215. color: #333;
  216. }
  217. .form_group {
  218. margin:0 20rpx;
  219. line-height: 60rpx;
  220. background: #fff;
  221. border-radius: 10rpx;
  222. padding: 20rpx;
  223. }
  224. .form_group input, .form_group picker {
  225. width: 100%;
  226. border-bottom: 1px solid #ddd;
  227. color: $base-btn-color;
  228. height: 60rpx;
  229. line-height: 60rpx;
  230. padding: 0rpx 20rpx;
  231. }
  232. .ar_picker_wrap picker {
  233. width: 100%;
  234. box-sizing: border-box;
  235. }
  236. .tui-picker-content picker {
  237. width: 260rpx;
  238. display: inline-block;
  239. padding: 0 10rpx;
  240. }
  241. .tui-picker-content .time_text {
  242. margin: 0 20rpx;
  243. }
  244. /*主容器*/
  245. .stepper {
  246. width: 214rpx;
  247. height: 60rpx;
  248. border: 2rpx solid #ddd;
  249. border-radius: 10rpx;
  250. background: #fff;
  251. margin-top: 10rpx;
  252. }
  253. /*加号和减号*/
  254. .stepper text {
  255. float: left;
  256. width: 70rpx;
  257. line-height: 52rpx;
  258. text-align: center;
  259. }
  260. /*数值*/
  261. .stepper input {
  262. width: 70rpx;
  263. height: 60rpx;
  264. float: left;
  265. margin: 0 auto;
  266. text-align: center;
  267. font-size: 12px;
  268. border: none;
  269. border-left: 1px solid #ddd;
  270. border-right: 1px solid #ddd;
  271. padding: 0;
  272. border-radius: 0;
  273. color: $base-btn-color;
  274. }
  275. /*普通样式*/
  276. .stepper .normal {
  277. color: black;
  278. }
  279. /*禁用样式*/
  280. .stepper .disable {
  281. color: #ccc;
  282. }
  283. .get_code {
  284. padding: 0rpx 60rpx;
  285. position: fixed;
  286. bottom: 20rpx;
  287. width: 100%;
  288. box-sizing: border-box;
  289. }
  290. .ar_book {
  291. background: $base-btn-color;
  292. font-size: 28rpx;
  293. color: #fff;
  294. border-radius: 10rpx;
  295. margin: 40rpx 0rpx 10rpx;
  296. padding: 0rpx 60rpx;
  297. }
  298. .show-btn {
  299. margin-top: 100rpx;
  300. color: #2c2;
  301. }
  302. .modal-mask {
  303. width: 100%;
  304. height: 100%;
  305. position: fixed;
  306. top: 0;
  307. left: 0;
  308. background: #000;
  309. opacity: 0.5;
  310. overflow: hidden;
  311. z-index: 9000;
  312. color: #fff;
  313. }
  314. .modal-dialog {
  315. width: 540rpx;
  316. overflow: hidden;
  317. position: fixed;
  318. top: 45%;
  319. left: 0;
  320. z-index: 9999;
  321. background: #f9f9f9;
  322. margin: -180rpx 105rpx;
  323. border-radius: 36rpx;
  324. }
  325. .modal-title {
  326. padding-top: 50rpx;
  327. font-size: 36rpx;
  328. color: #030303;
  329. text-align: center;
  330. }
  331. .modal-content {
  332. padding: 60rpx 0;
  333. }
  334. .modal-input {
  335. display: flex;
  336. font-size: 30rpx;
  337. }
  338. .password {
  339. width: 100%;
  340. height: 80rpx;
  341. font-size: 30rpx;
  342. line-height: 80rpx;
  343. padding: 0 20rpx;
  344. box-sizing: border-box;
  345. color: #606266;
  346. text-align: center;
  347. }
  348. input-holder {
  349. color: #666;
  350. font-size: 28rpx;
  351. }
  352. .modal-footer {
  353. display: flex;
  354. flex-direction: row;
  355. height: 86rpx;
  356. border-top: 1px solid #dedede;
  357. font-size: 34rpx;
  358. line-height: 86rpx;
  359. }
  360. .modal-footer button::after{
  361. border: none;
  362. }
  363. .modal-footer .btn-cancel {
  364. width: 50%;
  365. color: #2a7fff;
  366. text-align: center;
  367. border-right: 1px solid #dedede;
  368. border-radius: 0;
  369. }
  370. .modal-footer .btn-confirm {
  371. width: 50%;
  372. color: #666;
  373. text-align: center;
  374. }
  375. /* 密码有效期 */
  376. .itemBox {
  377. flex-flow: wrap;
  378. }
  379. .itemBox view {
  380. width: 30%;
  381. box-sizing: border-box;
  382. margin: 10rpx;
  383. }
  384. .itemBox view.active text{
  385. background: $base-btn-color;
  386. color: #fff;
  387. }
  388. .itemBox view text {
  389. text-align: center;
  390. width: 100%;
  391. background: #fff;
  392. color: $base-btn-color;
  393. font-size: 28rpx;
  394. display: inline-block;
  395. border: 2rpx solid $base-btn-color;
  396. border-radius: 40rpx;
  397. }
  398. </style>