partner-home.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <view class="partner-home">
  3. <!-- 头部信息 -->
  4. <view class="header">
  5. <image class="avatar" src="/static/img/logo.png" mode="aspectFit"></image>
  6. <view class="header-text">
  7. <text class="title">您好,合伙人</text>
  8. <text class="subtitle">这里是合伙人数据中心</text>
  9. </view>
  10. <navigator url="/pages-mine/pages/partner/partner-rule" class="rule-btn">合伙人规则</navigator>
  11. </view>
  12. <view class="content" style="margin-top: -180rpx">
  13. <!-- 收入统计 -->
  14. <view class="income-section">
  15. <view class="section-header">
  16. <text class="section-title">收入统计</text>
  17. <text class="tip">每月20号到账上月结算收益</text>
  18. </view>
  19. <view class="income-grid">
  20. <view class="income-item">
  21. <text class="amount">¥{{ detail.totalIncome || "0.00" }}</text>
  22. <text class="label">累计收入</text>
  23. </view>
  24. <view class="income-item">
  25. <text class="amount">¥{{ detail.todayEstimateIncome || "0.00" }}</text>
  26. <text class="label">今日预估</text>
  27. </view>
  28. <view class="income-item">
  29. <text class="amount">¥{{ detail.lastMontyEstimateIncome || "0.00" }}</text>
  30. <text class="label">上月预估</text>
  31. </view>
  32. <view class="income-item">
  33. <text class="amount">¥{{ detail.thisMontyEstimateIncome || "0.00" }}</text>
  34. <text class="label">本月预估</text>
  35. </view>
  36. <view class="income-item">
  37. <text class="amount">¥{{ detail.lastMontySettlement || "0.00" }}</text>
  38. <text class="label">上月结算</text>
  39. </view>
  40. <view class="income-item">
  41. <text class="amount">¥{{ detail.waitAccount || "0.00" }}</text>
  42. <text class="label">待到账</text>
  43. </view>
  44. </view>
  45. </view>
  46. <!-- 实用工具 -->
  47. <view class="tools-section">
  48. <text class="section-title">实用工具</text>
  49. <view class="tools-grid">
  50. <navigator url="/pages-mine/pages/partner/income-detail" class="tool-item">
  51. <image src="/pages-mine/static/partner1.png" mode="aspectFit"></image>
  52. <text>收入明细</text>
  53. </navigator>
  54. <navigator url="/pages-mine/pages/partner/order-detail" class="tool-item">
  55. <image src="/pages-mine/static/partner2.png" mode="aspectFit"></image>
  56. <text>订单明细</text>
  57. </navigator>
  58. </view>
  59. </view>
  60. <!-- 生成海报按钮 -->
  61. <button class="generate-poster" @click="generatePoster">生成专属二维码海报</button>
  62. <!-- 添加海报弹窗 -->
  63. <u-popup
  64. v-model="showPoster"
  65. mode="center"
  66. border-radius="16"
  67. :custom-style="posterStyle"
  68. >
  69. <view class="poster-container">
  70. <image
  71. class="poster-image"
  72. src="/pages-mine/static/poster.png"
  73. mode="aspectFit"
  74. @longpress="saveImage"
  75. ></image>
  76. <view class="poster-tip">长按图片保存至相册分享</view>
  77. </view>
  78. </u-popup>
  79. </view>
  80. </view>
  81. </template>
  82. <script>
  83. export default {
  84. data() {
  85. return {
  86. detail: {
  87. totalIncome: 0,
  88. todayEstimateIncome: 0,
  89. lastMontyEstimateIncome: 0,
  90. thisMontyEstimateIncome: 0,
  91. lastMontySettlement: 0,
  92. waitAccount: 0,
  93. },
  94. showPoster: false,
  95. posterStyle: {
  96. backgroundColor: 'transparent',
  97. },
  98. };
  99. },
  100. onLoad() {
  101. this.getPartnerInfo();
  102. },
  103. methods: {
  104. getPartnerInfo() {
  105. uni.$u.get("/token/getUserPartnerInfo").then((res) => {
  106. if (res.code == 200) {
  107. this.detail = res.data;
  108. }
  109. });
  110. },
  111. generatePoster() {
  112. this.showPoster = true;
  113. },
  114. saveImage() {
  115. uni.getSetting({
  116. success: (res) => {
  117. if (!res.authSetting["scope.writePhotosAlbum"]) {
  118. uni.authorize({
  119. scope: "scope.writePhotosAlbum",
  120. success: () => {
  121. this.saveImageToAlbum();
  122. },
  123. fail: () => {
  124. uni.showToast({
  125. title: "请授权保存图片到相册",
  126. icon: "none",
  127. });
  128. },
  129. });
  130. } else {
  131. this.saveImageToAlbum();
  132. }
  133. },
  134. });
  135. },
  136. saveImageToAlbum() {
  137. uni.saveImageToPhotosAlbum({
  138. filePath: "/pages-mine/static/poster.png",
  139. success: () => {
  140. uni.showToast({
  141. title: "保存成功",
  142. icon: "success",
  143. });
  144. },
  145. fail: () => {
  146. uni.showToast({
  147. title: "保存失败",
  148. icon: "none",
  149. });
  150. },
  151. });
  152. },
  153. },
  154. };
  155. </script>
  156. <style>
  157. </style>
  158. <style lang="scss" scoped>
  159. .partner-home {
  160. min-height: 100vh;
  161. background-color: #f5f5f5;
  162. .section-title {
  163. font-size: 32rpx;
  164. font-weight: bold;
  165. margin-bottom: 20rpx;
  166. display: block;
  167. }
  168. .header {
  169. display: flex;
  170. align-items: flex-start;
  171. background-color: #4caf50;
  172. padding: 30rpx;
  173. padding-top: 45rpx;
  174. border-radius: 16rpx;
  175. margin-bottom: 20rpx;
  176. height: 322rpx;
  177. border-radius: 0rpx 0rpx 161rpx 161rpx;
  178. .avatar {
  179. width: 80rpx;
  180. height: 80rpx;
  181. border-radius: 50%;
  182. margin-right: 20rpx;
  183. }
  184. .header-text {
  185. flex: 1;
  186. color: #fff;
  187. .title {
  188. font-size: 32rpx;
  189. font-weight: bold;
  190. display: block;
  191. }
  192. .subtitle {
  193. font-size: 24rpx;
  194. opacity: 0.8;
  195. }
  196. }
  197. .rule-btn {
  198. padding: 10rpx 20rpx;
  199. background: rgba(255, 255, 255, 0.2);
  200. border-radius: 30rpx;
  201. color: #fff;
  202. font-size: 24rpx;
  203. }
  204. }
  205. .income-section {
  206. background-color: #fff;
  207. border-radius: 16rpx;
  208. padding: 30rpx;
  209. margin: 20rpx auto;
  210. width: calc(100% - 40rpx);
  211. .section-header {
  212. display: flex;
  213. justify-content: space-between;
  214. align-items: center;
  215. margin-bottom: 20rpx;
  216. .tip {
  217. font-size: 24rpx;
  218. color: #999;
  219. }
  220. }
  221. .income-grid {
  222. display: grid;
  223. grid-template-columns: repeat(2, 1fr);
  224. gap: 20rpx;
  225. .income-item {
  226. background-color: #f8f8f8;
  227. padding: 20rpx;
  228. border-radius: 12rpx;
  229. text-align: center;
  230. .amount {
  231. color: #ff4d4f;
  232. font-size: 32rpx;
  233. font-weight: bold;
  234. display: block;
  235. }
  236. .label {
  237. font-size: 24rpx;
  238. color: #666;
  239. margin-top: 8rpx;
  240. }
  241. }
  242. }
  243. }
  244. .tools-section {
  245. background-color: #fff;
  246. border-radius: 16rpx;
  247. padding: 30rpx;
  248. margin: 20rpx auto;
  249. width: calc(100% - 40rpx);
  250. .tools-grid {
  251. display: flex;
  252. gap: 30rpx;
  253. .tool-item {
  254. flex: 1;
  255. display: flex;
  256. align-items: center;
  257. padding: 20rpx;
  258. border-radius: 12rpx;
  259. image {
  260. width: 90rpx;
  261. height: 90rpx;
  262. margin-right: 10rpx;
  263. }
  264. text {
  265. font-size: 26rpx;
  266. color: #333;
  267. }
  268. }
  269. }
  270. }
  271. .generate-poster {
  272. width: calc(100% - 60rpx);
  273. height: 88rpx;
  274. line-height: 88rpx;
  275. background-color: #4caf50;
  276. color: #fff;
  277. border-radius: 10rpx;
  278. font-size: 28rpx;
  279. margin: 40rpx auto;
  280. }
  281. .poster-container {
  282. display: flex;
  283. flex-direction: column;
  284. align-items: center;
  285. .poster-image {
  286. width: 490rpx;
  287. height: 872rpx;
  288. }
  289. .poster-tip {
  290. font-size: 32rpx;
  291. color: #fff;
  292. text-align: center;
  293. background-color: #333;
  294. text-justify: space-between;
  295. width: 490rpx;
  296. line-height: 54rpx;
  297. position: relative;
  298. top: -2rpx;
  299. }
  300. }
  301. ::v-deep .u-mode-center-box {
  302. background-color: transparent !important;
  303. }
  304. }
  305. </style>