Browse Source

微信支付与定位修改

master
unknown 7 months ago
parent
commit
2631dd99db
  1. 37
      App.vue
  2. 6
      README.md
  3. 32
      common/js/qqLatLng.js
  4. 4
      config/request.js
  5. 4
      config/site.config.js
  6. 23
      manifest.json
  7. 10
      pages.json
  8. 62
      pages/indexEntry/enroll/payment/payh5.vue
  9. 89
      pages/indexEntry/enroll/payment/payment.vue
  10. 2
      pages/indexEntry/enroll/registInfo/registInfo.vue
  11. 99
      pages/indexEntry/enroll/signContract/webView.vue
  12. 1
      pages/tabbar/index/index.vue
  13. 4
      pages/tabbar/learnCar/comp/topInfo.vue
  14. 19
      pages/tabbar/mine/index.vue
  15. 48
      store/modules/user.js

37
App.vue

@ -1,24 +1,47 @@
<script>
export default {
onLaunch: function() {
console.log('App Launch')
// uni.hideTabBar();
// #ifdef MP-WEIXIN
// initEid();
// #endif
this.getLocationAuthority()
},
onShow: function() {
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
},
methods: {
getLocationAuthority() {
let _this = this
uni.getLocation({
type: 'wgs84',
success: function(res) {
_this.$store.dispatch('getUserInfo')
},
fail: function(err) {
console.log('为什么失败了')
console.log(err)
uni.showModal({
content: '为了能够获取精确的数据,请去手机设置里手动开启app定位权限',
showCancel: false,
confirmText: '知道了,关闭弹窗',
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
}
});
}
}
}
</script>
<style lang="scss">
<style lang="scss">
/*每个页面公共css */
@import '@/uni_modules/uview-ui/index.scss';
@import 'common/css/app.scss'
</style>

6
README.md

@ -0,0 +1,6 @@
易收宝对接文档: [](https://docs.qq.com/doc/DSFJKS01tTlVVUkZU)
小程序的appid:wx9e7d9eea420f6541
中原聚端的appid: wxe8bb3f7b8cf30362

32
common/js/qqLatLng.js

@ -65,6 +65,8 @@ KJTencentLocation.setLocationManagerInfo(dic)
export function requestSingleFreshLocation() {
return new Promise((resolve, reject) => {
console.log(KJTencentLocation.requestSingleFreshLocation)
KJTencentLocation.requestSingleFreshLocation((res) => {
@ -83,21 +85,21 @@ export function requestSingleFreshLocation() {
}
}
if(res.location.latitude==0) {
uni.showModal({
title: 'app想要获取您的定位权限',
content: '为了能够获取精确的数据,请去手机设置里手动开启app定位权限',
showCancel: false,
confirmText: '知道了,关闭弹窗',
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
}
// if(res.location.latitude==0) {
// uni.showModal({
// title: 'app想要获取您的定位权限',
// content: '为了能够获取精确的数据,请去手机设置里手动开启app定位权限',
// showCancel: false,
// confirmText: '知道了,关闭弹窗',
// success: function (res) {
// if (res.confirm) {
// console.log('用户点击确定');
// } else if (res.cancel) {
// console.log('用户点击取消');
// }
// }
// });
// }
resolve(res)
});
})

4
config/request.js

@ -26,8 +26,8 @@ module.exports = (vm) => {
// 初始化请求拦截器时,会执行此方法,此时data为undefined,赋予默认{}
config.data = config.data || {}
// 根据custom参数中配置的是否需要token,添加对应的请求头
// console.log('--------------')
// console.log(config)
console.log('--------------')
console.log(config)
let token = vm.$store.state.user.vuex_loginInfo.accessToken
if(token) {
config.header.Authorization = 'Bearer ' + token

4
config/site.config.js

@ -2,8 +2,8 @@ const VUE_APP_PLATFORM = process.env.VUE_APP_PLATFORM;
// localIp = false
module.exports = {
H5_API: VUE_APP_PLATFORM === 'h5' ? '/api' : '',//h5代理
WX_API: VUE_APP_PLATFORM === 'h5' ? '/' : 'http://192.168.1.38:8318/',//非代理地址
// WX_API: VUE_APP_PLATFORM === 'h5' ? '/' : 'http://work.lyjppt.com:8099/',//非代理地址
WX_API: VUE_APP_PLATFORM === 'h5' ? '/' : 'http://192.168.1.43:8318/',//非代理地址
// WX_API: VUE_APP_PLATFORM === 'h5' ? '/' : 'http://work.lyjppt.com:8099/',// http://192.168.1.43:8318/ http://123.6.232.54:8099/非代理地址
website: 'http://192.168.1.37',
httpPrefix: 'app-api/',
imgUrl: 'https://jiangxijiakao-1.oss-cn-hangzhou.aliyuncs.com/defaultImages/app/bigImg/'

23
manifest.json

@ -2,8 +2,8 @@
"name" : "洛阳学车",
"appid" : "__UNI__3347C6E",
"description" : "",
"versionName" : "1.1.5",
"versionCode" : 115,
"versionName" : "1.1.8",
"versionCode" : 118,
"transformPx" : false,
/* 5+App */
"app-plus" : {
@ -16,13 +16,19 @@
"autoclose" : true,
"delay" : 0
},
"permission" : {
"scope.userLocation" : {
"desc" : "查询用户地理位置,推荐本地驾校,提高用户服务"
}
},
/* */
"modules" : {
"Maps" : {},
"Barcode" : {},
"Geolocation" : {},
"VideoPlayer" : {},
"Share" : {}
"Share" : {},
"Payment" : {}
},
/* */
"distribute" : {
@ -33,6 +39,7 @@
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_BACKGROUND_LOCATION\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
@ -51,8 +58,7 @@
"<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.FOREGROUND_SERVICE\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_LOCATION_EXTRA_COMMANDS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_BACKGROUND_LOCATION\"/>"
"<uses-permission android:name=\"android.permission.ACCESS_LOCATION_EXTRA_COMMANDS\"/>"
]
},
/* ios */
@ -91,6 +97,13 @@
"appkey_android" : "3c5fcc5ee6aaba56e4806f3382399c16",
"name" : "amapOV4nNDfa"
}
},
"payment" : {
"weixin" : {
"__platform__" : [ "ios", "android" ],
"appid" : "wx9e7d9eea420f6541",
"UniversalLinks" : ""
}
}
}
},

10
pages.json

@ -143,7 +143,6 @@
"backgroundTextStyle": "dark"
}
},
{
"path": "enroll/payment/payment",
"style": {
@ -153,6 +152,13 @@
}
},
{
"path": "enroll/payment/payh5",
"style": {
"navigationBarTitleText": "支付",
"backgroundTextStyle": "dark"
}
},
{
"path": "enroll/paymentSuccess/paymentSuccess",
"style": {
"navigationBarTitleText": "报名成功",
@ -422,7 +428,7 @@
{
"path": "myOrder/voucher/voucher",
"style": {
"navigationBarTitleText": "培训缴费电子凭证666",
"navigationBarTitleText": "培训缴费电子凭证",
// "navigationStyle": "custom",
"enablePullDownRefresh": true,
"backgroundTextStyle": "dark"

62
pages/indexEntry/enroll/payment/payh5.vue

@ -0,0 +1,62 @@
<template>
<view class="">
<web-view :src="$store.state.webViewUrl" @onPostMessage="postMessage" @message="postMessage"></web-view>
<!-- <web-view src="http://192.168.1.44:92/vue/wxStudentCertificate3" @onPostMessage="postMessage" @message="postMessage"></web-view> -->
</view>
</template>
<script>
export default {
onLoad() {
this.initWx()
},
methods: {
postMessage(res) {
console.log('监听到了')
let item = res.detail.data[0]
console.log(res)
console.log('监听到的发送事件')
console.log(item)
if(item.action=='lyxc-wxPay') {
this.$u.toast('用户点击了微信支付')
this.wxPay(item)
}else if(item.action=='lyxc-paySuccess') {
this.$u.toast('支付完成,app跳转页面吧')
}
},
// "action": "lyxc-wxPay",
// "miniProgramType": 2,
// "miniAppId": "gh_89b377cbc340",
// "path": "/pages/wxPayOnly/wxPayOnly?channelNo=QD202404083509&orderNo=20240423170705024771&inpartNo=820198016000045&merchantName=&amount=1&redMsg=&payType=04"
wxPay(item) {
console.log(item)
// #ifdef APP-PLUS
this.sweixin ? this.sweixin.launchMiniProgram({
path: item.path, // pages/index/index
type: item.miniProgramType, // 0- 1- 2- 0
id: item.miniAppId //id
}) : plus.nativeUI.alert('当前环境不支持微信操作!');
// #endif
},
initWx() {
// #ifdef APP-PLUS
plus.share.getServices((s) => {
var shares = {};
for (var i = 0; i < s.length; i++) {
var t = s[i];
console.log("...........", t);
shares[t.id] = t;
}
var sweixin = shares['weixin'];
this.sweixin = sweixin
}, function(e) {
console.log("获取分享服务列表失败:" + e.message);
});
// #endif
},
}
}
</script>
<style>
</style>

89
pages/indexEntry/enroll/payment/payment.vue

@ -3,16 +3,16 @@
<view class="pad">
<view class="card">
<view class="orderInfo">
<view class="schoolName">翔力驾校</view>
<view class="schoolName">{{schoolName}}</view>
<view class="price">
<text class="uint"></text>{{ info.a }}
<text class="uint" v-if="amount"></text>{{ $u.utils.priceTo(amount) }}
</view>
<!-- <view class="num">交易单号65465879312</view> -->
</view>
<view class="li border">
<view class="lab">订单金额</view>
<!-- <view class="li border">
amount
<view class="val"> {{info.a}}</view>
</view>
</view> -->
<!-- <view class="li">
<view class="lab">订单编号</view>
<view class="val">{{info.a}}</view>
@ -44,9 +44,10 @@
</view>
</view>
<view class="footerBtn pad">
<view class="btnBg" @click="getYSBLink">确认支付</view>
<view class="btnBg" @click="getStudentByPayment()">确认支付</view>
<!-- <view class="btnBg" @click="paySubmit">确认支付</view> -->
</view>
<web-view :src="link" v-if="link" @load="loadWebView"></web-view>
</view>
</view>
</template>
@ -62,7 +63,8 @@
info: {
a: '待对接'
},
link: ''
schoolName: '',
amount: '0',
}
},
onLoad(options) {
@ -74,9 +76,10 @@
this.initWx()
},
onPullDownRefresh() {
this.getStudentByPayment()
// this.getStudentByPayment()
},
methods: {
initWx() {
// #ifdef APP-PLUS
plus.share.getServices((s) => {
@ -93,47 +96,19 @@
});
// #endif
},
wxPay(data) {
// const data = {
// channelNo: 'QD202401250001', //
// encodeData: '', //{"outOrderNo":"15456","timestamp":"1632815312300"},jsonoutOrderNo
// miniAppName: '', //
// env: '',// u8u6prod
// distinctId: '',//
// unionMode: 'miniProToMiniPro', // 使
// }
// #ifdef APP-PLUS
// this.sweixin ? this.sweixin.launchMiniProgram({
// appId: 'wx9e7d9eea420f6541', //appid wx9e7d9eea420f6541 wx05c2e4857b6806c8
// path: `/pages/ysbCheckStand/ysbCheckStand?data=${JSON.stringify(data)}`, // pages/index/index
// envVersion: 'trial', // trial, release
// }) : plus.nativeUI.alert('!');
this.sweixin ? this.sweixin.launchMiniProgram({
miniAppId: 'wx9e7d9eea420f6541', //ID
path: '', //
miniProgramType: '1', // 0 1 2
}) : plus.nativeUI.alert('当前环境不支持微信操作!');
// #endif
},
async getStudentByPayment() {
async getStudentByPayment(type) {
console.log('来到了这没有')
const {
data: res
} = await pre_create({
trainingApplyId: this.trainingApplyId
})
this.amount = res.amount
this.schoolName = res.schoolName
console.log('创建的订单信息')
// console.log(res.orderNo)
this.encodeData = res.encodeData
// this.param_sign(res.orderNo)
// await this.getYSBLink(res.encodeData)
// this.wxPay()
// this.$store.dispatch('getUserInfo')
// setTimeout(()=>{
// this.wxPay()
// },1500)
console.log(res)
this.param_sign(res.orderNo)
},
//
async param_sign(outOrderNo) {
@ -143,11 +118,12 @@
}
console.log(JSON.stringify(obj))
const {data: res} = await param_sign({jsonParam:JSON.stringify(obj)})
this.encodeData = res.encodeData
console.log('加密后的数据')
console.log(res.encodeData)
this.getYSBLink()
},
getYSBLink() {
async getYSBLink() {
if(!this.encodeData) return this.$u.toast('没有获取到支付信息')
const channelNo = 'QD202404083509';
//commonh5platformpay_miniPro
@ -159,25 +135,16 @@
//
// const preUrl = 'https://zmcht.zybank.com.cn/cem_ysb/index.html';
// let obj = {"outOrderNo":orderNo || "2024041211570300000308","timestamp":"1632815312300"}
// const encodeData = encodeData
// ()-
const distinctId = this.userId
const callback = `${preUrl}?encodeData=${this.encodeData}#/checkStandPre?platform=${platform}&channelNo=${channelNo}&checkStand_v3=true&distinctId=${distinctId}`;
this.link = callback;
console.log('callback')
console.log(callback)
const payLink = `${preUrl}?encodeData=${this.encodeData}#/checkStandPre?platform=${platform}&channelNo=${channelNo}&checkStand_v3=true&distinctId=${distinctId}`;
console.log('payLink')
console.log(payLink)
this.$store.commit('updateWebVeiwUrl', payLink)
this.$goPage('/pages/indexEntry/enroll/payment/payh5')
},
loadWebView() {
console.log('会来到vebview事件里吗?')
this.wxPay()
},
paySubmit() {
console.log('这是什么')
console.log(this.sweixin)
this.wxPay()
// this.$goPage('/pages/indexEntry/enroll/paymentSuccess/paymentSuccess')
}
}
}
</script>

2
pages/indexEntry/enroll/registInfo/registInfo.vue

@ -279,7 +279,7 @@
finishSubjectName: '',//
waitSubjectName: '',//
waitSubject: '',//
photoPath: '',
photoPath: 'https://lyjp-bucket-main.oss-cn-beijing.aliyuncs.com/985114ca01ff35554333927a5d1d52883d3ad21301caac4b637df56169b2c916.png',
address: '',
totalAmount: 0,
transfer: 2, //

99
pages/indexEntry/enroll/signContract/webView.vue

@ -1,99 +0,0 @@
<template>
<view class="page-web">
<!-- 签署合同webview -->
<view class="page-inner">
<web-view :src="$store.state.webViewUrl" @message="message" @onPostMessage="handlePostMessage"></web-view>
</view>
</view>
</template>
<script>
import learnDriveApi from '@/api/learnDrive.js'
export default {
data() {
return {
title: '加载中...',
trainingApplyId: ''
}
},
onLoad(options) {
this.trainingApplyId = options.id
let _this = this
// const currentWebview = _this.$mp.page.$getAppWebview();
this.shang()
},
mounted() {
},
methods: {
shang() {
let _this = this
var currentWebview = this.$scope.$getAppWebview();
setTimeout(()=>{
console.log('currentWebview')
console.log(currentWebview)
let wv = currentWebview.children()[0]
wv.addEventListener('loaded', async function () {
let webVeiwUrl = wv.getURL()
console.log(webVeiwUrl)
var reg = RegExp(/wait/i);//signaturecallback
if(reg.test(webVeiwUrl)){
console.log('匹配成功了')
uni.navigateTo({
url: '/pages/learnDriveStep/payMoney/payMoney?trainingApplyId='+_this.trainingApplyId
})
}
console.log('监听到了————————————————————')
}, false);
},500)
},
handlePostMessage(e) {
console.log('好消息' + e)
}
},
onReady() {
// #ifdef APP-PLUS
// var wv;
// var height = 0;
// uni.getSystemInfo({
// //
// success: (sysinfo) => {
// height = sysinfo.windowHeight; // ---(-50)
// },
// complete: () => {}
// });
// var currentWebview = this.$scope
// .$getAppWebview() //html5plusplus.webview.currentWebview()uni-appvue使plus.webview.currentWebview()
// console.log(height)
// setTimeout(function() {
// wv = currentWebview.children()[0]
// wv.setStyle({
// top: 70,
// height: height
// })
// }, 1000); //
// #endif
}
}
</script>
<style>
.page-web {
flex: 1;
width: 100%;
flex-direction: column;
}
.page-inner {
flex: 1;
}
</style>

1
pages/tabbar/index/index.vue

@ -210,6 +210,7 @@
this.initApi()
},
onShow() {
// if(!this.vuex_cityInfo.lat) {
// this.$store.dispatch('getCity')
// }

4
pages/tabbar/learnCar/comp/topInfo.vue

@ -2,7 +2,9 @@
<view class="topInfo card">
<view class="user_row">
<view class="avatar">
<image :src="vuex_userInfo.photoPath" mode="aspectFill" v-if="vuex_userInfo.photoPath"></image>
<!-- <image :src="vuex_userInfo.photoPath" mode="aspectFill" v-if="vuex_userInfo.photoPath"></image> -->
<image src="https://lyjp-bucket-main.oss-cn-beijing.aliyuncs.com/985114ca01ff35554333927a5d1d52883d3ad21301caac4b637df56169b2c916.png" mode="aspectFill" v-if="vuex_userInfo.photoPath"></image>
</view>
<view class="rightTxt">
<view style="display: flex;align-items: center;" @click="topClick">

19
pages/tabbar/mine/index.vue

@ -4,7 +4,9 @@
<!-- 用户信息 -->
<view class="userInfo">
<view class="avatar">
<image :src="vuex_userInfo.photoPath" mode="aspectFill" v-if="vuex_userInfo.photoPath" @click="show=true"></image>
<!-- <image :src="vuex_userInfo.photoPath" mode="aspectFill" v-if="vuex_userInfo.photoPath" @click="show=true"></image> -->
<image src="https://lyjp-bucket-main.oss-cn-beijing.aliyuncs.com/985114ca01ff35554333927a5d1d52883d3ad21301caac4b637df56169b2c916.png" mode="aspectFill" v-if="vuex_userInfo.photoPath" ></image>
</view>
<view class="rightInfo" @click="topClick">
<view class="name-row">
@ -69,7 +71,7 @@
{name: '学时查询', icon: require('@/static/images/mineIcon/minIcon (4).png'),url: '/pages/mineEntry/carLearnHours/carLearnHours'},
{name: '我的评价', icon: require('@/static/images/mineIcon/minIcon (1).png'),url: '/pages/mineEntry/myEvaluate/myEvaluate'},
// {name: '退', icon: require('@/static/images/mineIcon/minIcon (3).png'),url: '/pages/mineEntry/refund/refund'},
{name: '变更车型', icon: require('@/static/images/mineIcon/minIcon (7).png'),url: '/pages/mineEntry/modelChange/modelChange'},
// {name: '', icon: require('@/static/images/mineIcon/minIcon (7).png'),url: '/pages/mineEntry/modelChange/modelChange'},
{name: '同城转校', icon: require('@/static/images/mineIcon/minIcon (5).png'),url: '/pages/mineEntry/schoolTransfer/schoolTransfer'},
// {name: '退', icon: require('@/static/images/mineIcon/minIcon (6).png'),url: ''},
{name: '关于我们', icon: require('@/static/images/mineIcon/minIcon (2).png'),url: '/pages/mineEntry/aboutUs/aboutUs'},
@ -92,8 +94,17 @@
if(item.name=='我的订单'&&this.vuex_userInfo.applyStep>2&&this.vuex_userInfo.applyStep<6) {
return this.$goPage('/pages/mineEntry/myForecastName/myForecastName')
}
if(this.vuex_userInfo.applyStep!=6) {
return this.$u.toast('您还未报名驾校')
// if(this.vuex_userInfo.applyStep!=6) {
// return this.$u.toast('')
// }
if(item.name=='同城转校') {
uni.showModal({
content: '请在原驾校退学后至新驾校报名!',
success:(res)=> {
if(res.confirm) this.$goPage(item.url)
}
})
return false
}
}
this.$goPage(item.url)

48
store/modules/user.js

@ -179,8 +179,9 @@ function getCityInfo(resolve, reject, commit) {
let result = res.location
if(result.latitude===0) {
console.log('gogogo来了吗?')
// openGps()
// uni.getLocation({
// type: 'wgs84',
// // type: 'wgs84',
// type: 'gcj02',
// success: function(res) {
// console.log('只为弹出权限当前位置的经度:' + res.longitude);
@ -221,3 +222,48 @@ function getCityInfo(resolve, reject, commit) {
}
}
function openGps(){
plus.android.requestPermissions(
['android.permission.ACCESS_FINE_LOCATION'],
function(resultObj) {
var result = 0;
for (var i = 0; i < resultObj.granted.length; i++) {
var grantedPermission = resultObj.granted[i];
console.log('已获取的权限:' + grantedPermission);
result = 1
}
for (var i = 0; i < resultObj.deniedPresent.length; i++) {
var deniedPresentPermission = resultObj.deniedPresent[i];
console.log('拒绝本次申请的权限:' + deniedPresentPermission);
result = 0
}
for (var i = 0; i < resultObj.deniedAlways.length; i++) {
var deniedAlwaysPermission = resultObj.deniedAlways[i];
console.log('永久拒绝申请的权限:' + deniedAlwaysPermission);
result = -1
}
// 若所需权限被拒绝,则打开APP设置界面,可以在APP设置界面打开相应权限
if (result != 1) {
//如果用户第一次拒绝后,跳转到**应用**的权限页面
var Intent = plus.android.importClass("android.content.Intent");
var Settings = plus.android.importClass("android.provider.Settings");
var Uri = plus.android.importClass("android.net.Uri");
var mainActivity = plus.android.runtimeMainActivity();
var intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
var uri = Uri.fromParts("package", mainActivity.getPackageName(), null);
intent.setData(uri);
mainActivity.startActivity(intent);
}
},
function(error) {
console.log('申请权限错误:' + error.code + " = " + error.message);
resolve({
code: error.code,
message: error.message
});
}
);
}
Loading…
Cancel
Save