爱简收旧衣按件回收前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

236 lines
5.3 KiB

1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="promo-modal-page">
  3. <!-- 顶部导航栏 -->
  4. <view class="nav-bar" :style="{height: navBarTotalHeight + 'px', paddingTop: statusBarHeight + 'px'}">
  5. <view class="nav-bar-inner">
  6. <view class="back-icon" @tap="navigateBack">
  7. <uni-icons type="left" size="22" color="#222" />
  8. </view>
  9. <view class="nav-bar-title">推广链接</view>
  10. <view class="nav-bar-right">
  11. <uni-icons type="more-filled" size="22" color="#222" />
  12. </view>
  13. </view>
  14. </view>
  15. <!-- 用户信息 -->
  16. <view class="user-info-modal" :style="{ marginTop: navBarTotalHeight + 'px' }">
  17. <view class="avatar-frame">
  18. <image class="avatar-img" :src="userInfo.avatar" mode="aspectFill" />
  19. </view>
  20. <view class="nickname">{{userInfo.name}}</view>
  21. </view>
  22. <!-- 二维码区 -->
  23. <view class="qrcode-modal-section">
  24. <image class="qrcode-img" :src="qrcodeUrl" mode="widthFix" />
  25. <!-- <view class="invite-code">邀请码{{inviteCode}}</view> -->
  26. </view>
  27. <!-- 底部按钮 -->
  28. <view class="bottom-btns-modal">
  29. <button class="btn gray">分享给好友</button>
  30. <button class="btn green">保存到本地</button>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import pullRefreshMixin from '@/pages/mixins/pullRefreshMixin.js'
  36. export default {
  37. mixins: [pullRefreshMixin],
  38. data() {
  39. return {
  40. statusBarHeight: 0,
  41. navBarHeight: 44,
  42. navBarTotalHeight: 44,
  43. userInfo: {
  44. avatar: '/static/avatar.png',
  45. name: '战斗世界',
  46. },
  47. qrcodeUrl: '/static/qrcode.png',
  48. inviteCode: '888888',
  49. }
  50. },
  51. onLoad() {
  52. const sysInfo = uni.getSystemInfoSync()
  53. this.statusBarHeight = sysInfo.statusBarHeight
  54. this.navBarHeight = 44
  55. this.navBarTotalHeight = this.statusBarHeight + this.navBarHeight
  56. // 可能要等待获取到数据
  57. this.getQrcode()
  58. },
  59. methods: {
  60. async onRefresh() {
  61. // 模拟刷新数据
  62. await new Promise(resolve => setTimeout(resolve, 1000))
  63. uni.stopPullRefresh()
  64. },
  65. navigateBack() {
  66. uni.navigateBack()
  67. },
  68. getQrcode(){
  69. // 获取全局二维码路径
  70. if (getApp().globalData.qr_path) {
  71. console.log('获取到二维码路径', getApp().globalData.qr_path)
  72. this.qrcodeUrl = getApp().globalData.qr_path
  73. } else {
  74. console.log('全局二维码路径不存在')
  75. uni.getImageInfo({
  76. src: `${config.baseUrl}/recycle-admin/applet/promotion/getInviteCode?token=${uni.getStorageSync('token')}`,
  77. success: res => {
  78. getApp().globalData.qr_path = res.path
  79. console.log(getApp().globalData.qr_path, 'qr_path')
  80. this.qrcodeUrl = getApp().globalData.qr_path
  81. },
  82. fail: err => {
  83. console.log('QR code load failed:', err)
  84. }
  85. })
  86. }
  87. },
  88. }
  89. }
  90. </script>
  91. <style lang="scss" scoped>
  92. .promo-modal-page {
  93. min-height: 100vh;
  94. background: linear-gradient(to bottom, #f6fff2 0%, #fff 100%);
  95. display: flex;
  96. flex-direction: column;
  97. align-items: center;
  98. position: relative;
  99. .nav-bar {
  100. position: fixed;
  101. top: 0;
  102. left: 0;
  103. right: 0;
  104. z-index: 1000;
  105. width: 100vw;
  106. background: linear-gradient(to right, #b2f08d 0%, #39e9d2 100%);
  107. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.03);
  108. .nav-bar-inner {
  109. display: flex;
  110. align-items: center;
  111. height: 44px;
  112. width: 100vw;
  113. position: relative;
  114. }
  115. .back-icon,
  116. .nav-bar-right {
  117. width: 44px;
  118. height: 44px;
  119. display: flex;
  120. align-items: center;
  121. justify-content: center;
  122. position: absolute;
  123. top: 0;
  124. }
  125. .back-icon {
  126. left: 0;
  127. }
  128. .nav-bar-right {
  129. right: 0;
  130. }
  131. .nav-bar-title {
  132. flex: 1;
  133. text-align: center;
  134. font-size: 36rpx;
  135. font-weight: bold;
  136. color: #222;
  137. letter-spacing: 2rpx;
  138. line-height: 44px;
  139. }
  140. }
  141. .user-info-modal {
  142. display: flex;
  143. flex-direction: column;
  144. align-items: center;
  145. .avatar-frame {
  146. width: 104rpx;
  147. height: 104rpx;
  148. border-radius: 10rpx;
  149. overflow: hidden;
  150. background: #f2f2f2;
  151. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.10);
  152. .avatar-img {
  153. width: 104rpx;
  154. height: 104rpx;
  155. object-fit: cover;
  156. display: block;
  157. }
  158. }
  159. .nickname {
  160. margin-top: 24rpx;
  161. font-size: 32rpx;
  162. font-weight: bold;
  163. color: #222;
  164. text-align: center;
  165. }
  166. }
  167. .qrcode-modal-section {
  168. margin-top: 48rpx;
  169. width: 300rpx;
  170. display: flex;
  171. flex-direction: column;
  172. align-items: center;
  173. .qrcode-img {
  174. width: 100%;
  175. height: 100%;
  176. background: #fff;
  177. border-radius: 24rpx;
  178. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
  179. }
  180. .invite-code {
  181. margin-top: 32rpx;
  182. font-size: 30rpx;
  183. color: #222;
  184. font-weight: bold;
  185. text-align: center;
  186. }
  187. }
  188. .bottom-btns-modal {
  189. position: fixed;
  190. left: 0;
  191. right: 0;
  192. bottom: 0;
  193. display: flex;
  194. justify-content: space-between;
  195. padding: 24rpx 32rpx calc(env(safe-area-inset-bottom) + 24rpx) 32rpx;
  196. background: #fff;
  197. z-index: 100;
  198. .btn {
  199. flex: 1;
  200. height: 88rpx;
  201. border-radius: 44rpx;
  202. font-size: 32rpx;
  203. font-weight: bold;
  204. margin: 0 12rpx;
  205. border: none;
  206. &.gray {
  207. background: linear-gradient(90deg, #f7f7f7, #f2f2f2);
  208. color: #888;
  209. }
  210. &.green {
  211. background: linear-gradient(90deg, #b2f08d, #39e9d2);
  212. color: #fff;
  213. }
  214. }
  215. }
  216. }
  217. </style>