qrcode.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <app-layout>
  3. <view v-if="setting.cs_wechat_qrcode" class="dir-top-nowrap cross-center">
  4. <view class="cs-wechat">客服微信</view>
  5. <view class="cs-box dir-top-nowrap cross-center">
  6. <image class="box-grow-0" :src="setting.cs_wechat_qrcode" load-lazy></image>
  7. <view class="box-grow-0 cs-wechat-name" v-if="setting.cs_wechat">微信号:{{setting.cs_wechat}}</view>
  8. <view class="box-grow-0 dir-left-nowrap cross-center end">
  9. <view @click="save(setting.cs_wechat_qrcode)" class="btn">保存客服二维码图片</view>
  10. <view v-if="setting.cs_wechat" @click="copy" class="btn">复制客服微信号</view>
  11. </view>
  12. </view>
  13. </view>
  14. <view v-if="setting.cs_wechat_flock_qrcode" class="dir-top-nowrap cross-center bottom">
  15. <view class="cs-wechat">微信群</view>
  16. <view class="cs-box dir-top-nowrap cross-center">
  17. <image :src="setting.cs_wechat_flock_qrcode" class="box-grow-0" load-lazy></image>
  18. <view class="box-grow-0 dir-left-nowrap cross-center end">
  19. <view @click="save(setting.cs_wechat_flock_qrcode)" class="btn">保存群二维码图片</view>
  20. </view>
  21. </view>
  22. </view>
  23. </app-layout>
  24. </template>
  25. <script>
  26. export default {
  27. name: "qrcode",
  28. components: {},
  29. data() {
  30. return {
  31. setting: {},
  32. }
  33. },
  34. onLoad() { this.$commonLoad.onload();
  35. const self = this;
  36. self.$request({
  37. url: self.$api.lottery.setting,
  38. }).then(info => {
  39. if (info.code === 0) {
  40. self.setting = info.data.setting;
  41. }
  42. }).catch(e => {
  43. // 网络请求出错
  44. })
  45. },
  46. methods: {
  47. save(url) {
  48. const self = this;
  49. // #ifndef MP-ALIPAY
  50. uni.showLoading({title: `图片保存中`});
  51. uni.downloadFile({
  52. url,
  53. success: function (e) {
  54. uni.saveImageToPhotosAlbum({
  55. filePath: e.tempFilePath,
  56. success: function () {
  57. uni.showToast({title: '保存成功'});
  58. },
  59. fail: function (err) {
  60. if (err.errMsg) {
  61. uni.showModal({
  62. title: '提示',
  63. content: '您好,请先授权保存到相册权限',
  64. showCancel: false,
  65. success(res) {
  66. if (res.confirm) {
  67. uni.openSetting({
  68. success(settingdata) {
  69. if (settingdata.authSetting['scope.writePhotosAlbum']) {
  70. uni.saveImageToPhotosAlbum({
  71. filePath: e.tempFilePath,
  72. success: function () {
  73. uni.showToast({title: '保存成功'});
  74. },
  75. })
  76. } else {
  77. uni.showModal({
  78. title: '提示',
  79. content: '授权失败,请稍后重新获取',
  80. showCancel: false,
  81. })
  82. }
  83. }
  84. })
  85. }
  86. }
  87. })
  88. }
  89. },
  90. complete: function (e) {
  91. uni.hideLoading();
  92. }
  93. });
  94. },
  95. fail: function (e) {
  96. uni.showModal({
  97. title: '图片下载失败',
  98. content: e.errMsg,
  99. showCancel: false,
  100. });
  101. },
  102. complete: function (e) {
  103. uni.hideLoading();
  104. }
  105. });
  106. // #endif
  107. // #ifdef MP-ALIPAY
  108. my.showLoading({content: '图片保存中'});
  109. my.saveImage({
  110. url: url,
  111. showActionSheet: true,
  112. success: () => {
  113. uni.showToast({title: '保存成功'});
  114. },
  115. complete() {
  116. my.hideLoading();
  117. }
  118. })
  119. // #endif
  120. },
  121. copy() {
  122. this.$utils.uniCopy({
  123. data: this.setting.cs_wechat,
  124. success(){
  125. //#ifndef MP-WEIXIN
  126. uni.showToast({ title: '复制成功'});
  127. // #endif
  128. }
  129. });
  130. },
  131. }
  132. }
  133. </script>
  134. <style scoped lang="scss">
  135. .bottom {
  136. margin-bottom: #{40rpx};
  137. }
  138. .cs-wechat {
  139. height: #{80rpx};
  140. width: #{240rpx};
  141. text-align: center;
  142. line-height: #{80rpx};
  143. border: #{1rpx} dashed #999999;
  144. color: #353535;
  145. border-radius: #{16rpx};
  146. font-size: #{36rpx};
  147. margin-top: #{40rpx};
  148. background: #FFFFFF;
  149. margin-bottom: -#{40rpx};
  150. z-index: 1;
  151. }
  152. .cs-box {
  153. width: #{670rpx};
  154. border-radius: #{16rpx};
  155. border: #{1rpx} dashed #999999;
  156. background: #FFFFFF;
  157. }
  158. .cs-box image {
  159. margin-top: #{88rpx};
  160. height: #{360rpx};
  161. width: #{360rpx};
  162. display: block;
  163. }
  164. .cs-wechat-name {
  165. margin-top: #{32rpx};
  166. font-size: #{28rpx};
  167. color: #999999;
  168. }
  169. .end {
  170. margin-bottom: #{56rpx};
  171. margin-top: #{24rpx};
  172. }
  173. .end .btn:nth-child(2) {
  174. margin-left: #{20rpx};
  175. }
  176. .btn {
  177. text-align: center;
  178. height: #{64rpx};
  179. width: #{264rpx};
  180. line-height: #{64rpx};
  181. color: #ff4544;
  182. border-radius: #{32rpx};
  183. border: #{1px} solid #ff4544;
  184. font-size: #{24rpx};
  185. }
  186. </style>