index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <view>
  3. <u-navbar title="分享" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
  4. <view class="flex invitation">
  5. <view class="flex invitation-user">
  6. <image src="../../static/public/share_bg.png" mode="aspectFit"></image>
  7. <view class="title">盲票</view>
  8. <image class="avatar" :src="avatar" mode=""></image>
  9. </view>
  10. <view class="invitation-name">{{ userInfo.nickName }}</view>
  11. <view class="invitation-name-tip">邀请您一起来刮盲票</view>
  12. <view class="flex invitation-code">
  13. <image :src="codeUrl" mode="aspectFill"></image>
  14. </view>
  15. <view class="invitation-code-tip">长按识别二维码</view>
  16. <view class="invitation-bottom-tip">盲票,玩的就是有趣</view>
  17. </view>
  18. <view class="flex btn">
  19. <button type="default" open-type="share">分享链接给好友</button>
  20. <button type="default" @click="saveImg">保存海报</button>
  21. </view>
  22. <share-code ref="shareCode" :posterData.sync="posterData" />
  23. </view>
  24. </template>
  25. <script>
  26. import env from '../../config/env.js'
  27. import $http from '@/utils/request.js'
  28. import ShareCode from "../../components/share-code/share-code.vue"
  29. export default {
  30. components: {
  31. ShareCode
  32. },
  33. data() {
  34. return {
  35. codeUrl: '',
  36. userInfo: {},
  37. avatar: '',
  38. boxId: '',
  39. // 图片数据
  40. posterData: {
  41. poster: {
  42. //根据屏幕大小自动生成图片背景大小
  43. url: "https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/mp.png", //图片地址
  44. r: 15, //圆角半径
  45. w: 340, //图片宽度
  46. h: 447, //图片高度
  47. p: 20 //图片内边距padding
  48. },
  49. mainImg: {
  50. // 头像
  51. url: "", //图片地址
  52. r: 33, //圆角半径
  53. w: 66, //宽度
  54. h: 66, //高度
  55. mt: 40
  56. },
  57. title: {
  58. // 昵称
  59. text: "", //文本
  60. fontSize: 26, //字体大小
  61. color: "#4F4F4F", //颜色
  62. lineHeight: 37, //行高#4F4F4F 100%
  63. mt: 30, //margin-top
  64. w: 300,
  65. align: "center"
  66. },
  67. codeImg: {
  68. // 小程序码
  69. url: "", //图片地址
  70. w: 124, //宽度
  71. h: 124, //高度
  72. mt: 20, //margin-top
  73. r: 62, //圆角半径
  74. mt: 55
  75. },
  76. tips: [
  77. ]
  78. }
  79. };
  80. },
  81. onLoad(options) {
  82. this.boxId = options.boxId
  83. },
  84. onShow() {
  85. this.getUrl()
  86. this.getBaseInfo()
  87. },
  88. methods: {
  89. getBaseInfo() {
  90. uni.showLoading({
  91. title: '加载中'
  92. });
  93. $http.post('/api/v1/mp/user/getLoginUserinfo', {}).then(res => {
  94. uni.hideLoading();
  95. if (res.code == 0) {
  96. this.userInfo = res.data
  97. this.avatar = this.posterData.mainImg.url = env.filePublic + res.data.avatar
  98. this.posterData.title.text = res.data.nickName
  99. }
  100. }).catch(() => {
  101. uni.hideLoading();
  102. })
  103. },
  104. getUrl() {
  105. $http.post('/api/v1/mp/user/share/code/generate', {
  106. boxId: this.boxId,
  107. type: "1"
  108. }).then(res => {
  109. this.codeUrl = this.posterData.codeImg.url = env.filePublic + res.data
  110. })
  111. },
  112. saveImg() {
  113. this.$refs.shareCode.posterShow()
  114. },
  115. },
  116. onShareAppMessage(res) {
  117. return {
  118. title: '分享盲票',
  119. path: `/pages/ticketBox/detail?boxId=${ this.boxId }&userId=${ this.userInfo.userId }&type=1`,
  120. type: 2,
  121. }
  122. }
  123. }
  124. </script>
  125. <style lang="scss" scoped>
  126. .invitation {
  127. flex-direction: column;
  128. margin: 50rpx 30rpx;
  129. padding: 0 0 80rpx;
  130. border: 1px solid rgba(236, 236, 236, 100);
  131. border-radius: 20rpx;
  132. background-color: #FFFFFF;
  133. &-user {
  134. position: relative;
  135. width: 100%;
  136. margin-bottom: 80rpx;
  137. image {
  138. width: 100%;
  139. height: 188rpx;
  140. border-top-left-radius: 20rpx;
  141. border-top-right-radius: 20rpx;
  142. }
  143. .title {
  144. position: absolute;
  145. font-size: 52rpx;
  146. color: #FFFFFF;
  147. top: 20rpx;
  148. }
  149. .avatar {
  150. position: absolute;
  151. width: 134rpx;
  152. height: 134rpx;
  153. border-radius: 50%;
  154. top: 120rpx;
  155. }
  156. }
  157. .invitation-name {
  158. font-size: 52rpx;
  159. margin-bottom: 40rpx;
  160. }
  161. .invitation-name-tip {
  162. font-size: 36rpx;
  163. color: rgba(134, 134, 134, 100);
  164. margin-bottom: 20rpx;
  165. }
  166. .invitation-code {
  167. image {
  168. width: 250rpx;
  169. height: 250rpx;
  170. margin-bottom: 20rpx;
  171. }
  172. }
  173. .invitation-code-tip {
  174. font-size: 34rpx;
  175. color: rgba(181, 181, 181, 100);
  176. margin-bottom: 60rpx;
  177. }
  178. .invitation-bottom-tip {
  179. font-size: 28rpx;
  180. }
  181. }
  182. .tip {
  183. text-align: center;
  184. }
  185. .btn {
  186. padding: 40rpx 20rpx;
  187. .ge {
  188. height: 40rpx;
  189. }
  190. /deep/ button {
  191. line-height: 60rpx;
  192. font-size: 28rpx;
  193. height: 60rpx;
  194. color: #fff;
  195. background-color: $uni-bg-color;
  196. border: none;
  197. border-radius: 8rpx;
  198. }
  199. }
  200. </style>