123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 |
- var util = require('../../utils/util.js');
- var api = require('../../config/api.js');
- var app = getApp();
- Page({
- data: {
- userInfo: {
- nickName: '点击登录',
- avatarUrl: '/static/images/my.png'
- },
- referee: {
- level: "V0",
- levelName: '无'
- },
- hasLogin: false,
- myqr_show: false, //我的分享二维码
- myqr_url: "https://6a7a-jzmall-3gi3t6y452ddb0ff-1306484940.tcb.qcloud.la/member/member.png",
- myqr_blur: 100, //背景模糊值
- myqr_width: 640,
- myqr_top: 20,
- view_disabled: true,
- myqr_type: 0, //0会员卡 1引荐人海报
- plugid: '0775f898abc4d932f5e9a2f2b8f88bcb',
- },
- onLoad: function (options) {
- // 页面初始化 options为页面跳转所带来的参数
-
- },
- // 页面分享
- onShareAppMessage: function () {
- let that = this;
- if (!app.globalData.hasLogin) {
- wx.navigateTo({
- url: "/pages/auth/login/login"
- });
- return;
- }
- that.hidePoster();
- var title = "Hi,我送你超级鲸会员卡,快点击收下吧";
- var path = '/pages/member/card/receive/receiveCard?rId=' + that.data.userInfo.id;
- if(that.data.userInfo.id==null||typeof that.data.userInfo.id=='undefined'){
- util.showErrorToast('id为空,请重新登录');
- return;
- }
- var imageUrl = 'https://7a68-zhaijieshi-3guecm78383ca692-1307626841.tcb.qcloud.la/member/get.png';
- if (that.data.myqr_type == 1) {
- title = "鲸致引荐人,自购享优惠,分享躺赚钱";
- path = "/pages/ucenter/parter/recommend/recommend?rId=" + that.data.userInfo.id;
- imageUrl = that.data.myqr_url;
- }
- console.info(title)
- return {
- title: title,
- // desc: "我送你一份礼物,快点击收下吧~",
- path: path, //'/pages/member/card/receive/receiveCard?rId=' + this.data.userInfo.id,
- imageUrl: imageUrl //'https://6a7a-jzmall-3gi3t6y452ddb0ff-1306484940.tcb.qcloud.la/member/get.png'
- }
- },
- onReady: function () {},
- presentMemberCard() { //赠送会员卡
- this.setData({
- myqr_show: true,
- myqr_blur: 25,
- view_disabled: false,
- myqr_width: 640,
- myqr_top: 20,
- myqr_type: 0, //0会员卡 1引荐人海报
- myqr_url: "https://6a7a-jzmall-3gi3t6y452ddb0ff-1306484940.tcb.qcloud.la/member/member.png",
- })
- },
- hidePoster() {
- this.setData({
- myqr_show: false,
- myqr_blur: 100,
- view_disabled: true
- })
- },
- createQrcode: function () { //二维码生成
- let that = this;
- wx.showLoading();
- util.request(api.RefereePoster, {}, 'POST').then(function (res) {
- wx.hideLoading();
- if (res.errno == 0) {
- that.setData({
- myqr_show: true,
- myqr_blur: 25,
- view_disabled: false,
- myqr_url: res.data.imgUrl,
- myqr_width: 480,
- myqr_type: 1, //0会员卡 1引荐人海报
- myqr_top: 10,
- })
- } else {
- util.showErrorToast(res.errmsg);
- }
- });
- // wx.navigateTo({
- // url: '/pages/referee/poster/poster'
- // });
- },
- onShow: function () {
- console.info(app.globalData.hasLogin);
- //获取用户的登录信息
- if (app.globalData.hasLogin) {
- let userInfo = wx.getStorageSync('userInfo');
- this.setData({
- userInfo: userInfo,
- hasLogin: true
- });
- let that = this;
- util.request(api.RefereeIndex).then(function (res) {
- if (res.errno === 0) {
- console.log(res);
- that.setData({
- referee: res.data
- });
- }
- });
- }
- },
- onHide: function () {
- // 页面隐藏
- },
- onUnload: function () {
- // 页面关闭
- },
- goLogin() {
- if (!this.data.hasLogin) {
- wx.navigateTo({
- url: "/pages/auth/login/login"
- });
- }
- },
- goOrder() {
- if (this.data.hasLogin) {
- try {
- wx.setStorageSync('tab', 0);
- } catch (e) {
- }
- wx.navigateTo({
- url: "/pages/referee/order/order",
- });
- } else {
- wx.navigateTo({
- url: "/pages/auth/login/login"
- });
- }
- },
- goMyTeam() {
- if (this.data.hasLogin) {
- wx.navigateTo({
- url: "/pages/referee/team/team",
- });
- } else {
- wx.navigateTo({
- url: "/pages/auth/login/login"
- });
- }
- },
- goBlance(e) {
- let type = e.currentTarget.dataset.type;
- if (this.data.hasLogin) {
- wx.navigateTo({
- url: "/pages/referee/blance/blance?type=" + type,
- });
- } else {
- wx.navigateTo({
- url: "/pages/auth/login/login"
- });
- }
- },
- aboutUs: function () {
- wx.navigateTo({
- url: '/pages/ucenter/about/about'
- });
- },
- goHelp: function () {
- wx.navigateTo({
- url: '/pages/ucenter/help/help'
- });
- },
- goClause() {
- wx.navigateTo({
- url: '/pages/referee/protocol/sp'
- });
- },
- goCopyCode() {
- let that = this
- if (that.data.referee.code) {
- wx.setClipboardData({
- data: that.data.referee.code,
- success: function (res) {
- wx.showToast({
- title: '邀请码复制成功',
- icon: 'success',
- duration: 2000
- });
- }
- })
- }
- },
- goGrade() {
- wx.navigateTo({
- url: '/pages/referee/gradeInfo/gradeInfo',
- })
- },
- goSaveQrcode() {
- let that = this
- wx.showLoading({
- title: '生成中',
- });
- if (that.data.myqr_type == 0) {
- util.request(api.RefereeMemberPoster, {}).then(function (res) {
- wx.hideLoading();
- if (res.errno == 0) {
- that.goDownloadFile(res.data.imgUrl);
- } else {
- wx.showToast({
- title: res.errmsg,
- duration: 5000
- })
- }
- })
- } else { //海报保存
- that.goDownloadFile(that.data.myqr_url);
- }
- },
- goDownloadFile(url) {
- let that = this;
- wx.showLoading({
- title: '图片保存中',
- });
- console.log(that.data);
- wx.downloadFile({
- url: url,
- success: function (res) {
- console.log(res)
- wx.saveImageToPhotosAlbum({
- filePath: res.tempFilePath,
- success: function (res) {
- wx.hideLoading();
- wx.showModal({
- title: '存图成功',
- content: '图片成功保存到相册了,可以分享到朋友圈了',
- showCancel: false,
- confirmText: '好的',
- confirmColor: '#a78845',
- success: function (res) {
- if (res.confirm) {
- console.log('用户点击确定');
- that.hidePoster();
- }
- }
- })
- },
- fail: function (res) {
- wx.hideLoading();
- wx.showModal({
- title: '警告',
- content: '未授权或取消保存',
- showCancel: false
- })
- that.hidePoster();
- }
- })
- },
- fail: function (res) {
- wx.hideLoading();
- console.log(res);
- }
- })
- }
- })
|