auth-card.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <template>
  2. <view class="container">
  3. <view class="agentinfo-detail">
  4. <view class="detail_user">账户 {{ agentInfo.phone }} 是</view>
  5. <view class="detail_fixed">大卫博士授权{{ agentInfo.level_name }}</view>
  6. <view class="detail_fixed_info">
  7. <image src="../../static/index/my/level_bg.png" mode="widthFix" class="fixed_info_bg"></image>
  8. <view class="fixed_info_text">{{ agentInfo.level_name }}信息</view>
  9. </view>
  10. <view class="main">
  11. <view class="item">
  12. <view>类  型:</view>
  13. <view>{{ agentInfo.level_name }}</view>
  14. </view>
  15. <view class="item">
  16. <view>昵  称:</view>
  17. <view>{{ agentInfo.nickname }}</view>
  18. </view>
  19. <view class="item">
  20. <view>姓  名:</view>
  21. <view>{{ agentInfo.realname }}</view>
  22. </view>
  23. <!-- <view class="item">
  24. <view>身份证号:</view>
  25. <view>{{ showCradNum(num) }}</view>
  26. </view> -->
  27. <view class="item">
  28. <view>授权状态:</view>
  29. <!-- <view :class="agentInfo.status === 1 ? 'spec' : ''">{{ agentInfo.status === 1 ? '已授权' : '已过期' }}
  30. </view> -->
  31. <view class="spec">已授权</view>
  32. </view>
  33. </view>
  34. <!-- <view class="btnContainer" v-if="status === 1" @click="toSeeAuth">
  35. <p>查看授权书</p>
  36. </view> -->
  37. </view>
  38. <image src="../../static/index/my/chengnuo.png" class="chengnuo"></image>
  39. </view>
  40. </template>
  41. <script>
  42. import {
  43. judgeIosPermission, // 获取iOS设备上当前App是否有某项权限
  44. requestAndroidPermission, // 获取Android设备上当前App是否有某项权限
  45. } from '@/common/util/permission.js'
  46. import _share from '@/common/util/share.js'
  47. import {
  48. _API_Auth_Code,
  49. _API_Auth_Share
  50. } from '@/apis/user.js'
  51. export default {
  52. data() {
  53. return {
  54. title: '我的授权',
  55. drawOver: false,
  56. name: this.$store.state.userinfo.nickname,
  57. phone: this.$store.state.userinfo.mobile,
  58. canvasWidth: uni.upx2px(750),
  59. canvasHeight: uni.upx2px(1323),
  60. url: '',
  61. code: '',
  62. long: '',
  63. src: '',
  64. agentInfo: ''
  65. // y: '',
  66. // m: '',
  67. // d: ''
  68. }
  69. },
  70. onLoad({
  71. id
  72. }) {
  73. uni.showLoading({
  74. mask: true
  75. })
  76. _API_Auth_Code({
  77. id: id ? id : this.$store.state.userinfo.id
  78. }).then(res => {
  79. uni.hideLoading()
  80. if (res.code === 200) {
  81. let phone = res.data.phone
  82. phone = phone.substring(0, 3) + '****' + phone
  83. .substr(phone.length - 4)
  84. this.agentInfo = res.data
  85. this.agentInfo.phone = phone
  86. // 使用后端渲染的图片
  87. // this.src = res.data.url
  88. // 前端渲染
  89. // const can = document.getElementsByTagName('canvas')[0]
  90. // const ctx = can.getContext('2d')
  91. // const img = document.getElementsByTagName('img')[0]
  92. // const { windowWidth, windowHeight } = uni.getSystemInfoSync();
  93. // const regW = windowWidth / 375
  94. // const regH = windowHeight / 603
  95. // ctx.drawImage(img, 0, 0, windowWidth, windowHeight)
  96. // ctx.font="14px Arial";
  97. // ctx.fillText(res.data.realname, 170 * regW, 212 * regH)
  98. // ctx.font="14px Arial";
  99. // ctx.fillText(res.data.phone, 170 * regW , 240 * regH)
  100. // ctx.font="25px Arial";
  101. // ctx.fillText(res.data.level_name, 130 * regW , 310 * regH)
  102. // ctx.font="11px Arial";
  103. // ctx.fillText(res.data.code, 120 * regW, 365 * regH)
  104. // ctx.font="11px Arial";
  105. // const y1 = this.y = this.$options.filters.getYear(res.data.auth_startime)
  106. // const m1 = this.m = this.$options.filters.getMonth(res.data.auth_startime)
  107. // const d1 = this.d = this.$options.filters.getDate(res.data.auth_startime)
  108. // const y2 = this.y = this.$options.filters.getYear(res.data.auth_endtime)
  109. // const m2 = this.m = this.$options.filters.getMonth(res.data.auth_endtime)
  110. // const d2 = this.d = this.$options.filters.getDate(res.data.auth_endtime)
  111. // ctx.fillText(`${y1}年${m1}月${d1}日 - ${y2}年${m2}月${d2}日`, 120 * regW, 395 * regH)
  112. // this.src = can.toDataURL("image/png", 1)
  113. // alert(this.src)
  114. } else {
  115. uni.showModal({
  116. content: "暂未授权",
  117. showCancel: false
  118. }).then(() => {
  119. uni.navigateBack()
  120. })
  121. }
  122. })
  123. },
  124. onBackPress() { // 返回时收起分享
  125. if (uni._SHARE && uni._SHARE.isVisible()) {
  126. uni._MASK.hide()
  127. uni._SHARE.hide()
  128. return true
  129. }
  130. },
  131. methods: {
  132. previewImage() { //点击预览图片
  133. uni.showLoading({
  134. mask: true
  135. })
  136. uni.canvasToTempFilePath({
  137. canvasId: 'canvas'
  138. }).then(([, res]) => { //首先将 canvas 转化为一个图片,获得图片的临时路径
  139. uni.hideLoading()
  140. uni.previewImage({
  141. urls: [res.tempFilePath]
  142. })
  143. })
  144. },
  145. save() { // 点击保存图片
  146. if (plus.os.name == "iOS") { // 判断设备
  147. if (judgeIosPermission("photoLibrary")) {
  148. uni.showLoading({
  149. mask: true
  150. })
  151. uni.canvasToTempFilePath({
  152. canvasId: 'canvas'
  153. }).then(([, res]) => { //首先将 canvas 转化为一个图片,获得图片的临时路径
  154. uni.saveImageToPhotosAlbum({
  155. filePath: res.tempFilePath
  156. }).then(() => {
  157. uni.hideLoading()
  158. uni.toast('保存成功')
  159. })
  160. })
  161. } else {
  162. uni.toast('大卫博士需要获取访问相册的权限,以保证图片能够保存到您的手机相册')
  163. }
  164. } else {
  165. requestAndroidPermission('android.permission.WRITE_EXTERNAL_STORAGE').then(res => {
  166. if (res === 1) {
  167. uni.showLoading({
  168. mask: true
  169. })
  170. uni.canvasToTempFilePath({
  171. canvasId: 'canvas'
  172. }).then(([, res]) => { //首先将 canvas 转化为一个图片,获得图片的临时路径
  173. uni.saveImageToPhotosAlbum({
  174. filePath: res.tempFilePath
  175. }).then(() => {
  176. uni.hideLoading()
  177. uni.toast('保存成功')
  178. })
  179. })
  180. } else {
  181. this.$refs.ltm.modal('保存失败', ['大卫博士需要获取访问相册的权限,以保证图片能够保存到您的手机相册'], 'nocancel')
  182. }
  183. })
  184. }
  185. },
  186. share() { // 点击分享证书
  187. if (this.url) { // 如果证书已经上传到服务器,直接分享
  188. _share({
  189. type: 2,
  190. imageUrl: this.url
  191. })
  192. } else { // 如果服务器没有证书,先上传再分享
  193. uni.showLoading({
  194. mask: true
  195. })
  196. uni.canvasToTempFilePath({
  197. canvasId: 'canvas',
  198. quality: 0.5
  199. }).then(([, res]) => { //首先将 canvas 转化为一个图片,获得图片的临时路径
  200. plus.zip.compressImage({
  201. src: res.tempFilePath,
  202. dst: '_doc/a.jpg',
  203. overwrite: true,
  204. quality: 20
  205. }, e => {
  206. _API_Auth_Share({
  207. name: 'img',
  208. filePath: e.target
  209. }).then(res => {
  210. if (res.code == 200) {
  211. this.url = res.data.url
  212. _share({
  213. type: 2,
  214. imageUrl: this.url
  215. })
  216. }
  217. })
  218. })
  219. })
  220. }
  221. }
  222. }
  223. }
  224. </script>
  225. <style lang="scss">
  226. page {
  227. min-height: 100%;
  228. height: auto;
  229. display: flex;
  230. flex-direction: column;
  231. justify-content: flex-start;
  232. }
  233. .container {
  234. width: 100%;
  235. flex: 1;
  236. min-width: 0;
  237. // height: 100%;
  238. background-image: url('http://api.app.cliu.cc/public/uploads/select/bg1.png');
  239. background-size: 100% auto;
  240. background-repeat: repeat;
  241. background-color: #f2f2f2;
  242. background-position: 100% 0;
  243. position: relative;
  244. padding: 5vh 0 0 0;
  245. box-sizing: border-box;
  246. .agentinfo-detail {
  247. width: calc(100% - 60rpx);
  248. background-color: #fff;
  249. margin: 0 auto;
  250. // position: absolute;
  251. // left: 50%;
  252. // bottom: 0;
  253. // transform: translate(-50%, -234rpx);
  254. // z-index: 99;
  255. display: flex;
  256. flex-direction: column;
  257. align-items: center;
  258. padding: 40rpx 50rpx;
  259. box-sizing: border-box;
  260. border-radius: 24rpx;
  261. .detail_user {
  262. color: #333333;
  263. font-size: 28rpx;
  264. margin-bottom: 20rpx;
  265. }
  266. .detail_fixed {
  267. color: #F53C1E;
  268. font-size: 52rpx;
  269. margin-bottom: 30rpx;
  270. }
  271. .detail_fixed_info {
  272. width: 100%;
  273. position: relative;
  274. height: 40rpx;
  275. .fixed_info_bg {
  276. position: absolute;
  277. width: 486rpx;
  278. height: auto;
  279. left: 50%;
  280. top: 50%;
  281. transform: translate(-50%, -50%);
  282. }
  283. .fixed_info_text {
  284. position: absolute;
  285. left: 50%;
  286. top: 50%;
  287. transform: translate(-50%, -50%);
  288. color: #333333;
  289. font-size: 28rpx;
  290. }
  291. }
  292. .main {
  293. width: 100%;
  294. margin-bottom: 50rpx;
  295. .item {
  296. width: 100%;
  297. height: 84rpx;
  298. display: flex;
  299. align-items: center;
  300. justify-content: space-between;
  301. border-bottom: 1px solid #EEEEEE;
  302. color: #333333;
  303. font-size: 32rpx;
  304. .spec {
  305. color: #F53C1E !important;
  306. }
  307. }
  308. }
  309. .btnContainer {
  310. width: 100%;
  311. height: 96rpx;
  312. text-align: center;
  313. line-height: 96rpx;
  314. background: #F53C1E;
  315. border-radius: 8rpx;
  316. color: #FFFFFF;
  317. font-size: 32rpx;
  318. }
  319. }
  320. .chengnuo {
  321. display: block;
  322. width: 468rpx;
  323. height: 234rpx;
  324. margin: 5vh auto 15px auto;
  325. // position: absolute;
  326. // width: 348rpx;
  327. // height: 174rpx;
  328. // left: 50%;
  329. // bottom: 0px;
  330. // z-index: 98;
  331. // transform: translate(-50%, -40rpx);
  332. }
  333. }
  334. </style>