| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- // pages/bdAccount/bdAccount.js
- const util = require('../../utils/util.js');
- const app = getApp();
- Page({
- data: {
- wxbd:"未绑定",
- bankbd:"未绑定",
- wxName:"",
- wxHeadImg:"",
- cardHolder:"",
- bankAccount:"",
- bankName:"",
- storeTel:"",
- storeCard:"",
- agentTel:"",
- agentCard:"",
- agentQualifications:"",
- userInfo:{
- cardName: '',
- bankCard: '',
- bankName: '',
- nickName:null,
- realname:null,
- avatarUrl:null,
- bankCode:null,
- },
- wechatVo:{
- },
-
- },
- setVal:function(e){
- this.setData({
- [e.target.dataset.key] : e.detail.value
- })
- },
- binding:function(e){
- util.request(util.api.updateBankInfo, this.data.userInfo, "POST", true, true,app.globalData.token).then((res)=>{
- if (res.code == 200) {
- this.setData({
- userInfo: res.result,
- })
- app.globalData.userInfo = res.result
- //存入缓存
- wx.setStorage({
- data: res.result,
- key: 'birthdayUserInfo',
- })
- util.toast('保存成功')
- }
- });
- },
- submit:function(){
- util.request(util.api.updateInfo, this.data.userInfo, "POST", true, true,app.globalData.token).then((res)=>{
- if (res.code == 200) {
- this.setData({
- userInfo: res.result,
- })
- app.globalData.userInfo = res.result
- //存入缓存
- wx.setStorage({
- data: res.result,
- key: 'birthdayUserInfo',
- })
- util.toast('保存成功')
- }
- });
- },
- getUserProfile: function (e) {
- var that = this
-
- if(util.isNullOrEmpty(that.data.userInfo.realname)) {
- util.toast('请输入真实姓名');
- return;
- }
- wx.getUserProfile({
- desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
- success :(res) => { //有箭头函数可以直接用this 没有要 let that = this
- // 存储本地信息
- console.log(res.userInfo)
- console.log(1111111111)
- this.data.wechatVo.realName = that.data.userInfo.realname
- this.data.wechatVo.avatarUrl = res.userInfo.avatarUrl
- this.data.wechatVo.nickName = res.userInfo.nickName
- // this.data
- wx.login({
- success: res => {
- var code = res.code
- this.data.wechatVo.code = code
- // util.request(util.api.addRole, that.data.userInfo, "POST", false, true,app.globalData.token).then((res)=>{
- util.request(util.api.miniAppLogin, this.data.wechatVo, "POST", false, true,app.globalData.token).then((res)=>{
- if (res.code == 200) {
- // app.globalData.openId = res.result.userInfo.openId
- util.toast('绑定成功')
- this.setData({
- userInfo: res.result,
- isLogin: 1,
- })
- app.globalData.userInfo = res.result
- //存入缓存
- wx.setStorage({
- data: res.result,
- key: 'birthdayUserInfo',
- })
- this.onLoad();
- }else{
- util.toast('绑定失败,请联系管理员')
- }
- })
- }
- })
- },
- fail(res){
- console.log(res)
- }
- })
- // if (e.detail.userInfo) {
- // //用户按了允许授权按钮
- // //插入登录的用户的相关信息到数据库
- // wx.login({
- // success: res => {
- // var code = res.code
- // util.request(util.api.miniAppLogin, {rawData: that.data.bindInfo,realName:that.data.userInfo.realname,
- // code: code,}, "POST", true, true,app.globalData.token).then((res)=>{
- // if (res.code == 200) {
- // // app.globalData.openId = res.result.userInfo.openId
- // console.log(res)
- // this.setData({
- // userInfo: res.result,
- // isLogin: 1,
- // })
- // app.globalData.userInfo = res.result
- // //存入缓存
- // wx.setStorage({
- // data: res.result,
- // key: 'birthdayUserInfo',
- // })
- // this.onLoad();
- // }
- // })
- // }
- // })
- // } else {
- // //用户按了拒绝按钮
- // wx.showModal({
- // title: '警告',
- // content: '您点击了拒绝授权,将无法进入小程序,请授权之后再进入!!!',
- // showCancel: false,
- // confirmText: '返回授权',
- // success: function (res) {
- // if (res.confirm) {
- // console.log('用户点击了“返回授权”')
- // }
- // }
- // })
- // }
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- if(app.globalData.userInfo && app.globalData.userInfo.bankCard!=null){
- this.data.bankbd="已绑定"
- }
- this.setData({
- userInfo: app.globalData.userInfo,
- bankbd:this.data.bankbd
-
- })
- },
- inputedit: function (e) {
- let _this = this;
- let dataset = e.currentTarget.dataset;
- let value = e.detail.value;
- let name = dataset.name;
- _this.data[name] = value;
- _this.setData({
- [name]: _this.data[name]
- });
- },
- })
|