applyAuthorisation.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. <template>
  2. <view>
  3. <view v-if="step">
  4. <u-navbar :title="title" title-color="#101010" :is-back="false" >
  5. </u-navbar>
  6. <view class="main2">
  7. <view class="item" v-for="(item,i) in meterListCk"
  8. :key="i" >
  9. <view class="item1">
  10. <view class="item11">{{item.name}}</view>
  11. <view class="item12">电源状态:<span>{{item.switchStatus?'开':'关'}}</span></view>
  12. </view>
  13. <view class="item2" >
  14. <span>关</span>
  15. <u-switch size="32" @change="switchBtnApi(item,$event)"
  16. v-model="item.switchStatus" inactive-color="#ff9900" ></u-switch >
  17. <span>开</span>
  18. </view>
  19. </view>
  20. <u-divider :isnone="meterListCk.length==0" v-if="!meterListCk.length"
  21. nonetext="暂无记录" border-color="rgba(119,119,119,1)">
  22. 已经到底了</u-divider>
  23. </view>
  24. <view class="bottom">
  25. <u-divider border-color=" rgba(119,119,119,1)">
  26. 温馨提示</u-divider>
  27. <view class="view">
  28. <img class="view1" src="@/assets/img/apply-look.png">
  29. <img class="view2" src="@/assets/img/apply-text.png">
  30. </view>
  31. </view>
  32. </view>
  33. <view v-if="!step">
  34. <u-navbar title="填写申请人信息" title-color="#101010" :is-back="false" >
  35. </u-navbar>
  36. <view class="main">
  37. <view class="item">
  38. <view class="title">
  39. 申请授权
  40. </view>
  41. <view class="value">
  42. {{title}}
  43. </view>
  44. </view>
  45. <view class="item" v-if="information.remark">
  46. <view class="title">
  47. 备注
  48. </view>
  49. <view class="value">
  50. {{information.remark}}
  51. </view>
  52. </view>
  53. <view class="item">
  54. <view class="title">
  55. 姓名<span>*</span>
  56. </view>
  57. <view class="value" v-if="!step3">
  58. <input type="text" v-model="name" placeholder="请填写姓名" />
  59. </view>
  60. <view class="value" v-if="step3">
  61. {{name}}
  62. </view>
  63. </view>
  64. <view class="item">
  65. <view class="title">
  66. 联系电话<span>*</span>
  67. </view>
  68. <view class="value" v-if="!step3">
  69. <input type="text" v-model="phone" placeholder="请填写手机号码" />
  70. </view>
  71. <view class="value" v-if="step3">
  72. {{phone}}
  73. </view>
  74. </view>
  75. <!-- <view class="item">
  76. <view class="title">
  77. <span></span> 备注
  78. </view>
  79. </view> -->
  80. <view class="item">
  81. <view class="valueInfo" style=" width: 100%;" >
  82. <span style=" color: #777777;font-size: 32rpx;" >备注信息</span>
  83. <textarea type="text" v-model="remark"
  84. style="background-color: #f5f5f5;height: 100rpx;width: 90%;padding: 20rpx;border-radius: 5px;"
  85. placeholder="请填写备注,便于管理员分配所需电表" /></textarea>
  86. </view>
  87. </view>
  88. </view>
  89. <button class="submit2" v-if="step2" >审批中</button>
  90. <!-- 提交 -->
  91. <button class="submit" v-else @click="submit" >提交</button>
  92. </view>
  93. <!-- 提交反馈 -->
  94. <u-modal v-model="show" :show-title="false" :show-cancel-button="true" cancel-text="关闭" :show-confirm-button="false" >
  95. <view class="modal">
  96. <view class="success-icon">
  97. <img src="@/assets/img/md-check_circle vRxbRvD@3x.png" alt="" />
  98. </view>
  99. <view class="success-text">
  100. 授权申请提交成功
  101. </view>
  102. <view class="wait">
  103. 请等待单位能源管理员审核通过
  104. </view>
  105. </view>
  106. </u-modal>
  107. </view>
  108. </template>
  109. <script>
  110. import * as API_energyManage from '@/apis/pagejs/energyManage.js'
  111. import * as API_user from '@/apis/pagejs/user.js'
  112. import * as API from '@/apis/pagejs/managementList.js'
  113. import {
  114. checkPhone
  115. } from '@/apis/utils'
  116. export default {
  117. data() {
  118. return {
  119. show:false,
  120. meterId:"",
  121. id:"",
  122. name:"",
  123. phone:"",
  124. title:"",
  125. step:false,
  126. step2:false,
  127. step3:false,
  128. meterList:[],
  129. regUser:{},
  130. remark:"",
  131. information:{},
  132. }
  133. },
  134. onLoad(op) {
  135. this.id=op.id
  136. this.getInformation()
  137. this.query()
  138. },
  139. computed:{
  140. meterListCk(){
  141. var sz=[]
  142. for(var i in this.meterList){
  143. var item=this.meterList[i]
  144. if(item.checked){
  145. sz.push(item)
  146. }
  147. }
  148. return sz
  149. }
  150. },
  151. methods: {
  152. query(){
  153. uni.showLoading({
  154. title: "加载中",
  155. mask: true,
  156. })
  157. API_user.findByOpenId({
  158. noerror:true,
  159. openId: this.carhelp.getOpenId(),
  160. }).then((response) => {
  161. if(response.result){
  162. this.step3=true
  163. var token = response ? response.data.token : '';
  164. this.carhelp.setToken(token);
  165. this.carhelp.setPersonInfo(response.data.regUser);
  166. this.carhelp.setPersonInfoPlus(response.data)
  167. this.regUser=response.data.regUser
  168. this.name=this.regUser.name
  169. this.phone=this.regUser.phone
  170. }
  171. }).catch(error => {
  172. uni.hideLoading();
  173. })
  174. },
  175. switchBtnApiMethod(node,key){
  176. uni.showLoading({
  177. title: "加载中",
  178. mask: true,
  179. })
  180. API_energyManage.remoteSwitch({
  181. meterId:node.id,
  182. enabled:key
  183. }).then((res) => {
  184. uni.hideLoading();
  185. node.switchStatus=key
  186. }).catch(error => {
  187. uni.showToast({
  188. title: error,
  189. icon: "none"
  190. })
  191. })
  192. },
  193. switchBtnApi(node,key){
  194. uni.showModal({
  195. confirmColor:`${key?'#3CC51F':'red'}`,
  196. confirmText:`${key?'开启':'关闭'}`,
  197. content: `确认是否要"${key?'开启':'关闭'}"${node.name}`,
  198. title: "提示",
  199. success:res=> {
  200. if(res.confirm){
  201. //this.switchBtnApiMethod(node,key);
  202. }else{
  203. node.switchStatus=!key
  204. }
  205. }
  206. })
  207. console.log(node,key)
  208. },
  209. getInformation(){
  210. if(!this.carhelp.getOpenId()){
  211. uni.showToast({
  212. icon: "none",
  213. title: "未获取到OpenId,请使用微信扫码"
  214. })
  215. return
  216. }
  217. uni.showLoading({
  218. title: "加载中",
  219. mask: true,
  220. })
  221. API.information({
  222. id:this.id,
  223. openId:this.carhelp.getOpenId(),
  224. }).then((res) => {
  225. this.title=res.data.information.title
  226. this.information=res.data.information;
  227. var allCheck=res.data.allCheck
  228. uni.hideLoading();
  229. //this.show=true
  230. var info=res.data.applicationInfo;
  231. if(allCheck){
  232. this.step=true
  233. this.meterList=res.data.meterList
  234. var img=require('@/assets/img/controlCover.png')
  235. var s='background:url('+img+') center fixed;background-size:cover;';
  236. console.log(s)
  237. document.getElementsByTagName("uni-page")[0].style=s
  238. }
  239. if(info&&info.status==0){
  240. this.step2=true
  241. }
  242. }).catch(error => {
  243. uni.showToast({
  244. title: error,
  245. icon: "none"
  246. })
  247. })
  248. },
  249. submit(){
  250. if(!this.carhelp.getOpenId()){
  251. uni.showToast({
  252. icon: "none",
  253. title: "未获取到OpenId,请使用微信扫码"
  254. })
  255. return
  256. }
  257. if(!this.name.length){
  258. uni.showToast({
  259. icon: "none",
  260. title: "请输入姓名"
  261. })
  262. return
  263. }
  264. var checkPhoneResult = checkPhone(this.phone);
  265. if (checkPhoneResult !== true) {
  266. uni.showToast({
  267. icon: "none",
  268. title: checkPhoneResult,
  269. })
  270. return;
  271. }
  272. uni.showLoading({
  273. title: "加载中",
  274. mask: true,
  275. })
  276. API.apply({
  277. id:this.id,
  278. name:this.name,
  279. phone:this.phone,
  280. remark:this.remark,
  281. openId:this.carhelp.getOpenId(),
  282. }).then((res) => {
  283. uni.hideLoading();
  284. if(res.result){
  285. this.show=true
  286. }
  287. this.getInformation()
  288. }).catch(error => {
  289. uni.showToast({
  290. title: error,
  291. icon: "none"
  292. })
  293. })
  294. }
  295. }
  296. }
  297. </script>
  298. <style lang="scss" scoped>
  299. page{
  300. //background: url('@/assets/img/controlCover.png') center fixed ;
  301. //background-size:cover;
  302. }
  303. .main2{
  304. margin: 24rpx 0;
  305. padding-bottom: 300rpx;
  306. .item{
  307. margin: 32rpx ;
  308. padding: 32rpx ;
  309. background-color: #fff;
  310. border-radius: 15px;
  311. display: flex;
  312. align-items: center;
  313. justify-content: space-between;
  314. .item11{
  315. font-size: 32rpx;
  316. color: rgba(51,51,51,1);
  317. font-weight: bold;
  318. }
  319. .item12{
  320. font-size: 24rpx;
  321. color:#777777 ;
  322. span{
  323. font-weight: bold;
  324. color: rgba(51,51,51,1);
  325. }
  326. }
  327. .item2{
  328. display: flex; align-items: center;
  329. }
  330. }
  331. }
  332. .main{
  333. margin: 24rpx 0;
  334. background-color: #fff;
  335. .item{
  336. padding: 24rpx 32rpx;
  337. display: flex;
  338. align-items: center;
  339. border-bottom: 1px solid rgba(221,221,221,1);
  340. .title{
  341. width: 30%;
  342. color: #777777;
  343. font-size: 32rpx;
  344. span{
  345. color: #EE3138;
  346. }
  347. }
  348. .value{
  349. img{
  350. width: 80rpx;
  351. }
  352. .uni-input-placeholder{
  353. color: rgba(204,204,204,1);;
  354. }
  355. }
  356. .icon{
  357. margin-left: auto;
  358. }
  359. }
  360. .item:last-of-type{
  361. border: none;
  362. }
  363. }
  364. // 提交
  365. .submit{
  366. background-color: rgba(22,119,255,1);
  367. color: rgba(255,255,255,1);
  368. margin: 0 32rpx;
  369. border-radius: 50px;
  370. }
  371. // 提交
  372. .submit2{
  373. background-color: #777777;
  374. color: rgba(255,255,255,1);
  375. margin: 0 32rpx;
  376. border-radius: 50px;
  377. }
  378. // 提交反馈
  379. .modal{
  380. text-align: center;
  381. .success-icon{
  382. margin-top: 24rpx;
  383. img{
  384. width: 132rpx;
  385. height: 132rpx;
  386. }
  387. }
  388. .success-text{
  389. color: rgba(16,16,16,1);
  390. font-size: 36rpx;
  391. margin-top: 16rpx;
  392. font-weight: bold;
  393. }
  394. .wait{
  395. margin-top: 10rpx;
  396. margin-bottom: 48rpx;
  397. }
  398. }
  399. .bottom{
  400. position: fixed;
  401. left: 0;
  402. right: 0;
  403. bottom: 0;
  404. padding: 20rpx 32rpx;
  405. .view{
  406. background-color: #fff;
  407. border-radius: 12px;
  408. background: linear-gradient(180deg, rgba(24,90,198,1) 0%,rgba(22,119,255,1) 100%);
  409. margin: 32rpx;
  410. padding: 24rpx 0;
  411. white-space: pre;
  412. display: flex;
  413. align-items: flex-end;
  414. justify-content: center;
  415. }
  416. .view1{
  417. height: 80rpx;
  418. }
  419. .view2{
  420. height: 56rpx;
  421. }
  422. }
  423. </style>