applyAuthorisation.vue 6.7 KB

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