index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <v-container class="invite-user pa-0" fluid>
  3. <div class="box box1">
  4. <div class="box-header">参与步骤</div>
  5. <div class="box-main">
  6. <v-img
  7. class="cybz-content"
  8. src="~/assets/image/activity/invite-user/cybz-content@2x.png"
  9. />
  10. <div class="cybz-content-text">
  11. <div class="cybz-content-text-item">分享好友</div>
  12. <div class="cybz-content-text-item">邀请购买云机</div>
  13. <div class="cybz-content-text-item">返星币换现金</div>
  14. </div>
  15. <v-btn class="share-button" rounded @click="share()">
  16. <template v-if="$userAgent.isApp">分享好友赚星币</template>
  17. <template v-else>复制链接分享好友赚星币</template>
  18. </v-btn>
  19. <!-- <button @click="share()">邀请</button> -->
  20. </div>
  21. <!-- <div class="h-40">13</div> -->
  22. </div>
  23. <div class="box box2">
  24. <div class="box-header">收益明细</div>
  25. <div class="box-main">
  26. <div class="grid grid-cols-2 gap-x-4 gap-y-8">
  27. <div
  28. v-for="(item, index) in dataList"
  29. :key="index"
  30. :class="{
  31. 'col-span-2': index === 6,
  32. }"
  33. >
  34. <div class="label text-sm">
  35. <span>{{ item.label }}</span>
  36. </div>
  37. <div class="value text-2xl font-bold">
  38. <span>{{ item.value | formatNumber }}</span>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. <!-- <div class="box box3">
  45. <div class="box-header">返利套餐</div>
  46. <div class="box-main"></div>
  47. </div> -->
  48. <div class="box box4">
  49. <div class="box-header">活动规则</div>
  50. <div class="box-main text-sm" v-html="activityRules">
  51. <!-- <p>1、传播过程中有任何疑问,可直接咨询客服</p>
  52. <p>
  53. 2、用户可以通过分享页面或者套餐给想要分享的人,被分享人购买云机套餐后,分享人可获得套餐对应的星币
  54. </p>
  55. <p>
  56. 3、星币为双子星云手机平台唯一认可代币,仅能通过充值、赠送和分享获得,其它渠道途径非法获取的星币,不受平台认可
  57. </p>
  58. <p>4、星币可在双子星购买任一等价值套餐</p>
  59. <p>
  60. 5、请勿利用双子星传播或扩散任何有关于政治、情色等任何违法的信息,一经发现,取消资格,如果触犯任何法律相关问题,平台不负任何责任
  61. </p> -->
  62. </div>
  63. </div>
  64. <!-- <div class="">invite-user</div> -->
  65. <!-- <button>刷新数据</button> -->
  66. <!-- <div class="">{{ data }}</div> -->
  67. <!-- <div class="text-center">
  68. <span>分享好友购买云机套餐<br />返星币换现金</span>
  69. </div>
  70. <div class="text-center mt-4">
  71. <van-button type="primary" @click="share()">邀请好友</van-button>
  72. </div>
  73. <van-icon name="chat-o" />
  74. <van-icon name="shape-plus" class-prefix="mdi" />
  75. <van-button @click="$fetch()">刷新</van-button>
  76. <div class="ccc">{{ 36666666.123456 | formatNumber }}</div>
  77. <div class="ccc">{{ '2020-01-01' | formatDate }}</div> -->
  78. </v-container>
  79. </template>
  80. <script>
  81. // import qs from 'qs';
  82. // import clipboard from 'clipboardy/browser';
  83. import * as clipboard from 'clipboard-polyfill/text';
  84. import { getStarCoinOverview } from '~/api/activity/invite-user.js';
  85. import { getContentByType } from '~/api/public/agreement.js';
  86. export default {
  87. // auth: false,
  88. name: 'InviteUser',
  89. filters: {},
  90. data() {
  91. return {
  92. data: {
  93. todayIncomeStarCoin: 0,
  94. totalIncomeStarCoin: 0,
  95. todayBuyOrderCount: 0,
  96. totalBuyOrderCount: 0,
  97. todayBuyOrderSuccessCount: 0,
  98. totalBuyOrderSuccessCount: 0,
  99. withdrawStarCoinNum: 0,
  100. inviteUserName: null,
  101. activityId: null,
  102. status: 0,
  103. },
  104. activityRules: '',
  105. };
  106. },
  107. async fetch() {
  108. //
  109. try {
  110. this.getActivityRules();
  111. this.data = (await getStarCoinOverview(this)).data;
  112. } catch (error) {
  113. this.$toast.error(error.message);
  114. }
  115. },
  116. head: {
  117. title: '邀请好友',
  118. // share: {
  119. // title: '标题',
  120. // content: '内容',
  121. // gotoUrl: 'http://localhost',
  122. // shareImg: 'http://localhost',
  123. // },
  124. },
  125. computed: {
  126. dataList() {
  127. return [
  128. { label: '今日收益(星币)', value: this.data.todayIncomeStarCoin },
  129. { label: '总收益(星币)', value: this.data.totalIncomeStarCoin },
  130. { label: '今日购买订单数', value: this.data.todayBuyOrderSuccessCount },
  131. { label: '累计推广订单', value: this.data.totalBuyOrderCount },
  132. {
  133. label: '今日购买成功客户',
  134. value: this.data.todayBuyOrderSuccessCount,
  135. },
  136. {
  137. label: '累计购买成功客户',
  138. value: this.data.totalBuyOrderSuccessCount,
  139. },
  140. // { label: '可提现星币数量', value: this.data.withdrawStarCoinNum },
  141. ];
  142. },
  143. },
  144. mounted() {
  145. this.$userAgent.isMiniProgram &&
  146. this.$wx.miniProgram.postMessage({
  147. data: {
  148. action: 'updateAppMessageShareData',
  149. params: {
  150. title: '双子星云手机',
  151. path: '/pages/home/home',
  152. imageUrl:
  153. location.origin +
  154. require('~/assets/image/activity/invite-user/bg@2x.png'),
  155. // promise: null,
  156. },
  157. },
  158. });
  159. },
  160. methods: {
  161. async share() {
  162. // console.log(this);
  163. if (this.data.status !== 1) {
  164. if (this.data.status === 0) {
  165. throw new Error('当前活动已过期');
  166. }
  167. if (this.data.status === 2) {
  168. throw new Error('当前活动未开启');
  169. }
  170. throw new Error('未知活动状态');
  171. }
  172. this.$tongji.trackEvent('活动', '分享', '', 0);
  173. const url =
  174. location.origin +
  175. this.$router.resolve({
  176. path: '/activity/invite-user/register',
  177. query: {
  178. invitationUserName: this.data.inviteUserName,
  179. activityId: this.data.activityId,
  180. },
  181. }).href;
  182. if (this.$userAgent.isMiniProgram) {
  183. // 小程序环境
  184. await clipboard.writeText(`${url} 唔即云手机`);
  185. this.$toast.success('链接复制成功');
  186. } else if (this.$userAgent.isApp) {
  187. // app环境
  188. this.$native.share({
  189. title: '双子星APP',
  190. content: '分享好友购买云机套餐,返星币换现金',
  191. gotoUrl: url,
  192. shareImg: 'sdsa.png',
  193. });
  194. } else {
  195. // 浏览器环境
  196. await clipboard.writeText(`${url} 唔即云手机`);
  197. // throw new Error('1231');
  198. this.$toast.success('链接复制成功');
  199. }
  200. },
  201. async getActivityRules() {
  202. const res = await getContentByType(this, 'iuserrules01');
  203. this.activityRules = res.data.content
  204. .replace(/[\d\D]*<body>([\d\D]+)<\/body>[\d\D]*/i, '$1')
  205. .replace(/<div class="phone-container">([\d\D]+)<\/div>/g, '$1');
  206. },
  207. },
  208. };
  209. </script>
  210. <style lang="scss" scoped>
  211. .invite-user {
  212. color: #333;
  213. background-image: url('~/assets/image/activity/invite-user/bg@2x.png');
  214. background-size: 100% auto;
  215. // background-position-y: -44px;
  216. overflow: hidden;
  217. padding-bottom: 30px;
  218. }
  219. .box {
  220. width: 373px;
  221. box-sizing: border-box;
  222. margin: auto;
  223. border-image-source: url('~/assets/image/activity/invite-user/box@2x.png');
  224. border-image-slice: 38 * 2 20 * 2 30 * 2 fill;
  225. // border-image-width: 200px;
  226. // border-image-slice: 200%;
  227. border-width: 38px 15px 15px;
  228. // border-width: 1px;
  229. border-style: solid;
  230. position: relative;
  231. + .box {
  232. margin-top: 30px;
  233. }
  234. .box-header {
  235. position: absolute;
  236. top: -30px;
  237. // left: 141px;
  238. left: 0;
  239. right: 0;
  240. text-align: center;
  241. padding: 0 130px;
  242. color: #fff;
  243. }
  244. .box-main {
  245. padding: 30px 15px 20px;
  246. }
  247. }
  248. .box1 {
  249. margin-top: 275px;
  250. .box-main {
  251. // padding: 30px 15px 20px;
  252. padding-left: 0;
  253. padding-right: 0;
  254. }
  255. .cybz-content {
  256. width: 305px;
  257. height: 75px;
  258. margin: auto;
  259. display: block;
  260. // margin-top: 30px;
  261. }
  262. .cybz-content-text {
  263. // display: flex;
  264. display: grid;
  265. // width: 305px;
  266. // padding: 0 28px;
  267. // align-items: center;
  268. // margin: auto;
  269. // justify-content: space-between;
  270. grid-template-columns: 1fr 1fr 1fr;
  271. font-size: 12px;
  272. color: #333;
  273. .cybz-content-text-item {
  274. // width: 0;
  275. // flex: auto;
  276. text-align: center;
  277. }
  278. }
  279. .share-button {
  280. display: block;
  281. margin: auto;
  282. width: 302px !important;
  283. height: 62px !important;
  284. background-image: url('~/assets/image/activity/invite-user/share-button@2x.png');
  285. background-size: 100% 100%;
  286. margin-top: 24px;
  287. // margin-bottom: 24px;
  288. color: #dd1b0d;
  289. font-size: 22px;
  290. font-weight: bold;
  291. }
  292. }
  293. .box2 {
  294. .label {
  295. // font-size: 14px;
  296. }
  297. .value {
  298. color: #ff6600;
  299. // font-size: 24px;
  300. }
  301. .box-main {
  302. padding-left: 20px;
  303. padding-right: 20px;
  304. }
  305. }
  306. .box4 {
  307. .box-main {
  308. // padding-left: 20px;
  309. // padding-top: 0;
  310. }
  311. }
  312. </style>