Invitation.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. <template>
  2. <view class="Invitation">
  3. <image src="https://s1.ax1x.com/2020/04/07/G2uBbd.png" mode="" style="width: 100%;height: 340px"></image>
  4. <view class="flex center" style="margin: -20px 0 0px;">
  5. <view class="flex column">
  6. <button open-type="share" class="round" style="position: relative;">
  7. <image src="https://lailemefresh.oss-cn-shanghai.aliyuncs.com/imgs/2YNSJW4NwsEf2ZD.png" mode="" style="width: 76px;height: 76px;"></image>
  8. <text style="position: absolute;top: 50px;left:0;width: 100%;font-size: 12px;">分享微信好友</text>
  9. </button>
  10. </view>
  11. <view class="" style="width: 32px;height: 0;">
  12. </view>
  13. <view class="flex column">
  14. <button @tap="shareFc()" class="round" style="position: relative;">
  15. <image src="https://lailemefresh.oss-cn-shanghai.aliyuncs.com/imgs/AdRP3QjijAimkQZ.png" mode="" style="width: 76px;height: 76px;"></image>
  16. <text style="position: absolute;top: 50px;left:0;width: 100%;font-size: 12px;">分享朋友圈</text>
  17. </button>
  18. </view>
  19. </view>
  20. <view class="btnBox flex">
  21. <view class="box">
  22. <view class="title">
  23. 我的邀请
  24. </view>
  25. <view class="content">
  26. <span class="number">{{invite_num}}</span>
  27. <span>人</span>
  28. </view>
  29. <view class="btn" @click="naviageToPage('/pages/InvitationList/InvitationList')">
  30. 点击查看
  31. </view>
  32. </view>
  33. <view class="box">
  34. <view class="title">
  35. 我的抢购券
  36. </view>
  37. <view class="content" style="color: #EE4F08;">
  38. <span class="number">{{coupen_num}}</span>
  39. <span>张</span>
  40. </view>
  41. <view class="btn" style="background-color: #EE4F08;" @click="naviageToPage('/pages/parity/PanicbuyingLIst')">
  42. 前往抢购
  43. </view>
  44. </view>
  45. </view>
  46. <view class="listBig" style="width: 100%;">
  47. <image src="https://lailemefresh.oss-cn-shanghai.aliyuncs.com/imgs/5riYrpyWDsj5Bek.png" mode="" style="width: 100%;height: 160px;"></image>
  48. <view class="listBox">
  49. <view class="list" v-for="(item,i) in list" :key="i">
  50. <view class="img" style="width: 227rpx;height: 227rpx;">
  51. <image :src="item.img" mode="" style="width: 100%;height: 100%;"></image>
  52. </view>
  53. <view class="right">
  54. <view class="" style="font-weight: Bold;margin-top: 12px;">
  55. {{item.title}}
  56. </view>
  57. <view class="flex" style="justify-content: space-between;margin: 7.5px;align-items: flex-end;">
  58. <view class="" style="color: #999999;text-decoration: line-through;">
  59. 市场价:{{item.otPrice}}
  60. </view>
  61. <view class="" style="font-size: 30px;color: #EE4F08;">
  62. {{item.kxStockVo.price}}
  63. </view>
  64. </view>
  65. <!-- <view class="btn">
  66. 立即领券
  67. </view> -->
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. <view class="flex_row_c_c modalView" :class="qrShow?'show':''" @tap="hideQr()">
  73. <view class="flex_column">
  74. <view class="backgroundColor-white padding1vh border_radius_10px">
  75. <image :src="poster.finalPath" mode="widthFix" class="posterImage"></image>
  76. </view>
  77. <view class="flex_row marginTop2vh">
  78. <button type="primary" size="mini" @tap.prevent.stop="saveImage()">保存图片</button>
  79. <!-- <button type="primary" size="mini" @tap.prevent.stop="share()">分享图片</button> -->
  80. </view>
  81. </view>
  82. </view>
  83. <!-- <button type="primary" @tap="shareFc()">生成海报</button> -->
  84. <view class="hideCanvasView">
  85. <canvas class="hideCanvas" canvas-id="default_PosterCanvasId" :style="{width: (poster.width||0) + 'px', height: (poster.height||0) + 'px'}"></canvas>
  86. </view>
  87. </view>
  88. </template>
  89. <script>
  90. import _app from '@/util/QS-SharePoster/app.js';
  91. import {
  92. getSharePoster
  93. } from '@/util/QS-SharePoster/QS-SharePoster.js';
  94. export default {
  95. data() {
  96. return {
  97. url: '',
  98. invite_num: 0,
  99. coupen_num: 0,
  100. list: [],
  101. p: '',
  102. poster: {},
  103. qrShow: false,
  104. canvasId: 'default_PosterCanvasId'
  105. };
  106. },
  107. mounted() {
  108. let that = this
  109. that.$api.request('get', 'inviteBuyingInfo', failres => {
  110. that.logining = false
  111. that.$api.msg(failres.msg)
  112. }).then(res => {
  113. console.log(res)
  114. that.p = res.data.p
  115. that.coupen_num = res.data.coupen_num
  116. that.invite_num = res.data.invite_num
  117. })
  118. that.$api.request('get', 'activityGoodsList', {
  119. activityType: 2,
  120. storageId: this.$store.state.storageId
  121. }, failres => {
  122. that.logining = false
  123. that.$api.msg(failres.msg)
  124. }).then(res => {
  125. console.log(res)
  126. that.list = res.data
  127. })
  128. },
  129. onLoad() {
  130. },
  131. onShareAppMessage() {
  132. return {
  133. title: '0.1限时大抢购',
  134. // imageUrl: this.goods.img,
  135. path: '/pages/share/inviteNewPeople?p=' + this.p,
  136. }
  137. },
  138. methods: {
  139. naviageToPage(page, title) {
  140. const that = this
  141. if (title) {
  142. console.log(title, 'jinlai')
  143. title ? title : ''
  144. uni.navigateTo({
  145. url: page + '&title=' + title
  146. })
  147. } else {
  148. console.log(page)
  149. uni.navigateTo({
  150. url: page
  151. })
  152. }
  153. // console.log(that.categoryButtomList[index].title)
  154. },
  155. share(type) {
  156. },
  157. async shareFc() {
  158. try {
  159. console.log('准备生成:' + new Date())
  160. const d = await getSharePoster({
  161. _this: this, //若在组件中使用 必传
  162. type: 'testShareType',
  163. formData: {
  164. //访问接口获取背景图携带自定义数据
  165. },
  166. posterCanvasId: this.canvasId, //canvasId
  167. delayTimeScale: 20, //延时系数
  168. /* background: {
  169. width: 1080,
  170. height: 1920,
  171. backgroundColor: '#666'
  172. }, */
  173. drawArray: ({
  174. bgObj,
  175. type,
  176. bgScale
  177. }) => {
  178. const dx = bgObj.width * 0.3;
  179. const fontSize = bgObj.width * 0.045;
  180. const lineHeight = bgObj.height * 0.04;
  181. //可直接return数组,也可以return一个promise对象, 但最终resolve一个数组, 这样就可以方便实现后台可控绘制海报
  182. return new Promise((rs, rj) => {
  183. rs([{
  184. type: 'custom',
  185. setDraw(Context) {
  186. Context.setFillStyle('black');
  187. Context.setGlobalAlpha(0.3);
  188. Context.fillRect(0, bgObj.height - bgObj.height * 0.2, bgObj.width, bgObj.height * 0.2);
  189. Context.setGlobalAlpha(1);
  190. }
  191. },
  192. {
  193. type: 'image',
  194. url: 'https://lailemefresh.oss-cn-shanghai.aliyuncs.com/imgs/iWWHE7rtFYTnG8t.jpg',
  195. alpha: .3,
  196. dx,
  197. dy: bgObj.height - bgObj.width * 0.25,
  198. infoCallBack(imageInfo) {
  199. let scale = bgObj.width * 0.2 / imageInfo.height;
  200. return {
  201. circleSet: {
  202. x: imageInfo.width * scale / 2,
  203. y: bgObj.width * 0.2 / 2,
  204. r: bgObj.width * 0.2 / 2
  205. }, // 圆形图片 , 若circleSet与roundRectSet一同设置 优先circleSet设置
  206. dWidth: imageInfo.width * scale, // 因为设置了圆形图片 所以要乘以2
  207. dHeight: bgObj.width * 0.2,
  208. /* roundRectSet: { // 圆角矩形
  209. r: imageInfo.width * .1
  210. } */
  211. }
  212. }
  213. },
  214. {
  215. type: 'text',
  216. fontStyle: 'italic',
  217. text: '取舍',
  218. size: fontSize,
  219. color: 'white',
  220. alpha: .5,
  221. textAlign: 'left',
  222. textBaseline: 'middle',
  223. infoCallBack(textLength) {
  224. _app.log('index页面的text的infocallback ,textlength:' + textLength);
  225. return {
  226. dx: bgObj.width - textLength - fontSize,
  227. dy: bgObj.height - lineHeight * 3
  228. }
  229. },
  230. serialNum: 0,
  231. id: 'tag1' //自定义标识
  232. },
  233. {
  234. type: 'text',
  235. text: '取舍',
  236. fontWeight: 'bold',
  237. size: fontSize,
  238. color: 'white',
  239. alpha: .75,
  240. textAlign: 'left',
  241. textBaseline: 'middle',
  242. serialNum: 1,
  243. allInfoCallback({ //v3.0.1 更新 可以获取drawArray中全部数据
  244. drawArray
  245. } = {}) {
  246. const obj = drawArray.find(item => item.id === 'tag1');
  247. /* return {
  248. dx: obj.dx,
  249. dy: obj.dy + lineHeight
  250. } */
  251. //也可以return promise对象
  252. return new Promise((rs, rj) => {
  253. setTimeout(() => {
  254. rs({
  255. dx: obj.dx,
  256. dy: obj.dy + lineHeight
  257. });
  258. }, 1);
  259. });
  260. }
  261. },
  262. {
  263. type: 'text',
  264. text: '取舍',
  265. size: fontSize,
  266. color: 'white',
  267. alpha: 1,
  268. textAlign: 'left',
  269. textBaseline: 'middle',
  270. infoCallBack(textLength) {
  271. return {
  272. dx: bgObj.width - textLength - fontSize,
  273. dy: bgObj.height - lineHeight
  274. }
  275. }
  276. },
  277. {
  278. type: 'image',
  279. url: 'https://lailemefresh.oss-cn-shanghai.aliyuncs.com/imgs/iWWHE7rtFYTnG8t.jpg',
  280. alpha: .3,
  281. dx: bgObj.width * 0.05,
  282. dy: bgObj.height - bgObj.width * 0.25,
  283. }
  284. // {
  285. // type: 'qrcode',
  286. // text: '你好,我是取舍',
  287. // size: bgObj.width * 0.2,
  288. // dx: bgObj.width * 0.05,
  289. // dy: bgObj.height - bgObj.width * 0.25
  290. // }
  291. ]);
  292. })
  293. },
  294. setCanvasWH: ({
  295. bgObj,
  296. type,
  297. bgScale
  298. }) => { // 为动态设置画布宽高的方法,
  299. this.poster = bgObj;
  300. }
  301. });
  302. console.log('海报生成成功, 时间:' + new Date() + ', 临时路径: ' + d.poster.tempFilePath)
  303. this.poster.finalPath = d.poster.tempFilePath;
  304. this.qrShow = true;
  305. } catch (e) {
  306. _app.hideLoading();
  307. _app.showToast(JSON.stringify(e));
  308. console.log(JSON.stringify(e));
  309. }
  310. },
  311. saveImage() {
  312. // #ifndef H5
  313. uni.saveImageToPhotosAlbum({
  314. filePath: this.poster.finalPath,
  315. success(res) {
  316. _app.showToast('保存成功');
  317. }
  318. })
  319. // #endif
  320. // #ifdef H5
  321. _app.showToast('保存了');
  322. // #endif
  323. },
  324. share() {
  325. // #ifdef APP-PLUS
  326. _app.getShare(false, false, 2, '', '', '', this.poster.finalPath, false, false);
  327. // #endif
  328. // #ifndef APP-PLUS
  329. _app.showToast('分享了');
  330. // #endif
  331. },
  332. hideQr() {
  333. this.qrShow = false;
  334. }
  335. }
  336. }
  337. </script>
  338. <style lang="scss">
  339. page {
  340. background-color: #F4F6FA;
  341. }
  342. .Invitation {
  343. // min-height: 100vh;
  344. .round {
  345. background: #F4F6FA;
  346. border: none;
  347. outline: none;
  348. width: 76px;
  349. height: 100px;
  350. border: none !important;
  351. padding: 0;
  352. }
  353. button::after {
  354. border: none !important;
  355. }
  356. .column {
  357. flex-flow: column;
  358. align-items: center;
  359. font-size: 12px;
  360. }
  361. .center {
  362. justify-content: center;
  363. }
  364. .btnBox {
  365. width: calc(100% - 30px);
  366. background-color: #fff;
  367. box-shadow: 1px 1px 10px -6px #404044;
  368. border-radius: 10px;
  369. padding: 20px 0 15px;
  370. position: relative;
  371. margin: 0 auto;
  372. &::after {
  373. display: block;
  374. content: '';
  375. width: 1px;
  376. height: 117px;
  377. background-color: #D8D9DE;
  378. position: absolute;
  379. top: 50%;
  380. left: 50%;
  381. transform: translate(-50%, -50%);
  382. }
  383. .title {
  384. color: #4E4C49;
  385. font-weight: bold;
  386. }
  387. .box {
  388. // height: 156rpx;
  389. width: 50%;
  390. display: flex;
  391. flex-flow: column;
  392. justify-content: space-around;
  393. align-items: center;
  394. text-align: center;
  395. .content {
  396. color: #B47D3C;
  397. .number {
  398. font-size: 100rpx;
  399. }
  400. }
  401. .btn {
  402. width: 100px;
  403. height: 30px;
  404. background-color: #D39F62;
  405. text-align: center;
  406. line-height: 30px;
  407. color: #fff;
  408. border-radius: 30rpx;
  409. }
  410. }
  411. }
  412. .listBig {
  413. position: relative;
  414. padding: 0 30rpx 18px;
  415. margin-top: 10rpx;
  416. .listBox {
  417. top: 60px;
  418. left: 50%;
  419. transform: translateX(-50%);
  420. width: calc(100% - 59rpx);
  421. position: absolute;
  422. }
  423. .list {
  424. width: 100%;
  425. display: flex;
  426. align-items: center;
  427. background-color: #fff;
  428. border-bottom: 1px solid #F7F4F8;
  429. padding: 22rpx;
  430. .img {
  431. margin-right: 46rpx;
  432. }
  433. .right {
  434. .btn {
  435. // width: 230rpx;
  436. // height: 60rpx;
  437. border: 1px solid #EE4F08;
  438. color: #EE4F08;
  439. border-radius: 50px;
  440. padding: 7rpx 37rpx;
  441. padding-right: 71rpx;
  442. position: relative;
  443. max-width: 120px;
  444. margin: 26rpx 0;
  445. &::after {
  446. display: block;
  447. content: '';
  448. width: 42rpx;
  449. height: 40rpx;
  450. position: absolute;
  451. top: 50%;
  452. right: 10px;
  453. transform: translateY(-50%);
  454. background: url(../../static/youhui.png) no-repeat center;
  455. background-size: 100% 100%;
  456. }
  457. }
  458. }
  459. }
  460. }
  461. }
  462. // 海报滴
  463. .hideCanvasView {
  464. position: relative;
  465. }
  466. .hideCanvas {
  467. position: fixed;
  468. top: -99999upx;
  469. left: -99999upx;
  470. z-index: -99999;
  471. }
  472. .flex_row_c_c {
  473. display: flex;
  474. flex-direction: row;
  475. justify-content: center;
  476. align-items: center;
  477. }
  478. .modalView {
  479. width: 100%;
  480. height: 100%;
  481. position: fixed;
  482. top: 0;
  483. left: 0;
  484. right: 0;
  485. bottom: 0;
  486. opacity: 0;
  487. outline: 0;
  488. transform: scale(1.2);
  489. perspective: 2500upx;
  490. background: rgba(0, 0, 0, 0.6);
  491. transition: all .3s ease-in-out;
  492. pointer-events: none;
  493. backface-visibility: hidden;
  494. z-index: 999;
  495. }
  496. .modalView.show {
  497. opacity: 1;
  498. transform: scale(1);
  499. pointer-events: auto;
  500. }
  501. .flex_column {
  502. display: flex;
  503. flex-direction: column;
  504. }
  505. .backgroundColor-white {
  506. background-color: white;
  507. }
  508. .border_radius_10px {
  509. border-radius: 10px;
  510. }
  511. .padding1vh {
  512. padding: 1vh;
  513. }
  514. .posterImage {
  515. width: 60vw;
  516. }
  517. .flex_row {
  518. display: flex;
  519. flex-direction: row;
  520. }
  521. .marginTop2vh {
  522. margin-top: 2vh;
  523. }
  524. </style>