@@ -7,16 +7,14 @@ App({ | |||||
//存储storage初始化globalData数据-- | //存储storage初始化globalData数据-- | ||||
//何时存储,用来判断,不用获取code | //何时存储,用来判断,不用获取code | ||||
that.initGlobalData(); | that.initGlobalData(); | ||||
//授权处理 | |||||
UTIL.initSQFromWX(); | |||||
//获取code | //获取code | ||||
// UTIL.getCOdeFromWX({ | |||||
// complate: (code) => { | |||||
// console.log('app:微信code,' + code); | |||||
// // //获取openId | |||||
// that.getOpenIdFromFW(code); | |||||
// } | |||||
// }); | |||||
UTIL.getCOdeFromWX({ | |||||
complate: (code) => { | |||||
console.log('app:微信code,' + code); | |||||
// //获取openId | |||||
that.getOpenIdFromFW(code); | |||||
} | |||||
}); | |||||
//获取设备信息 | //获取设备信息 | ||||
wx.getSystemInfo({ | wx.getSystemInfo({ | ||||
success: function (res) { | success: function (res) { | ||||
@@ -71,12 +69,13 @@ App({ | |||||
UTIL.httpRequestNoneDetal(API.URL_GET_OPENID, sendData, "POST", { | UTIL.httpRequestNoneDetal(API.URL_GET_OPENID, sendData, "POST", { | ||||
success: (res) => { | success: (res) => { | ||||
if (res._code == API.SUCCESS_CODE) { | if (res._code == API.SUCCESS_CODE) { | ||||
console.log("成功获取到openId:" + res._data.openid); | |||||
UTIL.showToastNoneIcon("openId:" + res._data.openid); | UTIL.showToastNoneIcon("openId:" + res._data.openid); | ||||
} else { | } else { | ||||
//未获取到openId | //未获取到openId | ||||
console.log("失败,获取到openId:" + res._msg); | |||||
UTIL.showToastNoneIcon("openId:失败"); | |||||
// console.log("失败,获取到openId:" + res.msg); | |||||
STORAGE.setOpenId(res.data.openId) | |||||
STORAGE.setSessionKey(res.data.sessionKey) | |||||
// UTIL.showToastNoneIcon("openId:失败"); | |||||
} | } | ||||
} | } | ||||
}) | }) | ||||
@@ -153,6 +152,6 @@ App({ | |||||
selfClass: '', | selfClass: '', | ||||
}, | }, | ||||
}); | }); | ||||
}, 200000); | |||||
}, 2000); | |||||
}, | }, | ||||
}) | }) |
@@ -123,9 +123,9 @@ Page({ | |||||
} | } | ||||
, | , | ||||
fail: (res) => { | fail: (res) => { | ||||
wx.navigateTo({ | |||||
url: '/pages/wxAuth/wxAuth', | |||||
}) | |||||
// wx.navigateTo({ | |||||
// url: '/pages/wxAuth/wxAuth', | |||||
// }) | |||||
} | } | ||||
} | } | ||||
@@ -224,21 +224,21 @@ Page({ | |||||
v: 3, | v: 3, | ||||
warehouseId: 10005 | warehouseId: 10005 | ||||
} | } | ||||
UTIL.httpRequest(API.URL_ZB_RECOMMEND_LIST, sendData, | |||||
{ | |||||
success: (res) => { | |||||
if (res._code == API.SUCCESS_CODE) { | |||||
UTIL.showToastNoneIcon("数据共:" + res._data.length + "条"); | |||||
} else { | |||||
UTIL.showToastNoneIcon(res._msg) | |||||
} | |||||
}, | |||||
fail: (res) => { | |||||
UTIL.showToastNoneIcon(API.MSG_FAIL_HTTP) | |||||
}, | |||||
complete: (res) => { | |||||
} | |||||
}); | |||||
// UTIL.httpRequest(API.URL_ZB_RECOMMEND_LIST, sendData, | |||||
// { | |||||
// success: (res) => { | |||||
// if (res._code == API.SUCCESS_CODE) { | |||||
// UTIL.showToastNoneIcon("数据共:" + res._data.length + "条"); | |||||
// } else { | |||||
// UTIL.showToastNoneIcon(res._msg) | |||||
// } | |||||
// }, | |||||
// fail: (res) => { | |||||
// UTIL.showToastNoneIcon(API.MSG_FAIL_HTTP) | |||||
// }, | |||||
// complete: (res) => { | |||||
// } | |||||
// }); | |||||
} | } | ||||
, | , | ||||
@@ -1,5 +1,7 @@ | |||||
// pages/index/index.js | // pages/index/index.js | ||||
import * as UTIL from '../../../utils/util.js'; | import * as UTIL from '../../../utils/util.js'; | ||||
import * as API from '../../../utils/API.js'; | |||||
import * as STORAGE from '../../../utils/storage' | |||||
const APP = getApp(); | const APP = getApp(); | ||||
Page({ | Page({ | ||||
@@ -7,7 +9,8 @@ Page({ | |||||
* 页面的初始数据 | * 页面的初始数据 | ||||
*/ | */ | ||||
data: { | data: { | ||||
isIPhoneX:false | |||||
isIPhoneX:false, | |||||
privacyCheck:true //用户协议 | |||||
}, | }, | ||||
/** | /** | ||||
@@ -67,19 +70,53 @@ Page({ | |||||
onShareAppMessage: function () { | onShareAppMessage: function () { | ||||
}, | }, | ||||
getPhoneNumber: function(e) { | |||||
checkboxChange: function(res) { | |||||
let checkStatus = false; | |||||
if(res.detail.value.length!=0){ | |||||
checkStatus = true; | |||||
}else{ | |||||
checkStatus = false; | |||||
} | |||||
this.setData({ | |||||
privacyCheck:checkStatus | |||||
}) | |||||
}, | |||||
getPhoneNumber: function(res) { | |||||
let that = this; | let that = this; | ||||
let { | let { | ||||
detail | detail | ||||
} = e; | |||||
console.log(detail) | |||||
} = res; | |||||
if (!detail.encryptedData) { | if (!detail.encryptedData) { | ||||
//允许授权 | |||||
APP.showToast("未获取到手机号码,注册失败!"); | APP.showToast("未获取到手机号码,注册失败!"); | ||||
return; | return; | ||||
}else if(this.data.privacyCheck == false){ | |||||
APP.showToast("请阅读并同意用户协议和隐私政策!"); | |||||
return; | |||||
} | } | ||||
let sendData = { | |||||
sessionKey:STORAGE.getSessionKey(), | |||||
iv:detail.iv, | |||||
encryptedData:detail.encryptedData | |||||
} | |||||
UTIL.httpRequest(API.URL_POST_DECRYPTEDWXDATA, sendData,{ | |||||
success: (res) => { | |||||
if (res._code == API.SUCCESS_CODE) { | |||||
// UTIL.showToastNoneIcon("数据共:" + res._data.length + "条"); | |||||
} else { | |||||
//待删 | |||||
wx.navigateTo({ | |||||
url: '/pages/index/index', | |||||
}) | |||||
UTIL.showToastNoneIcon(res.msg) | |||||
} | |||||
}, | |||||
fail: (res) => { | |||||
UTIL.showToastNoneIcon(API.MSG_FAIL_HTTP) | |||||
}, | |||||
complete: (res) => { | |||||
} | |||||
}); | |||||
// if (res.detail.userInfo) { | // if (res.detail.userInfo) { | ||||
// //用户按了允许授权按钮 | // //用户按了允许授权按钮 | ||||
// var that = this; | // var that = this; | ||||
@@ -9,10 +9,12 @@ | |||||
<view class="quick-login" style="bottom:{{isIPhoneX?'8vh':'5vh'}}"> | <view class="quick-login" style="bottom:{{isIPhoneX?'8vh':'5vh'}}"> | ||||
<button class="key-login" type='primary' open-type='getPhoneNumber' bindgetphonenumber="getPhoneNumber">微信一键登录</button > | <button class="key-login" type='primary' open-type='getPhoneNumber' bindgetphonenumber="getPhoneNumber">微信一键登录</button > | ||||
<view class="authorization" style="margin-top:{{isIPhoneX?'5vh':'3vh'}}"> | <view class="authorization" style="margin-top:{{isIPhoneX?'5vh':'3vh'}}"> | ||||
<label> | |||||
<checkbox value="cb" checked="true" class="changeSize"/> | |||||
<text>我已阅读并同意用户协议和隐私政策</text> | |||||
</label> | |||||
<checkbox-group bindchange="checkboxChange"> | |||||
<label> | |||||
<checkbox value="privacy" checked="{{privacyCheck}}" class="changeSize" /> | |||||
<text>我已阅读并同意用户协议和隐私政策</text> | |||||
</label> | |||||
</checkbox-group> | |||||
</view> | </view> | ||||
</view> | </view> | ||||
</view> | </view> |
@@ -1,82 +1,82 @@ | |||||
{ | { | ||||
"description": "项目配置文件", | |||||
"packOptions": { | |||||
"ignore": [ | |||||
{ | |||||
"type": "file", | |||||
"value": ".eslintrc.js" | |||||
} | |||||
] | |||||
}, | |||||
"setting": { | |||||
"urlCheck": false, | |||||
"es6": true, | |||||
"enhance": true, | |||||
"postcss": true, | |||||
"preloadBackgroundData": false, | |||||
"minified": true, | |||||
"newFeature": false, | |||||
"coverView": true, | |||||
"nodeModules": false, | |||||
"autoAudits": false, | |||||
"showShadowRootInWxmlPanel": true, | |||||
"scopeDataCheck": false, | |||||
"uglifyFileName": false, | |||||
"checkInvalidKey": true, | |||||
"checkSiteMap": false, | |||||
"uploadWithSourceMap": true, | |||||
"compileHotReLoad": false, | |||||
"lazyloadPlaceholderEnable": false, | |||||
"useMultiFrameRuntime": true, | |||||
"useApiHook": true, | |||||
"useApiHostProcess": true, | |||||
"babelSetting": { | |||||
"ignore": [], | |||||
"disablePlugins": [], | |||||
"outputPath": "" | |||||
"description": "项目配置文件", | |||||
"packOptions": { | |||||
"ignore": [ | |||||
{ | |||||
"type": "file", | |||||
"value": ".eslintrc.js" | |||||
} | |||||
] | |||||
}, | }, | ||||
"useIsolateContext": true, | |||||
"userConfirmedBundleSwitch": false, | |||||
"packNpmManually": false, | |||||
"packNpmRelationList": [], | |||||
"minifyWXSS": true, | |||||
"disableUseStrict": false, | |||||
"minifyWXML": true, | |||||
"showES6CompileOption": false, | |||||
"useCompilerPlugins": false, | |||||
"ignoreUploadUnusedFiles": true | |||||
}, | |||||
"compileType": "miniprogram", | |||||
"libVersion": "2.21.1", | |||||
"appid": "wxaace54cc2cf8924b", | |||||
"projectname": "WXMB", | |||||
"debugOptions": { | |||||
"hidedInDevtools": [] | |||||
}, | |||||
"scripts": {}, | |||||
"staticServerOptions": { | |||||
"baseURL": "", | |||||
"servePath": "" | |||||
}, | |||||
"isGameTourist": false, | |||||
"condition": { | |||||
"search": { | |||||
"list": [] | |||||
"setting": { | |||||
"urlCheck": false, | |||||
"es6": true, | |||||
"enhance": true, | |||||
"postcss": true, | |||||
"preloadBackgroundData": false, | |||||
"minified": true, | |||||
"newFeature": false, | |||||
"coverView": true, | |||||
"nodeModules": false, | |||||
"autoAudits": false, | |||||
"showShadowRootInWxmlPanel": true, | |||||
"scopeDataCheck": false, | |||||
"uglifyFileName": false, | |||||
"checkInvalidKey": true, | |||||
"checkSiteMap": false, | |||||
"uploadWithSourceMap": true, | |||||
"compileHotReLoad": false, | |||||
"lazyloadPlaceholderEnable": false, | |||||
"useMultiFrameRuntime": true, | |||||
"useApiHook": true, | |||||
"useApiHostProcess": true, | |||||
"babelSetting": { | |||||
"ignore": [], | |||||
"disablePlugins": [], | |||||
"outputPath": "" | |||||
}, | |||||
"useIsolateContext": true, | |||||
"userConfirmedBundleSwitch": false, | |||||
"packNpmManually": false, | |||||
"packNpmRelationList": [], | |||||
"minifyWXSS": true, | |||||
"disableUseStrict": false, | |||||
"minifyWXML": true, | |||||
"showES6CompileOption": false, | |||||
"useCompilerPlugins": false, | |||||
"ignoreUploadUnusedFiles": true | |||||
}, | }, | ||||
"conversation": { | |||||
"list": [] | |||||
"compileType": "miniprogram", | |||||
"libVersion": "2.21.1", | |||||
"appid": "wx90a68c6fdd650f48", | |||||
"projectname": "WXMB", | |||||
"debugOptions": { | |||||
"hidedInDevtools": [] | |||||
}, | }, | ||||
"game": { | |||||
"list": [] | |||||
"scripts": {}, | |||||
"staticServerOptions": { | |||||
"baseURL": "", | |||||
"servePath": "" | |||||
}, | }, | ||||
"plugin": { | |||||
"list": [] | |||||
}, | |||||
"gamePlugin": { | |||||
"list": [] | |||||
}, | |||||
"miniprogram": { | |||||
"list": [] | |||||
"isGameTourist": false, | |||||
"condition": { | |||||
"search": { | |||||
"list": [] | |||||
}, | |||||
"conversation": { | |||||
"list": [] | |||||
}, | |||||
"game": { | |||||
"list": [] | |||||
}, | |||||
"plugin": { | |||||
"list": [] | |||||
}, | |||||
"gamePlugin": { | |||||
"list": [] | |||||
}, | |||||
"miniprogram": { | |||||
"list": [] | |||||
} | |||||
} | } | ||||
} | |||||
} | } |
@@ -8,7 +8,7 @@ let { | |||||
//用户登录页面,接口检测用户token失效,需跳转重新登录 | //用户登录页面,接口检测用户token失效,需跳转重新登录 | ||||
const USER_LOGIN_PAGE_PATH='/pages/user/login/login'; | const USER_LOGIN_PAGE_PATH='/pages/user/login/login'; | ||||
//接口成功 | //接口成功 | ||||
const SUCCESS_CODE = '000000'; | |||||
const SUCCESS_CODE = '200'; | |||||
//微信登陆失效 | //微信登陆失效 | ||||
const INVALID_USER_TOKEN_CODE = '001007'; | const INVALID_USER_TOKEN_CODE = '001007'; | ||||
@@ -25,12 +25,12 @@ const MSG_INVALID_USER_TOKEN='登陆信息失效,请重新登陆'; | |||||
/****************接口提示信息end**************** | /****************接口提示信息end**************** | ||||
/****************接口地址start****************/ | /****************接口地址start****************/ | ||||
/* 定位获取附近的商店 */ | |||||
const URL_LOCATION_SHOPQUERYBYLOCATION = `${URL_PREFIX}/location/shopquerybylocation`; | |||||
/* 根据版块信息获取推荐数据 */ | |||||
const URL_ZB_RECOMMEND_LIST = `${URL_PREFIX}/recommend/list`; | |||||
//获取openId | //获取openId | ||||
const URL_GET_OPENID=`${URL_PREFIX}/wechat/codeLogin`; | const URL_GET_OPENID=`${URL_PREFIX}/wechat/codeLogin`; | ||||
// 获取手机号解密接口 | |||||
const URL_POST_DECRYPTEDWXDATA = `${URL_PREFIX}/wechat/decryptedWXData`; | |||||
/****************接口地址end****************/ | /****************接口地址end****************/ | ||||
export { | export { | ||||
@@ -44,7 +44,6 @@ export { | |||||
MSG_FALSE_TO, | MSG_FALSE_TO, | ||||
MSG_ERROR_TO, | MSG_ERROR_TO, | ||||
MSG_INVALID_USER_TOKEN, | MSG_INVALID_USER_TOKEN, | ||||
URL_LOCATION_SHOPQUERYBYLOCATION, | |||||
URL_ZB_RECOMMEND_LIST, | |||||
URL_GET_OPENID, | URL_GET_OPENID, | ||||
URL_POST_DECRYPTEDWXDATA | |||||
} | } |
@@ -10,7 +10,6 @@ function getMemberId() { | |||||
*/ | */ | ||||
function setMemberId(memberId) { | function setMemberId(memberId) { | ||||
wx.setStorageSync('memberId', memberId); | wx.setStorageSync('memberId', memberId); | ||||
} | } | ||||
/** | /** | ||||
* 获取当前登录用户的 token | * 获取当前登录用户的 token | ||||
@@ -25,6 +24,33 @@ function getToken() { | |||||
function setToken(token) { | function setToken(token) { | ||||
wx.setStorageSync('token', token); | wx.setStorageSync('token', token); | ||||
} | } | ||||
/** | |||||
* 获取当前登录用户的 openId | |||||
*/ | |||||
function getOpenId() { | |||||
return wx.getStorageSync('openId'); | |||||
} | |||||
/** | |||||
* 设置用户openId | |||||
* @param {用户openId} openId | |||||
*/ | |||||
function setOpenId(openId) { | |||||
wx.setStorageSync('openId', openId); | |||||
} | |||||
/** | |||||
* 获取当前登录用户的 sessionKey | |||||
*/ | |||||
function getSessionKey() { | |||||
return wx.getStorageSync('sessionKey'); | |||||
} | |||||
/** | |||||
* 设置用户openId | |||||
* @param {用户openId} sessionKey | |||||
*/ | |||||
function setSessionKey(sessionKey) { | |||||
wx.setStorageSync('sessionKey', sessionKey); | |||||
} | |||||
export { | export { | ||||
@@ -32,4 +58,8 @@ export { | |||||
setMemberId, | setMemberId, | ||||
getToken, | getToken, | ||||
setToken, | setToken, | ||||
getOpenId, | |||||
setOpenId, | |||||
getSessionKey, | |||||
setSessionKey | |||||
} | } |
@@ -208,50 +208,50 @@ function handleFail(data = '') { | |||||
/** | /** | ||||
* 微信授权 获取信息 | * 微信授权 获取信息 | ||||
*/ | */ | ||||
function initSQFromWX() { | |||||
let that = this; | |||||
wx.getSetting({ | |||||
success(res) { | |||||
// function initSQFromWX() { | |||||
// let that = this; | |||||
// wx.getSetting({ | |||||
// success(res) { | |||||
// if (res.authSetting['scope.userInfo']) { | |||||
// console.log('个人信息:authSetting 已授权'); | |||||
// } else { | |||||
// console.log('个人信息:authSetting 未授权'); | |||||
// } | |||||
if (res.authSetting['scope.userLocation']) { | |||||
//定位已开启,暂不做功能处理 | |||||
console.log('定位:authSetting 已授权'); | |||||
getApp().globalData.setInfo.locationOpenIdWX = true; | |||||
} else { | |||||
//定位未开启,申请授权 | |||||
wx.authorize({ | |||||
scope: 'scope.userLocation', | |||||
success() { | |||||
//定位已开启,暂不做功能处理 | |||||
console.log('定位:wx.authorize success'); | |||||
getApp().globalData.setInfo.locationOpenIdWX = true; | |||||
} | |||||
, | |||||
fail() { | |||||
//如果之前已经拒绝过,直接返回fail 不弹窗 | |||||
console.log('定位:wx.authorize fail'); | |||||
getApp().globalData.setInfo.locationOpenIdWX = false; | |||||
wx.navigateTo({ | |||||
url: '/pages/wxAuth/wxAuth', | |||||
}) | |||||
// // if (res.authSetting['scope.userInfo']) { | |||||
// // console.log('个人信息:authSetting 已授权'); | |||||
// // } else { | |||||
// // console.log('个人信息:authSetting 未授权'); | |||||
// // } | |||||
// if (res.authSetting['scope.userLocation']) { | |||||
// //定位已开启,暂不做功能处理 | |||||
// console.log('定位:authSetting 已授权'); | |||||
// getApp().globalData.setInfo.locationOpenIdWX = true; | |||||
// } else { | |||||
// //定位未开启,申请授权 | |||||
// wx.authorize({ | |||||
// scope: 'scope.userLocation', | |||||
// success() { | |||||
// //定位已开启,暂不做功能处理 | |||||
// console.log('定位:wx.authorize success'); | |||||
// getApp().globalData.setInfo.locationOpenIdWX = true; | |||||
// } | |||||
// , | |||||
// fail() { | |||||
// //如果之前已经拒绝过,直接返回fail 不弹窗 | |||||
// console.log('定位:wx.authorize fail'); | |||||
// getApp().globalData.setInfo.locationOpenIdWX = false; | |||||
// wx.navigateTo({ | |||||
// url: '/pages/wxAuth/wxAuth', | |||||
// }) | |||||
} | |||||
// } | |||||
}) | |||||
// }) | |||||
} | |||||
}, | |||||
fail(e) { | |||||
}, | |||||
complete() { | |||||
} | |||||
}); | |||||
} | |||||
// } | |||||
// }, | |||||
// fail(e) { | |||||
// }, | |||||
// complete() { | |||||
// } | |||||
// }); | |||||
// } | |||||
/** | /** | ||||
* 获取微信Code | * 获取微信Code | ||||
@@ -262,6 +262,7 @@ function getCOdeFromWX({ complate }) { | |||||
success: function (data) { | success: function (data) { | ||||
console.log(data) | console.log(data) | ||||
complate(data.code); | complate(data.code); | ||||
hideLoadingHaveMask() | |||||
}, | }, | ||||
fail: function (err) { | fail: function (err) { | ||||
hideLoadingHaveMask(); | hideLoadingHaveMask(); | ||||
@@ -354,8 +355,6 @@ export { | |||||
httpRequest, | httpRequest, | ||||
httpRequestNoneDetal, | httpRequestNoneDetal, | ||||
initSQFromWX, | |||||
getCOdeFromWX, | getCOdeFromWX, | ||||
getLocationFromWX, | getLocationFromWX, | ||||
getUserInfoFomWX, | getUserInfoFomWX, | ||||