Commit 992b34ca authored by liwei's avatar liwei

添加了金币相关接口

parent f242803e
...@@ -130,3 +130,26 @@ export function telMessage(data){ ...@@ -130,3 +130,26 @@ export function telMessage(data){
data, data,
}); });
} }
/**
* 充值金币
*/
export function payGoldCoins(data){
return request({
method: "post",
url: '/app/memGoldCoinFlow/add',
data,
});
}
/**
* 查询金币余额
*/
export function getBalance(data){
return request({
method: "get",
url: '/app/memGoldCoinFlow/balance',
data,
});
}
...@@ -270,6 +270,7 @@ import {articleList, getOssUrl} from "../../api/article"; ...@@ -270,6 +270,7 @@ import {articleList, getOssUrl} from "../../api/article";
if (this.info.memAuthCount == 2){ if (this.info.memAuthCount == 2){
this.authShow = false this.authShow = false
} }
this.button[0].num = this.info.goldCoinsCount
}) })
}, },
//获取动态列表,只获取最新的一条 //获取动态列表,只获取最新的一条
......
...@@ -29,11 +29,13 @@ ...@@ -29,11 +29,13 @@
</view> </view>
</view> </view>
<view class="bottom"> <view class="bottom">
<button class="btn" :loading="loading" @click="iosPayHandler">立即充值</button> <button class="btn" :loading="loading" @click="Pay">立即充值</button>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
import {getBalance, payGoldCoins} from "../../api/user";
let iapChannel = null // 苹果内部支付渠道 let iapChannel = null // 苹果内部支付渠道
export default { export default {
data() { data() {
...@@ -55,9 +57,14 @@ export default { ...@@ -55,9 +57,14 @@ export default {
price: 0, // 支付金额 price: 0, // 支付金额
courseIds: [], // 支付的课程ids courseIds: [], // 支付的课程ids
applePrice: 30, // ios充值金额 applePrice: 30, // ios充值金额
userId: null,//用户id
memberId:null//会员id
} }
}, },
onLoad: function(option) { onLoad(option) {
const userInfo = uni.getStorageSync("userInfo");
this.userId = userInfo.businessId
this.memberId = userInfo.memberId
// // 获取支付金额 // // 获取支付金额
// if (option.params) { // if (option.params) {
// const params = JSON.parse(option.params) // const params = JSON.parse(option.params)
...@@ -83,7 +90,50 @@ export default { ...@@ -83,7 +90,50 @@ export default {
// this.errorMsg() // this.errorMsg()
// }); // });
}, },
onShow(){
this.getCoinBalance()
},
methods: { methods: {
//查询金币余额
getCoinBalance(){
getBalance().then(res =>{
this.balance = res.data.data
}).catch(e => {
console.log(e)
})
},
//点击充值选项
clickItem(index, item) {
this.activeIndex = index
this.coinCount = item.coin
this.payMoney = item.price
},
//立即充值
Pay(){
const params = {
type:'1',//类型 1充值 2消费
balance: this.balance,//当前用户余额
count: this.coinCount,//充值的金币数
actionType:'10',//行为类型 10:用户充值 11:系统充值 20:点赞 21:发动态 22:留言 23:要微信联系方式 24:接收微信请求
targetId: this.userId,//目标用户id
memberId: this.memberId//当前用户会员id
}
payGoldCoins(params).then( res =>{
if (res.data.code == 200){
uni.showToast({
title: '充值成功',
icon: 'success'
})
//调用查余额接口
this.getCoinBalance()
} else {
uni.showToast({
title: res.data.message,
icon: 'none'
})
}
})
},
// requestOrder() { // requestOrder() {
// uni.showLoading({ // uni.showLoading({
// title: '检测支付环境...' // title: '检测支付环境...'
...@@ -130,10 +180,6 @@ export default { ...@@ -130,10 +180,6 @@ export default {
// showCancel: false // showCancel: false
// }) // })
// }, // },
clickItem(index, item) {
this.activeIndex = index
this.payMoney = item.price
},
async loadData() { async loadData() {
}, },
......
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