12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import WelfareMall from '../api/welfareMall'
- function getUserInfo() {
- return wx.getStorageSync('userInfo') || null;
- }
- function getMobileCache() {
- const userInfo = getUserInfo()
- if (userInfo != null) {
- return userInfo.mobile || ''
- }
- return ''
- }
- function getPhoneNumber(e, func) {
- var encryptedData = e.detail.encryptedData;
- console.log(encryptedData);
- var iv = e.detail.iv;
- if (!encryptedData || encryptedData.length == 0 || !iv || iv.length == 0) {
- return;
- }
- //获取手机号
- getApp().doDecodePhone(encryptedData, iv, function () {
- func(getMobileCache())
- });
- }
- function getPhoneNumberNew(e, func) {
- var code = e.detail.code;
- console.log(code);
-
- //如果版本过低 没有code 就用之前的放吧
- if (!code || code.length == 0 ) {
- getPhoneNumber(e,func)
- }else{
- //获取手机号
- getApp().doDecodePhoneNew(code, function () {
- func(getMobileCache())
- });
- }
-
- }
- /**
- * 获取统一颜色
- */
- async function getColor(){
- let config = wx.getStorageSync('config') || null
- if(config != null){
- return config;
- }
- let res = await WelfareMall.getIndexList();
- //颜色存到缓存中
- wx.setStorageSync('config',res.data.config);
- return res.data.config;
- }
- module.exports = {
- getUserInfo,
- getMobileCache,
- getPhoneNumber,
- getPhoneNumberNew,
- getColor
- }
-
|