app-my-share.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <view class="app-my-share" v-if="shareInfo.parent_id" :style="{backgroundColor: newData.background}">
  3. <view class="share-info">
  4. <view class="headimg">
  5. <image :src="shareInfo.parent_headimg"></image>
  6. </view>
  7. <text class="nickname" :style="{color:newData.color}">{{shareInfo.parent_name}}为您服务</text>
  8. <view class="contact" @click="showQrCode" :style="{borderColor:newData.color,color:newData.color}">
  9. <image src="../../../static/image/icon/wechat-white.png"></image> 联系
  10. </view>
  11. </view>
  12. <view class="show-qrcode" v-if="showQrCodeStatus">
  13. <div class="info">
  14. <view class="close" @click="showQrCode">
  15. <image src="../../../static/image/icon/invalid.png"></image>
  16. </view>
  17. <view class="share">
  18. <view class="headimg">
  19. <image :src="shareInfo.parent_headimg"></image>
  20. </view>
  21. <view class="nickname">
  22. <view>{{shareInfo.parent_name}}</view>
  23. <view class="desc">加我微信,随时为您服务</view>
  24. </view>
  25. </view>
  26. <image class="qrcode" :src="shareInfo.parent_qr_code"></image>
  27. <view class="saoyisao">扫一扫上面的二维码图案,加我微信</view>
  28. </div>
  29. <view class="save-btn" @click="saveImg">保存二维码</view>
  30. </view>
  31. <view class="placeholder"></view>
  32. </view>
  33. </template>
  34. <script>
  35. import {mapState, mapGetters} from 'vuex';
  36. export default {
  37. name: "app-my-share",
  38. props:{
  39. shareInfo:{
  40. type: Object,
  41. default(){
  42. return {
  43. }
  44. }
  45. },
  46. value: {
  47. type: Object,
  48. default: function() {
  49. return {
  50. background: `#efeff4`,
  51. color: '#ffffff',
  52. }
  53. }
  54. },
  55. homePages: {
  56. type: Object|Array,
  57. default() {
  58. return {};
  59. }
  60. },
  61. },
  62. data(){
  63. return {
  64. showQrCodeStatus: false,
  65. }
  66. },
  67. methods: {
  68. showQrCode(){
  69. console.log(this.homePages)
  70. this.showQrCodeStatus = !this.showQrCodeStatus;
  71. },
  72. saveImg(){
  73. uni.downloadFile({
  74. url: this.shareInfo.qrcode,
  75. success: (res) =>{
  76. if (res.statusCode === 200){
  77. uni.saveImageToPhotosAlbum({
  78. filePath: res.tempFilePath,
  79. success: function() {
  80. uni.showToast({
  81. title: "保存成功",
  82. icon: "none"
  83. });
  84. },
  85. fail: function() {
  86. uni.showToast({
  87. title: "保存失败",
  88. icon: "none"
  89. });
  90. }
  91. });
  92. }
  93. }
  94. });
  95. }
  96. },
  97. onLoad(){
  98. },
  99. computed: {
  100. ...mapState('mallConfig', {
  101. setting: state => state.mall.setting
  102. }),
  103. ...mapGetters('mallConfig', {
  104. getTheme: 'getTheme',
  105. }),
  106. newData() {
  107. let value = this.value;
  108. if (typeof this.homePages.navs !== "undefined") {
  109. this.homePages.navs.forEach(item => {
  110. item.template.data.forEach(temp => {
  111. if(temp.id === 'search'){
  112. value = temp.data;
  113. }
  114. })
  115. })
  116. }
  117. return value;
  118. },
  119. },
  120. }
  121. </script>
  122. <style scoped lang="scss">
  123. .app-my-share{
  124. width: 100%;
  125. height: #{124rpx};
  126. z-index: 9999999;
  127. background: #ffffff;
  128. font-size: #{26rpx};
  129. padding: 40rpx #{30rpx} 0;
  130. .share-info{
  131. display: flex;
  132. align-items: center;
  133. height: 100%;
  134. .headimg{
  135. border-radius: 50%;
  136. width: #{50rpx};
  137. height: #{50rpx};
  138. overflow: hidden;
  139. margin-right: #{10rpx};
  140. image{
  141. width: 100%;
  142. height: 100%;
  143. }
  144. }
  145. .contact{
  146. border: #{1rpx} solid #ccc;
  147. border-radius: #{20rpx};
  148. padding: #{2rpx} #{15rpx};
  149. display: flex;
  150. align-items: center;
  151. margin-left: #{10rpx};
  152. image{
  153. width: #{30rpx};
  154. height: #{30rpx};
  155. margin-right: #{10rpx};
  156. }
  157. }
  158. }
  159. .show-qrcode{
  160. position: fixed;
  161. width: 100%;
  162. height: 100%;
  163. left: 0;
  164. top: 0;
  165. background: rgba(0,0,0,.3);
  166. padding-top: #{150rpx};
  167. display: flex;
  168. flex-direction: column;
  169. align-items: center;
  170. z-index: 999999999;
  171. image{
  172. height: 100%;
  173. width: 100%;
  174. }
  175. .info{
  176. background: #ffffff;
  177. padding: #{60rpx} #{70rpx};
  178. border-radius: #{30rpx};
  179. .close{
  180. float: right;
  181. width: #{40rpx};
  182. height: #{40rpx};
  183. position: relative;
  184. top: -30rpx;
  185. right: -30rpx;
  186. }
  187. .share{
  188. display: flex;
  189. align-items: center;
  190. margin-top: #{30rpx};
  191. .headimg{
  192. width: #{80rpx};
  193. height: #{80rpx};
  194. border-radius: 50%;
  195. overflow: hidden;
  196. }
  197. .nickname{
  198. display: flex;
  199. flex-direction: column;
  200. margin-left: #{15rpx};
  201. .desc{
  202. font-size: #{20rpx};
  203. color: #888888;
  204. }
  205. }
  206. }
  207. .qrcode{
  208. width: #{450rpx};
  209. height: #{450rpx};
  210. }
  211. .saoyisao{
  212. color: #888888;
  213. text-align: center;
  214. font-size: #{20rpx};
  215. }
  216. }
  217. .save-btn{
  218. background: #FE3666;
  219. color: #ffffff;
  220. font-size: #{28rpx};
  221. margin-top: #{40rpx};
  222. padding: #{20rpx} #{100rpx};
  223. border-radius: #{30rpx};
  224. }
  225. }
  226. }
  227. </style>