Commit c5e9154b authored by 小耗子's avatar 小耗子

第一版

parent c7344b34
......@@ -3,6 +3,8 @@
onLaunch: function() {
},
onShow: function() {
console.log("从后台进入")
// wx.reLaunch()
},
onHide: function() {
}
......
### 微信步数(zhmp):
```
商城:106975910000477 测试环境小程序
企业:999999998 小程序
APPID: wx60c6530c49c52ff7
```
### 无步数商城小程序 :
```
商城:119583623123146
企业:625 商城小程序
AppID:wx91fa336def077983
AppSecret: 7f2855a8ff743f1f295ecb9af07f5998
```
\ No newline at end of file
......@@ -2,8 +2,8 @@
* Shopro全局配置文件
*/
export const BASE_URL = 'http://172.18.0.229:9001' //后台根域名 https://demo.shopro.top
// export const BASE_URL = 'https://wxcs.zhonghuihaotai.com' //后台根域名 https://demo.shopro.top
// export const BASE_URL = 'http://172.18.0.229:9001' //后台根域名 https://demo.shopro.top
export const BASE_URL = 'https://wxcs.zhonghuihaotai.com' //后台根域名 https://demo.shopro.top
// export const BASE_URL = 'https://wxcs.zhonghuihaotai.com' //后台根域名 https://demo.shopro.top
export const API_URL = `${BASE_URL}/api/a1/` //后台接口域名
export const IMG_URL = 'http://file.shopro.top' //全局网络图片地址变量,css背景图片地址变量在uni.scss
......
......@@ -57,7 +57,8 @@
"appid" : "wx60c6530c49c52ff7",
"setting" : {
"urlCheck" : false,
"minified" : true
"minified" : true,
"es6" : false
},
"usingComponents" : true,
"permission" : {
......
......@@ -9,7 +9,6 @@
"style": {
"navigationBarTitleText": "步数",
"navigationBarTextStyle": "black",
"enablePullDownRefresh":true,
"navigationBarBackgroundColor":"#ffffff",
"navigationStyle": "custom"
},
......@@ -56,7 +55,7 @@
}
}
],
"subPackages":[],
"tabBar": {
......
......@@ -11,20 +11,31 @@
<text></text>
</view>
<view v-else class="steps-empower">
<u-button open-type="getPhoneNumber" @getphonenumber="getInfoPhoneNumber" type="primary" size="mini" color="#00c791" :plain="true" text="授权查看"></u-button>
<u-button open-type="getPhoneNumber" @getphonenumber="getInfoPhoneNumber" type="primary"
size="normal" color="#00c791" :plain="true" text="授权查看"></u-button>
</view>
</view>
<image src="../../static/img/run/ranking_btn.png" class="ranking_btn" mode="widthFix"></image>
<!-- <image src="../../static/img/run/ranking_btn.png" class="ranking_btn" mode="widthFix"></image> -->
<view class="runDataExplain">
<view class="explain">使用说明:</view>
<text class="">
您在微信授权登录后如未能正常显示步数,请检查以下微信项目设置无误:
1、微信运动已启用
2、微信运动已设置数据来源。具体见进入微信运动--设置(右上角齿轮图标)-数据来源
</text>
</view>
</view>
</view>
<u-tabbar :value="tabBarVal" @change="changeTabBar" :fixed="true" :placeholder="true" activeColor="#00c791" :safeAreaInsetBottom="true">
<u-tabbar :value="tabBarVal" @change="changeTabBar" :fixed="true" :placeholder="true" activeColor="#00c791"
:safeAreaInsetBottom="true">
<u-tabbar-item text="步数" name="步数">
<image class="u-page__item__slot-icon" slot="active-icon" src="../../static/img/run/tabbar_Index1.png">
</image>
<image class="u-page__item__slot-icon" slot="inactive-icon" src="../../static/img/run/tabbar_Index.png">
</image>
</u-tabbar-item>
<u-tabbar-item text="商城" name="商城">
<u-tabbar-item text="商城" name="商城">
<image class="u-page__item__slot-icon" slot="active-icon" src="../../static/img/run/tabbar_shop1.png">
</image>
<image class="u-page__item__slot-icon" slot="inactive-icon" src="../../static/img/run/tabbar_shop.png">
......@@ -43,53 +54,58 @@
export default {
data() {
return {
unregistered:false,
unregistered: true,
tabBarVal: '步数',
registerPopup:true,
form:{name:'xxx'},
registerPopup: true,
form: {
name: 'xxx'
},
tips: '获取',
seconds: 10,
checkSessionStatus:false
checkSessionStatus: false
}
},
computed: {
...mapGetters(['userInfo','todayNum','wxCode'])
...mapGetters(['userInfo', 'todayNum', 'wxCode'])
},
methods: {
...mapActions(['getPhoneNumber','registerInfoFn','getWeRunDataFn','authCheck','getUserInfo','checkValidSession']),
...mapActions(['getPhoneNumber', 'registerInfoFn', 'getWeRunDataFn', 'authCheck', 'getUserInfo',
'checkValidSession'
]),
// 切换底部tab;
changeTabBar(name){
changeTabBar(name) {
this.tabBarVal = name;
if(name == '商城') {
if(!this.unregistered) {
if (name == '商城') {
if (!this.unregistered) {
this.$u.toast("点击授权进行注册");
return false;
}
uni.navigateTo({
url: '/pages/h5/index'
})
}
}
},
// 获取手机号
async getInfoPhoneNumber (e) {
async getInfoPhoneNumber(e) {
let number = await this.getPhoneNumber(e);
let register = await this.registerInfoFn();
if(register){ //注册成功,再掉获取步数接口
if (register) { //注册成功,再掉获取步数接口
let runData = await this.getWeRunDataFn();
runData && (this.unregistered = true);
}
},
async authAndWeRun(){
async authAndWeRun() {
let auth = await this.authCheck();
if(auth == 0) {
console.log("调用authcheck的值"+auth)
let that = this;
if (auth == 0) {
let runData = await this.getWeRunDataFn();
runData && (this.unregistered = true);
}else if(auth == 2001){
this.getUserInfo();
this.unregistered = false;
} else if (auth == 2001) {
this.unregistered = false;
}
},
async loginSession(){
async loginSession() {
let token = uni.getStorageSync('token');
let that = this;
/**
......@@ -104,20 +120,21 @@
* *
*/
if(this.checkSessionStatus && token) {
if (this.checkSessionStatus && token) {
let token = uni.getStorageSync('token');
this.authAndWeRun();
}else{
console.log("token的值===================="+token)
this.authAndWeRun();
} else {
// session 不存在,调用login。userInfo 。更新session
uni.login({
success: function(info) { //调用code
console.log("code000000000000000000000000==========",info.code)
that.$store.commit('wxCode',info.code); //按钮切换全选。
let userInfo = that.getUserInfo();
userInfo.then(res=>{
that.authCheck().then(checkCode =>{
if(checkCode == 0 ) {
that.getWeRunDataFn().then(runData =>{
uni.login({
success: function(info) { //调用code
console.log("code000000000000000000000000==========", info.code)
that.$store.commit('wxCode', info.code); //按钮切换全选。
let userInfo = that.getUserInfo(info.code);
userInfo.then(res => {
that.authCheck().then(checkCode => {
if (checkCode == 0) {
that.getWeRunDataFn().then(runData => {
runData && (that.unregistered = true);
})
}
......@@ -126,13 +143,12 @@
}
})
}
},
async getAuth(){
async getAuth() {
let that = this;
uni.checkSession({ //校验session
success(res) {//有效
console.log("有效session")
success(res) { //有效
if (res.errMsg === "checkSession:ok") {
that.checkSessionStatus = true;
// 如果有缓存信息
......@@ -140,22 +156,22 @@
}
},
fail(err) { //无效
console.log("无效session")
console.log("无效session")
that.checkSessionStatus = false;
that.loginSession()
}
})
}
},
onHide(){
},
onHide() {},
onShow() {
this.tabBarVal = "步数";
console.log("步数。。。。")
// uni.hideTabBar();
this.getAuth();
},
onReady() {
this.getAuth();
}
}
</script>
......@@ -207,6 +223,17 @@
font-size: 20rpx;
}
}
.runDataExplain{
.explain{
font-weight: bold;
margin-bottom:20rpx ;
}
color: #D7D7D7;
text-align: left;
width: 75%;
margin:20px auto;
line-height: 42rpx;
}
.ranking_btn {
margin-top: 100rpx;
......@@ -215,12 +242,11 @@
}
}
.registre-popup{
margin:60rpx 0;
padding:0 40rpx;
.btn{
}
.registre-popup {
margin: 60rpx 0;
padding: 0 40rpx;
.btn {}
}
}
......
......@@ -12,12 +12,6 @@ const state = {
registerType: 'register' //注册时的类型为普通注册
},
wxCode:'',
// weRunData:{//今日步数
// todayNum: 0,
// totalNum: 0,
// updateDate: "",
// yesterdayNum: 0
// },
todayNum:0,
sessionStatus:false
}
......@@ -27,7 +21,8 @@ const getters = {
userInfo: state => state.userInfo,
todayNum: state => state.todayNum,
wxCode: state=> state.wxCode,
sessionStatus: state=> state.sessionStatus
sessionStatus: state=> state.sessionStatus,
mallId: state=>state.mallId
}
const actions = {
......@@ -41,12 +36,13 @@ const actions = {
state
}, code) {
return new Promise((resolve, reject) => {
let mallId = '106975910000477'
uni.setStorageSync("mallId", mallId)
let code = state.wxCode;
uni.setStorageSync("mallId", state.mallId);
// console.log(state.wxCode)
// let code = state.wxCode;
http('user.getHomePage', {
code: code,
mallId: mallId
mallId: state.mallId
}).then(res => {
if (!res.code) {
let { sessionKey } = res.data;
......@@ -75,13 +71,26 @@ const actions = {
api("user.authCheck", {
mallId: mallId
}).then(res => {
console.log("authcheck状态码=========================")
console.log(res)
let data = res.data;
if (res.code === 0) {
resolve(res.code)
} else if (res.code == 1001) {
reject(res.code)
} else if (res.code == 2001) {
uni.login({
success: function(info) { //调用code
state.wxCode == info.code;
dispatch('getUserInfo',info.code);
}
})
resolve(res.code);
} else {
reject(res.code)
uni.showToast({
title: res.msg,
duration: 2000,
icon:'none'
});
resolve(res.code)
}
});
})
......@@ -140,12 +149,22 @@ const actions = {
// 查询步数
getWeRunDataFn({state}){
return new Promise((resolve,reject) => {
let wRunEncryptedData = {}
// let wRunEncryptedData = {}
let data= ""
wx.getWeRunData({
success: function(res) {
wRunEncryptedData.encryptedData = encodeURIComponent(res.encryptedData);
wRunEncryptedData.iv = encodeURIComponent(res.iv);
http('user.wxRun', wRunEncryptedData).then(res => {
let obj = {
encryptedData:res.encryptedData,
iv:res.iv,
sessionKey:uni.getStorageSync("sessionKey")
}
data = JSON.stringify(obj)
// wRunEncryptedData.encryptedData = encodeURIComponent(res.encryptedData);
// wRunEncryptedData.iv = encodeURIComponent(res.iv);
// wRunEncryptedData.sessionKey = encodeURIComponent(uni.getStorageSync("sessionKey") );
http('user.wxRun', {data:data}).then(res => {
console.log("微信步数++=========================")
console.log(res)
if (!res.code && res.data) {
state.todayNum = res.data.todayNum;
resolve(res.data);
......@@ -163,7 +182,7 @@ const actions = {
fail:function(err){
console.log(err)
uni.showToast({
title: "您未开通微信运动,请关注微信运动公众号后重试",
title: "您未授权微信步数,请点击右上角...进去设置开启授权",
duration: 2000,
icon:'none'
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment