applyAuthorisation.vue 8.5 KB

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