Internship-position.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view class="flex-common-css iPhone-bottom box-border-box">
  3. <Nav title="实习岗位" leftColor="#fff" bgckgroundBox='transparent' titleColor="#fff"></Nav>
  4. <image class="bg" src="@/static/img/index/sxgw.png" mode=""></image>
  5. <image class="code-img" :src="codeImg" mode="aspectFit"></image>
  6. <!-- <image @click="saveImg" class="but-img" src="@/static/img/index/bcdxc.png" mode=""></image> -->
  7. </view>
  8. </template>
  9. <script>
  10. import {
  11. commonPracticeCode
  12. } from "@/api/common.js"
  13. export default {
  14. components: {},
  15. data() {
  16. return {
  17. codeImg: ''
  18. };
  19. },
  20. onLoad(data) {},
  21. mounted() {
  22. this.commonPracticeCode()
  23. },
  24. methods: {
  25. commonPracticeCode() {
  26. commonPracticeCode().then((res) => {
  27. if (res.code == 1) {
  28. this.codeImg = res.data.url
  29. }
  30. })
  31. },
  32. scrolltolower() {
  33. console.log('触底');
  34. },
  35. saveImg() {
  36. let that = this
  37. //获取授权列表,查看是否授权写入相册权限
  38. uni.getSetting({
  39. success(res) {
  40. if (!res.authSetting['scope.writePhotosAlbum']) {
  41. uni.authorize({
  42. scope: 'scope.writePhotosAlbum',
  43. success() {
  44. that.saveimgtoAlbum(that.codeImg)
  45. }
  46. })
  47. } else {
  48. that.saveimgtoAlbum(that.codeImg)
  49. }
  50. }
  51. })
  52. },
  53. saveimgtoAlbum(imgurl) {
  54. //图片保存到本地
  55. let that = this
  56. uni.downloadFile({
  57. url: imgurl,
  58. success: function(res) {
  59. uni.showLoading()
  60. uni.saveImageToPhotosAlbum({
  61. filePath: res.tempFilePath,
  62. success: function(data) {
  63. uni.hideLoading()
  64. uni.showToast({
  65. title: '保存成功',
  66. icon: 'success',
  67. duration: 1500
  68. })
  69. },
  70. fail: function(err) {
  71. uni.hideLoading()
  72. if (err.errMsg === "saveImageToPhotosAlbum:fail auth deny") {
  73. uni.openSetting({
  74. success(settingdata) {
  75. if (settingdata.authSetting[
  76. 'scope.writePhotosAlbum']) {
  77. uni.showToast({
  78. title: '您已授权成功,请重新保存',
  79. icon: 'success',
  80. duration: 1500
  81. })
  82. } else {
  83. uni.showToast({
  84. title: '尚未授权,无法保存',
  85. icon: 'none',
  86. duration: 1500
  87. })
  88. }
  89. }
  90. })
  91. }
  92. },
  93. complete(res) {
  94. console.log(res);
  95. }
  96. })
  97. }
  98. })
  99. }
  100. },
  101. }
  102. </script>
  103. <style lang="scss" scoped>
  104. .bg {
  105. width: 100%;
  106. height: 100vh;
  107. position: fixed;
  108. left: 0;
  109. top: 0;
  110. }
  111. .but-img {
  112. width: 670rpx;
  113. height: 88rpx;
  114. position: absolute;
  115. bottom: 56rpx;
  116. left: 40rpx;
  117. }
  118. .code-img {
  119. width: 340rpx;
  120. height: 340rpx;
  121. position: absolute;
  122. top: calc(50vh - (340rpx / 2));
  123. left: 204rpx;
  124. border-radius: 20rpx;
  125. }
  126. </style>