1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- // pages/set_name/set_name.js
- const APIClient = require('../../utils/APIClient.js');
- const login = require('../../utils/loginSchedule.js');
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- textValue: ''
- },
- /*获取输入内容*/
- bindKeyInput: function(e) {
- this.setData({
- textValue: e.detail.value
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- wx.setNavigationBarTitle({
- title: '更改昵称'
- })
- },
- /*点击更改*/
- save: function () {
- if(this.data.textValue == '') {
- wx.showModal({
- title: '提示',
- content: '请输入要更改的昵称',
- success: function(res) {
- if (res.confirm) {
- console.log('用户点击确定')
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- return false;
- };
- login.getOpenidSessionKey((res) => {
- //console.log(res.data.data.uid);
- APIClient.getSetNameSchedule({
- uid: res.data.data.uid
- }, {
- wechatName: this.data.textValue
- }).success(res => {
- console.log(res)
- if(res.data.success) {
- wx.redirectTo({
- url: '../my/my?ind=0'
- })
- }
- })
- }, function() {
- wx.showModal({
- title: '提示',
- content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
- showCancel: false,
- success: function (res) {
- if (res.confirm) {
- console.log('用户点击确定')
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- });
- }
- })
|