12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- // pages/start/index.js
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- phone: "",
- data: {
- id: "",
- userInfo: {
- phone: ""
- },
- },
- onLoad(e) {
- const that = this;
- // 获取用户信息
- wx.getSetting({
- success: r => {
- if (!r.authSetting['scope.userInfo']) return
- // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
- wx.getUserInfo({
- success: res => {
- const p = {
- ...res.userInfo
- };
- app.globalData.userInfo = p;
- that.setData({
- userInfo: p
- })
- }
- })
- }
- })
- },
- bindgetuserinfo(data) {
- app.globalData.userInfo = {
- ...(app.globalData.userInfo || {}),
- ...(data.detail.userInfo || {})
- }
- this.setData({
- userInfo: app.globalData.userInfo
- })
- },
- goSign() {
- if (!this.phone) return wx.showToast({
- title: '请输入正确的手机号',
- icon: "none"
- })
- app.globalData.userInfo.phone = this.phone;
- wx.showLoading()
- wx.cloud.callFunction({
- name: "quickstartFunctions",
- data: {
- type: "createUser",
- data: app.globalData.userInfo
- }
- }).then(res => {
- wx.hideLoading({
- success: (res) => {
- wx.redirectTo({
- url: '/pages/select/index',
- })
- },
- })
- }).catch(err => {
- wx.hideLoading({
- success: (res) => {
- wx.showToast({
- title: '服务走丢了~',
- icon: "none"
- })
- },
- })
- })
- },
- phoneNum(e) {
- if (!/1[0-9]{10}/.test(e.detail.value)) return
- this.phone = e.detail.value || 0
- }
- })
|