| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import common from '../../utils/util';
- import server from '../../utils/main';
- const app = getApp();
- var imageIndex = 0;
- var arrBuildImageSource = [];
- var arrBuildImageTarget = [];
- Page({
- data: {
- },
- onLoad: function (options) {
- this.setData({
- Height: common.getSystemHeight(),
- });
- },
- onUnload: function () {
- wx.setStorageSync("IsShare", true);
- },
- buildShareImage: function () {
- imageIndex = 0;
- arrBuildImageSource = [];
- for (var i = 2; i < 6; i++)
- arrBuildImageSource.push("../../images/programsystem_screenshot_pic0" + i + ".png");
- arrBuildImageTarget = [];
- this.buildImage();
- },
- buildImage: function () {
- var that = this;
- var ctx = wx.createCanvasContext("MyCanvas", this);
- ctx.drawImage(arrBuildImageSource[imageIndex], 0, 0, 400, 300);
- var avatar = wx.getStorageSync("Avatar");
- if (avatar) {
- ctx.drawImage(avatar, 15, 250, 40, 40);
- ctx.drawImage("../../images/universalpic_mask_face_size01.png", 13, 248, 44, 44);
- ctx.fillStyle = "#ffffff";
- ctx.setFontSize(14);
- ctx.fillText(app.globalData.userInfo.NickName, 65, 264);
- }
- ctx.draw(true, function (n) {
- wx.canvasToTempFilePath({
- x: 0,
- y: 0,
- width: 400,
- height: 300,
- canvasId: 'MyCanvas',
- success: function (res2) {
- console.log(res2.tempFilePath);
- arrBuildImageTarget.push(res2.tempFilePath);
- if (arrBuildImageTarget.length < arrBuildImageSource.length) {
- imageIndex++;
- that.buildImage();
- }
- else {
- wx.previewImage({
- current: arrBuildImageTarget[0], // 当前显示图片的http链接
- urls: arrBuildImageTarget // 需要预览的图片http链接列表
- });
- }
- }
- })
- });
- },
- onShareAppMessage: function () {
- return {
- title: app.globalData.ShareTitle,
- path: 'pages/index/index?UserID=' + app.globalData.userInfo.UserID,
- imageUrl: app.globalData.ShareImageUrl,
- }
- },
- });
|