|
@@ -2,7 +2,9 @@
|
|
|
<view class='app-container'>
|
|
|
<view class="header">
|
|
|
<view class="info" flex>
|
|
|
- <img class="dev-img" :src="info.devicePic" />
|
|
|
+ <view class="dev-img" flex center>
|
|
|
+ <img :src="info.devicePic" />
|
|
|
+ </view>
|
|
|
<view class="dev" flex column>
|
|
|
<view class="dev-name">{{ info.deviceName }}</view>
|
|
|
<view class="dev-history" @click="getRouter">开通记录<uni-icons type="right" color="#9fa5ad" size="11" /></view>
|
|
@@ -21,7 +23,7 @@
|
|
|
<view flex between>
|
|
|
<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"
|
|
|
+ flex column between @click="getActive(item, index)" :data-content-before="item.operators"
|
|
|
:data-content-after="item.tagName">
|
|
|
<view class="flow">{{ item.name }}</view>
|
|
|
<view class="discount icon">{{ item.goodDiscountedPrice }}</view>
|
|
@@ -61,14 +63,16 @@ export default {
|
|
|
options: [],
|
|
|
// 选择
|
|
|
active: 0,
|
|
|
+ // 流量套餐id
|
|
|
+ goddsId: 0,
|
|
|
state: ''
|
|
|
}
|
|
|
},
|
|
|
onLoad(e) {
|
|
|
this.state = e.state
|
|
|
this.getOpenId(e)
|
|
|
- this.getDetail(e)
|
|
|
- this.getOptions(e)
|
|
|
+ this.getDetail()
|
|
|
+ this.getOptions()
|
|
|
},
|
|
|
methods: {
|
|
|
// 获取openId
|
|
@@ -81,8 +85,8 @@ export default {
|
|
|
},
|
|
|
|
|
|
// 流量信息
|
|
|
- getDetail(e) {
|
|
|
- detail({ state: e.state }).then(res => {
|
|
|
+ getDetail() {
|
|
|
+ detail({ state: this.state }).then(res => {
|
|
|
if (res.code === 0) {
|
|
|
this.info = res.data
|
|
|
this.rateplan = res.data.rateplan
|
|
@@ -92,23 +96,32 @@ export default {
|
|
|
},
|
|
|
|
|
|
// 流量套餐
|
|
|
- getOptions(e) {
|
|
|
- options({ state: e.state }).then(res => {
|
|
|
+ getOptions() {
|
|
|
+ options({ state: this.state }).then(res => {
|
|
|
this.options = res.data
|
|
|
+ this.goodsId = res.data[0].id
|
|
|
res.data.map(i => document.documentElement.style.setProperty('——operators', i.operators))
|
|
|
})
|
|
|
},
|
|
|
|
|
|
// 选择套餐
|
|
|
- getActive(index) {
|
|
|
+ getActive(item, index) {
|
|
|
this.active = index
|
|
|
+ this.goodsId = item.id
|
|
|
},
|
|
|
|
|
|
// 下单
|
|
|
getWechatPay() {
|
|
|
- wechatPay(this.openId).then(res => {
|
|
|
+ wechatPay({
|
|
|
+ openId: this.openId,
|
|
|
+ goodType: 18,
|
|
|
+ goodsId: this.goodsId,
|
|
|
+ ptype: 1,
|
|
|
+ state: this.state,
|
|
|
+ tradeType: 2
|
|
|
+ }).then(res => {
|
|
|
if (res.code === 0) {
|
|
|
- this.form = JSON.parse(res.data)
|
|
|
+ this.form = JSON.parse(res.data.wxOrder.formUrl)
|
|
|
if (typeof WeixinJSBridge == 'undefined') {
|
|
|
if (document.addEventListener) {
|
|
|
document.addEventListener('WeixinJSBridge', this.onBridgeReady(), false)
|
|
@@ -128,13 +141,13 @@ export default {
|
|
|
WeixinJSBridge.invoke('getBrandWCPayRequest', this.form, function (res) {
|
|
|
if (res.err_msg == "get_brand_wcpay_request:ok") {
|
|
|
// 支付成功刷新页面
|
|
|
+ this.getDetail()
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
|
|
|
// 开通记录
|
|
|
getRouter() {
|
|
|
- console.log(1);
|
|
|
uni.navigateTo({
|
|
|
url: `/pages/pay/detail?state=${this.state}`,
|
|
|
})
|
|
@@ -155,10 +168,16 @@ export default {
|
|
|
|
|
|
.info {
|
|
|
.dev-img {
|
|
|
+ background: rgba(0, 0, 0, 0.12);
|
|
|
width: 120rpx;
|
|
|
height: 120rpx;
|
|
|
border-radius: 50%;
|
|
|
margin: 64rpx 0 0 64rpx;
|
|
|
+
|
|
|
+ img {
|
|
|
+ width: 96rpx;
|
|
|
+ height: 96rpx;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
.dev {
|