*/ | */ | ||||
export const getOpenId = function (code) { | export const getOpenId = function (code) { | ||||
return request({ | return request({ | ||||
url: `/wx/openid/${code}`, | |||||
url: `/wx/openIdAndUnionId/${code}`, | |||||
method: 'GET', | method: 'GET', | ||||
}) | }) | ||||
} | } |
const __request_base_url__ = { | const __request_base_url__ = { | ||||
develop: "http://192.168.11.11:9061/api", | |||||
// develop: "https://qmhhapi-test.t-aaron.com/api", | |||||
// develop: "http://192.168.11.11:9061/api", | |||||
develop: "https://qmhhapi-test.t-aaron.com/api", | |||||
trial: "https://qmhhapi-test.t-aaron.com/api", | trial: "https://qmhhapi-test.t-aaron.com/api", | ||||
release: "https://qmhh.t-aaron.com/api" | release: "https://qmhh.t-aaron.com/api" | ||||
} | } |
{ | { | ||||
title:'积分商城', | title:'积分商城', | ||||
iconPath: '../../assets/first/stores.png', | iconPath: '../../assets/first/stores.png', | ||||
path: '/pages/index/index', | |||||
path: '/package_A/pages/stores/index', | |||||
type: 'mini' | type: 'mini' | ||||
}, | }, | ||||
{ | { | ||||
}, | }, | ||||
onShow() { | onShow() { | ||||
this.getOnliveNum() | |||||
let tenant = wx.getStorageSync('tenant') | |||||
if(Object.keys(tenant).length) { | |||||
this.getOnliveNum() | |||||
} | |||||
}, | }, | ||||
url: path, | url: path, | ||||
}) | }) | ||||
} else if(type === 'mini'){ | } else if(type === 'mini'){ | ||||
wx.navigateToMiniProgram({ | |||||
appId: 'wx57d8902569fbf5e1', | |||||
path, | |||||
envVersion: 'develop', | |||||
success(res) { | |||||
} | |||||
}) | |||||
const { tenantCode, tenantId } = wx.getStorageSync('tenant') | |||||
if(tenantId === 5){ | |||||
wx.navigateToMiniProgram({ | |||||
appId: 'wx57d8902569fbf5e1', | |||||
path: `pages/index/index?tenantCode=${tenantCode}`, | |||||
extraData: { | |||||
tenantCode | |||||
}, | |||||
envVersion: env, | |||||
success(res) { | |||||
} | |||||
}) | |||||
}else{ | |||||
wx.navigateTo({ | |||||
url: path, | |||||
}) | |||||
} | |||||
} else { | } else { | ||||
wx.navigateTo({ | wx.navigateTo({ | ||||
url: path, | url: path, |
fromType: 'tabbar', | fromType: 'tabbar', | ||||
tenantId: '', | tenantId: '', | ||||
tenantCurrent: -1, // 当前选择的租户数据index | tenantCurrent: -1, // 当前选择的租户数据index | ||||
tenantCode: null, | |||||
tenantOptions: [], // 租户列表 | tenantOptions: [], // 租户列表 | ||||
formRules: { | formRules: { | ||||
tenantId: { | tenantId: { | ||||
this.setData({tenantCurrent, tenantId}) | this.setData({tenantCurrent, tenantId}) | ||||
} | } | ||||
const openid = wx.getStorageSync('openid') | const openid = wx.getStorageSync('openid') | ||||
const unionid = wx.getStorageSync('unionid') | |||||
if(openid) { | if(openid) { | ||||
this.setData({openid}) | |||||
this.setData({openid,unionid}) | |||||
} else { | } else { | ||||
getOpenidData().then(res=> { | getOpenidData().then(res=> { | ||||
this.setData({openid: res.openid}) | |||||
this.setData({openid: res.openid, unionid: res.unionid}) | |||||
}) | }) | ||||
} | } | ||||
}, | }, | ||||
selectTenant(e) { | selectTenant(e) { | ||||
const tenantCurrent = e.detail.value | const tenantCurrent = e.detail.value | ||||
let tenantId = this.data.tenantOptions[tenantCurrent].id | let tenantId = this.data.tenantOptions[tenantCurrent].id | ||||
let tenantCode = this.data.tenantOptions[tenantCurrent].code | |||||
this.setData({ | this.setData({ | ||||
tenantCurrent, | tenantCurrent, | ||||
tenantId | |||||
tenantId, | |||||
tenantCode | |||||
}) | }) | ||||
this.validate('tenantId') | this.validate('tenantId') | ||||
}, | }, | ||||
goHome() { | goHome() { | ||||
this.validateForm().then(res => { | this.validateForm().then(res => { | ||||
if(res) { | if(res) { | ||||
enterMini({openid: this.data.openid, tenantId: this.data.tenantId}).then(item=> { | |||||
enterMini({openid: this.data.openid, unionid: this.data.unionid, tenantId: this.data.tenantId}).then(item=> { | |||||
if(item.code === 0) { | if(item.code === 0) { | ||||
const tenantObj = { | const tenantObj = { | ||||
tenantCurrent: this.data.tenantCurrent, | tenantCurrent: this.data.tenantCurrent, | ||||
tenantId: this.data.tenantId | |||||
tenantId: this.data.tenantId, | |||||
tenantCode: this.data.tenantCode, | |||||
} | } | ||||
wx.setStorage({ | wx.setStorage({ | ||||
key: 'tenant', | key: 'tenant', |
let code = result.code | let code = result.code | ||||
getOpenId(code).then(i=> { | getOpenId(code).then(i=> { | ||||
if(i.code === 0) { | if(i.code === 0) { | ||||
const openid = i.data | |||||
const {openId,unionId} = i.data | |||||
wx.setStorage({ | wx.setStorage({ | ||||
key: 'openid', | key: 'openid', | ||||
data: openid | |||||
data: openId | |||||
}) | }) | ||||
resolve({openid}) | |||||
wx.setStorage({ | |||||
key: 'unionid', | |||||
data: unionId | |||||
}) | |||||
resolve({openid: openId,unionid: unionId}) | |||||
} | } | ||||
}) | }) | ||||
} | } |