环卫车小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
2.4 KiB

10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
  1. <template>
  2. <view class="se-p-60">
  3. <view class="se-p-40 se-flex se-bgc-white se-br-20 se-bs se-flex-v-sa">
  4. <text class="se-pb-50 se-pt-100">邀请好友</text>
  5. <image class="se-a-300 se-br-20" :src="qrcode" mode=""></image>
  6. <!-- <text class="se-pt-50 se-pb-80">邀请码{{shareId}} </text> -->
  7. <!-- 邀请码TKAFGED -->
  8. </view>
  9. <view class="se-px-100 se-pt-80 se-fs-20 se-flex">
  10. <view @click="onSubmit"
  11. class="se-mx-10 se-flex-1 se-br-40 se-flex-h-c se-h-80 se-lh-80 se-ta-c se-fs-28 se-c-white se-bgc-green">
  12. <text>保存到本地</text>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import { getInviteCode } from "@/common/api.js"
  19. export default {
  20. data() {
  21. return {
  22. qrcode:"",
  23. shareId:""
  24. }
  25. },
  26. watch: {
  27. },
  28. onLoad(options) {
  29. this.onInviteCode()
  30. },
  31. methods: {
  32. onInviteCode(){
  33. let that = this
  34. let params={}
  35. getInviteCode(params).then(response=>{
  36. console.info("getInviteCode",response)
  37. that.qrcode = response.result.url
  38. that.shareId = response.result.shareId
  39. }).catch(error=>{
  40. })
  41. },
  42. onSubmit(){
  43. const url = this.qrcode;
  44. // 先下载网络图片到本地
  45. uni.downloadFile({
  46. url, // 网络图片地址
  47. success: (res) => {
  48. if (res.statusCode === 200) {
  49. // 下载成功,调用保存图片接口
  50. uni.saveImageToPhotosAlbum({
  51. filePath: res.tempFilePath, // 本地图片路径
  52. success: () => {
  53. uni.showToast({
  54. title: '图片保存成功',
  55. icon: 'success',
  56. });
  57. },
  58. fail: (err) => {
  59. if (err.errMsg.includes('auth')) {
  60. // 如果用户没有授权,提示并引导用户授权
  61. uni.showModal({
  62. title: '授权提示',
  63. content: '需要授权保存图片到相册,是否前往设置授权?',
  64. success: (res) => {
  65. if (res.confirm) {
  66. uni.openSetting();
  67. }
  68. },
  69. });
  70. } else {
  71. uni.showToast({
  72. title: '保存失败',
  73. icon: 'none',
  74. });
  75. }
  76. },
  77. });
  78. } else {
  79. uni.showToast({
  80. title: '图片下载失败',
  81. icon: 'none',
  82. });
  83. }
  84. },
  85. fail: () => {
  86. uni.showToast({
  87. title: '图片下载失败',
  88. icon: 'none',
  89. });
  90. },
  91. });
  92. },
  93. },
  94. onReady() {
  95. },
  96. }
  97. </script>
  98. <style>
  99. page {
  100. background-color: #f5f5f5;
  101. }
  102. </style>