123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833 |
- const app = getApp();
- var utils = require("../../../utils/http");
- const util = require("../../../utils/util");
- let winwidth = 0, allquery = '';
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- imgUrl: app.globalData.imgUrl,
- src: '',
- type: '',
- aid: '',
- cangth: 0,
- shareImg: '',
- posterimg: '',
- qrcodeimg: '',
- title: '',
- aType: '',
- listshare: false,
- openSet: false,
- vrtype: '',
- vrurl: '',
- employee_uid: "",
- agent_id: "",
- bType: "",
- fromType: ""
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- let that = this;
- this.setData({
- type: options.type,
- aid: options.aid,
- listshare: options.listshare ? true : false,
- vrtype: options.vrtype ? options.vrtype : '',
- vrurl: options.turl ? options.turl : ''
- })
- if (!!options.tp) {
- this.setData({
- aType: options.tp
- })
- }
- if (!!options.ty) {
- this.setData({
- bType: options.ty
- })
- }
- if (!!options.f) {
- this.setData({
- fromType: options.f
- })
- }
- wx.showLoading({
- title: '加载中...',
- })
- wx.getSystemInfo({
- success: (res) => {
- winwidth = res.windowWidth;
- }
- })
- if (that.data.listshare) {
- if (this.data.type == 'materialCase') {
- allquery = '&u=' + app.globalData.personMsg.id + '&c=' + options.c + '&s=' + options.s + '&st=' + options.st + '&e=' + options.e + '&h=' + options.h;
- }
- if (this.data.type == 'materialEvidence') {
- allquery = 'uid=' + app.globalData.personMsg.id + '&cate=' + options.cate;
- }
- if (this.data.type == 'video') {
- allquery = "uid=" + app.globalData.personMsg.id + "&ftext=" + options.ftext + "&nText=" + options.nText;
- }
- }
- if (this.data.type == 'shareArticle') {
- this.addsharetap();
- } else {
- this.sharelogtap();
- }
- },
- addsharetap: function () {
- let that = this;
- utils.$post({
- url: app.globalData.webUrl + 'api/agentsWork/agent_sharelog',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- type: "AgentArticle",
- article_id: that.data.aid,
- },
- success: function (r) { }
- })
- },
- sharelogtap: function (e) {
- var that = this;
- utils.$post({
- url: app.globalData.webUrl + 'api/share/addlog',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: that.data.aid,
- type: that.data.type == 'vr' ? (that.data.vrtype + '_vr') : that.data.type,
- other_data: that.data.type == 'vr' ? that.data.vrurl : ''
- },
- success: function (r) {
- }
- })
- },
- postermsg: function () {
- let that = this;
- if (that.data.listshare) {
- if (this.data.type == 'materialCase') {
- that.setData({
- posterimg: app.globalData.imgUrl + 'xcx/caseposter.jpg',
- title: "案例列表"
- })
- }
- if (this.data.type == 'materialEvidence') {
- that.setData({
- posterimg: app.globalData.imgUrl + 'xcx/praiseimg.jpg',
- title: "客户好评"
- })
- }
- if (this.data.type == 'video') {
- that.setData({
- posterimg: app.globalData.imgUrl + 'xcx/videoposter.png',
- title: "拓客视频"
- })
- }
- that.getcodeimg()
- return false;
- }
- if (that.data.type == 'activity') {
- if (that.data.aType && that.data.aType == 'broker') {
- utils.$post({
- url: app.globalData.webUrl + 'api/agents_work/activity_detail',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: that.data.aid,
- uid: app.globalData.personMsg.id
- },
- success: function (res) {
- if (res.data.code == '0') {
- that.setData({
- posterimg: res.data.data.cover,
- title: res.data.data.title
- })
- }
- that.getcodeimg()
- }
- })
- } else {
- utils.$post({
- url: app.globalData.webUrl + 'api/activity/details',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: that.data.aid,
- uid: app.globalData.personMsg.id
- },
- success: function (res) {
- if (res.data.code == '0') {
- that.setData({
- posterimg: res.data.data.poster,
- title: res.data.data.title
- })
- }
- that.getcodeimg()
- }
- })
- }
- }
- if (this.data.type == 'materialCase') {
- utils.$get({
- url: app.globalData.webUrl + 'api/casedetail',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: this.data.aid,
- uid: app.globalData.personMsg.id,
- },
- success: function (res) {
- if (res.data.code == '0') {
- res.data.data.cover_img = res.data.data.cover_img.replace('http://o.nczyzs.com/', 'https://o.nczyzs.com/');
- that.setData({
- posterimg: res.data.data.cover_img,
- title: res.data.data.title
- })
- }
- that.getcodeimg()
- }
- })
- }
- if (this.data.type == 'materialEvidence') {
- utils.$get({
- url: app.globalData.webUrl + 'api/evidencedetail',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: that.data.aid,
- uid: app.globalData.personMsg.id,
- },
- success: function (res) {
- if (res.data.code == '0') {
- let img = res.data.data.difference == 1 ? (res.data.data.cover ? res.data.data.cover : (res.data.data.pics[0] + '?x-oss-process=video/snapshot,t_100,f_jpg,w_375,m_fast')) : res.data.data.pics[0];
- img = img.replace('http://o.nczyzs.com/', 'https://o.nczyzs.com/');
- that.setData({
- posterimg: img,
- title: res.data.data.title
- })
- }
- that.getcodeimg()
- }
- })
- }
- if (this.data.type == 'video') {
- utils.$post({
- url: app.globalData.webUrl + 'api/video/info',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- video_id: that.data.aid
- },
- success: function (rs) {
- if (rs.data.code == '0') {
- that.setData({
- posterimg: rs.data.data.cover ? rs.data.data.cover : (rs.data.data.video_url + '?x-oss-process=video/snapshot,t_100,f_jpg,w_500,m_fast'),
- title: rs.data.data.title
- })
- }
- that.getcodeimg()
- }
- })
- }
- if (this.data.type == 'article') {
- utils.$post({
- url: app.globalData.webUrl + 'api/article/info',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- article_id: that.data.aid
- },
- success: function (res) {
- if (res.data.code == '0') {
- that.setData({
- posterimg: res.data.data.cover_img,
- title: res.data.data.title
- })
- }
- that.getcodeimg()
- }
- })
- }
- if (this.data.type == 'Construction') {
- utils.$post({
- url: app.globalData.webUrl + 'api/construction/view',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: that.data.aid
- },
- success: function (res) {
- if (res.data.code == '0') {
- that.setData({
- posterimg: res.data.data.cover,
- title: res.data.data.name
- })
- }
- that.getcodeimg()
- }
- })
- }
- if (this.data.type == 'shareArticle') {
- utils.$post({
- url: app.globalData.webUrl + 'api/agentsWork/share_article_details',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- from: that.data.fromType,
- id: that.data.aid
- },
- success: function (res) {
- wx.hideLoading();
- if (res.data.code == '0') {
- let imgUrl = '';
- if (that.data.fromType == 2) {
- if (res.data.data.type == 1) {
- imgUrl = res.data.data.file[0] + '?x-oss-process=video/snapshot,t_100,f_jpg,w_200,m_fast';
- } else if (res.data.data.type == 3) {
- imgUrl = res.data.data.file_img;
- } else {
- imgUrl = res.data.data.file[0];
- }
- } else {
- if (res.data.data.type == 1) {
- imgUrl = res.data.data.file[0] + '?x-oss-process=video/snapshot,t_100,f_jpg,w_200,m_fast';
- } else {
- imgUrl = res.data.data.file[0];
- }
- }
-
- that.setData({
- posterimg: imgUrl,
- title: res.data.data.title
- })
- that.getcodeimg()
- }
- }
- })
- }
- if (this.data.type == 'building') {
- utils.$post({
- url: app.globalData.webUrl + 'api/building/view',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: that.data.aid
- },
- success: function (res) {
- if (res.data.code == '0') {
- that.setData({
- posterimg: res.data.data.cover[0],
- title: res.data.data.name
- })
- }
- that.getcodeimg()
- }
- })
- }
- if (this.data.type == 'buildingProgress') {
- utils.$post({
- url: app.globalData.webUrl + 'client/building/progress_detail',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: that.data.aid
- },
- success: function (res) {
- if (res.data.code == '0') {
- let data = res.data.data;
- if (data.type == 'video') {
- if (data.img && data.img.length) {
- that.setData({
- posterimg: data.img[0],
- title: `${data.building_name}-${data.name}`
- })
- } else {
- that.setData({
- posterimg: `${data.video}?x-oss-process=video/snapshot,t_100,f_jpg,w_200,m_fast`,
- title: `${data.building_name}-${data.name}`
- })
- }
- } else if (data.type == 'img') {
- that.setData({
- posterimg: data.img[0],
- title: `${data.building_name}-${data.name}`
- })
- } else {
- that.setData({
- posterimg: data.vr[0]['vrfirstImg'],
- title: `${data.building_name}-${data.name}`
- })
- }
- }
- that.getcodeimg()
- }
- })
- }
- if (this.data.type == 'CompanyStrength') {
- utils.$post({
- url: app.globalData.webUrl + 'api/company_strength/read',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: that.data.aid
- },
- success: function (res) {
- if (res.data.code == '0') {
- let img = res.data.data.difference == 1 ? (res.data.data.cover ? res.data.data.cover : (res.data.data.pics + '?x-oss-process=video/snapshot,t_100,f_jpg,w_375,m_fast')) : res.data.data.cover;
- img = img.replace('http://o.nczyzs.com/', 'https://o.nczyzs.com/');
- that.setData({
- posterimg: img,
- title: res.data.data.title
- })
- }
- that.getcodeimg()
- }
- })
- }
- if (this.data.type == 'vr') {
- let title, imgurl;
- if (this.data.vrtype == 'company') {
- title = "在线逛展厅-" + app.globalData.companyobj.company_name;
- imgurl = app.globalData.imgUrl + 'xcx/aaa/vrcover.png';
- that.setData({
- posterimg: imgurl,
- title: title
- })
- that.getcodeimg()
- } else if (this.data.vrtype == 'employeeCard') {
- title = app.globalData.companyobj.company_name + 'VR寻址';
- imgurl = app.globalData.imgUrl + "/xcx/sharenamecard.png";
- that.setData({
- posterimg: imgurl,
- title: title
- })
- that.getcodeimg()
- } else if (this.data.vrtype == 'materialCase') {
- utils.$get({
- url: app.globalData.webUrl + 'client/casedetail',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: this.data.aid,
- share: '146'
- },
- success: function (res) {
- if (res.data.code == '0') {
- title = res.data.data.title + '的VR';
- imgurl = res.data.data.cover_img;
- that.setData({
- posterimg: imgurl,
- title: title
- })
- that.getcodeimg()
- }
- }
- })
- } else if (this.data.vrtype == 'building') {
- utils.$get({
- url: app.globalData.webUrl + 'client/building/view',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: this.data.aid,
- share: '146'
- },
- success: function (res) {
- if (res.data.code == '0') {
- title = res.data.data.name + '的VR';
- imgurl = res.data.data.cover;
- that.setData({
- posterimg: Array.isArray(imgurl) && imgurl.length ? imgurl[0] : imgurl,
- title: title
- })
- that.getcodeimg()
- }
- }
- })
- } else if (this.data.vrtype == 'construction') {
- utils.$post({
- url: app.globalData.webUrl + 'client/construction/view',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: this.data.aid,
- share: '146'
- },
- success: function (res) {
- if (res.data.code == '0') {
- title = res.data.data.name + '的VR';
- imgurl = res.data.data.cover;
- that.setData({
- posterimg: imgurl,
- title: title
- })
- that.getcodeimg()
- }
- }
- })
- }
- }
- if (this.data.type == 'housetype') {
- utils.$post({
- url: app.globalData.webUrl + 'api/building/housetype_detail',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: that.data.aid
- },
- success: function (res) {
- if (res.data.code == '0') {
- let data = res.data.data;
- let posterCover = "";
- if (data.house_img && Array.isArray(data.house_img) && data.house_img.length) {
- posterCover = data.house_img[0];
- } else {
- posterCover = data.vr_link_img;
- }
- if (data.room == 9) {
- data.shareTitle = "别墅";
- } else {
- data.shareTitle = `${data.room}室${data.hall}厅${data.bathroom}卫`;
- }
- that.setData({
- posterimg: posterCover,
- title: data.shareTitle
- })
- }
- that.getcodeimg()
- }
- })
- }
- },
- getcodeimg: function () {
- let that = this, query = '', path = '';
- if (that.data.listshare) {
- if (this.data.type == 'materialCase') {
- query = allquery + '&ctp=' + app.globalData.clientype;
- path = 'share/pages/caselist/caselist'
- }
- if (this.data.type == 'materialEvidence') {
- query = allquery + '&ctp=' + app.globalData.clientype;
- path = 'share/pages/praiselist/praiselist'
- }
- if (this.data.type == 'video') {
- query = allquery + '&ctp=' + app.globalData.clientype;
- path = 'share/pages/videolist/videolist'
- }
- } else {
- if (that.data.type == 'activity') {
- if (that.data.aType && that.data.aType == 'broker') {
- query = 'aid=' + this.data.aid + '&bid=' + app.globalData.brokeruserId + '&ctp=' + app.globalData.clientype + '&t=b';
- path = 'share/pages/activitymsg/activitymsg';
- } else {
- query = 'aid=' + this.data.aid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype;
- path = 'share/pages/activitymsg/activitymsg';
- }
- }
- if (this.data.type == 'materialCase') {
- if (this.data.bType == 'b') {
- query = 'a=' + that.data.aid + '&u=' + app.globalData.agentEmployeEid + '&c=' + app.globalData.clientype + "&g=" + app.globalData.brokeruserId;
- path = 'share/pages/materialcase/materialcase';
- } else {
- query = 'cid=' + that.data.aid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype;
- path = 'share/pages/materialcase/materialcase';
- }
- }
- if (this.data.type == 'materialEvidence') {
- if (this.data.bType == 'b') {
- query = 'e=' + that.data.aid + '&u=' + app.globalData.agentEmployeEid + '&c=' + app.globalData.clientype + "&g=" + app.globalData.brokeruserId;
- path = 'share/pages/publicpraisemsg/publicpraisemsg';
- } else {
- query = 'eid=' + that.data.aid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype;
- path = 'share/pages/publicpraisemsg/publicpraisemsg';
- }
- }
- if (this.data.type == 'CompanyStrength') {
- if (this.data.bType == 'b') {
- query = 'e=' + that.data.aid + '&u=' + app.globalData.agentEmployeEid + '&c=' + app.globalData.clientype + "&g=" + app.globalData.brokeruserId;
- path = 'share/pages/companystrengthmsg/companystrengthmsg';
- } else {
- query = 'eid=' + that.data.aid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype;
- path = 'share/pages/companystrengthmsg/companystrengthmsg';
- }
-
- }
- if (this.data.type == 'video') {
- if (this.data.bType == 'b') {
- query = 'v=' + that.data.aid + '&u=' + app.globalData.agentEmployeEid + '&c=' + app.globalData.clientype + "&g=" + app.globalData.brokeruserId;
- path = 'share/pages/videoshare/videoshare';
- } else {
- query = 'vid=' + that.data.aid + '&userid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype;
- path = 'share/pages/videoshare/videoshare';
- }
- }
- if (this.data.type == 'article') {
- if (this.data.bType == 'b') {
- query = 'a=' + that.data.aid + '&u=' + app.globalData.agentEmployeEid + '&c=' + app.globalData.clientype + "&g=" + app.globalData.brokeruserId;
- path = 'share/pages/articleshare/articleshare';
- } else {
- query = 'aid=' + that.data.aid + '&userid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype;
- path = 'share/pages/articleshare/articleshare';
- }
- }
- if (this.data.type == 'spellgroup') {
- query = 'a=' + that.data.aid + '&u=' + app.globalData.personMsg.id + '&t=' + '&e=' + app.globalData.personMsg.binded.id + '&p=' + app.globalData.clientype;
- path = 'share/pages/collagemsg/collagemsg';
- }
- if (this.data.type == 'Construction') {
- query = 'cid=' + that.data.aid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype;
- path = 'share/pages/constructsite/constructsite';
- }
- if (this.data.type == 'building') {
- if (this.data.bType == 'b') {
- query = 'u=' + app.globalData.agentEmployeEid + '&c=' + that.data.aid + '&t=' + app.globalData.clientype + "&g=" + app.globalData.brokeruserId;
- path = 'share/pages/buildprogress/buildprogress';
- } else {
- query = 'u=' + app.globalData.personMsg.id + '&c=' + that.data.aid + '&e=' + app.globalData.personMsg.binded.id + '&t=' + app.globalData.clientype;
- path = 'share/pages/buildprogress/buildprogress';
- }
- }
- if (this.data.type == 'buildingProgress') {
- query = 'u=' + app.globalData.personMsg.id + '&c=' + that.data.aid + '&e=' + app.globalData.personMsg.binded.id + '&t=' + app.globalData.clientype;
- path = 'share/pages/buildShare/buildShare';
- }
- if (this.data.type == 'vr') {
- query = 'c=' + app.globalData.clientype + '&u=' + app.globalData.personMsg.id + '&a=' + this.data.aid + '&y=' + this.data.vrtype + '&l=' + this.data.vrurl;
- path = 'pages/other/other';
- }
- if (this.data.type == 'shareArticle') {
- query = 'c=' + this.data.aid + '&u=' + app.globalData.agentEmployeEid + '&ct=' + app.globalData.clientype + '&ag=' + app.globalData.brokeruserId + '&f='+this.data.fromType;
- path = 'share/pages/brokershareinfo/brokershareinfo';
- }
- if (this.data.type == 'housetype') {
- if (this.data.bType == 'b') {
- query = 'd=' + that.data.aid + '&u=' + app.globalData.agentEmployeEid + '&c=' + app.globalData.clientype + "&g=" + app.globalData.brokeruserId;
- path = 'share/pages/housetype/housetype';
- } else {
- query = 'd=' + that.data.aid + '&u=' + app.globalData.personMsg.id + '&c=' + app.globalData.clientype;
- path = 'share/pages/housetype/housetype';
- }
- }
- }
- utils.$post({
- url: app.globalData.webUrl + 'api/share/qrcode',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- query: query,
- path: path
- },
- success: function (res) {
- if (res.data.code == "0") {
- that.setData({
- qrcodeimg: res.data.data
- })
- setTimeout(function () {
- that.createdCode();
- }, 300)
- }
- },
- fail() {
- }
- })
- },
- //开始绘图
- createdCode: function () {
- let that = this;
- if (that.data.title.length > 15) {
- that.setData({
- title: that.data.title.substring(0, 13) + '...'
- })
- }
- let topwidth = winwidth * 710 / 750, topheight = '';
- const ctx = wx.createCanvasContext('myCanvas'); //绘图上下文
- wx.getImageInfo({
- src: that.data.posterimg,
- success(res) {
- wx.getImageInfo({
- src: that.data.qrcodeimg,
- success(rs) {
- topheight = topwidth * res.height / res.width;
- that.setData({
- cangth: topheight + 110
- })
- ctx.save();
- ctx.drawImage(res.path, 0, 0, topwidth, topheight);
- ctx.rect(0, topheight, topwidth, 110);
- ctx.setFillStyle('#FFFFFF');
- ctx.fill();
- ctx.restore()
- ctx.setFontSize(14);
- ctx.fillText("@" + (app.globalData.personMsg.binded&&app.globalData.personMsg.binded.name?app.globalData.personMsg.binded.name:app.globalData.personMsg.nickname), 12, topheight + 44, topwidth - 70);
- ctx.fillText(that.data.title, 12, topheight + 66, topwidth - 70);
- ctx.drawImage(rs.path, topwidth - 100, topheight + 12, 88, 88);
- ctx.draw();
- wx.hideLoading();
- setTimeout(() => {
- wx.canvasToTempFilePath({
- x: 0,
- y: 0,
- canvasId: 'myCanvas',
- success: function (res) {
- let shareImg = res.tempFilePath;
- that.setData({
- shareImg: shareImg,
- })
- },
- fail: function (res) { }
- })
- }, 500)
- }, fail(res) {
- console.log(res)
- },
- })
- }, fail(res) {
- console.log(res)
- }
- })
- },
- saveimgtap: function () {
- let that = this;
- // 获取用户是否开启用户授权相册
- wx.getSetting({
- success(res) {
- // 如果没有则获取授权
- if (!res.authSetting['scope.writePhotosAlbum']) {
- wx.authorize({
- scope: 'scope.writePhotosAlbum',
- success() {
- wx.saveImageToPhotosAlbum({
- filePath: that.data.shareImg,
- success() {
- wx.showToast({
- title: '保存成功'
- })
- },
- fail() {
- wx.showToast({
- title: '保存失败',
- icon: 'none'
- })
- }
- })
- },
- fail() {
- // 如果用户拒绝过或没有授权,则再次打开授权窗口
- //(ps:微信api又改了现在只能通过button才能打开授权设置,以前通过openSet就可打开,下面有打开授权的button弹窗代码)
- that.setData({
- openSet: true
- })
- }
- })
- } else {
- // 有则直接保存
- wx.saveImageToPhotosAlbum({
- filePath: that.data.shareImg,
- success() {
- wx.showToast({
- title: '保存成功'
- })
- },
- fail() {
- wx.showToast({
- title: '保存失败',
- icon: 'none'
- })
- }
- })
- }
- }
- })
- },
- cancleSet() {
- this.setData({
- openSet: false
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- let that = this;
- that.postermsg();
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- // onShareAppMessage: function () {
- // }
- })
|