diff --git a/pages/member/member.vue b/pages/member/member.vue
index ed692f3..a796f11 100644
--- a/pages/member/member.vue
+++ b/pages/member/member.vue
@@ -7,7 +7,7 @@
-
+
@@ -33,16 +33,19 @@
-
-
-
+
+
+
+
- 发给朋友
- 保存相册
+
+ 保存相册
-
+
+
+
@@ -53,15 +56,63 @@
export default {
data() {
return {
- cardActive: 0
+ cardActive: 0,
+ img: '',
+ user_info: {
+ promotion: ''
+ },
}
},
- onLoad() {
-
- },
+ onLoad() {
+ weixin.getOpenidInfo(info => {
+ this.user_info = info
+ console.log(this.user_info)
+ })
+ },
+ onShareAppMessage() {
+ return {
+ title: '加入会员',
+ path: '/pages/member/member?promotion_id=' + this.user_info.id,
+ imageUrl: this.img
+ }
+ },
methods: {
- shareOpen() {
- this.$refs.shareCode.open()
+ shareOpen() {
+ uni.showLoading({
+ title: '加载中'
+ });
+ uni.request({
+ url: this.baseUrl + '/api/member/get-wxa-qrcode',
+ method: 'POST',
+ data: {
+ path: '',
+ scene: this.user_info.id
+ },
+ success: r => {
+ if (r.data.status === 1) {
+ let img_qr = r.data.data // 二维码
+ let ctx = uni.createCanvasContext('firstCanvas')
+ // ctx.fillStyle = '#fff';
+ // ctx.fillRect(0, 0, 214, 342);
+ ctx.drawImage('../../static/bg_haibao@2x.png', 0, 0, 220, 220);
+ ctx.drawImage(img_qr, 43, 43, 128, 128);
+ ctx.draw()
+ setTimeout(()=>{
+ uni.canvasToTempFilePath({
+ canvasId: 'firstCanvas',
+ fileType: 'jpg',
+ success: (res) => {
+ uni.hideLoading()
+ this.$refs.shareCode.open()
+ this.img = res.tempFilePath
+ },
+ })
+ },100)
+ } else {
+ this.alert(r.data.msg)
+ }
+ }
+ })
},
shareClose() {
this.$refs.shareCode.close()
@@ -79,7 +130,25 @@
url: "../buyMember/buyMember"
});
}
- },
+ },
+ //保存图片时,h5端不能直接保存,只能通过预览长按保存
+ save() {
+ let _this = this;
+ // #ifdef H5
+ uni.previewImage({
+ urls: [_this.img]
+ })
+ // #endif
+ // #ifdef APP-PLUS||MP-WEIXIN
+ uni.saveImageToPhotosAlbum({
+ filePath: _this.img,
+ success: function() {
+ _this.$refs.shareCode.close()
+ _this.alert('保存成功')
+ }
+ });
+ // #endif
+ },
}
}
diff --git a/utils/weixin.js b/utils/weixin.js
index e783555..31524b0 100644
--- a/utils/weixin.js
+++ b/utils/weixin.js
@@ -26,7 +26,7 @@ export const weixin = {
const user_info1 = result.data.data.user_info
user_info1.openid = user_info1.wechat_openid
uni.setStorageSync(user_info_key, user_info1)
- cb(result.data.data.user_info)
+ cb(user_info1)
}
});
}