12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- import {
- getVipInfo,
- } from '~/api/user'
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
- },
- /**
- * 组件的初始数据
- */
- data: {
- show: false,
- type: '',
- vipTime:''
- },
- methods: {
- open({
- type
- }) {
- if (typeof this.getTabBar === 'function') {
- this.getTabBar().setData({
- mask: true
- })
- }
- this.getVipInfo()
- this.setData({
- type,
- show: true
- })
- },
- closeModal() {
- this.setData({
- show: false
- })
- if (typeof this.getTabBar === 'function') {
- this.getTabBar().setData({
- mask: false
- })
- }
- },
- async getVipInfo() {
- let vipTime = await getVipInfo()
- console.log(vipTime);
- this.setData({
- vipTime
- })
- },
- creatShare() {
- let context = wx.createSelectorQuery();
- context
- .select('#vip')
- .fields({
- node: true,
- size: true
- }).exec((res) => {
- const canvas = res[0].node;
- const ctx = canvas.getContext('2d');
- const dpr = wx.getSystemInfoSync().pixelRatio;
- canvas.width = res[0].width * dpr;
- canvas.height = res[0].height * dpr;
- ctx.scale(dpr, dpr);
- ctx.font = '20px PingFang';
- let pic = canvas.createImage();
- pic.src = 'http://reader-wx.ai160.com/images/reader/v3/learn/vip1.png'
- pic.onload = () => {
- ctx.drawImage(pic, 0, 0, 375, 201);
- ctx.fillText('终身使用', 144, 135)
- ctx.fillStyle = 'red'
- setTimeout(() => {
- wx.canvasToTempFilePath({
- canvas: canvas,
- success(res) {
- wx.saveImageToPhotosAlbum({
- filePath: res.tempFilePath,
- success(res) {}
- })
- },
- fail(res) {
- console.log('fail', res);
- }
- }, this)
- }, 500)
- }
- })
- },
- }
- })
|