基本信息
源码名称:源码:微信小程序团购拼单demo下载(入门级)
源码大小:0.45M
文件格式:.zip
开发语言:PHP
更新时间:2018-02-07
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
思路很清晰
思路很清晰
//index.js
//获取应用实例
const app = getApp()
var initTxt = '已开团,离成团还差1人,\n完善下方信息,立即参加!'
Page({
data: {
name: '',
tel: '',
userInfo: {},
txt: initTxt,
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo')
},
//事件处理函数
bindViewTap: function () {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad: function () {
if (app.globalData.userInfo) {
this.setData({
userInfo: app.globalData.userInfo,
hasUserInfo: true
})
} else if (this.data.canIUse) {
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
app.userInfoReadyCallback = res => {
this.setData({
userInfo: res.userInfo,
hasUserInfo: true,
})
}
} else {
// 在没有 open-type=getUserInfo 版本的兼容处理
wx.getUserInfo({
success: res => {
app.globalData.userInfo = res.userInfo
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
}
},
getUserInfo: function (e) {
console.log(e)
app.globalData.userInfo = e.detail.userInfo
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
},
calling: function () {
wx.makePhoneCall({
phoneNumber: '0371-55021623',
})
},
formSubmit: function (e) {
var that = this;
var formData = e.detail.value;
if (e.detail.value.name.length == 0) {
wx.showToast({
title: '请输入姓名',
icon: 'loading',
duration: 1500
})
setTimeout(function () {
wx.hideToast()
}, 2000)
} else if (e.detail.value.tel.length == 0) {
wx.showToast({
title: '请输入电话',
icon: 'loading',
duration: 1500
})
setTimeout(function () {
wx.hideToast()
}, 2000)
} else if (e.detail.value.tel.length != 11) {
wx.showToast({
title: '请输入11位手机号码!',
icon: 'loading',
duration: 1500
})
setTimeout(function () {
wx.hideToast()
}, 2000)
} else {
wx.request({
url: 'https://call.hylink2.com/Home/Index/xcx',
data: formData,
header: {
'Content-Type': 'application/json'
},
success: function (res) {
console.log(res.data)
wx.showToast({
title: '提交成功!',
icon: 'success',
duration: 1500
})
wx.navigateTo({
url: '../hongbao/hongbao'
})
setTimeout(function () {
wx.hideToast()
}, 2000)
}
})
}
},
formReset: function (e) {
console.log('form发生了reset事件,携带数据为:', e.detail.value)
this.setData({
name: '',
tel: ''
})
},
//加载完后,处理事件
// 如果有本地数据,则直接显示
onLoad: function (options) {
var that = this;
//获取本地数据
wx.getStorage({
key: 'name',
success: function (res) {
console.log(res.data);
that.setData({ name: res.data });
}
});
wx.getStorage({
key: 'contacts',
success: function (res) {
console.log(res.data);
that.setData({ contacts: res.data });
}
});
wx.getStorage({
key: 'date',
success: function (res) {
console.log(res.data);
that.setData({ date: res.data });
}
});
},
//加载完后,处理事件
// 如果有本地数据,则直接显示
onLoad: function (options) {
var that = this;
//获取本地数据
wx.getStoerage({
key: 'name',
success: function (res) {
console.log(res.data);
that.setData({ name: res.data });
}
});
wx.getStorage({
key: 'contacts',
success: function (res) {
console.log(res.data);
that.setData({ contacts: res.data });
}
});
wx.getStorage({
key: 'date',
success: function (res) {
console.log(res.data);
that.setData({ date: res.data });
}
});
},
onReady: function () {
// 页面渲染完成
},
onShow: function () {
// 页面显示
},
onHide: function () {
// 页面隐藏
},
onUnload: function () {
// 页面关闭
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
return {
title: '开红包,分享好友,免费领取健康大礼包>>>',
imageUrl: '/pages/images/hongbao.png',
}
}
})