123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485 |
- const util = require("../../../utils/util.js");
- const app = getApp();
- Page({
- data: {
- shareImage: '',
- orderid: "",
- groupid: "",
- painting: {},
- info: {
- posters: [],
- },
- indicatorDots: true,
- current: 0,
- channel: 0,
- channelTimes: 0,
- sid: '',
- pid: '',
- groupbook: -1,
- status: 0,
- userInfo: app.globalData.userInfo,
- showConent: true,
- shareStatus: 1,
- makeTask: false //是否为宝贝币中心任务进入
- },
- onLoad(options) {
- console.log('options', options)
- if (options.channel != 0 && !util.isEmpty(options.channel)) {
- this.setData({ channel: options.channel, channelTimes: options.channelTimes });
- }
- let prePath = util.getPrePageRoute();
- this.setData({ id: options.id, orderid: options.orderid || '', groupid: options.groupid || '', userInfo: app.globalData.userInfo, sid: options.sid || '', pid: options.pid || '', groupbook: options.groupbook || -1, showConent: (prePath == 'pages/product/activity/index' || prePath == 'pages/account/monetaryCenter/posterTask') ? true : false, makeTask: options.makeTask });
- },
- onReady() {
- this.getActivity();
- },
- // 复制文案
- copyContent(e) {
- let val = e.currentTarget.dataset.data;
- wx.setClipboardData({
- data: val,
- success: function (res) {
- wx.showToast({
- title: '复制成功',
- icon: 'none'
- });
- }
- });
- },
- // 获取分享家是否停用
- stat() {
- let that = this;
- util.stat().then(res => {
- that.setData({ shareStatus: res.shareStatus })
- })
- },
- // 获取用户信息
- getActivity() {
- console.log(this.data.id);
- let that = this, data = { aid: that.data.id }, url = "article", params = {};//article ———— 二维码
- if (this.data.channel && this.data.channel != 0 && this.data.channelTimes == 1) {
- params.channelId = this.data.channel;
- params.channelCount = parseInt(this.data.channelTimes) + 1;
- }
- if (!util.isEmpty(that.data.orderid)) {
- url = "group";
- data.orderid = that.data.orderid;
- params.orderid = that.data.orderid;
- }
- if (!util.isEmpty(that.data.groupid)) {
- url = "group";
- data.groupid = that.data.groupid;
- params.groupid = that.data.groupid;
- }
- if (!util.isEmpty(that.data.id)) {
- params.aid = that.data.id;
- }
- if (!util.isEmpty(that.data.sid)) {
- params.sharesid = that.data.sid;
- }
- if (!util.isEmpty(that.data.pid)) {
- params.sharepid = that.data.pid;
- }
- params.code = this.data.userInfo.code;
- params.sharer = this.data.userInfo.nickname;
- data.params = JSON.stringify(params);
- console.log(data);
- console.log(url);
- util.ajax({
- func: "user/poster/" + url, // user/poster/article user/qrcode/group
- data: data // user/qrcode/article ——获取活动二维码
- }, function (res) {
- console.log(res);
- if (res.code == 0) {
- res.data.invitePrice = util.config.invitePrice;
- let tags = [];
- if (!util.isObjEmpty(res.data.tags)) {
- for (let i in res.data.tags) {
- tags.push(res.data.tags[i].tagValue);
- }
- }
- res.data.tags = tags.join("|");
- res.data.tags = res.data.tags.length > 37 ? res.data.tags.substring(0, 37) + ".." : res.data.tags;
- if (!util.isEmpty(res.data.avatar)) {
- wx.downloadFile({
- url: util.config.apiServer + "file.do?url=" + res.data.avatar,
- success(ret) {
- if (ret.statusCode === 200) {
- res.data.avatar = ret.tempFilePath;
- }
- that.setData({ info: res.data });
- that.cateQroce(data, url, res.data.qrcode, res.data.groupid);
- }
- });
- } else {
- res.data.avatar = "/images/default_logo.jpg";
- that.setData({ info: res.data });
- that.cateQroce(data, url, res.data.qrcode, res.data.groupid);
- }
- that.stat()
- } else
- util.showTips(res.reason);
- });
- },
- // 生成二维码
- cateQroce(data, url, qrcode, groupid) {
- console.log(url);
- let that = this;
- if (!util.isEmpty(that.data.orderid)) data.groupid = groupid;
- console.log(data);
- util.ajax({
- func: "user/qrcode/" + url,
- data: data
- }, function (res) {
- console.log(res);
- if (res.code == 0) {
- console.log(res);
- that.data.info.qrcode = res.data;
- that.setData({ info: that.data.info });
- } else
- util.showTips(res.reason);
- });
- },
- swiperChange(e) {
- let current = e.detail.current;
- this.setData({ current: e.detail.current });
- },
- // 记录分享次数
- shareRecord(aid) {
- if (!util.isEmpty(aid)) {
- util.ajax({
- func: 'article/share',
- data: { "aid": aid },
- load: false
- }), function (res) {
- console.log(res)
- }
- }
- },
- cetaInvite() {
- // this.shareRecord(this.data.id)
- wx.showLoading({
- title: '海报生成中'
- });
- let that = this, views = [];
- if (this.data.current < this.data.info.posters.length) {
- let poster = this.data.info.posters[this.data.current];
- console.log(poster.posterPic);
- views.push({
- type: 'image',
- url: poster.posterPic,
- top: 0,
- left: 0,
- width: poster.posterWidth,
- height: poster.posterHeight
- },
- // that.data.info.qrcode
- // https://img.bbztx.com/images/upload/thumbs/20221212/logo/1670811442549004585.png
- {
- type: 'image',
- url: that.data.info.qrcode,
- top: poster.posterHeight - poster.qrcodeY - poster.qrcodeHeight,
- left: poster.qrcodeX,
- width: poster.qrcodeWidth,
- height: poster.qrcodeHeight
- })
- this.setData({
- painting: {
- width: poster.posterWidth,
- height: poster.posterHeight,
- clear: true,
- views: views
- }
- });
- } else if (this.data.current === this.data.info.posters.length) {
- if (!util.isEmpty(that.data.orderid)) {
- views.push({
- type: 'image',
- url: "https://img.bbztx.com/images/upload/thumbs/20221212/logo/1670814536619084888.jpg",
- top: 0,
- left: 0,
- width: 750,
- height: 1332
- },
- // that.data.info.qrcode
- // https://img.bbztx.com/images/upload/thumbs/20221212/logo/1670811442549004585.png
- {
- type: 'image',
- url: that.data.info.qrcode,
- top: 1078,
- left: 488,
- width: 210,
- height: 210
- },
- {
- type: 'image',
- url: that.data.info.avatar,
- borderRadius: 65,
- top: 268,
- left: 310,
- width: 139,
- height: 139
- },
- {
- type: 'image',
- url: that.data.info.logo,
- top: 542,
- left: 18,
- width: 712,
- height: 370
- },
- {
- type: 'text',
- content: that.data.info.discountPrice,
- fontSize: 40,
- bolder: true,
- color: '#ee3a43',
- textAlign: 'left',
- top: 482,
- left: 460
- },
- {
- type: 'text',
- content: that.data.info.nickname + " 邀您拼团",
- fontSize: 32,
- color: '#3e3a39',
- textAlign: 'center',
- top: 420,
- left: 750 / 2
- },
- {
- type: 'text',
- content: that.data.info.tags,
- fontSize: 24,
- color: '#ee3a43',
- textAlign: 'left',
- MaxLineNumber: 1,
- breakWord: true,
- lineHeight: 30,
- top: 927,
- left: 50,
- width: 650
- },
- {
- type: 'text',
- content: "活动费",
- fontSize: 26,
- color: '#595757',
- textAlign: 'left',
- top: 990,
- left: 50
- },
- {
- type: 'text',
- content: "¥",
- fontSize: 18,
- color: '#ee3a43',
- textAlign: 'left',
- top: 995,
- left: 168
- },
- {
- type: 'text',
- content: that.data.info.price,
- fontSize: 26,
- bolder: true,
- color: '#ee3a43',
- textAlign: 'left',
- top: 990,
- left: 186
- });
- } else {
- views.push({
- type: 'image',
- url: 'https://img.bbztx.com/images/upload/thumbs/20221110/logo/1668071284848082519.jpg',
- top: 0,
- left: 0,
- width: 750,
- height: 1332
- },
- {
- type: 'image',
- url: that.data.info.logo,
- top: 235,
- left: 71,
- arcType: "arc",
- borderRadius: 12,
- width: 604,
- height: 311
- },
- {
- type: 'image',
- url: that.data.info.qrcode,
- top: 1036,
- left: 65,
- width: 210,
- height: 210
- },
- {
- type: 'image',
- url: that.data.info.avatar,
- borderRadius: 47,
- top: 105,
- left: 80,
- width: 100,
- height: 100
- },
- {
- type: 'text',
- content: that.data.info.tags,
- fontSize: 24,
- color: '#ee3a43',
- textAlign: 'left',
- top: 580,
- left: 70
- },
- {
- type: 'text',
- content: " " + that.data.info.commentContent,
- MaxLineNumber: 4,
- lineHeight: 50,
- breakWord: true,
- fontSize: 28,
- width: 580,
- color: '#333333',
- textAlign: 'justify',
- top: 745,
- left: 70
- },
- {
- type: 'text',
- content: "活动费",
- fontSize: 28,
- color: '#333333',
- textAlign: 'left',
- top: 630,
- left: 70
- },
- {
- type: 'text',
- content: "¥",
- fontSize: 18,
- color: '#ee3a43',
- textAlign: 'left',
- top: 640,
- left: 168
- },
- {
- type: 'text',
- content: that.data.info.price,
- fontSize: 32,
- color: '#ee3a43',
- textAlign: 'left',
- top: 630,
- left: 186
- },
- {
- type: 'text',
- content: that.data.info.nickname,
- fontSize: 32,
- color: '#231815',
- textAlign: 'left',
- top: 120,
- left: 200
- },
- {
- type: 'text',
- content: that.data.userInfo.roleType == 'normal' || that.data.userInfo.roleTypeDisable == 1 ? "让宝贝探索属于自己的世界" : "邀你参加活动,送你" + util.config.invitePrice + "元新人现金券",
- fontSize: 22,
- color: '#231815',
- textAlign: 'left',
- top: 160,
- left: 200
- });
- }
- if (that.data.info.psAttendCount > 10) {
- views.push({
- type: 'text',
- content: "已售" + that.data.info.psAttendCount + "人",
- fontSize: 24,
- color: '#898989',
- textAlign: 'right',
- top: !util.isEmpty(that.data.orderid) ? 992 : 630,
- left: !util.isEmpty(that.data.orderid) ? 700 : 675
- })
- }
- this.setData({
- painting: {
- width: 750,
- height: 1332,
- clear: true,
- views: views
- }
- });
- }
- },
- swiperGetImage(event) {
- const { tempFilePath, errMsg } = event.detail;
- const current = event.currentTarget.dataset.current;
- if (errMsg === 'canvasdrawer:ok') {
- this.data.img.push(tempFilePath)
- this.data.info.posters[current].canvasImage = tempFilePath;
- this.setData({
- info: this.data.info,
- img: this.data.img,
- });
- wx.hideLoading();
- }
- },
- eventGetImage(event) {
- const { tempFilePath, errMsg } = event.detail;
- if (errMsg === 'canvasdrawer:ok') {
- wx.saveImageToPhotosAlbum({
- filePath: tempFilePath,
- success(res) {
- console.log('saveImageToPhotosAlbum-res', res)
- wx.showToast({
- title: '保存图片成功',
- icon: 'success',
- duration: 2000,
- success: () => {
- if (this.data.makeTask) {
- wx.navigateBack()
- }
- }
- })
- },
- fail(err) {
- console.log('saveImageToPhotosAlbum-err', err)
- if (err.errMsg === "saveImageToPhotosAlbum:fail:auth denied" || err.errMsg === "saveImageToPhotosAlbum:fail auth deny" || err.errMsg === "saveImageToPhotosAlbum:fail authorize no response") {
- wx.showModal({
- title: '提示',
- content: '需要您授权保存相册',
- showCancel: false,
- success: modalSuccess => {
- wx.openSetting({
- success(settingdata) {
- console.log("settingdata", settingdata)
- if (settingdata.authSetting['scope.writePhotosAlbum']) {
- wx.showModal({
- title: '提示',
- content: '获取权限成功,再次点击即可保存!',
- showCancel: false,
- })
- } else {
- wx.showModal({
- title: '提示',
- content: '获取权限失败,将无法保存到相册。',
- showCancel: false,
- })
- }
- }
- })
- }
- })
- }
- }
- });
- wx.hideLoading();
- }
- }
- })
|