You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
2.0 KiB
93 lines
2.0 KiB
import { createQRCode } from '../../utils/api'
|
|
var api = require('../../../../utils/api.js')
|
|
Component({
|
|
data: {
|
|
qrcodeValue: 'https://www.baidu.com',
|
|
visible: false,
|
|
qrCodeImage: ''
|
|
},
|
|
properties: {
|
|
dialogVisible: {
|
|
type: Boolean,
|
|
observer: function (value) {
|
|
this.setData({
|
|
visible: value
|
|
})
|
|
},
|
|
value: false
|
|
},
|
|
groupInfo: {
|
|
type: Object,
|
|
value: {
|
|
groupAvatar: '',
|
|
groupLeader: '',
|
|
groupName:'',
|
|
groupId: ''
|
|
}
|
|
}
|
|
},
|
|
pageLifetimes: {
|
|
show () {
|
|
this.getGridList()
|
|
}
|
|
},
|
|
methods: {
|
|
// 预览 二维码
|
|
previewImage() {
|
|
const that = this.selectComponent('#qrcode')
|
|
wx.canvasToTempFilePath({
|
|
canvasId: 'wux-qrcode',
|
|
success: (res) => {
|
|
wx.previewImage({
|
|
urls: [res.tempFilePath]
|
|
})
|
|
}
|
|
}, that)
|
|
},
|
|
// 关闭 弹框
|
|
closeDialog () {
|
|
this.triggerEvent('parentVisibleValue', {visibleValue: false})
|
|
this.setData({
|
|
visible: false
|
|
})
|
|
},
|
|
// 获取当前用户所有网格
|
|
getGridList() {
|
|
api.getGridList().then(res => {
|
|
res.data.forEach((item,index) => {
|
|
if(index==0){
|
|
this.setData({
|
|
gridId:item.gridId
|
|
})
|
|
}
|
|
})
|
|
this.getUserInfo()
|
|
}).catch(err => {
|
|
})
|
|
},
|
|
// 获取用户信息
|
|
getUserInfo () {
|
|
api.getUserInfo().then(res => {
|
|
this.setData({
|
|
inviteUserId:res.data.id
|
|
})
|
|
this.createQRCode()
|
|
}).catch(err => {
|
|
})
|
|
},
|
|
createQRCode () {
|
|
const para = {
|
|
gridId: this.data.gridId,
|
|
inviteUserId: this.data.inviteUserId
|
|
}
|
|
createQRCode(para).then(res => {
|
|
console.log('生成邀请二维码', res)
|
|
this.setData({
|
|
qrCodeImage: res.data
|
|
})
|
|
}).catch(err => {
|
|
console.log(err)
|
|
})
|
|
}
|
|
}
|
|
})
|