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">
  11. {{replaceLastTwoWords2(item.name)}}</view>
  12. <view class="item12">电源状态:<span>{{item.switchStatus?'开':'关'}}</span></view>
  13. </view>
  14. <view class="item2" >
  15. <span>关</span>
  16. <u-switch size="32" @change="switchBtnApi(item,$event)"
  17. v-model="item.switchStatus" inactive-color="#ff9900" ></u-switch >
  18. <span>开</span>
  19. </view>
  20. </view>
  21. <u-divider :isnone="meterListCk.length==0" v-if="!meterListCk.length"
  22. nonetext="暂无记录" border-color="rgba(119,119,119,1)">
  23. 已经到底了</u-divider>
  24. </view>
  25. <view class="bottom">
  26. <u-divider border-color=" rgba(119,119,119,1)">
  27. 温馨提示</u-divider>
  28. <view class="view">
  29. <img class="view1" src="@/assets/img/apply-look.png">
  30. <img class="view2" src="@/assets/img/apply-text.png">
  31. </view>
  32. </view>
  33. </view>
  34. <view v-if="!step">
  35. <u-navbar title="填写申请人信息" title-color="#101010" :is-back="false" >
  36. </u-navbar>
  37. <view class="main">
  38. <view class="item">
  39. <view class="title">
  40. 申请授权
  41. </view>
  42. <view class="value">
  43. {{title}}
  44. </view>
  45. </view>
  46. <view class="item" v-if="information.remark">
  47. <view class="title">
  48. 备注
  49. </view>
  50. <view class="value">
  51. {{information.remark}}
  52. </view>
  53. </view>
  54. <view class="item">
  55. <view class="title">
  56. 姓名<span>*</span>
  57. </view>
  58. <view class="value" v-if="!step3">
  59. <input type="text" v-model="name" placeholder="请填写姓名" />
  60. </view>
  61. <view class="value" v-if="step3">
  62. {{name}}
  63. </view>
  64. </view>
  65. <view class="item">
  66. <view class="title">
  67. 联系电话<span>*</span>
  68. </view>
  69. <view class="value" v-if="!step3">
  70. <input type="text" v-model="phone" placeholder="请填写手机号码" />
  71. </view>
  72. <view class="value" v-if="step3">
  73. {{phone}}
  74. </view>
  75. </view>
  76. <!-- <view class="item">
  77. <view class="title">
  78. <span></span> 备注
  79. </view>
  80. </view> -->
  81. <view class="item">
  82. <view class="valueInfo" style=" width: 100%;" >
  83. <span style=" color: #777777;font-size: 32rpx;" >备注信息</span>
  84. <textarea type="text" v-model="remark"
  85. style="background-color: #f5f5f5;height: 100rpx;width: 90%;padding: 20rpx;border-radius: 5px;"
  86. placeholder="请填写备注,便于管理员分配所需电表" /></textarea>
  87. </view>
  88. </view>
  89. </view>
  90. <button class="submit2" v-if="step2" >审批中</button>
  91. <!-- 提交 -->
  92. <button class="submit" v-else @click="submit" >提交</button>
  93. </view>
  94. <!-- 提交反馈 -->
  95. <u-modal v-model="show" :show-title="false" :show-cancel-button="true" cancel-text="关闭" :show-confirm-button="false" >
  96. <view class="modal">
  97. <view class="success-icon">
  98. <img src="@/assets/img/md-check_circle vRxbRvD@3x.png" alt="" />
  99. </view>
  100. <view class="success-text">
  101. 授权申请提交成功
  102. </view>
  103. <view class="wait">
  104. 请等待单位能源管理员审核通过
  105. </view>
  106. </view>
  107. </u-modal>
  108. </view>
  109. </template>
  110. <script>
  111. import * as API_energyManage from '@/apis/pagejs/energyManage.js'
  112. import * as API_user from '@/apis/pagejs/user.js'
  113. import * as API from '@/apis/pagejs/managementList.js'
  114. import {
  115. checkPhone
  116. } from '@/apis/utils'
  117. export default {
  118. data() {
  119. return {
  120. show:false,
  121. meterId:"",
  122. id:"",
  123. name:"",
  124. phone:"",
  125. title:"",
  126. step:false,
  127. step2:false,
  128. step3:false,
  129. meterList:[],
  130. regUser:{},
  131. remark:"",
  132. information:{},
  133. }
  134. },
  135. onLoad(op) {
  136. this.id=op.id
  137. this.getInformation()
  138. this.query()
  139. },
  140. computed:{
  141. meterListCk(){
  142. var sz=[]
  143. for(var i in this.meterList){
  144. var item=this.meterList[i]
  145. if(item.checked){
  146. sz.push(item)
  147. }
  148. }
  149. return sz
  150. }
  151. },
  152. methods: {
  153. query(){
  154. uni.showLoading({
  155. title: "加载中",
  156. mask: true,
  157. })
  158. API_user.findByOpenId({
  159. noerror:true,
  160. openId: this.carhelp.getOpenId(),
  161. }).then((response) => {
  162. if(response.result){
  163. this.step3=true
  164. var token = response ? response.data.token : '';
  165. this.carhelp.setToken(token);
  166. this.carhelp.setPersonInfo(response.data.regUser);
  167. this.carhelp.setPersonInfoPlus(response.data)
  168. this.regUser=response.data.regUser
  169. this.name=this.regUser.name
  170. this.phone=this.regUser.phone
  171. }
  172. }).catch(error => {
  173. uni.hideLoading();
  174. })
  175. },
  176. switchBtnApiMethod(node,key){
  177. uni.showLoading({
  178. title: "加载中",
  179. mask: true,
  180. })
  181. API_energyManage.remoteSwitch({
  182. meterId:node.id,
  183. enabled:key
  184. }).then((res) => {
  185. uni.hideLoading();
  186. node.switchStatus=key
  187. }).catch(error => {
  188. uni.showToast({
  189. title: error,
  190. icon: "none"
  191. })
  192. })
  193. },
  194. switchBtnApi(node,key){
  195. uni.showModal({
  196. confirmColor:`${key?'#3CC51F':'red'}`,
  197. confirmText:`${key?'开启':'关闭'}`,
  198. content: `确认是否要"${key?'开启':'关闭'}"${this.replaceLastTwoWords(node.name)}`, 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>