invite.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <Theme>
  3. <view class="wrap">
  4. <Navbar title="邀请有礼" fixed border>
  5. <template #right>
  6. <navMenu :options="{ icon: 'icon-home', text: '主页' }" />
  7. </template>
  8. </Navbar>
  9. <view class="content">
  10. <view class="qrcode">
  11. <image
  12. :src="BaseUrl + '/api/other/qrcode?text=' + detail.app_url"
  13. alt=""
  14. class="img"
  15. />
  16. </view>
  17. <view class="invite-code-section">
  18. <text class="invite-label"> <trans _t="我的邀请码"></trans>: </text>
  19. <text class="invite-code">{{ userInfo.share_code }}</text>
  20. </view>
  21. <!-- <view class="invite-link-section">
  22. <text class="invite-link">{{ detail.text }}</text>
  23. </view> -->
  24. <up-copy
  25. class="invite-copy-btn"
  26. :content="userInfo.share_code"
  27. :notice="t('复制成功')"
  28. >
  29. <trans class="copy" _t="复制" />
  30. </up-copy>
  31. </view>
  32. <view class="tips_content">
  33. <view class="tips_content-head">
  34. <view class="tips_content-head__tag">
  35. <trans _t="推广步骤"></trans>:
  36. </view>
  37. </view>
  38. <view class="tips_content-body">
  39. <view v-html="detail.share_info"></view>
  40. </view>
  41. </view>
  42. <view class="invitation-records-page">
  43. <view class="page-title">
  44. <trans _t="邀请记录" />
  45. </view>
  46. <view class="records-list">
  47. <view
  48. class="record-item"
  49. v-for="(record, index) in records"
  50. :key="index"
  51. >
  52. <view class="inviter-info">
  53. <view class="avatar">
  54. <image
  55. :src="record.comfrom?.userimg"
  56. mode="widthFix"
  57. class="avatar-img"
  58. alt="用户头像"
  59. ></image>
  60. </view>
  61. <!-- 姓名 -->
  62. <view class="inviter-name">
  63. <text>{{ record.comfrom?.username }}</text>
  64. </view>
  65. </view>
  66. <!-- 优惠券信息 -->
  67. <view class="coupon-info">
  68. <view class="coupon-name">
  69. <text>{{ record.title }}</text>
  70. </view>
  71. <view class="coupon-amount">
  72. <text class="symbol">{{ symbol.symbol }}</text>
  73. <text class="amount">{{ Moneyhtml(record.money) }}</text>
  74. </view>
  75. </view>
  76. </view>
  77. <view class="empty-state" v-if="records.length === 0">
  78. <trans class="empty-text" _t="暂无邀请记录"></trans>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. </Theme>
  84. </template>
  85. <script setup>
  86. import { BaseUrl, Moneyhtml } from "@/utils";
  87. import Navbar from "@/components/navbar";
  88. import navMenu from "@/components/nav_menu";
  89. import { computed, ref, nextTick } from "vue";
  90. import { OTHER_CONFIG, SHOP_SHOPCOUNPON_LIST } from "@/api";
  91. import { t } from "@/locale";
  92. import { useUserStore, useSystemStore } from "@/store";
  93. import { onShow } from "@dcloudio/uni-app";
  94. const useUser = useUserStore();
  95. const userInfo = computed(() => useUser.getuserInfo);
  96. const useSystem = useSystemStore();
  97. const symbol = computed(() => useSystem.getSymbol);
  98. const detail = ref({});
  99. const records = ref([]);
  100. const getDetail = async () => {
  101. try {
  102. const res = await OTHER_CONFIG("share");
  103. detail.value = res.data;
  104. } catch (error) {}
  105. };
  106. const getDataList = async () => {
  107. try {
  108. const res = await SHOP_SHOPCOUNPON_LIST();
  109. records.value = res.data || [];
  110. } catch (error) {
  111. Toast(error.msg);
  112. }
  113. };
  114. const getStatusText = (status) => {
  115. switch (status) {
  116. case "used":
  117. return "已使用";
  118. case "unused":
  119. return "未使用";
  120. case "expired":
  121. return "已过期";
  122. default:
  123. return "";
  124. }
  125. };
  126. onShow(() => {
  127. nextTick(() => {
  128. getDetail();
  129. getDataList();
  130. });
  131. });
  132. </script>
  133. <style lang="less" scoped>
  134. @import url("@/style.less");
  135. .wrap {
  136. background: var(--bg);
  137. min-height: 100vh;
  138. .content {
  139. position: relative;
  140. z-index: 3;
  141. margin: 10% 8% 0;
  142. border-radius: 2.667vw;
  143. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
  144. padding: 20rpx;
  145. .qrcode {
  146. .hor();
  147. .img {
  148. width: 200rpx;
  149. height: 200rpx;
  150. }
  151. }
  152. .invite-code-section {
  153. .flex_center();
  154. padding-bottom: 40rpx;
  155. color: var(--black);
  156. .invite-label {
  157. font-size: 28rpx;
  158. display: block;
  159. }
  160. .invite-code {
  161. font-size: 32rpx;
  162. font-weight: bold;
  163. }
  164. }
  165. .invite-link-section {
  166. background-color: var(--bg);
  167. border: 1rpx solid var(--borderColor);
  168. border-radius: 12rpx;
  169. padding: 24rpx;
  170. margin-bottom: 40rpx;
  171. word-break: break-all;
  172. .invite-link {
  173. font-size: 28rpx;
  174. }
  175. }
  176. .invite-copy-btn {
  177. max-width: 40vw;
  178. height: 70rpx;
  179. background-color: var(--black);
  180. color: @white;
  181. border-radius: 12rpx;
  182. padding: 0 24rpx;
  183. font-size: 32rpx;
  184. text-align: center;
  185. line-height: 70rpx;
  186. margin: 0 auto;
  187. &:active {
  188. opacity: 0.8;
  189. }
  190. }
  191. }
  192. .tips_content {
  193. margin: 30px 8% 0;
  194. // border-radius: 2.667vw;
  195. // box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
  196. padding: 0 0rpx;
  197. .tips_content-head__tag {
  198. display: inline-block;
  199. padding: 12rpx 20rpx;
  200. background-color: var(--black);
  201. border-radius: 10rpx;
  202. color: #fff;
  203. font-size: 30rpx;
  204. font-weight: 500;
  205. }
  206. .tips_content-body {
  207. margin-top: 18px;
  208. }
  209. }
  210. .invitation-records-page {
  211. padding-bottom: 20rpx;
  212. .page-title {
  213. height: 120rpx;
  214. line-height: 120rpx;
  215. text-align: center;
  216. font-size: 36rpx;
  217. font-weight: 600;
  218. color: #333;
  219. background-color: #fff;
  220. border-bottom: 1rpx solid #eee;
  221. }
  222. .records-list {
  223. padding: 20rpx;
  224. .record-item {
  225. display: flex;
  226. justify-content: space-between;
  227. align-items: center;
  228. background-color: #f5f5f7;
  229. border-radius: 16rpx;
  230. padding: 30rpx 24rpx;
  231. margin-bottom: 20rpx;
  232. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  233. transition: all 0.3s ease;
  234. &:active {
  235. transform: scale(0.99);
  236. box-shadow: 0 1rpx 5rpx rgba(0, 0, 0, 0.03);
  237. }
  238. .inviter-info {
  239. display: flex;
  240. align-items: center;
  241. .avatar {
  242. width: 80rpx;
  243. height: 80rpx;
  244. border-radius: 50%;
  245. overflow: hidden;
  246. margin-right: 20rpx;
  247. background-color: #f0f0f0;
  248. .avatar-img {
  249. width: 100%;
  250. height: 100%;
  251. object-fit: cover;
  252. }
  253. }
  254. .inviter-name {
  255. font-size: 32rpx;
  256. color: #333;
  257. font-weight: 500;
  258. }
  259. }
  260. .coupon-info {
  261. display: flex;
  262. flex-direction: column;
  263. align-items: flex-end;
  264. .coupon-name {
  265. font-size: 26rpx;
  266. color: #666;
  267. margin-bottom: 8rpx;
  268. }
  269. .coupon-amount {
  270. display: flex;
  271. align-items: baseline;
  272. .symbol {
  273. font-size: 28rpx;
  274. color: #ff4d4f;
  275. }
  276. .amount {
  277. font-size: 36rpx;
  278. color: #ff4d4f;
  279. font-weight: 600;
  280. }
  281. }
  282. }
  283. }
  284. .empty-state {
  285. display: flex;
  286. flex-direction: column;
  287. align-items: center;
  288. padding: 30rpx 0;
  289. .empty-text {
  290. font-size: 30rpx;
  291. color: #999;
  292. }
  293. }
  294. }
  295. }
  296. }
  297. </style>