applyAuthorisation.vue 9.5 KB

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