parent
8866ea3313
commit
7cef51200c
@ -0,0 +1,484 @@ |
||||
<template> |
||||
<view class="QS-tabs" :style="{ |
||||
'z-index': zIndex, |
||||
'font-size': getFontSize + 'rpx', |
||||
'background-color': getBgColor, |
||||
'transition-duration': getDuration + 's' |
||||
}"> |
||||
<scroll-view scroll-x class="QS-tabs-scroll" :scroll-left="left" scroll-with-animation :style="{ |
||||
'z-index': (Number(zIndex) + 1) |
||||
}"> |
||||
<view class="QS-tabs-scroll-box"> |
||||
<!-- 循环tabs --> |
||||
<view class="QS-tabs-scroll-item" :style="{ |
||||
'height':'100rpx', |
||||
'line-height': getHeight + 'rpx', |
||||
'min-width': getWidth + 'rpx', |
||||
'padding': '0 ' + space + 'rpx', |
||||
'color': index===getCurrent?getActiveColor:getDefaultColor, |
||||
'font-weight': activeBold&&index===getCurrent?'bold':'', |
||||
'transition-duration': getDuration + 's', |
||||
'z-index': (Number(zIndex) + 2) |
||||
}" |
||||
v-for="(item, index) in getTabs" :key="index" @tap="emit(index)" :id="preId + index"> |
||||
<!-- line1 --> |
||||
<view v-if="animationMode==='line1'" class="boxStyle" :style="getDurationStyle +( index===getCurrent?getActiveStyle:getDefaultStyle)"></view> |
||||
{{item.name || item}} |
||||
</view> |
||||
<!-- itemBackground --> |
||||
<view v-if="hasItemBackground" class="itemBackgroundBox" :style="{ |
||||
'height': getHeight + 'rpx', |
||||
'width': (isLine3&&tabsInfo[animationFinishCurrent]?tabsInfo[animationFinishCurrent].width:tabsInfo[getCurrent].width) + 'px', |
||||
'z-index': Number(zIndex) + 1, |
||||
'transition-duration': getDuration + 's', |
||||
'left': (tabsInfo[getCurrent]?tabsInfo[getCurrent].left:0) + 'px' |
||||
}"> |
||||
<view class="itemBackground" :style="'transition-duration:' + getDuration + 's;' + |
||||
'background-color:' + getItemBackgroundColor + ';' + |
||||
'box-shadow: 0 0 5rpx 5rpx ' + getItemBackgroundColor + ';' + |
||||
itemBackgroundStyle + ';'" /> |
||||
</view> |
||||
<!-- line2 --> |
||||
<view v-if="animationMode==='line2'" class="boxStyle2" :style="getLinezIndex + getDurationStyle + |
||||
'width:' + lW + 'px;' + |
||||
'background-color:' + (lineColor||getActiveColor) + ';' + |
||||
line2Style + ';' + |
||||
'left:' + line2Dx + 'px;'" /> |
||||
|
||||
<view v-if="animationMode==='line3'" class="boxStyle2" :style="getLinezIndex + |
||||
'width:' + lW + 'px;' + |
||||
'background-color:' + (lineColor||getActiveColor) + ';' + |
||||
line2Style + ';' + |
||||
'left:' + getLine3Dx + 'px'" /> |
||||
|
||||
</view> |
||||
</scroll-view> |
||||
</view> |
||||
</template> |
||||
|
||||
<script> |
||||
const { |
||||
windowWidth |
||||
} = uni.getSystemInfoSync(); |
||||
const preId = 'QSTabsID_'; |
||||
export default { |
||||
props: { |
||||
tabs: { //需循环的标签列表 |
||||
type: Array, |
||||
default () { |
||||
return []; |
||||
} |
||||
}, |
||||
current: { //当前所在滑块的 index |
||||
type: Number, |
||||
default: 0 |
||||
}, |
||||
height: { //QS-tabs的高度和行高 |
||||
type: [String, Number], |
||||
default: 80 |
||||
}, |
||||
minWidth: { //单个tab的最小宽度 //v1.4修改 |
||||
type: [String, Number], |
||||
default: 250 |
||||
}, |
||||
fontSize: { //字体大小 |
||||
type: [String, Number], |
||||
default: 30 |
||||
}, |
||||
duration: { //过渡动画时长, 单位 s |
||||
type: [String, Number], |
||||
default: .5 |
||||
}, |
||||
activeColor: { //选中项的主题颜色 |
||||
type: String, |
||||
default: '#33cc33' |
||||
}, |
||||
defaultColor: { //未选中项的主题颜色 |
||||
type: String, |
||||
default: '#888' |
||||
}, |
||||
animationLineWidth: { //动画线条的宽度 |
||||
type: [String, Number], |
||||
default: 20 |
||||
}, |
||||
line2Style: { //line2线条的样式 |
||||
type: String, |
||||
default: 'height: 8rpx;border-radius: 4rpx;' |
||||
}, |
||||
animationMode: { //动画类型 |
||||
type: String, |
||||
default: 'line1' |
||||
}, |
||||
autoCenter: { //是否自动滚动至中心目标 |
||||
type: Boolean, |
||||
default: true |
||||
}, |
||||
autoCenterMode: { //滚动至中心目标类型 |
||||
type: String, |
||||
default: 'component' |
||||
}, |
||||
activeStyle: { //line1模式选中项的样式 |
||||
type: String, |
||||
default: 'bottom:0;left:50%;transform: translate(-50%,-100%);height: 8rpx;border-radius:4rpx;' |
||||
}, |
||||
defaultStyle: { //line1模式未选中项的样式 |
||||
type: String, |
||||
default: 'bottom:0;left:50%;transform: translate(-50%,-100%);height: 8rpx;border-radius:4rpx;' |
||||
}, |
||||
backgroundColor: { //统一背景颜色 |
||||
type: String, |
||||
default: 'rgba(255,255,255,0)' |
||||
}, |
||||
hasItemBackground: { //是否开启背景追光 |
||||
type: Boolean, |
||||
default: false |
||||
}, |
||||
itemBackgroundColor: { //统一追光背景颜色 |
||||
type: String, |
||||
default: 'rgba(255,255,255,0)' |
||||
}, |
||||
itemBackgroundStyle: { //追光样式 |
||||
type: String, |
||||
default: '' |
||||
}, |
||||
zIndex: { //css的z-index属性值 |
||||
type: [String, Number], |
||||
default: 99 |
||||
}, |
||||
swiperWidth: { //line3生效, 外部swiper的宽度, 单位rpx |
||||
type: [String, Number], |
||||
default: 750 |
||||
}, |
||||
space: { //tab间距 |
||||
type: [String, Number], |
||||
default: '0' |
||||
}, |
||||
activeBold: { //当前tab字体是否加粗 |
||||
type: Boolean, |
||||
default: true |
||||
}, |
||||
lineColor: { //line颜色 |
||||
type: String, |
||||
default: '' |
||||
} |
||||
}, |
||||
computed: { |
||||
isLine3() { |
||||
return this.animationMode === 'line3'; |
||||
}, |
||||
getCurrent() { |
||||
const current = Number(this.current); |
||||
if (current > (this.getTabs.length - 1)) { |
||||
return (this.getTabs.length - 1) |
||||
} |
||||
return current; |
||||
}, |
||||
getTabs() { |
||||
return this.tabs; |
||||
}, |
||||
getHeight() { |
||||
return Number(this.height); |
||||
}, |
||||
getWidth() { |
||||
return Number(this.minWidth); |
||||
}, |
||||
getFontSize() { |
||||
return this.fontSize; |
||||
}, |
||||
getDuration() { |
||||
return Number(this.duration); |
||||
}, |
||||
getBgColor() { |
||||
const defaultColor = this.backgroundColor || 'rgba(255,255,255,0)'; |
||||
if (this.getTabs[this.getCurrent] instanceof Object) { |
||||
return this.getTabs[this.getCurrent].backgroundColor || defaultColor; |
||||
} else { |
||||
return defaultColor; |
||||
} |
||||
}, |
||||
getItemBackgroundColor() { |
||||
const defaultColor = this.itemBackgroundColor || 'rgba(255,255,255,0)'; |
||||
if (this.getTabs[this.getCurrent] instanceof Object) { |
||||
return this.getTabs[this.getCurrent].itemBackgroundColor || defaultColor; |
||||
} else { |
||||
return defaultColor; |
||||
} |
||||
}, |
||||
getDurationStyle() { |
||||
return `transition-duration: ${this.getDuration}s;` |
||||
}, |
||||
getActiveColor() { |
||||
let activeColor; |
||||
if (this.getTabs[this.getCurrent] instanceof Object) { |
||||
if (this.getTabs[this.getCurrent].activeColor) { |
||||
activeColor = this.getTabs[this.getCurrent].activeColor; |
||||
} else { |
||||
activeColor = this.activeColor; |
||||
} |
||||
} else { |
||||
activeColor = this.activeColor; |
||||
} |
||||
return activeColor; |
||||
}, |
||||
getDefaultColor() { |
||||
let defaultColor; |
||||
if (this.getTabs[this.getCurrent] instanceof Object) { |
||||
if (this.getTabs[this.getCurrent].defaultColor) { |
||||
defaultColor = this.getTabs[this.getCurrent].defaultColor; |
||||
} else { |
||||
defaultColor = this.defaultColor; |
||||
} |
||||
} else { |
||||
defaultColor = this.defaultColor; |
||||
} |
||||
return defaultColor; |
||||
}, |
||||
getActiveStyle() { |
||||
return `width:${this.animationLineWidth}%;background-color:${this.getActiveColor};${this.activeStyle};`; |
||||
}, |
||||
getDefaultStyle() { |
||||
return `width:0;background-color:${this.getActiveColor};${this.defaultStyle};`; |
||||
}, |
||||
getLinezIndexNum() { |
||||
return Number(this.zIndex) + 2; |
||||
}, |
||||
getLinezIndex() { |
||||
return `z-index: ${this.getLinezIndexNum};`; |
||||
}, |
||||
getLine3Dx() { |
||||
return Number(this.line3Dx) + Number(this.line3AddDx); |
||||
} |
||||
}, |
||||
watch: { |
||||
current(n, o) { |
||||
this.change(n); |
||||
}, |
||||
tabs() { |
||||
this.init(); |
||||
} |
||||
}, |
||||
data() { |
||||
return { |
||||
left: 0, |
||||
tabsInfo: [], |
||||
line2Width: Number(this.animationLineWidth), |
||||
setTimeoutFc: null, |
||||
componentsWidth: 0, |
||||
animationFinishCurrent: this.current, |
||||
pxWidth: 0, |
||||
lW: 0, |
||||
sW: 0, |
||||
preId, |
||||
line3Dx: 0, |
||||
line3AddDx: 0, |
||||
line2Dx: 0 |
||||
} |
||||
}, |
||||
// #ifndef H5 |
||||
onReady() { |
||||
this.init(); |
||||
}, |
||||
// #endif |
||||
// #ifdef H5 |
||||
mounted() { |
||||
this.init(); |
||||
}, |
||||
// #endif |
||||
methods: { |
||||
init() { |
||||
this.countPx(); |
||||
let view = uni.createSelectorQuery().in(this); |
||||
for (let i = 0; i < this.tabs.length; i++) { |
||||
view.select('#' + preId + i).boundingClientRect(); |
||||
} |
||||
view.exec((res) => { |
||||
const arr = []; |
||||
for (let i = 0; i < res.length; i++) { |
||||
arr.push(res[i]); |
||||
} |
||||
this.tabsInfo = arr; |
||||
this.countLine2Dx(); |
||||
this.countLine3Dx(); |
||||
let _this = this; |
||||
_this.getQuery(() => { |
||||
_this.countScrollX(); |
||||
}); |
||||
}) |
||||
}, |
||||
countLine2Dx() { |
||||
if (this.animationMode === 'line2') { |
||||
const tab = this.tabsInfo[this.getCurrent]; |
||||
if(tab) this.line2Dx = tab.left + tab.width / 2 - this.lW / 2; |
||||
} |
||||
}, |
||||
countLine3Dx() { |
||||
if (this.animationMode === 'line3') { |
||||
const tab = this.tabsInfo[this.animationFinishCurrent]; |
||||
if(tab) this.line3Dx = tab.left + tab.width / 2 - this.lW / 2; |
||||
} |
||||
}, |
||||
countPx() { |
||||
const w = uni.upx2px(this.getWidth); |
||||
this.pxWidth = w; |
||||
this.lW = (w * (Number(this.animationLineWidth) / 100))+72.5; |
||||
this.sW = uni.upx2px(Number(this.swiperWidth)); |
||||
}, |
||||
emit(index) { |
||||
this.$emit('change', index); |
||||
}, |
||||
change() { |
||||
this.countScrollX(); |
||||
if (this.animationMode === 'line2') { |
||||
this.line2Width = 2; |
||||
if (this.setTimeoutFc) clearTimeout(this.setTimeoutFc); |
||||
this.setTimeoutFc = setTimeout(() => { |
||||
this.line2Width = this.animationLineWidth; |
||||
}, this.getDuration * 1000 * 3 / 5); |
||||
this.countLine2Dx(); |
||||
} |
||||
}, |
||||
getQuery(cb) { |
||||
try { |
||||
let view = uni.createSelectorQuery().in(this).select('.QS-tabs'); |
||||
view.fields({ |
||||
size: true |
||||
}, data => { |
||||
if (data) { |
||||
this.componentsWidth = data.width; |
||||
if (cb && typeof cb === 'function') cb(data); |
||||
} else { |
||||
this.retryGetQuery(cb); |
||||
} |
||||
}).exec(); |
||||
} catch (e) { |
||||
//TODO handle the exception |
||||
this.componentsWidth = windowWidth; |
||||
} |
||||
}, |
||||
retryGetQuery(cb) { |
||||
try { |
||||
let view = uni.createSelectorQuery().select('.QS-tabs'); |
||||
view.fields({ |
||||
size: true |
||||
}, data => { |
||||
if (data) { |
||||
this.componentsWidth = data.width; |
||||
} else { |
||||
this.componentsWidth = windowWidth; |
||||
} |
||||
if (cb && typeof cb === 'function') cb(data); |
||||
}).exec(); |
||||
} catch (e) { |
||||
//TODO handle the exception |
||||
this.componentsWidth = windowWidth; |
||||
} |
||||
}, |
||||
countScrollX() { |
||||
if (this.autoCenter) { |
||||
let tab; |
||||
if(this.isLine3) { |
||||
tab = this.tabsInfo[this.animationFinishCurrent]; |
||||
}else{ |
||||
tab = this.tabsInfo[this.getCurrent]; |
||||
} |
||||
if(tab) { |
||||
let tabCenter = tab.left + tab.width/2; |
||||
let fatherWidth; |
||||
if (this.autoCenterMode === 'window') { |
||||
fatherWidth = windowWidth; |
||||
} else { |
||||
fatherWidth = this.componentsWidth; |
||||
} |
||||
this.left = tabCenter - fatherWidth / 2; |
||||
} |
||||
} |
||||
}, |
||||
setDx(dx) { |
||||
const tab = this.tabsInfo[dx>0?(this.animationFinishCurrent + 1):(this.animationFinishCurrent - 1)]; |
||||
this.line3AddDx = dx / this.sW * (tab?tab.width:this.pxWidth); |
||||
}, |
||||
setFinishCurrent(current) { |
||||
this.line3AddDx = 0; |
||||
this.animationFinishCurrent = current; |
||||
this.countLine3Dx(); |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style scoped> |
||||
view, |
||||
scroll-view { |
||||
box-sizing: border-box; |
||||
} |
||||
|
||||
.QS-tabs { |
||||
width: 100%; |
||||
transition-property: background-color, color; |
||||
} |
||||
|
||||
.QS-tabs::-webkit-scrollbar { |
||||
display: none; |
||||
width: 0 !important; |
||||
height: 0 !important; |
||||
-webkit-appearance: none; |
||||
background: transparent; |
||||
} |
||||
|
||||
.QS-tabs-scroll { |
||||
width: 100%; |
||||
white-space: nowrap; |
||||
position: relative; |
||||
} |
||||
|
||||
.QS-tabs-scroll-box { |
||||
position: relative; |
||||
display: flex; |
||||
white-space: nowrap !important; |
||||
display: block !important; |
||||
} |
||||
|
||||
.QS-tabs-scroll-item { |
||||
position: relative; |
||||
display: inline-block; |
||||
text-align: center; |
||||
transition-property: background-color, color, font-weight; |
||||
} |
||||
|
||||
.content { |
||||
overflow: hidden; |
||||
white-space: nowrap; |
||||
text-overflow: ellipsis; |
||||
} |
||||
|
||||
.boxStyle { |
||||
pointer-events: none; |
||||
position: absolute; |
||||
transition-property: all; |
||||
} |
||||
|
||||
.boxStyle2 { |
||||
pointer-events: none; |
||||
position: absolute; |
||||
bottom: 0; |
||||
transition-property: all; |
||||
transform: translateY(-100%); |
||||
} |
||||
|
||||
.itemBackgroundBox { |
||||
pointer-events: none; |
||||
position: absolute; |
||||
top: 0; |
||||
transition-property: left, background-color; |
||||
display: flex; |
||||
flex-direction: row; |
||||
justify-content: center; |
||||
align-items: center; |
||||
} |
||||
|
||||
.itemBackground { |
||||
height: 100%; |
||||
width: 100%; |
||||
transition-property: all; |
||||
} |
||||
</style> |
@ -1,314 +1,392 @@ |
||||
<template> |
||||
<view> |
||||
<view class="width100 height100p backcorf06"> |
||||
<view class="block"> |
||||
<view class="content height60"> |
||||
<input type="number" class="my flleft font18 fcorfff" placeholder="请输入充值号码" v-model="inputPhone" /> |
||||
<template> |
||||
<view> |
||||
<view class="width100 height100p backcorf06"> |
||||
<view class="block"> |
||||
<view class="content height60"> |
||||
<input type="number" class="my flleft font18 fcorfff" placeholder="请输入充值号码" v-model="inputPhone" /> |
||||
</view> |
||||
<view class="line1 width100 backcorfff"></view> |
||||
</view> |
||||
</view> |
||||
<view class="mart5"> |
||||
<QSTabs ref="tabs" :tabs="tabs" animationMode="line2" :current="current" @change="change" |
||||
activeColor="#089bf5" lineColor="#089bf5" minWidth="374"> |
||||
</QSTabs> |
||||
</view> |
||||
<view class="width90 font16 fcor333 fontwig6 mart20"> |
||||
选择金额 |
||||
</view> |
||||
<view class="list"> |
||||
<view class="box" :class="{'on':item.realPrice == inputAmount}" v-for="(item,index) in amountList" |
||||
:key="index" @click="select(item)"> |
||||
<view class="heTitle">{{item.price}}元</view> |
||||
<view class="font13 fcor999" v-if="item.status == 2">已售空</view> |
||||
</view> |
||||
</view> |
||||
<view class="mart5 width90 font18 fcor333 fontwig6"> |
||||
充值说明: |
||||
</view> |
||||
<view v-if="current == 0"> |
||||
<view class="mart5 width80 font14 fcoreb5 fontwig6" style="list-style-type: decimal;"> |
||||
<view style="width: 5%;" class="flleft">1:</view> |
||||
<view style="margin-left: 5%;">此业务为话费慢充。日常72小时内到账,如遇月初、月末运营商高峰期或系统更新,到账时间会有一定延迟,敬请谅解。充值失败后系统会自动为您退款至原账户。急单请选择“6小时到账”充值端口,感谢您的支持! |
||||
</view> |
||||
<view class="line1 width100 backcorfff"></view> |
||||
</view> |
||||
</view> |
||||
<view class="width90 font16 fcor333 fontwig6 mart40"> |
||||
选择金额 |
||||
</view> |
||||
<view class="list"> |
||||
<view class="box" :class="{'on':item.realPrice == inputAmount}" v-for="(item,index) in amountList" :key="index" |
||||
@click="select(item)"> |
||||
<view class="heTitle">{{item.price}}元</view> |
||||
<view class="font13 fcor999" v-if="item.status == 2">已售空</view> |
||||
<view class="mart5 width80 font14 fcor999 fontwig6" style="list-style-type: decimal;"> |
||||
<view style="width: 5%;" class="flleft">2:</view> |
||||
<view style="margin-left: 5%;">慢充话费与营业厅充值一样,只是到账时间稍长。充值过程中可能出现分批到账的情况,但是总金额不会少,请耐心等待。</view> |
||||
</view> |
||||
<view class="mart5 width80 font14 fcor999 fontwig6" style="list-style-type: decimal;"> |
||||
<view style="width: 5%;" class="flleft">3:</view> |
||||
<view style="margin-left: 5%;"> |
||||
目前仅支持(移动、联通、电信三网号段),运营商黑名单号码(长期欠费或非实名制认证)携号转网空号、虚拟卡(如165167170171162等等虚拟号段)副卡号码或做过某些特殊套餐绑定的卡暂不支持充值,请勿下单。 |
||||
</view> |
||||
</view> |
||||
<view class="mart5 width80 font14 fcor999 fontwig6" style="list-style-type: decimal;"> |
||||
<view style="width: 5%;" class="flleft">4:</view> |
||||
<view style="margin-left: 5%;">停机号码需要额外补缴欠费后,慢充话费才能到账。<text |
||||
class="fcoreb5">此服务为虚拟充值类服务,无特殊情况不支持退款,下单前请确认充值的号码无误。</text></view> |
||||
</view> |
||||
<view class="mart5 width80 font14 fcor999 fontwig6" style="list-style-type: decimal;"> |
||||
<view style="width: 5%;" class="flleft">5:</view> |
||||
<view style="margin-left: 5%;">空号、错号充值后不支持退款,请您务必核对确认号码无误后再进行充值。非空号欠费可充,欠费1个月导致空号的不能充值,损失自负无法退款。 |
||||
</view> |
||||
</view> |
||||
<view class="mart5 width80 font14 fcor999 fontwig6" style="list-style-type: decimal;"> |
||||
<view style="width: 5%;" class="flleft">6:</view> |
||||
<view style="margin-left: 5%;"><text |
||||
class="fcoreb5">本充值业务不提供发票</text>。如需发票请在运营商手机客户端储开取电子发票,也可以凭身份证到运营商实体营业厅打印发票。</view> |
||||
</view> |
||||
<view class="mart5 width80 font14 fcor999 fontwig6" style="list-style-type: decimal;"> |
||||
<view style="width: 5%;" class="flleft">7:</view> |
||||
<view style="margin-left: 5%;">如遇系统维护充值失败,将72小时后原路退款到付款账户。 </view> |
||||
</view> |
||||
<view class="mart5 width80 font14 fcor999 fontwig6 marb40" style="list-style-type: decimal;"> |
||||
<view style="width: 5%;" class="flleft">8:</view> |
||||
<view style="margin-left: 5%;">请登录所属运营商app(手机营业厅)查看充值号码的到账情况,如金额有出入或未到账,请截图充值记录明细反馈给客服。录明细反馈给客服。</view> |
||||
</view> |
||||
</view> |
||||
<view class="mart5 width90 font18 fcor333 fontwig6"> |
||||
话费充值温馨提示: |
||||
</view> |
||||
<view class="mart5 width80 font14 fcor999 fontwig6" style="list-style-type: decimal;"> |
||||
<view style="width: 5%;" class="flleft">1:</view> |
||||
<view style="margin-left: 5%;">慢充话费与营业厅充值一样,只是到账时间稍长。充值过程中可能出现分批到账的情况,但是总金额不会少,请耐心等待。</view> |
||||
</view> |
||||
<view class="mart5 width80 font14 fcor999 fontwig6" style="list-style-type: decimal;"> |
||||
<view style="width: 5%;" class="flleft">2:</view> |
||||
<view style="margin-left: 5%;">此业务为话费慢充,日常72小时内到账,如遇月初、月末高峰期或系统更新到账时间会有一定延迟,敬请谅解!急单勿拍!</view> |
||||
</view> |
||||
<view class="mart5 width80 font14 fcor999 fontwig6" style="list-style-type: decimal;"> |
||||
<view style="width: 5%;" class="flleft">3:</view> |
||||
<view style="margin-left: 5%;">目前仅支持(移动、联通、电信三网号段), 运营商黑名单号码(长期欠费或非实名制认证)、携号转网,空号、虚拟卡(如165.167.170.171.162等等虚拟号段)、副卡号码或做过某些特殊套餐绑定的卡暂不支持充值,请勿下单。</view> |
||||
</view> |
||||
<view class="mart5 width80 font14 fcor999 fontwig6" style="list-style-type: decimal;"> |
||||
<view style="width: 5%;" class="flleft">4:</view> |
||||
<view style="margin-left: 5%;">停机号码需要额外补缴欠费后,慢充话费才能到账。<text class="fcoreb5">此服务为虚拟充值类服务,无特殊情况不支持退款,下单前请确认充值的号码无误。</text></view> |
||||
</view> |
||||
<view class="mart5 width80 font14 fcor999 fontwig6" style="list-style-type: decimal;"> |
||||
<view style="width: 5%;" class="flleft">5:</view> |
||||
<view style="margin-left: 5%;">空号、错号充值后不支持退款,请您务必核对确认号码无误后再进行充值。非空号欠费可充,欠费1个月导致空号的不能充值,损失自负无法退款。</view> |
||||
</view> |
||||
<view class="mart5 width80 font14 fcor999 fontwig6" style="list-style-type: decimal;"> |
||||
<view style="width: 5%;" class="flleft">6:</view> |
||||
<view style="margin-left: 5%;"><text class="fcoreb5">本充值业务不提供发票</text>。如需发票请在运营商手机客户端储开取电子发票,也可以凭身份证到运营商实体营业厅打印发票。</view> |
||||
</view> |
||||
<view class="mart5 width80 font14 fcor999 fontwig6" style="list-style-type: decimal;"> |
||||
<view style="width: 5%;" class="flleft">7:</view> |
||||
<view style="margin-left: 5%;">如遇系统维护充值失败,将72小时后原路退款到付款账户。 </view> |
||||
</view> |
||||
<view class="mart5 width80 font14 fcor999 fontwig6 marb40" style="list-style-type: decimal;"> |
||||
<view style="width: 5%;" class="flleft">8:</view> |
||||
<view style="margin-left: 5%;">请登录所属运营商app(手机营业厅)查看充值号码的到账情况,如金额有出入或未到账,请截图充值记录明细反馈给客服。</view> |
||||
</view> |
||||
<view class="height100p"></view> |
||||
<view class="bombtn width94 font16"> |
||||
<view class="width50 flleft payem">应付: {{inputAmount}}元</view> |
||||
<view class="width50 flright paybtn" @click="addOrderPay">立即购买</view> |
||||
</view> |
||||
</view> |
||||
</template> |
||||
|
||||
<script> |
||||
let app = getApp(); |
||||
import { |
||||
getListOutRechargePrice, |
||||
addOrderPay, |
||||
orderToUnionPayphone |
||||
} from '../../../Utils/Api.js'; |
||||
export default { |
||||
data() { |
||||
return { |
||||
typeId: '', |
||||
inputAmountId: '', |
||||
inputAmount: '', |
||||
orderPrice:'', |
||||
inputPhone: '', |
||||
amoutType: '', |
||||
codesVlues: '', |
||||
amountList: [], |
||||
amoutstatus:'' |
||||
} |
||||
}, |
||||
onLoad(options) { |
||||
this.typeId = options.id; |
||||
if (this.typeId == 1) { |
||||
uni.setNavigationBarTitle({ |
||||
title: '中国移动' |
||||
}) |
||||
this.amoutType = 2; |
||||
this.getListOutRechargePrice(2); |
||||
return; |
||||
} |
||||
if (this.typeId == 2) { |
||||
uni.setNavigationBarTitle({ |
||||
title: '中国电信' |
||||
}) |
||||
this.amoutType = 1; |
||||
this.getListOutRechargePrice(1); |
||||
return; |
||||
} |
||||
if (this.typeId == 3) { |
||||
uni.setNavigationBarTitle({ |
||||
title: '中国联通' |
||||
}) |
||||
this.amoutType = 3; |
||||
this.getListOutRechargePrice(3); |
||||
return; |
||||
} |
||||
|
||||
|
||||
}, |
||||
methods: { |
||||
select(amoutinfos) { |
||||
this.inputAmount = amoutinfos.realPrice; |
||||
this.orderPrice = amoutinfos.price; |
||||
this.inputAmountId = amoutinfos.id; |
||||
this.amoutstatus = amoutinfos.status; |
||||
}, |
||||
|
||||
/** |
||||
* 查询价格 |
||||
*/ |
||||
getListOutRechargePrice(item) { |
||||
uni.showLoading({ |
||||
title: '加载中...' |
||||
}) |
||||
let params = { |
||||
type: item, |
||||
regionId: app.globalData.cityId, |
||||
showType: 3 |
||||
} |
||||
getListOutRechargePrice(params).then(res => { |
||||
uni.hideLoading() |
||||
if (res.return_code == '000000') { |
||||
<view v-if="current == 1"> |
||||
<view class="mart5 width80 font14 fcoreb5 fontwig6" style="list-style-type: decimal;"> |
||||
<view style="width: 5%;" class="flleft">1:</view> |
||||
<view style="margin-left: 5%;">充值后6小时内到账,请耐心等待;如遇月初、月末运营商充值压力大,充值失败后,系统会为您自动再提交一次,如二次充值仍然失败,系统将会自动为您退款至原账户,请悉知。 |
||||
</view> |
||||
</view> |
||||
<view class="mart5 width80 font14 fcor999 fontwig6" style="list-style-type: decimal;"> |
||||
<view style="width: 5%;" class="flleft">2:</view> |
||||
<view style="margin-left: 5%;"> |
||||
目前仅支持(移动、联通、电信三网号段),运营商黑名单号码(长期欠费或非实名制认证)携号转网空号、虚拟卡(如165167170171162等等虚拟号段)副卡号码或做过某些特殊套餐绑定的卡暂不支持充值,请勿下单。 |
||||
</view> |
||||
</view> |
||||
<view class="mart5 width80 font14 fcor999 fontwig6" style="list-style-type: decimal;"> |
||||
<view style="width: 5%;" class="flleft">3:</view> |
||||
<view style="margin-left: 5%;">停机号码需要额外补缴欠费后,慢充话费才能到账。此服务为虚拟充值类服务,无特殊情况不支持退款,下单前请确认充值的号码无误。</view> |
||||
</view> |
||||
<view class="mart5 width80 font14 fcor999 fontwig6" style="list-style-type: decimal;"> |
||||
<view style="width: 5%;" class="flleft">4:</view> |
||||
<view style="margin-left: 5%;">空号、错号充值后不支持退款,请您务必核对确认号码无误后再进行充值。非空号欠费可充,欠费1个月导致空号的不能充值,损失自负无法退款。</view> |
||||
</view> |
||||
<view class="mart5 width80 font14 fcor999 fontwig6" style="list-style-type: decimal;"> |
||||
<view style="width: 5%;" class="flleft">5:</view> |
||||
<view style="margin-left: 5%;"><text |
||||
class="fcoreb5">本充值业务不提供发票。</text>如需发票请在运营商手机客户端储开取电子发票,也可以凭身份证到运营商实体营业厅打印发票。</view> |
||||
</view> |
||||
<view class="mart5 width80 font14 fcor999 fontwig6" style="list-style-type: decimal;"> |
||||
<view style="width: 5%;" class="flleft">6:</view> |
||||
<view style="margin-left: 5%;">如遇系统维护充值失败,将72小时后原路退款到付款账户。 |
||||
</view> |
||||
</view> |
||||
<view class="mart5 width80 font14 fcor999 fontwig6" style="list-style-type: decimal;"> |
||||
<view style="width: 5%;" class="flleft">7:</view> |
||||
<view style="margin-left: 5%;">请登录所属运营商app(手机营业厅)查看充值号码的到账情况,如金额有出入或未到账,请截图充值记录明细反馈给客服。录明细反馈给客服。</view> |
||||
</view> |
||||
</view> |
||||
<view class="height100p"></view> |
||||
<view class="bombtn width94 font16"> |
||||
<view class="width50 flleft payem">应付: {{inputAmount}}元</view> |
||||
<view class="width50 flright paybtn" @click="addOrderPay">立即购买</view> |
||||
</view> |
||||
</view> |
||||
</template> |
||||
|
||||
<script> |
||||
let app = getApp(); |
||||
import { |
||||
getListOutRechargePrice, |
||||
addOrderPay, |
||||
orderToUnionPayphone |
||||
} from '../../../Utils/Api.js'; |
||||
import QSTabs from '../../../components/QS-tabs/QS-tabs.vue'; |
||||
export default { |
||||
components: { |
||||
QSTabs |
||||
}, |
||||
data() { |
||||
return { |
||||
typeId: '', |
||||
inputAmountId: '', |
||||
inputAmount: '', |
||||
orderPrice: '', |
||||
inputPhone: '', |
||||
amoutType: '', |
||||
codesVlues: '', |
||||
amountList: [], |
||||
amoutstatus: '', |
||||
tabs: ["72小时到账", "6小时到账"], //切换操作 |
||||
current: 0, //默认 |
||||
swiperCurrent: 2 |
||||
} |
||||
}, |
||||
onLoad(options) { |
||||
this.typeId = options.id; |
||||
if (this.typeId == 1) { |
||||
uni.setNavigationBarTitle({ |
||||
title: '中国移动' |
||||
}) |
||||
this.amoutType = 2; |
||||
this.getListOutRechargePrice(2); |
||||
return; |
||||
} |
||||
if (this.typeId == 2) { |
||||
uni.setNavigationBarTitle({ |
||||
title: '中国电信' |
||||
}) |
||||
this.amoutType = 1; |
||||
this.getListOutRechargePrice(1); |
||||
return; |
||||
} |
||||
if (this.typeId == 3) { |
||||
uni.setNavigationBarTitle({ |
||||
title: '中国联通' |
||||
}) |
||||
this.amoutType = 3; |
||||
this.getListOutRechargePrice(3); |
||||
return; |
||||
} |
||||
|
||||
|
||||
}, |
||||
methods: { |
||||
select(amoutinfos) { |
||||
this.inputAmount = amoutinfos.realPrice; |
||||
this.orderPrice = amoutinfos.price; |
||||
this.inputAmountId = amoutinfos.id; |
||||
this.amoutstatus = amoutinfos.status; |
||||
}, |
||||
//筛选 |
||||
change(index) { |
||||
this.$refs.tabs.setFinishCurrent(index); |
||||
this.current = index; |
||||
this.inputAmount = ''; |
||||
this.amoutstatus = ''; |
||||
if (index == 0) { |
||||
this.swiperCurrent = 2; |
||||
this.getListOutRechargePrice(this.amoutType); |
||||
} else { |
||||
this.swiperCurrent = 1; |
||||
this.getListOutRechargePrice(this.amoutType); |
||||
} |
||||
}, |
||||
/** |
||||
* 查询价格 |
||||
*/ |
||||
getListOutRechargePrice(item) { |
||||
uni.showLoading({ |
||||
title: '加载中...' |
||||
}) |
||||
let params = { |
||||
type: item, |
||||
regionId: app.globalData.cityId, |
||||
showType: 3, |
||||
rechargeType: this.swiperCurrent |
||||
} |
||||
getListOutRechargePrice(params).then(res => { |
||||
uni.hideLoading() |
||||
if (res.return_code == '000000' && res.return_data) { |
||||
this.amountList = res.return_data; |
||||
} |
||||
}) |
||||
}, |
||||
|
||||
/** |
||||
* 提交订单 |
||||
*/ |
||||
addOrderPay() { |
||||
if(this.amoutstatus == 2){ |
||||
uni.showToast({ |
||||
title: '当前面值已售空', |
||||
duration:2000, |
||||
icon: "none" |
||||
}); |
||||
return; |
||||
} else { |
||||
this.amountList = []; |
||||
} |
||||
}) |
||||
}, |
||||
|
||||
/** |
||||
* 提交订单 |
||||
*/ |
||||
addOrderPay() { |
||||
if (this.amoutstatus == 2) { |
||||
uni.showToast({ |
||||
title: '当前面值已售空', |
||||
duration: 2000, |
||||
icon: "none" |
||||
}); |
||||
return; |
||||
} |
||||
if (this.inputPhone == '') { |
||||
uni.showToast({ |
||||
title: '请输入充值号码', |
||||
icon: "none" |
||||
}); |
||||
return; |
||||
} |
||||
if (this.inputPhone == '') { |
||||
if (this.inputPhone.length != 11) { |
||||
uni.showToast({ |
||||
title: '请输入充值号码', |
||||
title: '请输入正确充值号码', |
||||
icon: "none" |
||||
}); |
||||
return; |
||||
} |
||||
if (this.inputAmount == '') { |
||||
uni.showToast({ |
||||
title: '请选择价格', |
||||
icon: "none" |
||||
}); |
||||
return false; |
||||
} |
||||
let params = { |
||||
"orderPrice": this.orderPrice, |
||||
"payPrice": this.inputAmount, |
||||
"rechargeContent": this.inputPhone, |
||||
"rechargeModel": this.amoutType, |
||||
"agentKey": this.codesVlues, |
||||
"objectId": this.inputAmountId, |
||||
} |
||||
uni.showLoading({ |
||||
title: '加载中...' |
||||
}) |
||||
addOrderPay(params).then(res => { |
||||
uni.hideLoading() |
||||
if (res.return_code == '000000') { |
||||
this.orderToUnionPayphone(res.return_data.id); |
||||
|
||||
} else { |
||||
uni.showToast({ |
||||
title: res.return_msg, |
||||
icon: "none" |
||||
}) |
||||
} |
||||
}) |
||||
}, |
||||
//获取订单信息 |
||||
orderToUnionPayphone(item) { |
||||
let params = { |
||||
"orderId" : item |
||||
} |
||||
orderToUnionPayphone(params).then(res => { |
||||
if (res.return_code == '000000') { |
||||
this.uniontopay(res.return_data.prepayid); |
||||
} else { |
||||
uni.showToast({ |
||||
title: res.return_msg, |
||||
icon: 'none' |
||||
}) |
||||
} |
||||
}) |
||||
}, |
||||
//银联支付 |
||||
uniontopay(item) { |
||||
let that = this; |
||||
upsdk.pluginReady(function() { |
||||
upsdk.pay({ |
||||
tn: item, |
||||
success: function(res) { |
||||
uni.showToast({ |
||||
title: '支付成功' |
||||
}) |
||||
uni.reLaunch({ |
||||
url: '/pages/tabBar/user/user' |
||||
}); |
||||
}, |
||||
fail: function(err) { |
||||
uni.showToast({ |
||||
title: err.msg, |
||||
icon: 'none', |
||||
duration: 2000 |
||||
}) |
||||
// 支付失败, err.msg 是失败原因描述, 比如TN号不合法, 或者用户取消了交易 等等。 |
||||
} |
||||
}); |
||||
}); |
||||
}, |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style lang="scss"> |
||||
.block { |
||||
width: 94%; |
||||
padding: 60upx 3%; |
||||
|
||||
.my { |
||||
width: 80%; |
||||
height: 120upx; |
||||
display: flex; |
||||
align-items: center; |
||||
} |
||||
|
||||
.uni-input-placeholder { |
||||
color: #FFFFFF; |
||||
} |
||||
} |
||||
|
||||
.list { |
||||
width: 94%; |
||||
margin-left: 3%; |
||||
display: flow-root; |
||||
justify-content: space-between; |
||||
align-items: center; |
||||
padding: 20upx 0; |
||||
|
||||
.box { |
||||
width: 30%; |
||||
margin-left: 1%; |
||||
margin-right: 2%; |
||||
margin-top: 20upx; |
||||
float: left; |
||||
height: 120upx; |
||||
// line-height: 120upx; |
||||
display: inline-grid; |
||||
justify-content: center; |
||||
align-items: center; |
||||
text-align: center; |
||||
box-shadow: 0upx 0upx 4upx #666666; |
||||
font-size: 36upx; |
||||
color: #089bf5; |
||||
|
||||
&.on { |
||||
background-color: #089bf5; |
||||
color: #ffffff; |
||||
} |
||||
} |
||||
|
||||
.heTitle { |
||||
width: 100%; |
||||
font-size: 15px; |
||||
} |
||||
} |
||||
|
||||
.bombtn { |
||||
position: fixed; |
||||
height: 45px; |
||||
bottom: 20px; |
||||
border-radius: 6px; |
||||
|
||||
.payem { |
||||
height: 45px; |
||||
line-height: 45px; |
||||
text-align: center; |
||||
background-color: #007AFF; |
||||
color: #FFFFFF; |
||||
border-radius: 6px 0 0 6px; |
||||
} |
||||
|
||||
.paybtn { |
||||
height: 45px; |
||||
line-height: 45px; |
||||
text-align: center; |
||||
background-color: #F8A628; |
||||
border-radius: 0 6px 6px 0; |
||||
color: #FFFFFF; |
||||
} |
||||
} |
||||
} |
||||
if (this.inputAmount == '') { |
||||
uni.showToast({ |
||||
title: '请选择价格', |
||||
icon: "none" |
||||
}); |
||||
return false; |
||||
} |
||||
let params = { |
||||
"orderPrice": this.orderPrice, |
||||
"payPrice": this.inputAmount, |
||||
"rechargeContent": this.inputPhone, |
||||
"rechargeModel": this.amoutType, |
||||
"agentKey": this.codesVlues, |
||||
"objectId": this.inputAmountId, |
||||
} |
||||
uni.showLoading({ |
||||
title: '加载中...' |
||||
}) |
||||
addOrderPay(params).then(res => { |
||||
uni.hideLoading() |
||||
if (res.return_code == '000000') { |
||||
this.orderToUnionPayphone(res.return_data.id); |
||||
|
||||
} else { |
||||
uni.showToast({ |
||||
title: res.return_msg, |
||||
icon: "none" |
||||
}) |
||||
} |
||||
}) |
||||
}, |
||||
//获取订单信息 |
||||
orderToUnionPayphone(item) { |
||||
let params = { |
||||
"orderId": item |
||||
} |
||||
orderToUnionPayphone(params).then(res => { |
||||
if (res.return_code == '000000') { |
||||
this.uniontopay(res.return_data.prepayid); |
||||
} else { |
||||
uni.showToast({ |
||||
title: res.return_msg, |
||||
icon: 'none' |
||||
}) |
||||
} |
||||
}) |
||||
}, |
||||
//银联支付 |
||||
uniontopay(item) { |
||||
let that = this; |
||||
upsdk.pluginReady(function() { |
||||
upsdk.pay({ |
||||
tn: item, |
||||
success: function(res) { |
||||
uni.showToast({ |
||||
title: '支付成功' |
||||
}) |
||||
uni.reLaunch({ |
||||
url: '/pages/tabBar/user/user' |
||||
}); |
||||
}, |
||||
fail: function(err) { |
||||
uni.showToast({ |
||||
title: err.msg, |
||||
icon: 'none', |
||||
duration: 2000 |
||||
}) |
||||
// 支付失败, err.msg 是失败原因描述, 比如TN号不合法, 或者用户取消了交易 等等。 |
||||
} |
||||
}); |
||||
}); |
||||
}, |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style lang="scss"> |
||||
.block { |
||||
width: 94%; |
||||
padding: 60upx 3%; |
||||
|
||||
.my { |
||||
width: 80%; |
||||
height: 120upx; |
||||
display: flex; |
||||
align-items: center; |
||||
} |
||||
|
||||
.uni-input-placeholder { |
||||
color: #FFFFFF; |
||||
} |
||||
} |
||||
|
||||
.list { |
||||
width: 94%; |
||||
margin-left: 3%; |
||||
display: flow-root; |
||||
justify-content: space-between; |
||||
align-items: center; |
||||
padding: 20upx 0; |
||||
|
||||
.box { |
||||
width: 30%; |
||||
margin-left: 1%; |
||||
margin-right: 2%; |
||||
margin-top: 20upx; |
||||
float: left; |
||||
height: 120upx; |
||||
// line-height: 120upx; |
||||
display: inline-grid; |
||||
justify-content: center; |
||||
align-items: center; |
||||
text-align: center; |
||||
box-shadow: 0upx 0upx 4upx #666666; |
||||
font-size: 36upx; |
||||
color: #089bf5; |
||||
|
||||
&.on { |
||||
background-color: #089bf5; |
||||
color: #ffffff; |
||||
} |
||||
} |
||||
|
||||
.heTitle { |
||||
width: 100%; |
||||
font-size: 15px; |
||||
} |
||||
} |
||||
|
||||
.bombtn { |
||||
position: fixed; |
||||
height: 45px; |
||||
bottom: 20px; |
||||
border-radius: 6px; |
||||
|
||||
.payem { |
||||
height: 45px; |
||||
line-height: 45px; |
||||
text-align: center; |
||||
background-color: #007AFF; |
||||
color: #FFFFFF; |
||||
border-radius: 6px 0 0 6px; |
||||
} |
||||
|
||||
.paybtn { |
||||
height: 45px; |
||||
line-height: 45px; |
||||
text-align: center; |
||||
background-color: #F8A628; |
||||
border-radius: 0 6px 6px 0; |
||||
color: #FFFFFF; |
||||
} |
||||
} |
||||
</style> |
||||
|
@ -1,398 +1,336 @@ |
||||
<template> |
||||
<view> |
||||
<view class="block"> |
||||
<view class="content"> |
||||
<view class="my"> |
||||
我的账户余额: {{user.gold}} 个 ( 1:100) |
||||
</view> |
||||
</view> |
||||
</view> |
||||
<view class="block"> |
||||
<view class="title"> |
||||
充值金额 |
||||
</view> |
||||
<view class="content"> |
||||
<view class="amount"> |
||||
<view class="list"> |
||||
<view class="box" v-for="(amount,index) in amountList" :key="index" @tap="select(amount)" |
||||
:class="{'on':amount == inputAmount}"> |
||||
{{amount}}元 |
||||
</view> |
||||
</view> |
||||
<view class="num"> |
||||
<view class="text"> |
||||
自定义充值金额 |
||||
</view> |
||||
<view class="input"> |
||||
<input type="number" v-model="inputAmount" /> |
||||
</view> |
||||
</view> |
||||
</view> |
||||
</view> |
||||
</view> |
||||
<view class="block"> |
||||
<view class="title"> |
||||
选择支付方式 |
||||
</view> |
||||
<view class="content"> |
||||
<view class="pay-list"> |
||||
<!-- <view class="row" @tap="paytype='alipay'"> |
||||
<view class="left"> |
||||
<image src="/static/img/alipay.png"></image> |
||||
</view> |
||||
<view class="center"> |
||||
支付宝支付 |
||||
</view> |
||||
<view class="right"> |
||||
<radio :checked="paytype=='alipay'" color="#0083f5" /> |
||||
</view> |
||||
</view> --> |
||||
<view class="row" @tap="paytype='wxpay'"> |
||||
<view class="left"> |
||||
<image :src="imagewxUrl+imgadres"></image> |
||||
</view> |
||||
<view class="center"> |
||||
微信支付 |
||||
</view> |
||||
<view class="right"> |
||||
<radio :checked="paytype=='wxpay'" color="#0083f5" /> |
||||
</view> |
||||
</view> |
||||
</view> |
||||
</view> |
||||
</view> |
||||
<view class="pay"> |
||||
<button class="btn" @tap="doDeposit">立即充值</button> |
||||
<view class="tis"> |
||||
点击立即充值,即代表您同意<view class="terms"> |
||||
《条款协议》 |
||||
</view> |
||||
</view> |
||||
</view> |
||||
</view> |
||||
</template> |
||||
|
||||
<script> |
||||
let app = getApp() |
||||
import { |
||||
addOrder, |
||||
orderToPay |
||||
} from "../../../Utils/Api.js"; |
||||
// #ifdef H5 |
||||
var jweixin = require('jweixin-module'); |
||||
// #endif |
||||
export default { |
||||
data() { |
||||
return { |
||||
inputAmount: '', //金额 |
||||
amountList: [10, 50, 100], //预设3个可选快捷金额 |
||||
paytype: 'wxpay', //支付类型 |
||||
user: "", |
||||
imagewxUrl: app.globalData.imageWxImg, |
||||
imgadres:'wxpay.png' |
||||
}; |
||||
}, |
||||
onLoad() { |
||||
this.user = app.globalData.userInfo |
||||
}, |
||||
methods: { |
||||
|
||||
select(amount) { |
||||
this.inputAmount = amount; |
||||
}, |
||||
doDeposit() { |
||||
if (parseFloat(this.inputAmount).toString() == "NaN") { |
||||
uni.showToast({ |
||||
title: '请输入正确金额', |
||||
icon: 'none' |
||||
}); |
||||
return; |
||||
} |
||||
if (this.inputAmount <= 0) { |
||||
uni.showToast({ |
||||
title: '请输入大于0的金额', |
||||
icon: 'none' |
||||
}); |
||||
return; |
||||
} |
||||
if (parseFloat(this.inputAmount).toFixed(2) != parseFloat(this.inputAmount)) { |
||||
uni.showToast({ |
||||
title: '最多只能输入两位小数哦~', |
||||
icon: 'none' |
||||
}); |
||||
return; |
||||
} |
||||
uni.showLoading({ |
||||
title: '正在提交订单...' |
||||
}) |
||||
let goods = { |
||||
"identificationCode":app.globalData.identificationCode, |
||||
"highChildOrderList": [{ |
||||
"goodsType": 2, |
||||
"goodsId": app.globalData.userInfo.id, |
||||
"saleCount": 1, |
||||
"goodsPrice": this.inputAmount |
||||
}] |
||||
} |
||||
addOrder(goods).then(res => { |
||||
uni.hideLoading(); |
||||
if (res.return_code == '000000') { |
||||
//模板模拟支付,实际应用请调起微信/支付宝 |
||||
let params = { |
||||
"orderId": res.return_data.id, |
||||
"openId": app.globalData.openId, |
||||
"orderScene": "GOODS_ORDER" |
||||
} |
||||
orderToPay(params).then(res => { |
||||
if (res.return_code == '000000') { |
||||
// #ifdef MP |
||||
uni.showLoading({ |
||||
title: '支付中...' |
||||
}) |
||||
uni.requestPayment({ |
||||
"appId": res.return_data.appId, |
||||
"nonceStr": res.return_data.nonceStr, |
||||
"package": res.return_data.package, |
||||
"paySign": res.return_data.sign, |
||||
"signType": "MD5", |
||||
"timeStamp": res.return_data.timeStamp, |
||||
success: function(res) { |
||||
uni.hideLoading(); |
||||
uni.showToast({ |
||||
title: '支付成功' |
||||
}) |
||||
setTimeout(() => { |
||||
uni.navigateBack({}) |
||||
}, 100) |
||||
}, |
||||
fail: function(err) { |
||||
uni.hideLoading(); |
||||
console.log('fail:' + JSON.stringify(err)); |
||||
} |
||||
}); |
||||
// #endif |
||||
|
||||
//判断是否是公众号 |
||||
// #ifdef H5 |
||||
//判断微信浏览器 |
||||
this.payRequest(res); |
||||
// #endif |
||||
} else { |
||||
uni.showToast({ |
||||
title: '支付失败' |
||||
}) |
||||
} |
||||
}) |
||||
|
||||
|
||||
} else { |
||||
uni.showToast({ |
||||
title: res.return_msg |
||||
}); |
||||
} |
||||
}) |
||||
}, |
||||
payRequest: function(self) { |
||||
uni.showLoading({ |
||||
title: '支付中...' |
||||
}) |
||||
jweixin.config({ |
||||
// debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 |
||||
appId: self.return_data.appId, // 必填,公众号的唯一标识 |
||||
timestamp: self.return_data.timeStamp, // 必填,生成签名的时间戳 |
||||
nonceStr: self.return_data.nonceStr, // 必填,生成签名的随机串 |
||||
signature: self.return_data.sign, // 必填,签名,见附录1 |
||||
jsApiList: ['chooseWXPay'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2 |
||||
}); |
||||
uni.hideLoading(); |
||||
jweixin.ready(function() { |
||||
jweixin.checkJsApi({ |
||||
jsApiList: ['chooseWXPay'], // 需要检测的JS接口列表,所有JS接口列表见附录2, |
||||
success: function(res) {}, |
||||
fail: function(res) {} |
||||
}); |
||||
jweixin.chooseWXPay({ |
||||
appId: self.return_data.appId, |
||||
timestamp: self.return_data |
||||
.timeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符 |
||||
nonceStr: self.return_data.nonceStr, // 支付签名随机串,不长于 32 位 |
||||
package: self.return_data |
||||
.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=***) |
||||
signType: 'MD5', // 签名方式,默认为'SHA1',使用新版支付需传入'MD5' |
||||
paySign: self.return_data.sign, // 支付签名 |
||||
success: function(res) { |
||||
// 支付成功后的回调函数 |
||||
uni.showToast({ |
||||
title: '支付成功' |
||||
}) |
||||
uni.reLaunch({ |
||||
url: '../success/success?id=' + that.couponId |
||||
}); |
||||
}, |
||||
cancel: function(r) {}, |
||||
fail: function(res) {} |
||||
}); |
||||
}); |
||||
|
||||
jweixin.error(function(res) { |
||||
uni.showToast({ |
||||
icon: 'none', |
||||
title: '支付失败了', |
||||
duration: 4000 |
||||
}); |
||||
}); |
||||
}, |
||||
}, |
||||
|
||||
} |
||||
</script> |
||||
|
||||
<style lang="scss"> |
||||
.block { |
||||
width: 94%; |
||||
padding: 20upx 3%; |
||||
|
||||
.title { |
||||
width: 100%; |
||||
font-size: 34upx; |
||||
} |
||||
|
||||
.content { |
||||
.my { |
||||
width: 100%; |
||||
height: 120upx; |
||||
display: flex; |
||||
align-items: center; |
||||
font-size: 30upx; |
||||
border-bottom: solid 1upx #eee; |
||||
} |
||||
|
||||
.amount { |
||||
width: 100%; |
||||
|
||||
.list { |
||||
display: flex; |
||||
justify-content: space-between; |
||||
padding: 20upx 0; |
||||
|
||||
.box { |
||||
width: 30%; |
||||
height: 120upx; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
border-radius: 10upx; |
||||
box-shadow: 0upx 5upx 20upx rgba(0, 0, 0, 0.05); |
||||
font-size: 36upx; |
||||
background-color: #f1f1f1; |
||||
color: 333; |
||||
|
||||
&.on { |
||||
background-color: #0083f5; |
||||
color: #fff; |
||||
} |
||||
} |
||||
} |
||||
|
||||
<template> |
||||
<view> |
||||
<view class="block"> |
||||
<view class="content"> |
||||
<view class="my"> |
||||
我的账户余额: {{user.gold}} 个 ( 1:100) |
||||
</view> |
||||
</view> |
||||
</view> |
||||
<view class="block"> |
||||
<view class="title"> |
||||
充值金额 |
||||
</view> |
||||
<view class="content"> |
||||
<view class="amount"> |
||||
<view class="list"> |
||||
<view class="box" v-for="(amount,index) in amountList" :key="index" @tap="select(amount)" |
||||
:class="{'on':amount == inputAmount}"> |
||||
{{amount}}元 |
||||
</view> |
||||
</view> |
||||
<view class="num"> |
||||
<view class="text"> |
||||
自定义充值金额 |
||||
</view> |
||||
<view class="input"> |
||||
<input type="number" v-model="inputAmount" /> |
||||
</view> |
||||
</view> |
||||
</view> |
||||
</view> |
||||
</view> |
||||
<view class="block"> |
||||
<view class="title"> |
||||
选择支付方式 |
||||
</view> |
||||
<view class="content"> |
||||
<view class="pay-list"> |
||||
<view class="row" @tap="paytype='wxpay'"> |
||||
<view class="left"> |
||||
<image mode="widthFix" style="border-radius: 50%;" src="../../../static/img/unionpay.png"> |
||||
</image> |
||||
</view> |
||||
<view class="center"> |
||||
银联支付 |
||||
</view> |
||||
<view class="right"> |
||||
<radio :checked="paytype=='wxpay'" color="#0083f5" /> |
||||
</view> |
||||
</view> |
||||
</view> |
||||
</view> |
||||
</view> |
||||
<view class="pay"> |
||||
<button class="btn" @tap="doDeposit">立即充值</button> |
||||
<view class="tis"> |
||||
点击立即充值,即代表您同意<view class="terms"> |
||||
《条款协议》 |
||||
</view> |
||||
</view> |
||||
</view> |
||||
</view> |
||||
</template> |
||||
|
||||
<script> |
||||
let app = getApp() |
||||
import { |
||||
addOrder, |
||||
orderToPay, |
||||
unionPay |
||||
} from "../../../Utils/Api.js"; |
||||
// #ifdef H5 |
||||
var jweixin = require('jweixin-module'); |
||||
// #endif |
||||
export default { |
||||
data() { |
||||
return { |
||||
inputAmount: '', //金额 |
||||
amountList: [100, 200, 300, 500, 800, 1000], //预设3个可选快捷金额 |
||||
paytype: 'wxpay', //支付类型 |
||||
user: "", |
||||
imagewxUrl: app.globalData.imageWxImg, |
||||
imgadres: 'wxpay.png' |
||||
}; |
||||
}, |
||||
onLoad() { |
||||
this.user = app.globalData.userInfo |
||||
}, |
||||
methods: { |
||||
|
||||
select(amount) { |
||||
this.inputAmount = amount; |
||||
}, |
||||
doDeposit() { |
||||
if (parseFloat(this.inputAmount).toString() == "NaN") { |
||||
uni.showToast({ |
||||
title: '请输入正确金额', |
||||
icon: 'none' |
||||
}); |
||||
return; |
||||
} |
||||
if (this.inputAmount <= 0) { |
||||
uni.showToast({ |
||||
title: '请输入大于0的金额', |
||||
icon: 'none' |
||||
}); |
||||
return; |
||||
} |
||||
if (parseFloat(this.inputAmount).toFixed(2) != parseFloat(this.inputAmount)) { |
||||
uni.showToast({ |
||||
title: '最多只能输入两位小数哦~', |
||||
icon: 'none' |
||||
}); |
||||
return; |
||||
} |
||||
uni.showLoading({ |
||||
title: '正在提交订单...' |
||||
}) |
||||
let goods = { |
||||
"identificationCode": app.globalData.identificationCode, |
||||
"highChildOrderList": [{ |
||||
"goodsType": 2, |
||||
"goodsId": app.globalData.userInfo.id, |
||||
"saleCount": 1, |
||||
"goodsPrice": this.inputAmount |
||||
}] |
||||
} |
||||
addOrder(goods).then(res => { |
||||
uni.hideLoading(); |
||||
if (res.return_code == '000000') { |
||||
//模板模拟支付,实际应用请调起微信/支付宝 |
||||
this.unionPay(res.return_data.id); |
||||
} else { |
||||
uni.showToast({ |
||||
title: res.return_msg |
||||
}); |
||||
} |
||||
}) |
||||
}, |
||||
//银联获取信息 |
||||
unionPay(item) { |
||||
let goods = { |
||||
"orderId": item |
||||
} |
||||
unionPay(goods).then(res => { |
||||
if (res.return_code == '000000') { |
||||
this.uniontopay(res.return_data.prepayid); |
||||
} else { |
||||
uni.showToast({ |
||||
title: res.return_msg, |
||||
icon: 'none', |
||||
duration: 2000 |
||||
}); |
||||
} |
||||
}) |
||||
}, |
||||
//银联支付 |
||||
uniontopay(item) { |
||||
let that = this; |
||||
upsdk.pluginReady(function() { |
||||
upsdk.pay({ |
||||
tn: item, |
||||
success: function(res) { |
||||
uni.showToast({ |
||||
title: '支付成功' |
||||
}) |
||||
uni.navigateBack({}) |
||||
}, |
||||
fail: function(err) { |
||||
uni.showToast({ |
||||
title: err.msg, |
||||
icon: 'none', |
||||
duration: 2000 |
||||
}) |
||||
// 支付失败, err.msg 是失败原因描述, 比如TN号不合法, 或者用户取消了交易 等等。 |
||||
} |
||||
}); |
||||
}); |
||||
} |
||||
}, |
||||
|
||||
} |
||||
</script> |
||||
|
||||
<style lang="scss"> |
||||
.block { |
||||
width: 94%; |
||||
padding: 20upx 3%; |
||||
|
||||
.title { |
||||
width: 100%; |
||||
font-size: 34upx; |
||||
} |
||||
|
||||
.content { |
||||
.my { |
||||
width: 100%; |
||||
height: 120upx; |
||||
display: flex; |
||||
align-items: center; |
||||
font-size: 30upx; |
||||
border-bottom: solid 1upx #eee; |
||||
} |
||||
|
||||
.amount { |
||||
width: 100%; |
||||
|
||||
.list { |
||||
display: flow-root; |
||||
justify-content: space-between; |
||||
padding: 20upx 0; |
||||
|
||||
.box { |
||||
width: 30%; |
||||
height: 120rpx; |
||||
float: left; |
||||
margin-left: 3.333%; |
||||
margin-top: 20px; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
border-radius: 10rpx; |
||||
box-shadow: 0rpx 5rpx 20rpx rgba(0, 0, 0, 0.05); |
||||
font-size: 36rpx; |
||||
background-color: #f1f1f1; |
||||
color: 333; |
||||
|
||||
&.on { |
||||
background-color: #0083f5; |
||||
color: #fff; |
||||
} |
||||
} |
||||
} |
||||
|
||||
.num { |
||||
margin-top: 10upx; |
||||
margin-top: 20upx; |
||||
display: flex; |
||||
justify-content: flex-end; |
||||
align-items: center; |
||||
|
||||
|
||||
.text { |
||||
padding-right: 10upx; |
||||
font-size: 30upx; |
||||
font-size: 40upx; |
||||
} |
||||
|
||||
|
||||
.input { |
||||
width: 28.2vw; |
||||
border-bottom: solid 2upx #999; |
||||
|
||||
|
||||
justify-content: flex-end; |
||||
align-items: center; |
||||
|
||||
|
||||
input { |
||||
margin: 0 20upx; |
||||
height: 60upx; |
||||
font-size: 30upx; |
||||
font-size: 40upx; |
||||
color: #0083f5; |
||||
justify-content: flex-end; |
||||
align-items: center; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
.pay-list { |
||||
width: 100%; |
||||
border-bottom: solid 1upx #eee; |
||||
|
||||
.row { |
||||
width: 100%; |
||||
height: 120upx; |
||||
display: flex; |
||||
align-items: center; |
||||
|
||||
.left { |
||||
width: 100upx; |
||||
flex-shrink: 0; |
||||
display: flex; |
||||
align-items: center; |
||||
|
||||
image { |
||||
width: 80upx; |
||||
height: 80upx; |
||||
} |
||||
} |
||||
|
||||
.center { |
||||
width: 100%; |
||||
font-size: 30upx; |
||||
} |
||||
|
||||
.right { |
||||
width: 100upx; |
||||
flex-shrink: 0; |
||||
display: flex; |
||||
justify-content: flex-end; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
.pay { |
||||
margin-top: 20upx; |
||||
width: 100%; |
||||
display: flex; |
||||
justify-content: center; |
||||
flex-wrap: wrap; |
||||
|
||||
.btn { |
||||
width: 70%; |
||||
height: 80upx; |
||||
border-radius: 80upx; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
color: #fff; |
||||
background-color: #0083f5; |
||||
box-shadow: 0upx 5upx 10upx rgba(0, 0, 0, 0.2); |
||||
} |
||||
|
||||
.tis { |
||||
margin-top: 10upx; |
||||
width: 100%; |
||||
font-size: 24upx; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: baseline; |
||||
color: #999; |
||||
|
||||
.terms { |
||||
color: #5a9ef7; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
.pay-list { |
||||
width: 100%; |
||||
border-bottom: solid 1upx #eee; |
||||
|
||||
.row { |
||||
width: 100%; |
||||
height: 120upx; |
||||
display: flex; |
||||
align-items: center; |
||||
|
||||
.left { |
||||
width: 100upx; |
||||
flex-shrink: 0; |
||||
display: flex; |
||||
align-items: center; |
||||
|
||||
image { |
||||
width: 80upx; |
||||
height: 80upx; |
||||
} |
||||
} |
||||
|
||||
.center { |
||||
width: 100%; |
||||
font-size: 30upx; |
||||
} |
||||
|
||||
.right { |
||||
width: 100upx; |
||||
flex-shrink: 0; |
||||
display: flex; |
||||
justify-content: flex-end; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
.pay { |
||||
margin-top: 20upx; |
||||
width: 100%; |
||||
display: flex; |
||||
justify-content: center; |
||||
flex-wrap: wrap; |
||||
|
||||
.btn { |
||||
width: 70%; |
||||
height: 80upx; |
||||
border-radius: 80upx; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
color: #fff; |
||||
background-color: #0083f5; |
||||
box-shadow: 0upx 5upx 10upx rgba(0, 0, 0, 0.2); |
||||
} |
||||
|
||||
.tis { |
||||
margin-top: 10upx; |
||||
width: 100%; |
||||
font-size: 24upx; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: baseline; |
||||
color: #999; |
||||
|
||||
.terms { |
||||
color: #5a9ef7; |
||||
} |
||||
} |
||||
} |
||||
</style> |
||||
|
Before Width: | Height: | Size: 405 KiB After Width: | Height: | Size: 153 KiB |
Loading…
Reference in new issue