Kaynağa Gözat

优化

master
两千亩小少爷 3 yıl önce
ebeveyn
işleme
dbbe87b425
8 değiştirilmiş dosya ile 233 ekleme ve 167 silme
  1. +12
    -13
      nsgk_entry/app.js
  2. +18
    -18
      nsgk_entry/pages/show/show.js
  3. +44
    -7
      nsgk_entry/pages/user/login/login.js
  4. +6
    -4
      nsgk_entry/pages/user/login/login.wxml
  5. +75
    -75
      nsgk_entry/project.config.json
  6. +6
    -7
      nsgk_entry/utils/API.js
  7. +31
    -1
      nsgk_entry/utils/storage.js
  8. +41
    -42
      nsgk_entry/utils/util.js

+ 12
- 13
nsgk_entry/app.js Dosyayı Görüntüle

@@ -7,16 +7,14 @@ App({
//存储storage初始化globalData数据--
//何时存储,用来判断,不用获取code
that.initGlobalData();
//授权处理
UTIL.initSQFromWX();
//获取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({
success: function (res) {
@@ -71,12 +69,13 @@ App({
UTIL.httpRequestNoneDetal(API.URL_GET_OPENID, sendData, "POST", {
success: (res) => {
if (res._code == API.SUCCESS_CODE) {
console.log("成功获取到openId:" + res._data.openid);
UTIL.showToastNoneIcon("openId:" + res._data.openid);
} else {
//未获取到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: '',
},
});
}, 200000);
}, 2000);
},
})

+ 18
- 18
nsgk_entry/pages/show/show.js Dosyayı Görüntüle

@@ -123,9 +123,9 @@ Page({
}
,
fail: (res) => {
wx.navigateTo({
url: '/pages/wxAuth/wxAuth',
})
// wx.navigateTo({
// url: '/pages/wxAuth/wxAuth',
// })

}
}
@@ -224,21 +224,21 @@ Page({
v: 3,
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) => {
// }
// });
}
,



+ 44
- 7
nsgk_entry/pages/user/login/login.js Dosyayı Görüntüle

@@ -1,5 +1,7 @@
// pages/index/index.js
import * as UTIL from '../../../utils/util.js';
import * as API from '../../../utils/API.js';
import * as STORAGE from '../../../utils/storage'
const APP = getApp();
Page({

@@ -7,7 +9,8 @@ Page({
* 页面的初始数据
*/
data: {
isIPhoneX:false
isIPhoneX:false,
privacyCheck:true //用户协议
},

/**
@@ -67,19 +70,53 @@ Page({
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 {
detail
} = e;
console.log(detail)
} = res;
if (!detail.encryptedData) {
//允许授权
APP.showToast("未获取到手机号码,注册失败!");
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) {
//       //用户按了允许授权按钮
//       var that = this;


+ 6
- 4
nsgk_entry/pages/user/login/login.wxml Dosyayı Görüntüle

@@ -9,10 +9,12 @@
<view class="quick-login" style="bottom:{{isIPhoneX?'8vh':'5vh'}}">
<button class="key-login" type='primary' open-type='getPhoneNumber' bindgetphonenumber="getPhoneNumber">微信一键登录</button >
<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>

+ 75
- 75
nsgk_entry/project.config.json Dosyayı Görüntüle

@@ -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": []
}
}
}
}

+ 6
- 7
nsgk_entry/utils/API.js Dosyayı Görüntüle

@@ -8,7 +8,7 @@ let {
//用户登录页面,接口检测用户token失效,需跳转重新登录
const USER_LOGIN_PAGE_PATH='/pages/user/login/login';
//接口成功
const SUCCESS_CODE = '000000';
const SUCCESS_CODE = '200';
//微信登陆失效
const INVALID_USER_TOKEN_CODE = '001007';

@@ -25,12 +25,12 @@ const MSG_INVALID_USER_TOKEN='登陆信息失效,请重新登陆';
/****************接口提示信息end****************

/****************接口地址start****************/
/* 定位获取附近的商店 */
const URL_LOCATION_SHOPQUERYBYLOCATION = `${URL_PREFIX}/location/shopquerybylocation`;
/* 根据版块信息获取推荐数据 */
const URL_ZB_RECOMMEND_LIST = `${URL_PREFIX}/recommend/list`;
//获取openId
const URL_GET_OPENID=`${URL_PREFIX}/wechat/codeLogin`;
// 获取手机号解密接口
const URL_POST_DECRYPTEDWXDATA = `${URL_PREFIX}/wechat/decryptedWXData`;


/****************接口地址end****************/

export {
@@ -44,7 +44,6 @@ export {
MSG_FALSE_TO,
MSG_ERROR_TO,
MSG_INVALID_USER_TOKEN,
URL_LOCATION_SHOPQUERYBYLOCATION,
URL_ZB_RECOMMEND_LIST,
URL_GET_OPENID,
URL_POST_DECRYPTEDWXDATA
}

+ 31
- 1
nsgk_entry/utils/storage.js Dosyayı Görüntüle

@@ -10,7 +10,6 @@ function getMemberId() {
*/
function setMemberId(memberId) {
wx.setStorageSync('memberId', memberId);
}
/**
* 获取当前登录用户的 token
@@ -25,6 +24,33 @@ function getToken() {
function setToken(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 {
@@ -32,4 +58,8 @@ export {
setMemberId,
getToken,
setToken,
getOpenId,
setOpenId,
getSessionKey,
setSessionKey
}

+ 41
- 42
nsgk_entry/utils/util.js Dosyayı Görüntüle

@@ -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
@@ -262,6 +262,7 @@ function getCOdeFromWX({ complate }) {
success: function (data) {
console.log(data)
complate(data.code);
hideLoadingHaveMask()
},
fail: function (err) {
hideLoadingHaveMask();
@@ -354,8 +355,6 @@ export {

httpRequest,
httpRequestNoneDetal,

initSQFromWX,
getCOdeFromWX,
getLocationFromWX,
getUserInfoFomWX,


Yükleniyor…
İptal
Kaydet