|
@@ -2,28 +2,30 @@
|
|
|
<view class='app-container'>
|
|
|
<view class="header">
|
|
|
<view class="info" flex>
|
|
|
- <img class="dev-img" src="../../static/logo.png" />
|
|
|
+ <img class="dev-img" :src="info.devicePic" />
|
|
|
<view class="dev" flex column>
|
|
|
- <view class="dev-name">123</view>
|
|
|
- <view class="dev-history">开通记录<uni-icons type="right" color="#9fa5ad" size="11" /></view>
|
|
|
+ <view class="dev-name">{{ info.deviceName }}</view>
|
|
|
+ <view class="dev-history" @click="getRouter">开通记录<uni-icons type="right" color="#9fa5ad" size="11" /></view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="progress" flex column center>
|
|
|
- <progress :percent="50" activeColor="#FFD5A0" backgroundColor="#746C64" border-radius="20" />
|
|
|
+ <progress :percent="percent" activeColor="#FFD5A0" backgroundColor="#746C64" border-radius="20" />
|
|
|
<view class="progress-info" flex between>
|
|
|
- <text>已用:xxxM/剩余:xxxM</text>
|
|
|
- <text>总量:1GB</text>
|
|
|
+ <text>已用:{{ this.rateplan.used }}M / 剩余:{{ this.rateplan.left }}M</text>
|
|
|
+ <text>总量:{{ this.rateplan.total / 1024 }}G</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="main">
|
|
|
<view class="title">流量选择</view>
|
|
|
<view flex between>
|
|
|
- <view :class="['list', active === index ? 'active' : '']" v-for="(item, index) in options" :key="index" flex
|
|
|
- column between @click="getActive(index)">
|
|
|
- <view class="flow">{{ item.flow }}GB</view>
|
|
|
- <view class="discount icon">{{ item.discount }}</view>
|
|
|
- <view class="price icon">{{ item.price }}</view>
|
|
|
+ <view :class="['list', active === index ? 'active' : '']"
|
|
|
+ :style="{ 'width': `calc(${100 / options.length}% - 5px)` }" v-for="(item, index) in options" :key="index"
|
|
|
+ flex column between @click="getActive(index)" :data-content-before="item.operators"
|
|
|
+ :data-content-after="item.tagName">
|
|
|
+ <view class="flow">{{ item.name }}</view>
|
|
|
+ <view class="discount icon">{{ item.goodDiscountedPrice }}</view>
|
|
|
+ <view class="price icon">{{ item.goodPrice }}</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="explain" flex column>
|
|
@@ -43,33 +45,30 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { openId, wechatPay } from "@/api/pay"
|
|
|
+import { openId, wechatPay, detail, options } from "@/api/pay"
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
openId: '',
|
|
|
+ // 流量信息
|
|
|
+ info: {},
|
|
|
+ rateplan: {},
|
|
|
+ // 已用流量
|
|
|
+ percent: 0,
|
|
|
// 下单表单
|
|
|
form: {},
|
|
|
// 流量选择
|
|
|
- options: [{
|
|
|
- flow: 10,
|
|
|
- price: 29,
|
|
|
- discount: 20
|
|
|
- }, {
|
|
|
- flow: 20,
|
|
|
- price: 49,
|
|
|
- discount: 40
|
|
|
- }, {
|
|
|
- flow: 30,
|
|
|
- price: 69,
|
|
|
- discount: 60
|
|
|
- }],
|
|
|
+ options: [],
|
|
|
// 选择
|
|
|
- active: 0
|
|
|
+ active: 0,
|
|
|
+ state: ''
|
|
|
}
|
|
|
},
|
|
|
onLoad(e) {
|
|
|
+ this.state = e.state
|
|
|
this.getOpenId(e)
|
|
|
+ this.getDetail(e)
|
|
|
+ this.getOptions(e)
|
|
|
},
|
|
|
methods: {
|
|
|
// 获取openId
|
|
@@ -81,6 +80,25 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
|
|
|
+ // 流量信息
|
|
|
+ getDetail(e) {
|
|
|
+ detail({ state: e.state }).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.info = res.data
|
|
|
+ this.rateplan = res.data.rateplan
|
|
|
+ this.percent = this.rateplan.used / this.rateplan.total * 100
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ // 流量套餐
|
|
|
+ getOptions(e) {
|
|
|
+ options({ state: e.state }).then(res => {
|
|
|
+ this.options = res.data
|
|
|
+ res.data.map(i => document.documentElement.style.setProperty('——operators', i.operators))
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
// 选择套餐
|
|
|
getActive(index) {
|
|
|
this.active = index
|
|
@@ -89,7 +107,6 @@ export default {
|
|
|
// 下单
|
|
|
getWechatPay() {
|
|
|
wechatPay(this.openId).then(res => {
|
|
|
- console.log(JSON.parse(res.data));
|
|
|
if (res.code === 0) {
|
|
|
this.form = JSON.parse(res.data)
|
|
|
if (typeof WeixinJSBridge == 'undefined') {
|
|
@@ -113,6 +130,14 @@ export default {
|
|
|
// 支付成功刷新页面
|
|
|
}
|
|
|
})
|
|
|
+ },
|
|
|
+
|
|
|
+ // 开通记录
|
|
|
+ getRouter() {
|
|
|
+ console.log(1);
|
|
|
+ uni.navigateTo({
|
|
|
+ url: `/pages/pay/detail?state=${this.state}`,
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -176,12 +201,11 @@ export default {
|
|
|
.main {
|
|
|
padding: 0 32rpx;
|
|
|
|
|
|
- .active{
|
|
|
+ .active {
|
|
|
background-color: rgba(199, 170, 134, 0.12);
|
|
|
}
|
|
|
|
|
|
.list {
|
|
|
- width: calc(100% / 3 - 20rpx);
|
|
|
height: 268rpx;
|
|
|
border: 1px solid #C7AA86;
|
|
|
border-radius: 16rpx;
|
|
@@ -211,7 +235,7 @@ export default {
|
|
|
}
|
|
|
|
|
|
.list::before {
|
|
|
- content: '联通';
|
|
|
+ content: attr(data-content-before);
|
|
|
position: absolute;
|
|
|
left: -1px;
|
|
|
top: -1px;
|
|
@@ -223,7 +247,7 @@ export default {
|
|
|
}
|
|
|
|
|
|
.list::after {
|
|
|
- content: '限时优惠';
|
|
|
+ content: attr(data-content-after);
|
|
|
position: absolute;
|
|
|
left: 0px;
|
|
|
bottom: -1px;
|