Commit 2292d493 by yuzhenWang

Merge branch 'wyz' into 'dev'

增加index.html解析参数

See merge request !114
parents 07acd072 68de31b4
......@@ -3,6 +3,36 @@
<head>
<meta charset="UTF-8" />
<script>
// ============ 新增:解析 URL 参数并设置状态栏占位 ============
//解决项目以h5的方式内嵌到app的webview中,手机状态栏和页面顶部内容重叠的问题
(function() {
function getQueryParam(name) {
// 从 hash 中提取查询参数
const hash = window.location.hash;
const queryIndex = hash.indexOf('?');
console.log('queryIndex', queryIndex);
if (queryIndex === -1) return null;
const queryString = hash.substring(queryIndex + 1);
const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
const r = queryString.match(reg);
console.log('匹配结果', r);
if (r != null) return decodeURIComponent(r[2]);
return null;
}
const statusBarHeight = getQueryParam('statusBarHeight');
console.log('状态栏高度', statusBarHeight);
if (statusBarHeight) {
const height = parseInt(statusBarHeight, 10);
if (!isNaN(height) && height > 0) {
document.write('<style>' +
'html, body { margin:0; padding:0; height:100%; overflow:hidden; }' +
'body { padding-top: ' + height + 'px; box-sizing: border-box; }' +
'#app { height: 100%; overflow-y: auto; }' +
'</style>');
}
}
})();
// ============ 新增结束 ============
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports('top: constant(a)'))
document.write(
......
......@@ -29,7 +29,8 @@
<!-- 家办商城跳cffp的分享功能 -->
<!-- #ifdef H5 -->
<!-- v-if="!generatedImage" -->
<view class="generateImageBox" ref="captureElement" v-if="!generatedImage">
<!-- 生成海报逻辑暂不需要 -->
<!-- <view class="generateImageBox" ref="captureElement" v-if="!generatedImage">
<view class="imgBox">
<img class="posterImg" @load="handleBgImageLoad" @error="handleBgImageError" style="display: block;"
:src="sharePosterItem.fileFirstImage+'?t='+Math.random()" crossorigin="anonymous" alt="防缓存图片" />
......@@ -53,7 +54,7 @@
识别二维码查看商品
</view>
</view>
<!-- 二维码容器 -->
<view class="qrcode-container">
<canvas canvas-id="qrcode" class="qrcode-canvas"
:style="{width: qrCodeSize + 'px', height: qrCodeSize + 'px'}"></canvas>
......@@ -61,7 +62,7 @@
</view>
</view>
</view>
</view> -->
<!-- #endif -->
<view class="productBox">
<view class="productList" :style="{marginTop}">
......
<template>
<view class="container">
<!-- 禁用弹窗 -->
<restrictedTip ref="restrictedTip"/>
<restrictedTip ref="restrictedTip" />
<view style="flex: 1;">
<!-- #ifdef APP -->
<view class="backArrow">
......@@ -11,7 +11,7 @@
<!-- 课程详情 -->
<template v-if="courseInfoItem">
<view class="courseItemBox" >
<view class="courseItemBox">
<course-item :thumbnailPath="courseInfoItem.displayImage" :title="courseInfoItem.fileTitle"
:summaryBox="courseInfoItem.fileSynopsis"
:dataList="{coursePrice:courseInfoItem.coursePrice,salesNumber:courseInfoItem.salesNumber}"
......@@ -22,9 +22,11 @@
<view class="priceInfoContent">
<h4>价格明细</h4>
<view ><text class="txtFont">现价</text><text>¥{{Number(courseInfoItem.coursePrice).toFixed(2)}}</text></view>
<view><text class="txtFont">现价</text><text>¥{{Number(courseInfoItem.coursePrice).toFixed(2)}}</text>
</view>
<view>
<text class="txtFont" @click="toggle(1,'bottom')">积分抵扣<i class="iconfont icon-31tishi txtFont"></i></text>
<text class="txtFont" @click="toggle(1,'bottom')">积分抵扣<i
class="iconfont icon-31tishi txtFont"></i></text>
<text class="integralBox" @click="toggle(2,'bottom')"
v-if="intergralInfo.preFortune">{{isDeduction != 'true' ? '未选' : '已选'}}积分,可抵扣{{deductionCore}}<i
class="iconfont icon-youjiantou iconStyle"></i></text>
......@@ -38,7 +40,7 @@
<!-- 支付方式 -->
<view class="paymentMethodContent">
<h4>选择支付方式</h4>
<view @click="selectPaymentMethod(2)" >
<view @click="selectPaymentMethod(2)">
<view class="paymentItem" v-if="runEnv!=='wechat-miniprogram'">
<view>
<i class="iconfont icon-zhifubao"></i>
......@@ -110,7 +112,8 @@
</view>
<view v-if="popupType===1"><text>1积分=1元,积分抵扣如同现金,所有产品均可使用</text></view>
<view v-if="popupType===2">
<view class="deductionInfoItem" :class="{'actived':isDeduction == 'true'}" @click="selectDeduction(true)">
<view class="deductionInfoItem" :class="{'actived':isDeduction == 'true'}"
@click="selectDeduction(true)">
<view style="display: flex;">
<text>可抵扣</text>
<view class="integralInfoBox">
......@@ -122,7 +125,8 @@
<i class="iconfont icon-duihao " style="font-size: 28rpx;"></i>
</view>
</view>
<view class="deductionInfoItem" :class="{'actived':isDeduction == 'false'}" @click="selectDeduction(false)">
<view class="deductionInfoItem" :class="{'actived':isDeduction == 'false'}"
@click="selectDeduction(false)">
<view>
<text>不使用积分抵扣</text>
</view>
......@@ -180,8 +184,8 @@
<script>
import api from "@/api/api";
import courseItem from "@/components/courseItem/courseItem.vue";
import {apiURL,companyInfo,shareURL} from "@/environments/environment";
import {nextTick} from "vue";
import { apiURL, companyInfo, shareURL } from "@/environments/environment";
import { nextTick } from "vue";
import common from '../../common/common';
import { initJssdkShare, setWechatShare } from '@/util/fiveshare';
import dataHandling from "@/util/dataHandling";
......@@ -215,10 +219,10 @@
isRedirect: null,
amount: 0,
calculatedPrice: 0,
dataToken:'',
oldToken:'',//原始用户token
pollTimer:'',
runEnv:dataHandling.h5RuntimeEnv()
dataToken: '',
oldToken: '', //原始用户token
pollTimer: '',
runEnv: dataHandling.h5RuntimeEnv()
}
},
computed: {
......@@ -242,7 +246,7 @@
methods: {
queryInfo() {
api.queryInfo({userId:uni.getStorageSync('cffp_userId')}).then(res=>{
api.queryInfo({ userId: uni.getStorageSync('cffp_userId') }).then(res => {
// 保存用户得个人信息
if (res['success']) {
delete res.data.commonResult
......@@ -251,12 +255,12 @@
...res.data
}
// 账号禁用用户
if(res.data.userIsActive&&res.data.userIsActive==2){
if (res.data.userIsActive && res.data.userIsActive == 2) {
this.$refs.restrictedTip.open()
uni.setStorageSync('userIsActive',String(res.data.userIsActive))
uni.setStorageSync('userIsActive', String(res.data.userIsActive))
return
}
if(res.data.userIsActive&&res.data.userIsActive!=2){
if (res.data.userIsActive && res.data.userIsActive != 2) {
this.$refs.restrictedTip.close()
uni.removeStorageSync('userIsActive')
}
......@@ -298,10 +302,11 @@
api.unifiedPay(param).then(res => {
this.paymentBtnDisabled = false;
if (res['success']) {
const prepayId = res['data']['prepayId'];//统一下单订单号 如果为空,代表0元订单支付成功
if(prepayId){
const prepayId = res['data']['prepayId']; //统一下单订单号 如果为空,代表0元订单支付成功
if (prepayId) {
const orderInfoParam = {
"appid": res['data']['appid'], // 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致
"appid": res['data'][
'appid'], // 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致
"noncestr": res['data']['noncestr'], // 随机字符串
"package": res['data']['packAge'], // 固定值
"partnerid": res['data']['partnerid'], // 微信支付商户号
......@@ -324,7 +329,7 @@
})
}
});
}else {
} else {
uni.navigateTo({
url: `/pages/orderStatus/orderStatus?orderId=${this.orderId}&fileId=${this.fileId}&orderStatus=2&userId=${this.userId}&isRedirect=1`
})
......@@ -348,7 +353,7 @@
//deviceType:PC为1,移动端为2,微信为3
if (this.deviceType == 3) {
// 向小程序通信
if(dataHandling.h5RuntimeEnv()=='wechat-miniprogram'){
if (dataHandling.h5RuntimeEnv() == 'wechat-miniprogram') {
this.paymentBtnDisabled = false;
// 跳转到小程序消息接收中转页面,拉起小程序的支付
wx.miniProgram.navigateTo({
......@@ -376,7 +381,7 @@
} else {
window.location.href = res['data']['paymentForm']['action'];
}
}else{
} else {
uni.showToast({
title: res['message'],
duration: 2000,
......@@ -458,7 +463,7 @@
}
},
getunifiedPay(param){
getunifiedPay(param) {
api.unifiedPay(param).then((res) => {
const data = res['data'];
......@@ -507,7 +512,7 @@
}).then(res => {
if (res['success']) {
this.courseInfoItem = res['data']['data'];
console.log('this.courseInfoItem',this.courseInfoItem);
console.log('this.courseInfoItem', this.courseInfoItem);
}
})
},
......@@ -540,8 +545,8 @@
if (val === 1) {
this.$refs.popup.close()
if(this.isDeduction == 'true'){
this.toggle(3,'center')
if (this.isDeduction == 'true') {
this.toggle(3, 'center')
}
} else {
this.$refs.popup1.close()
......@@ -572,26 +577,27 @@
}, 500)
}
},
reLogin(option,flag){
reLogin(option, flag) {
uni.showLoading({
title: '加载中...'
});
const params = {
loginType:'5',
loginType: '5',
authToken: uni.getStorageSync('dataToken'),
visitorUuid:uni.getStorageSync('visitorUuid')?uni.getStorageSync('visitorUuid'):dataHandling.uuid()
visitorUuid: uni.getStorageSync('visitorUuid') ? uni.getStorageSync('visitorUuid') : dataHandling
.uuid()
}
api.loginVerification(params).then((res)=>{
if(res['success']){
api.loginVerification(params).then((res) => {
if (res['success']) {
// 之前没使用过系统没有userid,登录并写入缓存
if(flag=='1'){
uni.setStorageSync('isLogin','1');
uni.setStorageSync('loginType','codelogin');
if (flag == '1') {
uni.setStorageSync('isLogin', '1');
uni.setStorageSync('loginType', 'codelogin');
uni.setStorageSync('cffp_userId', res.data.userId);
uni.setStorageSync('uni-token', res.data['token']);
uni.setStorageSync('visitorUuid', res.data['visitorUuid']);
}else if(flag=='2'){
} else if (flag == '2') {
// 有userid,直接可以购买但付款人只是帮订单账号付钱,购买成功还是进入到付款人的账号
this.oldToken = uni.getStorageSync('uni-token')
uni.setStorageSync('oldToken', this.oldToken);
......@@ -599,7 +605,7 @@
}
this.userId = res.data.userId
this.dataToken = ''
}else{
} else {
uni.showToast({
title: res['message'],
duration: 2000,
......@@ -615,20 +621,31 @@
},
onLoad(option) {
if(uni.getStorageSync('dataToken')){
if (uni.getStorageSync('dataToken')) {
this.dataToken = uni.getStorageSync('dataToken')
}
if(uni.getStorageSync('dataToken')){
if (uni.getStorageSync('dataToken')) {
// 没有使用过系统或者之前使用过但未登录
if(!uni.getStorageSync('cffp_userId')|| (uni.getStorageSync('cffp_userId')&&uni.getStorageSync('loginType')=='visitor')){
this.reLogin(option,'1')
}else if(uni.getStorageSync('cffp_userId')!=option.userId){
if (!uni.getStorageSync('cffp_userId') || (uni.getStorageSync('cffp_userId') && uni.getStorageSync(
'loginType') == 'visitor')) {
this.reLogin(option, '1')
} else if (uni.getStorageSync('cffp_userId') != option.userId) {
// 付钱的人和分享的人不一样
this.reLogin(option,'2')
this.reLogin(option, '2')
}
}
dataHandling.pocessTracking(
'购买',
`用户进入到订单确认页`,
'进入',
2,
'订单确认页',
'',
`/pages/orderConfirm/orderConfirm?fileId=${option.fileId}&orderId=${option.orderId}&userId=${option.userId}`
)
this.fileId = Number(option.fileId);
this.orderId = option.orderId;
if (option.userId) {
......@@ -640,25 +657,25 @@
uni.request({
url: `${apiURL}/authorize/obtainToken`,
method: 'POST',
data: {ticket:'uni-app', loginId:option.userId},
data: { ticket: 'uni-app', loginId: option.userId },
success: (res) => {
if (res.statusCode === 200) {
uni.setStorageSync('uni-token', res.data['data']['token']);
uni.setStorageSync('cffp_userId', option.userId);
uni.setStorageSync('isLogin','1');
uni.setStorageSync('isLogin', '1');
uni.setStorageSync('isH5', 1);
this.courseDetailLoad(option);
}
}
});
}else{
} else {
this.courseDetailLoad(option);
}
},
onShow() {
if(uni.getStorageSync('loginType')=='codelogin'){
if (uni.getStorageSync('loginType') == 'codelogin') {
this.queryInfo()
}
// #ifdef H5
......@@ -676,10 +693,11 @@
</script>
<style lang="scss" scoped>
::v-deep .uni-popup .uni-popup__wrapper{
::v-deep .uni-popup .uni-popup__wrapper {
margin: 0 !important;
}
.container {
// position: relative;
width: 100%;
......@@ -687,7 +705,8 @@
display: flex;
flex-direction: column;
.backArrow{
.backArrow {
box-sizing: border-box;
display: flex;
height: 100rpx;
......@@ -698,15 +717,18 @@
margin-bottom: 10rpx;
color: #333333;
background-color: #fff;
text:nth-child(2){
text:nth-child(2) {
width: 100%;
text-align: center;
position: absolute;
}
}
.txtFont{
.txtFont {
font-size: 27rpx;
}
.courseItemBox {
margin: 20rpx;
border-radius: 10rpx;
......@@ -719,6 +741,7 @@
padding: 20rpx;
box-sizing: border-box;
width: 100%;
.title {
display: flex;
justify-content: space-between;
......@@ -1005,7 +1028,8 @@
justify-content: flex-end;
z-index: 100000;
background: rgba(0, 0, 0, 0.8);
.icon-liulanqi{
.icon-liulanqi {
margin: 0px 10rpx;
color: #3b43d5;
background: #fff;
......@@ -1013,6 +1037,7 @@
border-radius: 8rpx;
font-size: 36rpx;
}
.guideImgBox {
margin: 20px auto;
......
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