app-my-share.vue 8.3 KB

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