authorizedQRCode.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <view>
  3. <u-navbar title="授权二维码" title-color="#101010">
  4. </u-navbar>
  5. <u-picker v-model="show" mode="selector"
  6. :default-selector="[defaultIndex]"
  7. :range="informationList" range-key="title"
  8. @confirm="confirm"></u-picker>
  9. <u-modal v-model="openModalBl" @confirm="confirmPhone" confirm-text="拨打电话" confirm-color="#606266"
  10. :show-cancel-button="true" ref="uModal" :asyncClose="true" :title="userInfo.name" :content="userInfo.phone"
  11. ></u-modal>
  12. <view class="main">
  13. <view class="company">
  14. {{companyInfo.name}}
  15. </view>
  16. <view class="energy-meter" v-if="informationList.length==1">
  17. {{information.title}}
  18. </view>
  19. <view class="energy-meter" v-else @click="show=true">
  20. {{information.title}}<u-icon name="arrow-down"></u-icon>
  21. </view>
  22. <!-- 个人信息 -->
  23. <view class="infos">
  24. <!-- <view class="photo">
  25. <img src="@/assets/img/PEokWS2@3x.png" alt="" />
  26. </view> -->
  27. <view class="details">
  28. <view class="name">
  29. {{userInfo.name}}
  30. </view>
  31. <view class="tel">
  32. {{userInfo.phone}}
  33. </view>
  34. </view>
  35. <view class="dial" @click="openModalBl=true" >
  36. <img src="@/assets/img/antOutline-phone 1.svg" alt="" />
  37. </view>
  38. </view>
  39. <!-- 二维码 -->
  40. <view class="qr-code">
  41. <view class="title">
  42. 扫描下方的二维码申请授权
  43. </view>
  44. <view class="win">
  45. <view class="border-corner left-top"></view>
  46. <view class="border-corner right-top"></view>
  47. <view class="border-corner left-bottom"></view>
  48. <view class="border-corner right-bottom"></view>
  49. <view class="code-box">
  50. <img id="qrcode2" :src="qrCodeImg">
  51. <img id="qrcode" style="display: none;">
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. import * as API from '@/apis/pagejs/managementList.js'
  60. import {
  61. convertCanvasToImage,
  62. substrMb
  63. } from '@/apis/utils'
  64. import QRCode from 'qrcodejs2'
  65. export default {
  66. data() {
  67. return {
  68. openModalBl: false,
  69. qrCodeImg: "",
  70. informationList: [],
  71. information: {},
  72. defaultIndex: 0,
  73. companyInfo:{},
  74. userInfo:{},
  75. show:false,
  76. }
  77. },
  78. onReady() {
  79. this.userInfo =this.carhelp.getPersonInfo();
  80. this.companyInfo =this.carhelp.getPersonInfoPlus().companyInfo;
  81. this.getInformationList()
  82. },
  83. methods: {
  84. confirmPhone() {
  85. this.openModalBl = false;
  86. uni.makePhoneCall({
  87. phoneNumber: this.userInfo.phone //仅为示例
  88. });
  89. },
  90. confirm(e){
  91. console.log(e)
  92. this.defaultIndex=e[0]
  93. this.information = this.informationList[e[0]]
  94. this.qrCodeImgMethod()
  95. },
  96. qrCodeImgMethod() {
  97. var url=window.location.href.split("/#")[0]
  98. var joinUrl = url+"/#/pages/managementList/applyAuthorisation?id="+this.information.id
  99. let qrcode = new QRCode('qrcode', {
  100. width: 200,
  101. height: 200,
  102. text: joinUrl,
  103. correctLevel: QRCode.CorrectLevel.M,
  104. })
  105. var canvas = document.getElementsByTagName('canvas')[0];
  106. this.qrCodeImg = convertCanvasToImage(canvas);
  107. },
  108. //授权二维码
  109. getInformationList() {
  110. uni.showLoading({
  111. title: "加载中",
  112. mask: true,
  113. })
  114. API.informationList().then((res) => {
  115. uni.hideLoading();
  116. this.informationList = res.data.informationList;
  117. console.log(this.informationList)
  118. if (this.informationList.length) {
  119. this.information = this.informationList[0]
  120. this.qrCodeImgMethod()
  121. }else{
  122. uni.showModal({
  123. title:"提示",
  124. content:"未生成二维码,请联系管理员",
  125. showCancel:false,
  126. success: (res) => {
  127. uni.navigateBack()
  128. }
  129. })
  130. }
  131. }).catch(error => {
  132. uni.showToast({
  133. title: error,
  134. icon: "none"
  135. })
  136. })
  137. },
  138. }
  139. }
  140. </script>
  141. <style>
  142. page {
  143. background-color: rgba(94, 161, 255, 1);
  144. }
  145. </style>
  146. <style lang="scss" scoped>
  147. .main {
  148. margin: 48rpx;
  149. padding: 48rpx 0rpx;
  150. background-color: #fff;
  151. box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.39);
  152. border-radius: 20px;
  153. .company {
  154. width: 344rpx;
  155. height: 72rpx;
  156. line-height: 72rpx;
  157. border-radius: 28px;
  158. background-color: rgba(83, 150, 255, 1);
  159. color: rgba(255, 255, 255, 1);
  160. font-size: 36rpx;
  161. text-align: center;
  162. margin: auto;
  163. }
  164. .energy-meter {
  165. color: rgb(16, 16, 16);
  166. font-size: 32rpx;
  167. margin-top: 20rpx;
  168. text-align: center;
  169. font-weight: bold;
  170. }
  171. .infos {
  172. display: flex;
  173. align-items: c;
  174. margin-top: 48rpx;
  175. padding: 48rpx 80rpx;
  176. border: 1px solid rgba(244, 244, 244, 1);
  177. .photo {
  178. img {
  179. width: 80rpx;
  180. height: 80rpx;
  181. border-radius: 50px;
  182. }
  183. }
  184. .details {
  185. margin-left: 16rpx;
  186. .name {
  187. color: rgba(51, 51, 51, 1);
  188. font-size: 32rpx;
  189. display: flex;
  190. align-items: center;
  191. span {
  192. display: inline-block;
  193. width: 84px;
  194. height: 16px;
  195. border-radius: 4px;
  196. border: 1px solid rgba(187, 190, 194, 1);
  197. margin-left: 8rpx;
  198. }
  199. }
  200. .tel {
  201. color: rgba(119, 119, 119, 1);
  202. font-size: 24rpx;
  203. margin-top: 4rpx;
  204. }
  205. }
  206. .dial {
  207. width: 64rpx;
  208. height: 64rpx;
  209. background-color: rgba(22, 119, 255, 1);
  210. border-radius: 50px;
  211. display: flex;
  212. align-items: center;
  213. justify-content: center;
  214. margin-left: auto;
  215. img {
  216. width: 40rpx;
  217. height: 40rpx;
  218. }
  219. }
  220. }
  221. }
  222. // 二维码
  223. .qr-code {
  224. padding: 48rpx 0rpx;
  225. text-align: center;
  226. .title {
  227. color: rgb(16, 16, 16);
  228. font-size: 32rpx;
  229. }
  230. .code-box {
  231. width: 400rpx;
  232. height: 400rpx;
  233. border: 1px solid rgb(153, 204, 255);
  234. border-radius: 4px;
  235. img {
  236. width: 400rpx;
  237. height: 400rpx;
  238. }
  239. }
  240. .win {
  241. margin-top: 32rpx;
  242. padding: 30rpx;
  243. position: relative;
  244. display: inline-block;
  245. }
  246. .border-corner {
  247. z-index: 900;
  248. position: absolute;
  249. width: 70rpx;
  250. height: 70rpx;
  251. background: rgba(0, 0, 0, 0);
  252. border: 4px solid #5396FF;
  253. }
  254. .left-top {
  255. top: 0;
  256. left: 0;
  257. border-right: none;
  258. border-bottom: none;
  259. border-top-left-radius: 4px;
  260. }
  261. .right-top {
  262. top: 0;
  263. right: 0;
  264. border-left: none;
  265. border-bottom: none;
  266. border-top-right-radius: 4px;
  267. }
  268. .left-bottom {
  269. bottom: 0;
  270. left: 0;
  271. border-right: none;
  272. border-top: none;
  273. border-bottom-left-radius: 4px;
  274. }
  275. .right-bottom {
  276. bottom: 0;
  277. right: 0;
  278. border-left: none;
  279. border-top: none;
  280. border-bottom-right-radius: 4px;
  281. }
  282. }
  283. </style>