applyAuthorisation.vue 10 KB

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