1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- const WXAPI = require('apifm-wxapi')
- const AUTH = require('../../utils/auth')
- Page({
- data: {
- },
- onLoad: function (options) {
- },
- onShow: function () {
- AUTH.wxaCode().then(code => {
- this.data.code = code
- })
- this.getUserApiInfo()
- },
- async getUserApiInfo() {
- const res = await WXAPI.userDetail(wx.getStorageSync('token'))
- if (res.code == 0) {
- let _data = {}
- _data.apiUserInfoMap = res.data
- if (res.data.base.mobile) {
- _data.userMobile = res.data.base.mobile
- }
- if (this.data.order_hx_uids && this.data.order_hx_uids.indexOf(res.data.base.id) != -1) {
- _data.canHX = true // 具有扫码核销的权限
- }
- const adminUserIds = wx.getStorageSync('adminUserIds')
- if (adminUserIds && adminUserIds.indexOf(res.data.base.id) != -1) {
- _data.isAdmin = true
- }
- if (res.data.peisongMember && res.data.peisongMember.status == 1) {
- _data.memberChecked = false
- } else {
- _data.memberChecked = true
- }
- this.setData(_data);
- }
- },
- getPhoneNumber: function(e) {
- if (!e.detail.errMsg || e.detail.errMsg != "getPhoneNumber:ok") {
- wx.showModal({
- title: '提示',
- content: e.detail.errMsg,
- showCancel: false
- })
- return;
- }
- this._getPhoneNumber(e)
- },
- async _getPhoneNumber(e) {
- let res
- const extConfigSync = wx.getExtConfigSync()
- if (extConfigSync.subDomain) {
- // 服务商模式
- res = await WXAPI.wxappServiceBindMobile({
- token: wx.getStorageSync('token'),
- code: this.data.code,
- encryptedData: e.detail.encryptedData,
- iv: e.detail.iv,
- })
- } else {
- res = await WXAPI.bindMobileWxapp(wx.getStorageSync('token'), this.data.code, e.detail.encryptedData, e.detail.iv)
- }
- AUTH.wxaCode().then(code => {
- this.data.code = code
- })
- if (res.code === 10002) {
- AUTH.login(this)
- return
- }
- if (res.code == 0) {
- wx.showToast({
- title: '绑定成功',
- icon: 'success',
- duration: 2000
- })
- this.getUserApiInfo();
- } else {
- wx.showModal({
- title: '提示',
- content: res.msg,
- showCancel: false
- })
- }
- }
- })
|