index.vue 4.9 KB

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