index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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/bg/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-test-1307117429.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. console.log(res);
  97. this.userInfo = res.data
  98. this.avatar = this.posterData.mainImg.url = env.filePublic + res.data.avatar
  99. this.posterData.title.text = res.data.nickName
  100. }
  101. }).catch(() => {
  102. uni.hideLoading();
  103. })
  104. },
  105. getUrl() {
  106. $http.post('/api/v1/mp/user/share/code/generate', {
  107. boxId: this.boxId,
  108. type: "1"
  109. }).then(res => {
  110. this.codeUrl = this.posterData.codeImg.url = env.filePublic + res.data
  111. })
  112. },
  113. saveImg() {
  114. this.$refs.shareCode.posterShow()
  115. },
  116. },
  117. onShareAppMessage(res) {
  118. return {
  119. title: '分享盲票',
  120. path: `/pages/ticketBox/detail?boxId=${ this.boxId }&userId=${ this.userInfo.userId }&type=1`,
  121. type: 2,
  122. }
  123. }
  124. }
  125. </script>
  126. <style lang="scss" scoped>
  127. .invitation {
  128. flex-direction: column;
  129. margin: 50rpx 30rpx;
  130. padding: 0 0 80rpx;
  131. border: 1px solid rgba(236, 236, 236, 100);
  132. border-radius: 20rpx;
  133. background-color: #FFFFFF;
  134. &-user {
  135. position: relative;
  136. width: 100%;
  137. margin-bottom: 80rpx;
  138. image {
  139. width: 100%;
  140. height: 188rpx;
  141. border-top-left-radius: 20rpx;
  142. border-top-right-radius: 20rpx;
  143. }
  144. .title {
  145. position: absolute;
  146. font-size: 52rpx;
  147. color: #FFFFFF;
  148. top: 20rpx;
  149. }
  150. .avatar {
  151. position: absolute;
  152. width: 134rpx;
  153. height: 134rpx;
  154. border-radius: 50%;
  155. top: 120rpx;
  156. }
  157. }
  158. .invitation-name {
  159. font-size: 52rpx;
  160. margin-bottom: 40rpx;
  161. }
  162. .invitation-name-tip {
  163. font-size: 36rpx;
  164. color: rgba(134, 134, 134, 100);
  165. margin-bottom: 20rpx;
  166. }
  167. .invitation-code {
  168. image {
  169. width: 250rpx;
  170. height: 250rpx;
  171. margin-bottom: 20rpx;
  172. }
  173. }
  174. .invitation-code-tip {
  175. font-size: 34rpx;
  176. color: rgba(181, 181, 181, 100);
  177. margin-bottom: 60rpx;
  178. }
  179. .invitation-bottom-tip {
  180. font-size: 28rpx;
  181. }
  182. }
  183. .tip {
  184. text-align: center;
  185. }
  186. .btn {
  187. padding: 40rpx 20rpx;
  188. .ge {
  189. height: 40rpx;
  190. }
  191. /deep/ button {
  192. line-height: 60rpx;
  193. font-size: 28rpx;
  194. height: 60rpx;
  195. color: #fff;
  196. background-color: $uni-bg-color;
  197. border: none;
  198. border-radius: 8rpx;
  199. }
  200. }
  201. </style>