Commit 2292d493 by yuzhenWang

Merge branch 'wyz' into 'dev'

增加index.html解析参数

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