index.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. <template>
  2. <mescroll-body ref="mescrollRef" :sticky="true" @init="mescrollInit" :down="{ use: false }" :up="upOption" @up="upCallback">
  3. <view class="poster">
  4. <view class="tips">邀请好友即获得奖励!</view>
  5. <view class="iconfont icon-gift"></view>
  6. <view class="action-btn">
  7. <view class="btn-wrapper">
  8. <view class="btn-item" @click="shareNow">立即邀请</view>
  9. </view>
  10. </view>
  11. </view>
  12. </view>
  13. <!-- 分享对话框 start -->
  14. <u-popup v-model="shareShow" mode="bottom" border-radius="14" height="453">
  15. <view class="share-popup">
  16. <text class="share-title">邀请确认</text>
  17. <view class="row">
  18. <view class="col-6" @click="doShare('share')">
  19. <button class="mt-1" open-type="share">
  20. <view class="iconfont icon-fenxiang-post"></view>
  21. <text class="txt">立即邀请</text>
  22. </button>
  23. </view>
  24. <view class="col-6" @click="doShare('copy')">
  25. <button class="mt-1">
  26. <view class="iconfont icon-copy"></view>
  27. <text class="mt-1">复制链接</text>
  28. </button>
  29. </view>
  30. </view>
  31. <view class="share-btn" @click="shareShow = false">
  32. <view class="btn-wrapper">
  33. <view class="btn-item" @click="shareNow">取消邀请</view>
  34. </view>
  35. </view>
  36. </view>
  37. </u-popup>
  38. <!-- 分享对话框 end -->
  39. <!-- 生成海报对话框 -->
  40. <poster-img :img-show.sync="showPoster" v-if="showPoster"></poster-img>
  41. <view class="title-wrapper">
  42. <view class="title">邀请记录</view>
  43. </view>
  44. <!-- 邀请列表 start-->
  45. <view class="share-list">
  46. <view class="share-item show-type" v-for="(item, index) in list.content" :key="index" @click="onTargetDetail(item.id)">
  47. <block>
  48. <view class="share-item-left flex-box">
  49. <view class="share-item-image">
  50. <image class="image" :src="item.subUserInfo.avatar"></image>
  51. </view>
  52. <view class="share-item-title twolist-hidden">
  53. <view class="name">{{ item.subUserInfo.name }}</view>
  54. <view class="no">会员号:{{ item.subUserInfo.userNo }}</view>
  55. </view>
  56. <view class="share-item-footer m-top10">
  57. <text class="share-views f-24 col-8">邀请时间:{{ item.createTime | timeFormat('yyyy-mm-dd hh:MM') }}</text>
  58. </view>
  59. </view>
  60. </block>
  61. </view>
  62. </view>
  63. <!-- 邀请列表 end -->
  64. </mescroll-body>
  65. </template>
  66. <script>
  67. import MescrollBody from '@/components/mescroll-uni/mescroll-body.vue'
  68. import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins'
  69. import * as ShareApi from '@/api/share'
  70. import { getEmptyPaginateObj, getMoreListData } from '@/utils/app'
  71. import config from '@/config'
  72. const pageSize = 15
  73. export default {
  74. components: {
  75. MescrollBody
  76. },
  77. mixins: [MescrollMixin],
  78. data() {
  79. return {
  80. // h5
  81. url: '',
  82. // 立即分享
  83. shareShow: false,
  84. // 生成海报
  85. showPoster: false,
  86. // 邀请列表
  87. list: getEmptyPaginateObj(),
  88. // 上拉加载配置
  89. upOption: {
  90. // 首次自动执行
  91. auto: true,
  92. // 每页数据的数量; 默认10
  93. page: { size: pageSize },
  94. // 数量要大于3条才显示无更多数据
  95. noMoreSize: 3,
  96. }
  97. }
  98. },
  99. methods: {
  100. /**
  101. * 上拉加载的回调 (页面初始化时也会执行一次)
  102. * 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10
  103. * @param {Object} page
  104. */
  105. upCallback(page) {
  106. const app = this;
  107. // 设置列表数据
  108. app.getShareList(page.num)
  109. .then(list => {
  110. const curPageLen = list.content.length;
  111. const totalSize = list.content.totalElements;
  112. app.mescroll.endBySize(curPageLen, totalSize);
  113. })
  114. .catch(() => app.mescroll.endErr());
  115. },
  116. /**
  117. * 获取邀请列表
  118. * @param {Number} pageNo 页码
  119. */
  120. getShareList(pageNo = 1) {
  121. const app = this
  122. return new Promise((resolve, reject) => {
  123. ShareApi.list({ page: pageNo }, { load: false })
  124. .then(result => {
  125. // 合并新数据
  126. const newList = result.data.paginationResponse;
  127. app.url = result.data.url;
  128. app.list.content = getMoreListData(newList, app.list, pageNo);
  129. resolve(newList);
  130. })
  131. .catch(result => reject());
  132. })
  133. },
  134. /**
  135. * 立即邀请
  136. */
  137. shareNow() {
  138. this.shareShow = true;
  139. },
  140. /**
  141. * 确认分享
  142. */
  143. doShare(action) {
  144. const app = this;
  145. app.shareShow = false;
  146. let copyContent = app.url + "#?" + app.$getShareUrlParams();
  147. // #ifdef MP-WEIXIN
  148. ShareApi.getMiniAppLink({
  149. path: 'pages/index/index',
  150. query: app.$getShareUrlParams()
  151. }).then(res => {
  152. if (res && res.link) {
  153. copyContent = res.link;
  154. }
  155. })
  156. // #endif
  157. if (action == 'copy') {
  158. uni.setClipboardData({
  159. data: copyContent,
  160. success: function() {
  161. uni.showToast({
  162. title: "复制成功",
  163. icon: 'none'
  164. });
  165. },
  166. fail: () => {
  167. uni.showToast({
  168. title: "复制失败",
  169. icon: 'none'
  170. });
  171. }
  172. })
  173. } else {
  174. return false;
  175. }
  176. },
  177. /**
  178. * 分享当前页面
  179. */
  180. onShareAppMessage() {
  181. const app = this
  182. return {
  183. title: config.name,
  184. path: "/pages/index/index?" + app.$getShareUrlParams()
  185. }
  186. },
  187. /**
  188. * 分享到朋友圈
  189. * 本接口为 Beta 版本,暂只在 Android 平台支持,详见分享到朋友圈 (Beta)
  190. * https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share-timeline.html
  191. */
  192. onShareTimeline() {
  193. const app = this
  194. const { page } = app
  195. return {
  196. title: config.name,
  197. path: "/pages/index/index?" + app.$getShareUrlParams()
  198. }
  199. }
  200. }
  201. }
  202. </script>
  203. <style lang="scss" scoped>
  204. /* 顶部选项卡 */
  205. .container {
  206. min-height: 100vh;
  207. }
  208. .poster {
  209. padding: 20rpx;
  210. text-align: center;
  211. .iconfont {
  212. text-align: center;
  213. font-size: 120rpx;
  214. margin: 50rpx;
  215. color: $fuint-theme;
  216. }
  217. .action-btn {
  218. text-align: center;
  219. margin-top: 10rpx;
  220. .btn-wrapper {
  221. height: 100%;
  222. display: block;
  223. align-items: center;
  224. width: 70%;
  225. margin: 0 auto;
  226. .btn-item {
  227. font-size: 28rpx;
  228. height: 80rpx;
  229. line-height: 80rpx;
  230. text-align: center;
  231. color: #fff;
  232. border-radius: 80rpx;
  233. background: linear-gradient(to right, #f9211c, #ff6335);
  234. }
  235. }
  236. }
  237. }
  238. .share-popup {
  239. padding: 20rpx;
  240. font-size: 30rpx;
  241. text-align: center;
  242. .share-title {
  243. margin-top: 40rpx;
  244. font-size: 35rpx;
  245. font-weight: bold;
  246. }
  247. .row {
  248. margin-top: 30rpx;
  249. padding-top: 80rpx;
  250. clear: both;
  251. height: 240rpx;
  252. .col-6 {
  253. width: 50%;
  254. float: left;
  255. .mt-1 {
  256. line-height: 60rpx;
  257. font-size: 24rpx;
  258. background: none;
  259. }
  260. .iconfont {
  261. color: $fuint-theme;
  262. font-size: 56rpx;
  263. }
  264. }
  265. }
  266. .share-btn {
  267. text-align: center;
  268. .btn-wrapper {
  269. height: 100%;
  270. display: block;
  271. align-items: center;
  272. width: 80%;
  273. margin: 0 auto;
  274. border: solid 2rpx #ccc;
  275. border-radius: 80rpx;
  276. .btn-item {
  277. font-size: 28rpx;
  278. height: 80rpx;
  279. line-height: 80rpx;
  280. text-align: center;
  281. color: #333;
  282. }
  283. }
  284. }
  285. }
  286. .title-wrapper {
  287. display: flex;
  288. width: 100%;
  289. height: 88rpx;
  290. line-height: 88rpx;
  291. color: #333;
  292. padding-left: 20rpx;
  293. font-size: 30rpx;
  294. font-weight: bold;
  295. background: #fff;
  296. margin-top: 50rpx;
  297. border-bottom: 1rpx solid #e4e4e4;
  298. z-index: 100;
  299. overflow: hidden;
  300. white-space: nowrap;
  301. }
  302. /* 分享列表 */
  303. .share-list {
  304. padding-top: 10rpx;
  305. line-height: 1;
  306. background: #f7f7f7;
  307. }
  308. .share-item {
  309. margin-bottom: 10rpx;
  310. padding: 20rpx;
  311. background: #fff;
  312. &:last-child {
  313. margin-bottom: 0;
  314. }
  315. .share-item-title {
  316. max-height: 80rpx;
  317. font-size: 24rpx;
  318. color: #333;
  319. .name {
  320. font-weight: bold;
  321. }
  322. .no {
  323. margin-top: 20rpx;
  324. font-size: 20rpx;
  325. color: #888888;
  326. }
  327. }
  328. .share-item-image .image {
  329. display: block;
  330. border-radius: 100rpx;
  331. height: 100rpx;
  332. width: 100rpx;
  333. border: 2rpx solid #cccccc;
  334. float: left;
  335. background: #ccc;
  336. }
  337. .share-item-footer {
  338. margin-top: 0rpx;
  339. clear: both;
  340. text-align: right;
  341. }
  342. }
  343. .show-type {
  344. display: flex;
  345. .share-item-left {
  346. padding-right: 20rpx;
  347. width: 10rpx;
  348. }
  349. .share-item-title {
  350. min-height: 100rpx;
  351. float: left;
  352. margin-left: 10rpx;
  353. }
  354. }
  355. </style>