Commit 85470940 authored by 珠峰架构's avatar 珠峰架构

同步代码

parents 6ecb2b0d f9aa0f8c
...@@ -39,6 +39,15 @@ ...@@ -39,6 +39,15 @@
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
},{ },{
"path" : "pages/h5/pay",
"name":"pay",
"style" :
{
"navigationBarTitleText": "支付",
"enablePullDownRefresh": false
}
},{
"path" : "pages/index/cart", "path" : "pages/index/cart",
"name" :"cart", "name" :"cart",
"style" : "style" :
...@@ -56,6 +65,7 @@ ...@@ -56,6 +65,7 @@
} }
} }
<<<<<<< HEAD
,{ ,{
"path" : "pages/h5/pay", "path" : "pages/h5/pay",
"name":"pay", "name":"pay",
...@@ -66,6 +76,8 @@ ...@@ -66,6 +76,8 @@
} }
} }
=======
>>>>>>> f9aa0f8cb7d83071cf50743c971db8673eea303a
], ],
"subPackages":[], "subPackages":[],
......
...@@ -9,21 +9,18 @@ ...@@ -9,21 +9,18 @@
export default { export default {
data() { data() {
return { return {
webUrl:'' webUrl:'',
appointPage:''
} }
} , } ,
onReady(){ onReady(){
// this.webUrl = "http://172.18.0.147:8000/#/?time="+new Date().getTime()
// this.webUrl = "https://wxcs.zhonghuihaotai.com/webpage/wxdist/index.html#/?mallId=171795610000098&time="+new Date().getTime()
// this.webUrl = "https://wx.zhonghuihaotai.com/webpage/wxdist/index.html#/?mallId=134581110000230&companyId=00000310&time="+new Date().getTime() // this.webUrl = "https://wx.zhonghuihaotai.com/webpage/wxdist/index.html#/?mallId=134581110000230&companyId=00000310&time="+new Date().getTime()
}, },
methods:{ methods:{
handleMsg(e){ handleMsg(e){
console.log(e) // uni.navigateToMiniProgram({
console.log('接收到消息:' + JSON.stringify(e.detail.data)); // orderId: data.orderId,
uni.navigateToMiniProgram({ // });
orderId: data.orderId,
});
}, },
saveMiniCode(){ saveMiniCode(){
let fsCode = uni.getStorageSync('token'); let fsCode = uni.getStorageSync('token');
...@@ -31,16 +28,17 @@ ...@@ -31,16 +28,17 @@
if (!res.code && res.data) { if (!res.code && res.data) {
let code = res.data.sfCode; let code = res.data.sfCode;
let time = new Date().getTime(); let time = new Date().getTime();
this.webUrl = `https://wxcs.zhonghuihaotai.com/webpage/wxdist/index.html#/?mallId=106975910000477&companyId=999999998&time=${time}&sfCode=${code}` this.webUrl= `https://wxcs.zhonghuihaotai.com/webpage/wxdist/index.html#/${this.appointPage?this.appointPage:""}?mallId=106975910000477&companyId=999999998&time=${time}&sfCode=${code}&authMode=force`
// this.webUrl = `https://wxcs.zhonghuihaotai.com/webpage/wxdist/index.html#/?mallId=106975910000477&companyId=999999998&time=${time}&sfCode=${code}` // this.webUrl = `https://wxcs.zhonghuihaotai.com/webpage/wxdist/index.html#/?mallId=106975910000477&companyId=999999998&time=${time}&sfCode=${code}`
} else { console.log(this.webUrl)
} }
}) })
} }
}, },
onLoad(){ onLoad(option){
uni.hideTabBar(); this.appointPage = option.appointPage;//指定页面
// uni.hideTabBar();
this.saveMiniCode(); this.saveMiniCode();
}, },
onLaunch(){ onLaunch(){
......
<template> <template>
<view> <view>
<button @click="pay">测试小程序支付</button> <view class="pay-container" v-if="!isPay">
<view class="money-box"><text class="money">{{actuallyPay}}</text></view>
<u-button @click="pay" shape="circle" type="primary" text="确认支付" color="#61b077"></u-button>
</view>
<view class="payResult" v-else>
<u-icon v-if="payStatus == 'pending'" name="clock" size="60px" color="#61b077"></u-icon>
<u-icon v-else-if="payStatus == 'fulfilled'" name="checkmark-circle" size="60px" color="#61b077"></u-icon>
<u-icon v-else name="close-circle" size="60px" color="#ff0000"></u-icon>
<view class="tips">
{{payTips}}
</view>
<view class="bot">
<view class="lf">
<u-button type="primary" color="#61b077" text="查看订单" @click="goPath('shopMallList')"></u-button>
</view>
<view class="rt">
<u-button type="primary" color="#61b077" :plain="true" text="继续购买" @click="goPath('')"></u-button>
</view>
</view>
</view>
</view> </view>
</template> </template>
<script> <script>
import http from '@/shopro/request/index';
export default { export default {
data() { data() {
return { return {
params:{} params:{},
actuallyPay:"",//现金支付
payStatus:'pending',
payTips:"等待中",
orderId:"",
isPay:false
} }
}, },
methods: { methods: {
goPath(path){
uni.navigateTo({
url: `/pages/h5/index?appointPage=${path}`
})
},
// 支付结果查询
payResult(){
http('user.status', {orderId:this.orderId}).then(res => {
if(res.code == 0){
if(res.data) {
this.payStatus = "fulfilled";
this.payTips = "下单成功";
}else{
this.payStatus = "rejected";
this.payTips = "支付有延迟,请查看订单";
}
}
})
},
pay() { pay() {
console.log(this.params) let that = this;
wx.requestPayment({ wx.requestPayment({
appId:this.params.appId,
timeStamp: this.params.timeStamp, timeStamp: this.params.timeStamp,
nonceStr: this.params.nonceStr, nonceStr: this.params.nonceStr,
package: this.params.nonceStr, package: this.params.package,
signType: this.params.signType, signType: this.params.signType,
paySign: this.params.paySign, paySign: this.params.paySign,
success(res) { success(res) {
console.log("小程序成功。。。。") that.isPay = true;
that.payResult();
console.log(res)
}, },
fail(res) { fail(err) {
console.log("shibai 。。。。") that.isPay = false;
console.log(res) if(err.errMsg == 'requestPayment:fail cancel'){
that.$u.toast("取消支付");
}else{
that.$u.toast(err.errMsg);
}
} }
}) })
} }
}, },
onLoad(option){ onLoad(option){
let {data,orderId} = option; let {data,orderId,actuallyPay} = option;
console.log(option); this.actuallyPay = actuallyPay;
this.orderId = orderId;
this.params = JSON.parse(decodeURIComponent(data)); this.params = JSON.parse(decodeURIComponent(data));
console.log(this.params);
} }
} }
</script> </script>
<style lang="scss" scoped>
<style> .pay-container{
.money-box{
font-size: 28rpx;
font-weight: bold;
margin: 100rpx 0 ;
text-align: center;
.money{
font-size: 48rpx;
}
}
::v-deep .u-button{
width: 80%;
}
}
.payResult{
text-align: center;
margin: 100rpx 0 ;
::v-deep .u-icon{
justify-content: center;
}
.tips{
font-size: 38rpx;
color: #61b077;
margin:20rpx 0 80rpx 0 ;
}
.bot{
margin: 0 auto;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 10%;
.lf,.rt{
width: 45%;
}
}
}
</style> </style>
...@@ -6,17 +6,15 @@ ...@@ -6,17 +6,15 @@
<image src="../../static/img/run/runBg.png" class="run-logo" mode="widthFix"></image> <image src="../../static/img/run/runBg.png" class="run-logo" mode="widthFix"></image>
<view class="run-step-number"> <view class="run-step-number">
<text class="title">今日步数</text> <text class="title">今日步数</text>
<view class="steps" v-if="todayNum"> <view class="steps" v-if="unregistered">
<text class="num">{{todayNum}}</text> <text class="num">{{todayNum}}</text>
<text></text> <text></text>
</view> </view>
<view v-else class="steps-empower"> <view v-else class="steps-empower">
<u-button type="primary" size="mini" color="#00c791" :plain="true" text="授权查看"></u-button> <u-button open-type="getPhoneNumber" @getphonenumber="getInfoPhoneNumber" type="primary" size="mini" color="#00c791" :plain="true" text="授权查看"></u-button>
</view> </view>
</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>
<!-- open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" -->
<!-- <button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">1111</button> -->
</view> </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">
...@@ -45,7 +43,7 @@ ...@@ -45,7 +43,7 @@
export default { export default {
data() { data() {
return { return {
todayNum: 0, unregistered:false,
tabBarVal: '步数', tabBarVal: '步数',
registerPopup:true, registerPopup:true,
form:{name:'xxx'}, form:{name:'xxx'},
...@@ -54,55 +52,47 @@ ...@@ -54,55 +52,47 @@
} }
}, },
computed: { computed: {
...mapGetters(['userInfo']) ...mapGetters(['userInfo','todayNum'])
}, },
methods: { methods: {
...mapActions([]), ...mapActions(['getPhoneNumber','registerInfoFn','getWeRunDataFn','authCheck','getUserInfo']),
// 获取步数 // 切换底部tab;
getWeRunData() {
let wRunEncryptedData = {}
let that = this;
uni.getWeRunData({
success: function(res) {
wRunEncryptedData.encryptedData = res.encryptedData
wRunEncryptedData.iv = res.iv
http('user.wxRun', wRunEncryptedData).then(res => {
if (!res.code && res.data) {
// that.todayNum = res.data.todayNum;
that.todayNum = 0;
console.log(that.todayNum)
} else {
that.todayNum = 0;
// that.$u.toast(res.msg);
}
})
}
})
},
changeTabBar(name){ changeTabBar(name){
this.tabBarVal = name; this.tabBarVal = name;
console.log(name)
if(name == '商城') { if(name == '商城') {
// let fsCode = uni.getStorageSync('token'); if(!this.unregistered) {
// http('user.miniCode', {fsCode:fsCode}).then(res => { this.$u.toast("点击授权进行注册");
// if (!res.code && res.data) { return false;
uni.navigateTo({ }
url: '/pages/h5/index', uni.navigateTo({
}) url: '/pages/h5/index',
// } else { })
// that.todayNum = 0;
// }
// })
} }
}, },
getPhoneNumber (e) { // 获取手机号
if(!e.detail.code){ async getInfoPhoneNumber (e) {
this.$u.toast(e.detail.code); let number = await this.getPhoneNumber(e);
let register = await this.registerInfoFn();
if(register){ //注册成功,再掉获取步数接口
let runData = await this.getWeRunDataFn();
runData && (this.unregistered = true);
} }
}, },
async getAuth(){
let token = uni.getStorageSync('token');
// 如果有缓存信息
if (token) {
let auth = await this.authCheck();
if(auth == 0) {
let runData = await this.getWeRunDataFn();
runData && (this.unregistered = true);
}else if(auth == 2001){
this.unregistered = false;
}
} else {
let getUserInfo = await this.getUserInfo();
}
}
}, },
onHide(){ onHide(){
}, },
...@@ -111,45 +101,7 @@ ...@@ -111,45 +101,7 @@
// uni.hideTabBar(); // uni.hideTabBar();
}, },
onReady() { onReady() {
// this.geAauthorizeWeRun() this.getAuth();
let token = uni.getStorageSync('token');
// 如果有缓存信息
if (token) {
let authCheck = store.dispatch('authCheck');
authCheck.then(resolve => {
this.getWeRunData()
}).catch(errCode => {
console.log(errCode)
if (errCode == 2001) {
// 手机号输入
console.log(this.userInfo)
console.log("信息是--------------")
this.registerInfo = {
companyId: '999999998', //开放式传
mobile: '15501156151', //封闭式传
empcardno: '', //封闭式传
registerType: 'register' //注册时的类型为普通注册
}
console.log(this.registerInfo)
http('user.register', this.registerInfo).then(res => {
if (!res.code) {
// this.getWeRunData()
} else {
// that.$u.toast(res.msg);
}
})
}
})
} else {
let getUserInfo = store.dispatch('getUserInfo');
getUserInfo.then(resolve => {
}).catch(errCode => {
})
}
} }
} }
</script> </script>
......
...@@ -65,7 +65,6 @@ export default { ...@@ -65,7 +65,6 @@ export default {
// 处理wechat jssdk 签名网址(针对IOS微信浏览器做优化) // 处理wechat jssdk 签名网址(针对IOS微信浏览器做优化)
entry() { entry() {
let that = this;
var entryUrl = location.href; var entryUrl = location.href;
if (this.device() === 'ios') { if (this.device() === 'ios') {
if (typeof(location.entryUrl) !== 'undefined') { if (typeof(location.entryUrl) !== 'undefined') {
......
...@@ -16,7 +16,7 @@ export default { ...@@ -16,7 +16,7 @@ export default {
}, },
register :{ register :{
url: 'mall/register', url: 'mall/register',
auth: true, auth: false,
method: "post" method: "post"
}, },
wxRun :{ wxRun :{
...@@ -33,6 +33,16 @@ export default { ...@@ -33,6 +33,16 @@ export default {
url: 'mall/miniCode', url: 'mall/miniCode',
auth: true, auth: true,
method: "get" method: "get"
},
miniPhone:{
url:'mall/miniPhone',
auth: false,
method: "get"
},
status:{
url:'order/status',
auth: true,
method: "get"
} }
}, },
index:{ index:{
......
...@@ -2,22 +2,35 @@ ...@@ -2,22 +2,35 @@
import http from '@/shopro/request/index' import http from '@/shopro/request/index'
import api from "@/shopro/request/index"; import api from "@/shopro/request/index";
const state = { const state = {
mallId:'106975910000477',
sessionkey: uni.getStorageSync("sessionkey") || "", sessionkey: uni.getStorageSync("sessionkey") || "",
userInfo: {} userInfo: {},
// token:"" registerInfo: {//注册信息
companyId: '999999998', //开放式传
mobile: '', //封闭式传
empcardno: '', //封闭式传
registerType: 'register' //注册时的类型为普通注册
},
// weRunData:{//今日步数
// todayNum: 0,
// totalNum: 0,
// updateDate: "",
// yesterdayNum: 0
// },
todayNum:0
} }
const getters = { const getters = {
token: state => state.token, token: state => state.token,
userInfo: state => state.userInfo userInfo: state => state.userInfo,
todayNum: state => state.todayNum
} }
const actions = { const actions = {
/***获取用户信息 /***获取用户信息
无token 走获取用户信息接口。 无token 走获取用户信息接口。
有token 走校验authcheck信息 有token 走校验authcheck信息
*/ */
async getUserInfo({ async getUserInfo({
dispatch, dispatch,
commit, commit,
...@@ -37,8 +50,6 @@ const actions = { ...@@ -37,8 +50,6 @@ const actions = {
} else { } else {
uni.login({ uni.login({
success: function(info) { success: function(info) {
console.log("获取手机号======")
console.log(info)
let code = info.code; let code = info.code;
http('user.getHomePage', { http('user.getHomePage', {
code: code, code: code,
...@@ -81,38 +92,100 @@ const actions = { ...@@ -81,38 +92,100 @@ const actions = {
if (res.code === 0) { if (res.code === 0) {
resolve(res.code) resolve(res.code)
} else if (res.code == 1001) { } else if (res.code == 1001) {
dispatch('getUserInfo') dispatch('getUserInfo');
reject(res.code)
} else { } else {
reject(res.code) reject(res.code)
} }
}); });
}) })
}, },
// // 获取用户信息 // 获取手机号
// geAauthorizeWeRun({ getPhoneNumber({commit},e){
// commit, return new Promise((resolve,reject) => {
// dispatch, let code = e.detail.code;
// getters, if(!code){
// state uni.showToast({
// }) { title: code,
// //解密微信运动 duration: 2000,
// uni.getWeRunData({ icon:'none'
// success: function(res) { });
// console.log(res) }else{
// wRunEncryptedData.encryptedData = res.encryptedData http('user.miniPhone',{code:code,mallId:state.mallId}).then(res=>{
// wRunEncryptedData.iv = res.iv if (!res.code && res.data) {
// } state.registerInfo.mobile = res.data;
// }) resolve(res.data);
// }, } else {
uni.showToast({
title: res.msg,
duration: 2000,
icon:'none'
});
reject(0);
}
})
}
})
},
// 注册用户
registerInfoFn({commit,state},e){
return new Promise((resolve,reject) => {
if(!state.registerInfo.mobile){
uni.showToast({
title: "手机号为空",
duration: 2000,
icon:'none'
});
}
http('user.register', state.registerInfo).then(res => {
if (res.code==0) {
resolve(1);
} else{
uni.showToast({
title: res.msg,
duration: 2000,
icon:'none'
});
reject(res.data);
}
})
})
},
// 查询步数
getWeRunDataFn({state}){
return new Promise((resolve,reject) => {
let wRunEncryptedData = {}
uni.getWeRunData({
success: function(res) {
wRunEncryptedData.encryptedData = res.encryptedData;
wRunEncryptedData.iv = res.iv;
http('user.wxRun', wRunEncryptedData).then(res => {
if (!res.code && res.data) {
state.todayNum = res.data.todayNum;
resolve(res.data);
} else {
state.todayNum = 0;
uni.showToast({
title: res.msg,
duration: 2000,
icon:'none'
});
reject(res.data);
}
})
}
})
})
}
} }
const mutations = { const mutations = {
token(state, payload) { token(state, payload) {
state.token = payload; state.token = payload;
uni.setStorageSync("token", payload); uni.setStorageSync("token", payload);
},
USER_INFO(state, info) {
commit("userInfo", info);
} }
} }
export default { export default {
state, state,
......
...@@ -142,7 +142,6 @@ export default { ...@@ -142,7 +142,6 @@ export default {
//微信支付 //微信支付
wxpay(data, callback) { wxpay(data, callback) {
let that = this;
this.isWechat() && this.initJssdk(function(res) { this.isWechat() && this.initJssdk(function(res) {
jweixin.ready(function() { jweixin.ready(function() {
jweixin.chooseWXPay({ jweixin.chooseWXPay({
......
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