|
@@ -1,19 +1,34 @@
|
|
|
const { default: activity } = require("../../api/activity");
|
|
|
+import drawQrcode from '../../utils/weapp.qrcode.js'
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
-
|
|
|
+ activityId:0, //活动id
|
|
|
+ userMobile:'', //电话
|
|
|
+ codeId:'',//code唯一码
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
+ console.log('接受参数');
|
|
|
+ console.log(options);
|
|
|
+ let _self = this;
|
|
|
if(options.id){
|
|
|
this.activityInfo(options.id)
|
|
|
+ _self.activityId = options.id;
|
|
|
+ }
|
|
|
+ //用户手机
|
|
|
+ if(options.mobile) {
|
|
|
+ _self.userMobile = options.mobile;
|
|
|
+ }
|
|
|
+ if(_self.activityId!=0 && _self.userMobile!='') {
|
|
|
+ //获取code
|
|
|
+ _self.getCode()
|
|
|
}
|
|
|
|
|
|
},
|
|
@@ -66,8 +81,14 @@ Page({
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
},
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取活动详细信息
|
|
|
+ * @param {*} activityId
|
|
|
+ */
|
|
|
async activityInfo(activityId){
|
|
|
let result = await activity.getActivityDetail(activityId);
|
|
|
+ console.log('获取活动详细信息');
|
|
|
console.log(result)
|
|
|
var objSwitch = getApp().globalData.typeSwitchObj
|
|
|
|
|
@@ -94,6 +115,31 @@ Page({
|
|
|
this.setData({
|
|
|
activityInfo:result
|
|
|
})
|
|
|
-
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取分享码
|
|
|
+ */
|
|
|
+ async getCode() {
|
|
|
+ let _self = this;
|
|
|
+ let res = await activity.createShareActivityCode(_self.activityId,_self.userMobile);
|
|
|
+ _self.codeId = res.codeId;
|
|
|
+ //根据codeId 生成二维码
|
|
|
+
|
|
|
+ drawQrcode({
|
|
|
+ width: 200,
|
|
|
+ height: 200,
|
|
|
+ canvasId: 'myQrcode',
|
|
|
+ // ctx: wx.createCanvasContext('myQrcode'),
|
|
|
+ text: 'https://github.com/yingye',
|
|
|
+ // v1.0.0+版本支持在二维码上绘制图片
|
|
|
+ image: {
|
|
|
+ imageResource: '../../images/logo.png',
|
|
|
+ dx: 70,
|
|
|
+ dy: 70,
|
|
|
+ dWidth: 60,
|
|
|
+ dHeight: 60
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
})
|